Commit graph

159 commits

Author SHA1 Message Date
Naveen Gattu
0e3b52af27 fmt 2021-11-30 18:13:39 -08:00
Naveen Gattu
00a7c172e2
rm ws 2021-11-30 12:54:15 -08:00
Naveen Gattu
9af545e4e4
Do not use ParallelIterator if not using rayon 2021-11-30 12:51:56 -08:00
yvt
638941ac43 refactor(layout_2020): add depth parameter to the closure passed to FragmentTree::find 2021-06-16 00:56:41 +09:00
Josh Matthews
260347e5dc Simplify control flow of whitespace handling. 2020-07-27 20:06:55 -04:00
Josh Matthews
d8b4dab4e3 Implement basic white-space: pre support for layout 2020. 2020-07-27 20:06:53 -04:00
Manish Goregaokar
5a53fb1271 Adjust absolute positioned box offsets in flow layout 2020-07-27 09:48:37 -07:00
Manish Goregaokar
96c0c50874 Allow adjusting box offsets 2020-07-27 09:48:37 -07:00
bors-servo
9864e4ce6c
Auto merge of #27385 - servo:list, r=Manishearth
Add Layout 2020 support for `display: list-item`
2020-07-24 21:18:16 -04:00
Simon Sapin
b91e293819 Add layout support for list markers 2020-07-24 09:31:24 +02:00
Simon Sapin
82e274aec9 Make a bool for display: list-item available to flow box construction 2020-07-23 16:43:57 +02:00
Patrick Walton
362b64aa68 Use the size of the containing block, not the size of the block formatting
context, to place floats in layout 2020.

The containing block for a float is not necessarily the same as the block
formatting context the float is in per CSS 2.1 [1]:

"For other elements, if the element’s position is relative or static, the
containing block is formed by the content edge of the nearest block container
ancestor box."

This shows up in the simplest case:

	<html>
	<body>
	<div style="float: left">Hello</div>
	</body>
	</html>

In this case, the `<html>` element is the block formatting context with inline
size equal to the width of the window, but the `<body>` element with nonzero
inline margins is the containing block for the float. The float placement must
respect the content box of the `<body>` element (i.e. floats must not overlap
the `<body>` element's margins), not that of the `<html>` element.

Because a single block formatting context may contain floats with different
containing blocks, the left and right "walls" of that containing block become
properties of individual floats at the time of placement, not properties of the
float context itself.

Additionally, this commit generalizes the float placement logic a bit to allow
the placement of arbitrary objects, not just floats. This is intended to
support inline layout and block formatting context placement.

This commit updates the `FloatContext` and associated tests only and doesn't
actually wire the context up to the rest of layout, so floats in pages still
aren't actually laid out.

[1]: https://drafts.csswg.org/css2/#containing-block-details
2020-07-22 19:58:28 -07:00
Patrick Walton
5b36d211b4 Add an implementation of the core float and clear placement logic in layout
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.
2020-07-20 12:42:34 -07:00
Simon Sapin
080f5bb763 An element establishing a formatting context *is* the containing block for its contents 2020-06-23 00:41:26 +02:00
bors-servo
53263595f1
Auto merge of #26968 - servo:layout-2020-lazy-content-sizes, r=SimonSapin
Compute content sizes lazily in layout 2020
2020-06-19 13:50:29 -04:00
Simon Sapin
42e9d2450e Parallelize BlockContainer::inline_content_sizes 2020-06-19 15:38:15 +02:00
Simon Sapin
5fed956d65 Remove the now single-field Accumulator struct 2020-06-19 15:30:23 +02:00
Simon Sapin
51c388fe1c Rename outer_inline* outside of sizing.rs to outer_inline_content_sizes* 2020-06-19 15:27:33 +02:00
Anthony Ramine
235df94f2e Compute content sizes lazily in layout 2020 2020-06-18 14:11:02 +02:00
Martin Robinson
f3e373bc62 Add animation and transition support for pseudo-elements
This change extends the DocumentAnimationSet to hold animations for
pseudo-elements. Since pseudo-elements in Servo are not in the DOM like
in Gecko, they need to be handled a bit carefully in stylo.  When a
pseudo-element has an animation, recascade the style. Finally, this
change passes the pseudo-element string properly to animation events.

Fixes: #10316
2020-06-16 16:33:55 +02:00
bors-servo
ba5568a0a6
Auto merge of #26921 - mrobinson:animation-set-key, r=jdm
Add DocumentAnimationSet and AnimationSetKey

This will be used in order to hold animations for pseudo elements in the
DocumentAnimationSet. Also no longer store the OpaqueNode in the
animation and transition data structures. This is already part of the
DocumentAnimationSet key.

---
<!-- 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
- [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-06-16 03:25:29 -04:00
Anthony Ramine
db80b8e3c1 Make IndependentFormattingContext an enum 2020-06-15 18:09:15 +02:00
Anthony Ramine
07d8c28d4a Make outer_inline and outer_inline_and_percentages free functions
They now take a closure that will compute the content sizes on demand.
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
Martin Robinson
4a3995bb37 Add DocumentAnimationSet and AnimationSetKey
This will be used in order to hold animations for pseudo elements in the
DocumentAnimationSet. Also no longer store the OpaqueNode in the
animation and transition data structures. This is already part of the
DocumentAnimationSet key.
2020-06-15 10:28:30 +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
Anthony Ramine
d9e87f2eb1 Mutably borrow to do layout of independent formatting contexts
We want to compute content sizes on demand rather than eagerly so we will
need to mutate the independent formatting contexts that own the content sizes.
2020-06-09 13:44:43 +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
fff5cd5142 Owned ServoArc<ComputedValues> in TraversalHandler 2020-06-04 13:19:53 +02:00
Simon Sapin
67d8aa84d2 Anonymous flex item for text directly in a flex container 2020-06-04 13:19:53 +02:00
Simon Sapin
ec548e849c Flex items in the box tree 2020-06-04 13:19:53 +02:00
Anthony Ramine
a30bdc16dd Reconstruct the box tree incrementally in some case 2020-06-04 10:49:45 +02:00
Martin Robinson
a238597a18 layout_2020: Add support for transitions and animations 2020-05-19 10:02:03 +02:00
Simon Sapin
1f6efbf9e9 Correctly paint the CSS canvas’ background
https://drafts.csswg.org/css-backgrounds/#special-backgrounds

Fixes https://github.com/servo/servo/issues/25559
Closes https://github.com/servo/servo/pull/26121, as it is an alternative.
2020-05-15 13:37:09 +02:00
Simon Sapin
3e8623332b Rewrite handling of pointers to boxes in the DOM tree 2020-05-15 13:25:35 +02:00
Simon Sapin
c43ab0c267 Rename BoxTreeRoot/FragmentTreeRoot to BoxTree/FragmentTree 2020-05-15 13:25:35 +02:00
Simon Sapin
ee62c7f2e4 Set in the DOM the box generated by the root element 2020-05-15 13:25:35 +02:00
Simon Sapin
09dbf91e7b display: contents computes to block on the root element 2020-05-15 13:25:35 +02:00
bors-servo
aa9f16ce45
Auto merge of #26477 - mrobinson:layout-2020-get-computed-value, r=jdm
Add support for getComputedStyle() to layout_2020

These changes add support for `getComputedStyle()` to layout_2020.

---
<!-- 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
- [x] There are tests for these changes

<!-- 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-05-11 15:57:25 -04:00
Martin Robinson
9c7b1ae715 layout_2020: Add initial support for getComputedStyle
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.
2020-05-11 20:14:01 +02:00
Martin Robinson
a637810df3 layout_2020: Add support for transform-style
This requires creating a matching stacking context for every reference
frame and also properly placing those stacking contexts inside them.
2020-05-11 15:03:29 +02:00
Simon Sapin
7f975c3d5d Remove use of some other unstable features 2020-04-15 15:17:52 +02:00
bors-servo
5926577534
Auto merge of #26079 - servo:box-sizing, r=nox
Implement the `box-sizing` property
2020-04-01 07:49:08 -04:00
Simon Sapin
08801d94cd Less cloning 2020-04-01 01:00:14 +02:00
bors-servo
75ca3d8198
Auto merge of #26075 - servo:facepalm, r=jdm
Don’t forget to apply the inline-start margin to blocks 🤦
2020-03-31 17:44:51 -04: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
Simon Sapin
8350f8a08a Don’t forget to apply the inline-start margin to blocks 🤦 2020-03-31 22:59:43 +02:00