Title: [135693] trunk
Revision
135693
Author
[email protected]
Date
2012-11-26 01:38:43 -0800 (Mon, 26 Nov 2012)

Log Message

[Shadow DOM] Implement Element::createShadowRoot()
https://bugs.webkit.org/show_bug.cgi?id=102911

Reviewed by Kentaro Hara.

Source/WebCore:

Added an API implementation and exposed it.

This is basically an alias of the ShadowRoot constructor, which
will be removed as bug 102913.

Test: fast/dom/shadow/shadow-aware-create-shdow-root.html

* bindings/gobject/GNUmakefile.am:
* dom/Element.cpp:
(WebCore::Element::createShadowRoot):
(WebCore):
* dom/Element.h:
(Element):
* dom/Element.idl:

LayoutTests:

The coverage might not seem comprehensive at a glance. However,
this is just an alias of ShadowRoot constructor and there are
bunch of test cases which cover it.

As bug 102913 will convert such callsites to use createShadowRoot(),
the API will get be covered well then.

* fast/dom/shadow/shadow-aware-create-shdow-root-expected.txt: Added.
* fast/dom/shadow/shadow-aware-create-shdow-root.html: Added.
  Further ShadowAware API will come here.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (135692 => 135693)


--- trunk/LayoutTests/ChangeLog	2012-11-26 09:27:28 UTC (rev 135692)
+++ trunk/LayoutTests/ChangeLog	2012-11-26 09:38:43 UTC (rev 135693)
@@ -1,3 +1,21 @@
+2012-11-26  Hajime Morrita  <[email protected]>
+
+        [Shadow DOM] Implement Element::createShadowRoot()
+        https://bugs.webkit.org/show_bug.cgi?id=102911
+
+        Reviewed by Kentaro Hara.
+
+        The coverage might not seem comprehensive at a glance. However,
+        this is just an alias of ShadowRoot constructor and there are
+        bunch of test cases which cover it.
+
+        As bug 102913 will convert such callsites to use createShadowRoot(),
+        the API will get be covered well then.
+
+        * fast/dom/shadow/shadow-aware-create-shdow-root-expected.txt: Added.
+        * fast/dom/shadow/shadow-aware-create-shdow-root.html: Added.
+          Further ShadowAware API will come here.
+
 2012-11-26  Alexander Pavlov  <[email protected]>
 
         [Chromium] Unreviewed, mark platform/chromium/fast/forms/calendar-picker/week-picker-key-operations.html as flaky (date-dependent).

Added: trunk/LayoutTests/fast/dom/shadow/shadow-aware-create-shadow-root-expected.txt (0 => 135693)


--- trunk/LayoutTests/fast/dom/shadow/shadow-aware-create-shadow-root-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-aware-create-shadow-root-expected.txt	2012-11-26 09:38:43 UTC (rev 135693)
@@ -0,0 +1,13 @@
+Tests for ShadowAware JS APIs.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS root1.constructor is window.WebKitShadowRoot
+PASS root1 is not root2
+PASS root1 is window.internals.oldestShadowRoot(host)
+PASS root2 is window.internals.youngestShadowRoot(host)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/shadow-aware-create-shadow-root.html (0 => 135693)


--- trunk/LayoutTests/fast/dom/shadow/shadow-aware-create-shadow-root.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-aware-create-shadow-root.html	2012-11-26 09:38:43 UTC (rev 135693)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Tests for ShadowAware JS APIs.");
+
+// ShadowAware.createShadowRoot()
+var host = document.createElement('div');
+var root1 = host.createShadowRoot();
+var root2 = host.createShadowRoot();
+shouldBe("root1.constructor", "window.WebKitShadowRoot");
+shouldNotBe("root1", "root2");
+shouldBe("root1", "window.internals.oldestShadowRoot(host)");
+shouldBe("root2", "window.internals.youngestShadowRoot(host)");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (135692 => 135693)


--- trunk/Source/WebCore/ChangeLog	2012-11-26 09:27:28 UTC (rev 135692)
+++ trunk/Source/WebCore/ChangeLog	2012-11-26 09:38:43 UTC (rev 135693)
@@ -1,3 +1,25 @@
+2012-11-26  Hajime Morrita  <[email protected]>
+
+        [Shadow DOM] Implement Element::createShadowRoot()
+        https://bugs.webkit.org/show_bug.cgi?id=102911
+
+        Reviewed by Kentaro Hara.
+
+        Added an API implementation and exposed it.
+
+        This is basically an alias of the ShadowRoot constructor, which
+        will be removed as bug 102913.
+
+        Test: fast/dom/shadow/shadow-aware-create-shdow-root.html
+
+        * bindings/gobject/GNUmakefile.am:
+        * dom/Element.cpp:
+        (WebCore::Element::createShadowRoot):
+        (WebCore):
+        * dom/Element.h:
+        (Element):
+        * dom/Element.idl:
+
 2012-11-26  Jon Lee  <[email protected]>
 
         Extend EventDispatcher::dispatchSimulatedClick to allow sending a mouseover event

Modified: trunk/Source/WebCore/bindings/gobject/GNUmakefile.am (135692 => 135693)


--- trunk/Source/WebCore/bindings/gobject/GNUmakefile.am	2012-11-26 09:27:28 UTC (rev 135692)
+++ trunk/Source/WebCore/bindings/gobject/GNUmakefile.am	2012-11-26 09:38:43 UTC (rev 135693)
@@ -237,6 +237,8 @@
 	DerivedSources/webkit/WebKitDOMRangePrivate.h \
 	DerivedSources/webkit/WebKitDOMScreen.cpp \
 	DerivedSources/webkit/WebKitDOMScreenPrivate.h \
+	DerivedSources/webkit/WebKitDOMShadowRoot.cpp \
+	DerivedSources/webkit/WebKitDOMShadowRootPrivate.h \
 	DerivedSources/webkit/WebKitDOMStorage.cpp \
 	DerivedSources/webkit/WebKitDOMStorageInfo.cpp \
 	DerivedSources/webkit/WebKitDOMStorageInfoPrivate.h \

Modified: trunk/Source/WebCore/dom/Element.cpp (135692 => 135693)


--- trunk/Source/WebCore/dom/Element.cpp	2012-11-26 09:27:28 UTC (rev 135692)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-11-26 09:38:43 UTC (rev 135693)
@@ -1440,6 +1440,11 @@
     return data->m_shadow.get();
 }
 
+PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionCode& ec)
+{
+    return ShadowRoot::create(this, ec);
+}
+
 ShadowRoot* Element::userAgentShadowRoot() const
 {
     if (ElementShadow* elementShadow = shadow()) {

Modified: trunk/Source/WebCore/dom/Element.h (135692 => 135693)


--- trunk/Source/WebCore/dom/Element.h	2012-11-26 09:27:28 UTC (rev 135692)
+++ trunk/Source/WebCore/dom/Element.h	2012-11-26 09:38:43 UTC (rev 135693)
@@ -275,6 +275,8 @@
 
     ElementShadow* shadow() const;
     ElementShadow* ensureShadow();
+    PassRefPtr<ShadowRoot> createShadowRoot(ExceptionCode&);
+
     virtual void willAddAuthorShadowRoot() { }
     virtual bool areAuthorShadowsAllowed() const { return true; }
 

Modified: trunk/Source/WebCore/dom/Element.idl (135692 => 135693)


--- trunk/Source/WebCore/dom/Element.idl	2012-11-26 09:27:28 UTC (rev 135692)
+++ trunk/Source/WebCore/dom/Element.idl	2012-11-26 09:38:43 UTC (rev 135693)
@@ -119,8 +119,10 @@
     readonly attribute Element nextElementSibling;
     readonly attribute unsigned long childElementCount;
 
-#if defined(ENABLE_SHADOW_DOM)
+    // ShadowAware API
+#if defined(ENABLE_SHADOW_DOM) && ENABLE_SHADOW_DOM
     [Reflect, V8EnabledAtRuntime=shadowDOM] attribute DOMString pseudo;
+    [V8EnabledAtRuntime=shadowDOM] ShadowRoot createShadowRoot() raises(DOMException);
 #endif
 
     // DOM 4
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to