aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* Elide lifetimes where possible after rustup (#34824)Martin Robinson2025-01-031-1/+0
| | | | | | | | | The new version of rust allows us to elide some lifetimes and clippy is now complaining about this. This change elides them where possible and removes the clippy exceptions. Fixes #34804. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Upgrade rustc to 1.83 (#34793)Nico Burns2025-01-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Upgrade rustc to 1.83 Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix crown (change copied from linked clippy function) Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix named lifetime lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Bump shell.nix Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix non-local impl warnings Signed-off-by: Nico Burns <nico@nicoburns.com> * Format with 1.83 formatting changes Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix manual non-local impl Signed-off-by: Nico Burns <nico@nicoburns.com> * More fixes for crown Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix tidy Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix needless_return lints Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix doc comment lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix missing wait lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow needless_lifetimes lint Signed-off-by: Nico Burns <nico@nicoburns.com> * more doc comments Signed-off-by: Nico Burns <nico@nicoburns.com> * More needless_returns Signed-off-by: Nico Burns <nico@nicoburns.com> * is_empty lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix needless_lifetime lints Signed-off-by: Nico Burns <nico@nicoburns.com> * fix div_ceil lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow non-minimal bool Signed-off-by: Nico Burns <nico@nicoburns.com> * Non-local impl in constellation Signed-off-by: Nico Burns <nico@nicoburns.com> * Missing wait in constellation Signed-off-by: Nico Burns <nico@nicoburns.com> * fmt Signed-off-by: Nico Burns <nico@nicoburns.com> * remove useless lints table Signed-off-by: Nico Burns <nico@nicoburns.com> * Fixup comments Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow non-local definition in sandboxing code to simplify feature flagging Signed-off-by: Nico Burns <nico@nicoburns.com> * Remove wait calls and allow zombie_processes lint Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
* layout: Make a new `ContainingBlockSize` type (#34565)Martin Robinson2024-12-111-7/+15
| | | | | | | | 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>
* layout: Add `LayoutBoxBase` and use it for `IndependentFormattingContext` ↵Martin Robinson2024-12-071-0/+1
| | | | | | | | | | | | | | | | | | (#34507) Add a new struct `LayoutBoxBase`, that will be used throughout the box tree. The idea of this struct is that we have a place to consistently store common layout information (style and node information) and also to cache layout results such as content sizes (inline and maybe later box sizes) and eventually layout results. In addition to the addition of this struct, `IndependentFormattingContext` is flattened slightly so that it directly holds the contents of both replaced and non-replaced elements. This is only added to independent formatting contexts, but will later be added to all block containers as well. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Refactor computation of preferred aspect ratios (#34416)Oriol Brufau2024-11-291-3/+17
| | | | | | | | | | | | | | | | | | | * 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-0/+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>
* Fix inline content sizes of intrinsic element with indefinite block size ↵Oriol Brufau2024-11-111-18/+28
| | | | | | | | | | | | | | | | | (#34152) To compute the min-content and max-content inline sizes of a replaced element, we were only using the aspect ratio to transfer definite block sizes resulting from clamping the preferred block size between the min and max block sizes. However, if the preferred block size is indefinite, then we weren't transfering the min and max through the aspect ratio. This patch adds a `SizeConstraint` enum that can represent these cases, and a `ConstraintSpace` struct analogous to `IndefiniteContainingBlock` but with no inline size, and a `SizeConstraint` block size. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Replace ComputedValues with WritingMode on IndefiniteContainingBlock (#34090)Oriol Brufau2024-11-041-28/+15
| | | | | We only need the writing mode, not the entire computed style. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Refactor positioned layout (#33922)Oriol Brufau2024-10-211-17/+0
| | | | | | | | | | | | | | | 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>
* Avoid recomputing inline_content_sizes() when not needed (#33806)Oriol Brufau2024-10-141-1/+1
| | | | | | | | | | | 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>
* Make ComputedValuesExt expose keywords for the sizing properties (#33558)Oriol Brufau2024-09-271-1/+1
| | | | | | | | | | | | | | | | 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>
* layout: Right-to-left support for other layout modes (#33375)Martin Robinson2024-09-111-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | * 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: Add an indefinite containing block for intrinsic sizing (#33204)Oriol Brufau2024-08-291-1/+84
| | | | | | | | | | | | | | | | | | 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: Prepare for bidi by guarding all access to `writing-mode` (#33082)Martin Robinson2024-08-161-0/+14
| | | | | | | | | 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>
* make ContainingBlock use Au for inline_size and block_size (#31370)atbrakhi2024-02-201-5/+5
|
* make size of DefiniteContainingBlock use app units (#31369)atbrakhi2024-02-171-3/+4
|
* Compile Servo with the latest version of rust stable (#30831)Martin Robinson2023-12-061-1/+0
| | | | | | | | | | | | | | | | This completes the transition to compiling Servo with rust stable. Some nightly-only features are still used when compiling the `script` and `crown` crates, as well as for some style unit tests. These will likely break with newer compiler versions, but `crown` can be disabled for them conditionally. This is just the first step. This has some caveats: 1. We need to disable setting up the special linker on Linux. The -Z option isn't supported with stable rust so using this is out -- meanwhile we can't be sure that lld is installed on most systems. 2. `cargo fmt` still uses some unstable options, so we need to rely on the unstable toolchain just for running `fmt`. The idea is to fix this gradually.
* Add initial support for table box tree construction (#30799)Martin Robinson2023-12-051-0/+1
| | | | | | | | | | | | This is the first part of constructing the box tree for table layout. No layout is actually done and the construction of tables is now hidden behind a flag (in order to not regress WPT). Notably, this does not handle anonymous table part construction, when the DOM does not reflect a fully-formed table. That's part two. Progress toward #27459. Co-authored-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Manish Goregaokar <manishsmail@gmail.com>
* Layout 2020: Rename `flow_relative` types to `Logical...` (#30324)Martin Robinson2023-09-121-2/+2
| | | | | | 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-111-2/+2
| | | | | * strict imports formatting * Reformat all imports
* remove `extern crate` (#30311)Samson2023-09-081-5/+0
| | | | | | | | | | | * 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>
* Use std::cell::OnceCell and remove mitochondria dependency (#30207)Martin Robinson2023-08-251-0/+1
| | | | | `OnceCell` is now part of the standard library and we'll be able to use it once we upgrade rust. For now we can use the version that's shipped behind a feature flag in rust. This removes a dependency on one crate.
* Layout 2020: Move all Fragment code to the `fragment_tree` directoryMartin Robinson2023-06-041-2/+2
| | | | | | | | 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.
* Combine DOM-related concepts in Layout 2020 into dom.rsMartin Robinson2023-05-131-4/+1
|
* Detect body elements during layoutMartin Robinson2023-05-041-0/+1
| | | | | | | | | | | | | | | | | 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.
* Add layout support for list markersSimon Sapin2020-07-241-0/+1
|
* Add an implementation of the core float and clear placement logic in layoutPatrick Walton2020-07-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 2020, not yet wired to the rest of layout. This commit implements an object that handles the 10 rules in CSS 2.1: https://www.w3.org/TR/CSS2/visuren.html#float-position The implementation strategy is that of a persistent balanced binary search tree of float bands. Binary search trees are commonly used for implementing float positioning; e.g. by WebKit. Persistence enables each object that interacts with floats to efficiently contain a snapshot of the float list at the time that object was laid out. That way, incremental layout can invalidate and start reflow at any point in a containing block. This commit features extensive use of [QuickCheck](https://github.com/BurntSushi/quickcheck) to ensure that the rules of the CSS specification are followed. Because this is not yet connected to layout, floats will not actually be laid out in Web pages yet. Note that unit tests as set up in Servo currently require types that they access to be public. Therefore, some internal layout 2020 types that were previously private have been made public. This is somewhat unfortunate. Part of #25167.
* Layout 2020 skeleton for `display: flex`, behind a prefSimon Sapin2020-06-041-0/+1
|
* Rename BoxTreeRoot/FragmentTreeRoot to BoxTree/FragmentTreeSimon Sapin2020-05-151-1/+1
|
* layout_2020: Add initial support for getComputedStyleMartin Robinson2020-05-111-0/+2
| | | | | | | This implementation is more-or-less on par with the one from layout_2013 and in some cases better. There are still some cases where we don't return the correct "resolved value," but this is enough to test animations and transitions.
* Remove use of some other unstable featuresSimon Sapin2020-04-151-2/+0
|
* Replace OpaqueStyleAndLayoutData by StyleAndOpaqueLayoutDataAnthony Ramine2020-04-061-1/+1
|
* layout_2020: Stop throwing away hoisted boxes in nested absolutesMartin Robinson2020-03-271-2/+0
| | | | | | | We were previously throwing away some boxes hoisted to containing blocks for all descendants when they were contained by absolutes. This prevents panics in existing web platform tests that would otherwise be triggered by the addition of the `unreachable!` statement.
* Add an `ArcRefCell<T>` typePatrick Walton2020-03-171-0/+1
|
* Make AbsolutelyPositionedBox be 'staticAnthony Ramine2020-03-171-0/+1
|
* layout_2020: Paint hoisted positioned fragments in tree orderMartin Robinson2020-03-111-0/+2
| | | | | | | | | | | | | | | | | | | Instead of painting hoisted position fragments in the order to which they are hoisted, paint them in tree order and properly incorporate them into the stacking context. We do this by creating a placeholder fragment in the original tree position of hoisted fragments. The ghost fragment contains an atomic id which links back to the hoisted fragment in the containing block. While building the stacking context, we keep track of containing blocks and their children. When encountering a placeholder fragment we look at the containing block's hoisted children in order to properly paint the hoisted fragment. One notable design modification in this change is that hoisted fragments no longer need an AnonymousFragment as their parent. Instead they are now direct children of the fragment that establishes their containing block.
* Add layout debugger support to layout_2020Fernando Jiménez Moreno2020-02-211-0/+5
|
* Upgrade to rustc 1.42.0-nightly (3291ae339 2020-01-15)Simon Sapin2020-01-161-1/+0
|
* Make `for_maybe_position_relative` take care of relative adjustment.Simon Sapin2019-12-131-30/+0
|
* impl From<&'_ DefiniteContainingBlock> for ContainingBlockSimon Sapin2019-12-101-0/+10
|
* Containing blocks contains styles rather than just a writing modeSimon Sapin2019-12-071-5/+4
|
* Use the WritingMode bitflags from StyloSimon Sapin2019-12-071-3/+5
|
* Add inline_size_is_autoSimon Sapin2019-12-031-0/+1
|
* Rename IntrinsicSizes to ContentSizesSimon Sapin2019-12-031-1/+1
|
* Add intrinsic size computation for inline formatting contextsSimon Sapin2019-12-021-0/+1
|
* Un-allow and fix warnings in `components/layout_2020`Simon Sapin2019-12-021-15/+1
|
* Split FlowChildren in IndependentLayout and FlowLayoutAnthony Ramine2019-11-261-1/+1
| | | | | The result of doing the layout of an independent formatting context should be unconcerned with margin collapsing.
* Use std::mem::take instead of defining itSimon Sapin2019-11-261-9/+0
|
* Make IndependentFormattingContext a struct that owns stylesSimon Sapin2019-11-261-85/+4
| | | | | | | | … and has a private enum for its contents. Privacy forces the rest of the code to go through methods rather than matching on the enum, reducing accidental layout-mode-specific behavior.