aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/formatting_contexts.rs
Commit message (Collapse)AuthorAgeFilesLines
* layout: Combine `layout_2020` and `layout_thread_2020` into a crate called ↵Martin Robinson11 days1-363/+0
| | | | | | | | | | | | | | | | | | `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>
* layout: Report memory usage for fragment and box trees. (#36553)Josh Matthews11 days1-4/+5
| | | | | | | | | | | | Add memory reporter integration for the fragment and box trees that are persisted in the layout thread. Testing: Looked at the numbers for https://servo.org and https://html.spec.whatwg.org/. The former was very small, but the latter was 700mb. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* layout: Add a `LayoutBoxBase` to inline boxes (#36513)Martin Robinson2025-04-141-2/+3
| | | | | | | | | | | | `LayoutBoxBase` will soon contain laid out `Fragment`s of a box tree node in order to facilitate incremental layout and also layout queries. This is currently missing for inline boxes, so this change adds a `LayoutBoxBase` to them. Testing: This should not change any observable behavior, so existing WPT suites should suffice for testing. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Enable using cached fragments when there is a BoxTree update point ↵Martin Robinson2025-04-091-3/+3
| | | | | | | | | | | | | | | | | | (#36404) This starts to enable the fragment cache for all layout modes, except grid. The main tricky bit here is that update points are absolutes and these need to be laid out again in their containing blocks. We punt a little bit on this, by forcing ancestors of update points to rebuild their Fragments. This is just the first step. Testing: We do not currently have layout performance tests, but will try to run some tests manually later. Behavior is covered by the WPT. 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: Cache `IndependentNonReplacedContents::layout()` (#36082)Oriol Brufau2025-03-241-34/+67
| | | | | | | | | | | | | | | This replaces `IndependentLayout` with `CacheableLayoutResult` and stores it in `LayoutBoxBase` so it can be reused when we need to lay out a box multiple times. This is a generalization of the caching that we had for flexbox, which is now removed in favor of the new one. With this, the number of runs per second in the Chromium perf test `flexbox-deeply-nested-column-flow.html` are multiplied by 3. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Limit `content_inline_size_for_table` override to collapsed columns ↵Oriol Brufau2025-02-051-3/+3
| | | | | | | | | | | | | | | | | | | (#35209) A box is usually sized by the formatting context in which it participates. However, tables have some special sizing behaviors that we implemented with a `content_inline_size_for_table` override. However, breaking the assumptions of the formatting context isn't great. It was also bad for performance that we could try to layout a table among floats even though it wouldn't en up fitting because of a larger min-content size. Therefore, this changes the logic so that formatting contexts use some special sizing for tables, and then tables only override that amount when there are collapsed columns. Eventually, we should try to remove that case too, see https://github.com/w3c/csswg-drafts/issues/11408 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Take percentage columns into account when sizing table grid min and ↵Martin Robinson2025-01-271-7/+8
| | | | | | | | | | | | | | | | | | | | | max (#35167) The specification doesn't say how to deal with percentages when determining the minimum and maximum size of a table grid, so follow the approach that Chromium uses. Essentially, figure out the "missing" percentage from the non-percentage columns and then use that to work backwards to fine the size of the percentage ones. This change is larger than one might expect, because this percentage approach shouldn't happen for tables that are descendants of a flex, grid or table container (except when there is an interceding absolute). We have to pass this information down when building the box tree. This will also make it easier to improve propagated text decorations in the future. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Remove min and max container sizes from `FlexContext` (#35144)Oriol Brufau2025-01-241-1/+0
| | | | | | | | | | | | | Thanks to #34946 we don't have to recompute the min and max sizes, we can get them from the `ContainingBlock`. And then in `FlexContext` there is no need to store both the definite and the min & max sizes of the container`, we can instead make do with a single `FlexRelativeVec2<SizeConstraint>`. This removes 1 of the 3 usages of `ContentBoxSizesAndPBMDeprecated`, which is also good. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Make naming of variables consistent with `SpecificLayoutInfo` (#35104)Martin Robinson2025-01-211-1/+1
| | | | | | | This is a followup to #34926. Fixes #35078. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* layout: Fix border widths of table wrapper with collapsed borders (#35097)Oriol Brufau2025-01-211-1/+1
| | | | | | | For a table wrapper in collapsed-borders mode we were just halving the border widths from the computed style. However, it needs to actually receive half of the resulting collapsed border, which can be bigger. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Remove some unneeded `is_table` parameters (#35064)Oriol Brufau2025-01-191-9/+0
| | | | | We can just check the `LayoutStyle` instead. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Allow layouts to customize their used style (#35012)Oriol Brufau2025-01-161-2/+24
| | | | | | | | | | | | | | | Some layouts like table need some style overrides. We were handling this in `ComputedValuesExt`, but it was messy, unreliable and too limited. For example, we were assuming that a style with `display: table` would belong to a table wrapper box or table grid box. However, certain HTML elements can ignore their `display` value and generate a different kind of box. I think we aren't doing that yet, but we will need this. Also, resolving the used border of a table needs layout information, which we don't have in `ComputedValuesExt`. This patch will allow to improve border collapsing in a follow-up. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Remove the obsolete layout tracing functionality (#35001)Martin Robinson2025-01-151-5/+4
| | | | | | | | | | | | | | | | | | | | 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>
* layout: grid-template getComputedStyle cleanup (#34926)Steven Novaryo2025-01-101-2/+2
| | | | | | | | | | | | | | | | | * Update Taffy and WPT expectations Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Rename DetailedInfo to SpecificInfo Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Run fmt Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* layout: grid template getComputedStyle resolved value (#34885)Steven Novaryo2025-01-091-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Store taffy detailed info into fragment Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix info propagation and resolved grid track query Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix import Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Fix tracklist matching logic and type optimization Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Run fmt Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Update wpt expectations Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Optimizing info propagation and minor qol Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> * Run fmt Signed-off-by: stevennovaryo <steven.novaryo@gmail.com> --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* layout: Defer some table sizing logic to the parent formatting context (#34889)Oriol Brufau2025-01-091-9/+16
| | | | | | | | | | | | | A box is usually sized by the formatting context in which it participates. However, tables have some special sizing behaviors, and these were in conflict. Instead of letting tables attempting to re-resolve their inline table, which failed to e.g. take flex properties into account or resolve sizing keywords correctly, now tables will trust the inline size determined by the parent. They will only floor it by the min-content size, and maybe shrink the final size due to collapsed columns. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Treat % as 0 for the min-content contribution of replaced elements (#32103)Oriol Brufau2025-01-061-0/+1
| | | | | | | | | `width` and `max-width` typically treat expressions with percentages as their initial value, but for the min-content contribution of replaced elements, they should instead be treated as zero. https://drafts.csswg.org/css-sizing-3/#replaced-percentage-min-contribution Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Fix intrinsic contributions of anonymous blocks (#34719)Oriol Brufau2024-12-221-0/+1
| | | | | | | | | | | In order to compute the inline min-content and max-content contributions of an anonymous block, we were finding its min-content and max-content inline size with a SizeConstraint coming from the block size of the box. However, anonymous blocks do not establish a containing block for their contents, so this patch uses a SizeConstraint from the block size of the containing block. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Fix intrinsic contributions of tables (#34696)Oriol Brufau2024-12-201-0/+7
| | | | | | | | | If a table element had e.g. `width: 0px`, we were assuming that this was its intrinsic min-content and max-content contributions. However, tables are always at least as big as its min-content size, so this patch floors the intrinsic contributions by that amount. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Distinguish cached `inline_content_sizes()` from uncached ones (#34595)Oriol Brufau2024-12-121-15/+22
| | | | | | | | | | | | | | Several structs and enums had a `inline_content_sizes()` method, but it wasn't clear which ones would try to cache the result, and which ones would always compute it. Therefore, this performs some clarifying renaming: - Cached ones stay as `inline_content_sizes()` - Uncached ones become `compute_inline_content_sizes()` Also, to simplify calls to `LayoutBoxBase::inline_content_sizes()`, `compute_inline_content_sizes()` is moved into a new trait. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Add `LayoutBoxBase` and use it for `IndependentFormattingContext` ↵Martin Robinson2024-12-071-147/+68
| | | | | | | | | | | | | | | | | | (#34507) Add a new struct `LayoutBoxBase`, that will be used throughout the box tree. The idea of this struct is that we have a place to consistently store common layout information (style and node information) and also to cache layout results such as content sizes (inline and maybe later box sizes) and eventually layout results. In addition to the addition of this struct, `IndependentFormattingContext` is flattened slightly so that it directly holds the contents of both replaced and non-replaced elements. This is only added to independent formatting contexts, but will later be added to all block containers as well. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Refactor computation of preferred aspect ratios (#34416)Oriol Brufau2024-11-291-16/+23
| | | | | | | | | | | | | | | | | | | * Refactor computation of preferred aspect ratios Computing min/max-content sizes required a ContainingBlock in order to resolve the padding and border when determining the preferred aspect ratio. However, all callers already knew the padding and border, so they can compute the ratio themselves, and pass it directly instead of the ContainingBlock. Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Put preferred aspect ratio into ConstraintSpace Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Use an AtomicRefCell instead of a RwLock for caching intrinsic sizes (#34384)Oriol Brufau2024-11-261-13/+9
| | | | | | It panics if the value is mutably borrowed concurrently, but this allows it to perform better. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Remove unnecessary clone in layout (#34350)Nico Burns2024-11-231-1/+1
| | | Signed-off-by: Nico Burns <nico@nicoburns.com>
* Layout: Implement CSS Grid using `taffy` (#32619)Nico Burns2024-11-211-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add layout.grid.enabled pref Signed-off-by: Nico Burns <nico@nicoburns.com> * Add taffy dependency Signed-off-by: Nico Burns <nico@nicoburns.com> * Import taffy <-> stylo conversion code from taffy_stylo crate Signed-off-by: Nico Burns <nico@nicoburns.com> * Add `Grid` variant to DisplayInside Signed-off-by: Nico Burns <nico@nicoburns.com> * Implement CSS Grid using Taffy Signed-off-by: Nico Burns <nico@nicoburns.com> Import full stylo_taffy crate Signed-off-by: Nico Burns <nico@nicoburns.com> Squashed PR feedback changes Deduplicate is_document_only_whitespace Signed-off-by: Nico Burns <nico@nicoburns.com> Import taffy::AvailableSpace Signed-off-by: Nico Burns <nico@nicoburns.com> Rename FlexContext to TaffyContainerContext Signed-off-by: Nico Burns <nico@nicoburns.com> Eliminate references to flexbox in taffy/layout module Signed-off-by: Nico Burns <nico@nicoburns.com> Use constructors for geom types Signed-off-by: Nico Burns <nico@nicoburns.com> Remove comment about abspos elements splitting contiguous text runs Signed-off-by: Nico Burns <nico@nicoburns.com> Remove reference to flexbox in taffy/construct Signed-off-by: Nico Burns <nico@nicoburns.com> Deduplicate construction of flexbox/grid containers Signed-off-by: Nico Burns <nico@nicoburns.com> Make anonymous text runs InFlow Signed-off-by: Nico Burns <nico@nicoburns.com> Remove commented code Signed-off-by: Nico Burns <nico@nicoburns.com> Update comments Signed-off-by: Nico Burns <nico@nicoburns.com> Inline/vendor the stylo/taffy interop code Signed-off-by: Nico Burns <nico@nicoburns.com> * Update test expectations Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix nits from PR review Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
* Use a RwLock to cache inline_content_sizes() (#34232)Oriol Brufau2024-11-131-17/+22
| | | | | | | | | | | In order to support size keywords in block layout, we may need to call `inline_content_sizes()` in order to compute the min/max-content sizes. But this required a mutable reference in order the update the cache, and in various places we already had mutable references. So this switches the cache into a RwLock to avoid needing mutable refs. Note OnceCell wouldn't work because it's not thread-safe. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Fix inline content sizes of intrinsic element with indefinite block size ↵Oriol Brufau2024-11-111-27/+18
| | | | | | | | | | | | | | | | | (#34152) To compute the min-content and max-content inline sizes of a replaced element, we were only using the aspect ratio to transfer definite block sizes resulting from clamping the preferred block size between the min and max block sizes. However, if the preferred block size is indefinite, then we weren't transfering the min and max through the aspect ratio. This patch adds a `SizeConstraint` enum that can represent these cases, and a `ConstraintSpace` struct analogous to `IndefiniteContainingBlock` but with no inline size, and a `SizeConstraint` block size. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Avoid layout sometimes when stretching (#33967)Martin Robinson2024-10-241-0/+3
| | | | | | | | | | | | | | | | | | | | This is the second flexbox caching change. It seeks to detect when a relayout can be avoided in the case of a stretching flex item. This heuristic can be combined, because currently we still do relayout sometimes when we do not need to. For instance currently we always relayout when a flex child is itself a column flex. This only needs to happen when the grandchildren themselves grow or shrink. That optimization is perhaps a lower priority as `flex-grow: 0 / flex-shrink: 1` is the default behavior for flex. Since this change means we more consistenly zero out the percentage part of `calc` expressions when they have circular dependencies, this causes one test to start failing (`/css/css-values/calc-min-height-block-1.html`). This is related to w3c/csswg-drafts#10969, which is pending on further discussion in the working group. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Avoid recomputing inline_content_sizes() when not needed (#33806)Oriol Brufau2024-10-141-11/+13
| | | | | | | | | | | The result of `inline_content_sizes()` may depend on the block size of the containing block, so we were always recomputing in case we got a different block size. However, if no content has a vertical percentage or stretches vertically, then we don't need to recompute: the result will be the same anyways. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Unify logic for laying out floats and atomic inlines (#33802)Oriol Brufau2024-10-111-1/+8
| | | Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Simplify the computation of CAPMIN (#33577)Oriol Brufau2024-09-281-5/+20
| | | | | | | | | | | | CAPMIN is the largest min-content contribution of the table captions. In Servo, the standard way to compute min/max-content contributions is `outer_inline_content_sizes()`, so just use that instead of reinventing the wheel. This also fixes cyclic percentages to resolve consistently with normal block boxes. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Use `Au` in `ComputedValuesExt` (#33396)atbrakhi2024-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | * Use app unit in `ComputedValuesExt` Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: atbrakhi <atbrakhi@igalia.com> * Some miscellaneous fixes Signed-off-by: Martin Robinson <mrobinson@igalia.com> * remove redundant defination of `containing_block_inline_size` Signed-off-by: atbrakhi <atbrakhi@igalia.com> --------- Signed-off-by: atbrakhi <atbrakhi@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Fix various issues with replaced elements in flex layout (#33263)Oriol Brufau2024-08-301-0/+13
| | | | | | | | In particular, this takes into account that flex items may be stretched, and if they have an aspect ratio, we ma6y need to convert the stretched size through the ratio. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Handle aspect ratios in `ReplacedContent::inline_content_sizes` (#33240)Oriol Brufau2024-08-291-17/+10
| | | | | | | We were only handling the aspect ratio of a replaced element when computing its min/max-content contribution, but not when computing the min/max-content size. Now both cases will take it into account. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Add an indefinite containing block for intrinsic sizing (#33204)Oriol Brufau2024-08-291-44/+83
| | | | | | | | | | | | | | | | | | When computing the min-content or max-content size of an element we need to ignore `inline-size`, `min-inline-size` and `max-inline-size`. However, we should take the block-axis sizing properties into account. That's because the contents could have percentages depending on them, which can then affect their inline size via an aspect ratio. Therefore, this patch adds `IndefiniteContainingBlock`, which is similar to `ContainingBlock`, but it allows an indefinite inline-size. This struct is then passed arround during intrinsic sizing. More refinement will be needed in follow-up patches in order to fully address the problem. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Allow caching `IndependentFormattingContext::inline_content_sizes()` (#33207)Oriol Brufau2024-08-271-3/+1
| | | | | | | | | | | | For non-replaced formatting contexts, this method redirected directly to `NonReplacedFormattingContextContents::inline_content_sizes()`, which has the actual logic for the computation. Thus it was bypassing the cache, which is handled in `NonReplacedFormattingContext::inline_content_sizes()`. Therefore, this patch redirects to the latter. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Prepare for bidi by guarding all access to `writing-mode` (#33082)Martin Robinson2024-08-161-4/+4
| | | | | | | | | We want to selectively enable right-to-left writing modes per layout context. This change makes that possible by allowing access to `writing-mode` though an interface that always returns the default horizontal top-to-bottom (implicitly left-to-right) writing mode. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* layout: Initial implementation of `flex-direction: column` and ↵Martin Robinson2024-08-141-15/+31
| | | | | | | | | | | | | | | | | | | | | | `column-reverse` (#33031) This change removes restrictions on using the column layout mode of flexbox and adds an initial implementation of sizing for that flex direction. There's a lot of missing pieces still, but in some cases this does render column flexbox. In particular, there are now two code paths for preferred widths (intrinsic size) calcuation: one in the main axis (row) and one in the cross axis (column) corresponding to the flex direciton with horizontal writing modes. In addition, `FlexItemBox::inline_content_sizes` is removed in favor of making `sizing::outer_inline` / `IndependentFormattingContext::outer_inline_content_sizes` generic enough to handle using a different value for auto minimum sizes, which flexbox needs. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Compute intrinsic sizes for flex items and flex containers (#32854)Delan Azabani2024-08-021-1/+1
| | | | | Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Properly handle min/max cross container size (#32785)Delan Azabani2024-07-161-0/+1
| | | | | Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* layout: Add support for table captions (#32657)Martin Robinson2024-07-031-4/+25
| | | | | | | | | | | | | This adds initial support for table captions. To do this, the idea of the table wrapper becomes a bit more concrete. Even so, the wrapper is still reponsible for allocating space for the grid's border and padding, as those properties are specified on the wrapper and not grid in CSS. In order to account for this weirdness of HTML/CSS captions and grid are now laid out and placed with a negative offset in the table wrapper content rect. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Simplify `Contents` a little (#32487)Martin Robinson2024-06-211-5/+3
| | | | | | | Instead of duplicating some of `NonReplacedContents` in `Contents`, divide it into either replaced and non-replaced content, since this is how the layout system processes `Contents` always. In addition, stop using `TryInto` to match replaced or non-replaced contents, as it is quite confusing to handle an `Err` as a success case.
* layout: Allow transforming inline replaced elements (#31833)Martin Robinson2024-03-271-6/+10
| | | | | | | | | | This requires passing through information about whether or not the element in question is replaced when checking to see if it's transformable and transitively all functions that make decisions about containing blocks. A new FragmentFlag is added to help track this -- it will be set on both the replaced items BoxFragment container as well as the Fragment for the replaced item itself. Fixes #31806.
* rustdoc: Fix two warnings in `components/layout_2020` (#31712)Rhea-Eve2024-03-181-2/+2
| | | | | | | | | | | | | | | | | | * Fix BoxFragment reference. Signed-off-by: Rhea Karty <rheakarty@gmail.com> * Fix reference to InlineFormattingContext. Signed-off-by: Rhea Karty <rheakarty@gmail.com> * Rewrap lines to avoid long length * Remove trailing whitesapce --------- Signed-off-by: Rhea Karty <rheakarty@gmail.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Fix size of tables in flow layout (#31455)Oriol Brufau2024-03-021-9/+22
| | | | | | | | | | | | | | | | | | | | | | * Fix size of tables in flow layout The contents of a table can make it bigger than what we would expect from its 'width', 'min-width', 'height' and ' min-height' properties. Also, 'width: auto' doesn't stretch it to fill the containing block. We had to refactor the resolution of margins to happen after layout, otherwise 'auto' margins wouldn't align correctly. Co-authored-by: Martin Robinson <mrobinson@igalia.com> * Feedback * Consistently use `containing_block_for_table` in table layout * Update test result --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Start work on table row height and vertical-align (#31246)Martin Robinson2024-02-101-1/+1
| | | | | | | | | This implements a very naive row height allocation approach. It has just enough to implement `vertical-align` in table cells. Rowspanned cells get enough space for their content, with the extra space necessary being allocated to the last row. There's still a lot missing here, including proper distribution of row height to rowspanned cells. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Collect both start and end baselines for fragments (#31230)Martin Robinson2024-02-051-1/+9
| | | | | | | | This change starts collecting the starting baseline set for fragments, which is necessary for some layout modes (flex and tables, namely) as well as being important for the implementation of `align-items`. In addition, it converts baseline measurement to use `Au` everywhere. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Lint layout_2020 with clippy (#31196)Oriol Brufau2024-01-261-7/+5
| | | cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
* layout: Shape text only once (#31146)Martin Robinson2024-01-251-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Shape text during InlineFormattingContext construction rather than doing it twice during fragment tree construction. This is a step on the way toward proper font fallback. This also moves all `TextRun` related code into `text_run.rs` to try to trim down the size of `inline.rs`. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because this should only have performance impacts. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
* Lint layout_2020 with clippy (#31169)Oriol Brufau2024-01-251-1/+1
| | | cargo clippy --fix -p layout_2020 --allow-dirty --broken-code