Add a pseudoclass that matches img elements that are backed by an attachment
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2018 19:33:54 +0000 (19:33 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2018 19:33:54 +0000 (19:33 +0000)
commite35079a87fecd6eeaf828b39e14b08d978551458
treec39f1dbb2790842af86f962ef1398feb048a9402
parent50cd692b5bce7116a9d8ca21a46fc4b04fd5d4c3
Add a pseudoclass that matches img elements that are backed by an attachment
https://bugs.webkit.org/show_bug.cgi?id=191286
<rdar://problem/45823554>

Reviewed by Dean Jackson.

Source/WebCore:

Test: fast/css/has-attachment.html

Added a :has-attachment pseudoclass, enabled only when the attachment element is enabled at
runtime, that matches elements (currently only img elements qualify) that have an attachment
element in their shadow DOM.

* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const): Handle the new PseudoClassHasAttachment value.
* css/CSSSelector.h: Added a new value to the PseudoClassType enum.

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const): Check the new PseudoClassHasAttachment value
  using the new hasAttachment test function.

* css/SelectorCheckerTestFunctions.h:
(WebCore::hasAttachment): Added. Tests if the element is an img element that has an
  attachment.

* css/SelectorPseudoClassAndCompatibilityElementMap.in: Added has-attachment.

* css/parser/CSSParserContext.cpp:
(WebCore::CSSParserContext::CSSParserContext): Initialize new attachmentEnabled member based
  on RuntimeEnabledFeatures.
(WebCore::operator==): Compare new attachmentEnabled member.
* css/parser/CSSParserContext.h:
(WebCore::CSSParserContextHash::hash): Include new attachmentEnabled member.

* css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::consumePseudo): Reject :has-attachment if the attachment
  element is not enabled.

* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType): Handle PseudoClassHasAttachment.

LayoutTests:

* fast/css/has-attachment-expected.txt: Added.
* fast/css/has-attachment.html: Added.
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/has-attachment-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/has-attachment.html [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/CSSSelector.cpp
Source/WebCore/css/CSSSelector.h
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/css/SelectorCheckerTestFunctions.h
Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in
Source/WebCore/css/parser/CSSParserContext.cpp
Source/WebCore/css/parser/CSSParserContext.h
Source/WebCore/css/parser/CSSSelectorParser.cpp
Source/WebCore/cssjit/SelectorCompiler.cpp