Title: [106208] trunk
Revision
106208
Author
[email protected]
Date
2012-01-29 19:47:32 -0800 (Sun, 29 Jan 2012)

Log Message

Add a ShadowRoot constructor as 'WebKitShadowRootConstructor', enabled by SHADOW_DOM flag.
https://bugs.webkit.org/show_bug.cgi?id=76354

Reviewed by Hajime Morita.

We use vendor-prefixed name, 'WebKitShadowRoot', instead of 'ShadowRoot'
since this is a feature under development.

Source/WebCore:

* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::create):
(WebCore):
* dom/ShadowRoot.h:
(WebCore):
(ShadowRoot):
* dom/ShadowRoot.idl:
* page/DOMWindow.idl:

LayoutTests:

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106207 => 106208)


--- trunk/LayoutTests/ChangeLog	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/LayoutTests/ChangeLog	2012-01-30 03:47:32 UTC (rev 106208)
@@ -1,3 +1,15 @@
+2012-01-29  Hayato Ito  <[email protected]>
+
+        Add a ShadowRoot constructor as 'WebKitShadowRootConstructor', enabled by SHADOW_DOM flag.
+        https://bugs.webkit.org/show_bug.cgi?id=76354
+
+        Reviewed by Hajime Morita.
+
+        We use vendor-prefixed name, 'WebKitShadowRoot', instead of 'ShadowRoot'
+        since this is a feature under development.
+
+        * fast/dom/shadow/shadow-root-js-api.html:
+
 2012-01-29  Yuzo Fujishima  <[email protected]>
 
         [Chromium] Unreviewed test expectation change.

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt (106207 => 106208)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt	2012-01-30 03:47:32 UTC (rev 106208)
@@ -3,7 +3,14 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS new WebKitShadowRoot() threw exception TypeError: Not enough arguments.
+PASS new WebKitShadowRoot(undefined) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+PASS new WebKitShadowRoot(null) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+PASS new WebKitShadowRoot(1) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
 PASS shadowHost is shadowRoot.host
+PASS new WebKitShadowRoot(shadowHost) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+The previous test should not have side effects.
+PASS shadowHost is shadowRoot.host
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html (106207 => 106208)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html	2012-01-30 03:47:32 UTC (rev 106208)
@@ -10,10 +10,16 @@
 
 if (window.layoutTestController)
     layoutTestController.dumpAsText();
+shouldThrow("new WebKitShadowRoot()");
+shouldThrow("new WebKitShadowRoot(undefined)");
+shouldThrow("new WebKitShadowRoot(null)");
+shouldThrow("new WebKitShadowRoot(1)");
 var shadowHost = document.createElement('div');
-internals.ensureShadowRoot(shadowHost);
-var shadowRoot = internals.shadowRoot(shadowHost);
+var shadowRoot = new WebKitShadowRoot(shadowHost);
 shouldBe("shadowHost", "shadowRoot.host");
+shouldThrow("new WebKitShadowRoot(shadowHost)");
+debug('The previous test should not have side effects.');
+shouldBe("shadowHost", "shadowRoot.host");
 
 </script>
 <script src=""

Modified: trunk/Source/WebCore/ChangeLog (106207 => 106208)


--- trunk/Source/WebCore/ChangeLog	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/Source/WebCore/ChangeLog	2012-01-30 03:47:32 UTC (rev 106208)
@@ -1,3 +1,22 @@
+2012-01-29  Hayato Ito  <[email protected]>
+
+        Add a ShadowRoot constructor as 'WebKitShadowRootConstructor', enabled by SHADOW_DOM flag.
+        https://bugs.webkit.org/show_bug.cgi?id=76354
+
+        Reviewed by Hajime Morita.
+
+        We use vendor-prefixed name, 'WebKitShadowRoot', instead of 'ShadowRoot'
+        since this is a feature under development.
+
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::create):
+        (WebCore):
+        * dom/ShadowRoot.h:
+        (WebCore):
+        (ShadowRoot):
+        * dom/ShadowRoot.idl:
+        * page/DOMWindow.idl:
+
 2012-01-29  Noel Gordon  <[email protected]>
 
         [chromium] Use decoding swizzle only on libjpeg-turbo 1.1.90+

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (106207 => 106208)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-01-30 03:47:32 UTC (rev 106208)
@@ -53,6 +53,19 @@
 {
 }
 
+PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ExceptionCode& ec)
+{
+    if (!element || element->shadowRoot()) {
+        ec = HIERARCHY_REQUEST_ERR;
+        return 0;
+    }
+    RefPtr<ShadowRoot> shadowRoot = create(element->document());
+    element->setShadowRoot(shadowRoot, ec);
+    if (ec)
+        return 0;
+    return shadowRoot.release();
+}
+
 String ShadowRoot::nodeName() const
 {
     return "#shadow-root";

Modified: trunk/Source/WebCore/dom/ShadowRoot.h (106207 => 106208)


--- trunk/Source/WebCore/dom/ShadowRoot.h	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/Source/WebCore/dom/ShadowRoot.h	2012-01-30 03:47:32 UTC (rev 106208)
@@ -27,17 +27,19 @@
 #ifndef ShadowRoot_h
 #define ShadowRoot_h
 
+#include "ExceptionCode.h"
 #include "TreeScope.h"
 
 namespace WebCore {
 
+class ContentInclusionSelector;
 class Document;
 class HTMLContentElement;
-class ContentInclusionSelector;
 
 class ShadowRoot : public TreeScope {
 public:
     static PassRefPtr<ShadowRoot> create(Document*);
+    static PassRefPtr<ShadowRoot> create(Element*, ExceptionCode&);
 
     void recalcShadowTreeStyle(StyleChange);
 

Modified: trunk/Source/WebCore/dom/ShadowRoot.idl (106207 => 106208)


--- trunk/Source/WebCore/dom/ShadowRoot.idl	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/Source/WebCore/dom/ShadowRoot.idl	2012-01-30 03:47:32 UTC (rev 106208)
@@ -28,7 +28,9 @@
 
     interface [
         Conditional=SHADOW_DOM,
-        EnabledAtRuntime=shadowDOM
+        EnabledAtRuntime=shadowDOM,
+        Constructor(in Element host),
+        ConstructorRaisesException
     ] ShadowRoot : Node {
         readonly attribute Element host;
     };

Modified: trunk/Source/WebCore/page/DOMWindow.idl (106207 => 106208)


--- trunk/Source/WebCore/page/DOMWindow.idl	2012-01-30 02:39:14 UTC (rev 106207)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2012-01-30 03:47:32 UTC (rev 106208)
@@ -398,6 +398,7 @@
         attribute EntityConstructor Entity;
         attribute EntityReferenceConstructor EntityReference;
         attribute ProcessingInstructionConstructor ProcessingInstruction;
+        attribute [Conditional=SHADOW_DOM, EnabledAtRuntime=shadowDOM] ShadowRootConstructor WebKitShadowRoot;
 
         attribute HTMLDocumentConstructor HTMLDocument;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to