Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add CustomStateSet and :state() selector#20012

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
keithamus:custom-state-set
Dec 6, 2023
Merged

Add CustomStateSet and :state() selector#20012
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
keithamus:custom-state-set

Conversation

@keithamus
Copy link
Member

@keithamus keithamus commented Nov 5, 2023

59cb7cb

Add CustomStateSet and :state() selector
https://bugs.webkit.org/show_bug.cgi?id=215911

Reviewed by Tim Nguyen.

This adds the CustomStateSet idl definitions, and the `states` getter in
the ElementInternals IDL. The gatter laziliy initialises a
CustomStateSet object in ElementRareData which behaves like a
setlike<DOMString>.

This also adds the `:state()` pseudo selector, which can take an ident
and matches when the ident matches one of the given states in the
CustomStateSet for the element.

Any states set by CustomStateSet need to invalidate styles for the
element, so the `:state()` pseudo can match.

* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/state-in-has-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/state-in-has.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-state-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/ElementInternals-states-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/ElementInternals-states.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/state-pseudo-class-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/state-pseudo-class.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/custom-state-set-strong-ref.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/idlharness.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/state-css-selector-shadow-dom.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/state-css-selector-shadow-dom.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/state-css-selector.tentative-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* Source/WebCore/css/CSSSelector.h:
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const):
* Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in:
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::add):
* Source/WebCore/css/parser/CSSParserContext.h:
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::isOnlyPseudoClassFunction):
(WebCore::CSSSelectorParser::consumePseudo):
* Source/WebCore/css/parser/CSSSelectorParserContext.cpp:
(WebCore::CSSSelectorParserContext::CSSSelectorParserContext):
(WebCore::add):
* Source/WebCore/css/parser/CSSSelectorParserContext.h:
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
* Source/WebCore/dom/CustomStateSet.cpp: Added.
(WebCore::CustomStateSet::addToSetLike):
(WebCore::CustomStateSet::removeFromSetLike):
(WebCore::CustomStateSet::clearFromSetLike):
(WebCore::CustomStateSet::has):
* Source/WebCore/dom/CustomStateSet.h: Added.
* Source/WebCore/dom/CustomStateSet.idl: Added.
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::hasCustomState const):
(WebCore::Element::ensureCustomStateSet):
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/ElementInternals.cpp:
(WebCore::ElementInternals::states):
* Source/WebCore/dom/ElementInternals.h:
* Source/WebCore/dom/ElementInternals.idl:
* Source/WebCore/dom/ElementRareData.cpp:
* Source/WebCore/dom/ElementRareData.h:
(WebCore::ElementRareData::customStateSet):
(WebCore::ElementRareData::setCustomStateSet):
(WebCore::ElementRareData::useTypes const):
* Source/WebCore/dom/NodeRareData.h:

Canonical link: https://commits.webkit.org/271600@main

e495b9d

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2
✅ 🧪 webkitperl 🧪 ios-wk2 🧪 api-mac ✅ 🧪 api-wpe
🧪 ios-wk2-wpt 🧪 mac-wk1 ✅ 🛠 gtk
🛠 🧪 jsc 🧪 api-ios 🧪 mac-wk2 🧪 gtk-wk2
🛠 🧪 jsc-arm64 🛠 tv ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 tv-sim 🧪 mac-wk2-stress ✅ 🛠 jsc-armv7
✅ 🛠 🧪 merge ✅ 🛠 watch ✅ 🧪 jsc-armv7-tests
🛠 watch-sim

Copy link
Member

@nt1m nt1m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add a special case at: https://searchfox.org/wubkat/rev/023c54054092dc68c5df3b230ed3137cbd753b16/Source/WebCore/css/parser/CSSSelectorParser.cpp#743-763

Otherwise, :state with no argument won't be rejected.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Nov 5, 2023
@rniwa
Copy link
Member

rniwa commented Nov 5, 2023

https://bugs.webkit.org/show_bug.cgi?id=215911

There should be the but title right above it.

This adds the CustomStateSet idl definitions, and the states getter in the ElementInternals IDL. The gatter laziliy initialises a CustomStateSet object in ElementRareData which behaves like a setlike.

Please insert a line break after 100 characters or so.

@rniwa
Copy link
Member

rniwa commented Nov 6, 2023

We should add a test for invalidating :host:state(foo).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do a WPT resync of custom-elements/ and custom-state-pseudo-class separately ? I think it'll make it easier for you to export, and it's easier to review generally since it's clear which ones are new tests.

@Ahmad-S792 Ahmad-S792 added DOM For bugs specific to XML/HTML DOM elements (including parsing). and removed merging-blocked Applied to prevent a change from being merged labels Nov 12, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 4, 2023
@nt1m nt1m removed the merging-blocked Applied to prevent a change from being merged label Dec 4, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 5, 2023
@keithamus keithamus removed the merging-blocked Applied to prevent a change from being merged label Dec 5, 2023
@keithamus keithamus requested review from cdumez and nt1m December 5, 2023 10:33
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 5, 2023
@keithamus keithamus added request-merge-queue Request a pull request to be added to merge-queue once ready and removed merging-blocked Applied to prevent a change from being merged labels Dec 6, 2023
@Ahmad-S792 Ahmad-S792 added merge-queue Applied to send a pull request to merge-queue and removed request-merge-queue Request a pull request to be added to merge-queue once ready labels Dec 6, 2023
https://bugs.webkit.org/show_bug.cgi?id=215911

Reviewed by Tim Nguyen.

This adds the CustomStateSet idl definitions, and the `states` getter in
the ElementInternals IDL. The gatter laziliy initialises a
CustomStateSet object in ElementRareData which behaves like a
setlike<DOMString>.

This also adds the `:state()` pseudo selector, which can take an ident
and matches when the ident matches one of the given states in the
CustomStateSet for the element.

Any states set by CustomStateSet need to invalidate styles for the
element, so the `:state()` pseudo can match.

* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/state-in-has-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/state-in-has.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-state-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/ElementInternals-states-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/ElementInternals-states.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/state-pseudo-class-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/state/tentative/state-pseudo-class.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/custom-state-set-strong-ref.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/idlharness.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/state-css-selector-shadow-dom.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/state-css-selector-shadow-dom.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-state-pseudo-class/state-css-selector.tentative-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* Source/WebCore/css/CSSSelector.h:
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const):
* Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in:
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::add):
* Source/WebCore/css/parser/CSSParserContext.h:
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::isOnlyPseudoClassFunction):
(WebCore::CSSSelectorParser::consumePseudo):
* Source/WebCore/css/parser/CSSSelectorParserContext.cpp:
(WebCore::CSSSelectorParserContext::CSSSelectorParserContext):
(WebCore::add):
* Source/WebCore/css/parser/CSSSelectorParserContext.h:
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
* Source/WebCore/dom/CustomStateSet.cpp: Added.
(WebCore::CustomStateSet::addToSetLike):
(WebCore::CustomStateSet::removeFromSetLike):
(WebCore::CustomStateSet::clearFromSetLike):
(WebCore::CustomStateSet::has):
* Source/WebCore/dom/CustomStateSet.h: Added.
* Source/WebCore/dom/CustomStateSet.idl: Added.
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::hasCustomState const):
(WebCore::Element::ensureCustomStateSet):
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/ElementInternals.cpp:
(WebCore::ElementInternals::states):
* Source/WebCore/dom/ElementInternals.h:
* Source/WebCore/dom/ElementInternals.idl:
* Source/WebCore/dom/ElementRareData.cpp:
* Source/WebCore/dom/ElementRareData.h:
(WebCore::ElementRareData::customStateSet):
(WebCore::ElementRareData::setCustomStateSet):
(WebCore::ElementRareData::useTypes const):
* Source/WebCore/dom/NodeRareData.h:

Canonical link: https://commits.webkit.org/271600@main
@webkit-commit-queue
Copy link
Collaborator

Committed 271600@main (59cb7cb): https://commits.webkit.org/271600@main

Reviewed commits have been landed. Closing PR #20012 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Dec 6, 2023
@keithamus keithamus deleted the custom-state-set branch December 6, 2023 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DOM For bugs specific to XML/HTML DOM elements (including parsing).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants