<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[197952] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/197952">197952</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-03-10 13:11:33 -0800 (Thu, 10 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 <a href="http://trac.webkit.org/projects/webkit/changeset/197917">r197917</a> 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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCustomElementInterfacecpp">trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSHTMLElementCustomcpp">trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSSelectorcpp">trunk/Source/WebCore/css/CSSSelector.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSSelectorh">trunk/Source/WebCore/css/CSSSelector.h</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckercpp">trunk/Source/WebCore/css/SelectorChecker.cpp</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckerTestFunctionsh">trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h</a></li>
<li><a href="#trunkSourceWebCorecssSelectorPseudoClassAndCompatibilityElementMapin">trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in</a></li>
<li><a href="#trunkSourceWebCorecssjitSelectorCompilercpp">trunk/Source/WebCore/cssjit/SelectorCompiler.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcustomelementsdefinedpseudoclassexpectedtxt">trunk/LayoutTests/fast/custom-elements/defined-pseudo-class-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsdefinedpseudoclasshtml">trunk/LayoutTests/fast/custom-elements/defined-pseudo-class.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsdefinedruleexpectedhtml">trunk/LayoutTests/fast/custom-elements/defined-rule-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcustomelementsdefinedrulehtml">trunk/LayoutTests/fast/custom-elements/defined-rule.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/LayoutTests/ChangeLog        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-03-10  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add :defined support
+        https://bugs.webkit.org/show_bug.cgi?id=155108
+
+        Reviewed by Antti Koivisto.
+
+        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.
+
</ins><span class="cx"> 2016-03-10  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CSP: Implement support for script and style nonces
</span></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsdefinedpseudoclassexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/defined-pseudo-class-expected.txt (0 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/defined-pseudo-class-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/defined-pseudo-class-expected.txt        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+
+PASS The defined flag of a custom element must be set if a custom element has not been upgraded yet 
+PASS The defined flag of a custom element must be set when a custom element is successfully upgraded 
+PASS The defined flag of a custom element must be set if there is a matching definition 
+PASS The defined flag of a custom element created by HTML parser must be unset if there is no matching definition 
+PASS The defined flag of a custom element created by HTML parser must be set if there is a matching definition 
+PASS The defined flag of a custom element created by HTML parser must be set after checking the returned result is an instance of HTMLElement 
+PASS The defined flag of a custom element must be set after checking the returned result is an instance of HTMLElement when upgrading a custom element 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsdefinedpseudoclasshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/defined-pseudo-class.html (0 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/defined-pseudo-class.html                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/defined-pseudo-class.html        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Custom Elements: The ':defined' pseudo-class applies to elements that are defined.&lt;/title&gt;
+&lt;link rel=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;/&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/custom/#the-defined-element-pseudo-class-defined&quot;&gt;
+&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+var upgradeCandidate = document.createElement('my-element');
+
+test(function () {
+    assert_false(upgradeCandidate.matches(':defined'));
+}, 'The defined flag of a custom element must be set if a custom element has not been upgraded yet');
+
+var matchInsideConstructor;
+class MyElement extends HTMLElement {
+    constructor() {
+        super();
+        matchInsideConstructor = this.matches(':defined');
+    }
+}
+document.defineElement('my-element', MyElement);
+
+test(function () {
+    assert_true(upgradeCandidate.matches(':defined'));
+    assert_false(matchInsideConstructor, 'Upgrading a custom element must set defined flag after invoking the constructor');
+}, 'The defined flag of a custom element must be set when a custom element is successfully upgraded');
+
+test(function () {
+    var definedElement = document.createElement('my-element');
+    assert_true(definedElement.matches(':defined'));
+    assert_false(matchInsideConstructor, 'Creating a custom element must set defined flag after invoking the constructor');
+}, 'The defined flag of a custom element must be set if there is a matching definition');
+
+document.write('&lt;my-other-element&gt;&lt;/my-other-element&gt;');
+
+test(function () {
+    var parserCreatedUnfefinedElement = document.querySelector('my-other-element');
+    assert_false(parserCreatedUnfefinedElement.matches(':defined'));
+}, 'The defined flag of a custom element created by HTML parser must be unset if there is no matching definition');
+
+document.write('&lt;my-element&gt;&lt;/my-element&gt;');
+
+test(function () {
+    var parserCreatedDefinedElement = document.querySelector('my-element');
+    assert_true(parserCreatedDefinedElement.matches(':defined'));
+}, 'The defined flag of a custom element created by HTML parser must be set if there is a matching definition');
+
+class ReturnsAnotherNode extends HTMLElement {
+    constructor() {
+        super();
+        matchInsideConstructor = this.matches(':defined');
+        return document.createTextNode('');
+    }
+}
+document.defineElement('returns-another-node', ReturnsAnotherNode);
+
+document.write('&lt;returns-another-node&gt;&lt;/returns-another-node&gt;');
+
+test(function () {
+    assert_true(document.querySelector('returns-another-node').matches(':defined'));
+    assert_false(matchInsideConstructor,
+        'HTML parser must create a custom element with the defined flag initially unset');
+}, 'The defined flag of a custom element created by HTML parser must be set after checking the returned result is an instance of HTMLElement');
+
+test(function () {
+    var instance = document.createElement('returns-another-node-2');
+    try {
+        document.defineElement('returns-another-node-2', class extends ReturnsAnotherNode {});
+    } catch (e) { }
+    assert_false(instance.matches(':defined'));
+    assert_false(matchInsideConstructor,
+        'Creating a custom element must leave the defined flag unset when synchronous custom elements flag is not set');
+}, 'The defined flag of a custom element must be set after checking the returned result is an instance of HTMLElement when upgrading a custom element');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsdefinedruleexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/defined-rule-expected.html (0 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/defined-rule-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/defined-rule-expected.html        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+    &lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt;
+    &lt;div style=&quot;width: 100px; height: 100px; background: green;&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcustomelementsdefinedrulehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/custom-elements/defined-rule.html (0 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/custom-elements/defined-rule.html                                (rev 0)
+++ trunk/LayoutTests/fast/custom-elements/defined-rule.html        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Custom Elements: The ':defined' pseudo-class applies to elements that are defined.&lt;/title&gt;
+    &lt;link rel=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;/&gt;
+    &lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/custom/#the-defined-element-pseudo-class-defined&quot;&gt;
+    &lt;link rel=&quot;match&quot; href=&quot;reference/green-box.html&quot;/&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;style&gt;
+        .box {
+            display: block;
+            width: 100px;
+            height: 25px;
+        }
+        my-defined-element { background: red; color: green; }
+        my-defined-element:defined { background: green; }
+        my-defined-element:not(:defined) { color: red; }
+
+        my-undefined-element { background: green; color: red; }
+        my-undefined-element:defined { background: red; }
+        my-undefined-element:not(:defined) { color: green; }
+
+        div.box { background: green; color: red; height: 50px; }
+        div:defined { color: green; }
+        div:not(:defined) { background: red; }
+    &lt;/style&gt;
+    &lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt;
+    &lt;my-defined-element class=&quot;box&quot;&gt;FAIL&lt;/my-defined-element&gt;
+    &lt;my-undefined-element class=&quot;box&quot;&gt;FAIL&lt;/my-undefined-element&gt;
+    &lt;div class=&quot;box&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+
+        document.defineElement('my-defined-element', class extends HTMLElement {});
+
+    &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/ChangeLog        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2016-03-10  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add :defined support
+        https://bugs.webkit.org/show_bug.cgi?id=155108
+
+        Reviewed by Antti Koivisto.
+
+        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.
+
</ins><span class="cx"> 2016-03-10  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r197943.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCustomElementInterfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx">     Element* wrappedElement = JSElement::toWrapped(newElement);
</span><span class="cx">     if (!wrappedElement)
</span><span class="cx">         return nullptr;
</span><del>-    wrappedElement-&gt;setIsCustomElement();
</del><ins>+    wrappedElement-&gt;setCustomElementIsResolved();
</ins><span class="cx">     return wrappedElement;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSHTMLElementCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">             return JSValue::encode(jsUndefined());
</span><span class="cx"> 
</span><span class="cx">         Ref&lt;HTMLElement&gt; element = HTMLElement::create(interface-&gt;name(), document);
</span><ins>+        element-&gt;setIsUnresolvedCustomElement();
</ins><span class="cx">         auto* jsElement = JSHTMLElement::create(newElementStructure, globalObject, element.get());
</span><span class="cx">         cacheWrapper(globalObject-&gt;world(), element.ptr(), jsElement);
</span><span class="cx">         return JSValue::encode(jsElement);
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.cpp (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.cpp        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/css/CSSSelector.cpp        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -643,6 +643,11 @@
</span><span class="cx">                 str.appendLiteral(&quot;:host&quot;);
</span><span class="cx">                 break;
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+            case CSSSelector::PseudoClassDefined:
+                str.appendLiteral(&quot;:defined&quot;);
+                break;
+#endif
</ins><span class="cx">             case CSSSelector::PseudoClassUnknown:
</span><span class="cx">                 ASSERT_NOT_REACHED();
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.h (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.h        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/css/CSSSelector.h        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -162,6 +162,9 @@
</span><span class="cx"> #if ENABLE(SHADOW_DOM)
</span><span class="cx">             PseudoClassHost,
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+            PseudoClassDefined,
+#endif
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         enum PseudoElementType {
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.cpp        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -991,6 +991,10 @@
</span><span class="cx">             // :host matches based on context. Cases that reach selector checker don't match.
</span><span class="cx">             return false;
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+        case CSSSelector::PseudoClassDefined:
+            return isDefinedElement(element);
+#endif
</ins><span class="cx">         case CSSSelector::PseudoClassWindowInactive:
</span><span class="cx">             return isWindowInactive(element);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckerTestFunctionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -63,6 +63,13 @@
</span><span class="cx">         &amp;&amp; !element.isDisabledFormControl();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+ALWAYS_INLINE bool isDefinedElement(const Element&amp; element)
+{
+    return !element.isUnresolvedCustomElement();
+}
+#endif
+
</ins><span class="cx"> ALWAYS_INLINE bool isMediaDocument(const Element&amp; element)
</span><span class="cx"> {
</span><span class="cx">     return element.document().isMediaDocument();
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorPseudoClassAndCompatibilityElementMapin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -78,3 +78,7 @@
</span><span class="cx"> #if ENABLE(SHADOW_DOM)
</span><span class="cx"> host
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(CUSTOM_ELEMENTS)
+defined
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCorecssjitSelectorCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (197951 => 197952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2016-03-10 20:52:19 UTC (rev 197951)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2016-03-10 21:11:33 UTC (rev 197952)
</span><span class="lines">@@ -542,6 +542,11 @@
</span><span class="cx">     case CSSSelector::PseudoClassEnabled:
</span><span class="cx">         fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr(isEnabled));
</span><span class="cx">         return FunctionType::SimpleSelectorChecker;
</span><ins>+#if ENABLE(CUSTOM_ELEMENTS)
+    case CSSSelector::PseudoClassDefined:
+        fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr(isDefinedElement));
+        return FunctionType::SimpleSelectorChecker;
+#endif
</ins><span class="cx">     case CSSSelector::PseudoClassFocus:
</span><span class="cx">         fragment.unoptimizedPseudoClasses.append(JSC::FunctionPtr(SelectorChecker::matchesFocusPseudoClass));
</span><span class="cx">         return FunctionType::SimpleSelectorChecker;
</span></span></pre>
</div>
</div>

</body>
</html>