Commit graph

380 commits

Author SHA1 Message Date
David Shin
7cec63c2bc Bug 1874066: Distinguish edge selectors vs. other nth selectors. r=firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D198464
2024-01-15 16:09:17 +00:00
Keith Cirkel
01be187814 Bug 1866351 - allow :state() after ::part() r=emilio
Adds parser tests for ::part() and ::slotted() to ensure that :state() can only appear after a ::part()

Differential Revision: https://phabricator.services.mozilla.com/D194578
2023-12-03 20:31:24 +00:00
Zach Hoffman
2d02e6d74f Bug 1865563 - Rustfmt servo/. r=firefox-style-system-reviewers,emilio
$ git ls-files servo/*.rs | xargs rustup run nightly rustfmt

Differential Revision: https://phabricator.services.mozilla.com/D194020
2023-11-20 15:17:57 +00:00
Emilio Cobos Álvarez
0b801f75f3 Bug 1864647 - Don't crash when finding nested relative selectors. r=dshin
For now, do the same as pseudo-elements, which is effectively to keep
them in the replaced selector but don't match them. Avoid crashing in
this case.

I filed https://github.com/w3c/csswg-drafts/issues/9600 since this issue
isn't specific about :has(), and depending on the result of that
discussion, the "proper" solution might be different.

Differential Revision: https://phabricator.services.mozilla.com/D193663
2023-11-15 17:21:24 +00:00
Emilio Cobos Álvarez
83e7ff6f92 Bug 1850974 - Make :is(:host) work. r=zrhoffman
This should work per spec, see
https://github.com/w3c/csswg-drafts/issues/9509.

Tweak a bit the selector flags set up so that checking for :host
selectors during CascadeData rebuilds is cheap.

Differential Revision: https://phabricator.services.mozilla.com/D191570
2023-11-01 19:20:28 +00:00
Natalia Csoregi
245fbaa7e8 Backed out changeset 3b13b5585380 (bug 1850974) for causing multiple failures e.g. parser crashes. CLOSED TREE 2023-10-27 19:19:11 +03:00
Emilio Cobos Álvarez
f4542a93c1 Bug 1850974 - Make :is(:host) work. r=zrhoffman
This should work per spec, see
https://github.com/w3c/csswg-drafts/issues/9509.

Tweak a bit the selector flags set up so that checking for :host
selectors during CascadeData rebuilds is cheap.

Differential Revision: https://phabricator.services.mozilla.com/D191570
2023-10-27 14:29:38 +00:00
David Shin
bbff1a3b96 Bug 1853258: Part 3 - Optimize invalidating relative selectors on DOM mutation. r=emilio
There are cases where we can run a selector match to realize that some DOM mutations
will not make a difference in the relative selector match state, which avoids
O(n^2) behaviour under some circumstances.

Differential Revision: https://phabricator.services.mozilla.com/D191307
2023-10-24 15:11:54 +00:00
Emilio Cobos Álvarez
6df8d66691 Bug 1859917 - Fixup opt build.
MANUAL PUSH: Bustage fix CLOSED TREE
2023-10-19 17:58:24 +02:00
Emilio Cobos Álvarez
f5eb13c2da Bug 1859917 - Make SelectorList cheaply cloneable and more compact. r=dshin
We have ArcSelectorList for selector-lists that are cheap to copy.

For bug 1859915 and related, what we're going to end up doing is probably
expanding into the SelectorList of the parent rule unconditionally, at least
for the "single bare &" case.

It'd be nice to unify SelectorList implementations as preparation for that, and
make them cheaper to clone in general.

My proposal is making SelectorList a tagged pointer to either a single
selector, or to a ThinArc, effectively preserving the SmallVec<> optimization
we have now. This patch implements that proposal.

Depends on D191361

Differential Revision: https://phabricator.services.mozilla.com/D191362
2023-10-19 15:35:54 +00:00
David Shin
faa0e1c8ea Bug 1858720: Prevent :has over-invalidation with sibling DOM mutations. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D190817
2023-10-17 13:17:31 +00:00
Emilio Cobos Álvarez
b54e546019 Bug 1857936 - Remove invalid assert. r=zrhoffman
<forgiving-selector-list> uses <any-value>, which uses
<declaration-value>, which forbids some bad tokens, so our behavior is
correct.

Add a test for this.

Differential Revision: https://phabricator.services.mozilla.com/D190497
2023-10-10 10:08:36 +00:00
Emilio Cobos Álvarez
508315ff53 Bug 1856018 - Make forgiving selectors serialize. r=dshin
As per resolution in https://github.com/w3c/csswg-drafts/issues/8356

Safari already does this. Expand the tests they tweaked to be useful
again (test that when non-forgiving parsing is used, then the selector
is invalid).

Differential Revision: https://phabricator.services.mozilla.com/D189666
2023-10-04 12:52:06 +00:00
Sandor Molnar
3eebdc5a45 Backed out changeset 21db15048e15 (bug 1856018) for causing multiple failures/bustages CLOSED TREE 2023-10-03 20:41:43 +03:00
Emilio Cobos Álvarez
d0f7e8403a Bug 1856018 - Make forgiving selectors serialize. r=dshin
As per resolution in https://github.com/w3c/csswg-drafts/issues/8356

Safari already does this. Expand the tests they tweaked to be useful
again (test that when non-forgiving parsing is used, then the selector
is invalid).

Differential Revision: https://phabricator.services.mozilla.com/D189666
2023-10-03 16:05:24 +00:00
Emilio Cobos Álvarez
0e00ba901b Bug 1854658 - Fix the part combinator to deal with exportparts correctly. r=zrhoffman
We need to jump to an element in the correct scope just like ::slotted()
does.

Factor that code to its own function both so that it's easier to reason
about and so that the code for that function remains small. At the end
of the day other combinators like descendant or sibling get executed a
ton of times (while pseudo-elements only jump once).

Differential Revision: https://phabricator.services.mozilla.com/D189478
2023-10-02 11:51:03 +00:00
Mike Hommey
ad5c3990ad Bug 1855617 - Upgrade stylo to bitflags 2. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D189451
2023-09-28 08:01:16 +00:00
Mike Hommey
e963564f60 Bug 1852209 - Fixup servo for bitflags 2 after bug 1792501. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D189315
2023-09-27 19:56:16 +00:00
CanadaHonk
1ec96570e0 Bug 1854809 - Include quotes in AtomString CSS serialization r=emilio
The serialization of `AtomString` should include quotes itself
rather than users of it having to do so themselves.

Differential Revision: https://phabricator.services.mozilla.com/D189050
2023-09-25 20:39:51 +00:00
Butkovits Atila
699a770452 Backed out changeset f4a2f296a2ea (bug 1854809) for causing build bustages. CLOSED TREE 2023-09-24 01:07:55 +03:00
CanadaHonk
ec54a400d5 Bug 1854809 - Include quotes in AtomString CSS serialization r=emilio
The serialization of `AtomString` should include quotes itself
rather than users of it having to do so themselves.

Differential Revision: https://phabricator.services.mozilla.com/D189050
2023-09-23 21:13:18 +00:00
David Shin
018c4ad794 Bug 1792501: Part 4 - Basic :has invalidation. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D185677
2023-09-14 22:21:25 +00:00
David Shin
aa280d1e29 Bug 1792501: Part 3 - Let :has contribute to dependencies. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D185676
2023-09-14 22:21:25 +00:00
David Shin
4100e7723e Bug 1792501: Part 1 - Mark relative selector search path. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D185674
2023-09-14 22:21:24 +00:00
Sandor Molnar
4bd577fefa Backed out 8 changesets (bug 1792501) for causing wpt failures on /css/selectors/...
Backed out changeset 993b0e6567e6 (bug 1792501)
Backed out changeset 7686c9df9ad4 (bug 1792501)
Backed out changeset cf9f855ad80c (bug 1792501)
Backed out changeset 27abe13a5a48 (bug 1792501)
Backed out changeset f708f940e907 (bug 1792501)
Backed out changeset 2a7c57a69803 (bug 1792501)
Backed out changeset 69f1155100f5 (bug 1792501)
Backed out changeset 3f5f59b76a56 (bug 1792501)
2023-09-14 20:08:41 +03:00
David Shin
a53ddf9908 Bug 1792501: Part 4 - Basic :has invalidation. r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D185677
2023-09-14 12:30:56 +00:00
David Shin
63086e5c76 Bug 1792501: Part 3 - Let :has contribute to dependencies. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D185676
2023-09-14 12:30:56 +00:00
David Shin
7b00e82664 Bug 1792501: Part 1 - Mark relative selector search path. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D185674
2023-09-14 12:30:54 +00:00
Mike Hommey
6ebb4786a2 Bug 1852208 - Prepare dom and style crates for a switch to a bitflags 2-derived bitflags 1. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D188061
2023-09-14 00:01:42 +00:00
Emilio Cobos Álvarez
cf18ae38db Bug 1852568 - Update cssparser. r=tlouw,supply-chain-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D187910
2023-09-12 16:03:44 +00:00
Mike Hommey
5384d789bb Bug 1852201 - Downgrade bitflags in the dom and style crates. r=emilio
This undoes bug 1835681, adjusting for changes that happened since then,
because the crates don't build with the real bitflags 2, and there are
some challenges to make them work with the real bitflags 2.

Differential Revision: https://phabricator.services.mozilla.com/D187748
2023-09-10 22:27:26 +00:00
Emilio Cobos Álvarez
a12b2fedd1 Bug 1846745 - Update cssparser. r=tlouw,supply-chain-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D185154
2023-08-02 16:57:37 +00:00
David Shin
1a6e83991a Bug 1845095: Make sure caching and filtering for relative selector isn't used in invalidation. r=emilio
Unify the invalidation flag used for nth index cache for this purpose.

Differential Revision: https://phabricator.services.mozilla.com/D184526
2023-07-31 12:21:25 +00:00
David Shin
604783a77a Bug 1845095: Bloom filter for fast-rejecting :has(). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D184525
2023-07-31 12:21:24 +00:00
Cristina Horotan
fae61692c7 Backed out 2 changesets (bug 1845095) for causing wpt failures at is-pseudo-containing-complex-in-has.html CLOSED TREE
Backed out changeset 28c18b287904 (bug 1845095)
Backed out changeset fb0e9233e07d (bug 1845095)
2023-07-28 19:07:26 +03:00
David Shin
9e02c40dd1 Bug 1845095: Make sure caching and filtering for relative selector isn't used in invalidation. r=emilio
Unify the invalidation flag used for nth index cache for this purpose.

Differential Revision: https://phabricator.services.mozilla.com/D184526
2023-07-28 13:13:35 +00:00
David Shin
398ecb5c1f Bug 1845095: Bloom filter for fast-rejecting :has(). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D184525
2023-07-28 13:13:34 +00:00
Emilio Cobos Álvarez
30adf86c52 Bug 1844900 - Improve memory usage with nesting. r=dshin
The idea is to share more memory when expanding nested rules (so being
able to share the whole :is() / :where() allocation), and same for the
Dependency computation (basically, share it across all descendant
selectors).

This prevents exponential explosion in cases like the one in bug 1844446
if you replace tag selectors by class selectors (so that we build
invalidation maps for them).

Differential Revision: https://phabricator.services.mozilla.com/D184283
2023-07-27 21:38:10 +00:00
Natalia Csoregi
c181ea32cf Backed out changeset c59d018a76ed (bug 1844900) for causing bustages. CLOSED TREE 2023-07-28 00:04:59 +03:00
Emilio Cobos Álvarez
1f450024cb Bug 1844900 - Improve memory usage with nesting. r=dshin
The idea is to share more memory when expanding nested rules (so being
able to share the whole :is() / :where() allocation), and same for the
Dependency computation (basically, share it across all descendant
selectors).

This prevents exponential explosion in cases like the one in bug 1844446
if you replace tag selectors by class selectors (so that we build
invalidation maps for them).

Differential Revision: https://phabricator.services.mozilla.com/D184283
2023-07-27 20:24:23 +00:00
Iulian Moraru
8ec6e4224d Backed out 2 changesets (bug 1845095) for causing build bustages related to DummyAtom: PrecomputedHash. CLOSED TREE
Backed out changeset c3549dbe2420 (bug 1845095)
Backed out changeset 2b7db53664a6 (bug 1845095)
2023-07-27 21:31:19 +03:00
David Shin
e928053513 Bug 1845095: Make sure caching and filtering for relative selector isn't used in invalidation. r=emilio
Unify the invalidation flag used for nth index cache for this purpose.

Differential Revision: https://phabricator.services.mozilla.com/D184526
2023-07-27 18:03:38 +00:00
David Shin
50d297a299 Bug 1845095: Bloom filter for fast-rejecting :has(). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D184525
2023-07-27 18:03:38 +00:00
David Shin
700bb9288f Bug 1822177: Simple relative selector caching. r=emilio
This simple relative selector cache avoids O(n^2) behaviour when the relative
selector is not in the subject position. e.g. `.anchor:has(.a) ~ .subject`,
with a DOM tree .anchor + .subject + .. + .subject.

Differential Revision: https://phabricator.services.mozilla.com/D184373
2023-07-25 14:23:27 +00:00
David Shin
f8ba4f823c Bug 1843103: Proper cousin style sharing for non-rightmost :has() selectors. r=emilio
Previous code actually could not distinguish when `:has()` is on the rightmost
side or not. This caused every candidate containing any `:has()` selector to be
outright refused from being inserted into style sharing cache.

Differential Revision: https://phabricator.services.mozilla.com/D183405
2023-07-24 12:49:57 +00:00
Emilio Cobos Álvarez
32ea1e021b Bug 1842221 - Simplify ThinArc and friends. r=boris
ThinArc is way more complex than it needs to be, and miri complains
about various things when using the selectors crate with it.

This doesn't fully fix miri, but it gets much closer. ThinArc becomes
just an alias for Arc<HeaderSlice<>>. This allows to simplify the
bindings to ArcSlice too, since now the existing Arc<> code can just be
used.

Differential Revision: https://phabricator.services.mozilla.com/D183011
2023-07-12 07:17:25 +00:00
Markus Stange
24f1c30cdc Bug 1839082 - Add a fast path for non-compound attribute selectors. r=emilio
This improves the testcase in bug 1837673, because it means that we only
check attributes once. Before this patch, we would check them twice: First,
the SimpleFilter path would check for the presence of the attribute, and then
later we would enumerate attributes again to check the attribute value.
Now we don't use the SimpleFilter path anymore and go straight to attribute
enumeration.

Differential Revision: https://phabricator.services.mozilla.com/D181349
2023-07-09 19:09:27 +00:00
Mike Hommey
e46d768d3c Bug 1841160 - Update phf to 0.11.2. r=emilio,supply-chain-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D182514
2023-07-04 07:29:08 +00:00
Emilio Cobos Álvarez
caae6da5e7 Bug 1837818 - Remove special selector-matching case in matches_simple_selector. r=boris
This doesn't regress stylebench.

Depends on D180592

Differential Revision: https://phabricator.services.mozilla.com/D180593
2023-06-19 09:51:38 +00:00
Emilio Cobos Álvarez
e92382018b Bug 1837818 - Minor selector matching tweaks. r=boris
The idea is to make the function small enough that it's fast to inline and
optimize by the compiler. For that:

 * Move some complex bits of matches_simple_selector into functions so
   that the compiler can put them out of line if it wants.

 * Rename a function to be more descriptive and not force it to be
   inline (that wasn't measured afaict, comes from the :nth-child(of)
   implementation).

Depends on D180591

Differential Revision: https://phabricator.services.mozilla.com/D180592
2023-06-16 17:24:01 +00:00