Commit graph

9109 commits

Author SHA1 Message Date
Martin Robinson
81f5157522
Add support for table fixups (#30868)
This adds support for fixing up tables so that internal table elements
that are not properly parented in the DOM have the correct box tree
structure according to the CSS Table specification [1]. Note that this
only comes into play when building the DOM via script, as HTML 5 has its
own table fixups that mean that the box tree construction fixups here
are not necessary.

There are no tests for this change. In general, it's hard to write tests
against the shape of the box tree, because it depends on the DOM. We
plan to test this via WPT tests once layout is complete.

1. https://drafts.csswg.org/css-tables/#table-internal-element

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2023-12-22 12:11:58 +00:00
Martin Robinson
74798c4b7b
layout: Add support for text-align-last (#30905)
This change adds support for `text-align-last` as well as ensuring that
it also applies to lines before forced line breaks. Two tests start to
fail because they rely on right-to-left text to pass:

 - /css/css-text/text-align/text-align-last-010.html.ini
 - /css/css-text/text-align/text-align-last-011.html.ini
2023-12-21 14:45:34 +00:00
Alex Touchet
e4aed3d06a
Update branch name to main (#30877) 2023-12-16 09:32:20 +00:00
Martin Robinson
ccf0b739df
Add basic support for text-align: justify (#30807)
This also enables parsing of `text-justify` for non-legacy layout,
though only None is supported (disabling justification).
2023-12-15 14:00:13 +00:00
atbrakhi
9028c90332
Generalize LengthPercentageOrAuto impl to Generic Type (#30824)
* Generalize LengthPercentageOrAuto impl to Generic Type

* review fix
2023-12-06 10:20:43 +00:00
Martin Robinson
a05598402e
Add initial support for sticky positioning for non-legacy layout (#30686)
* Add initial support for sticky positioning for non-legacy layout

Many tests still fail for a variety of reasons. One of the primary ones
is that CSSOM currently does not return correct values for elements
positioned by sticky nodes. This requires changes to WebRender to work
properly.

* Fix an assertion failure in the legacy layout sticky code
2023-11-29 09:03:24 +00:00
Oriol Brufau
27056eb93a Further changes required by Servo 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
1ada5e9605 style: Add a query-selector fast path for attribute selectors in the rightmost compound
Differential Revision: https://phabricator.services.mozilla.com/D180553
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
de9fb7983a style: Speed up / specialize attribute selector-matching
Inline the attribute lookup code, and only branch on the attribute selector
type if we have found an attribute.

Differential Revision: https://phabricator.services.mozilla.com/D180531
2023-11-24 08:57:14 +01:00
Oriol Brufau
8c5a028955 Further changes required by Servo 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
e59c71d8ef style: Remove unused TElement::has_attr
Differential Revision: https://phabricator.services.mozilla.com/D180530
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
3da2db1c53 style: Remove the never_matches field from attr selectors
It's an extra branch which in practice we almost never take, plus extra
checks during parsing.

Differential Revision: https://phabricator.services.mozilla.com/D180529
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
c36a22a97f style: Don't recompute quirks mode -> case sensitivity over and over
The only reason we pass the quirks mode around is to compute the case
sensitivity, but we can just pass the later.

Differential Revision: https://phabricator.services.mozilla.com/D180527
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
5b184f448b style: Fix style invalidation on layer rule insertion
Layer insertion may change the order of styles, so we may need to fully
invalidate.

Without this change, bug 1838045 makes
layer-statement-before-import.html fail.

Differential Revision: https://phabricator.services.mozilla.com/D180929
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
50d7f882dd style: Container units should prevent us from sharing style by rule node
At least when the containers are different.

For now check that by doing a somewhat simplified test (checking
sibling-ness).

The new flag can be useful to optimize container query restyles on
resizes too, in the future.

Differential Revision: https://phabricator.services.mozilla.com/D179268
2023-11-24 08:57:14 +01:00
Ting-Yu Lin
07d6ec5d4b style: Remove obsolete comment to add use counter for developing CSS properties
The CSS properties in the list are all shipped. Since we still don't support use
counter for developing CSS properties since this bug opens, I assume this
feature is not critical. Hence the removal of the comment.

Differential Revision: https://phabricator.services.mozilla.com/D180771
2023-11-24 08:57:14 +01:00
David Shin
ae5e0d49d8 style: Move ANCHORS_RELATIVE_SELECTOR out of nsINode flags
Move the flag to ComputedValueFlags, like `CONSIDERED_RELATIVE_SELECTOR`.

Differential Revision: https://phabricator.services.mozilla.com/D180726
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
9321265b38 style: Clean up Context::for_non_inherited_property
We don't ever check the particular property, so it can just be a
boolean.

Differential Revision: https://phabricator.services.mozilla.com/D180680
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
3da0e44d98 style: Fix rebase conflict with bug 1837664 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
77c541b38a style: Do not snap -webkit-text-stroke-width to dev pixels
Introduce LineWidth (which doesn't snap) and let BorderSideWidth
wrap it and actually do the snapping.

Differential Revision: https://phabricator.services.mozilla.com/D180688
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
127e00e48a style: Improve border-image shorthand serialization, and annotate more passes 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
78f8d575b7 style: Don't allow to share style by rule node for links
(Regardless of visitedness)

Differential Revision: https://phabricator.services.mozilla.com/D180353
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
c8ccb52c9e style: Improve border shorthand serialization
Fix some bugs caught by css/cssom/shorthand-values. In particular:

  * Make the shorthand order match the spec.
  * Omit values when we can.

Fix a subtest that wasn't correct. Shorthands can be serialized as long
as !important matches in all components.

Differential Revision: https://phabricator.services.mozilla.com/D180466
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
cf3d31038c style: Minor clean-ups to border shorthand parsing
This doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D180465
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
7c8cf00033 style: Avoid selecting zero-resolution images in image-set
Fairly straight-forward. This fixes the two tests mentioned in comment 0
which aren't still in the repo.

Differential Revision: https://phabricator.services.mozilla.com/D180414
2023-11-24 08:57:14 +01:00
Oriol Brufau
5842cfc127 Further changes required by Servo 2023-11-24 08:57:14 +01:00
Andrew Osmond
42d9ec1106 style: Add method to parse CSS filters without context for workers
This patch adds the ability to parse most CSS filters without a context.
OffscreenCanvas can use this on worker threads to provide support for
filter operations.

Differential Revision: https://phabricator.services.mozilla.com/D179994
2023-11-24 08:57:14 +01:00
CanadaHonk
a10df24ffb style: Serialize NaN and infinity numbers
Added NaN/inf serialization of <number> and changed calc() code to not
remove NaN/infinity in code using it.

This change is unfortunately imperfect as some things using <number>
still refuse to serialize NaN/infinity for some reason (scale()?), but
this bug/patch is just for <number> so leaving that out of scope for
this.

Also added new WPT test file for number NaN/inf serialization based
on existing serialization tests (all pass already!).

5 other WPT subtests now newly pass.

Differential Revision: https://phabricator.services.mozilla.com/D178587
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
dcb61c095f style: Forbid negative CSS resolutions at parse time
Apply some clang-tidy suggestions while I was going through the
ServoStyleConstsInlines while at it.

Remove one 0x test because it's tested on the same test and causes a
harness error.

Differential Revision: https://phabricator.services.mozilla.com/D180331
2023-11-24 08:57:14 +01:00
Ting-Yu Lin
019c14cf0b style: Make flex-flow serialization interoperable
Differential Revision: https://phabricator.services.mozilla.com/D180270
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
d02c4e2fe9 style: Remove viewport rule code
Turns out Servo doesn't need this either, see
https://github.com/servo/servo/pull/29850.

Differential Revision: https://phabricator.services.mozilla.com/D180264
2023-11-24 08:57:14 +01:00
Oriol Brufau
0b75c1d9d1 Further changes required by Servo 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
23d60c2195 style: Unify parallel and sequential traversal scheduling
Use in_place_scope_fifo to spawn work into the thread pool while doing
work in the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D179492
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
7771cf25a8 style: Remove :nth-child(... of) pref
We ship this, and the front-end uses it by default, so remove the pref.

Differential Revision: https://phabricator.services.mozilla.com/D180222
2023-11-24 08:57:14 +01:00
Boris Chiou
bcae33a43f style: Send offset-position to the compositor
We send offset-position to the compositor, just like other similar
properties, e.g. offset-rotate, offset-anchor. This includes extracting
this animation value, doing serialization and sending it via IPC.

So now we can run the animation of ray() on the compositor properly.

Differential Revision: https://phabricator.services.mozilla.com/D179862
2023-11-24 08:57:14 +01:00
Boris Chiou
2fef5d1a17 style: Add at <position> into ray() in style system
We reuse PositionOrAuto here, and let "auto" represent the situation when the
author omits "at <position>" because it has a special meaning.

https://drafts.fxtf.org/motion-1/#valdef-ray-at-position

Note: No need to update css/motion/parsing/offset-path-parsing-valid.html
because Blink added some to the upstream repo already.

Differential Revision: https://phabricator.services.mozilla.com/D179860
2023-11-24 08:57:14 +01:00
Boris Chiou
8b60424e29 style: Return Err() in to_animated_zero() for offset-path
It's unnecessary to implement ToAnimatedZero for this property and so we
return Err(()), just like other properties which also use basic shapes,
e.g. clip-path, shape-outside.

Differential Revision: https://phabricator.services.mozilla.com/D179859
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
52e2cc5ff0 style: Change some references to raw pointers in some FFI functions
Even tho https://github.com/rust-lang/rust/issues/112337 is IMO a rust
bug, it's easy to work around in our code and it doesn't really affect
expressiveness.

Differential Revision: https://phabricator.services.mozilla.com/D180065
2023-11-24 08:57:14 +01:00
Oriol Brufau
e792eba7c7 Further changes required by Servo 2023-11-24 08:57:14 +01:00
Jihye Hong
9e223342e7 style: Make content-visibility: auto forces contain-intrinsic-size to gain an auto value
When the content having `content-visibility: auto` and the specific value for `contain-intrinsic-size` is slightly out of the viewport,
its computed value keeps changing.
This patch makes `content-visibilty: auto` forces `contain-intrinsic-size` to gain an auto value to solve this issue.

Differential Revision: https://phabricator.services.mozilla.com/D174583
2023-11-24 08:57:14 +01:00
Boris Chiou
e1b6632313 style: Update the syntax of offset-position
Now it supports "normal" keyword. Also, offset-position doesn't create
stacking context and it doesn't have offset transform, so we can
simplify CompareMotionValues() a little bit.

Note: We don't have to add test in [1] because Blink added one to WPT
upstream repo already.

[1] css/motion/parsing/offset-position-parsing-valid.html

Note: the usage of offset-position is in other bugs.

Differential Revision: https://phabricator.services.mozilla.com/D179623
2023-11-24 08:57:14 +01:00
Oriol Brufau
0fd2f08da1 Further changes required by Servo 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
7b4fb5dc22 style: Simplify border snapping
Make the computed value of border-like properties app units (which is
effectively what happens in Gecko already), and clamp at computed value
time.

Differential Revision: https://phabricator.services.mozilla.com/D179481
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
ad72081ac8 style: Rustfmt servo/. r=zrhoffman
$ find servo -name '*.rs' | xargs rustup run nightly rustfmt

Depends on D179380

Differential Revision: https://phabricator.services.mozilla.com/D179381
2023-11-24 08:57:14 +01:00
Oriol Brufau
68cbe6833d Further changes required by Servo 2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
6728158188 style: Use non-locked rules for all rule types that can
Anything that doesn't need interior mutability doesn't need Locked<>
around it.

Depends on D179059

Differential Revision: https://phabricator.services.mozilla.com/D179060
2023-11-24 08:57:14 +01:00
Zach Hoffman
0aed54f636 style: [css-properties-values-api] Remove Locked<> from CssRule::Property arc
Depends on D179038

Differential Revision: https://phabricator.services.mozilla.com/D179039
2023-11-24 08:57:14 +01:00
David Shin
ff8100d396 style: Correct style sharing handling for any element that considered :has() in selector matching
For any element that anchors a `:has()` selector (i.e. Matches a selector that
contains a `:has()` on its rightmost side), we prevent style sharing altogether,
as evaluation of the `:has()` selector is required in the first place to
determine style sharing.

On the other hand, any element matching a rule containing `:has()` without
anchoring it can do style sharing for siblings, but not cousins.

Differential Revision: https://phabricator.services.mozilla.com/D176836
2023-11-24 08:57:14 +01:00
Zach Hoffman
5c0897c8eb style: [css-properties-values-api] Share PropertyRule instance when cloning CssRule::Property
Differential Revision: https://phabricator.services.mozilla.com/D178892
2023-11-24 08:57:14 +01:00
Emilio Cobos Álvarez
48f2f475c6 style: Flush parent document layout if needed for viewport dependent media queries
This is necessary to properly report changes in our document.

The remaining failures are about change event scheduling, which is a
pre-existing issue. Will fix, but in a separate bug.

Differential Revision: https://phabricator.services.mozilla.com/D178917
2023-11-24 08:57:14 +01:00