aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/positioned.rs
Commit message (Collapse)AuthorAgeFilesLines
* Layout 2020: Rename `flow_relative` types to `Logical...` (#30324)Martin Robinson2023-09-121-16/+15
| | | | | | 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-8/+9
| | | | | * strict imports formatting * Reformat all imports
* remove `extern crate` (#30311)Samson2023-09-081-0/+1
| | | | | | | | | | | * 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>
* Split line layout into two phases (#30089)Martin Robinson2023-08-111-6/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Handle BFC roots with auto width next to floats (#30057)Oriol Brufau2023-08-081-0/+11
| | | Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Make fewer PositioningContexts when descending (#30061)Martin Robinson2023-08-031-6/+52
| | | | | | When descending and we have the option, don't create new PositioningContexts just to update the static position of laid out abspos descendants. Instead, use the new PositioningContextLength to only update the newly added hoisted abspos boxes.
* Remove rayon_croissant and clean up `contains_floats` (#29960)Martin Robinson2023-07-191-13/+19
| | | | | | | | | | | Remove rayon_croissant and refactor the way that information about floats in flows bubbles up. This simplifies the code a good deal and lets us take advantage of some more optimized functions provided by rayon. This removes 2 crates from the dependency tree. In addition, this allows avoiding passing `contains_floats` up from every box tree construction function. This makes things simpler, but also opens up the possibility of passing more of these flags up in the future (such as `contains_counters`).
* Make the choice of layout runtime settingMartin Robinson2023-07-061-1/+1
| | | | Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
* Layout 2020: implement clearance as Option<Length>Oriol Brufau2023-06-291-1/+1
| | | | | | | | | | 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.
* Fix positioning of statically positioned fixed child of absolutesMartin Robinson2023-06-231-0/+11
|
* Fix positioning of statically positioned absolute child of inline boxMartin Robinson2023-06-231-5/+12
|
* Properly position absolutes with static insets that are children of floatsMartin Robinson2023-06-221-2/+2
| | | | | | | | | | | | | | | | Previously, final float positions were calculated when their parents were positioned. This prevented proper positioning of absolute children of floats with static insets, because they accumulate offsets as they are hoisted up the tree. This change moves the final float positioning to `PlacementState::place_fragment` for the float itself so that it happens before any insets are updated for hoisted descendants. In addition to simplifying the code, this makes it a bit more efficient. Finally, floats are taken into account when updating static insets of hoisted boxes. Fixes #29826.
* Simplify layout of absolutes with static insetsMartin Robinson2023-06-201-68/+46
| | | | | | | | | | | | | | | | | | | Absolutes with static insets need to be laid out at their ancestor containing blocks, but their position is dependent on their parent's layout. The static layout position is passed up the tree during hoisting and ancestors each add their own offset to the position until it is relative to the containing block that contains the absolute. This is currently done with a closure and a fairly tricky "tree rank" numbering system that needs to be threaded through the entire layout. This change replaces that system. Every time a child is laid out we create a positioning context to hold any absolute children (this can be optimized away at a later time). At each of these moments, we call a method to aggregate offsets to the static insets of hoisted absolutes. This makes the logic easier to follow and will also allow implementing this behavior for inline-blocks, which was impossible with the old system.
* Layout 2020: Move all Fragment code to the `fragment_tree` directoryMartin Robinson2023-06-041-63/+4
| | | | | | | | 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.
* Auto merge of #29757 - Loirooriol:sequential-context-2020, r=Loirooriolbors-servo2023-06-031-1/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lay out floats and handle clearance in layout 2020, but don't flow text around them yet This is a crude rebase of #27539 <!-- 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 - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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. -->
| * Do not hoist floated fragmentsMartin Robinson2023-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of hoisting floated fragments to be siblings of the fragment created by their containing block formatting context, keep them in "normal" fragment tree position and adjust their positioning to be relative to the containing block. This means that float fragments follow the existing invariants of the fragment tree and properly handle hit testing, painting order, and relative positioning. The tradeoff here is more complexity tracking the containing block offsets from the block formatting context (including handling collapsed margins), but less complexity dealing with hoisting / shared ownership in addition to the correctness benefits. Some tests are failing now because this change revealed some additional shortcomings with clearing block formatting context content size past the end of their contained floats. This will be fixed in a followup change. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
| * Place floats in layout 2020, but don't flow text around the floats yet.Patrick Walton2023-06-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit puts floats behind the `layout.floats.enabled` pref, because of the following issues and unimplemented features: * Inline formatting contexts don't take floats into account, so text doesn't flow around the floats yet. * Non-floated block formatting contexts don't take floats into account, so BFCs can overlap floats. * Block formatting contexts that contain floats don't expand vertically to contain all the floats. That is, floats can stick out the bottom of BFCs, contra spec.
* | Auto merge of #29835 - mukilan:fix-double-borrow-in-hoisted, r=mrobinsonbors-servo2023-06-031-0/+15
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clear PositioningContext for speculative layouts <!-- Please describe your changes on the following line: --> Developed in collaboration with @mrobinson `try_layout` is used for laying out absolutely positioned descendants multiple times when min/max-{width, height} properties are set. When the same PositioningContext instance is used between successive attempts without clearing the accumulated descendants, we will generate multiple fragments which reference the same box, which then will lead to a double borrow error when layout is performed in parallel. --- <!-- 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 - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because crash testing is currently not working in servo. New tests will be added once #29832 is fixed. <!-- 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. -->
| * Clear PositioningContext for speculative layoutsMukilan Thiyagarajan2023-06-021-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | `try_layout` is used for laying out absolutely positioned descendants multiple times when min/max-{width, height} properties are set. When the same PositioningContext instance is used between successive attempts without clearing the accumulated descendants, we will generate multiple fragments which reference the same box, which then will lead to a double borrow error when layout is performed in parallel. Signed-off-by: Mukilan Thiyagarajan <me@mukilan.in>
* | layout_2020: Add an optional box size parameter to ↵Pu Xingyu2023-05-271-0/+1
|/ | | | | | | ReplacedContent::used_size_as_if_inline_element This allow us to specify the used size when calculating size of replaced content.
* Combine DOM-related concepts in Layout 2020 into dom.rsMartin Robinson2023-05-131-1/+2
|
* Better implement getComputedStyle() for positioned insetsMartin Robinson2023-05-091-113/+142
| | | | | | | | 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-041-1/+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.
* Rename `ComputedValuesExt::establishes_containing_block`Martin Robinson2023-04-201-1/+1
| | | | | | | | This renames the helper method to be a bit more accurate. For elements with static, relative, and sticky positioning, their containing block is always formed by their nearest block container ancestor. This method is really dealing with style that means an element will establish a containing block for absolutely positioned descendants.
* Fix calculation of block axis for abspos elementsMartin Robinson2023-04-141-2/+1
| | | | | | The calculation of the block axis positioning of absolutely positioned elements was using the inline size of the containing block instead of the block size.
* Handle min/max sizes in non-replaced positioned boxesDelan Azabani2023-04-121-61/+142
|
* Move AbsoluteBoxOffsets into HoistedSharedFragmentManish Goregaokar2020-07-271-13/+18
|
* Create HoistedSharedFragmentManish Goregaokar2020-07-271-6/+20
|
* Allow adjusting box offsetsManish Goregaokar2020-07-271-0/+19
|
* Compute content sizes lazily in layout 2020Anthony Ramine2020-06-181-12/+3
|
* Make IndependentFormattingContext an enumAnthony Ramine2020-06-151-39/+44
|
* Remove PositioningContext::create_and_layout_positionedAnthony Ramine2020-06-151-111/+86
| | | | It has only one call site.
* Move IndependentFormattingContext::as_replaced to ↵Anthony Ramine2020-06-151-2/+2
| | | | IndependentFormattingContextContents
* Rename contents to context in AbsolutelyPositionedBoxAnthony Ramine2020-06-151-10/+10
|
* Use the writing mode of the containing block when accessing CSS propertiesSimon Sapin2020-06-101-5/+8
| | | | | | | | … and converting them to flow-relative geometric values. These values are almost always used to size and position a fragment within its containing block, so using the mode of the containing block seems more correct. Note that the `writing-mode` and `direction` properties are disabled in Servo at the moment, so this PR by itself should have no effect: the writing mode of an element is always the same of that of its containing block since they’re both horizontal rtl.
* Store abspos boxes in a RefCell tooAnthony Ramine2020-06-091-26/+31
| | | | | | We want to mutate them when lazily computing their content sizes, but they are behind an Arc for the hoisting infra, so it also needs its own layer of inner mutability.
* layout_2020: Tag fragments with their pseudo content typeMartin Robinson2020-06-061-7/+5
| | | | | This will allow us to answer queries and properly handle animations in the future for fragments generated for pseudo content.
* Remove use of some other unstable featuresSimon Sapin2020-04-151-3/+3
|
* Less cloningSimon Sapin2020-04-011-13/+19
|
* Implement the `box-sizing` propertySimon Sapin2020-03-311-9/+6
|
* Introduce a `PaddingBorderMargin` helperSimon Sapin2020-03-311-21/+18
|
* layout_2020: Stop throwing away hoisted boxes in nested absolutesMartin Robinson2020-03-271-2/+2
| | | | | | | 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.
* layout_2020: Use ArcRefCell to track hoisted fragmentsMartin Robinson2020-03-271-30/+16
| | | | | | | | | | | This avoids the use of lookup tables for containing blocks when constructing the stacking context tree. This seems to catch some laid-out hoisted fragments that were otherwise dropped in the previous design. The changes cause one new test to pass and one to fail. Visual examination of the failing tests reveals that it's a progression (list markers are appearing when they were previously not rendered).
* Auto merge of #26037 - mrobinson:arcrefcell-fragment-tree, r=SimonSapinbors-servo2020-03-261-1/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | layout_2020: Use ArcRefCell in the fragment tree This will allow mutability which is useful for things like animations. <!-- 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 - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [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. -->
| * layout_2020: Use ArcRefCell in the fragment treeMartin Robinson2020-03-251-1/+6
| | | | | | | | This will allow mutability which is useful for things like animations.
* | Propagate text decoration where neededFernando Jiménez Moreno2020-03-231-0/+3
|/
* layout_2020: Add support for hoisting positioned fragments in inline boxesMartin Robinson2020-03-191-2/+2
| | | | | | | | | Add support for tracking containing blocks when doing inline layout. This requires setting up a PositioningContext for inline boxes when necessary. Instead of using the PositioningContext helper methods and we reuse the contexts between line breaks. Fixes #25279.
* layout_2020: Refactor PositioningContext to be simpler and smallerMartin Robinson2020-03-181-104/+65
| | | | | | Add a few helper methods which allow removing duplicate code in PositioningContext. These methods will also be used to properly implement hoisting in inline layout.
* Make AbsolutelyPositionedBox be 'staticAnthony Ramine2020-03-171-19/+12
|
* layout_2020: Paint hoisted positioned fragments in tree orderMartin Robinson2020-03-111-19/+28
| | | | | | | | | | | | | | | | | | | 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.