Commit Graph
85 Commits
Author SHA1 Message Date
Emilio Cobos Álvarez e4ecfea530 Bug 2038976 - Make CSSOM work on raw declaration blocks, rather than DeclarationBlock. r=firefox-style-system-reviewers,layout-reviewers,dshin
This will make being more granular with cloning easier, and we don't
need it after the previous patch.

This leaves DeclarationBlock only for the style attribute for now, we
need it for the AttrStyles stuff. But I plan to move that to
MiscContainer instead or so.

Differential Revision: https://phabricator.services.mozilla.com/D300052
2026-05-13 22:29:25 +00:00
Emilio Cobos Álvarez f7e0f764d4 Bug 2038976 - Move immutable flag from DeclarationBlock to Rust. r=firefox-style-system-reviewers,dshin
This makes us not have to care about the owning rule.

Make shmem rules immutable directly too, to avoid needing the
OwnerIsReadOnly() checks.

Differential Revision: https://phabricator.services.mozilla.com/D300026
2026-05-12 16:30:41 +00:00
Hiroyuki Ikezoe d1ee4bd4a8 Bug 2031468 - Disable ::-webkit-scrollbar on a per-domain blocklist. r=firefox-style-system-reviewers,layout-reviewers,emilio
Some sites probe `@supports selector(::-webkit-scrollbar)` to detect
WebKit/Blink and then ship styles that depend on real WebKit scrollbar
behavior, which our partial `::-webkit-scrollbar` support does not match.
Give us a way to disable the pseudo-element on specific domains while
keeping it enabled everywhere else; on listed domains the pseudo is
treated as unknown by the selector parser, so `@supports selector(...)`
also reports it as unsupported.

Differential Revision: https://phabricator.services.mozilla.com/D299295
2026-05-11 09:15:25 +00:00
Serban Stanca 06e30b558f Revert "Bug 2031468 - Disable ::-webkit-scrollbar on a per-domain blocklist. r=firefox-style-system-reviewers,layout-reviewers,emilio" for causing Android reftests failures.
This reverts commit 8a0a6843b1.
2026-05-11 07:48:05 +00:00
Hiroyuki Ikezoe 8a0a6843b1 Bug 2031468 - Disable ::-webkit-scrollbar on a per-domain blocklist. r=firefox-style-system-reviewers,layout-reviewers,emilio
Some sites probe `@supports selector(::-webkit-scrollbar)` to detect
WebKit/Blink and then ship styles that depend on real WebKit scrollbar
behavior, which our partial `::-webkit-scrollbar` support does not match.
Give us a way to disable the pseudo-element on specific domains while
keeping it enabled everywhere else; on listed domains the pseudo is
treated as unknown by the selector parser, so `@supports selector(...)`
also reports it as unsupported.

Differential Revision: https://phabricator.services.mozilla.com/D299295
2026-05-11 05:12:18 +00:00
Emilio Cobos Álvarez 1ddad57128 Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug
Make them concrete classes rather than interfaces, and make the
inheritance chain simpler.

Differential Revision: https://phabricator.services.mozilla.com/D296484
2026-04-28 07:38:27 +00:00
Silaghi ce61f876cc Revert "Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug" for causing wpt failures at BaseContentList
This reverts commit cde3e5607b.
2026-04-28 03:43:46 +00:00
Emilio Cobos Álvarez cde3e5607b Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug
Make them concrete classes rather than interfaces, and make the
inheritance chain simpler.

Differential Revision: https://phabricator.services.mozilla.com/D296484
2026-04-28 00:24:11 +00:00
Emilio Cobos Álvarez 11be491237 Bug 2024942 - Reduce more includes of ServoStyleConsts. r=sergesanspaille
Use nsTArray + span for SendAsyncMessage since it allows for incomplete
types (std::vector on libc++ doesn't).

Differential Revision: https://phabricator.services.mozilla.com/D288906
2026-03-21 07:07:21 +00:00
Sylvestre Ledru 55481ac4b5 Bug 2023419 - Remove Emacs/Vim modelines from layout/ r=emilio,firefox-style-system-reviewers,layout-reviewers
replaced by .editorconfig

Differential Revision: https://phabricator.services.mozilla.com/D287852
2026-03-17 12:05:43 +00:00
Emilio Cobos Álvarez 30b7a3d89a Bug 2014922 - Untangle pseudo-element and anon box definitions. r=firefox-style-system-reviewers,xpcom-reviewers,layout-reviewers,dshin,nika
I looked at this because in bug 2014331 I need to mark more pseudos as
element-backed, and it's kinda silly the state our setup is in right
now.

This is all a somewhat historical mess, because in the old style system
pseudo-elements were just atoms, and we had that different types of atom
setup. The source of truth for these right now lives in a header macro
file, which isn't very flexible.

But now we have PseudoStyleType which represents both pseudos and anon
boxes, and is similar to the rust side PseudoElement enum.

Plus, the ::-moz-tree pseudo-elements are defined as anon boxes which
doesn't make any sense, so move them to pseudo-elements while at it.

Unify this in a similar way we treat CSS properties: Source of truth is
in pseudo_elements.toml / anon_boxes.toml, and we generate Rust and C++
as needed. This allows removing the nsStaticAtom subclass thing from
XPCOM, too.

This avoids some nasty duplication around which pseudos are pref-gated
and what not as well.

Differential Revision: https://phabricator.services.mozilla.com/D282076
2026-02-06 07:39:54 +00:00
Norisz Fay 27f4694604 Revert "Bug 2014922 - Untangle pseudo-element and anon box definitions. r=firefox-style-system-reviewers,xpcom-reviewers,layout-reviewers,dshin,nika" for causing bustage @ ElementAnimationData.h
This reverts commit c70290c619.
2026-02-06 05:34:42 +00:00
Emilio Cobos Álvarez c70290c619 Bug 2014922 - Untangle pseudo-element and anon box definitions. r=firefox-style-system-reviewers,xpcom-reviewers,layout-reviewers,dshin,nika
I looked at this because in bug 2014331 I need to mark more pseudos as
element-backed, and it's kinda silly the state our setup is in right
now.

This is all a somewhat historical mess, because in the old style system
pseudo-elements were just atoms, and we had that different types of atom
setup. The source of truth for these right now lives in a header macro
file, which isn't very flexible.

But now we have PseudoStyleType which represents both pseudos and anon
boxes, and is similar to the rust side PseudoElement enum.

Plus, the ::-moz-tree pseudo-elements are defined as anon boxes which
doesn't make any sense, so move them to pseudo-elements while at it.

Unify this in a similar way we treat CSS properties: Source of truth is
in pseudo_elements.toml / anon_boxes.toml, and we generate Rust and C++
as needed. This allows removing the nsStaticAtom subclass thing from
XPCOM, too.

This avoids some nasty duplication around which pseudos are pref-gated
and what not as well.

Differential Revision: https://phabricator.services.mozilla.com/D282076
2026-02-06 03:42:45 +00:00
Emilio Cobos Álvarez b0833eed7d Bug 2008650 - Notify and invalidate on @position-try declaration changes. r=firefox-style-system-reviewers,layout-anchor-positioning-reviewers,layout-reviewers,dshin
This builds on top of bug 1910616.

I decided to bubble up the invalidation sets and keep the cascade data
difference in StylesheetInvalidationSet because it felt clearer (it
always was a bit of a wart that we had to pass the root and snapshot map
down to flush).

Now the caller is responsible to flush of course, but I think it's
nicer, specially now that we also merged the shadow dom invalidation
there.

Eventually, it might be worth moving most of the existing sets into the
`CascadeDataDifference`, to be able to track stuff more accurately...
Maybe we can just diff the ElementAndPseudoRules maps? Though given some
pages have hundreds of thousands of rules that might be too much, not
sure. Anyways, one step at a time.

Differential Revision: https://phabricator.services.mozilla.com/D277951
2026-01-06 15:12:03 +00:00
sickl8 4db5196484 Bug 2004140 - Implement initial StylePropertyMap support for CSSStyleRule. r=emilio,firefox-style-system-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D275366
2025-12-17 22:13:41 +00:00
Sandor Molnar 2d9326f07a Revert "Bug 2004140 - Implement initial StylePropertyMap support for CSSStyleRule. r=emilio,firefox-style-system-reviewers,janv" for causing build bustages @ StylePropertyMapReadOnly.cpp
This reverts commit 96a8bffa4e.
2025-12-15 20:40:52 +00:00
sickl8 96a8bffa4e Bug 2004140 - Implement initial StylePropertyMap support for CSSStyleRule. r=emilio,firefox-style-system-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D275366
2025-12-15 19:29:02 +00:00
David Shin dcd95a8a36 Bug 2005744: Add a comment for DevTools follow-up when adding to ToWebIDLSelectorWarningKind. r=firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D276190
2025-12-12 14:46:24 +00:00
Boris Chiou b7e1499bbc Bug 1997145 - Add pseudo element identifier to selector_matches_element(). r=firefox-style-system-reviewers,emilio
In order to support view transition pseudo-element, we have to pass the
pseudo element identifier to this function to retrive the correct
pseudo-element.

Differential Revision: https://phabricator.services.mozilla.com/D270626
2025-10-30 20:35:03 +00:00
Nicolas Chevobbe 5d0f814072 Bug 1995943 - Check all potentially related hosts in CSSStyleRule::SelectorMatchesElement. r=emilio,firefox-style-system-reviewers.
Differential Revision: https://phabricator.services.mozilla.com/D269931
2025-10-24 14:32:03 +00:00
David Shin 053240086b Bug 1882379: Generate warning for useless :scope selectors. r=firefox-style-system-reviewers,webidl,layout-reviewers,smaug,emilio
Differential Revision: https://phabricator.services.mozilla.com/D268045
2025-10-09 10:28:16 +00:00
Jan Varga 9f594375a9 Bug 1988479 - Add initial StylePropertyMap.get/set implementation for CSSStyleValue reification; r=firefox-style-system-reviewers,dshin
This patch introduces a minimal implementation of StylePropertyMap.get and
StylePropertyMap.set to support the first steps of CSSStyleValue reification.

For now:
- .get and .set fall back to the standard CSS OM rather than optimized
  reification paths.
- This is sufficient to allow initial WPT tests for reification to run and
  exercise the infrastructure.
- More efficient handling (avoiding round-tripping through CSS text, and
  reusing PropertyDeclarationBlock directly) will be added in follow-up patches.

Differential Revision: https://phabricator.services.mozilla.com/D264772
2025-09-18 11:14:53 +00:00
David Shin ddb7b52487 Bug 1980210: Support @scope in ChromeOnly CSSStyleRule.querySelectorAll. r=firefox-style-system-reviewers,devtools-reviewers,layout-reviewers,emilio,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D261767
2025-08-21 23:34:13 +00:00
David Shin 475481d626 Bug 1894251: Implement ChromeOnly CSSStyleRule.getScopeRootFor. r=firefox-style-system-reviewers,webidl,emilio
... Re-use existing `selectorMatchesElement` machinery for this, since finding
the scope root equates to running selector matching anyway.

Differential Revision: https://phabricator.services.mozilla.com/D261254
2025-08-19 15:44:50 +00:00
David Shin 5fd9ce062a Bug 1934914: Support @scope in CSSScopeRule#selectorMatchesElement. r=firefox-style-system-reviewers,devtools-reviewers,nchevobbe,emilio
Differential Revision: https://phabricator.services.mozilla.com/D259417
2025-08-06 22:50:56 +00:00
Jan Varga 16e1ff0824 Bug 1976443 - Implement CSSStyleRule.styleMap by returning a stub StylePropertyMap; r=emilio,smaug
This patch adds implementation of CSSStyleRule.styleMap from the CSS Typed OM
Level 1 specification.

It connects the partial interface for CSSStyleRule and returns a cached stub
StylePropertyMap instance.

This is part of ongoing incremental development of the CSS Typed OM API.

Differential Revision: https://phabricator.services.mozilla.com/D256957
2025-07-16 07:07:02 +00:00
Emilio Cobos Álvarez a8a2311474 Bug 1976457 - Sort includes in layout/. r=janv,dshin
Interesting bit is layout/.clang-format, the rest is all automated.

Differential Revision: https://phabricator.services.mozilla.com/D256616
2025-07-09 13:24:00 +00:00
Emilio Cobos Álvarez 6f23ab3430 Bug 1972515 - Expose out of band declarations like pres hints and view transition UA rules in InspectorUtils.getMatchingCSSRules. r=devtools-reviewers,nchevobbe,dshin
Differential Revision: https://phabricator.services.mozilla.com/D253483
2025-06-18 08:42:56 +00:00
Emilio Cobos Álvarez d16593275e Bug 1933473 - Track changes to declaration blocks correctly in the style rule map. r=devtools-reviewers,jwatt
The raw declaration block might change for a given rule. We need to keep
track of it properly for devtools in order to not lose track of rules.

Could I convince someone from DevTools to write a test for this? :)
Otherwise please point me to the right test to extend / change, and I
can.

Differential Revision: https://phabricator.services.mozilla.com/D230439
2024-11-28 12:10:15 +00:00
Boris Chiou b6c240ef4c Bug 1921553 - Use PseudoStyleRequest in nsCSSPseudoElements. r=view-transitions-reviewers,layout-reviewers,emilio
And some related code, such as `KeyframeEffectParams` and
`IsSupportedPseudoForAnimations()`.

Note: `GetPseudoAtom()` and `GetPseudoType()` are redundant, so remove them.

Differential Revision: https://phabricator.services.mozilla.com/D228224
2024-11-25 23:46:31 +00:00
Emilio Cobos Álvarez 2f64c16efb Bug 1921505 - Allow setting selectorText to a relative selector, if nested. r=dshin
Differential Revision: https://phabricator.services.mozilla.com/D223988
2024-09-27 18:54:08 +00:00
Emilio Cobos Álvarez e623bb8997 Bug 1919853 - Make InspectorUtils able to return CSSNestedDeclarations too. r=devtools-reviewers,nchevobbe,dshin
Rename getCSSStyleRules now that it can return something else, and
change getCSSStyleRules_starting_style.html to cover this again.

Unfortunately the asserts in ServoStyleRuleMap.cpp no longer hold,
because the style attribute and other declarations are expected not to
show up there.

Differential Revision: https://phabricator.services.mozilla.com/D222856
2024-09-20 15:59:53 +00:00
Emilio Cobos Álvarez 62087dd417 Bug 1918408 - Implement the nested declarations rule. r=dshin,webidl,smaug
I didn't put this behind a pref because it was a bit annoying to do with
the parser changes while keeping it fast, and because, at least nesting
wise, this is unlikely to cause compat issues.

There are some complexities for @scope, which I think I got right.

Fixed the tests not to depend on @scope necessarily per the discussion
in https://github.com/web-platform-tests/interop/issues/697.

Differential Revision: https://phabricator.services.mozilla.com/D222817
2024-09-19 20:23:22 +00:00
Daniel Holbert cd7fd0677f Bug 1896711 part 5: Use MakeRefPtr/MakeAndAddRef to reduce boilerplate, in layout/style. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D210390
2024-05-15 07:29:21 +00:00
Nicolas Chevobbe 04ae2068e4 Bug 1893923 - [devtools] Add ChromeOnly CSSStyleRule::querySelectorAll. r=layout-reviewers,emilio.
For the selector highlighter, we were retrieving the desugared selector of each
displayed rule, and using the selector text in querySelectorAll to retrieve the
elements matching the rule.
This can be very expensive, especially for deeply nested rule, for a feature that
might not even be used.
This patch is adding a method which takes a root node, and will return the
elements inside the root node that match the rule's selectors.
We're only exposing the method that existed in glue.rs to get the SelectorList
of a given Rule, and call `Servo_SelectorList_QueryAll` with it to get our NodeList.

A test file is added to ensure this works as expected.

Differential Revision: https://phabricator.services.mozilla.com/D208363
2024-04-29 06:43:23 +00:00
Emily McDonough 4de01116d4 Bug 1890844 - Tiny cleanup of classes implementing nsDOMCSSDeclaration r=layout-reviewers,emilio
* Make CSSKeyframeDeclaration final.
* Give DocToUpdate a default implementation returning nullptr. That way we can
    use that for CSSKeyframeDeclaration, CSSPageRule, and CSSStyleRule.
* Make DocToUpdate final on nsDOMCSSAttrDeclaration and nsComputedDOMStyle.

Differential Revision: https://phabricator.services.mozilla.com/D207198
2024-04-15 22:17:02 +00:00
David Shin fd14b1ba66 Bug 1862900: Fix build bustage. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D192687
2023-11-03 18:05:38 +00:00
David Shin 268a42b2d5 Bug 1833679 - DevTools warnings infrastructure. r=nchevobbe,emilio
Differential Revision: https://phabricator.services.mozilla.com/D191333
2023-11-02 15:29:12 +00:00
Emilio Cobos Álvarez fa938be857 Bug 1839420 - Make CSSStyleRule.selectorMatchesElement use the desugared selector list. r=nchevobbe,firefox-style-system-reviewers,boris
Trivial enough. This makes the test in D181732 pass.

Differential Revision: https://phabricator.services.mozilla.com/D181741
2023-06-22 22:12:49 +00:00
Emilio Cobos Álvarez dde7ee0dea Bug 1838627 - Refactor InspectorUtils APIs that just forward to CSSStyleRule, and expose desugared selectors on them. r=nchevobbe,webidl,firefox-style-system-reviewers,smaug,devtools-reviewers,boris
Differential Revision: https://phabricator.services.mozilla.com/D181109
2023-06-21 07:14:57 +00:00
Emilio Cobos Álvarez e11ddfc877 Bug 1835062 - Make CSSStyleRule a GroupRule. r=smaug,dshin
Lazily create the rule list since most style rules won't have child
rules.

Remaining failures in the cssom tests are tracked in other bugs.

Differential Revision: https://phabricator.services.mozilla.com/D180649
2023-06-14 09:36:22 +00:00
Stanca Serban 44700a590b Backed out changeset 4c6c30b03e25 (bug 1835062) for causing multiple failures in browser_parsable_css.js. CLOSED TREE 2023-06-14 04:55:44 +03:00
Emilio Cobos Álvarez c2abf9de97 Bug 1835062 - Make CSSStyleRule a GroupRule. r=smaug,dshin
Lazily create the rule list since most style rules won't have child
rules.

Remaining failures in the cssom tests are tracked in other bugs.

Differential Revision: https://phabricator.services.mozilla.com/D180649
2023-06-14 00:18:40 +00:00
Emilio Cobos Álvarez 8435cae09a Bug 1836755 - Improve behavior of :host in InspectorUtils.selectorMatchesElement. r=jdescottes,layout-reviewers,dshin
For non-adopted sheets, use the owner tree. Those are always good to go.

For constructed stylesheets, try to find the most likely candidate. It's
not perfect but it's likely to always be correct in practice.

We could ask for the specific host instead, though that can get rather
annoying in practice.

Differential Revision: https://phabricator.services.mozilla.com/D180347
2023-06-13 22:43:09 +00:00
Emilio Cobos Álvarez 2239425e0a Bug 1837638 - Merge CSSStyleRule and BindingStyleRule. r=dholbert
It was an extra layer of abstraction that we needed when stylo and the
old style system co-existed, but we no longer need it, and can just
merge them.

This will make upcoming CSS nesting changes to the object model easier.

Differential Revision: https://phabricator.services.mozilla.com/D180439
2023-06-09 17:16:34 +00:00
Emilio Cobos Álvarez 057cadb272 Bug 1832173 - Finish removing HasArcFFI. r=boris
Use the actual Locked<T> types around (via a typedef, just for
convenience).

Differential Revision: https://phabricator.services.mozilla.com/D177824
2023-05-12 22:31:38 +00:00
Butkovits Atila 1f06787277 Backed out changeset f6e3d050b3e7 (bug 1832173) for causing bustages at CanvasRenderingContext2D.cpp. CLOSED TREE 2023-05-13 01:16:03 +03:00
Emilio Cobos Álvarez 5c9b936c47 Bug 1832173 - Finish removing HasArcFFI. r=boris
Use the actual Locked<T> types around (via a typedef, just for
convenience).

Differential Revision: https://phabricator.services.mozilla.com/D177824
2023-05-12 21:37:19 +00:00
Emilio Cobos Álvarez 8f5d7d53d5 Bug 1832173 - Remove HasArcFFI for some types. r=boris
See blocked bug.

For non-Locked types we can just use the same underlying type at the FFI
boundary. Port StylesheetContents and CssUrlData to this set-up.
CssUrlData is already generated by cbindgen anyways.

Differential Revision: https://phabricator.services.mozilla.com/D177559
2023-05-11 00:36:24 +00:00
Emilio Cobos Álvarez eca75548b1 Bug 1729330 - Add a simple CSSLayerRule implementation. r=smaug
The specifics of how this is going to work are still getting spec'd /
discussed in https://github.com/w3c/csswg-drafts/issues/6576, but this
allows DevTools to work fine and the feature to be complete enough for
Nightly experimentation (with the other in-flight patches).

Otherwise devtools crashes when trying to inspect pages that use them.

Differential Revision: https://phabricator.services.mozilla.com/D124656
2021-09-08 11:18:32 +00:00