Add :defined support
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2016 21:11:33 +0000 (21:11 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Mar 2016 21:11:33 +0000 (21:11 +0000)
commitecad4648d09b759f950fc7bd76d140a854d9cda1
treec35f309ab5fe472f10078194385e4a23e8a0c713
parentcf713b193ab4cebca6368ad556796cc5333ae257
Add :defined support
https://bugs.webkit.org/show_bug.cgi?id=155108

Reviewed by Antti Koivisto.

Source/WebCore:

Added :defined pseudo class which applies to a successfully instantiated custom element or a builtin element.
A new node flag, isUnresolvedCustomElement, which was added in r197917 tracks un-upgraded / unresolved custom
elements for which :defined should not apply.

Tests: fast/custom-elements/defined-pseudo-class.html
       fast/custom-elements/defined-rule.html

* bindings/js/JSCustomElementInterface.cpp:
(WebCore::JSCustomElementInterface::constructElement): Unset isUnresolvedCustomElement now that HTMLElement's
constructor sets isUnresolvedCustomElement.
* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::constructJSHTMLElement): Set isUnresolvedCustomElement to true since :defined should never apply to
a custom element inside its constructor as HTMLElement constructor does not set the defined flag:
https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText): Added the support for serializing :defined.
* css/CSSSelector.h:
(PseudoClassType): Added PseudoClassDefined for :defined.
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne): Added the support for :defined.
* css/SelectorCheckerTestFunctions.h:
(WebCore::isDefinedElement): Added. Returns true for any builtin element and a custom element after a successful
construction / upgrades.
* css/SelectorPseudoClassAndCompatibilityElementMap.in: Added :defined.
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType): Added the support for :defined.

LayoutTests:

Added W3C style testharness.js tests and ref tests for :defined pseudo class.

* fast/custom-elements/defined-pseudo-class-expected.txt: Added.
* fast/custom-elements/defined-pseudo-class.html: Added.
* fast/custom-elements/defined-rule-expected.html: Added.
* fast/custom-elements/defined-rule.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@197952 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/custom-elements/defined-pseudo-class-expected.txt [new file with mode: 0644]
LayoutTests/fast/custom-elements/defined-pseudo-class.html [new file with mode: 0644]
LayoutTests/fast/custom-elements/defined-rule-expected.html [new file with mode: 0644]
LayoutTests/fast/custom-elements/defined-rule.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCustomElementInterface.cpp
Source/WebCore/bindings/js/JSHTMLElementCustom.cpp
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/cssjit/SelectorCompiler.cpp