Title: [202358] trunk
Revision
202358
Author
[email protected]
Date
2016-06-22 16:35:25 -0700 (Wed, 22 Jun 2016)

Log Message

AX: Add support for CSS4 :focus-within pseudo
https://bugs.webkit.org/show_bug.cgi?id=140144

Patch by Benjamin Poulain <[email protected]> on 2016-06-22
Reviewed by Antti Koivisto.

Source/WebCore:

Tests: fast/css/pseudo-focus-within-basics.html
       fast/css/pseudo-focus-within-inside-shadow-dom.html
       fast/css/pseudo-focus-within-style-sharing-1.html
       fast/css/pseudo-focus-within-style-sharing-2.html
       fast/selectors/focus-within-style-update.html

* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText):
* css/CSSSelector.h:
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
* css/SelectorPseudoClassAndCompatibilityElementMap.in:
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementHasFocusWithin):
* dom/ContainerNode.cpp:
(WebCore::destroyRenderTreeIfNeeded):
* dom/Element.cpp:
(WebCore::Element::~Element):
(WebCore::Element::setFocus):
(WebCore::Element::unregisterNamedFlowContentElement):
(WebCore::Element::setIsNamedFlowContentElement):
(WebCore::Element::clearIsNamedFlowContentElement):
(WebCore::Element::setStyleAffectedByFocusWithin):
(WebCore::Element::rareDataStyleAffectedByFocusWithin):
(WebCore::Element::rareDataIsNamedFlowContentElement):
* dom/Element.h:
(WebCore::Element::hasFocusWithin):
(WebCore::Element::styleAffectedByFocusWithin):
(WebCore::Element::isNamedFlowContentElement):
(WebCore::Element::setHasFocusWithin):
* dom/ElementRareData.h:
(WebCore::ElementRareData::styleAffectedByFocusWithin):
(WebCore::ElementRareData::setStyleAffectedByFocusWithin):
(WebCore::ElementRareData::isNamedFlowContentElement):
(WebCore::ElementRareData::setIsNamedFlowContentElement):
(WebCore::ElementRareData::ElementRareData):
(WebCore::ElementRareData::resetComputedStyle):
* dom/Node.h:
(WebCore::Node::flagHasFocusWithin):
(WebCore::Node::isNamedFlowContentNode): Deleted.
(WebCore::Node::setIsNamedFlowContentNode): Deleted.
(WebCore::Node::clearIsNamedFlowContentNode): Deleted.
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::clearContentElements):
(WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
(WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):
(WebCore::nextNodeInsideContentElement):
* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateElementRenderer):
* style/StyleRelations.cpp:
(WebCore::Style::commitRelationsToRenderStyle):
(WebCore::Style::commitRelations):
* style/StyleRelations.h:
* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::canShareStyleWithElement):

LayoutTests:

* fast/css/css-selector-text-expected.txt:
* fast/css/css-selector-text.html:
* fast/css/css-set-selector-text-expected.txt:
* fast/css/css-set-selector-text.html:
* fast/css/pseudo-focus-within-basics-expected.html: Added.
* fast/css/pseudo-focus-within-basics.html: Added.
* fast/css/pseudo-focus-within-inside-shadow-dom-expected.html: Added.
* fast/css/pseudo-focus-within-inside-shadow-dom.html: Added.
* fast/css/pseudo-focus-within-style-sharing-1-expected.html: Added.
* fast/css/pseudo-focus-within-style-sharing-1.html: Added.
* fast/css/pseudo-focus-within-style-sharing-2-expected.html: Added.
* fast/css/pseudo-focus-within-style-sharing-2.html: Added.
* fast/selectors/focus-within-style-update-expected.txt: Added.
* fast/selectors/focus-within-style-update.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202357 => 202358)


--- trunk/LayoutTests/ChangeLog	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/LayoutTests/ChangeLog	2016-06-22 23:35:25 UTC (rev 202358)
@@ -1,3 +1,25 @@
+2016-06-22  Benjamin Poulain  <[email protected]>
+
+        AX: Add support for CSS4 :focus-within pseudo
+        https://bugs.webkit.org/show_bug.cgi?id=140144
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css/css-selector-text-expected.txt:
+        * fast/css/css-selector-text.html:
+        * fast/css/css-set-selector-text-expected.txt:
+        * fast/css/css-set-selector-text.html:
+        * fast/css/pseudo-focus-within-basics-expected.html: Added.
+        * fast/css/pseudo-focus-within-basics.html: Added.
+        * fast/css/pseudo-focus-within-inside-shadow-dom-expected.html: Added.
+        * fast/css/pseudo-focus-within-inside-shadow-dom.html: Added.
+        * fast/css/pseudo-focus-within-style-sharing-1-expected.html: Added.
+        * fast/css/pseudo-focus-within-style-sharing-1.html: Added.
+        * fast/css/pseudo-focus-within-style-sharing-2-expected.html: Added.
+        * fast/css/pseudo-focus-within-style-sharing-2.html: Added.
+        * fast/selectors/focus-within-style-update-expected.txt: Added.
+        * fast/selectors/focus-within-style-update.html: Added.
+
 2016-06-17  Dean Jackson  <[email protected]>
 
         REGRESSION: Double tap to zoom does not work on yahoo finance

Modified: trunk/LayoutTests/fast/css/css-selector-text-expected.txt (202357 => 202358)


--- trunk/LayoutTests/fast/css/css-selector-text-expected.txt	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/LayoutTests/fast/css/css-selector-text-expected.txt	2016-06-22 23:35:25 UTC (rev 202358)
@@ -216,6 +216,26 @@
 PASS parseThenSerializeRule('a#b::-webkit-input-placeholder { }') is 'a#b::-webkit-input-placeholder { }'
 PASS parseThenSerializeRule('a[b].c#d::-webkit-input-placeholder { }') is 'a[b].c#d::-webkit-input-placeholder { }'
 
+PASS parseThenSerializeRule('a[b]:default { }') is 'a[b]:default { }'
+PASS parseThenSerializeRule('a.b:default { }') is 'a.b:default { }'
+PASS parseThenSerializeRule('a#b:default { }') is 'a#b:default { }'
+PASS parseThenSerializeRule('a[b].c#d:default { }') is 'a[b].c#d:default { }'
+
+PASS parseThenSerializeRule('a[b]:in-range { }') is 'a[b]:in-range { }'
+PASS parseThenSerializeRule('a.b:in-range { }') is 'a.b:in-range { }'
+PASS parseThenSerializeRule('a#b:in-range { }') is 'a#b:in-range { }'
+PASS parseThenSerializeRule('a[b].c#d:in-range { }') is 'a[b].c#d:in-range { }'
+
+PASS parseThenSerializeRule('a[b]:out-of-range { }') is 'a[b]:out-of-range { }'
+PASS parseThenSerializeRule('a.b:out-of-range { }') is 'a.b:out-of-range { }'
+PASS parseThenSerializeRule('a#b:out-of-range { }') is 'a#b:out-of-range { }'
+PASS parseThenSerializeRule('a[b].c#d:out-of-range { }') is 'a[b].c#d:out-of-range { }'
+
+PASS parseThenSerializeRule('a[b]:focus-within { }') is 'a[b]:focus-within { }'
+PASS parseThenSerializeRule('a.b:focus-within { }') is 'a.b:focus-within { }'
+PASS parseThenSerializeRule('a#b:focus-within { }') is 'a#b:focus-within { }'
+PASS parseThenSerializeRule('a[b].c#d:focus-within { }') is 'a[b].c#d:focus-within { }'
+
 PASS parseThenSerializeRule('input:not([type="file"]):focus { }') is 'input:not([type="file"]):focus { }'
 PASS parseThenSerializeRule(':-webkit-any([type="file"]) { }') is ':-webkit-any([type="file"]) { }'
 PASS parseThenSerializeRule(':-webkit-any(:hover) { }') is ':-webkit-any(:hover) { }'

Modified: trunk/LayoutTests/fast/css/css-selector-text.html (202357 => 202358)


--- trunk/LayoutTests/fast/css/css-selector-text.html	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/LayoutTests/fast/css/css-selector-text.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -307,6 +307,34 @@
 
 debug('');
 
+testSelectorRoundTrip("a[b]:default");
+testSelectorRoundTrip("a.b:default");
+testSelectorRoundTrip("a#b:default");
+testSelectorRoundTrip("a[b].c#d:default");
+
+debug('');
+
+testSelectorRoundTrip("a[b]:in-range");
+testSelectorRoundTrip("a.b:in-range");
+testSelectorRoundTrip("a#b:in-range");
+testSelectorRoundTrip("a[b].c#d:in-range");
+
+debug('');
+
+testSelectorRoundTrip("a[b]:out-of-range");
+testSelectorRoundTrip("a.b:out-of-range");
+testSelectorRoundTrip("a#b:out-of-range");
+testSelectorRoundTrip("a[b].c#d:out-of-range");
+
+debug('');
+
+testSelectorRoundTrip("a[b]:focus-within");
+testSelectorRoundTrip("a.b:focus-within");
+testSelectorRoundTrip("a#b:focus-within");
+testSelectorRoundTrip("a[b].c#d:focus-within");
+
+debug('');
+
 testSelectorRoundTrip('input:not([type="file"]):focus');
 testSelectorRoundTrip(':-webkit-any([type="file"])');
 testSelectorRoundTrip(':-webkit-any(:hover)');

Modified: trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt (202357 => 202358)


--- trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt	2016-06-22 23:35:25 UTC (rev 202358)
@@ -218,6 +218,26 @@
 PASS setThenReadSelectorText('a#b::-webkit-input-placeholder') is 'a#b::-webkit-input-placeholder'
 PASS setThenReadSelectorText('a[b].c#d::-webkit-input-placeholder') is 'a[b].c#d::-webkit-input-placeholder'
 
+PASS setThenReadSelectorText('a[b]:default') is 'a[b]:default'
+PASS setThenReadSelectorText('a.b:default') is 'a.b:default'
+PASS setThenReadSelectorText('a#b:default') is 'a#b:default'
+PASS setThenReadSelectorText('a[b].c#d:default') is 'a[b].c#d:default'
+
+PASS setThenReadSelectorText('a[b]:in-range') is 'a[b]:in-range'
+PASS setThenReadSelectorText('a.b:in-range') is 'a.b:in-range'
+PASS setThenReadSelectorText('a#b:in-range') is 'a#b:in-range'
+PASS setThenReadSelectorText('a[b].c#d:in-range') is 'a[b].c#d:in-range'
+
+PASS setThenReadSelectorText('a[b]:out-of-range') is 'a[b]:out-of-range'
+PASS setThenReadSelectorText('a.b:out-of-range') is 'a.b:out-of-range'
+PASS setThenReadSelectorText('a#b:out-of-range') is 'a#b:out-of-range'
+PASS setThenReadSelectorText('a[b].c#d:out-of-range') is 'a[b].c#d:out-of-range'
+
+PASS setThenReadSelectorText('a[b]:focus-within') is 'a[b]:focus-within'
+PASS setThenReadSelectorText('a.b:focus-within') is 'a.b:focus-within'
+PASS setThenReadSelectorText('a#b:focus-within') is 'a#b:focus-within'
+PASS setThenReadSelectorText('a[b].c#d:focus-within') is 'a[b].c#d:focus-within'
+
 PASS setThenReadSelectorText('input:not([type="file"]):focus') is 'input:not([type="file"]):focus'
 PASS setThenReadSelectorText(':-webkit-any([type="file"])') is ':-webkit-any([type="file"])'
 PASS setThenReadSelectorText(':-webkit-any(:hover)') is ':-webkit-any(:hover)'

Modified: trunk/LayoutTests/fast/css/css-set-selector-text.html (202357 => 202358)


--- trunk/LayoutTests/fast/css/css-set-selector-text.html	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/LayoutTests/fast/css/css-set-selector-text.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -311,6 +311,34 @@
 
 debug('');
 
+testSelectorRoundTrip("a[b]:default");
+testSelectorRoundTrip("a.b:default");
+testSelectorRoundTrip("a#b:default");
+testSelectorRoundTrip("a[b].c#d:default");
+
+debug('');
+
+testSelectorRoundTrip("a[b]:in-range");
+testSelectorRoundTrip("a.b:in-range");
+testSelectorRoundTrip("a#b:in-range");
+testSelectorRoundTrip("a[b].c#d:in-range");
+
+debug('');
+
+testSelectorRoundTrip("a[b]:out-of-range");
+testSelectorRoundTrip("a.b:out-of-range");
+testSelectorRoundTrip("a#b:out-of-range");
+testSelectorRoundTrip("a[b].c#d:out-of-range");
+
+debug('');
+
+testSelectorRoundTrip("a[b]:focus-within");
+testSelectorRoundTrip("a.b:focus-within");
+testSelectorRoundTrip("a#b:focus-within");
+testSelectorRoundTrip("a[b].c#d:focus-within");
+
+debug('');
+
 testSelectorRoundTrip('input:not([type="file"]):focus');
 testSelectorRoundTrip(':-webkit-any([type="file"])');
 testSelectorRoundTrip(':-webkit-any(:hover)');

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-basics-expected.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-basics-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-basics-expected.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<html class="focus-within">
+<head>
+<style>
+    * {
+        border: none;
+    }
+    .focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body class="focus-within">
+    <form id="form">
+    </form>
+    <div class="focus-within">
+        <input form="form" id="input" autofocus  class="focus-within">
+    </div>
+    <script>
+        document.getElementById("input").focus();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-basics.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-basics.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-basics.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+    * {
+        border: none;
+    }
+    :focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body>
+    <form id="form">
+    </form>
+    <div>
+        <input form="form" id="input" autofocus>
+    </div>
+    <script>
+        document.getElementById("input").focus();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-inside-shadow-dom-expected.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-inside-shadow-dom-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-inside-shadow-dom-expected.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html class="focus-within">
+<head>
+<style>
+    * {
+        border: none;
+    }
+    .focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body class="focus-within">
+    <div id="root" class="focus-within">
+    </div>
+    <script>
+        let rootElement = document.getElementById('root');
+        let firstRoot = rootElement.attachShadow({mode: 'closed'});
+        let insideDiv = document.createElement("div");
+        insideDiv.innerText = "Foobar";
+        insideDiv.className = "focus-within";
+        let inputElement = document.createElement("input")
+        inputElement.className = "focus-within";
+        insideDiv.appendChild(inputElement);
+        firstRoot.appendChild(insideDiv);
+        inputElement.focus();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-inside-shadow-dom.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-inside-shadow-dom.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-inside-shadow-dom.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+    * {
+        border: none;
+    }
+    :focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body>
+    <div id="root">
+    </div>
+    <script>
+        let rootElement = document.getElementById('root');
+        let firstRoot = rootElement.attachShadow({mode: 'closed'});
+        let insideDiv = document.createElement("div");
+        insideDiv.innerText = "Foobar";
+        let inputElement = document.createElement("input")
+        insideDiv.appendChild(inputElement);
+        firstRoot.appendChild(insideDiv);
+        inputElement.focus();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-1-expected.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-1-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-1-expected.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html class="focus-within">
+<head>
+<style>
+    * {
+        border: none;
+    }
+    .focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body class="focus-within">
+    <div class="focus-within">
+        <input form="form" id="input" autofocus  class="focus-within">
+    </div>
+    <div>
+        Foo
+    </div>
+    <div>
+        Bar
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-1.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-1.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-1.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+    * {
+        border: none;
+    }
+    :focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body>
+    <div>
+        <input form="form" id="input" autofocus>
+    </div>
+    <div>
+        Foo
+    </div>
+    <div>
+        Bar
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-2-expected.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-2-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-2-expected.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML>
+<html class="focus-within">
+<head>
+<style>
+    * {
+        border: none;
+    }
+    .focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body class="focus-within">
+    <div class="focus-within">
+        <input>
+        <input>
+        <input>
+        <input class="focus-within">
+        <input>
+        <input>
+        <input>
+    </div>
+    <script>
+        let midInput = document.getElementsByTagName("input")[3];
+        midInput.focus();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-2.html (0 => 202358)


--- trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-focus-within-style-sharing-2.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+    * {
+        border: none;
+    }
+    :focus-within {
+        border: 2px solid green;
+    }
+</style>
+</head>
+<body>
+    <div>
+        <input>
+        <input>
+        <input>
+        <input>
+        <input>
+        <input>
+        <input>
+    </div>
+    <script>
+        let midInput = document.getElementsByTagName("input")[3];
+        midInput.focus();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/selectors/focus-within-style-update-expected.txt (0 => 202358)


--- trunk/LayoutTests/fast/selectors/focus-within-style-update-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/focus-within-style-update-expected.txt	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,77 @@
+Check the basic features of the :focus-within pseudo class
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Initial State
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Set display none on target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS target2.matches(":focus") is true
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Try to focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS target1.matches(":focus") is true
+PASS target2.matches(":focus") is false
+Set display back on target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Set display none on container2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS target2.matches(":focus") is true
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Try to focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS target1.matches(":focus") is true
+PASS target2.matches(":focus") is false
+Set display back on container2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Detach container1 from the document
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+PASS container1.querySelectorAll(":focus-within").length is 0
+PASS target1.matches(":focus") is false
+PASS target2.matches(":focus") is false
+Try to focus target1
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+PASS container1.querySelectorAll(":focus-within").length is 0
+PASS target1.matches(":focus") is false
+PASS target2.matches(":focus") is false
+Focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Attach container1 in container2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]
+Move target1 in container2
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+PASS target1.matches(":focus") is false
+PASS target2.matches(":focus") is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/selectors/focus-within-style-update.html (0 => 202358)


--- trunk/LayoutTests/fast/selectors/focus-within-style-update.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/focus-within-style-update.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,170 @@
+<!doctype html>
+<html id="html">
+<head>
+<script src=""
+<style id="style">
+* {
+    background-color: white;
+}
+:focus-within {
+    background-color: rgb(1, 2, 3);
+}
+</style>
+</head>
+<body id="body">
+    <div id="webkit-test">
+        <div id="container1">
+            <div id="sibling1"></div>
+            <div id="sibling2">
+                <input id="target1">
+            </div>
+            <div id="sibling3"></div>
+        </div>
+        <div id="container2">
+            <div id="sibling4"></div>
+            <div id="sibling5">
+                <textarea id="target2"></textarea>
+            </div>
+            <div id="sibling6"></div>
+        </div>
+    </div>
+</body>
+<script>
+"use strict";
+description('Check the basic features of the :focus-within pseudo class');
+
+function elementsStyledWithFocusWithinSelector() {
+    let elements = [];
+    for (let element of document.querySelectorAll("*")) {
+        if (getComputedStyle(element).backgroundColor === 'rgb(1, 2, 3)') {
+            elements.push(element.id);
+        }
+    }
+    return elements;
+}
+
+function elementsMatchingFocusWithinSelector() {
+    let elements = [];
+    for (let element of document.querySelectorAll(":focus-within")) {
+        elements.push(element.id);
+    }
+    return elements;
+}
+
+debug("Initial State");
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+
+debug("Focus target1");
+var target1 = document.getElementById("target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Focus target2");
+var target2 = document.getElementById("target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Set display none on target2");
+target2.style.display = "none";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBeTrue('target2.matches(":focus")');
+
+debug("Focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Try to focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBeTrue('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Set display back on target2");
+target2.style.display = "revert";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Set display none on container2");
+var container2 = document.getElementById("container2");
+container2.style.display = "none";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBeTrue('target2.matches(":focus")');
+
+debug("Focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Try to focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBeTrue('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Set display back on container2");
+var container2 = document.getElementById("container2");
+container2.style.display = "revert";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Detach container1 from the document");
+var container1 = document.getElementById("container1");
+container1.parentElement.removeChild(container1);
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+shouldBe('container1.querySelectorAll(":focus-within").length', '0');
+shouldBeFalse('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Try to focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+shouldBe('container1.querySelectorAll(":focus-within").length', '0');
+shouldBeFalse('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Attach container1 in container2");
+container2.appendChild(container1);
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]');
+
+debug("Move target1 in container2");
+container2.appendChild(target1);
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+shouldBeFalse('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+gc();
+
+// Clean up the test.
+document.getElementById("webkit-test").style.display = "none";
+document.getElementById("style").innerHTML = "";
+
+</script>
+<script src=""
+</html>

Added: trunk/LayoutTests/fast/selectors/focus-within-with-selector-checker-expected.txt (0 => 202358)


--- trunk/LayoutTests/fast/selectors/focus-within-with-selector-checker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/focus-within-with-selector-checker-expected.txt	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,77 @@
+Test :focus-within with selectors not compiled by CSS JIT
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Initial State
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Set display none on target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS target2.matches(":focus") is true
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Try to focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS target1.matches(":focus") is true
+PASS target2.matches(":focus") is false
+Set display back on target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Set display none on container2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS target2.matches(":focus") is true
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Try to focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS target1.matches(":focus") is true
+PASS target2.matches(":focus") is false
+Set display back on container2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container1", "sibling2", "target1"]
+Detach container1 from the document
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+PASS container1.querySelectorAll(":focus-within").length is 0
+PASS target1.matches(":focus") is false
+PASS target2.matches(":focus") is false
+Try to focus target1
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+PASS container1.querySelectorAll(":focus-within").length is 0
+PASS target1.matches(":focus") is false
+PASS target2.matches(":focus") is false
+Focus target2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Attach container1 in container2
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "sibling5", "target2"]
+Focus target1
+PASS elementsStyledWithFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]
+PASS elementsMatchingFocusWithinSelector() is ["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]
+Move target1 in container2
+PASS elementsStyledWithFocusWithinSelector() is []
+PASS elementsMatchingFocusWithinSelector() is []
+PASS target1.matches(":focus") is false
+PASS target2.matches(":focus") is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/selectors/focus-within-with-selector-checker.html (0 => 202358)


--- trunk/LayoutTests/fast/selectors/focus-within-with-selector-checker.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/focus-within-with-selector-checker.html	2016-06-22 23:35:25 UTC (rev 202358)
@@ -0,0 +1,173 @@
+<!doctype html>
+<html id="html">
+<head>
+<script src=""
+<style id="style">
+* {
+    background-color: white;
+    color: rgb(2, 3, 4);
+}
+:matches(:root, :nth-of-type(n), :not(#specificity-trick), :nth-last-of-type(n)):focus-within {
+    background-color: rgb(1, 2, 3);
+}
+:matches(:root, :nth-last-of-type(n), :not(#specificity-trick)):focus-within {
+    color: rgb(5, 6, 7);
+}
+</style>
+</head>
+<body id="body">
+    <div id="webkit-test">
+        <div id="container1">
+            <div id="sibling1"></div>
+            <div id="sibling2">
+                <input id="target1">
+            </div>
+            <div id="sibling3"></div>
+        </div>
+        <div id="container2">
+            <div id="sibling4"></div>
+            <div id="sibling5">
+                <textarea id="target2"></textarea>
+            </div>
+            <div id="sibling6"></div>
+        </div>
+    </div>
+</body>
+<script>
+"use strict";
+description('Test :focus-within with selectors not compiled by CSS JIT');
+
+function elementsStyledWithFocusWithinSelector() {
+    let elements = [];
+    for (let element of document.querySelectorAll("*")) {
+        let computedStyle = getComputedStyle(element);
+        if (computedStyle.backgroundColor === 'rgb(1, 2, 3)' && computedStyle.color === 'rgb(5, 6, 7)') {
+            elements.push(element.id);
+        }
+    }
+    return elements;
+}
+
+function elementsMatchingFocusWithinSelector() {
+    let elements = [];
+    for (let element of document.querySelectorAll(":matches(:root, :nth-of-type(n), :not(#specificity-trick), :nth-last-of-type(n)):focus-within")) {
+        elements.push(element.id);
+    }
+    return elements;
+}
+
+debug("Initial State");
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+
+debug("Focus target1");
+var target1 = document.getElementById("target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Focus target2");
+var target2 = document.getElementById("target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Set display none on target2");
+target2.style.display = "none";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBeTrue('target2.matches(":focus")');
+
+debug("Focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Try to focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBeTrue('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Set display back on target2");
+target2.style.display = "revert";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Set display none on container2");
+var container2 = document.getElementById("container2");
+container2.style.display = "none";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBeTrue('target2.matches(":focus")');
+
+debug("Focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Try to focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBeTrue('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Set display back on container2");
+var container2 = document.getElementById("container2");
+container2.style.display = "revert";
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container1", "sibling2", "target1"]');
+
+debug("Detach container1 from the document");
+var container1 = document.getElementById("container1");
+container1.parentElement.removeChild(container1);
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+shouldBe('container1.querySelectorAll(":focus-within").length', '0');
+shouldBeFalse('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Try to focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+shouldBe('container1.querySelectorAll(":focus-within").length', '0');
+shouldBeFalse('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+debug("Focus target2");
+target2.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Attach container1 in container2");
+container2.appendChild(container1);
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "sibling5", "target2"]');
+
+debug("Focus target1");
+target1.focus();
+shouldBe('elementsStyledWithFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]');
+shouldBe('elementsMatchingFocusWithinSelector()', '["html", "body", "webkit-test", "container2", "container1", "sibling2", "target1"]');
+
+debug("Move target1 in container2");
+container2.appendChild(target1);
+shouldBe('elementsStyledWithFocusWithinSelector()', '[]');
+shouldBe('elementsMatchingFocusWithinSelector()', '[]');
+shouldBeFalse('target1.matches(":focus")');
+shouldBeFalse('target2.matches(":focus")');
+
+// Clean up the test.
+document.getElementById("webkit-test").style.display = "none";
+document.getElementById("style").innerHTML = "";
+
+</script>
+<script src=""
+</html>

Modified: trunk/Source/WebCore/ChangeLog (202357 => 202358)


--- trunk/Source/WebCore/ChangeLog	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/ChangeLog	2016-06-22 23:35:25 UTC (rev 202358)
@@ -1,3 +1,68 @@
+2016-06-22  Benjamin Poulain  <[email protected]>
+
+        AX: Add support for CSS4 :focus-within pseudo
+        https://bugs.webkit.org/show_bug.cgi?id=140144
+
+        Reviewed by Antti Koivisto.
+
+        Tests: fast/css/pseudo-focus-within-basics.html
+               fast/css/pseudo-focus-within-inside-shadow-dom.html
+               fast/css/pseudo-focus-within-style-sharing-1.html
+               fast/css/pseudo-focus-within-style-sharing-2.html
+               fast/selectors/focus-within-style-update.html
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::selectorText):
+        * css/CSSSelector.h:
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOne):
+        * css/SelectorPseudoClassAndCompatibilityElementMap.in:
+        * cssjit/SelectorCompiler.cpp:
+        (WebCore::SelectorCompiler::addPseudoClassType):
+        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
+        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementHasFocusWithin):
+        * dom/ContainerNode.cpp:
+        (WebCore::destroyRenderTreeIfNeeded):
+        * dom/Element.cpp:
+        (WebCore::Element::~Element):
+        (WebCore::Element::setFocus):
+        (WebCore::Element::unregisterNamedFlowContentElement):
+        (WebCore::Element::setIsNamedFlowContentElement):
+        (WebCore::Element::clearIsNamedFlowContentElement):
+        (WebCore::Element::setStyleAffectedByFocusWithin):
+        (WebCore::Element::rareDataStyleAffectedByFocusWithin):
+        (WebCore::Element::rareDataIsNamedFlowContentElement):
+        * dom/Element.h:
+        (WebCore::Element::hasFocusWithin):
+        (WebCore::Element::styleAffectedByFocusWithin):
+        (WebCore::Element::isNamedFlowContentElement):
+        (WebCore::Element::setHasFocusWithin):
+        * dom/ElementRareData.h:
+        (WebCore::ElementRareData::styleAffectedByFocusWithin):
+        (WebCore::ElementRareData::setStyleAffectedByFocusWithin):
+        (WebCore::ElementRareData::isNamedFlowContentElement):
+        (WebCore::ElementRareData::setIsNamedFlowContentElement):
+        (WebCore::ElementRareData::ElementRareData):
+        (WebCore::ElementRareData::resetComputedStyle):
+        * dom/Node.h:
+        (WebCore::Node::flagHasFocusWithin):
+        (WebCore::Node::isNamedFlowContentNode): Deleted.
+        (WebCore::Node::setIsNamedFlowContentNode): Deleted.
+        (WebCore::Node::clearIsNamedFlowContentNode): Deleted.
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::clearContentElements):
+        (WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
+        (WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):
+        (WebCore::nextNodeInsideContentElement):
+        * style/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::updateElementRenderer):
+        * style/StyleRelations.cpp:
+        (WebCore::Style::commitRelationsToRenderStyle):
+        (WebCore::Style::commitRelations):
+        * style/StyleRelations.h:
+        * style/StyleSharingResolver.cpp:
+        (WebCore::Style::SharingResolver::canShareStyleWithElement):
+
 2016-06-22  Oliver Hunt  <[email protected]>
 
         Integrate WebKit's CFURLConnection with App Transport Security

Modified: trunk/Source/WebCore/css/CSSSelector.cpp (202357 => 202358)


--- trunk/Source/WebCore/css/CSSSelector.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/css/CSSSelector.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -497,6 +497,9 @@
             case CSSSelector::PseudoClassFocus:
                 str.appendLiteral(":focus");
                 break;
+            case CSSSelector::PseudoClassFocusWithin:
+                str.appendLiteral(":focus-within");
+                break;
 #if ENABLE(VIDEO_TRACK)
             case CSSSelector::PseudoClassFuture:
                 str.appendLiteral(":future");

Modified: trunk/Source/WebCore/css/CSSSelector.h (202357 => 202358)


--- trunk/Source/WebCore/css/CSSSelector.h	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/css/CSSSelector.h	2016-06-22 23:35:25 UTC (rev 202358)
@@ -112,6 +112,7 @@
             PseudoClassHover,
             PseudoClassDrag,
             PseudoClassFocus,
+            PseudoClassFocusWithin,
             PseudoClassActive,
             PseudoClassChecked,
             PseudoClassEnabled,

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (202357 => 202358)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -944,6 +944,9 @@
             break;
         case CSSSelector::PseudoClassFocus:
             return matchesFocusPseudoClass(element);
+        case CSSSelector::PseudoClassFocusWithin:
+            addStyleRelation(checkingContext, element, Style::Relation::AffectedByFocusWithin);
+            return element.hasFocusWithin();
         case CSSSelector::PseudoClassHover:
             if (m_strictParsing || element.isLink() || canMatchHoverOrActiveInQuirksMode(context)) {
                 addStyleRelation(checkingContext, element, Style::Relation::AffectedByHover);

Modified: trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in (202357 => 202358)


--- trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in	2016-06-22 23:35:25 UTC (rev 202358)
@@ -25,6 +25,7 @@
 first-line, PseudoClassUnknown, PseudoElementFirstLine
 first-of-type
 focus
+focus-within
 horizontal
 host
 hover

Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (202357 => 202358)


--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -323,6 +323,7 @@
     void generateElementIsRoot(Assembler::JumpList& failureCases);
     void generateElementIsScopeRoot(Assembler::JumpList& failureCases);
     void generateElementIsTarget(Assembler::JumpList& failureCases);
+    void generateElementHasFocusWithin(Assembler::JumpList& failureCases);
 
     // Helpers.
     void generateAddStyleRelationIfResolvingStyle(Assembler::RegisterID element, Style::Relation::Type, Optional<Assembler::RegisterID> value = { });
@@ -674,6 +675,7 @@
     case CSSSelector::PseudoClassLastChild:
     case CSSSelector::PseudoClassOnlyChild:
     case CSSSelector::PseudoClassPlaceholderShown:
+    case CSSSelector::PseudoClassFocusWithin:
         fragment.pseudoClasses.add(type);
         if (selectorContext == SelectorContext::QuerySelector)
             return FunctionType::SimpleSelectorChecker;
@@ -2578,6 +2580,9 @@
     if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassTarget))
         generateElementIsTarget(matchingPostTagNameFailureCases);
 
+    if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassFocusWithin))
+        generateElementHasFocusWithin(matchingPostTagNameFailureCases);
+
     for (unsigned i = 0; i < fragment.unoptimizedPseudoClasses.size(); ++i)
         generateElementFunctionCallTest(matchingPostTagNameFailureCases, fragment.unoptimizedPseudoClasses[i]);
 
@@ -3791,6 +3796,12 @@
     failureCases.append(m_assembler.branchPtr(Assembler::NotEqual, Assembler::Address(document, Document::cssTargetMemoryOffset()), elementAddressRegister));
 }
 
+void SelectorCodeGenerator::generateElementHasFocusWithin(Assembler::JumpList& failureCases)
+{
+    generateAddStyleRelationIfResolvingStyle(elementAddressRegister, Style::Relation::AffectedByFocusWithin);
+    failureCases.append(m_assembler.branchTest32(Assembler::Zero, Assembler::Address(elementAddressRegister, Node::nodeFlagsMemoryOffset()), Assembler::TrustedImm32(Node::flagHasFocusWithin())));
+}
+
 void SelectorCodeGenerator::generateElementIsFirstLink(Assembler::JumpList& failureCases, Assembler::RegisterID element)
 {
     LocalRegister currentElement(m_registerAllocator);

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (202357 => 202358)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -103,9 +103,11 @@
     bool childIsHTMLSlotElement = false;
     childIsHTMLSlotElement = is<HTMLSlotElement>(child);
     // FIXME: Get rid of the named flow test.
-    if (!child.renderer() && !child.isNamedFlowContentNode() && !childIsHTMLSlotElement)
+    bool isElement = is<Element>(child);
+    if (!child.renderer() && !childIsHTMLSlotElement
+        && !(isElement && downcast<Element>(child).isNamedFlowContentElement()))
         return;
-    if (is<Element>(child))
+    if (isElement)
         RenderTreeUpdater::tearDownRenderers(downcast<Element>(child));
     else if (is<Text>(child))
         RenderTreeUpdater::tearDownRenderer(downcast<Text>(child));

Modified: trunk/Source/WebCore/dom/Element.cpp (202357 => 202358)


--- trunk/Source/WebCore/dom/Element.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/dom/Element.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -182,8 +182,8 @@
     if (document().hasLivingRenderTree()) {
         // When the document is not destroyed, an element that was part of a named flow
         // content nodes should have been removed from the content nodes collection
-        // and the isNamedFlowContentNode flag reset.
-        ASSERT_WITH_SECURITY_IMPLICATION(!isNamedFlowContentNode());
+        // and the isNamedFlowContentElement flag reset.
+        ASSERT_WITH_SECURITY_IMPLICATION(!isNamedFlowContentElement());
     }
 #endif
 
@@ -601,6 +601,9 @@
 
     document().userActionElements().setFocused(this, flag);
     setNeedsStyleRecalc();
+
+    for (Element* element = this; element; element = element->parentOrShadowHostElement())
+        element->setHasFocusWithin(flag);
 }
 
 void Element::setHovered(bool flag)
@@ -1620,7 +1623,7 @@
 
 void Element::unregisterNamedFlowContentElement()
 {
-    if (isNamedFlowContentNode() && document().renderView())
+    if (isNamedFlowContentElement() && document().renderView())
         document().renderView()->flowThreadController().unregisterNamedFlowContentElement(*this);
 }
 
@@ -1908,6 +1911,16 @@
     setAttributeEventListener(eventType, JSLazyEventListener::create(*this, attributeName, attributeValue));
 }
 
+void Element::setIsNamedFlowContentElement()
+{
+    ensureElementRareData().setIsNamedFlowContentElement(true);
+}
+
+void Element::clearIsNamedFlowContentElement()
+{
+    ensureElementRareData().setIsNamedFlowContentElement(false);
+}
+
 void Element::removeAllEventListeners()
 {
     ContainerNode::removeAllEventListeners();
@@ -2562,6 +2575,11 @@
     ensureElementRareData().setStyleAffectedByEmpty(true);
 }
 
+void Element::setStyleAffectedByFocusWithin()
+{
+    ensureElementRareData().setStyleAffectedByFocusWithin(true);
+}
+
 void Element::setChildrenAffectedByActive()
 {
     ensureElementRareData().setChildrenAffectedByActive(true);
@@ -2607,6 +2625,18 @@
     return elementRareData()->styleAffectedByEmpty();
 }
 
+bool Element::rareDataStyleAffectedByFocusWithin() const
+{
+    ASSERT(hasRareData());
+    return elementRareData()->styleAffectedByFocusWithin();
+}
+
+bool Element::rareDataIsNamedFlowContentElement() const
+{
+    ASSERT(hasRareData());
+    return elementRareData()->isNamedFlowContentElement();
+}
+
 bool Element::rareDataChildrenAffectedByActive() const
 {
     ASSERT(hasRareData());

Modified: trunk/Source/WebCore/dom/Element.h (202357 => 202358)


--- trunk/Source/WebCore/dom/Element.h	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/dom/Element.h	2016-06-22 23:35:25 UTC (rev 202358)
@@ -273,10 +273,12 @@
     bool active() const { return isUserActionElement() && isUserActionElementActive(); }
     bool hovered() const { return isUserActionElement() && isUserActionElementHovered(); }
     bool focused() const { return isUserActionElement() && isUserActionElementFocused(); }
+    bool hasFocusWithin() const { return getFlag(HasFocusWithin); };
 
     virtual void setActive(bool flag = true, bool pause = false);
     virtual void setHovered(bool flag = true);
     virtual void setFocus(bool flag);
+    void setHasFocusWithin(bool flag);
 
     bool tabIndexSetExplicitly() const;
     virtual bool supportsFocus() const;
@@ -296,6 +298,7 @@
 
     // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
     bool styleAffectedByEmpty() const { return hasRareData() && rareDataStyleAffectedByEmpty(); }
+    bool styleAffectedByFocusWithin() const { return hasRareData() && rareDataStyleAffectedByFocusWithin(); }
     bool childrenAffectedByHover() const { return getFlag(ChildrenAffectedByHoverRulesFlag); }
     bool childrenAffectedByActive() const { return hasRareData() && rareDataChildrenAffectedByActive(); }
     bool childrenAffectedByDrag() const { return hasRareData() && rareDataChildrenAffectedByDrag(); }
@@ -309,6 +312,7 @@
     bool hasFlagsSetDuringStylingOfChildren() const;
 
     void setStyleAffectedByEmpty();
+    void setStyleAffectedByFocusWithin();
     void setChildrenAffectedByHover() { setFlag(ChildrenAffectedByHoverRulesFlag); }
     void setChildrenAffectedByActive();
     void setChildrenAffectedByDrag();
@@ -521,6 +525,10 @@
     using ContainerNode::setAttributeEventListener;
     void setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value);
 
+    bool isNamedFlowContentElement() const { return hasRareData() && rareDataIsNamedFlowContentElement(); }
+    void setIsNamedFlowContentElement();
+    void clearIsNamedFlowContentElement();
+
 protected:
     Element(const QualifiedName&, Document&, ConstructionType);
 
@@ -607,6 +615,8 @@
     const RenderStyle& resolveComputedStyle();
 
     bool rareDataStyleAffectedByEmpty() const;
+    bool rareDataStyleAffectedByFocusWithin() const;
+    bool rareDataIsNamedFlowContentElement() const;
     bool rareDataChildrenAffectedByHover() const;
     bool rareDataChildrenAffectedByActive() const;
     bool rareDataChildrenAffectedByDrag() const;
@@ -749,6 +759,15 @@
     return element.isHTMLElement() && element.document().isHTMLDocument();
 }
 
+inline void Element::setHasFocusWithin(bool flag)
+{
+    if (hasFocusWithin() == flag)
+        return;
+    setFlag(flag, HasFocusWithin);
+    if (styleAffectedByFocusWithin())
+        setNeedsStyleRecalc();
+}
+
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Element)

Modified: trunk/Source/WebCore/dom/ElementRareData.h (202357 => 202358)


--- trunk/Source/WebCore/dom/ElementRareData.h	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/dom/ElementRareData.h	2016-06-22 23:35:25 UTC (rev 202358)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2009, 2010, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010, 2014, 2016 Apple Inc. All rights reserved.
  * Copyright (C) 2008 David Smith <[email protected]>
  *
  * This library is free software; you can redistribute it and/or
@@ -58,9 +58,15 @@
     bool styleAffectedByEmpty() const { return m_styleAffectedByEmpty; }
     void setStyleAffectedByEmpty(bool value) { m_styleAffectedByEmpty = value; }
 
+    bool styleAffectedByFocusWithin() const { return m_styleAffectedByFocusWithin; }
+    void setStyleAffectedByFocusWithin(bool value) { m_styleAffectedByFocusWithin = value; }
+
     RegionOversetState regionOversetState() const { return m_regionOversetState; }
     void setRegionOversetState(RegionOversetState state) { m_regionOversetState = state; }
 
+    bool isNamedFlowContentElement() const { return m_isNamedFlowContentElement; }
+    void setIsNamedFlowContentElement(bool value) { m_isNamedFlowContentElement = value; }
+
 #if ENABLE(FULLSCREEN_API)
     bool containsFullScreenElement() { return m_containsFullScreenElement; }
     void setContainsFullScreenElement(bool value) { m_containsFullScreenElement = value; }
@@ -116,6 +122,7 @@
     unsigned m_tabIndexWasSetExplicitly : 1;
     unsigned m_needsFocusAppearanceUpdateSoonAfterAttach : 1;
     unsigned m_styleAffectedByEmpty : 1;
+    unsigned m_styleAffectedByFocusWithin : 1;
 #if ENABLE(FULLSCREEN_API)
     unsigned m_containsFullScreenElement : 1;
 #endif
@@ -130,6 +137,7 @@
     unsigned m_childrenAffectedByBackwardPositionalRules : 1;
     unsigned m_childrenAffectedByPropertyBasedBackwardPositionalRules : 1;
     unsigned m_hasDisplayContents : 1;
+    unsigned m_isNamedFlowContentElement : 1;
 
     RegionOversetState m_regionOversetState;
 
@@ -160,6 +168,7 @@
     , m_tabIndexWasSetExplicitly(false)
     , m_needsFocusAppearanceUpdateSoonAfterAttach(false)
     , m_styleAffectedByEmpty(false)
+    , m_styleAffectedByFocusWithin(false)
 #if ENABLE(FULLSCREEN_API)
     , m_containsFullScreenElement(false)
 #endif
@@ -171,6 +180,7 @@
     , m_childrenAffectedByBackwardPositionalRules(false)
     , m_childrenAffectedByPropertyBasedBackwardPositionalRules(false)
     , m_hasDisplayContents(false)
+    , m_isNamedFlowContentElement(false)
     , m_regionOversetState(RegionUndefined)
     , m_minimumSizeForResizing(defaultMinimumSizeForResizing())
 {
@@ -200,6 +210,7 @@
     m_computedStyle = nullptr;
     m_hasDisplayContents = false;
     setStyleAffectedByEmpty(false);
+    setStyleAffectedByFocusWithin(false);
     setChildIndex(0);
 }
 

Modified: trunk/Source/WebCore/dom/Node.h (202357 => 202358)


--- trunk/Source/WebCore/dom/Node.h	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/dom/Node.h	2016-06-22 23:35:25 UTC (rev 202358)
@@ -247,7 +247,6 @@
     bool isDocumentFragment() const { return getFlag(IsDocumentFragmentFlag); }
     bool isShadowRoot() const { return isDocumentFragment() && isTreeScope(); }
 
-    bool isNamedFlowContentNode() const { return getFlag(IsNamedFlowContentNodeFlag); }
     bool hasCustomStyleResolveCallbacks() const { return getFlag(HasCustomStyleResolveCallbacksFlag); }
 
     bool hasSyntheticAttrChildNodes() const { return getFlag(HasSyntheticAttrChildNodesFlag); }
@@ -337,9 +336,6 @@
     bool isLink() const { return getFlag(IsLinkFlag); }
     void setIsLink(bool flag) { setFlag(flag, IsLinkFlag); }
 
-    void setIsNamedFlowContentNode() { setFlag(IsNamedFlowContentNodeFlag); }
-    void clearIsNamedFlowContentNode() { clearFlag(IsNamedFlowContentNodeFlag); }
-
     bool hasEventTargetData() const { return getFlag(HasEventTargetDataFlag); }
     void setHasEventTargetData(bool flag) { setFlag(flag, HasEventTargetDataFlag); }
 
@@ -572,6 +568,7 @@
     static int32_t flagIsElement() { return IsElementFlag; }
     static int32_t flagIsHTML() { return IsHTMLFlag; }
     static int32_t flagIsLink() { return IsLinkFlag; }
+    static int32_t flagHasFocusWithin() { return HasFocusWithin; }
     static int32_t flagHasRareData() { return HasRareDataFlag; }
     static int32_t flagIsParsingChildrenFinished() { return IsParsingChildrenFinishedFlag; }
     static int32_t flagChildrenAffectedByFirstChildRulesFlag() { return ChildrenAffectedByFirstChildRulesFlag; }
@@ -602,7 +599,7 @@
 
         StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1) | 1 << (nodeStyleChangeShift + 2),
         IsEditingTextOrUnresolvedCustomElementFlag = 1 << 17,
-        IsNamedFlowContentNodeFlag = 1 << 18,
+        HasFocusWithin = 1 << 18,
         HasSyntheticAttrChildNodesFlag = 1 << 19,
         HasCustomStyleResolveCallbacksFlag = 1 << 20,
         HasEventTargetDataFlag = 1 << 21,

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp (202357 => 202358)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -74,10 +74,10 @@
 {
     for (auto& contentElement : m_contentElements) {
         ASSERT(contentElement);
-        ASSERT(contentElement->isNamedFlowContentNode());
+        ASSERT(contentElement->isNamedFlowContentElement());
         ASSERT(&contentElement->document() == &document());
         
-        contentElement->clearIsNamedFlowContentNode();
+        contentElement->clearIsNamedFlowContentElement();
     }
     
     m_contentElements.clear();
@@ -497,7 +497,7 @@
 {
     ASSERT(&contentElement.document() == &document());
 
-    contentElement.setIsNamedFlowContentNode();
+    contentElement.setIsNamedFlowContentElement();
 
     resetMarkForDestruction();
 
@@ -518,10 +518,10 @@
 void RenderNamedFlowThread::unregisterNamedFlowContentElement(Element& contentElement)
 {
     ASSERT(m_contentElements.contains(&contentElement));
-    ASSERT(contentElement.isNamedFlowContentNode());
+    ASSERT(contentElement.isNamedFlowContentElement());
     ASSERT(&contentElement.document() == &document());
 
-    contentElement.clearIsNamedFlowContentNode();
+    contentElement.clearIsNamedFlowContentElement();
     m_contentElements.remove(&contentElement);
 
     if (canBeDestroyed())
@@ -616,7 +616,7 @@
 // Retrieve the next node to be visited while computing the ranges inside a region.
 static Node* nextNodeInsideContentElement(const Node& currNode, const Element* contentElement)
 {
-    ASSERT(contentElement && contentElement->isNamedFlowContentNode());
+    ASSERT(contentElement && contentElement->isNamedFlowContentElement());
 
     if (currNode.renderer() && currNode.renderer()->isSVGRoot())
         return NodeTraversal::nextSkippingChildren(currNode, contentElement);

Modified: trunk/Source/WebCore/style/RenderTreeUpdater.cpp (202357 => 202358)


--- trunk/Source/WebCore/style/RenderTreeUpdater.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -240,7 +240,7 @@
 
 void RenderTreeUpdater::updateElementRenderer(Element& element, Style::ElementUpdate& update)
 {
-    bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.isNamedFlowContentNode());
+    bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.isNamedFlowContentElement());
     if (shouldTearDownRenderers)
         tearDownRenderers(element, TeardownType::KeepHoverAndActive);
 

Modified: trunk/Source/WebCore/style/StyleRelations.cpp (202357 => 202358)


--- trunk/Source/WebCore/style/StyleRelations.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/style/StyleRelations.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -72,6 +72,7 @@
         case Relation::Unique:
             style.setUnique();
             break;
+        case Relation::AffectedByFocusWithin:
         case Relation::AffectedByPreviousSibling:
         case Relation::AffectsNextSibling:
         case Relation::ChildrenAffectedByBackwardPositionalRules:
@@ -102,6 +103,9 @@
         case Relation::AffectedByEmpty:
             element.setStyleAffectedByEmpty();
             break;
+        case Relation::AffectedByFocusWithin:
+            element.setStyleAffectedByFocusWithin();
+            break;
         case Relation::AffectedByHover:
             element.setChildrenAffectedByHover();
             break;

Modified: trunk/Source/WebCore/style/StyleRelations.h (202357 => 202358)


--- trunk/Source/WebCore/style/StyleRelations.h	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/style/StyleRelations.h	2016-06-22 23:35:25 UTC (rev 202358)
@@ -42,6 +42,7 @@
         AffectedByActive,
         AffectedByDrag,
         AffectedByEmpty,
+        AffectedByFocusWithin,
         AffectedByHover,
         AffectedByPreviousSibling,
         // For AffectsNextSibling 'value' tells how many element siblings to mark starting with 'element'.

Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (202357 => 202358)


--- trunk/Source/WebCore/style/StyleSharingResolver.cpp	2016-06-22 23:31:42 UTC (rev 202357)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp	2016-06-22 23:35:25 UTC (rev 202358)
@@ -230,6 +230,8 @@
         return false;
     if (candidateElement.affectsNextSiblingElementStyle() || candidateElement.styleIsAffectedByPreviousSibling())
         return false;
+    if (candidateElement.styleAffectedByFocusWithin() || element.styleAffectedByFocusWithin())
+        return false;
 
     auto& candidateElementId = candidateElement.idForStyleResolution();
     if (!candidateElementId.isNull() && m_ruleSets.features().idsInRules.contains(candidateElementId.impl()))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to