aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/fragment_tree
Commit message (Collapse)AuthorAgeFilesLines
* Add `BoxFragment::is_inline_box()` (#34233)Oriol Brufau2024-11-122-4/+9
| | | | | A helper function to check for inline boxes. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Fix geometry queries for floats and replaced inlines (#34083)Oriol Brufau2024-10-311-2/+5
| | | | | APIs like `clientWidth` were returning zero. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Improve how intrinsic sizes work for videos (#31746)eri2024-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * feat: patch for video layout sizes added rebase from main 2024/10/05 Co-authored-by: Josh Matthews <josh@joshmatthews.net> Signed-off-by: eri <epazos@igalia.com> * feat: take width and height parameters if provided Signed-off-by: eri <epazos@igalia.com> * chore: tidy the code and update test expectations Signed-off-by: eri <epazos@igalia.com> * feat: handle removing poster Signed-off-by: eri <epazos@igalia.com> * chore: update test expectations and remove debug code Signed-off-by: eri <epazos@igalia.com> * fix: issues after rebasing to main Signed-off-by: eri <epazos@igalia.com> * feat: pass src remove test and tidy Signed-off-by: eri <epazos@igalia.com> * chore: clippy fixes Signed-off-by: eri <epazos@igalia.com> * chore: update passing test expectations Signed-off-by: eri <epazos@igalia.com> * fix object-position-svg test Signed-off-by: eri <epazos@igalia.com> * fix unintentional override of video size and resize events Signed-off-by: eri <epazos@igalia.com> * change how resize events are sent to better match the spec Signed-off-by: eri <epazos@igalia.com> * simplify poster mutation handling Co-authored-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: eri <eri@inventati.org> * improved handling of intrinsic sizes - differentiate between natural size and css size - presentational attributes - fallback ratio for video element - handle more cases where the src/poster are added/removed - aspect ratio hints Signed-off-by: eri <epazos@igalia.com> * update test expectations Signed-off-by: eri <epazos@igalia.com> * fix cleaning current frame Signed-off-by: eri <epazos@igalia.com> * update test expectations Signed-off-by: eri <epazos@igalia.com> * Apply suggestions from code review Co-authored-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: eri <eri@inventati.org> * More code review suggestions Signed-off-by: eri <epazos@igalia.com> * Prevent aspect-ratio:auto from pulling the ratio from the default object size As resolved in https://github.com/w3c/csswg-drafts/issues/7524#issuecomment-1204462924 Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: eri <epazos@igalia.com> Signed-off-by: eri <eri@inventati.org> Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Avoid layout sometimes when stretching (#33967)Martin Robinson2024-10-241-0/+4
| | | | | | | | | | | | | | | | | | | | 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>
* Upgrade Stylo to 2024-10-04 (#33767)Oriol Brufau2024-10-201-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Upgrade Stylo to 2024-10-04 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D220285 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://bugzilla.mozilla.org/show_bug.cgi?id=1918093 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222817 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222856 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222532 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222533 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222534 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D223878 Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Remove BoxFragment::overconstrained (#33907)Oriol Brufau2024-10-191-51/+15
| | | | | | | | This was only used for serializing inset properties in getComputedStyle, but it was unnecessary and the logic was wrong anyways: an `auto` size doesn't imply that we won't be overconstrained, because it won't become negative even if the insets are big enough. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Fix resolved value of insets to use margin box instead of content box (#33906)Oriol Brufau2024-10-181-5/+4
| | | Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Remove dead (and incorrect) logic about vertical overconstrainment (#33696)Oriol Brufau2024-10-081-10/+1
| | | | | | | | | | | | | | | BoxFragment::new() had some logic to mark relative positioned boxes with both insets in the same axis set to something different than `auto` as overconstrained. However, this was dead code, since overconstrainment is checked for getComputedStyle queries, but not for relative positioning. Also, the logic was wrong: it was detecting vertical overconstrainment by checking `left` and `bottom` (instead of `top` and `bottom`). So it can just be removed. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Add support for `object-fit` and `object-position` (#33479)Martin Robinson2024-09-181-0/+1
| | | | | | | | | | This also makes a couple small improvements: - Rename `IntrinsicSizes` to `NaturalSizes` which reflects more modern spec language. - Move the conversion of Stylo's `ImageRendering` to WebRender's version to a `ToWebRender` trait implementation. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Let table-related boxes adjust their `overflow` values (#33400)Oriol Brufau2024-09-111-5/+5
| | | | | | | | | | The `overflow` property doesn't apply to table track and track groups, and table elements only accept a few `overflow` values. Therefore, this patch adds an `effective_overflow()` method to get the actual value that needs to be used. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Right-to-left support for other layout modes (#33375)Martin Robinson2024-09-113-16/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change removes the `effective_writing_mode` concept and tries to properly implement right-to-left layout support for all non-inline writing modes. In general, what needs to happen is that rectangles need to be converted to physical rectangles using the containing block. A right-to-left rectangle's inline start is on the right physical side of the containing block. Likewise a positive inline offset in right-to-left text is a negative physical one. The implementation here is pretty good for most layout modes, but floats are still a bit in process. Currently, floats are processed in the logical layout of the block container, but there still might be issues with float interaction with mixed RTL and LTR. While this does move us closer to supporting vertical writing modes, this is still unsupported. New failures: - Vertical writing mode not supported: - `/css/CSS2/floats/floats-placement-vertical-001b.xht` - `/css/CSS2/floats/floats-placement-vertical-001c.xht` - Absolutes inlines should avoid floats (#33323) - `/css/css-position/position-absolute-dynamic-static-position-floats-004.html` - No support for grid - `/css/css-align/self-alignment/self-align-safe-unsafe-grid-003.html` - `/css/css-position/static-position/inline-level-absolute-in-block-level-context-009.html` - `/css/css-position/static-position/inline-level-absolute-in-block-level-context-010.html` - Cannot reproduce these locally on any platform. Very mysterious: - `/css/css-tables/row-group-margin-border-padding.html` - `/css/css-tables/row-margin-border-padding.html` - Exposes bugs we have related to hanging whitespace in preserved whitespace inlines: - `/css/css-text/white-space/trailing-space-and-text-alignment-rtl-003.html` - `/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-023.html` Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* layout: Use `Au` in `ComputedValuesExt` (#33396)atbrakhi2024-09-101-28/+21
| | | | | | | | | | | | | | | | | | | | * 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>
* layout: Implement proper absolute child position for flexbox (#33346)Martin Robinson2024-09-091-40/+22
| | | | | | | | | | | This implements the requirements outlined in the [flexbox specification] about how to position absolute children of flex containers. We must establish a static position rectangle (to use if all insets are auto) and also align the child into that rectangle. [flebox specification]: https://drafts.csswg.org/css-flexbox/#abspos-items Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Prepare for bidi by guarding all access to `writing-mode` (#33082)Martin Robinson2024-08-161-9/+10
| | | | | | | | | 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: Convert the FragmentTree to physical geometry (#33030)Martin Robinson2024-08-144-138/+90
| | | | | | | | | | | | | | | | This converts all geometry in the FragmentTree into physical geometry, doing conversions ahead of time instead of when traversing the fragment tree. This is necessary to properly implement BiDi in Servo as we need to know what side borders are on in mixed RTL and LTR contexts. In addition, fragments are laid out in a particular context and only that context knows its writing mode. There were issues where were using one writing mode to lay out and another to convert to phyisical coordinates. This isn't an issue now since we only use the default writing mode, but starts to be an issue with BiDi text. Closes #25564. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* clippy: Fix various clippy warnings throughout the code (#33003)Ashwin Naren2024-08-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * replace u64::max_value() with u64::MAX Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * removed redundant import Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * Fixed dereference Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * Fixed a probable bug Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * fixed imports Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * fixed dereference Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * dereference formatting Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * removed unnessicary number imports Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * removed unnessicary number imports Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * removed excess borrow Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * ran mach fmt Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * fixed doc comment Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * removed deref on an immutable reference Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * fixed minor syntax error Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * reverted clamping Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * formatting Signed-off-by: Ashwin Naren <arihant2math@gmail.com> * reverted final clamp Signed-off-by: Ashwin Naren <arihant2math@gmail.com> --------- Signed-off-by: Ashwin Naren <arihant2math@gmail.com> Co-authored-by: Ashwin Naren <ashwin@pixelators.org>
* layout: Non-auto `z-index` should always make stacking contexts for flex ↵Martin Robinson2024-08-121-6/+8
| | | | | | items (#32961) Fixes #32756. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* layout: Add support for table captions (#32657)Martin Robinson2024-07-032-10/+15
| | | | | | | | | | | | | 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>
* use au in TextFragment (#32653)atbrakhi2024-07-031-2/+1
|
* fix clippy warning (#32667)atbrakhi2024-07-021-6/+1
|
* use app unit in box_fragement (#32349)atbrakhi2024-06-214-71/+66
|
* Rename `gfx` to `fonts` (#32556)Martin Robinson2024-06-191-2/+1
| | | | | | | | | This crate only takes care of fonts now as graphics related things are split into other crates. In addition, this exposes data structures at the top of the crate, hiding the implementation details and making it simpler to import them. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* layout: Take into account `display: table` etc in offset* queries (#32448)Martin Robinson2024-06-101-3/+7
| | | | | | | | | | | | | | | * layout: Take into account `display: table` etc in offset* queries The specification says that for deciding whether an element should be used for offset* queries, a browser should take into account whether the element is a table cell or table. This change makes that happen. Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Only tag HTML elements if they are in the HTML namespace --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Implement 'empty-cells' for layout 2020 (#32331)Oriol Brufau2024-05-211-0/+3
| | | | | https://drafts.csswg.org/css-tables/#empty-cell-rendering Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* compositor: Move WebRender-ish messages and types to `webrender_traits` (#32315)Mukilan Thiyagarajan2024-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | * Move WebRender related types to `webrender_traits` This refactor moves several WebRender related types from `compositing_traits`, `script_traits` and `net_traits` crates to the `webrender_traits` crate. This change also moves the `Image` type and associated function out of `net_traits` and into the `pixels` crate. Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> * Move `script_traits::WebrenderIpcSender` to `webrender_traits::WebRenderScriptApi` --------- Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Move non-gfx things out of `gfx_traits` and create a `base` crate (#32296)Martin Robinson2024-05-175-6/+6
| | | | | | | | | | | | | | | | | | | | | | | For a long time, `gfx_traits` has held a lot of things unrelated to graphics and also unrelated to the `gfx` crate (which is mostly about fonts). This is a cleanup which does a few things: 1. Move non `gfx` crate things out of `gfx_traits`. This is important in order to prevent dependency cycles with a different integration between layout, script, and fonts. 2. Rename the `msg` crate to `base`. It didn't really contain anything to do with messages and instead mostly holds ids, which are used across many different crates in Servo. This new crate will hold the *rare* data types that are widely used. Details: - All BackgroundHangMonitor-related things from base to a new `background_hang_monitor_api` crate. - Moved `TraversalDirection` to `script_traits` - Moved `Epoch`-related things from `gfx_traits` to `base`. - Moved `PrintTree` to base. This should be widely useful in Servo. - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it to `WebRenderFontApi`.
* use au in HoistedSharedFragment (#32288)atbrakhi2024-05-161-4/+5
|
* layout: Ensure empty list items are at least as tall as outside markers (#32152)Martin Robinson2024-04-291-0/+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>
* Address issues uncovered by rust-1.78 beta (#32130)Martin Robinson2024-04-221-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change makes changes to allow Servo to compile with the 1.78 version of Rust: - Dead code is removd (Rust seems to have gotten better at detecting it). - The `FlowRef` `DerefMut` is updated according to @SimonSapin's advice [^1]. - The `imports.rs` now explicitly silences warnings about unused imports. [^1]: https://github.com/servo/servo/issues/6503#issuecomment-2066088179 <!-- 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 they should not change behavior. <!-- 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. -->
* chore: Clean up use of `gfx` and `constellation` types (#31981)Martin Robinson2024-04-091-1/+1
| | | | | | | | | | | | This change contains three semi-related clean ups: 1. the `to_webrender()` and `from_webrender()` functions on Pipeline are turned into more-idiomatic `From` and `Into` implementations. 2. `combine_id_with_fragment_type` now returns a `u64` as that is what is expected for all callers and not a `usize`. 3. The `query_scroll_id` query is removed entirely. The `ExternalScrollId` that this queries is easily generated directly from the node's opaque id. Querying into layout isn't necessary at all.
* layout: Use `Au` in `ResolvedMargins` and `CollapsedMargin` (#31848)Ekta Siwach2024-03-281-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* layout: Allow transforming inline replaced elements (#31833)Martin Robinson2024-03-272-2/+5
| | | | | | | | | | 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.
* layout: use `Au` in `BoxFragment` (#31794)atbrakhi2024-03-221-16/+20
| | | | | * use au in BoxFragement * review fix
* layout: Add basic support for `getClientRects()` queries (#31696)Martin Robinson2024-03-151-23/+12
| | | | | | This adds basic support for `getClientRects()` by sharing code with the implementation of `getBoundingClientRect()`. In addition to sharing code, it also shares all of the bugs. Primarily, scrolilng positions are not taken into account when return boundary rectangles.
* rustdoc: Fix errors in `components` and `ports` (#31654)Tumuhairwe2024-03-152-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Fixed warnings in components/gfx/text/shaping/harfbuzz-rs components/layout_2020/fragment_tree ports/servoshell/minibrowser.rs * Fixed warnings in components/gfx/text/shaping/harfbuzz-rs components/layout_2020/fragment_tree ports/servoshell/minibrowser.rs. * Update minibrowser.rs Returned "if" back to "iff" * Update minibrowser.rs Changed ```BrowserManager``` to ```WebViewManager``` * Update fragment.rs Changed ```[SequentialLayoutState]``` to ```[crate::flow::float::SequentialLayoutState]``` * Update fragment.rs Balanced the length of paragraph lines in fragment.rs * Fix tidy errors --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* dependencies: Upgrade to WebRender 0.64 (#31486)Martin Robinson2024-03-141-1/+2
| | | | | | | | | 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>
* layout: Properly parent table-row and table-row-group (#31619)Martin Robinson2024-03-141-3/+23
| | | | | | | | Put table cell content fragments into a hieararchy of fragments that include their table row and table row group fragments. This ensures that things like relative positioning and transforms set on rows and row groups properly affect cells and cell content. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Propagate overflow values from `<body>` to root element (#31618)Martin Robinson2024-03-131-1/+4
| | | | | | | 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>
* clippy: Fix warnings in `components/layout_2020` (#31611)eri2024-03-114-8/+7
| | | | | * 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-4/+11
| | | | | | | 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: Add line height from preserved segment breaks in quirks mode (#31419)Martin Robinson2024-02-261-1/+3
| | | | | | | | | | 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: Add support for table rows, columns, rowgroups and colgroups (#31341)Martin Robinson2024-02-205-87/+162
| | | | | | | | | | | | | | 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>
* layout: Start work on table row height and vertical-align (#31246)Martin Robinson2024-02-101-0/+2
| | | | | | | | | 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-11/+27
| | | | | | | | 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>
* layout: return None bounding box when no nodes found (#31253)Smitty2024-02-021-11/+17
| | | Signed-off-by: syvb <me@iter.ca>
* layout: Round `clientTop`, etc queries to pixels properly (#31187)Martin Robinson2024-01-271-11/+13
| | | | | | | | | | | | | | | | * layout: Round getClientRect queries to pixels properly Instead of just flooring all pixels in getClientRect queries, we should round the rectangle. * Fix scrollWidth/scrollHeight too, and tests * Tests passing * Test expectation for legacy layout --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Lint layout_2020 with clippy (#31169)Oriol Brufau2024-01-256-29/+23
| | | cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
* rustdoc: Fix many rustdoc errors (#31147)Martin Robinson2024-01-223-7/+7
| | | | This fixes many rustdoc errors that occur due to raw URLs in rustdoc comments as well as unescaped Rust code that should be in backticks.
* layout: Implement support for `line-height` and `vertical-align` (#30902)Martin Robinson2024-01-081-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * layout: Implement support for `line-height` and `vertical-align` This is an initial implementation of proper `line-height` and `vertical-align` support. While this change includes the bulk of the work there are still many missing pieces for full support. In particular some big missing things are: - Flex containers do not properly compute their baselines. The idea is to tackle this in a followup change. This causes various flex tests to start failing because everything used to be top aligned. - The implementation of the line-height quirks (only active in quirks mode) are incomplete. While the quirk works in many cases, there are still some cases where it is handled incorrectly. This requires more redesign and refinement, better suited for a followup. - Most of the features are CSS 3 such as precision control of the baseline and first and last baselines are not implemented. This change gets us close to CSS 2.x support. While there are many new test passes with this change some tests are starting to fail. An accounting of new failures: Tests failing also in Layout 2013: - /css/css2/positioning/toogle-abspos-on-relpos-inline-child.html (only passes in Chrome) - /css/CSS2/fonts/font-applies-to-001.xht (potentially an issue with font size) Invalid tests: - /css/CSS2/visudet/inline-block-baseline-003.xht - /css/CSS2/visudet/inline-block-baseline-004.xht - These are are failing in all browsers. See https://bugs.chromium.org/p/chromium/issues/detail?id=1222151. Missing table support: - /_mozilla/mozilla/table_valign_middle.html Missing `font-size-adjust` support : - /css/css-fonts/font-size-adjust-zero-2.html (also failing in 2013) Incomplete form field support : - /html/rendering/widgets/the-select-element/option-add-label-quirks.html (label isn't rendered so button isn't the right size in quirks mode due to line height quirk) Need support for calculating flexbox baseline: - /css/css-flexbox/fieldset-baseline-alignment.html - /css/css-flexbox/flex-inline.html - /css/css-flexbox/flexbox-baseline-multi-line-horiz-001.html - /css/css-flexbox/flexbox-baseline-single-item-001a.html - /css/css-flexbox/flexbox-baseline-single-item-001b.html Failing because we don't create anonymous inline boxes for text children of blocks: - /css/CSS2/linebox/anonymous-inline-inherit-001.html Passes locally (potentially related to fonts): - /css/CSS2/css1/c414-flt-fit-004.xht - /css/css-transforms/transform-input-017.html - /html/obsolete/requirements-for-implementations/the-marquee-element-0/marquee-min-intrinsic-size.html - /css/css-fonts/first-available-font-005.html - /css/css-fonts/first-available-font-006.html * Some cleanups after live review with @mukilan Also update results.
* Add basic support for `text-align: justify` (#30807)Martin Robinson2023-12-151-0/+4
| | | | This also enables parsing of `text-justify` for non-legacy layout, though only None is supported (disabling justification).