Skip to content

Commit

Permalink
[popover] @supports selector(:popover-open) does not reflect disabled…
Browse files Browse the repository at this point in the history
… preference

https://bugs.webkit.org/show_bug.cgi?id=263405
rdar://117226626

Reviewed by Simon Fraser.

* LayoutTests/fast/selectors/popover-open-disabled-expected.html: Added.
* LayoutTests/fast/selectors/popover-open-disabled.html: Added.
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::CSSParserContext::CSSParserContext):
(WebCore::add):
* Source/WebCore/css/parser/CSSParserContext.h:
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParserContext::CSSSelectorParserContext):
(WebCore::CSSSelectorParser::consumePseudo):
* Source/WebCore/css/parser/CSSSelectorParser.h:

Canonical link: https://commits.webkit.org/269565@main
  • Loading branch information
nt1m committed Oct 20, 2023
1 parent afe912c commit d544e51
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
16 changes: 16 additions & 0 deletions LayoutTests/fast/selectors/popover-open-disabled-expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background-color: green;
}
</style>
</head>
<body>
<p>Test passes if you see a green square</p>
<div></div>
</body>
</html>
21 changes: 21 additions & 0 deletions LayoutTests/fast/selectors/popover-open-disabled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- webkit-test-runner [ PopoverAttributeEnabled=false ] -->
<!DOCTYPE html>
<html>
<head>
<title>Test that :popover-open selector is not supported when popover attribute is disabled</title>
<style>
div {
width: 100px;
height: 100px;
background-color: red;
@supports not selector(:popover-open) {
background-color: green;
}
}
</style>
</head>
<body>
<p>Test passes if you see a green square</p>
<div></div>
</body>
</html>
7 changes: 5 additions & 2 deletions Source/WebCore/css/parser/CSSParserContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ CSSParserContext::CSSParserContext(CSSParserMode mode, const URL& baseURL)
if (mode == UASheetMode) {
colorMixEnabled = true;
focusVisibleEnabled = true;
popoverAttributeEnabled = true;
propertySettings.cssContainmentEnabled = true;
propertySettings.cssIndividualTransformPropertiesEnabled = true;
propertySettings.cssInputSecurityEnabled = true;
Expand Down Expand Up @@ -104,6 +105,7 @@ CSSParserContext::CSSParserContext(const Document& document, const URL& sheetBas
, cssTextUnderlinePositionLeftRightEnabled { document.settings().cssTextUnderlinePositionLeftRightEnabled() }
, cssTextWrapNewValuesEnabled { document.settings().cssTextWrapNewValuesEnabled() }
, cssWordBreakAutoEnabled { document.settings().cssWordBreakAutoEnabled() }
, popoverAttributeEnabled { document.settings().popoverAttributeEnabled() }
, sidewaysWritingModesEnabled { document.settings().sidewaysWritingModesEnabled() }
, propertySettings { CSSPropertySettings { document.settings() } }
{
Expand Down Expand Up @@ -138,8 +140,9 @@ void add(Hasher& hasher, const CSSParserContext& context)
| context.cssTextUnderlinePositionLeftRightEnabled << 22
| context.cssTextWrapNewValuesEnabled << 23
| context.cssWordBreakAutoEnabled << 24
| context.sidewaysWritingModesEnabled << 25
| (uint64_t)context.mode << 26; // This is multiple bits, so keep it last.
| context.popoverAttributeEnabled << 25
| context.sidewaysWritingModesEnabled << 26
| (uint64_t)context.mode << 27; // This is multiple bits, so keep it last.
add(hasher, context.baseURL, context.charset, context.propertySettings, bits);
}

Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/css/parser/CSSParserContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct CSSParserContext {
bool cssTextUnderlinePositionLeftRightEnabled { false };
bool cssTextWrapNewValuesEnabled { false };
bool cssWordBreakAutoEnabled { false };
bool popoverAttributeEnabled { false };
bool sidewaysWritingModesEnabled { false };

// Settings, those affecting properties.
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/css/parser/CSSSelectorParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CSSSelectorParserContext::CSSSelectorParserContext(const CSSParserContext& conte
, cssNestingEnabled(context.cssNestingEnabled)
, focusVisibleEnabled(context.focusVisibleEnabled)
, hasPseudoClassEnabled(context.hasPseudoClassEnabled)
, popoverAttributeEnabled(context.popoverAttributeEnabled)
{
}

Expand All @@ -60,6 +61,7 @@ CSSSelectorParserContext::CSSSelectorParserContext(const Document& document)
, cssNestingEnabled(document.settings().cssNestingEnabled())
, focusVisibleEnabled(document.settings().focusVisibleEnabled())
, hasPseudoClassEnabled(document.settings().hasPseudoClassEnabled())
, popoverAttributeEnabled(document.settings().popoverAttributeEnabled())
{
}

Expand Down Expand Up @@ -799,6 +801,8 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::consumePseudo(CSSParserTok
return nullptr;
if (!m_context.hasPseudoClassEnabled && selector->pseudoClassType() == CSSSelector::PseudoClassType::Has)
return nullptr;
if (!m_context.popoverAttributeEnabled && selector->pseudoClassType() == CSSSelector::PseudoClassType::PopoverOpen)
return nullptr;
if (m_context.mode != UASheetMode && selector->pseudoClassType() == CSSSelector::PseudoClassType::HtmlDocument)
return nullptr;
#if ENABLE(ATTACHMENT_ELEMENT)
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/css/parser/CSSSelectorParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct CSSSelectorParserContext {
bool cssNestingEnabled { false };
bool focusVisibleEnabled { false };
bool hasPseudoClassEnabled { false };
bool popoverAttributeEnabled { false };

bool isHashTableDeletedValue { false };

Expand Down

0 comments on commit d544e51

Please sign in to comment.