Commit graph

48 commits

Author SHA1 Message Date
Martin Robinson
b60e105526 Refactor Layout 2020 layout for a compositor-side scroll tree
This change refactors how layout is done in Layout 2020 in preparation
for a compositor-side scroll tree:

1. Now the SpatialId and ClipId of each fragment is stored separately.
   This will allow storing a scroll node id instead of only the handle
   to the WebRender spatial node.
2. Separate out stacking context tree construction and display list
   building. This change will make it possible to eventually build the
   stacking context tree without the full display list if we find that
   necessary. For instance, this might be useful to cache containing
   block boundaries.
3. Add a `DisplayList` struct that stores both the WebRender display
   list builder and the compositor info. This exposes the API to the
   layout thread for display list building.

In addition, this change adds a lot of missing documentation.  This
should not change behavior.
2023-05-17 10:46:27 +02:00
bors-servo
4e37d07ea4
Auto merge of #29699 - mrobinson:add-html-body-tag, r=mukilan
Detect body elements during layout

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.

<!-- 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
- [x] These changes do not require tests because it does 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. -->
2023-05-04 11:35:25 +02:00
Martin Robinson
72302e2dae Detect body elements during layout
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.
2023-05-04 10:46:27 +02:00
Oriol Brufau
16b07ee456 Implement outline-offset in layout-2020
Tests that are now passing:
- /_mozilla/css/outline_offset_a.htm
- /css/css-ui/outline-010.html
- /css/css-ui/outline-012.html
- /css/css-ui/outline-013.html
- /css/css-ui/outline-017.html
- /css/css-ui/outline-negative-offset-composited-scroll.html
- /css/css-ui/outline-offset-001.html
- /css/css-ui/outline-offset-table-001.html
- /css/css-ui/outline-offset.html
- /css/css-ui/parsing/outline-offset-computed.html
- /css/css-ui/parsing/outline-offset-valid.html

Also improvements in:
- /_mozilla/mozilla/calc.html
- /css/css-ui/animation/outline-offset-interpolation.html
- /css/css-ui/inheritance.html
2023-05-02 17:59:48 +02:00
Oriol Brufau
d67bf49bd9 Implement outlines in layout-2020
This only covers the CSS2 properties: 'outline-width', 'outline-style',
'outline-color', and the shorthand 'outline'.

CSS UI 3 introduced 'outline-offset', which is left for a follow-up.

'outline-color: invert' isn't included either, but note CSS UI says that
conformant UAs may ignore the 'invert' value on platforms that do not
support color inversion of the pixels on the screen.

Tests that are now passing:
- /_mozilla/css/input_insertion_point_empty_a.html
- /_mozilla/css/outlines_simple_a.html
- /_mozilla/css/stacking_context_overflow_relative_outline_a.html
- /_mozilla/mozilla/getPropertyPriority.html
- /css/CSS2/ui/outline-color-001.xht
- /css/CSS2/ui/outline-color-002.xht
- /css/CSS2/ui/outline-color-007.xht
- /css/CSS2/ui/outline-color-008.xht
- /css/CSS2/ui/outline-color-013.xht
- /css/CSS2/ui/outline-color-018.xht
- /css/CSS2/ui/outline-color-023.xht
- /css/CSS2/ui/outline-color-024.xht
- /css/CSS2/ui/outline-color-025.xht
- /css/CSS2/ui/outline-color-031.xht
- /css/CSS2/ui/outline-color-036.xht
- /css/CSS2/ui/outline-color-041.xht
- /css/CSS2/ui/outline-color-046.xht
- /css/CSS2/ui/outline-color-047.xht
- /css/CSS2/ui/outline-color-048.xht
- /css/CSS2/ui/outline-color-049.xht
- /css/CSS2/ui/outline-color-050.xht
- /css/CSS2/ui/outline-color-051.xht
- /css/CSS2/ui/outline-color-052.xht
- /css/CSS2/ui/outline-color-053.xht
- /css/CSS2/ui/outline-color-054.xht
- /css/CSS2/ui/outline-color-058.xht
- /css/CSS2/ui/outline-color-059.xht
- /css/CSS2/ui/outline-color-061.xht
- /css/CSS2/ui/outline-color-062.xht
- /css/CSS2/ui/outline-color-069.xht
- /css/CSS2/ui/outline-color-070.xht
- /css/CSS2/ui/outline-color-071.xht
- /css/CSS2/ui/outline-color-072.xht
- /css/CSS2/ui/outline-color-073.xht
- /css/CSS2/ui/outline-color-074.xht
- /css/CSS2/ui/outline-color-075.xht
- /css/CSS2/ui/outline-color-079.xht
- /css/CSS2/ui/outline-color-081.xht
- /css/CSS2/ui/outline-color-082.xht
- /css/CSS2/ui/outline-color-089.xht
- /css/CSS2/ui/outline-color-090.xht
- /css/CSS2/ui/outline-color-091.xht
- /css/CSS2/ui/outline-color-092.xht
- /css/CSS2/ui/outline-color-093.xht
- /css/CSS2/ui/outline-color-094.xht
- /css/CSS2/ui/outline-color-095.xht
- /css/CSS2/ui/outline-color-099.xht
- /css/CSS2/ui/outline-color-101.xht
- /css/CSS2/ui/outline-color-102.xht
- /css/CSS2/ui/outline-color-109.xht
- /css/CSS2/ui/outline-color-110.xht
- /css/CSS2/ui/outline-color-111.xht
- /css/CSS2/ui/outline-color-112.xht
- /css/CSS2/ui/outline-color-113.xht
- /css/CSS2/ui/outline-color-114.xht
- /css/CSS2/ui/outline-color-115.xht
- /css/CSS2/ui/outline-color-119.xht
- /css/CSS2/ui/outline-color-121.xht
- /css/CSS2/ui/outline-color-122.xht
- /css/CSS2/ui/outline-color-130.xht
- /css/css-ui/outline-001.html
- /css/css-ui/outline-002.html
- /css/css-ui/outline-004.html
- /css/css-ui/outline-007.html
- /css/css-ui/outline-008.html
- /css/css-ui/outline-016.html
- /css/css-ui/outline-018.html
- /css/css-ui/outline-021.html
- /css/css-ui/outline-022.html
- /css/css-ui/outline-color-001.html
- /css/css-ui/outline-style-011.html
- /css/css-ui/outline-style-012.html
- /css/css-ui/outline-style-013.html
- /css/css-ui/outline-style-014.html
- /css/css-ui/parsing/outline-color-computed.html
- /css/css-ui/parsing/outline-color-valid-mandatory.html
- /css/css-ui/parsing/outline-shorthand.html
- /css/css-ui/parsing/outline-style-computed.html
- /css/css-ui/parsing/outline-style-valid.html
- /css/css-ui/parsing/outline-width-valid.html
- /css/css-ui/translucent-outline.html

Also improvements in:
- /_mozilla/mozilla/calc.html
- /css/css-ui/animation/outline-color-interpolation.html
- /css/css-ui/animation/outline-width-interpolation.html
- /css/css-ui/inheritance.html
- /css/css-ui/outline-017.html
- /css/css-ui/parsing/outline-valid-mandatory.html
- /css/css-ui/parsing/outline-width-computed.html
- /css/cssom/cssom-setProperty-shorthand.html
- /css/cssom/getComputedStyle-resolved-colors.html
- /css/cssom/serialize-values.html
- /css/cssom/shorthand-values.html

New failures:
- /css/CSS2/ui/outline-applies-to-005.xht
- /css/CSS2/ui/outline-applies-to-006.xht
- /css/CSS2/ui/outline-color-applies-to-005.xht
- /css/CSS2/ui/outline-color-applies-to-006.xht
- /css/CSS2/ui/outline-style-applies-to-005.xht
- /css/CSS2/ui/outline-style-applies-to-006.xht
- /css/CSS2/ui/outline-width-applies-to-005.xht
- /css/CSS2/ui/outline-width-applies-to-006.xht
  Al of these fail because tables are not implemented yet.
- /css/css-ui/outline-offset.html
  Fails because outline-offset is not implemented yet.
- /css/css-ui/outline-with-padding-001.html
  Fails because the outline doesn't include overflowing contents.
  I don't think this is required by the spec, Firefox fails too.
2023-05-02 02:37:10 +02:00
Oriol Brufau
678b590f80 Normalize corner radii that add up to > 100%
WebRender already seems to be doing this normalization, but this is
needed by inner_radii in order to properly compute the reduced radii
when background-clip is content-box or padding-box.

This will also be needed for expanding the radii for box-shadow or
outline.

Test: css/css-backgrounds/background-rounded-image-clip-002.html
2023-05-01 02:17:54 +02:00
bors-servo
4339b3bab4
Auto merge of #29684 - Loirooriol:corner-clipping-typos, r=mrobinson
Fix corner clipping typos in layout-2020

<!-- Please describe your changes on the following line: -->
inner_radii() had a minus sign that shouldn't be there.

And padding_edge_clip() and content_edge_clip() clearly need to to use
the padding_rect() and content_rect() instead of border_rect.

Tests:
  - css/css-backgrounds/background-clip-padding-box-with-border-radius.html
  - css/css-backgrounds/background-rounded-image-clip.html

---
<!-- 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 fix #29683 (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. -->
2023-04-29 09:15:59 +02:00
Oriol Brufau
88b9ecea3c Fix corner clipping typos in layout-2020
inner_radii() had a minus sign that shouldn't be there.

And padding_edge_clip() and content_edge_clip() clearly need to to use
the padding_rect() and content_rect() instead of border_rect.

Tests:
  - css/css-backgrounds/background-clip-padding-box-with-border-radius.html
  - css/css-backgrounds/background-rounded-image-clip.html
2023-04-29 08:25:48 +02:00
Oriol Brufau
668c4c8aba Round text decoration thickness to >= 1 device pixels
Previously the thickness coming from font metrics could be something
like 0.7px, so with 1dppx it would be painted as either 1 or 0 device
pixels.

Enforcing at least 1 device pixel ensures that the decoration will be
visible, and rounding to an integral amount of device pixels ensures
that the thickness won't vary depending on the position.

The specification requires this behavior when text-decoration-thickness
is set to a length or percentage. It's not clear if it should also
happen by default, but this seems to match other browsers (except for
WebKit rounding up instead of to the nearest integer).

The test text-decoration-thickness-from-zero-sized-font.html is now
failing because of #29675.
2023-04-27 23:48:53 +02:00
Martin Robinson
9e0b41ebc4 Add support for <iframe> elements for Layout 2020
This change adds support for the <iframe> element to Layout 2020. In
addition, certain aspects of the implementation are made the same
between both layout systems.
2023-04-04 17:49:24 +02:00
Martin Robinson
6d4b7e7a22 Move hit testing information out of WebRender
Store hit testing information in a data structure that sits alongside
the display list in the compositor. This will allow the compositor to
store more information per-node. The data structure also takes care of
de-duplicating information between successive display list entries. In
the future, the data structure can be even more aggressive in producing
smaller side hit testing lists, if necessary.
2023-03-15 12:25:29 +01:00
Emilio Cobos Álvarez
31e8e418ea Miscellaneous build / tidy fixes. 2021-02-26 17:53:55 +01:00
Matthias Deiml
b85a5dac5d Implement visibility for layout_2020 2020-06-14 00:31:37 +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
Martin Robinson
c2875482d6 layout_2020: Implement support for backface-visibility 2020-05-16 09:42:45 +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
Josh Matthews
af05da574b Use new webrender rounded clip API. 2020-05-12 14:43:41 -04:00
Josh Matthews
eb2f7f7f0a Convert all uses of UpdateResources api to use webrender transactions. 2020-05-11 17:41:56 -04:00
Josh Matthews
8842250033 Update webrender. 2020-05-11 17:41:56 -04:00
Emilio Cobos Álvarez
848a6203de Some servo build fixes. 2020-04-16 18:29:30 +02:00
Daniel Alley
61fb84d6a0 Don't send empty canvases to WebRender
If any dimension of a canvas is 0, don't try to render it as it causes
problems inside webrender.
2020-04-03 11:34:04 -04:00
Fernando Jiménez Moreno
17948f3b39 Propagate text decoration where needed 2020-03-23 11:13:10 +01:00
Fernando Jiménez Moreno
83fc9943d3 Do not use buggy text_decorations_in_effect 2020-03-23 11:10:44 +01:00
Fernando Jiménez Moreno
689b413bde Add support for text-decoration-style 2020-03-23 11:10:44 +01:00
Fernando Jiménez Moreno
928bd0d1d2 Add support for text-decoration-color 2020-03-23 11:10:44 +01:00
Fernando Jiménez Moreno
107af9e769 Render text-decoration: line-through on layout 2020 2020-03-23 11:10:44 +01:00
Fernando Jiménez Moreno
c87a4dd788 Remove unnecessary fragment rect clone 2020-03-23 11:10:44 +01:00
Fernando Jiménez Moreno
4fd5484e1a Render text-decoration: overline on layout 2020 2020-03-23 11:10:44 +01:00
Fernando Jiménez Moreno
48517bd61a Render text-decoration: underline on layout 2020 2020-03-23 11:10:44 +01:00
Fernando Jiménez Moreno
e3c8597ccb Store required font metrics on TextFragment 2020-03-23 11:10:44 +01: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
d03560b0f1 Add layout_2020 support for filters and mix-blend-mode 2020-02-19 10:26:13 +01:00
Martin Robinson
4a2787b974 Add initial stacking context paint order support to layout_2020
This adds very rudimentary support for paint order in stacking context.
In particular z-index is now handled properly, apart from issues with
hoisted fragments.
2020-02-17 10:05:19 +01:00
Martin Robinson
843df5b529 Add support for a stacking context pass to layout_2020
This adds an intermediary data structure that allows the display list
builder to move through the fragment tree in stacking context painting
order. Spatial nodes are built during this phase and all display list
items are added to the end of the display list.
2020-02-14 10:57:45 +01:00
Martin Robinson
63aae0178f Improve position:fixed support in layout_2020
This makes it so that position:fixed elements do not scroll with the
rest of the contents, but does not tackle the rest of the issues with
their positioning.
2020-02-11 10:42:35 +01:00
Martin Robinson
20b8edc625 Clean up BoxFragment display list builder in layout_2020
This makes things a big easier to read and will make it easier to add
support for position:fixed.
2020-02-07 14:35:05 +01:00
Martin Robinson
7a5a320d74 Add support for overflow:scroll and overflow:hidden to layout_2020
This adds clipping and interactive scrolling support, but scrolling from
script is still not functional.
2020-01-31 17:30:29 +01:00
Simon Sapin
632e731760 Render gradients 2020-01-24 14:20:20 +01:00
Simon Sapin
f39c3ff38b Apply background-clip to background-color 2020-01-24 14:20:20 +01:00
Simon Sapin
ea4882a1c5 Fix combinations of border-radius and background-clip 2020-01-24 14:20:20 +01:00
Simon Sapin
c8c198a172 Add a display_list::background module 2020-01-24 14:20:20 +01:00
Simon Sapin
6901bf951a Make layout_2020::display_list a directory-module 2020-01-24 14:20:20 +01:00
Simon Sapin
3e6489f543 Remove layout_2020::display_list, use WebRender display lists instead 2019-09-07 19:38:44 +02:00
Simon Sapin
526619a78a Replace the WebRenderDisplayItemConverter trait with an inherent method 2019-09-06 16:59:11 +02:00
Anthony Ramine
053e361e2f Remove more stuff from layout_2020 2019-08-13 13:45:05 +02:00
Anthony Ramine
317d700f5d Remove most of the things in layout 2020
We keep mostly the query system. There is probably more to delete but
that's a good start I think.
2019-07-31 17:09:17 +02:00
Anthony Ramine
4846d76e82 Make layout_2020 be layout_2013 2019-07-31 17:09:16 +02:00