aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/traversal.rs
Commit message (Collapse)AuthorAgeFilesLines
* layout: Correct damage propagation and style repair for repaint-only layout ↵Martin Robinson4 hours1-3/+2
| | | | | | | | | | | | | | | | | | | | | | (#37004) When making last-minute changes to the repaint-only layout pass, damage propagation was broken, meaning that full layout was always done. This change fixes that, meaning that times in the `blaster.html` test case now reflect those described in the original commit message from #36978. In addition, some style repair is now fixed: - `InlineFormattingContext`s now keep a `SharedInlineStyles` for the root of the IFC which is updated during style repair. - `BlockFormattingContext`s now properly update their style. These changes are verified by turning on repaint only layout for more properties in Stylo via servo/stylo#183. Testing: Manual performance testing via `blaster.html`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* layout: Add a repaint-only incremental layout mode (#36978)Martin Robinson7 days1-7/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | This change adds the simplest kind of incremental layout. When Servo detects that all style changes only require a repaint, only run stacking context tree and WebRender display list generation. This means that these kind of restyles do not need a re-layout. Instead, the existing box and fragment trees will be used and the styles of damaged nodes will be updated in their box and fragment tree nodes. This requires a new style repair DOM traversal for nodes that have had their style damaged. In addition, careful accounting of all the places where we store style must happen in order ot update those styles. Testing: This is covered by existing WPT tests as it should not change observable behavior. We have created a test case which shows a 50% speedup when run in Servo, even though there still a long way to go to match the speed of other browsers: https://gist.github.com/mrobinson/44ec87d028c0198917a7715a06dd98a0 Co-authored-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Structure reflow code to make it more modular (#36597)Martin Robinson2025-04-231-6/+2
| | | | | | | | | | | | This reworks the structure of reflow in `layout_thread_2020` in order to make it more modular. The goal here is to allow possibly adding a new fragment tree traversal and to, in general, make the code a bit more organized. Testing: This should not change any behavior so is covered by existing WPT tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Combine `layout_2020` and `layout_thread_2020` into a crate called ↵Martin Robinson2025-04-191-0/+74
| | | | | | | | | | | | | | | | | | `layout` (#36613) Now that legacy layout has been removed, the name `layout_2020` doesn't make much sense any longer, also it's 2025 now for better or worse. The split between the "layout thread" and "layout" also doesn't make as much sense since layout doesn't run on it's own thread. There's a possibility that it will in the future, but that should be something that the user of the crate controls rather than layout iself. This is part of the larger layout interface cleanup and optimization that @Looriool and I are doing. Testing: Covered by existing tests as this is just code movement. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Remove legacy layout (layout 2013) (#35943)Oriol Brufau2025-03-131-371/+0
| | | | | | We were already not compiling it and not running tests on it by default. So it's simpler to just completely remove it. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-2/+2
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* layout: Remove the obsolete layout tracing functionality (#35001)Martin Robinson2025-01-151-5/+1
| | | | | | | | | | | | | | | | | | | | There were two kinds of layout tracing controlled by the same debugging option: - modern layout: Functionality that dumped a JSON serialization of the layout tree before and after layout. - legacy layout: A scope based tracing that reported the process of layout in a structured way. I don't think anyone working on layout is using either of these two features. For modern layout requiring data structure to implement `serde` serialization is incredibly inconvenient and also generates a lot of extra code. We also have a more modern tracing functionality based on perfetto that we have started to use for layout and IMO it's actually being used and more robust. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Elide lifetimes where possible after rustup (#34824)Martin Robinson2025-01-031-6/+6
| | | | | | | | | The new version of rust allows us to elide some lifetimes and clippy is now complaining about this. This change elides them where possible and removes the clippy exceptions. Fixes #34804. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Replace .map_or(false with Option::is_some_and (#33468)Simon Wülker2024-09-161-1/+1
| | | Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* clippy: Fix warnings in `shared` and `config`, `fonts`, `layout`, and ↵Martin Robinson2024-07-041-1/+5
| | | | `layout_2020` components (#32674)
* script: Split style and layout data in DOM nodes (#31985)Martin Robinson2024-04-041-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change splits the style and layout data in DOM nodes that is populated by style and layout passes. This makes Servo's data design more like Gecko's. This allows: 1. Removing the various `StyleAndLayout` data structures used by layout. 2. Removing the `GetStyleAndLayoutData` and `GetStyleAndOpaqueLayoutData` traits. Accessing style and layout data are now just functions on the `LayoutNode` and `ThreadSafeLayoutNode` traits. 3. Styling now doesn't populate layout data. This is is postponed until layout itself. 4. Allows the DOM wrappers to no longer have to be generic over the layout data. This data was already stored using `std::any::Any` and the new code just makes layout responsible for downcasting. Cleaning up the generic type parameter in the DOM wrappers can happen in a followup change. The main benefit to all of this is that we should be able to remove unsafe creation of `ServoLayoutNode` in layout and `TrustedLayoutNodeAddress` entirely, because `ServoLayoutNode` will be able to be passed directly from script to layout. In addition, this removes one more abstraction layer from the layout DOM wrappers, making the code a lot more understandable. Note: This increases the measured size of DOM types, but the same data is stored. It's simply that before that data was stored behind a heap pointer.
* Lint layout_2013 with clippy (#31221)Oriol Brufau2024-01-301-1/+1
| | | | | | | | | * Lint layout_2013 with clippy CARGO_BUILD_RUSTC=rustc cargo clippy --fix -p layout_2013 --broken-code * ./mach fmt * Cosmetic adjustments
* Fix transform assertion failures in Layout 2013 and Layout 2020 (#30713)Martin Robinson2023-11-131-1/+1
| | | | | | | Layout asserts that it never creates stacking contexts that have a zero scale, yet it doesn't prevent the creation of those stacking contexts. This change stops their creation at an earlier stage. Fixes #30118.
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-8/+7
| | | | | * strict imports formatting * Reformat all imports
* remove `extern crate` (#30311)Samson2023-09-081-0/+1
| | | | | | | | | | | * remove extern crate * Update components/script_plugins/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Simplify our setup for font metric queries from styleOriol Brufau2023-05-111-1/+0
| | | | | | | | This is a backport of https://phabricator.services.mozilla.com/D157589, by Emilio Cobos Álvarez, plus some additions so that Servo compiles, and some parts from https://phabricator.services.mozilla.com/D144455. Should have no change in behavior.
* Fix some typosDirk Stolle2022-12-171-2/+2
| | | | Signed-off-by: Dirk Stolle <striezel-dev@web.de>
* layout: Don't built stacking contexts or display lists for empty blocks.Josh Matthews2020-06-091-0/+4
|
* Implement concept of dirty rootAnthony Ramine2020-05-191-0/+17
|
* Rename a bunch of style/layout data itemsAnthony Ramine2020-04-061-2/+2
| | | | | | | | | | | | | GetLayoutData::get_style_and_layout_data becomes GetOpaqueStyleAndLayoutData::get_opaque_style_and_layout_data. GetRawData::get_raw_data becomes GetStyleAndLayoutData::get_style_and_layout_data. LayoutNode::init_style_and_layout_data becomes LayoutNode::init_opaque_style_and_layout_data. LayoutNode::take_style_and_layout_data becomes LayoutNode::take_opaque_style_and_layout_data.
* Add a 'dom lifetime to GetLayoutDataAnthony Ramine2020-03-261-7/+7
|
* Some further removalsest312019-05-301-6/+0
|
* Rustfmt has changed its default style :/Simon Sapin2018-12-281-3/+4
|
* Update MPL license to https (part 4)Jan Andre Ikenmeyer2018-11-191-1/+1
|
* `cargo fix --edition-idioms`Simon Sapin2018-11-081-20/+20
|
* Reorder importsPyfisch2018-11-061-3/+3
|
* Sort `use` statementsSimon Sapin2018-11-061-2/+2
|
* `cargo fix --edition`Simon Sapin2018-11-061-7/+7
|
* Rustfmt layout cratePyfisch2018-09-011-23/+44
|
* style: Indent properly a couple more functions.Emilio Cobos Álvarez2018-02-241-7/+12
|
* Create own file for background calculations in layoutPyfisch2018-01-061-1/+1
| | | | | | | | | | Move display_list_builder.rs and webrender_helpers.rs along with the new file to components/layout/display_list/ Remove apparently unused IdType enum. Only variant used was OverflowClip. See #19676
* style: Remove TNode::set_can_be_fragmented and TNode::can_be_fragmented.Emilio Cobos Álvarez2018-01-041-1/+2
| | | | | Replace them instead by a computed value flag, the same way as the IS_IN_DISPLAY_NONE_SUBTREE flag works.
* Turn flow::base and friends into methodsMatt Brubeck2017-12-141-14/+14
|
* style: Remove unused argument in element_needs_traversal.Emilio Cobos Álvarez2017-11-171-2/+1
|
* Bump bitflags to 1.0 in every servo crateBastien Orivel2017-10-301-11/+11
|
* Wait as late as possible to assign ClipIdsMartin Robinson2017-10-241-4/+3
| | | | | | | | | This will allow Servo to create ClipScrollNodes later during display list construction, which will be necessary once rounded rectangles are removed from the LocalClip structure. Instead of keeping track of the ClipId of each ClipScrollNode, we keep track of its index in an array of ClipScrollNodes. This will allow us to access them without a hash lookup.
* Backed out changeset e64e659c077d: servo PR #18809 and revendor for reftest ↵Gecko Backout2017-10-191-11/+11
| | | | | | failures, e.g. in layout/reftests/bugs/392435-1.html. r=backout on a CLOSED TREE Backs out https://github.com/servo/servo/pull/18809
* Update bitflags to 1.0 in every servo crateBastien Orivel2017-10-191-11/+11
| | | | | It still needs dependencies update to remove all the other bitflags versions.
* Eliminate RestyleData entirely.Bobby Holley2017-09-121-1/+1
| | | | | | Without this change, the previous commit increases the size of ElementData. MozReview-Commit-ID: 87BZuXINiT9
* Eliminate the sequential/traversal parallel distinction in favor of a ↵Bobby Holley2017-08-251-8/+2
| | | | | | unified adaptive driver. MozReview-Commit-ID: ADVTNJntzmp
* order derivable traits listsClément DAVID2017-08-231-2/+2
| | | | | | Ignoring : - **generated**.rs - python/tidy/servo_tidy_tests/rust_tidy.rs
* Allow CalculateStackingRelativePositions to short-circuitMatt Brubeck2017-08-081-11/+18
|
* Code organization: Move all generic traversal code to layout::traversalMatt Brubeck2017-08-081-2/+85
|
* Rename compute_absolute_position to compute_stacking_relative_positionMatt Brubeck2017-08-081-3/+3
|
* Fix fixed position items with parents with CSS clipsMartin Robinson2017-08-031-3/+4
| | | | | | | | | | In order to properly handle CSS clipping, we need to keep track of what the different kinds of clips that we have. On one hand, clipping due to overflow rules should respect the containing block hierarchy, while CSS clipping should respect the flow tree hierarchy. In order to represent the complexity of items that are scrolled via one clip/scroll frame and clipped by another we keep track of that status with a ClipAndScrollInfo.
* Pass a callback to recalc_style_at to avoid traversing children twice.Bobby Holley2017-07-151-5/+9
| | | | MozReview-Commit-ID: DIHXaVNzbFM
* script: Move the layout_wrapper outside of script.Emilio Cobos Álvarez2017-07-151-13/+2
| | | | | | | | This allows us to have ensure_data() and clear_data() functions on the TElement trait, instead of hacking around it adding methods in random traits. This also allows us to do some further cleanup, which I'd rather do in a followup.
* Rip out the generic abstractions around ThreadLocalStyleContext.Bobby Holley2017-07-051-18/+6
| | | | MozReview-Commit-ID: 5WTLuk323Ac
* Eliminate ScrollRootIdMartin Robinson2017-04-201-1/+1
| | | | | | | Just use WebRender's ClipId directly. This will allow us to create and use ReferenceFrames in the future, if we need to do that. It will also make it easier to have Servo responsible for creating the root scrolling area, which will allow removing some old hacks in the future.
* stylo: Store font metrics provider in thread local style contextManish Goregaokar2017-04-091-0/+1
|