aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow
Commit message (Collapse)AuthorAgeFilesLines
...
* layout: Add a `FontMetricsProvider` for resolving font-relative units (#31966)Martin Robinson2024-04-041-6/+5
| | | | | | | | | | | | | | | | | | | The only font relative unit that Servo knows how to resolve currently is `rem` (relative to the root font size). This is because Stylo cannot do any font queries. This adds a mechanism to allow this, exposing the ability to properly render `ex` units in Servo. This change only allows resolving some font size relative units thoug, as Servo doesn't collect all the FontMetrics it needs to resolve them all. This capability will be added in followup changes. Some new tests fail: - ex-unit-001.html: This test fails because Servo does not yet have support for setting the weight using @font-face rules on web fonts. - ex-unit-004.html: This test fails because Servo does not yet have support for setting the Unicode range of a web font using @font-face rules. - first-available-font-001.html: This test fails because the above two feature are missing.
* script: Split style and layout data in DOM nodes (#31985)Martin Robinson2024-04-041-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Implementation of baseline-source (#31904)Munish Mummadi2024-04-021-6/+12
| | | Updating Stylo and test expectations.
* Update Stylo to 2023-10-16 (#31932)Oriol Brufau2024-03-302-8/+10
| | | | | | | | | | | | | | | | | | | | | | | * Update Stylo to 2023-10-16 * Fixup for https://phabricator.services.mozilla.com/D185154 * Fixup for https://phabricator.services.mozilla.com/D188216 * Fixup for https://phabricator.services.mozilla.com/D185677 * Fixup for https://phabricator.services.mozilla.com/D188566 * Fixup for https://phabricator.services.mozilla.com/D188727 * Fixup for https://phabricator.services.mozilla.com/D189475 * Fixup for https://phabricator.services.mozilla.com/D189521 * Fixup for https://phabricator.services.mozilla.com/D188812 * Fixup for https://phabricator.services.mozilla.com/D189484 * Update test expectations
* Obey `white-space: pre-wrap` when intrinsically sizing an IFC (#31930)Oriol Brufau2024-03-291-10/+20
| | | It was being treated like `pre`, but it allows wrapping lines.
* layout: Use `Au` in `ResolvedMargins` and `CollapsedMargin` (#31848)Ekta Siwach2024-03-282-59/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * change ResolvedMargins to use Au instead of length * made suggested changes removed whitespace changes made suggested changes * Update components/layout_2020/flexbox/layout.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Update components/layout_2020/flow/mod.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * fixed errors fixed errors fixed formatting fixed errors * modified changes made suggested changes * Update components/layout_2020/fragment_tree/fragment.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> updated components/layout_2020/fragment_tree/fragment.rs * Update components/layout_2020/flow/mod.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Update components/layout_2020/flow/mod.rs Co-authored-by: Oriol Brufau <obrufau@igalia.com> * updated changes updated changes * unified all the suggested changes here * fixed formatting * reverted unnecessary changes * fixed unnecessary warnings --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Ignore spaces before atomic inline for the min-content size (#31896)Oriol Brufau2024-03-271-1/+4
| | | | | | | | | | | | | | | * Ignore spaces before atomic inline for the min-content size For the min-content size we should wrap lines wherever is possible, so wrappable spaces shouldn't increase the length of the line, they will just be removed or hang at the end of the line. * Add a clarifying comment Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Pick the first or last baseline as appropriate (#31705)Oriol Brufau2024-03-251-4/+17
| | | | | | | The old logic was always picking the last baseline, but this should only happen for inline-blocks. Since replaced elements and flex containers aren't currently setting their baselines, this is only an improvement for inline-tables.
* layout: use `Au` in `BoxFragment` (#31794)atbrakhi2024-03-224-46/+41
| | | | | * use au in BoxFragement * review fix
* layout: Take into account `text-indent` for justification (#31777)Martin Robinson2024-03-211-1/+6
| | | | | | This change makes it so that when calculating the space added between words for justification, text-indent is taken into account. Fixes #31775.
* clippy: Fix several warnings (#31710)RustAndMetal2024-03-183-9/+6
| | | Signed-off-by: RustAndMetal <111676747+RustAndMetal@users.noreply.github.com>
* rustdoc: Fix two warnings in `components/layout_2020` (#31712)Rhea-Eve2024-03-181-1/+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>
* Allow pre-wrap whitespace to hang at the end of the line (#31681)Oriol Brufau2024-03-151-18/+54
| | | | | * Allow pre-wrap whitespace to hang at the end of the line * Use bitflags
* Obey white-space when intrinsically sizing an IFC (#31660)Oriol Brufau2024-03-152-27/+28
| | | | | | | | | | | | | | | | | The old logic was assuming that all whitespace was a break opportunity, and that no newlines would be preserved. Note that text shaping considers the advance of a newline to be the same as a space. This was problematic because if we have a segment with a preserved space and newline, only the advance of the space should contrinute to the size of the block container. Therefore, I'm changing the breaker logic in other to have newline characters in their own segment. Then glyph_run_is_whitespace_ending_with_preserved_newline can just be renamed to glyph_run_is_preserved_newline. This patch is still not perfect because it doesn't check allow_wrap(), so `nowrap` is treated like `normal`, and `pre-wrap` like `pre`.
* dependencies: Upgrade to WebRender 0.64 (#31486)Martin Robinson2024-03-141-1/+1
| | | | | | | | | This brings the version of WebRender used in Servo up-to-date with Gecko upstream. The big change here is that HiDPI is no longer handled via WebRender. Instead this happens via a scale applied to the root layer in the compositor. In addition to this change, various changes are made to Servo to adapt to the new WebRender API. Co-authored-by: Mukilan Thiyagarajan <mukilan@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.
* layout: IFCs should not always be marked as containing floats (#31641)Martin Robinson2024-03-142-2/+4
| | | | | | | Marking all IFCs as containing floats shouldn't change layout results, but does prevent parallel layout in some cases. This change fixes an issue where we were marking all IFCs as containing floats. Fixes #31540.
* 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.
* rustdoc: Fix warnings in `components/layout_2020` (#31647)Aarya Khandelwal2024-03-131-2/+2
| | | | | * Added a : to make it a clickable link * changed block_offset_of_parent to parent_offset , to make it a clickable link.
* rustdoc: Fix warnings in `components/layout_2020` (#31640)Aarya Khandelwal2024-03-131-3/+3
| | | | | * Changed LineItems to LineItem to make it a clickable link * No variant named Anonymous is present in Fragment.
* Fix vertical alignment at the root of an IFC (#31636)Oriol Brufau2024-03-132-41/+56
| | | | | | | | | | | | | | At the root of an inline formatting context, we used its vertical-align in order to compute the strut. That was wrong, since vertical-align on a block container shouldn't affect the contents, it should only affect the alignment of the block container (if it's inline-level) within the parent IFC. This was only working well if the block container was block-level, since effective_vertical_align_for_inline_layout returned `baseline` for block-level boxes. Instead of the outer display type, this patch changes the logic to check whether we are at the root of the IFC.
* layout: Propagate overflow values from `<body>` to root element (#31618)Martin Robinson2024-03-131-2/+46
| | | | | | | The specification gives instructions for how these values should be propagated. The other big changs here is that they aren't applied to the `<body>`. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: make `margin` in `pbm` use app unit (#31621)atbrakhi2024-03-134-84/+88
| | | | | | | | | | | * make margin in pbm use app unit * Simplification * Consistently resolve inline margins as Au, like block margins --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* clippy: Fix warnings in `components/layout_2020` (#31611)eri2024-03-117-42/+34
| | | | | * clippy: fix warnings in components/layout_2020 * fix: review comments
* Take spaces into account in the max-content size of an IFC (#31613)Oriol Brufau2024-03-111-11/+9
| | | | | | They were only considered in min-content sizes. Also avoid some pointless conversions from Au to Length. Fixes #31605.
* 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.
* Fixed unresolved links by appropriately linking to parent (#31588)Wepngong Maureen2024-03-081-2/+2
| | | Signed-off-by: Wepngong Maureen <maureenwepngong@gmail.com>
* Fix rustdoc warnings in `components/layout_2020` (#31587)sandeep2024-03-082-3/+3
| | | | | | | | | | | | | | * fix rustdoc warnings in components/layout_2020 Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local> * made suggested changes Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local> --------- Signed-off-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local> Co-authored-by: Sandeep Pillai <sandeeppillai@Sandeeps-MacBook-Air.local>
* layout: Add start of documentation for inline layout (#31519)Martin Robinson2024-03-062-0/+67
| | | Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* Fix size of tables in flow layout (#31455)Oriol Brufau2024-03-023-71/+146
| | | | | | | | | | | | | | | | | | | | | | * 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: Turn on synthetic small-caps for layout 2020 (#31435)Martin Robinson2024-02-282-5/+4
| | | | | | | | | | | | Synthetic small caps is supported by the font subsystem, but this is disabled in Layout 2020. We can turn this on to bring support to parity with the old layout system. In addition to turning on synthetic small-caps this change also improves the way that they work. Before, synthetic small caps meant that every character was a small version of capitalized character. After this change, capital letters are larger than small caps versions of small letters -- matching other browsers and the common expectation of how small caps works.
* Support <div align="..."> and <center> in block layout (#31423)Oriol Brufau2024-02-261-18/+75
| | | | | | | | | As per HTML [1], <div align="..."> and <center> should align descendants to the left/center/right. This is similar to having 'auto' margins [2], but without changing their used values [3]. [1]: https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3 [2]: https://html.spec.whatwg.org/multipage/rendering.html#align-descendants [3]: https://github.com/whatwg/html/issues/10149
* layout: Add line height from preserved segment breaks in quirks mode (#31419)Martin Robinson2024-02-261-8/+33
| | | | | | | | | | In quirks mode, preserved segment breaks should add line height to lines. This matches the behavior of WebKit and Blink, but not Gecko. This also handles the special-case of `<br>` elements, which are implemented with preserved segment breaks via `white-space: pre-line`. This is an implementation detail though because `<br>` has a special behavior if the line isn't empty -- it doesn't add any line height in this case.
* layout: Place absolutes in IFCs at their hypothetical static position (#31418)Martin Robinson2024-02-231-25/+27
| | | | | | | | Absolutes need to be placed at their hypothetical position as if the position value was static. This position differs based on the value they had before blockification. The code for placing absolutes was taking into account the original display for the inline value, but not for the block value. A static `display: block` box would placed at a new block position past the end of the linebox.
* Support <div align="..."> and <center> on inline layout (#31388)Oriol Brufau2024-02-231-12/+15
| | | | | | | | | | As per HTML [1], <div align="..."> and <center> should behave as if they had the text-align property set to the corresponding value. Servo implements that as internal text-align values because there should the extra effect of aligning block descendants, but that part has not been implemented yet. This patch only adds support for inline layout. [1]: https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3
* layout: Add initial support for `text-transform` (#31396)Martin Robinson2024-02-222-11/+164
| | | | | | | | | | | | | This adds basic support for `text-transform` in a way that is more complete than legacy layout. There are still many missing elements of proper `text-transform` support such as: 1. Support for `full-width` and `full-size-kana` 2. Support for grapheme based uppercasing, lowercasing, and capitalization. These are all done per-code point right now. 3. Support for the language-specific `SpecialCasing.txt` cases for case mapping such as the ones for Irish and Turkish. Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* Do not adjust margins in over-constrained cases (#31345)Oriol Brufau2024-02-211-86/+121
| | | | | | | This deviates from css2, but it's mandated by css-align, and matches what other browsers do when no margin is 'auto'. When some margin is 'auto', this should keep the proper round-tripping behavior that Gecko and WebKit lack, and Blink recently adopted.
* layout: Add support for table rows, columns, rowgroups and colgroups (#31341)Martin Robinson2024-02-202-4/+4
| | | | | | | | | | | | | | This adds support for table rows, columns, rowgroups and colgroups. There are few additions here: 1. The createion of fragments, which allows script queries and hit testing to work properly. These fragments are empty as all cells are still direct descendants of the table fragment. 2. Properly handling size information from tracks and track groups as well as frustrating rules about reordering rowgroups. 3. Painting a background seemlessly across track groups and groups. This is a thing that isn't done in legacy layout (nor WebKit)! Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* make ContainingBlock use Au for inline_size and block_size (#31370)atbrakhi2024-02-203-49/+42
|
* make size of DefiniteContainingBlock use app units (#31369)atbrakhi2024-02-172-3/+3
|
* layout: Do whitespace collapse during breaking and shaping (#31322)Martin Robinson2024-02-133-253/+279
| | | | | | | | 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: make `padding` and `border` use `Au` in `pbm` (#31289)atbrakhi2024-02-124-99/+108
| | | | | * use au for padding and border in pbm * review fix
* layout: Implement support for font fallback (#31254)Martin Robinson2024-02-113-193/+476
| | | | | | | 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: Start work on table row height and vertical-align (#31246)Martin Robinson2024-02-101-39/+49
| | | | | | | | | 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: Use `BoxFragment` border widths for display list generation (#31292)Martin Robinson2024-02-081-5/+0
| | | | | | | Instead of using the border widths from the style, use the ones recorded by the `BoxFragment`. This is necessary because inline layout can override these border widths during fragmentation. For instance, when a box is split across two lines only one fragment should have an inline start border.
* layout: Wait to count justification opportunities until justification (#31236)Martin Robinson2024-02-062-72/+38
| | | | | | | | | | Instead of tracking justification opportunities during line layout, wait until the line is about to be laid out and justification is about happen. This makes the logic for tracking justification opportunities simpler. In particular, we no longer have to carefully adjust them when trimming whitespace. Additionally, this avoids a bit of work unless justification is turned on. This also includes a small cleanup of the justification code.
* layout: Collect both start and end baselines for fragments (#31230)Martin Robinson2024-02-054-78/+68
| | | | | | | | 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>
* use app unit in replaced elements (#31178)atbrakhi2024-01-293-13/+16
| | | | | | | | | | | | | | | | | * use app unit in replaced elements * more app unit usage * Avoid unnecessary into() * Run ./mach fmt * use scaleby * update --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Implement computation of table column widths (#31165)Martin Robinson2024-01-251-4/+5
| | | | | | | | | | | | | | | | | * layout: Implement computation of table column widths This change implements the various steps of table column width computation, ignoring features that don't exist yet (such as separated borders, column elements, and colgroups). Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Fix an issue with the assignment of column percent width * Respond to review comments --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Shape text only once (#31146)Martin Robinson2024-01-254-239/+262
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. -->