Commit Graph

256 Commits

Author SHA1 Message Date
David Shin
7f31578a84 Bug 1886441: Part 4 - Add support for implicit scope. r=firefox-style-system-reviewers,emilio
Keep track of implicit scopes for shadow DOM styled separately,
as cascade data for shadow DOM are shared.

Differential Revision: https://phabricator.services.mozilla.com/D207781
2024-05-30 15:23:41 +00:00
Oriol Brufau
69332f9fd4 Bug 1887913 - AtomIdent and LocalName are different in Servo. r=emilio
In Gecko, LocalName is an alias for AtomIdent.
But in Servo they aren't the same, so these changes are needed.

Differential Revision: https://phabricator.services.mozilla.com/D205728
2024-03-26 16:21:53 +00:00
keithamus
390ef8eb0d Bug 1865589 - Notify PresShell of CustomState changes, so Restyle can invalidate. r=emilio,dshin
Differential Revision: https://phabricator.services.mozilla.com/D202460
2024-03-22 22:18:05 +00:00
Oriol Brufau
a03dabb455 Bug 1886141 - Simplify return type of relative_selector_search_direction(). r=emilio
Instead of Option<ElementSelectorFlags>, it can be ElementSelectorFlags,
representing None as ElementSelectorFlags::empty().

No change in behavior.

Differential Revision: https://phabricator.services.mozilla.com/D205051
2024-03-19 13:20:46 +00:00
Emilio Cobos Álvarez
5f79a1e4b6 Bug 1885136 - Allow Servo to start the style traversal from outside the thread pool. r=firefox-style-system-reviewers,zrhoffman
This should be flexible enough. In the future Servo might want to make
more guarantees about what threads the style thread pool contains.

Differential Revision: https://phabricator.services.mozilla.com/D204506
2024-03-14 10:19:59 +00:00
keithamus
2c3b3f4d43 Bug 1861466 - Add CustomStateSet and :state() pseudo. r=emilio,smaug
Differential Revision: https://phabricator.services.mozilla.com/D191988
2023-11-08 13:38:02 +00:00
David Shin
14291fa2ca 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
Sandor Molnar
f1783ba5d9 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
89940257af 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
Emilio Cobos Álvarez
6ffb0e4d93 Bug 1837734 - Remove unused TElement::has_attr. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D180530
2023-06-14 21:08:22 +00:00
David Shin
ba793505a2 Bug 1835037: Move ANCHORS_RELATIVE_SELECTOR out of nsINode flags. r=emilio
Move the flag to ComputedValueFlags, like `CONSIDERED_RELATIVE_SELECTOR`.

Differential Revision: https://phabricator.services.mozilla.com/D180726
2023-06-13 13:21:42 +00:00
Emilio Cobos Álvarez
3a9e9be090 Bug 1835681 - 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-05-30 08:04:52 +00:00
David Shin
2a948d57d8 Bug 1793012: Correct style sharing handling for any element that considered :has() in selector matching. r=emilio
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-05-25 14:35:18 +00:00
Emilio Cobos Álvarez
c195031050 Bug 1825825 - Simplify NAC setup. r=smaug
Make all UA widgets also NAC.

Keep the UA widget flag but break at anonymous subtree boundaries, so
that only nodes inside the UA widget directly (and not NAC from those)
get the flag.

This is important because two callers depend on this difference:

 * The style system, since we still want to match content rules from
   stylesheets in the UA widget. We also match user rules, which is a
   bit sketchy, but that was the previous behavior, will file a
   follow-up for that.

 * The reflector code, since we want the scope for UA widgets to not
   include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
   got it wrong.

After this patch, ChromeOnlyAccess is equivalent to
IsInNativeAnonymousSubtree, so we should probably unify the naming.
That's left for a follow-up patch because I don't have a strong
preference.

Differential Revision: https://phabricator.services.mozilla.com/D174310
2023-04-05 09:19:15 +00:00
Emilio Cobos Álvarez
f7e094302e Bug 1822432 - Restyle pseudo-elements as well on part attribute changes. r=jwatt
Refactor a bit the code to unify how we deal with this conditional
restyling (we had similar code for
MustCascadeChildrenIfInheritResetStyle).

Differential Revision: https://phabricator.services.mozilla.com/D172890
2023-03-27 18:17:56 +00:00
Oriol Brufau
b83672cf03 Bug 1804696 - Re-evaluate container queries when container gets display:contents. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D164234
2022-12-14 01:55:11 +00:00
Oriol Brufau
9553165dfd Bug 1804247 - Evaluate size feature to unknown if the container lacks size containment. r=emilio
For example, inline elements may have container-type:size but they don't
support size containment, so @container(width >= 0) shouldn't match.

Differential Revision: https://phabricator.services.mozilla.com/D163936
2022-12-06 19:08:51 +00:00
Oriol Brufau
b24d2092ae Bug 1804066 - @container(width:0) shouldn't match elements with no box. r=emilio
Depends on D163879

Differential Revision: https://phabricator.services.mozilla.com/D163844
2022-12-06 12:57:50 +00:00
Oriol Brufau
8610314c15 Bug 1792592 - Make container queries check content-box size. r=emilio
They were checking the border-box size (with paddings and borders), but
https://drafts.csswg.org/css-contain-3/#size-container says it should
be the content-box size.

Differential Revision: https://phabricator.services.mozilla.com/D163784
2022-12-05 15:16:48 +00:00
Emilio Cobos Álvarez
1f86312701 Bug 1803643 - Speed up dom iteration in querySelector. r=dholbert
This removes a few branches and null-checks that I found in profiles.

Depends on D163627

Differential Revision: https://phabricator.services.mozilla.com/D163628
2022-12-03 11:25:10 +00:00
Emilio Cobos Álvarez
f53d909a8c Bug 1794720 - fix invalidation of sibling combinators in different slots. r=firefox-style-system-reviewers,layout-reviewers,boris
This extends the code to deal with sibling invalidation to handle the
case where the flat tree doesn't match the DOM tree. In the test-case
for example, dom is:

 * details
   * summary id=a
   * summary

But flat tree is:

 * details
  * slot
    * summary id=a
  * slot
    * summary

Differential Revision: https://phabricator.services.mozilla.com/D159150
2022-10-20 08:39:18 +00:00
Emilio Cobos Álvarez
2bc0294d20 Bug 1791281 - Simplify our setup for font metric queries from style. r=jfkthame
While looking at moving the flag around I realized that the only reason
we have FontMetricsProvider and co is because we didn't have access to
the per-document font-prefs cache. That's trivial to fix tho, so do
that and simplify the setup for font queries even more.

Differential Revision: https://phabricator.services.mozilla.com/D157589
2022-09-20 19:30:45 +00:00
Emilio Cobos Álvarez
1c58e2a928 Bug 1773070 - Unify Gecko and Servo EventState/ElementState bits. r=smaug
Add a dom/base/rust crate called just "dom" where we can share these.

Most of the changes are automatic:

  s/mozilla::EventStates/mozilla::dom::ElementState/
  s/EventStates/ElementState/
  s/NS_EVENT_STATE_/ElementState::/
  s/NS_DOCUMENT_STATE_/DocumentState::/

And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.

Differential Revision: https://phabricator.services.mozilla.com/D148537
2022-06-07 23:09:52 +00:00
Emilio Cobos Álvarez
7115380b63 Bug 1769612 - More container queries plumbing. r=boris
Provide container information in computed::Context and use it to resolve
the container queries.

This still fails a lot of tests because we are not ensuring that layout
is up-to-date when we style the container descendants, but that's
expected.

Differential Revision: https://phabricator.services.mozilla.com/D146478
2022-05-20 09:59:39 +00:00
Marian-Vasile Laza
351f42f99b Backed out changeset 99ab9844b58a (bug 1769612) for causing web-platform failures on container-size-invalidation-after-load.html. 2022-05-20 05:20:30 +03:00
Emilio Cobos Álvarez
b9430f4967 Bug 1769612 - More container queries plumbing. r=boris
Provide container information in computed::Context and use it to resolve
the container queries.

This still fails a lot of tests because we are not ensuring that layout
is up-to-date when we style the container descendants, but that's
expected.

Differential Revision: https://phabricator.services.mozilla.com/D146478
2022-05-20 00:49:44 +00:00
Narcis Beleuzu
251b7ed431 Backed out changeset 8d386f8c684d (bug 1769612) for build bustages on applicable_declarations.rs 2022-05-20 02:15:44 +03:00
Emilio Cobos Álvarez
a1f89aa454 Bug 1769612 - More container queries plumbing. r=boris
Provide container information in computed::Context and use it to resolve
the container queries.

This still fails a lot of tests because we are not ensuring that layout
is up-to-date when we style the container descendants, but that's
expected.

Differential Revision: https://phabricator.services.mozilla.com/D146478
2022-05-19 22:23:07 +00:00
Emilio Cobos Álvarez
33f640d4eb Bug 1767625 - Simplify selector flags setup even more. r=boris
In my investigation for bug 1766439, I am digging into why selector
matching regressed.

It doesn't help that the selector-matching code is instantiated a
gazillion times (so there's a ton of copies of the relevant functions).

This was needed in the past because we had different ways of setting the
selector flags on elements, but I unified that recently and now we only
need to either set them or not. That is the kind of thing that
MatchingContext is really good for, so pass that instead on
MatchingContext creation.

Differential Revision: https://phabricator.services.mozilla.com/D145428
2022-05-06 08:17:20 +00:00
Emilio Cobos Álvarez
31ac41d30a Bug 1680285 - Simplify selector flag setting now that flag setting is atomic. r=nika,decoder
These bits are write-only, actually, and we don't even need to read
them.

Differential Revision: https://phabricator.services.mozilla.com/D141888
2022-03-24 15:09:47 +00:00
Emilio Cobos Álvarez
4c5ebc98ca Bug 1719824 - Inline GeckoNode::prev_sibling. r=smaug
It's very hot when matching some kind of selectors like the ones in bug
1717267, and the two function calls show up in the profiles.

Differential Revision: https://phabricator.services.mozilla.com/D119505
2021-07-09 15:22:59 +00:00
Emilio Cobos Álvarez
6f64bbcf83 Bug 1711170 - Look at the right element for exportparts in each_applicable_non_document_style_rule_data. r=boris
Otherwise we might not find those rules for invalidation.

Differential Revision: https://phabricator.services.mozilla.com/D115130
2021-05-20 08:31:34 +00:00
Emilio Cobos Álvarez
55b3bb27e4 Bug 1704551 - Add attribute names to the bloom filter. r=boris
Safari does this. This reduces the runtime in the example linked from
comment 0 quite a lot (40ms on a local opt build, from ~130ms on a
release nightly build).

I added a pref because there's a slight chance of performance
regressions on pages that do not use attribute selectors, as we're now
doing more unconditional work per element (adding the attributes to the
bloom filter). But the trade-off should be worth it, I think.

Differential Revision: https://phabricator.services.mozilla.com/D111689
2021-04-13 10:53:40 +00:00
Emilio Cobos Álvarez
ad5c7e466f Bug 1683295 - Make next_in_preorder generate slightly better code. r=heycam
This avoids the panic code in release builds.

Differential Revision: https://phabricator.services.mozilla.com/D100094
2020-12-23 02:59:11 +00:00
Emilio Cobos Álvarez
69199d50b9 Bug 1678881 - Avoid some allocations in selector serialization. r=xidorn
The allocations in display_to_css_identifier show up in the profiles of
bug 1675628.

Differential Revision: https://phabricator.services.mozilla.com/D97856
2020-11-22 01:02:22 +00:00
Emilio Cobos Álvarez
09604c958f Bug 1665823 - Consider display: none elements as having current style for animation-only traversal. r=hiro
This is mostly a band-aid, though it also serves sorta as an
optimization.

The issue here is basically bug 1393323. By re-cascading, right now we
can't come up with the right before-change style if CSSOM has mutated
the rules. We really need a better way to come up with the before-change
style, as the animation-only traversal is not really sustainable (nor
fast, for that matter...).

But this avoids crashing and prevents the regression easily, so let's do
that for now.

Differential Revision: https://phabricator.services.mozilla.com/D90700
2020-09-19 14:28:51 +00:00
Emilio Cobos Álvarez
25d3f423c1 Bug 1646811 - Fix gecko build.
Depends on D80248

Differential Revision: https://phabricator.services.mozilla.com/D80249
2020-06-18 18:14:29 +00:00
Martin Robinson
16205a26a7 Bug 1646811 - servo: Combine AnimationAndTransitionDeclarations and AnimationRules.
These two structs are very similar, so we can combine them.

Depends on D80243

Differential Revision: https://phabricator.services.mozilla.com/D80244
2020-06-18 18:14:07 +00:00
Martin Robinson
3edfabc7f8 Bug 1646811 - servo: 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

Depends on D80242

Differential Revision: https://phabricator.services.mozilla.com/D80243
2020-06-18 18:14:05 +00:00
Martin Robinson
47e3dbaf80 Bug 1646811 - servo: Include animations and transitions in the cascade.
Instead of applying animations and transitions to styled elements,
include them in the cascade. This allows them to interact properly with
things like font-size and !important rules.

Depends on D80234

Differential Revision: https://phabricator.services.mozilla.com/D80235
2020-06-18 18:12:14 +00:00
Martin Robinson
694a5a05a0 Bug 1646811 - servo: Better computation of animation keyframes.
This begins to address #26625 by properly applying CSS variables during
keyframe computation and no longer using `apply_declarations`. Instead,
walk the declarations, combining them into IntermediateComputedKeyframe,
maintaining declarations that modify CSS custom properties. Then compute
a set of AnimationValues for each keyframe and use those to produce
interpolated animation values.

Depends on D80233

Differential Revision: https://phabricator.services.mozilla.com/D80234
2020-06-18 18:12:07 +00:00
Martin Robinson
dfe189b874 Bug 1646811 - servo: Cache animation computed values when animations change.
Instead of recalculating the animation style every tick of an animation,
cache the computed values when animations change. In addition to being
more efficient, this will allow us to return animation rules as property
declarations because we don't need to consult the final style to produce
them.

Depends on D80232

Differential Revision: https://phabricator.services.mozilla.com/D80233
2020-06-18 18:11:57 +00:00
Emilio Cobos Álvarez
3e65f8f3ae Bug 1646546 - Port the style crate to rust 2018. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D80101
2020-06-17 23:40:30 +00:00
Anthony Ramine
510bb9fc72 Bug 1630676 - Don't expose any AtomicRefCell directly from style traits.
This lets us experiment with how we store this data on the DOM side.
2020-04-16 21:17:41 +02:00
Ciure Andrei
b9f226f4e7 Backed out 11 changesets (bug 1630676) for causing multiple failures CLOSED TREE
Backed out changeset c1fbe364b76c (bug 1630676)
Backed out changeset 629970c8f0b7 (bug 1630676)
Backed out changeset 1530f4a9aef2 (bug 1630676)
Backed out changeset a5b60fb5a0e1 (bug 1630676)
Backed out changeset a6e1a31c3e0d (bug 1630676)
Backed out changeset 4df9717e28f0 (bug 1630676)
Backed out changeset c76b0b0e503b (bug 1630676)
Backed out changeset 3c89aec57d0a (bug 1630676)
Backed out changeset 369cf504584d (bug 1630676)
Backed out changeset d7eff4acb616 (bug 1630676)
Backed out changeset 1d47c9354eeb (bug 1630676)
2020-04-16 21:45:51 +03:00
Anthony Ramine
df7c661b75 Bug 1630676 - Don't expose any AtomicRefCell directly from style traits.
This lets us experiment with how we store this data on the DOM side.
2020-04-16 18:37:49 +02:00
Emilio Cobos Álvarez
97bf130e47 Bug 1618509 - Allow to export a shadow part under multiple names. r=jwatt
Other browsers allow this and the spec doesn't really disallow it, so fix it,
add a test and carry on.

Differential Revision: https://phabricator.services.mozilla.com/D65107
2020-03-09 13:04:21 +00:00
Simon Sapin
4446bb348c Bug 1614394 - Move OpaqueNode to style_traits.
Differential Revision: https://phabricator.services.mozilla.com/D62302
2020-02-10 17:32:11 +00:00
Emilio Cobos Álvarez
9693838c60 Bug 1604173 - Rustfmt recent changes.
Differential Revision: https://phabricator.services.mozilla.com/D57314
2019-12-16 13:34:20 +00:00
Emilio Cobos Álvarez
b03dc3cbe9 Bug 1600773 - Invalidate shadow part pseudo-class styles correctly. r=heycam
I was going to send a test for `:focus` via wpt, but then realized it was
probably not spec-compliant with the new rules people want to follow for
:focus, so I filed https://github.com/w3c/csswg-drafts/issues/4555 instead.

Testing `:hover` / `:active` via wpt looked quite a bit of a hassle.

Differential Revision: https://phabricator.services.mozilla.com/D55591
2019-12-09 13:40:16 +00:00