Commit graph

65 commits

Author SHA1 Message Date
Manish Goregaokar
bc704d8a3d Move AbsoluteBoxOffsets into HoistedSharedFragment 2020-07-27 09:48:37 -07:00
Manish Goregaokar
d476a10773 Create HoistedSharedFragment 2020-07-27 09:48:37 -07:00
Manish Goregaokar
96c0c50874 Allow adjusting box offsets 2020-07-27 09:48:37 -07:00
Anthony Ramine
235df94f2e Compute content sizes lazily in layout 2020 2020-06-18 14:11:02 +02:00
Anthony Ramine
db80b8e3c1 Make IndependentFormattingContext an enum 2020-06-15 18:09:15 +02:00
Anthony Ramine
d0a1066d2d Remove PositioningContext::create_and_layout_positioned
It has only one call site.
2020-06-15 18:09:15 +02:00
Anthony Ramine
b53959d23d Move IndependentFormattingContext::as_replaced to IndependentFormattingContextContents 2020-06-15 18:09:15 +02:00
Anthony Ramine
b66dd66403 Rename contents to context in AbsolutelyPositionedBox 2020-06-15 18:09:15 +02:00
Simon Sapin
08f008a011 Use the writing mode of the containing block when accessing CSS properties
… 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.
2020-06-10 09:03:18 +02:00
Anthony Ramine
e975d24c4b Store abspos boxes in a RefCell too
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.
2020-06-09 15:13:18 +02:00
Martin Robinson
89855afa4d layout_2020: Tag fragments with their pseudo content type
This will allow us to answer queries and properly handle animations in
the future for fragments generated for pseudo content.
2020-06-06 17:25:08 +02:00
Simon Sapin
7f975c3d5d Remove use of some other unstable features 2020-04-15 15:17:52 +02:00
Simon Sapin
08801d94cd Less cloning 2020-04-01 01:00:14 +02:00
Simon Sapin
c377d9c48e Implement the box-sizing property 2020-03-31 23:43:58 +02:00
Simon Sapin
0e35d70ca8 Introduce a PaddingBorderMargin helper 2020-03-31 23:04:10 +02:00
Martin Robinson
ac2f402ae0 layout_2020: Stop throwing away hoisted boxes in nested absolutes
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.
2020-03-27 17:46:06 +01:00
Martin Robinson
19f4b708b3 layout_2020: Use ArcRefCell to track hoisted fragments
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).
2020-03-27 13:02:22 +01:00
bors-servo
4dbe3b30cd
Auto merge of #26037 - mrobinson:arcrefcell-fragment-tree, r=SimonSapin
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. -->
2020-03-26 10:23:23 -04:00
Martin Robinson
7cb0069be5 layout_2020: Use ArcRefCell in the fragment tree
This will allow mutability which is useful for things like animations.
2020-03-25 17:57:17 +01:00
Fernando Jiménez Moreno
17948f3b39 Propagate text decoration where needed 2020-03-23 11:13:10 +01:00
Martin Robinson
bd06227a60 layout_2020: Add support for hoisting positioned fragments in inline boxes
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.
2020-03-19 10:50:49 +01:00
Martin Robinson
712f9340e8 layout_2020: Refactor PositioningContext to be simpler and smaller
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.
2020-03-18 11:31:11 +01:00
Anthony Ramine
c3932185ec Make AbsolutelyPositionedBox be 'static 2020-03-17 11:15:17 -07:00
Martin Robinson
c3b1c92ac1 layout_2020: Paint hoisted positioned fragments in tree order
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.
2020-03-11 12:47:06 +01:00
Martin Robinson
8de55695e4 Have transforms and filters be CBs for all descendants in layout_2020
This is a feature that was never properly implemented in the previous
layout system. We still need to preserve their in-tree order in the
display list though.
2020-03-02 11:47:00 +01:00
Martin Robinson
c20c468814 Rename AbsolutelyPositionedBox::layout to AbsolutelyPositionedBox::to_hoisted
This method doesn't actually do any layout, but converts this block to a
HoistedAbsolutelyPositionedBox which is hoisted and then laid-out with
its containing block later. This makes the code a little easier to read.
2020-02-28 14:42:29 +01:00
Fernando Jiménez Moreno
c4276aa27e Fix rebase issues and run Prettier on layout viewer code 2020-02-21 11:11:00 +01:00
Fernando Jiménez Moreno
a042f85083 Dump box tree state into json files and display it on layout 2020 viewer 2020-02-21 11:11:00 +01:00
Fernando Jiménez Moreno
67706f9c0b Add fragment debug id 2020-02-21 11:11:00 +01:00
Martin Robinson
8825d588c1 Add initial support for scrollable overflow in layout_2020
This still isn't totally correct and non-root scrolling is not handled
at all, but the root frame now scrolls.
2020-01-21 15:29:23 +01:00
Emilio Cobos Álvarez
e885ccb7ae layout-2020: build fixes. 2019-12-16 14:23:56 +01:00
Anthony Ramine
abc2c15c28 Store an OpaqueNode in boxes and fragments 2019-12-13 17:59:27 +01:00
Anthony Ramine
47944a39fc Remove the Node type parameter from Contents
We now pass the Node as an argument during DOM traversal in layout.
2019-12-13 17:51:06 +01:00
Simon Sapin
58b7005a9b Make for_maybe_position_relative take care of relative adjustment. 2019-12-13 13:13:50 +01:00
Simon Sapin
b218957461 Rename CollectedAbsolutelyPositionedBox to HoistedAbsolutelyPositionedBox 2019-12-13 12:44:05 +01:00
Simon Sapin
53a8a609d2 Fix a width v.s. height confusion bug in abspos layout 2019-12-13 00:09:43 +01:00
Simon Sapin
5ebddf19e6 Layout position: fixed in the initial containing block 2019-12-12 22:50:11 +01:00
Simon Sapin
c44ee516a1 Give PositioningContext more responsibilities
Iits details are now private to the module.

It has a couple methods that take closures to make sure that "before" and "after" steps are done together:

* In an absolutely positioned box, take care of nested abspos (establish a new containing block, etc.)
* For a box that *might* be `position: relative`, optionally take care of the same.
2019-12-12 22:50:11 +01:00
Simon Sapin
9edda952c9 Make adjust_static_positions a method of PositioningContext 2019-12-12 15:43:50 +01:00
Simon Sapin
b43a3de51d Introduce PositioningContext 2019-12-12 15:37:01 +01:00
Simon Sapin
c895e3d236 Disable use of rayon with --layout-threads 1 instead of panicking 2019-12-10 18:41:24 +01:00
Simon Sapin
53ce714005 Fix a “Accessing content size that was not requested” panic
Percentage `width` are treated as `auto` for the purpose of
min/max-content computation, so they also need to be considered
when testing “wether width is auto”
2019-12-10 15:11:53 +01:00
Simon Sapin
a17db217a1 Struct with named fields over large tuple 2019-12-10 15:11:53 +01:00
Simon Sapin
be8df1d114 Move solve_axis function to module level 2019-12-10 15:11:53 +01:00
Simon Sapin
29067225a4 Conditionsals over closures 2019-12-10 15:11:53 +01:00
Simon Sapin
c07c980501 Delayed initialization over mutation 2019-12-10 15:11:53 +01:00
Simon Sapin
1fa20e93d0 Implement replaced abspos 2019-12-10 15:11:53 +01:00
Simon Sapin
1fcdde99cb Move two AbsoluteBoxOffsets fields into a Vec2 2019-12-10 15:11:53 +01:00
Simon Sapin
e86222d6bb Remove AbsoluteBoxOffsets’s type parameter 2019-12-10 15:11:53 +01:00
Simon Sapin
f43dc3afcb Remove inline/block_size from AbsolutelyPositionedFragment 2019-12-10 15:11:53 +01:00