Commit graph

49 commits

Author SHA1 Message Date
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
2692426103 Fix text-decoration for block containers in layout-2020
It was only applied to the 1st inline formatting context of a block
container. Other IFCs were created with the Default trait, implying
TextDecorationLine::NONE.
2023-04-26 20:44:01 +02:00
Oriol Brufau
c842023741 Support text-indent in layout-2020
Existing WPT now passing:
  - _mozilla/css/text_indent_a.html
  - css/CSS2/css1/c71-fwd-parsing-002.xht
  - css/CSS2/css1/c71-fwd-parsing-004.xht
  - css/CSS2/floats-clear/floats-138.xht
  - css/CSS2/text/text-indent-007.xht
  - css/CSS2/text/text-indent-008.xht
  - css/CSS2/text/text-indent-010.xht
  - css/CSS2/text/text-indent-019.xht
  - css/CSS2/text/text-indent-020.xht
  - css/CSS2/text/text-indent-031.xht
  - css/CSS2/text/text-indent-032.xht
  - css/CSS2/text/text-indent-043.xht
  - css/CSS2/text/text-indent-044.xht
  - css/CSS2/text/text-indent-055.xht
  - css/CSS2/text/text-indent-056.xht
  - css/CSS2/text/text-indent-067.xht
  - css/CSS2/text/text-indent-068.xht
  - css/CSS2/text/text-indent-079.xht
  - css/CSS2/text/text-indent-080.xht
  - css/CSS2/text/text-indent-091.xht
  - css/CSS2/text/text-indent-092.xht
  - css/CSS2/text/text-indent-103.xht
  - css/CSS2/text/text-indent-104.xht
  - css/CSS2/text/text-indent-112.xht
  - css/CSS2/text/text-indent-113.xht
  - css/CSS2/text/text-indent-115.xht
  - css/CSS2/text/text-indent-applies-to-002.xht
  - css/CSS2/text/text-indent-applies-to-003.xht
  - css/CSS2/text/text-indent-applies-to-005.xht
  - css/CSS2/text/text-indent-applies-to-006.xht
  - css/CSS2/text/text-indent-applies-to-007.xht
  - css/CSS2/text/text-indent-applies-to-008.xht
  - css/CSS2/text/text-indent-applies-to-009.xht
  - css/CSS2/text/text-indent-applies-to-010.xht
  - css/CSS2/text/text-indent-applies-to-011.xht
  - css/CSS2/text/text-indent-applies-to-014.xht
  - css/CSS2/text/text-indent-applies-to-015.xht
  - css/CSS2/text/text-indent-inherited-001.xht
  - css/CSS2/text/text-indent-overflow-001.xht
  - css/CSS2/text/text-indent-overflow-002.xht
  - css/CSS2/text/text-indent-overflow-003.xht
  - css/CSS2/text/text-indent-overflow-004.xht
  - css/CSS2/text/text-indent-wrap-001.xht
  - css/css-text-decor/text-shadow/textindent.html
  - css/css-text/text-indent/text-indent-percentage-001.xht
  - css/css-text/text-indent/text-indent-percentage-002.html
  - css/css-text/text-indent/text-indent-percentage-003.html
  - css/css-text/text-indent/text-indent-percentage-004.html
  - css/css-values/minmax-length-percent-serialize.html
  - css/css-values/minmax-length-serialize.html

Also improvements in:
  - _mozilla/mozilla/calc.html
  - css/css-text/animations/text-indent-interpolation.html
  - css/css-text/inheritance.html
  - css/css-text/parsing/text-indent-computed.html
  - css/css-text/parsing/text-indent-valid.html
  - css/css-transitions/properties-value-implicit-001.html
  - css/css-values/animations/calc-interpolation.html
  - css/css-values/minmax-percentage-serialize.html
  - css/css-values/viewport-units-css2-001.html
  - css/css-variables/variable-substitution-basic.html
  - css/cssom/serialize-values.html

Existing WPT now failing, due to lack of direction, outside list markers,
flex and grid:
  - css/CSS2/text/text-indent-rtl-001.xht
  - css/CSS2/text/text-indent-rtl-002.xht
  - css/css-pseudo/marker-content-023.html
  - css/css-text/text-indent/anonymous-flex-item-001.html
  - css/css-text/text-indent/anonymous-grid-item-001.html

New WPT tests:
 - css/css-text/text-indent/text-indent-length-001.html
 - css/css-text/text-indent/text-indent-length-002.html
   This one fails in layout-2013.
2023-04-25 23:01:07 +02: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
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
Simon Sapin
5fed956d65 Remove the now single-field Accumulator struct 2020-06-19 15:30:23 +02: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
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
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
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
Anthony Ramine
6fe294fa5b Make LayoutNodeHelpers::text_content return a cow 2020-03-31 15:02:13 +02:00
Fernando Jiménez Moreno
17948f3b39 Propagate text decoration where needed 2020-03-23 11:13:10 +01:00
Patrick Walton
0d6c60f03e Make whitespace preservation computation recursive in order to fix lifetime issues 2020-03-17 20:13:57 -07:00
Patrick Walton
9cb824e77c Wrap BlockLevelBox and InlineLevelBox with AtomicRefCell 2020-03-17 11:15:17 -07:00
Anthony Ramine
c3932185ec Make AbsolutelyPositionedBox be 'static 2020-03-17 11:15:17 -07: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
Anthony Ramine
b2f6cc7144 Introduce BlockLevelJob 2019-12-13 17:51:06 +01:00
Simon Sapin
1c8d14ac0d Upgrade rayon_croissant to 0.2.0 2019-12-12 18:57:18 +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
dd9dfc66e3 Use a new BoxContentSizes enum instead of Option<ContentSizes> 2019-12-04 15:36:05 +01:00
Simon Sapin
38e8fd1e99 Replace boolean parameters by a new ContentSizesRequest enum 2019-12-04 15:10:11 +01:00
Simon Sapin
6763e7e4ae Review nits 2019-12-04 14:22:13 +01:00
Simon Sapin
c056e5b6b0 Finish plumbing intrinsic min/max-content through box construction 2019-12-03 15:11:35 +01:00
Simon Sapin
da36fcddb0 Add box construction for 'inline-block'…
… and other atomic inline-level boxes.
2019-12-03 15:11:35 +01:00
Simon Sapin
303b36f17b Add content sizes computation for block containers 2019-12-03 15:11:35 +01:00
Simon Sapin
78bfa45eab Add a Target struct for mapfold_reduce_into call 2019-12-03 15:11:35 +01:00
Simon Sapin
cfdd23ac16 Add a request_content_sizes parameter to IndependentFormattingContext::construct 2019-12-03 15:11:35 +01:00
Simon Sapin
4e6e31a76c Pass a LayoutContext through box construction 2019-12-02 22:26:49 +01:00
Simon Sapin
9c5a595044 Add intrinsic size computation for inline formatting contexts 2019-12-02 22:11:54 +01:00
Anthony Ramine
48a4a82a49 Make InlineLevelBox::Atomic store an IndependentFormattingContext 2019-12-01 10:51:25 +01:00
Anthony Ramine
ecfb82260c Fix an unimplemented in layout 2020 2019-12-01 10:51:19 +01:00
Simon Sapin
80eec48d37 Use std::mem::take instead of defining it 2019-11-26 15:42:27 +01:00
Simon Sapin
b2b3ea992c Make IndependentFormattingContext a struct that owns styles
… 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.
2019-11-26 15:42:27 +01:00
Simon Sapin
22f5e07765 2020: define DisplayInside and DisplayOutside enums separately from Stylo 2019-10-24 10:44:31 +02:00
Anthony Ramine
6345e353d4 Handle inline-block as block for now in layout 2020
That makes Servo not panic when loading servo.org.
2019-10-11 16:43:52 +02:00
Anthony Ramine
e90fae52e5 Remove a wrong assertion 2019-10-08 13:42:41 +02:00
Anthony Ramine
0c156c60c2 Handle anonymous style in end_inline_formatting_context 2019-09-23 20:31:43 +02:00
Anthony Ramine
9cef3eee65 Uncomment more stuff related to box construction 2019-09-19 11:58:07 +02:00
Anthony Ramine
c08cfbb5f3 Cheat the system and use an Arc in BoxSlot
Ideally we want to be able to borrow from the DOM during box construction
but that's not playing very well at the moment with the current bridge
between script and layout.
2019-09-19 11:24:50 +02:00
Anthony Ramine
4444c5a2ad Import victor's layout system 🍷 2019-09-11 10:36:30 +02:00
Simon Sapin
86904757e6 Import files from Victor
fdb11f3e87
2019-09-11 10:06:35 +02:00