aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020
Commit message (Collapse)AuthorAgeFilesLines
...
* CI: Fail the lint job when cargo-clippy reports some warnings (#33941)tanishka2024-10-211-1/+1
| | | | | | | | | | | | | | | | | | | * Fail the lint job when cargo-clippy reports some warnings Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Remove todo comment Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * clippy: use Option::take instead of mem::replace Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Refactor positioned layout (#33922)Oriol Brufau2024-10-212-254/+197
| | | | | | | | | | | | | | | This unifies the size resolution into AbsoluteAxisSolver, since it needs to know the size in order to resolve auto margins correctly anyways. This will allow adding support for sizing keywords in a follow-up patch. Also, this avoids doing multiple layouts due to min and max constraints, improving performance. Additionally, tables may end up having a custom size, different than what we would expect by just looking at the sizing properties. This patch ensures that we resolve margins correctly with the final size, resulting in 2 tests now passing. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* clippy: fix explicit lifetime warning in ↵Noble Chinonso2024-10-211-2/+2
| | | | | components\layout_2020\style_ext.rs:320:20 (#33936) Signed-off-by: Noble <nobleuwuja@gmail.com>
* clippy: fix using clone() warning in ↵Noble Chinonso2024-10-211-4/+4
| | | | | components\layout_2020\display_list\mod.rs:1365:25 (#33935) Signed-off-by: Noble <nobleuwuja@gmail.com>
* Upgrade Stylo to 2024-10-04 (#33767)Oriol Brufau2024-10-206-37/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-192-71/+16
| | | | | | | | 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>
* clippy: Fix a variety of clippy warnings in `fonts`, `layout_2020` and the ↵chickenleaf2024-10-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DOM code (#33894) * fixed some clippy warnings Signed-off-by: L Ashwin B <lashwinib@gmail.com> * Delete extra file Signed-off-by: chickenleaf <lashwinib@gmail.com> * preserved newline in compositionevent.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: chickenleaf <lashwinib@gmail.com> * removed the newline in PrototypeList Signed-off-by: L Ashwin B <lashwinib@gmail.com> * removed the trailing whitespace Signed-off-by: L Ashwin B <lashwinib@gmail.com> --------- Signed-off-by: L Ashwin B <lashwinib@gmail.com> Signed-off-by: chickenleaf <lashwinib@gmail.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Minor cleanup for `Size` after #33844 (#33861)Oriol Brufau2024-10-163-11/+5
| | | Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Gate all use of `tracing` behind Cargo feature (#33845)Delan Azabani2024-10-163-20/+36
| | | Signed-off-by: Delan Azabani <dazabani@igalia.com>
* Avoid wrapping line at the start of text run with `text-wrap-mode: nowrap` ↵Oriol Brufau2024-10-161-4/+4
| | | | | | | | | (#33848) When computing the min-content size of an inline formatting context, we could allow a soft wrap opportunity at the start of a text run. This shouldn't happen with `text-wrap-mode: nowrap`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Remove SizeKeyword, merge it into Size (#33844)Oriol Brufau2024-10-153-45/+36
| | | | | It's not really useful to have it. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Avoid recomputing inline_content_sizes() when not needed (#33806)Oriol Brufau2024-10-1412-139/+257
| | | | | | | | | | | The result of `inline_content_sizes()` may depend on the block size of the containing block, so we were always recomputing in case we got a different block size. However, if no content has a vertical percentage or stretches vertically, then we don't need to recompute: the result will be the same anyways. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Unify logic for laying out floats and atomic inlines (#33802)Oriol Brufau2024-10-114-320/+224
| | | Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Handle inline margins in `layout_for_block_content_size()` (#33780)tanishka2024-10-101-1/+3
| | | | | | | | | | | | | * fix: Handle inline margins in layout_for_block_content_size() Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Update test expectations Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* Improve `Au(0)` constructions (#33709)birdbrained2024-10-101-5/+5
| | | | | This replaces `Au(0)` with `Au::zero()` and other utility functions when possible. Signed-off-by: hackerbirds <120066692+hackerbirds@users.noreply.github.com>
* Implement keyword sizes on atomic inlines (#33737)Oriol Brufau2024-10-101-39/+73
| | | | | | | | | Adds support for min-content, max-content, fit-content and stretch, for atomic inlines. There are some new test failures because we don't support vertical writing modes nor `transition-behavior:allow-discrete`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Use `content_box_sizes_and_padding_border_margin_deprecated()` in ↵Adavize Promise2024-10-101-12/+2
| | | | | | | | | | | | | | | | | | | `FlexItem::new()` (#33754) * Use content_box_sizes_and_padding_border_margin_deprecated() in FlexItem::new() Signed-off-by: PS Adavize <siyakapromise@gmail.com> * remove unnecessary variable declaration declaration Signed-off-by: PS Adavize <siyakapromise@gmail.com> * Remove redundant variable pbm Signed-off-by: PS Adavize <siyakapromise@gmail.com> --------- Signed-off-by: PS Adavize <siyakapromise@gmail.com>
* Fix writing mode in `content_box_sizes_and_padding_border_margin()` (#33773)Oriol Brufau2024-10-101-1/+1
| | | | | | This method should use the writing mode from the containing block, not the one of the current style. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Implement keyword sizes on floats (#33666)Oriol Brufau2024-10-082-41/+141
| | | | | | Adds support for min-content, max-content, fit-content and stretch, for floated elements. 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: Avoid double negation in `CellLayout::is_empty_for_empty_cells()` ↵Taym Haddadi2024-10-071-3/+2
| | | | | | | | | | | | | | | | | | | (#33688) * Avoid double negation in is_empty_for_empty_cells() Signed-off-by: Taym <haddadi.taym@gmail.com> * Remove more negation Signed-off-by: Taym <haddadi.taym@gmail.com> * Fix format Signed-off-by: Taym <haddadi.taym@gmail.com> --------- Signed-off-by: Taym <haddadi.taym@gmail.com>
* Fix `align-content` set to `start` or `end` on flexbox (#33667)Oriol Brufau2024-10-071-5/+7
| | | | | We need to handle `flex-wrap: wrap-reverse`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Skip anonymous blocks for percentage resolution (#33658)Oriol Brufau2024-10-051-8/+36
| | | | | | | | | Anonymous blocks have `height: auto`, so children with a percentage `height` were considered to have an indefinite height. However, anonymous blocks need to be skipped for percentage resolution, so the percentages may actually be definite. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* tools: Improve instrumentation and add it for some layout (#33647)Martin Robinson2024-10-053-0/+24
| | | | | | | Improves the instrumentation to skip all function arguments and also add spans for some layout modes. This is preparation for improving the performance of flexbox. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* clippy: Fix too_many_arguments warnings (#33648)tanishka2024-10-042-0/+5
| | | Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* Refactor sizing logic for table measures (#33579)Oriol Brufau2024-10-011-31/+34
| | | | | | | | | | After #33577, `get_outer_sizes_from_style()` is only used for column and cell measures. For these it's expected to ignore sizing keywords like `min-content`, so rename the function to `get_outer_sizes_for_measurement()`. Additionally, both callers need the percentage contribution, so include it in the returned tuple. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* fonts: Make `FontKey` and `FontInstanceKey` generation asynchronous (#33600)Martin Robinson2024-10-012-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | Instead of a blocking a layout thread on the generation of WebRender `FontKey`s and `FontInstanceKey`s, generate the keys ahead of time and send the font data to WebRender asynchronously. This has the benefit of allowing use of the font much more quickly in layout, though blocking display list sending itself on the font data upload. In order to make this work for web fonts, `FontContext` now asks the `SystemFontService` for a `FontKey`s and `FontInstanceKey`s for new web fonts. This should happen much more quickly as the `SystemFontService` is only blocking in order to load system fonts into memory now. In practice this still drops layout thread blocking to fractions of a millisecond instead of multiple milliseconds as before. In addition, ensure that we don't send font data or generate keys for fonts that are used in layout but never added to display lists. This should help to reduce memory usage and increase performance. Performance of this change was verified by putting a microbenchmark around `FontContext::create_font` which is what triggered font key generation. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Simplify the computation of CAPMIN (#33577)Oriol Brufau2024-09-282-45/+30
| | | | | | | | | | | | CAPMIN is the largest min-content contribution of the table captions. In Servo, the standard way to compute min/max-content contributions is `outer_inline_content_sizes()`, so just use that instead of reinventing the wheel. This also fixes cyclic percentages to resolve consistently with normal block boxes. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Don't recompute percentage contribution for table row (#33575)Oriol Brufau2024-09-281-8/+1
| | | | | We already computed it as part of the row measure. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Make ComputedValuesExt expose keywords for the sizing properties (#33558)Oriol Brufau2024-09-2711-190/+312
| | | | | | | | | | | | | | | | This will allow callers to start obeying `min-content`, `max-content`, `fit-content` and `stretch` in follow-up patches. The old functionality is kept as deprecated methods that we should eventually remove. This patch has very little impact on the existing behavior, just some very minimal implementation of the keywords for css tables. This also overhauls fixed-layout-2.html since: - It had code that wasn't doing anything - It had wrong expecations in prose - The logic seemed broken in general - All browsers were failing one testcase Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Fix table track constrainedness (#33550)Oriol Brufau2024-09-262-16/+23
| | | | | | | | | | | | | | | | | | | | | | | | * Fix table track constraindness Only as size that isn't `auto` and doesn't contain percentages can constrain a table track (https://drafts.csswg.org/css-tables/#constrainedness). However, in a bunch of cases we were only checking for `auto`. Also, we were allowing the inline-size of a cell to constrain both its column and row. Using the block-size of the row makes more sense. The spec doesn't define constrainedness for rows, though. Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Apply suggestions from code review Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Assert that we don't get malformed ContentSizes in tables (#33549)Oriol Brufau2024-09-261-5/+4
| | | | | | | We have improved the logic for computing intrinsic sizes, and apparently we are no longer getting a `ContentSizes` whose `min_content` is greater than the `max_content`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Avoid unnecessary recomputation of `inline-size` being `auto` (#33548)Oriol Brufau2024-09-251-2/+1
| | | | | This information is already provided by `get_outer_sizes_from_style()`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Switch `.len()` comparison to `is_empty()` in ↵danik2922024-09-251-1/+1
| | | | | | | | | | | | | | | | | `components/layout_2020/query.rs`. (#33544) * Improve readability of code Signed-off-by: Daniel Frantes <danfrantes@seznam.cz> * Fix style issue Signed-off-by: Martin Robinson <mrobinson@igalia.com> --------- Signed-off-by: Daniel Frantes <danfrantes@seznam.cz> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* fonts: Simplify `FontContext` in two ways that affect the unit test (#33541)Martin Robinson2024-09-252-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | This is done by no longer forwarding compositor-bound messages through SystemFontService and making `FontContext` non-generic: - Messages from the `FontContext` to the `Compositor` no longer need to be forwarded through the `SystemFontService`. Instead send these messages directly through the script IPC channel to the `Compositor`. - Instead of adding a mock `SystemFontServiceProxy`, simply implement a mock `SystemFontService` on the other side of an IPC channel in the `font_context` unit test. This allows making `FontContext` non-generic, greatly simplifying the code. The extra complexity moves into the unit test. These changes necessitate adding a new kind of `FontIdentifier`, `FontIdentifier::Mock` due to the fact that local fonts have platform-specific identifiers. This avoids having to pretend like the system font service can have web fonts -- which was always a bit of a hack. These two changes are combined into one PR because they both require extensive and similar chages in the font_context unit test which dependended on the details of both of them. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Use `ContentSizes::shrink_to_fit` when possible (#33527)Oriol Brufau2024-09-252-8/+11
| | | | | And ensure that the minimum wins for malformed ContentSizes. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* fonts: Use `IpcSharedMemory` to send font data (#33530)Martin Robinson2024-09-252-6/+6
| | | | | | | | | | | | | | | | | | | | | This changes modifes the way that font data is sent over IPC channels. Instead of serializing the data or sending it via IPC byte senders, font data is copied into shared memory and a copy of the handle is sent over the channel. There is also the idea of sending the file handle of the on disk data of system fonts. This could be implemented as a further followup once there is an abstraction in `ipc-channel` over file handles. To accomplish this, a `FontData` abstraction is added, which also allows caching an in-memory shared `Arc<Vec<u8>>` version of the data (neeeded by some APIs). This could also be a place for caching font tables in the future. Finally, the `FontCacheThread` is renamed to the `SystemFontService` while the proxy for this is now named `SystemFontServiceProxy`. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Layout: Implement innerText/outerText (#33312)Ben2024-09-241-4/+430
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement outerText on HtmlElement Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fixed some innerText/outerText bugs Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> * Unified innerText/outerText handling outside of Layout Before these 2 were treated separately and only within Layout would they end up calling the same method, now they are already unified within HTMLElement Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> * Address a few nits Signed-off-by: Martin Robinson <mrobinson@igalia.com> * Added innerText support for `inline-flex` Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> --------- Signed-off-by: Shane Handley <shanehandley@fastmail.com> Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Shane Handley <shanehandley@fastmail.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Add `HTMLCanvasDataSource::Empty` that represent transparent black instead ↵Samson2024-09-222-15/+17
| | | | | | | | | | | | | | | of `HTMLCanvasDataSource::Image(None)` (#33519) * `HTMLCanvasDataSource::Empty` that represent transparent black instead of Image(None) Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Fix warning from 3a0d27b2312c6396e85178615290ac2ec3592ce1 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* fix many clippy warnings (#33510)Gae242024-09-211-1/+1
| | | Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* Enable min-content, max-content, fit-content and stretch (#33492)Oriol Brufau2024-09-203-9/+16
| | | | | | | | | For the sizing properties. We don't actually support them yet, just treating them as the initial value. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Ensure that `<caption>`'s support `position: relative` (#33426)Martin Robinson2024-09-191-3/+13
| | | | | | | | | This change adds support for `position: relative` to table `<caption>`. In addition to adjusting their position according to inset values, table captions must also establish containing blocks for descendants that are absolutely positioned. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Add support for `object-fit` and `object-position` (#33479)Martin Robinson2024-09-1810-70/+155
| | | | | | | | | | 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>
* Add `rust-version` to all `Cargo.toml` files (#33483)Martin Robinson2024-09-171-0/+1
| | | | | | | This is another step preparing for building Servo without `mach`. Fixes #33430. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Clear `self.pending_whitespace.max_content` in `forced_line_break()` (#33469)Oriol Brufau2024-09-161-8/+8
| | | | | | | | | | | | If we encountered a preserved line break after some whitespace, we were including the space in the max-content size of the following line. So just like `line_break_opportunity()` was already clearing `self.pending_whitespace.min_content`, `forced_line_break()` needs to clear `self.pending_whitespace.max_content` too. Also some cosmetic refactoring. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Replace .map_or(false with Option::is_some_and (#33468)Simon Wülker2024-09-166-19/+23
| | | Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Small improvements for table border collapse (#33452)Oriol Brufau2024-09-162-15/+128
| | | | | | | | We were only collapsing the borders from adjacent cells. This patch also handles the borders from rows, row groups, columns, and column groups. Additionally, it takes the border style into account in order to decide which border wins. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Do not remove extra columns at the end of the table (#33451)Oriol Brufau2024-09-162-23/+15
| | | | | | | | | | | <col> and <colgroup> elements can be used to create extra columns that have no cell. We were removing these columns and column groups, but in general we shouldn't do that. Now we will only remove them if the table has no row nor row group. matching WebKit and the expectations of some tests. But note that Gecko and Blink never remove them. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Let `LengthPercentage::maybe_to_used_value()` accept `Option<Au>` (#33450)Oriol Brufau2024-09-161-17/+11
| | | | | | Bump Stylo to servo/stylo#75 and remove conversions that are no longer necessary. Signed-off-by: Oriol Brufau <obrufau@igalia.com>