aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/style_ext.rs
Commit message (Collapse)AuthorAgeFilesLines
* Improve logic for establishing a stacking context (#35947)Oriol Brufau2025-03-131-52/+84
| | | | | | | | | | In particular: - `z-index` will now work on unpositioned grid items. - `will-change: z-index` will only establish a stacking context if `z-index` applies, i.e. if the box is positioned or a flex/grid item. - The conditions in `establishes_stacking_context()` are reordered, so that the most likely ones are checked first. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Fix interaction of margin and stretch size on block-level boxes (#35904)Oriol Brufau2025-03-111-2/+18
| | | | | | | | | | | | | The CSSWG resolved that `block-size: stretch` on a block-level box stretches the margin box to fill the parent. However, if the parent doesn't have padding nor border, and doesn't establish an independent formatting context, then we assume that the margins will collapse. Therefore, we treat the margins as zero when resolving the stretch size, regardless of whether they will actually end up collapsing. https://github.com/w3c/csswg-drafts/issues/11044#issuecomment-2599101601 https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: support CSS will-change (#35787)Euclid Ye2025-03-091-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * support CSS `will-change` * update wpt-test result * Enable css-will-change test * Update css-will-change test results * Check transformable before will-change; update wpt-results * Solve merge conflict * Update Cargo.toml and Cargo.lock * Mark new failing test-cases --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* layout: Make `transform-style: preserve-3d` establish a containing block for ↵Daniel Hast2025-03-071-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | all descendants (#35808) * layout: Fix behavior of `transform-style: preserve-3d` This makes `transform-style: preserve-3d` establish a containing block for all descendants, as specified here: <https://drafts.csswg.org/css-transforms-2/#transform-style-property> Signed-off-by: Daniel Hast <hast.daniel@protonmail.com> * layout: Check for transformable elements Adds a new `is_transformable` helper method and use this in several other methods, including the methods for whether the fragment establishes a new stacking context or a containing block for all descendants. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com> * Use generic green square reference for reftest. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com> * layout: Fix stacking context & containing block checks. Only the computed value of `transform-style` should be used to determine whether the element establishes a stacking context and/or a containing block, not the used value. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com> * Update clip-no-stacking-context test expectation to pass. Signed-off-by: Daniel Hast <hast.daniel@protonmail.com> --------- Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
* reuse effects var in establishes_stacking_context (#35836)Stephen Muss2025-03-071-2/+2
| | | Signed-off-by: Stephen Muss <stephenmuss@gmail.com>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-6/+6
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* layout: Merge `BoxFragment::used_overflow` into ↵Euclid Ye2025-03-021-10/+27
| | | | | | | | | | | | | | | | | | | | | | | `ComputedValuesExt::effective_overflow` (#35670) (#35670) * Update wpt-test * Merge used_overflow to effective_overflow; remove duplicate call * Remove more duplicate calls; update effective_overflow logic * Update reference link&style * Apply final review suggestions Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* layout: Change the `IndefiniteContainingBlock` sizes to `Option<Au>` (#35653)Oriol Brufau2025-02-251-7/+6
| | | | | Thus avoiding the need to convert to/from `AuOrAuto`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Support for the `isolation` CSS property (#35552)Kingsley Yung2025-02-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Support for the isolation CSS property Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> * Temporarily bump stylo to refs/pull/125/head for testing Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> * Remove FAIL expectation of CSS isolation tests Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> * Add behavior test Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Revert temporary changes in Cargo.toml Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> --------- Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev> Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* layout: Partial support for sizing keywords on flex items (#35469)Oriol Brufau2025-02-171-22/+0
| | | | | | | | | | | | | | | | | | * Add tests for sizing keywords on flex items Signed-off-by: Oriol Brufau <obrufau@igalia.com> * layout: Partial support for sizing keywords on flex items When a flex item has `flex-basis: auto`, the used `flex-basis` is the value of the main size property. In that case, if the main size property was set to keyword, we were always assuming it was `auto`. Now we handle non-`auto` keywords correctly. Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Implement overflow scroll support for different axes (#35414)Euclid Ye2025-02-141-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * layout: Add AxesScrollSensitivity to enable control of scroll in axis Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout_2013: Be compatible with AxesScrollSensitivity Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: update struct AxesScrollSensitivity to euclid::Vector2D Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * display_list: implement From<Overflow> for ScrollSensitivity Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: simplify and reuse scroll related logic Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout_2013: simplify and reuse scroll related logic Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout, layout_2013: revert AxesScrollSensitivity to pair struct Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: Reimport ComputedOverflow as #35103 depends on it Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: Add AxesOverflow to replace PhysicalVec Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: implement scroll of viewport for different axes Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: explicitly handle overflow match Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * Update components/shared/webrender/Cargo.toml Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Let `resolve_color()` take its parameter by reference (#35247)Oriol Brufau2025-01-311-1/+1
| | | | | | | | Bumps Stylo to https://github.com/servo/stylo/pull/116 This way the callers don't have to clone it if they don't have ownership or want to use the value later. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Correctly resolve `currentcolor` on collapsed borders (#35163)Oriol Brufau2025-01-271-10/+19
| | | | | | | If a collapsed border has the `currentcolor` color, we were resolving it using the color of the table. Now we resolve it using the color of the box which owns the border that wins and becomes the collapsed border. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Hide collapsed borders crossed by spanning cells (#35129)Oriol Brufau2025-01-231-0/+4
| | | | | | | For example, a cell with `rowspan="2"` can cross a collapsed border that was set on the rows. Now the slice of this row border that is crossed by the cell will be hidden. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Fix border widths of table wrapper with collapsed borders (#35097)Oriol Brufau2025-01-211-31/+19
| | | | | | | For a table wrapper in collapsed-borders mode we were just halving the border widths from the computed style. However, it needs to actually receive half of the resulting collapsed border, which can be bigger. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Remove some unneeded `is_table` parameters (#35064)Oriol Brufau2025-01-191-0/+5
| | | | | We can just check the `LayoutStyle` instead. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Allow layouts to customize their used style (#35012)Oriol Brufau2025-01-161-166/+177
| | | | | | | | | | | | | | | Some layouts like table need some style overrides. We were handling this in `ComputedValuesExt`, but it was messy, unreliable and too limited. For example, we were assuming that a style with `display: table` would belong to a table wrapper box or table grid box. However, certain HTML elements can ignore their `display` value and generate a different kind of box. I think we aren't doing that yet, but we will need this. Also, resolving the used border of a table needs layout information, which we don't have in `ComputedValuesExt`. This patch will allow to improve border collapsing in a follow-up. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Make non-`normal` `align-content` establish a block formatting ↵TIN TUN AUNG2025-01-151-0/+9
| | | | | | | | | | | | | | | | | context (#34984) * Make non-normal align-content establish a block formatting context Signed-off-by: rayguo17 <rayguo17@gmail.com> * Adjust code comment Signed-off-by: Martin Robinson <mrobinson@igalia.com> --------- Signed-off-by: rayguo17 <rayguo17@gmail.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Improve logic for block size of table (#34947)Oriol Brufau2025-01-131-66/+0
| | | | | | | | | | The containing block for children already has the size coming from the style and the rules of the parent formatting context, so no need to try to recompute it. This allows removing a bunch of functions, and fixes some problems when the table is a flex item. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Generalize `ContainingBlock`'s block size to a `SizeConstraint` (#34946)Oriol Brufau2025-01-131-1/+4
| | | | | | | | | | | | | It used to be an `AuOrAuto`, turning it into a `SizeConstraint` allows passing the information about the min and max constraints when the containing block doesn't have a definite block size. This will be useful for table layout. Note that in most cases we were already constructing the containing block from a `SizeConstraint`, but we were calling `to_auto_or()` to turn it into an `AuOrAuto`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Improve painting of collapsed borders in table layout (#34933)Oriol Brufau2025-01-111-12/+39
| | | | | | | | This is still not the right approach, because we are not painting collapsed borders as a single thing. Instead, we are splitting them into two halves and paint each half on a different cell. This only looks good for solid borders. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Improve sizing of tables in collapsed-borders mode (#34932)Oriol Brufau2025-01-101-0/+17
| | | Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Set padding to zero on tables in collapsed-borders mode (#34908)Oriol Brufau2025-01-091-10/+16
| | | | | | | | | https://drafts.csswg.org/css2/#collapsing-borders > in this model, a table does not have padding https://drafts.csswg.org/css-tables/#collapsed-style-overrides > The padding of the table-root is ignored (as if it was set to 0px). Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Implement keyword sizes for block layout heuristics (#34695)Oriol Brufau2024-12-231-31/+0
| | | | | | | | Block layout uses some heuristics to guess whether margins are separated by clearance and then don't collapse. These heuristics now take the min-content, max-content, fit-content and stretch sizing keywords into account. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Refactor box size computation (#34671)Oriol Brufau2024-12-191-10/+19
| | | | | | | | | in each layout logic, in order to correctly resolve sizing keywords. This patch adds a new `Sizes` struct which holds the preferred, min and max sizing values for one axis, and unifies the logic to resolve the final size into there. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* layout: Make a new `ContainingBlockSize` type (#34565)Martin Robinson2024-12-111-3/+3
| | | | | | | | This might make caching these values a bit easier in the future. Correcting the visibility of `ContainingBlock` also exposed some new rustc and clippy warnings that are fixed here. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Refactor computation of preferred aspect ratios (#34416)Oriol Brufau2024-11-291-25/+3
| | | | | | | | | | | | | | | | | | | * Refactor computation of preferred aspect ratios Computing min/max-content sizes required a ContainingBlock in order to resolve the padding and border when determining the preferred aspect ratio. However, all callers already knew the padding and border, so they can compute the ratio themselves, and pass it directly instead of the ContainingBlock. Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Put preferred aspect ratio into ConstraintSpace Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Layout: Implement CSS Grid using `taffy` (#32619)Nico Burns2024-11-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add layout.grid.enabled pref Signed-off-by: Nico Burns <nico@nicoburns.com> * Add taffy dependency Signed-off-by: Nico Burns <nico@nicoburns.com> * Import taffy <-> stylo conversion code from taffy_stylo crate Signed-off-by: Nico Burns <nico@nicoburns.com> * Add `Grid` variant to DisplayInside Signed-off-by: Nico Burns <nico@nicoburns.com> * Implement CSS Grid using Taffy Signed-off-by: Nico Burns <nico@nicoburns.com> Import full stylo_taffy crate Signed-off-by: Nico Burns <nico@nicoburns.com> Squashed PR feedback changes Deduplicate is_document_only_whitespace Signed-off-by: Nico Burns <nico@nicoburns.com> Import taffy::AvailableSpace Signed-off-by: Nico Burns <nico@nicoburns.com> Rename FlexContext to TaffyContainerContext Signed-off-by: Nico Burns <nico@nicoburns.com> Eliminate references to flexbox in taffy/layout module Signed-off-by: Nico Burns <nico@nicoburns.com> Use constructors for geom types Signed-off-by: Nico Burns <nico@nicoburns.com> Remove comment about abspos elements splitting contiguous text runs Signed-off-by: Nico Burns <nico@nicoburns.com> Remove reference to flexbox in taffy/construct Signed-off-by: Nico Burns <nico@nicoburns.com> Deduplicate construction of flexbox/grid containers Signed-off-by: Nico Burns <nico@nicoburns.com> Make anonymous text runs InFlow Signed-off-by: Nico Burns <nico@nicoburns.com> Remove commented code Signed-off-by: Nico Burns <nico@nicoburns.com> Update comments Signed-off-by: Nico Burns <nico@nicoburns.com> Inline/vendor the stylo/taffy interop code Signed-off-by: Nico Burns <nico@nicoburns.com> * Update test expectations Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix nits from PR review Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
* Replace ComputedValues with WritingMode on IndefiniteContainingBlock (#34090)Oriol Brufau2024-11-041-30/+16
| | | | | We only need the writing mode, not the entire computed style. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Improve how intrinsic sizes work for videos (#31746)eri2024-10-291-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-70/+67
| | | | | | | | | | | | | | | | | | | | 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>
* Consistent resolution of cyclic percentages in min sizing properties (#33988)Oriol Brufau2024-10-241-34/+23
| | | | | | | | | | | | | | | The spec says that cyclic percentages in min sizing properties should be resolved against zero when computing intrinsic contributions. We were already doing that in the inline axis, but we were treating the entire expression as `auto` in the block axis. With this patch we will follow the spec in both axes. But note that browsers don't follo the spec in either axis, so we may have to revisit (see https://github.com/w3c/csswg-drafts/issues/10969). calc-min-height-block-1.html now fails because it tests what browsers do instead of what the spec says. 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>
* Upgrade Stylo to 2024-10-04 (#33767)Oriol Brufau2024-10-201-18/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* 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>
* Remove SizeKeyword, merge it into Size (#33844)Oriol Brufau2024-10-151-2/+2
| | | | | 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-141-13/+43
| | | | | | | | | | | 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>
* 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>
* Make ComputedValuesExt expose keywords for the sizing properties (#33558)Oriol Brufau2024-09-271-53/+104
| | | | | | | | | | | | | | | | 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>
* Enable min-content, max-content, fit-content and stretch (#33492)Oriol Brufau2024-09-201-2/+8
| | | | | | | | | 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>
* Small improvements for table border collapse (#33452)Oriol Brufau2024-09-161-1/+21
| | | | | | | | 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>
* Simplify table logic in effective_overflow() (#33431)Oriol Brufau2024-09-131-33/+22
| | | | | | | | | | | | | On tables, we need to treat an overflow value of `scroll` or `auto` as `visible`. Both `scroll` or `auto` are scrollable, which implies that the other axis must also have a scrollable value. Therefore, when we make the value behave as the non-scrollable `visible`, we need to adjust the other axis too. The previous logic was checking `is_scrollable()` but that wasn't necessary, since computed values must have the same scrollability. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Cleanup after #33396 (#33429)Oriol Brufau2024-09-121-4/+4
| | | | | | Mostly formatting improvements, but also recovering a pair of parenthesis that was accidentally removed, changing the logic. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Let table-related boxes adjust their `overflow` values (#33400)Oriol Brufau2024-09-111-3/+55
| | | | | | | | | | 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-111-33/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-57/+53
| | | | | | | | | | | | | | | | | | | | * 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-1/+21
| | | | | | | | | | | 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: Add an indefinite containing block for intrinsic sizing (#33204)Oriol Brufau2024-08-291-5/+93
| | | | | | | | | | | | | | | | | | When computing the min-content or max-content size of an element we need to ignore `inline-size`, `min-inline-size` and `max-inline-size`. However, we should take the block-axis sizing properties into account. That's because the contents could have percentages depending on them, which can then affect their inline size via an aspect ratio. Therefore, this patch adds `IndefiniteContainingBlock`, which is similar to `ContainingBlock`, but it allows an indefinite inline-size. This struct is then passed arround during intrinsic sizing. More refinement will be needed in follow-up patches in order to fully address the problem. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Add initial support for `clip-path: [<basic-shape> || <shape-box>]` ↵Chocolate Pie2024-08-281-0/+5
| | | | | | | | | | | | | | | | | | | | | (#33107) * Turn on clip-path tests and add results Signed-off-by: Martin Robinson <mrobinson@igalia.com> * enhance: Add support for `clip-path: [<basic-shape> || <shape-box>]` Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> * Changes from review Signed-off-by: Martin Robinson <mrobinson@igalia.com> --------- Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Add initial support for bidirectional text (BiDi) (#33148)Martin Robinson2024-08-211-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds supports for right-to-left text assigning bidi levels to all line items when necessary. This includes support for the `dir` attribute as well as corresponding CSS properties like `unicode-bidi`. It only implements right-to-left rendering for inline layout at the moment and doesn't include support for `dir=auto`. Because of missing features, this causes quite a few tests to start failing, as references become incorrect due to right-to-left rendering being active in some cases, but not others (before it didn't exist at all). Analysis of most of the new failures: ``` - /css/css-flexbox/gap-001-rtl.html /css/css-flexbox/gap-004-rtl.html - Require implementing BiDi in Flexbox, because the start and end inline margins are opposite the order of items. - /css/CSS2/bidi-text/direction-applies-to-*.xht /css/CSS2/bidi-text/direction-applies-to-002.xht /css/CSS2/bidi-text/direction-applies-to-003.xht /css/CSS2/bidi-text/direction-applies-to-004.xht - Broken due to a bug in tables, not allocating the right amount of width for a column. - /css/css-lists/inline-list.html - This fails because we wrongly insert a soft wrap opportunity between the start of an inline box and its first content. - /css/css-text/bidi/bidi-lines-001.html /css/css-text/bidi/bidi-lines-002.html /css/CSS2/text/bidi-flag-emoji.html - We do not fully support unicode-bidi: plaintext - /css/css-text/text-align/text-align-end-010.html /css/css-text/text-align/text-align-justify-006.html /css/css-text/text-align/text-align-start-010.html /html/dom/elements/global-attributes/* - We do not support dir=auto yet. - /css/css-text/white-space/tab-bidi-001.html - Servo doesn't support tab stops - /css/CSS2/positioning/abspos-block-level-001.html /css/css-text/word-break/word-break-normal-ar-000.html - Do not yet support RTL layout in block - /css/css-text/white-space/pre-wrap-018.html - Even in RTL contexts, spaces at the end of the line must hang and not be reordered - /css/css-text/white-space/trailing-space-and-text-alignment-rtl-002.html - We are letting spaces hang with white-space: pre, but they shouldn't hang. ``` Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>