Skip to content

Commit

Permalink
Stop stripping prefixes from PseudoClass & PseudoElement
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=266946
rdar://120323601

Reviewed by Darin Adler.

Since prefixes are no longer the main practice to graduate experimental features and they are only used for compatibility reasons or for internal usage,
there is no longer a reason to strip the prefixes from enum classes.

It provides more clarity to what is exposed to the web, and it reduces confusion.

This also fixes the bug where the WebInspector shows unprefixed pseudo elements for scrollbar/resizer pseudo elements which don't actually have unprefixed counterparts.

* LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt:
* Source/JavaScriptCore/inspector/scripts/codegen/generator.py:
(ucfirst):
* Source/JavaScriptCore/inspector/protocol/CSS.json:
* Source/WebCore/animation/WebAnimationUtilities.cpp:
(WebCore::compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder):
(WebCore::pseudoIdAsString):
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::CSSSelector::pseudoId):
(WebCore::CSSSelector::selectorText const):
* Source/WebCore/css/CSSSelector.h:
(WebCore::isLogicalCombinationPseudoClass):
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::hasScrollbarPseudoElement):
(WebCore::SelectorChecker::checkOne const):
* Source/WebCore/css/SelectorChecker.h:
(WebCore::SelectorChecker::isCommonPseudoClassSelector):
* Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in:
* Source/WebCore/css/makeSelectorPseudoClassAndCompatibilityElementMap.py:
(enumerablePseudoType):
* Source/WebCore/css/makeSelectorPseudoElementsMap.py:
(enumerablePseudoType):
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::isPseudoClassValidAfterPseudoElement):
(WebCore::isOnlyPseudoClassFunction):
(WebCore::CSSSelectorParser::consumePseudo):
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
(WebCore::SelectorCompiler::constructFragmentsInternal):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::setBeingDragged):
(WebCore::Element::setIsLink):
* Source/WebCore/dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::setAnimatingFullscreen):
(WebCore::FullscreenManager::setFullscreenControlsHidden):
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setAutoFilledAndViewable):
(WebCore::HTMLInputElement::setAutoFilledAndObscured):
* Source/WebCore/inspector/agents/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::protocolValueForPseudoId):
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::styleHidesScrollbarWithOrientation const):
(WebCore::LocalFrameView::updateScrollCorner):
* Source/WebCore/rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::updateScrollCornerStyle):
(WebCore::RenderLayerScrollableArea::updateResizerStyle):
* Source/WebCore/rendering/RenderScrollbar.cpp:
(WebCore::pseudoForScrollbarPart):
* Source/WebCore/rendering/style/RenderStyleConstants.cpp:
(WebCore::operator<<):
* Source/WebCore/rendering/style/RenderStyleConstants.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::RenderStyle::usesLegacyScrollbarStyle const):
* Source/WebCore/style/RuleSet.cpp:
(WebCore::Style::RuleSet::addRule):
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveElement):
(WebCore::Style::TreeResolver::resolvePseudoElement):
* Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.displayNameForPseudoId):

Canonical link: https://commits.webkit.org/272544@main
  • Loading branch information
nt1m committed Dec 31, 2023
1 parent 080d12d commit 55c55cb
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 245 deletions.
14 changes: 7 additions & 7 deletions LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ Pseudo:
]
},
{
"pseudoId": "scrollbar",
"pseudoId": "-webkit-scrollbar",
"matches": [
{
"rule": {
Expand Down Expand Up @@ -580,7 +580,7 @@ Pseudo:
]
},
{
"pseudoId": "scrollbar-thumb",
"pseudoId": "-webkit-scrollbar-thumb",
"matches": [
{
"rule": {
Expand Down Expand Up @@ -629,7 +629,7 @@ Pseudo:
]
},
{
"pseudoId": "scrollbar-button",
"pseudoId": "-webkit-scrollbar-button",
"matches": [
{
"rule": {
Expand Down Expand Up @@ -678,7 +678,7 @@ Pseudo:
]
},
{
"pseudoId": "scrollbar-track",
"pseudoId": "-webkit-scrollbar-track",
"matches": [
{
"rule": {
Expand Down Expand Up @@ -727,7 +727,7 @@ Pseudo:
]
},
{
"pseudoId": "scrollbar-track-piece",
"pseudoId": "-webkit-scrollbar-track-piece",
"matches": [
{
"rule": {
Expand Down Expand Up @@ -776,7 +776,7 @@ Pseudo:
]
},
{
"pseudoId": "scrollbar-corner",
"pseudoId": "-webkit-scrollbar-corner",
"matches": [
{
"rule": {
Expand Down Expand Up @@ -825,7 +825,7 @@ Pseudo:
]
},
{
"pseudoId": "resizer",
"pseudoId": "-webkit-resizer",
"matches": [
{
"rule": {
Expand Down
16 changes: 8 additions & 8 deletions Source/JavaScriptCore/inspector/protocol/CSS.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@
"after",
"selection",
"backdrop",
"scrollbar",
"scrollbar-thumb",
"scrollbar-button",
"scrollbar-track",
"scrollbar-track-piece",
"scrollbar-corner",
"spelling-error",
"resizer",
"view-transition",
"view-transition-group",
"view-transition-image-pair",
"view-transition-old",
"view-transition-new"
"view-transition-new",
"-webkit-scrollbar",
"-webkit-resizer",
"-webkit-scrollbar-thumb",
"-webkit-scrollbar-button",
"-webkit-scrollbar-track",
"-webkit-scrollbar-track-piece",
"-webkit-scrollbar-corner"
],
"description": "Pseudo-style identifier (see <code>enum PseudoId</code> in <code>RenderStyleConstants.h</code>)."
},
Expand Down
7 changes: 3 additions & 4 deletions Source/JavaScriptCore/inspector/scripts/codegen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@


def ucfirst(str):
if str == 'webkit':
return 'WebKit'
return str[:1].upper() + str[1:]


Expand Down Expand Up @@ -67,10 +69,7 @@ def ucfirst(str):
# Console.ChannelSource
'mediasource': 'MediaSource',
'webrtc': 'WebRTC',
'itp-debug': 'ITPDebug',

# CPUProfiler.ThreadInfo.type
'webkit': 'WebKit',
'itp-debug': 'ITPDebug'
}

# These objects are built manually by creating and setting JSON::Value instances.
Expand Down
12 changes: 6 additions & 6 deletions Source/WebCore/animation/WebAnimationUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static bool compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder
// - any other pseudo-elements not mentioned specifically in this list, sorted in ascending order by the Unicode codepoints that make up each selector
// - ::after
// - element children
enum SortingIndex : uint8_t { NotPseudo, Marker, Before, FirstLetter, FirstLine, GrammarError, Highlight, Scrollbar, Selection, SpellingError, After, Other };
enum SortingIndex : uint8_t { NotPseudo, Marker, Before, FirstLetter, FirstLine, GrammarError, Highlight, WebKitScrollbar, Selection, SpellingError, After, Other };
auto sortingIndex = [](PseudoId pseudoId) -> SortingIndex {
switch (pseudoId) {
case PseudoId::None:
Expand All @@ -78,8 +78,8 @@ static bool compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder
return GrammarError;
case PseudoId::Highlight:
return Highlight;
case PseudoId::Scrollbar:
return Scrollbar;
case PseudoId::WebKitScrollbar:
return WebKitScrollbar;
case PseudoId::Selection:
return Selection;
case PseudoId::SpellingError:
Expand Down Expand Up @@ -295,13 +295,13 @@ String pseudoIdAsString(PseudoId pseudoId)
static NeverDestroyed<const String> highlight(MAKE_STATIC_STRING_IMPL("::highlight"));
static NeverDestroyed<const String> marker(MAKE_STATIC_STRING_IMPL("::marker"));
static NeverDestroyed<const String> selection(MAKE_STATIC_STRING_IMPL("::selection"));
static NeverDestroyed<const String> scrollbar(MAKE_STATIC_STRING_IMPL("::-webkit-scrollbar"));
static NeverDestroyed<const String> spellingError(MAKE_STATIC_STRING_IMPL("::spelling-error"));
static NeverDestroyed<const String> viewTransition(MAKE_STATIC_STRING_IMPL("::view-transition"));
static NeverDestroyed<const String> viewTransitionGroup(MAKE_STATIC_STRING_IMPL("::view-transition-group"));
static NeverDestroyed<const String> viewTransitionImagePair(MAKE_STATIC_STRING_IMPL("::view-transition-image-pair"));
static NeverDestroyed<const String> viewTransitionOld(MAKE_STATIC_STRING_IMPL("::view-transition-old"));
static NeverDestroyed<const String> viewTransitionNew(MAKE_STATIC_STRING_IMPL("::view-transition-new"));
static NeverDestroyed<const String> webkitScrollbar(MAKE_STATIC_STRING_IMPL("::-webkit-scrollbar"));
switch (pseudoId) {
case PseudoId::After:
return after;
Expand All @@ -319,8 +319,6 @@ String pseudoIdAsString(PseudoId pseudoId)
return marker;
case PseudoId::Selection:
return selection;
case PseudoId::Scrollbar:
return scrollbar;
case PseudoId::SpellingError:
return spellingError;
case PseudoId::ViewTransition:
Expand All @@ -333,6 +331,8 @@ String pseudoIdAsString(PseudoId pseudoId)
return viewTransitionOld;
case PseudoId::ViewTransitionNew:
return viewTransitionNew;
case PseudoId::WebKitScrollbar:
return webkitScrollbar;
default:
return emptyString();
}
Expand Down
54 changes: 27 additions & 27 deletions Source/WebCore/css/CSSSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,20 @@ PseudoId CSSSelector::pseudoId(PseudoElement type)
return PseudoId::Before;
case PseudoElement::After:
return PseudoId::After;
case PseudoElement::Scrollbar:
return PseudoId::Scrollbar;
case PseudoElement::ScrollbarButton:
return PseudoId::ScrollbarButton;
case PseudoElement::ScrollbarCorner:
return PseudoId::ScrollbarCorner;
case PseudoElement::ScrollbarThumb:
return PseudoId::ScrollbarThumb;
case PseudoElement::ScrollbarTrack:
return PseudoId::ScrollbarTrack;
case PseudoElement::ScrollbarTrackPiece:
return PseudoId::ScrollbarTrackPiece;
case PseudoElement::Resizer:
return PseudoId::Resizer;
case PseudoElement::WebKitScrollbar:
return PseudoId::WebKitScrollbar;
case PseudoElement::WebKitScrollbarButton:
return PseudoId::WebKitScrollbarButton;
case PseudoElement::WebKitScrollbarCorner:
return PseudoId::WebKitScrollbarCorner;
case PseudoElement::WebKitScrollbarThumb:
return PseudoId::WebKitScrollbarThumb;
case PseudoElement::WebKitScrollbarTrack:
return PseudoId::WebKitScrollbarTrack;
case PseudoElement::WebKitScrollbarTrackPiece:
return PseudoId::WebKitScrollbarTrackPiece;
case PseudoElement::WebKitResizer:
return PseudoId::WebKitResizer;
case PseudoElement::ViewTransition:
return PseudoId::ViewTransition;
case PseudoElement::ViewTransitionGroup:
Expand Down Expand Up @@ -494,11 +494,11 @@ String CSSSelector::selectorText(StringView separator, StringView rightSide) con
} else if (cs->match() == Match::PseudoClass) {
switch (cs->pseudoClass()) {
#if ENABLE(FULLSCREEN_API)
case CSSSelector::PseudoClass::AnimatingFullScreenTransition:
case CSSSelector::PseudoClass::WebKitAnimatingFullScreenTransition:
builder.append(":-webkit-animating-full-screen-transition");
break;
#endif
case CSSSelector::PseudoClass::Any: {
case CSSSelector::PseudoClass::WebKitAny: {
builder.append(":-webkit-any(");
cs->selectorList()->buildSelectorsText(builder);
builder.append(')');
Expand All @@ -507,41 +507,41 @@ String CSSSelector::selectorText(StringView separator, StringView rightSide) con
case CSSSelector::PseudoClass::AnyLink:
builder.append(":any-link");
break;
case CSSSelector::PseudoClass::AnyLinkDeprecated:
case CSSSelector::PseudoClass::WebKitAnyLink:
builder.append(":-webkit-any-link");
break;
case CSSSelector::PseudoClass::Autofill:
builder.append(":autofill");
break;
case CSSSelector::PseudoClass::AutofillAndObscured:
case CSSSelector::PseudoClass::WebKitAutofillAndObscured:
builder.append(":-webkit-autofill-and-obscured");
break;
case CSSSelector::PseudoClass::AutofillStrongPassword:
case CSSSelector::PseudoClass::WebKitAutofillStrongPassword:
builder.append(":-webkit-autofill-strong-password");
break;
case CSSSelector::PseudoClass::AutofillStrongPasswordViewable:
case CSSSelector::PseudoClass::WebKitAutofillStrongPasswordViewable:
builder.append(":-webkit-autofill-strong-password-viewable");
break;
case CSSSelector::PseudoClass::Drag:
case CSSSelector::PseudoClass::WebKitDrag:
builder.append(":-webkit-drag");
break;
case CSSSelector::PseudoClass::FullPageMedia:
case CSSSelector::PseudoClass::WebKitFullPageMedia:
builder.append(":-webkit-full-page-media");
break;
#if ENABLE(FULLSCREEN_API)
case CSSSelector::PseudoClass::Fullscreen:
builder.append(":fullscreen");
break;
case CSSSelector::PseudoClass::WebkitFullScreen:
case CSSSelector::PseudoClass::WebKitFullScreen:
builder.append(":-webkit-full-screen");
break;
case CSSSelector::PseudoClass::FullScreenAncestor:
case CSSSelector::PseudoClass::WebKitFullScreenAncestor:
builder.append(":-webkit-full-screen-ancestor");
break;
case CSSSelector::PseudoClass::FullScreenDocument:
case CSSSelector::PseudoClass::WebKitFullScreenDocument:
builder.append(":-webkit-full-screen-document");
break;
case CSSSelector::PseudoClass::FullScreenControlsHidden:
case CSSSelector::PseudoClass::WebKitFullScreenControlsHidden:
builder.append(":-webkit-full-screen-controls-hidden");
break;
#endif
Expand Down Expand Up @@ -653,7 +653,7 @@ String CSSSelector::selectorText(StringView separator, StringView rightSide) con
case CSSSelector::PseudoClass::Invalid:
builder.append(":invalid");
break;
case CSSSelector::PseudoClass::HtmlDocument:
case CSSSelector::PseudoClass::InternalHTMLDocument:
builder.append(":-internal-html-document");
break;
case CSSSelector::PseudoClass::Lang:
Expand Down
42 changes: 21 additions & 21 deletions Source/WebCore/css/CSSSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,25 @@ struct PossiblyQuotedIdentifier {
NthLastOfType,
Link,
Visited,
Any,
WebKitAny,
AnyLink,
AnyLinkDeprecated,
WebKitAnyLink,
Autofill,
AutofillAndObscured,
AutofillStrongPassword,
AutofillStrongPasswordViewable,
WebKitAutofillAndObscured,
WebKitAutofillStrongPassword,
WebKitAutofillStrongPasswordViewable,
Hover,
Drag,
WebKitDrag,
Focus,
FocusVisible,
FocusWithin,
Active,
Checked,
Enabled,
FullPageMedia,
WebKitFullPageMedia,
Default,
Disabled,
HtmlDocument, // for internal use only with forms in table case in UA stylesheet
InternalHTMLDocument, // for internal use in html.css
Is,
Matches, // obsolete synonym for PseudoClassIs
Where,
Expand Down Expand Up @@ -167,11 +167,11 @@ struct PossiblyQuotedIdentifier {
NoButton,
#if ENABLE(FULLSCREEN_API)
Fullscreen,
WebkitFullScreen,
FullScreenDocument,
FullScreenAncestor,
AnimatingFullScreenTransition,
FullScreenControlsHidden,
WebKitFullScreen,
WebKitFullScreenDocument,
WebKitFullScreenAncestor,
WebKitAnimatingFullScreenTransition,
WebKitFullScreenControlsHidden,
#endif
#if ENABLE(PICTURE_IN_PICTURE_API)
PictureInPicture,
Expand Down Expand Up @@ -214,13 +214,13 @@ struct PossiblyQuotedIdentifier {
Highlight,
Marker,
Part,
Resizer,
Scrollbar,
ScrollbarButton,
ScrollbarCorner,
ScrollbarThumb,
ScrollbarTrack,
ScrollbarTrackPiece,
WebKitResizer,
WebKitScrollbar,
WebKitScrollbarButton,
WebKitScrollbarCorner,
WebKitScrollbarThumb,
WebKitScrollbarTrack,
WebKitScrollbarTrackPiece,
Selection,
Slotted,
SpellingError,
Expand Down Expand Up @@ -423,7 +423,7 @@ inline bool isLogicalCombinationPseudoClass(CSSSelector::PseudoClass pseudoClass
case CSSSelector::PseudoClass::Is:
case CSSSelector::PseudoClass::Where:
case CSSSelector::PseudoClass::Not:
case CSSSelector::PseudoClass::Any:
case CSSSelector::PseudoClass::WebKitAny:
case CSSSelector::PseudoClass::Matches:
case CSSSelector::PseudoClass::Has:
return true;
Expand Down
Loading

0 comments on commit 55c55cb

Please sign in to comment.