Source/WebCore: Add an internal flag to accept multiple shadow roots for the purpose...
authorshinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2012 00:57:19 +0000 (00:57 +0000)
committershinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2012 00:57:19 +0000 (00:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78453

Reviewed by Hajime Morita.

This patch introduces a flag to enable multiple shadow subtrees.
This flag is intended to be used for testing purpose for a while.
We will remove it later.

No new tests, no change in behavior.

* WebCore.exp.in:
* bindings/generic/RuntimeEnabledFeatures.cpp:
(WebCore):
* bindings/generic/RuntimeEnabledFeatures.h:
(RuntimeEnabledFeatures):
(WebCore::RuntimeEnabledFeatures::multipleShadowSubtreesEnabled):
(WebCore::RuntimeEnabledFeatures::setMultipleShadowSubtreesEnabled):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::create):
* dom/ShadowRootList.cpp:
(WebCore::ShadowRootList::pushShadowRoot):
* testing/Internals.cpp:
(WebCore::Internals::setMultipleShadowSubtreesEnabled):
(WebCore):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

LayoutTests: Needs an internal flag to accept multiple shadow roots for the purpose of tests
https://bugs.webkit.org/show_bug.cgi?id=78453

Reviewed by Hajime Morita.

* fast/dom/shadow/shadow-root-js-api.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108003 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/shadow/shadow-root-js-api.html
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRootList.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index 7e53994..a80e803 100644 (file)
@@ -1,3 +1,12 @@
+2012-02-15  Shinya Kawanaka  <shinyak@chromium.org>
+
+        Needs an internal flag to accept multiple shadow roots for the purpose of tests
+        https://bugs.webkit.org/show_bug.cgi?id=78453
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/shadow/shadow-root-js-api.html:
+
 2012-02-16  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         Fix the broken viewport tests
index 26337cf..6284dd3 100644 (file)
@@ -57,6 +57,18 @@ shouldBe("shadowRoot.querySelector('.class2')", "div2");
 shouldBeNull("shadowRoot.querySelector('.foo')");
 shouldBe("shadowRoot.querySelectorAll('div')", "[div1, div2]");
 shouldBe("shadowRoot.querySelectorAll('foo')", "[]");
+
+if (window.internals) {
+   window.internals.setMultipleShadowSubtreesEnabled(true);
+
+   // FIXME: Enable this test after Element's setShadowRoot should be replaced with ShadowRootList.
+   // https://bugs.webkit.org/show_bug.cgi?id=78313
+   // var youngerShadowRoot = new WebKitShadowRoot(shadowHost);
+   // shouldNotBe("youngerShadowRoot", "shadowRoot");
+
+   window.internals.setMultipleShadowSubtreesEnabled(false);
+}
+
 </script>
 <script src="../../js/resources/js-test-post.js"></script>
 </body>
index 04260db..8ed4ea0 100644 (file)
@@ -1,3 +1,34 @@
+2012-02-15  Shinya Kawanaka  <shinyak@chromium.org>
+
+        Add an internal flag to accept multiple shadow roots for the purpose of tests.
+        https://bugs.webkit.org/show_bug.cgi?id=78453
+
+        Reviewed by Hajime Morita.
+
+        This patch introduces a flag to enable multiple shadow subtrees.
+        This flag is intended to be used for testing purpose for a while.
+        We will remove it later.
+
+        No new tests, no change in behavior.
+
+        * WebCore.exp.in:
+        * bindings/generic/RuntimeEnabledFeatures.cpp:
+        (WebCore):
+        * bindings/generic/RuntimeEnabledFeatures.h:
+        (RuntimeEnabledFeatures):
+        (WebCore::RuntimeEnabledFeatures::multipleShadowSubtreesEnabled):
+        (WebCore::RuntimeEnabledFeatures::setMultipleShadowSubtreesEnabled):
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::create):
+        * dom/ShadowRootList.cpp:
+        (WebCore::ShadowRootList::pushShadowRoot):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setMultipleShadowSubtreesEnabled):
+        (WebCore):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-02-16  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         Fix the broken viewport tests
index 65b8c56..e52cd29 100644 (file)
@@ -2091,3 +2091,7 @@ __ZNK7WebCore20ScrollingCoordinator13scrollingTreeEv
 #endif
 
 __ZNK7WebCore4Node31numberOfScopedHTMLStyleChildrenEv
+
+#if ENABLE(SHADOW_DOM)
+__ZN7WebCore22RuntimeEnabledFeatures32setMultipleShadowSubtreesEnabledEb
+#endif
index 59e8b0f..78f8d91 100644 (file)
@@ -182,6 +182,7 @@ bool RuntimeEnabledFeatures::isMediaSourceEnabled = false;
 
 #if ENABLE(SHADOW_DOM)
 bool RuntimeEnabledFeatures::isShadowDOMEnabled = false;
+bool RuntimeEnabledFeatures::isMultipleShadowSubtreesEnabled = false;
 #endif
 
 } // namespace WebCore
index 6732cb1..5fa060b 100644 (file)
@@ -194,6 +194,9 @@ public:
 #if ENABLE(SHADOW_DOM)
     static bool shadowDOMEnabled() { return isShadowDOMEnabled; }
     static void setShadowDOMEnabled(bool isEnabled) { isShadowDOMEnabled = isEnabled; }
+
+    static bool multipleShadowSubtreesEnabled() { return isMultipleShadowSubtreesEnabled; }
+    static void setMultipleShadowSubtreesEnabled(bool isEnabled) { isMultipleShadowSubtreesEnabled = isEnabled; }
 #endif
 
 private:
@@ -255,6 +258,7 @@ private:
 
 #if ENABLE(SHADOW_DOM)
     static bool isShadowDOMEnabled;
+    static bool isMultipleShadowSubtreesEnabled;
 #endif
 };
 
index ef9ff01..ed90f0f 100644 (file)
 #include "HTMLContentSelector.h"
 #include "HTMLNames.h"
 #include "NodeRareData.h"
+#include "ShadowRootList.h"
 #include "SVGNames.h"
 #include "Text.h"
 
+#if ENABLE(SHADOW_DOM)
+#include "RuntimeEnabledFeatures.h"
+#endif
+
 namespace WebCore {
 
 ShadowRoot::ShadowRoot(Document* document)
@@ -97,7 +102,13 @@ PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ExceptionCode& ec)
 
 PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ShadowRootCreationPurpose purpose, ExceptionCode& ec)
 {
-    if (!element || element->hasShadowRoot()) {
+#if ENABLE(SHADOW_DOM)
+    bool isMultipleShadowSubtreesEnabled = RuntimeEnabledFeatures::multipleShadowSubtreesEnabled();
+#else
+    bool isMultipleShadowSubtreesEnabled = false;
+#endif
+
+    if (!element || (!isMultipleShadowSubtreesEnabled && element->hasShadowRoot())) {
         ec = HIERARCHY_REQUEST_ERR;
         return 0;
     }
index d79ebcb..d1955aa 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "Document.h"
 #include "Element.h"
+#include "RuntimeEnabledFeatures.h"
 #include "ShadowRoot.h"
 
 namespace WebCore {
@@ -44,9 +45,12 @@ ShadowRootList::~ShadowRootList()
 
 void ShadowRootList::pushShadowRoot(ShadowRoot* shadowRoot)
 {
-    // FIXME: We don't support multiple shadow root subtrees yet.
-    // https://bugs.webkit.org/show_bug.chi?id=77503
+#if ENABLE(SHADOW_DOM)
+    if (!RuntimeEnabledFeatures::multipleShadowSubtreesEnabled())
+        ASSERT(!hasShadowRoot());
+#else
     ASSERT(!hasShadowRoot());
+#endif
 
     m_shadowRoots.push(shadowRoot);
 }
index 9edbc6d..15620cd 100644 (file)
 #include "SpellChecker.h"
 #include "TextIterator.h"
 
+#if ENABLE(SHADOW_DOM)
+#include "RuntimeEnabledFeatures.h"
+#else
+#include <wtf/UnusedParam.h>
+#endif
+
 #if ENABLE(INPUT_COLOR)
 #include "ColorChooser.h"
 #endif
@@ -235,6 +241,15 @@ void Internals::removeShadowRoot(Element* host, ExceptionCode& ec)
     host->removeShadowRoot();
 }
 
+void Internals::setMultipleShadowSubtreesEnabled(bool enabled)
+{
+#if ENABLE(SHADOW_DOM)
+    RuntimeEnabledFeatures::setMultipleShadowSubtreesEnabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
+}
+
 Element* Internals::includerFor(Node* node, ExceptionCode& ec)
 {
     if (!node) {
index bf8ad23..7cdee17 100644 (file)
@@ -69,6 +69,7 @@ public:
     ShadowRootIfShadowDOMEnabledOrNode* youngestShadowRoot(Element* host, ExceptionCode&);
     ShadowRootIfShadowDOMEnabledOrNode* oldestShadowRoot(Element* host, ExceptionCode&);
     void removeShadowRoot(Element* host, ExceptionCode&);
+    void setMultipleShadowSubtreesEnabled(bool);
     Element* includerFor(Node*, ExceptionCode&);
     String shadowPseudoId(Element*, ExceptionCode&);
     PassRefPtr<Element> createContentElement(Document*, ExceptionCode&);
index 96a23a7..65da629 100644 (file)
@@ -43,6 +43,7 @@ module window {
         Node youngestShadowRoot(in Element host) raises (DOMException);
         Node oldestShadowRoot(in Element host) raises (DOMException);
 #endif
+        void setMultipleShadowSubtreesEnabled(in boolean enabled);
         Element includerFor(in Node node) raises (DOMException);
         void removeShadowRoot(in Element host) raises (DOMException);
         DOMString shadowPseudoId(in Element element) raises (DOMException);