Title: [120147] trunk
Revision
120147
Author
morr...@google.com
Date
2012-06-12 18:28:33 -0700 (Tue, 12 Jun 2012)

Log Message

Shadow Pseudo ID should be able to nest to point nested shadow DOM.
https://bugs.webkit.org/show_bug.cgi?id=62218

Reviewed by Dimitri Glazkov.

.:

* Source/autotools/symbols.filter:

Source/WebCore:

- updateSpecifiersWithElementName() didn't take nesting into account.
  tag history can contain selector entries which isn't marked as ShadowDescendant yet.
  such entry can be found by investigating isUnknownPseudoElement().
- SelectorChecker::checkSelector() was too strict. Unknown pseudo elements are essentially a kind of class or id
  in implementation perspective. For such, rejecting by missing elementStyle doesn't make sense:
  It isn't a pseudo but a real element for WebCore after all.
- Added Internals::setShadowPseudoId() to create a test harness whose DOM tree contains pseudo shadow ids.

Before this change, following selecdtor chain is created for "p::-shadow-child::-nested-shadow-child":

  [both tag name and -shadow-id are set] <-(ShadowDescendant)- [-nested-shadow-id]

What we want, which is created by this change is:

  [tag] <-(ShadowDescendant)- [-shadow-id is set] <-(ShadowdescenDant)- [-nested-shadow-id]

Test: fast/dom/shadow/shadow-nested-pseudo-id.html

* WebCore.exp.in:
* css/CSSParser.cpp:
(WebCore::CSSParser::updateSpecifiersWithElementName):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOneSelector):
* testing/Internals.cpp:
(WebCore::Internals::setShadowPseudoId):
(WebCore):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

Source/WebKit2:

* win/WebKit2.def:
* win/WebKit2CFLite.def:

LayoutTests:

* fast/dom/shadow/shadow-nested-pseudo-id-expected.txt: Added.
* fast/dom/shadow/shadow-nested-pseudo-id.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (120146 => 120147)


--- trunk/ChangeLog	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/ChangeLog	2012-06-13 01:28:33 UTC (rev 120147)
@@ -1,3 +1,12 @@
+2012-06-12  MORITA Hajime  <morr...@google.com>
+
+        Shadow Pseudo ID should be able to nest to point nested shadow DOM.
+        https://bugs.webkit.org/show_bug.cgi?id=62218
+
+        Reviewed by Dimitri Glazkov.
+
+        * Source/autotools/symbols.filter:
+
 2012-06-12  Christophe Dumez  <christophe.du...@intel.com>
 
         [EFL] Enable SHADOW_DOM flag

Modified: trunk/LayoutTests/ChangeLog (120146 => 120147)


--- trunk/LayoutTests/ChangeLog	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/LayoutTests/ChangeLog	2012-06-13 01:28:33 UTC (rev 120147)
@@ -1,3 +1,13 @@
+2012-06-12  MORITA Hajime  <morr...@google.com>
+
+        Shadow Pseudo ID should be able to nest to point nested shadow DOM.
+        https://bugs.webkit.org/show_bug.cgi?id=62218
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/shadow-nested-pseudo-id-expected.txt: Added.
+        * fast/dom/shadow/shadow-nested-pseudo-id.html: Added.
+
 2012-06-12  Ojan Vafai  <o...@chromium.org>
 
         Chromium rebaselines after r120135. The new results are clearly more correct.

Added: trunk/LayoutTests/fast/dom/shadow/shadow-nested-pseudo-id-expected.txt (0 => 120147)


--- trunk/LayoutTests/fast/dom/shadow/shadow-nested-pseudo-id-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-nested-pseudo-id-expected.txt	2012-06-13 01:28:33 UTC (rev 120147)
@@ -0,0 +1,12 @@
+Nested pseudo id should be matchable
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(tuple.shadowChild).color is 'rgb(255, 0, 0)'
+PASS window.getComputedStyle(shadowTuple.shadowChild).color is 'rgb(0, 0, 255)'
+PASS window.getComputedStyle(shadowTuple.shadowChild).backgroundColor is 'rgb(0, 128, 0)'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/shadow-nested-pseudo-id.html (0 => 120147)


--- trunk/LayoutTests/fast/dom/shadow/shadow-nested-pseudo-id.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-nested-pseudo-id.html	2012-06-13 01:28:33 UTC (rev 120147)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+
+p::-shadow-child {
+  color: red;
+}
+
+a::-nested-shadow-child {
+  color: blue;
+}
+
+p::-shadow-child::-nested-shadow-child {
+  background-color: green;
+}
+
+</style>
+</head>
+<body>
+
+<div id="console"></div>
+<p id="host"></div>
+
+<script>
+function buildShadowWithOneChild(host, childTagName, childPseudoId)
+{
+    var shadow = new WebKitShadowRoot(host);
+    var shadowChild = document.createElement(childTagName);
+    shadow.appendChild(shadowChild);
+    internals.setShadowPseudoId(shadowChild, childPseudoId);
+    return { host: host, shadow: shadow, shadowChild: shadowChild };
+}
+
+description("Nested pseudo id should be matchable");
+
+if (!window.internals)
+    fail("You need window.internals to run this test");
+    
+var host = document.getElementById("host");
+var tuple = buildShadowWithOneChild(host, "a", "-shadow-child");
+shouldBe("window.getComputedStyle(tuple.shadowChild).color", "'rgb(255, 0, 0)'");
+var shadowTuple = buildShadowWithOneChild(tuple.shadowChild, "b", "-nested-shadow-child");
+shouldBe("window.getComputedStyle(shadowTuple.shadowChild).color", "'rgb(0, 0, 255)'");
+shouldBe("window.getComputedStyle(shadowTuple.shadowChild).backgroundColor", "'rgb(0, 128, 0)'");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (120146 => 120147)


--- trunk/Source/WebCore/ChangeLog	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebCore/ChangeLog	2012-06-13 01:28:33 UTC (rev 120147)
@@ -1,3 +1,40 @@
+2012-06-12  MORITA Hajime  <morr...@google.com>
+
+        Shadow Pseudo ID should be able to nest to point nested shadow DOM.
+        https://bugs.webkit.org/show_bug.cgi?id=62218
+
+        Reviewed by Dimitri Glazkov.
+
+        - updateSpecifiersWithElementName() didn't take nesting into account.
+          tag history can contain selector entries which isn't marked as ShadowDescendant yet.
+          such entry can be found by investigating isUnknownPseudoElement().
+        - SelectorChecker::checkSelector() was too strict. Unknown pseudo elements are essentially a kind of class or id
+          in implementation perspective. For such, rejecting by missing elementStyle doesn't make sense:
+          It isn't a pseudo but a real element for WebCore after all.
+        - Added Internals::setShadowPseudoId() to create a test harness whose DOM tree contains pseudo shadow ids.
+
+        Before this change, following selecdtor chain is created for "p::-shadow-child::-nested-shadow-child":
+
+          [both tag name and -shadow-id are set] <-(ShadowDescendant)- [-nested-shadow-id]
+
+        What we want, which is created by this change is:
+
+          [tag] <-(ShadowDescendant)- [-shadow-id is set] <-(ShadowdescenDant)- [-nested-shadow-id]
+
+        Test: fast/dom/shadow/shadow-nested-pseudo-id.html
+
+        * WebCore.exp.in:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::updateSpecifiersWithElementName):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOneSelector):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setShadowPseudoId):
+        (WebCore):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-06-12  Christophe Dumez  <christophe.du...@intel.com>
 
         [soup] Prevent setting or editing httpOnly cookies from _javascript_

Modified: trunk/Source/WebCore/WebCore.exp.in (120146 => 120147)


--- trunk/Source/WebCore/WebCore.exp.in	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-06-13 01:28:33 UTC (rev 120147)
@@ -784,6 +784,7 @@
 __ZN7WebCore7Console21shouldPrintExceptionsEv
 __ZN7WebCore7Console24setShouldPrintExceptionsEb
 __ZN7WebCore7Element21boundsInRootViewSpaceEv
+__ZN7WebCore7Element17setShadowPseudoIdERKN3WTF12AtomicStringERi
 __ZN7WebCore7Element9innerTextEv
 __ZN7WebCore7IntRect5scaleEf
 __ZN7WebCore7IntRect5uniteERKS0_

Modified: trunk/Source/WebCore/css/CSSParser.cpp (120146 => 120147)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-06-13 01:28:33 UTC (rev 120147)
@@ -9269,7 +9269,7 @@
     CSSParserSelector* history = specifiers;
     while (history->tagHistory()) {
         history = history->tagHistory();
-        if (history->hasShadowDescendant())
+        if (history->isUnknownPseudoElement() || history->hasShadowDescendant())
             lastShadowDescendant = history;
     }
 

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (120146 => 120147)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2012-06-13 01:28:33 UTC (rev 120147)
@@ -1177,14 +1177,14 @@
         return false;
     }
     if (selector->m_match == CSSSelector::PseudoElement) {
-        if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules)
-            return false;
-
         if (selector->isUnknownPseudoElement()) {
             m_hasUnknownPseudoElements = true;
             return element->shadowPseudoId() == selector->value();
         }
 
+        if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules)
+            return false;
+
         PseudoId pseudoId = CSSSelector::pseudoId(selector->pseudoType());
         if (pseudoId == FIRST_LETTER) {
             if (Document* document = element->document())

Modified: trunk/Source/WebCore/testing/Internals.cpp (120146 => 120147)


--- trunk/Source/WebCore/testing/Internals.cpp	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebCore/testing/Internals.cpp	2012-06-13 01:28:33 UTC (rev 120147)
@@ -381,6 +381,16 @@
     return element->shadowPseudoId().string();
 }
 
+void Internals::setShadowPseudoId(Element* element, const String& id, ExceptionCode& ec)
+{
+    if (!element) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    return element->setShadowPseudoId(id, ec);
+}
+
 String Internals::visiblePlaceholder(Element* element)
 {
     HTMLTextFormControlElement* textControl = toTextFormControl(element);

Modified: trunk/Source/WebCore/testing/Internals.h (120146 => 120147)


--- trunk/Source/WebCore/testing/Internals.h	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebCore/testing/Internals.h	2012-06-13 01:28:33 UTC (rev 120147)
@@ -77,6 +77,8 @@
     ShadowRootIfShadowDOMEnabledOrNode* olderShadowRoot(Node* shadow, ExceptionCode&);
     Element* includerFor(Node*, ExceptionCode&);
     String shadowPseudoId(Element*, ExceptionCode&);
+    void setShadowPseudoId(Element*, const String&, ExceptionCode&);
+
     PassRefPtr<Element> createContentElement(Document*, ExceptionCode&);
     Element* getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode&);
     bool isValidContentSelect(Element* insertionPoint, ExceptionCode&);

Modified: trunk/Source/WebCore/testing/Internals.idl (120146 => 120147)


--- trunk/Source/WebCore/testing/Internals.idl	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebCore/testing/Internals.idl	2012-06-13 01:28:33 UTC (rev 120147)
@@ -50,6 +50,7 @@
 #endif
         Element includerFor(in Node node) raises (DOMException);
         DOMString shadowPseudoId(in Element element) raises (DOMException);
+        void setShadowPseudoId(in Element element, in DOMString id) raises (DOMException);
         Element createContentElement(in Document document) raises(DOMException);
         Element getElementByIdInShadowRoot(in Node shadowRoot, in DOMString id) raises(DOMException);
         boolean isValidContentSelect(in Element contentElement) raises(DOMException);

Modified: trunk/Source/WebKit2/ChangeLog (120146 => 120147)


--- trunk/Source/WebKit2/ChangeLog	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebKit2/ChangeLog	2012-06-13 01:28:33 UTC (rev 120147)
@@ -1,3 +1,13 @@
+2012-06-12  MORITA Hajime  <morr...@google.com>
+
+        Shadow Pseudo ID should be able to nest to point nested shadow DOM.
+        https://bugs.webkit.org/show_bug.cgi?id=62218
+
+        Reviewed by Dimitri Glazkov.
+
+        * win/WebKit2.def:
+        * win/WebKit2CFLite.def:
+
 2012-06-12  Kenneth Rohde Christiansen  <kenn...@webkit.org>
 
         Unreviewed build fix.

Modified: trunk/Source/WebKit2/win/WebKit2.def (120146 => 120147)


--- trunk/Source/WebKit2/win/WebKit2.def	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebKit2/win/WebKit2.def	2012-06-13 01:28:33 UTC (rev 120147)
@@ -220,6 +220,7 @@
         ?setResourcesDataSizeLimitsFromInternals@InspectorController@WebCore@@QAEXHH@Z
         ?setSansSerifFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z
         ?setScrollbarsSuppressed@ScrollView@WebCore@@QAEX_N0@Z
+        ?setShadowPseudoId@Element@WebCore@@QAEXABVAtomicString@WTF@@AAH@Z
         ?setDelegatesScrolling@ScrollView@WebCore@@QAEX_N@Z
         ?setScrollOffsetFromInternals@ScrollableArea@WebCore@@QAEXABVIntPoint@2@@Z
         ?setSerifFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z

Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (120146 => 120147)


--- trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-06-13 01:28:33 UTC (rev 120147)
@@ -215,6 +215,7 @@
         ?setDelegatesScrolling@ScrollView@WebCore@@QAEX_N@Z
         ?setScrollOffsetFromInternals@ScrollableArea@WebCore@@QAEXABVIntPoint@2@@Z
         ?setSerifFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z
+        ?setShadowPseudoId@Element@WebCore@@QAEXABVAtomicString@WTF@@AAH@Z
         ?setStandardFontFamily@Settings@WebCore@@QAEXABVAtomicString@WTF@@W4UScriptCode@@@Z
         ?setSuggestedValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z
         ?setEditingValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z

Modified: trunk/Source/autotools/symbols.filter (120146 => 120147)


--- trunk/Source/autotools/symbols.filter	2012-06-13 00:39:09 UTC (rev 120146)
+++ trunk/Source/autotools/symbols.filter	2012-06-13 01:28:33 UTC (rev 120147)
@@ -86,6 +86,7 @@
 _ZN7WebCore6JSNode6s_infoE;
 _ZN7WebCore6toNodeEN3JSC7JSValueE;
 _ZN7WebCore7Element20removeShadowRootListEv;
+_ZN7WebCore7Element17setShadowPseudoIdERKN3WTF12AtomicStringERi;
 _ZN7WebCore7toRangeEN3JSC7JSValueE;
 _ZN7WebCore9JSElement10putVirtualEPN3JSC9ExecStateERKNS1_10IdentifierENS1_7JSValueERNS1_15PutPropertySlotE;
 _ZN7WebCore9JSElement6s_infoE;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to