aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/fragment_tree
Commit message (Collapse)AuthorAgeFilesLines
* 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).
* Re-use the TextMetrics data structure in the Layout 2020 fragment tree (#30823)Martin Robinson2023-12-061-24/+1
| | | | | | | This data structure has all of the metrics needed to render a font and is in `Au`. We'll need more of these metrics for implementing `vertical-align` and its use doesn't increase the size of the Fragment tree (as the BoxFragment is still larger). In addition, this will be helpful when switching layout to `Au`.
* Add initial support for sticky positioning for non-legacy layout (#30686)Martin Robinson2023-11-291-9/+27
| | | | | | | | | | * Add initial support for sticky positioning for non-legacy layout Many tests still fail for a variety of reasons. One of the primary ones is that CSSOM currently does not return correct values for elements positioned by sticky nodes. This requires changes to WebRender to work properly. * Fix an assertion failure in the legacy layout sticky code
* Further changes required by ServoOriol Brufau2023-11-241-2/+2
|
* Temporarily convert existing cfg(debug_assertions) crashes to warnings (#30578)Delan Azabani2023-10-181-4/+5
|
* Refactor scrolls on the window object (#29680)Martin Robinson2023-09-152-28/+27
| | | | | | | | | | | | | | Refactor the scrolling and scrollable area calculation on the window object, to make it better match the specification. This has some mild changes to behavior, but in general things work the same as they did before. This is mainly preparation for properly handling viewport propagation of the `overflow` property but seems to fix a few issues as well. There is one new failure in Layout 2020 regarding `position: sticky`, but this isn't a big deal because there is no support for `position: sticky` in Layout 2020 yet. Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
* Layout 2020: Rename `flow_relative` types to `Logical...` (#30324)Martin Robinson2023-09-123-28/+28
| | | | | | This makes the names of flow relative geometry consistent with what is used in the style crate and removes them from a module. With this change it's more obvious what makes these types different from the ones in `euclid`.
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-116-19/+27
| | | | | * strict imports formatting * Reformat all imports
* remove `extern crate` (#30311)Samson2023-09-085-0/+5
| | | | | | | | | | | * remove extern crate * Update components/script_plugins/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* build(deps): bump bitflags from 1.3.2 to 2.3.1 (#30273)Martin Robinson2023-09-011-3/+3
| | | | | | Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.3.2 to 2.3.1. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/1.3.2...2.3.1)
* Layout floats as children of their inline ancestors (#30130)Martin Robinson2023-08-221-13/+0
| | | | | | | | | | | | | | | When layout was split into two phases, floats were laid out as direct children of the inline formatting context. This meant that they were positioned properly, but not properly made children of their inline ancestors' stacking contexts. This change maintains the proper positioning of floats, but positions them relatively to their inline ancestors. The big change here is that `text-align` needs to be taken into account before actually laying out LineItems. This has the added benefit of setting inline layout for the implementation of `text-align: full`. Now all line items are laid out at the real final position and we can adjust the `start_corner` property of float `BoxFragments` when their ancestors are laid out.
* Split line layout into two phases (#30089)Martin Robinson2023-08-112-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the first phase, we gather LineItems and then when we have enough to form a line we turn them into Fragments. This will make it possible to more simply implement `vertical-align` and `text-align: justify` because we need to measure the different aspects of the candidate line and then produce a Fragments. This is a general refactor of the way that inline layout works, so comes with some progressions. In addition there are some new failures. New failures: Some tests are now failing because only the test or reference is getting proper line height when it wasn't before. These should be fixed in a followup change that properly calculate line-height in more cases: - /_mozilla/css/list_style_position_a.html - /css/CSS2/floats/float-no-content-beside-001.html - /css/css-content/pseudo-element-inline-box.html - /css/css-flexbox/flexbox_flex-none-wrappable-content.html Some tests are now failing because floats are now placed properly, but are no longer in their inline box stacking contexts. These will be fixed by a followup change which properly parents them: - /css/filter-effects/filtered-inline-applies-to-float.html.ini - /css/css-color/inline-opacity-float-child.html.ini One test is failing due to floating point precision errors: - /css/CSS2/floats-clear/floats-141.xht.ini Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Try to `use` WebRender types moreMartin Robinson2023-07-101-2/+3
| | | | | The newer versions of WebRender move types around between `webrender` and `webrender_api` and this will reduce the churn during the upgrade.
* Layout 2020: implement clearance as Option<Length>Oriol Brufau2023-06-291-3/+9
| | | | | | | | | | Clearance was implemented as a Length, where zero meant no clearance. However, having a clearance of 0px should be different than having no clearance, since the former can still prevent margin collapse. This patch keeps the existing behavior, so it won't be possible to get a clearance of Some(Length::zero()), but it prepares the terrain for a follow-up to fix calculate_clearance to return the proper thing.
* Layout 2020: Move all Fragment code to the `fragment_tree` directoryMartin Robinson2023-06-047-3/+941
| | | | | | | | This is a simple code organization change with no behavior change with the idea of making Layout 2020 easier to understand by new folks to the project. The idea is that we will have a cleaner separation between the different parts of layout ie one directory for the fragment tree and one (currently multiple) directory for the box tree.
* Convert some comments into rustdocMartin Robinson2023-06-011-30/+30
| | | | | These were always meant to be rustdoc and converting them makes them show up in the IDE in a more helpful way.
* Better implement getComputedStyle() for positioned insetsMartin Robinson2023-05-092-0/+101
| | | | | | | | The specification dictates quite quite idiosyncratic return values when querying insets of positioned elements via getComputedStyle(). These depend on whether or not the elements size was overconstrained. This change adds a better implementation of that in preparation for returning proper values for position: sticky.
* Detect body elements during layoutMartin Robinson2023-05-042-0/+124
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.