aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/construct.rs
Commit message (Collapse)AuthorAgeFilesLines
* layout: Flatten inline box storage in InlineFormattingContexts (#32539)Martin Robinson2024-06-191-9/+14
| | | | | | | | | | | This accomplishes two things: 1. Makes it easier to iterate through all inline formatting context items. 2. Will make it possible to easily move back and forth through the tree of inline boxes, in order to enable reordering and splitting inline boxes on lines -- necessary for BiDi. Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* layout: Add a `InlineFormattingContextBuilder` (#32415)Martin Robinson2024-06-031-246/+147
| | | | | | | | | | | | | | | | The main change here is that collapsed and `text-transform`'d text is computed as it's processed by DOM traversal. This single transformed text is stored in the root of the `InlineFormattingContext`. This will eventually allow performing linebreaking and shaping of the entire inline formatting context at once. Allowing for intelligent processing of linebreaking and also shaping across elements. This matches more closely what LayoutNG does. This shouldn't have any (or negligable) behavioral changes, but will allow us to prevent linebreaking inside of clusters in a followup change. Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* layout: Ensure empty list items are at least as tall as outside markers (#32152)Martin Robinson2024-04-291-3/+3
| | | | | | | | | | | | | | | | While <https://drafts.csswg.org/css-lists/#list-style-position-property> says: > The size or contents of the marker box may affect the height of the > principal block box and/or the height of its first line box, and in some > cases may cause the creation of a new line box; this interaction is also > not defined. All other browsers ensure that the first line of list item content is the same block size as the marker. Doing this is complicated, but we can ensure that the entire list item is at least as tall as the marker. This should handle the majority of cases and we can make refinements later for stranger situations, such as when the marker is very tall. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Add a basic support for `list-style-position: outside` (#32114)Martin Robinson2024-04-221-8/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds very basic support for `list-style-position`. Currently, the marker does not do any kind of baseline alignment with the rest of the list item contents and it also doesn't force the list item to be at least as tall as the marker. This adds a few new failures: - Four failures because markers do not ensure that list-items have at least the same block size as they do: - FAIL [expected PASS] /css/CSS2/lists/list-style-applies-to-012.xht - FAIL [expected PASS] /css/CSS2/lists/list-style-applies-to-014.xht - FAIL [expected PASS] /css/CSS2/lists/list-style-type-applies-to-012.xht - FAIL [expected PASS] /css/CSS2/lists/list-style-type-applies-to-014.xht - One failure because we don't yet support the `::marker` pseudo-selector: - FAIL [expected PASS] /css/css-position/position-absolute-dynamic-list-marker.html - One failure because we don't support the list item exception for the line height quirk: - FAIL [expected PASS] /quirks/line-height-in-list-item.tentative.html Co-authored-by: Oriol Brufau <obrufau@igalia.com> <!-- Please describe your changes on the following line: --> Fixes #27383. --- <!-- 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 fix #27383. - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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. --> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Allow finishing anonymous inline-table at the end of inline elements (#31650)Oriol Brufau2024-03-141-0/+2
| | | This avoids inserting it outside of its parent.
* End ongoing IFC when inserting anonymous block-level table (#31606)Oriol Brufau2024-03-131-0/+1
| | | | So that the table appears after preceding inline-level contents. Fixes #31603.
* clippy: Fix warnings in `components/layout_2020` (#31611)eri2024-03-111-10/+6
| | | | | * clippy: fix warnings in components/layout_2020 * fix: review comments
* layout: Do not inherit node and fragment flags in anonymous boxes (#31586)Martin Robinson2024-03-091-2/+2
| | | | | | | This doesn't really have observable behavior right now, as much as I tried to trigger some kind of bug. On the other hand, it's just wrong and is very obvious when you dump the Fragment tree. If you create a `display: table-cell` that is a child of the `<body>` all parts of the anonymous table are flagged as if they are the `<body>` element.
* layout: Do whitespace collapse during breaking and shaping (#31322)Martin Robinson2024-02-131-194/+11
| | | | | | | | This moves white space collapse to right before breaking and shaping happens, which is more similar to what happens in legacy layout. This is the first step toward making this procedure more efficient (avoiding string copies) and also implementing support for `text-transform`. Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* layout: Implement support for font fallback (#31254)Martin Robinson2024-02-111-6/+8
| | | | | | | This adds an initial implementation of font fallback, on part with the one used in legacy layout. There are still issues. For instance, font matching is done per unicode character rather than based on graphemes or the shape first approach of Chrome. The idea is that these changes can be made later.
* layout: Shape text only once (#31146)Martin Robinson2024-01-251-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+5
| | | cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
* Add support for table fixups (#30868)Martin Robinson2023-12-221-46/+160
| | | | | | | | | | | | | | | | This adds support for fixing up tables so that internal table elements that are not properly parented in the DOM have the correct box tree structure according to the CSS Table specification [1]. Note that this only comes into play when building the DOM via script, as HTML 5 has its own table fixups that mean that the box tree construction fixups here are not necessary. There are no tests for this change. In general, it's hard to write tests against the shape of the box tree, because it depends on the DOM. We plan to test this via WPT tests once layout is complete. 1. https://drafts.csswg.org/css-tables/#table-internal-element Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Add initial support for table box tree construction (#30799)Martin Robinson2023-12-051-0/+3
| | | | | | | | | | | | This is the first part of constructing the box tree for table layout. No layout is actually done and the construction of tables is now hidden behind a flag (in order to not regress WPT). Notably, this does not handle anonymous table part construction, when the DOM does not reflect a fully-formed table. That's part two. Progress toward #27459. Co-authored-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Manish Goregaokar <manishsmail@gmail.com>
* Make LineItems a token stream on the root (#30608)Martin Robinson2023-10-251-6/+6
| | | | | | | | | Flattening the LineItem tree into a token stream will allow for handling the case where an unbreakable line segment spans multiple inline boxes which might have different hierarchies. This change also fixes the handling of the second anonymous fragment of a block-in-inline-split. Co-authored-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Anonymous boxes that wrap inlines should not inherit overflow (#30579)Martin Robinson2023-10-191-2/+2
| | | | | | | | | | | | | | In legacy layout, anonymous text wrappers were inheriting the `overflow` and `text-overflow` properties. This results in the creation of extra clipping for these anonymous wrappers which could clip away floats. We will likely implement `text-overflow` differently in non-legacy layout. This change marks all legacy layout pseudo elements as "legacy" and also adds a new pseudo element for non-legacy layout that does not inherit `overflow`. Fixes #30562. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-9/+11
| | | | | * strict imports formatting * Reformat all imports
* Add initial support for css-text-3 whitespace handling (#29828)Atbrakhi2023-07-201-153/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add initial support for css-text-3 whitespace handling This adds initial support for whitespace handling from the CSS specification for Layout 2020. In general, the basics are covered. Since test output is very sensitive to whitespace handling, this change incorporates several fixes: 1. Whitespace is collapsed according to the Phase 1 rules of the specification, though language-specific unbreaking rules are not handled properly yet. 2. Whitespace is mostly trimmed and positioned according to the Phase 2 rules, but full support for removing whitespace at the end of lines is pending on a temporary data structure to hold lines under construction. 3. Completely empty box fragments left over immediately after line breaks are now trimmed from the fragment tree. 4. This change tries to detect when an inline formatting context collapses through. Fixes #29994. Co-authored-by: Mukilan Thiyagarajan <me@mukilan.in> Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> * Update test results --------- Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <me@mukilan.in> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Remove rayon_croissant and clean up `contains_floats` (#29960)Martin Robinson2023-07-191-80/+39
| | | | | | | | | | | Remove rayon_croissant and refactor the way that information about floats in flows bubbles up. This simplifies the code a good deal and lets us take advantage of some more optimized functions provided by rayon. This removes 2 crates from the dependency tree. In addition, this allows avoiding passing `contains_floats` up from every box tree construction function. This makes things simpler, but also opens up the possibility of passing more of these flags up in the future (such as `contains_counters`).
* layout_2020: Check blocks for whether they will establish a formatting contextPu Xingyu2023-05-311-2/+4
|
* Combine DOM-related concepts in Layout 2020 into dom.rsMartin Robinson2023-05-131-4/+2
|
* Detect body elements during layoutMartin Robinson2023-05-041-5/+4
| | | | | | | | | | | | | | | | | During layout it is often useful, for various specification reasons, to know if an element is the `<body>` element of an `<html>` element root. There are a couple places where a brittle heuristic is used to detect `<body>` elements. This information is going to be even more important to properly handle `<html>` elements that inherit their overflow property from their `<body>` children. Implementing this properly requires updating the DOM wrapper interface. This check does reach up to the parent of thread-safe nodes, but this is essentially the same kind of operation that `parent_style()` does, so is ostensibly safe. This change should not change any behavior and is just a preparation step for properly handle `<body>` overflow.
* Fix text-decoration for block containers in layout-2020Oriol Brufau2023-04-261-3/+6
| | | | | | It was only applied to the 1st inline formatting context of a block container. Other IFCs were created with the Default trait, implying TextDecorationLine::NONE.
* Support text-indent in layout-2020Oriol Brufau2023-04-251-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Existing WPT now passing: - _mozilla/css/text_indent_a.html - css/CSS2/css1/c71-fwd-parsing-002.xht - css/CSS2/css1/c71-fwd-parsing-004.xht - css/CSS2/floats-clear/floats-138.xht - css/CSS2/text/text-indent-007.xht - css/CSS2/text/text-indent-008.xht - css/CSS2/text/text-indent-010.xht - css/CSS2/text/text-indent-019.xht - css/CSS2/text/text-indent-020.xht - css/CSS2/text/text-indent-031.xht - css/CSS2/text/text-indent-032.xht - css/CSS2/text/text-indent-043.xht - css/CSS2/text/text-indent-044.xht - css/CSS2/text/text-indent-055.xht - css/CSS2/text/text-indent-056.xht - css/CSS2/text/text-indent-067.xht - css/CSS2/text/text-indent-068.xht - css/CSS2/text/text-indent-079.xht - css/CSS2/text/text-indent-080.xht - css/CSS2/text/text-indent-091.xht - css/CSS2/text/text-indent-092.xht - css/CSS2/text/text-indent-103.xht - css/CSS2/text/text-indent-104.xht - css/CSS2/text/text-indent-112.xht - css/CSS2/text/text-indent-113.xht - css/CSS2/text/text-indent-115.xht - css/CSS2/text/text-indent-applies-to-002.xht - css/CSS2/text/text-indent-applies-to-003.xht - css/CSS2/text/text-indent-applies-to-005.xht - css/CSS2/text/text-indent-applies-to-006.xht - css/CSS2/text/text-indent-applies-to-007.xht - css/CSS2/text/text-indent-applies-to-008.xht - css/CSS2/text/text-indent-applies-to-009.xht - css/CSS2/text/text-indent-applies-to-010.xht - css/CSS2/text/text-indent-applies-to-011.xht - css/CSS2/text/text-indent-applies-to-014.xht - css/CSS2/text/text-indent-applies-to-015.xht - css/CSS2/text/text-indent-inherited-001.xht - css/CSS2/text/text-indent-overflow-001.xht - css/CSS2/text/text-indent-overflow-002.xht - css/CSS2/text/text-indent-overflow-003.xht - css/CSS2/text/text-indent-overflow-004.xht - css/CSS2/text/text-indent-wrap-001.xht - css/css-text-decor/text-shadow/textindent.html - css/css-text/text-indent/text-indent-percentage-001.xht - css/css-text/text-indent/text-indent-percentage-002.html - css/css-text/text-indent/text-indent-percentage-003.html - css/css-text/text-indent/text-indent-percentage-004.html - css/css-values/minmax-length-percent-serialize.html - css/css-values/minmax-length-serialize.html Also improvements in: - _mozilla/mozilla/calc.html - css/css-text/animations/text-indent-interpolation.html - css/css-text/inheritance.html - css/css-text/parsing/text-indent-computed.html - css/css-text/parsing/text-indent-valid.html - css/css-transitions/properties-value-implicit-001.html - css/css-values/animations/calc-interpolation.html - css/css-values/minmax-percentage-serialize.html - css/css-values/viewport-units-css2-001.html - css/css-variables/variable-substitution-basic.html - css/cssom/serialize-values.html Existing WPT now failing, due to lack of direction, outside list markers, flex and grid: - css/CSS2/text/text-indent-rtl-001.xht - css/CSS2/text/text-indent-rtl-002.xht - css/css-pseudo/marker-content-023.html - css/css-text/text-indent/anonymous-flex-item-001.html - css/css-text/text-indent/anonymous-grid-item-001.html New WPT tests: - css/css-text/text-indent/text-indent-length-001.html - css/css-text/text-indent/text-indent-length-002.html This one fails in layout-2013.
* Simplify control flow of whitespace handling.Josh Matthews2020-07-271-60/+78
|
* Implement basic white-space: pre support for layout 2020.Josh Matthews2020-07-271-14/+37
|
* Add layout support for list markersSimon Sapin2020-07-241-2/+45
|
* Make a bool for `display: list-item` available to flow box constructionSimon Sapin2020-07-231-10/+45
|
* Remove the now single-field `Accumulator` structSimon Sapin2020-06-191-15/+7
|
* Compute content sizes lazily in layout 2020Anthony Ramine2020-06-181-107/+16
|
* Make IndependentFormattingContext an enumAnthony Ramine2020-06-151-4/+4
|
* Make outer_inline and outer_inline_and_percentages free functionsAnthony Ramine2020-06-151-11/+11
| | | | They now take a closure that will compute the content sizes on demand.
* Use the writing mode of the containing block when accessing CSS propertiesSimon Sapin2020-06-101-5/+30
| | | | | | | | … and converting them to flow-relative geometric values. These values are almost always used to size and position a fragment within its containing block, so using the mode of the containing block seems more correct. Note that the `writing-mode` and `direction` properties are disabled in Servo at the moment, so this PR by itself should have no effect: the writing mode of an element is always the same of that of its containing block since they’re both horizontal rtl.
* Store abspos boxes in a RefCell tooAnthony Ramine2020-06-091-6/+12
| | | | | | We want to mutate them when lazily computing their content sizes, but they are behind an Arc for the hoisting infra, so it also needs its own layer of inner mutability.
* layout_2020: Tag fragments with their pseudo content typeMartin Robinson2020-06-061-99/+70
| | | | | This will allow us to answer queries and properly handle animations in the future for fragments generated for pseudo content.
* Owned `ServoArc<ComputedValues>` in `TraversalHandler`Simon Sapin2020-06-041-19/+9
|
* Anonymous flex item for text directly in a flex containerSimon Sapin2020-06-041-0/+24
|
* Make LayoutNodeHelpers::text_content return a cowAnthony Ramine2020-03-311-1/+7
|
* Propagate text decoration where neededFernando Jiménez Moreno2020-03-231-7/+35
|
* Make whitespace preservation computation recursive in order to fix lifetime ↵Patrick Walton2020-03-171-25/+45
| | | | issues
* Wrap `BlockLevelBox` and `InlineLevelBox` with `AtomicRefCell`Patrick Walton2020-03-171-72/+72
|
* Make AbsolutelyPositionedBox be 'staticAnthony Ramine2020-03-171-4/+4
|
* Store an OpaqueNode in boxes and fragmentsAnthony Ramine2019-12-131-3/+9
|
* Remove the Node type parameter from ContentsAnthony Ramine2019-12-131-32/+72
| | | | We now pass the Node as an argument during DOM traversal in layout.
* Introduce BlockLevelJobAnthony Ramine2019-12-131-55/+64
|
* Upgrade rayon_croissant to 0.2.0Simon Sapin2019-12-121-15/+15
|
* Disable use of rayon with `--layout-threads 1` instead of panickingSimon Sapin2019-12-101-23/+31
|
* Fix a “Accessing content size that was not requested” panicSimon Sapin2019-12-101-3/+3
| | | | | | Percentage `width` are treated as `auto` for the purpose of min/max-content computation, so they also need to be considered when testing “wether width is auto”
* Use a new `BoxContentSizes` enum instead of `Option<ContentSizes>`Simon Sapin2019-12-041-18/+13
|
* Replace boolean parameters by a new `ContentSizesRequest` enumSimon Sapin2019-12-041-47/+44
|