Changeset 197952 in webkit


Ignore:
Timestamp:
Mar 10, 2016 1:11:33 PM (8 years ago)
Author:
rniwa@webkit.org
Message:

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.
Location:
trunk
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r197944 r197952  
     12016-03-10  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Add :defined support
     4        https://bugs.webkit.org/show_bug.cgi?id=155108
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added W3C style testharness.js tests and ref tests for :defined pseudo class.
     9
     10        * fast/custom-elements/defined-pseudo-class-expected.txt: Added.
     11        * fast/custom-elements/defined-pseudo-class.html: Added.
     12        * fast/custom-elements/defined-rule-expected.html: Added.
     13        * fast/custom-elements/defined-rule.html: Added.
     14
    1152016-03-10  Daniel Bates  <dabates@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r197950 r197952  
     12016-03-10  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Add :defined support
     4        https://bugs.webkit.org/show_bug.cgi?id=155108
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added :defined pseudo class which applies to a successfully instantiated custom element or a builtin element.
     9        A new node flag, isUnresolvedCustomElement, which was added in r197917 tracks un-upgraded / unresolved custom
     10        elements for which :defined should not apply.
     11
     12        Tests: fast/custom-elements/defined-pseudo-class.html
     13               fast/custom-elements/defined-rule.html
     14
     15        * bindings/js/JSCustomElementInterface.cpp:
     16        (WebCore::JSCustomElementInterface::constructElement): Unset isUnresolvedCustomElement now that HTMLElement's
     17        constructor sets isUnresolvedCustomElement.
     18        * bindings/js/JSHTMLElementCustom.cpp:
     19        (WebCore::constructJSHTMLElement): Set isUnresolvedCustomElement to true since :defined should never apply to
     20        a custom element inside its constructor as HTMLElement constructor does not set the defined flag:
     21        https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor
     22        * css/CSSSelector.cpp:
     23        (WebCore::CSSSelector::selectorText): Added the support for serializing :defined.
     24        * css/CSSSelector.h:
     25        (PseudoClassType): Added PseudoClassDefined for :defined.
     26        * css/SelectorChecker.cpp:
     27        (WebCore::SelectorChecker::checkOne): Added the support for :defined.
     28        * css/SelectorCheckerTestFunctions.h:
     29        (WebCore::isDefinedElement): Added. Returns true for any builtin element and a custom element after a successful
     30        construction / upgrades.
     31        * css/SelectorPseudoClassAndCompatibilityElementMap.in: Added :defined.
     32        * cssjit/SelectorCompiler.cpp:
     33        (WebCore::SelectorCompiler::addPseudoClassType): Added the support for :defined.
     34
    1352016-03-10  Commit Queue  <commit-queue@webkit.org>
    236
  • trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp

    r197917 r197952  
    9999    if (!wrappedElement)
    100100        return nullptr;
    101     wrappedElement->setIsCustomElement();
     101    wrappedElement->setCustomElementIsResolved();
    102102    return wrappedElement;
    103103}
  • trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp

    r197634 r197952  
    6767
    6868        Ref<HTMLElement> element = HTMLElement::create(interface->name(), document);
     69        element->setIsUnresolvedCustomElement();
    6970        auto* jsElement = JSHTMLElement::create(newElementStructure, globalObject, element.get());
    7071        cacheWrapper(globalObject->world(), element.ptr(), jsElement);
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r197165 r197952  
    644644                break;
    645645#endif
     646#if ENABLE(CUSTOM_ELEMENTS)
     647            case CSSSelector::PseudoClassDefined:
     648                str.appendLiteral(":defined");
     649                break;
     650#endif
    646651            case CSSSelector::PseudoClassUnknown:
    647652                ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/css/CSSSelector.h

    r197165 r197952  
    163163            PseudoClassHost,
    164164#endif
     165#if ENABLE(CUSTOM_ELEMENTS)
     166            PseudoClassDefined,
     167#endif
    165168        };
    166169
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r197779 r197952  
    991991            // :host matches based on context. Cases that reach selector checker don't match.
    992992            return false;
     993#endif
     994#if ENABLE(CUSTOM_ELEMENTS)
     995        case CSSSelector::PseudoClassDefined:
     996            return isDefinedElement(element);
    993997#endif
    994998        case CSSSelector::PseudoClassWindowInactive:
  • trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h

    r195311 r197952  
    6464}
    6565
     66#if ENABLE(CUSTOM_ELEMENTS)
     67ALWAYS_INLINE bool isDefinedElement(const Element& element)
     68{
     69    return !element.isUnresolvedCustomElement();
     70}
     71#endif
     72
    6673ALWAYS_INLINE bool isMediaDocument(const Element& element)
    6774{
  • trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in

    r190680 r197952  
    7979host
    8080#endif
     81
     82#if ENABLE(CUSTOM_ELEMENTS)
     83defined
     84#endif
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r197779 r197952  
    543543        fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr(isEnabled));
    544544        return FunctionType::SimpleSelectorChecker;
     545#if ENABLE(CUSTOM_ELEMENTS)
     546    case CSSSelector::PseudoClassDefined:
     547        fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr(isDefinedElement));
     548        return FunctionType::SimpleSelectorChecker;
     549#endif
    545550    case CSSSelector::PseudoClassFocus:
    546551        fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr(SelectorChecker::matchesFocusPseudoClass));
Note: See TracChangeset for help on using the changeset viewer.