2011-04-20 Dominic Cooney <dominicc@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Apr 2011 06:33:42 +0000 (06:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Apr 2011 06:33:42 +0000 (06:33 +0000)
        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Exercise the new layoutTestController methods.

        * fast/dom/shadow/layout-tests-can-access-shadow-expected.txt: Added.
        * fast/dom/shadow/layout-tests-can-access-shadow.html: Added.
2011-04-20  Dominic Cooney  <dominicc@chromium.org>

        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Test: fast/dom/shadow/layout-tests-can-access-shadow.html

        * WebCore.exp.in: Mac DRT needs to see Element::ensure/removeShadowRoot
2011-04-20  Dominic Cooney  <dominicc@chromium.org>

        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Chromium DRT relies on the Chromium WebKit API

        * public/WebElement.h:
        * src/WebElement.cpp:
        (WebKit::WebElement::shadowRoot): don't steal a zero refcount
        (WebKit::WebElement::ensureShadowRoot): added
        (WebKit::WebElement::removeShadowRoot): added
2011-04-20  Dominic Cooney  <dominicc@chromium.org>

        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Support for new methods in GTK DRT.

        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
        (DumpRenderTreeSupportGtk::ensureShadowRoot):
        (DumpRenderTreeSupportGtk::removeShadowRoot):
        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
2011-04-20  Dominic Cooney  <dominicc@chromium.org>

        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Support for new methods in Mac DRT.

        * DOM/WebDOMOperations.mm:
        (-[DOMElement _ensureShadowRoot:]):
        (-[DOMElement _removeShadowRoot]):
        * DOM/WebDOMOperationsPrivate.h:
2011-04-20  Dominic Cooney  <dominicc@chromium.org>

        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Support for new methods in Qt DRT.

        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
        (DumpRenderTreeSupportQt::ensureShadowRoot):
        (DumpRenderTreeSupportQt::removeShadowRoot):
        * WebCoreSupport/DumpRenderTreeSupportQt.h:
2011-04-20  Dominic Cooney  <dominicc@chromium.org>

        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Support for new methods in WK2 WebKitTestRunner.

        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
        (WKBundleNodeHandleCopyElementEnsureShadowRoot):
        (WKBundleNodeHandleRemoveShadowRoot):
        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
        (WebKit::InjectedBundleNodeHandle::elementShadowRoot):
        (WebKit::InjectedBundleNodeHandle::elementEnsureShadowRoot):
        (WebKit::InjectedBundleNodeHandle::elementRemoveShadowRoot):
        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
2011-04-20  Dominic Cooney  <dominicc@chromium.org>

        Reviewed by Dimitri Glazkov.

        layoutTestController can create and destroy shadow DOM
        https://bugs.webkit.org/show_bug.cgi?id=59058

        Chromium, Mac, GTK and Qt DRT; and WK2 test runner.

        * DumpRenderTree/LayoutTestController.cpp:
        (ensureShadowRootCallback):
        (removeShadowRootCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (LayoutTestController::ensureShadowRoot):
        (LayoutTestController::removeShadowRoot):
        * DumpRenderTree/chromium/LayoutTestController.h:
        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
        (LayoutTestController::ensureShadowRoot):
        (LayoutTestController::removeShadowRoot):
        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
        (LayoutTestController::shadowRoot):
        (LayoutTestController::ensureShadowRoot):
        (LayoutTestController::removeShadowRoot):
        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
        (LayoutTestController::ensureShadowRoot):
        (LayoutTestController::removeShadowRoot):
        * DumpRenderTree/qt/LayoutTestControllerQt.h:
        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
        (LayoutTestController::ensureShadowRoot):
        (LayoutTestController::removeShadowRoot):
        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
        (WTR::LayoutTestController::shadowRoot):
        (WTR::LayoutTestController::ensureShadowRoot):
        (WTR::LayoutTestController::removeShadowRoot):
        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:

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

35 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/shadow/layout-tests-can-access-shadow-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/shadow/layout-tests-can-access-shadow.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebElement.h
Source/WebKit/chromium/src/WebElement.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DOM/WebDOMOperations.mm
Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h
Tools/ChangeLog
Tools/DumpRenderTree/LayoutTestController.cpp
Tools/DumpRenderTree/LayoutTestController.h
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h
Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm
Tools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
Tools/DumpRenderTree/qt/LayoutTestControllerQt.h
Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h

index cd07153..7f98ff2 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Exercise the new layoutTestController methods.
+
+        * fast/dom/shadow/layout-tests-can-access-shadow-expected.txt: Added.
+        * fast/dom/shadow/layout-tests-can-access-shadow.html: Added.
+
 2011-04-20  Dirk Pranke  <dpranke@chromium.org>
 
         Make video/image-zoom fail on GPU on all ports.
diff --git a/LayoutTests/fast/dom/shadow/layout-tests-can-access-shadow-expected.txt b/LayoutTests/fast/dom/shadow/layout-tests-can-access-shadow-expected.txt
new file mode 100644 (file)
index 0000000..193f43c
--- /dev/null
@@ -0,0 +1,13 @@
+
+This tests that LayoutTestController can access shadow DOM.
+
+PASS shadow.nodeName is "#shadow-root"
+PASS layoutTestController.shadowRoot(shadow) is null
+PASS layoutTestController.shadowRoot(p) is null
+PASS shadow.nodeName is "#shadow-root"
+PASS shadow === layoutTestController.shadowRoot(p) is true
+PASS layoutTestController.shadowRoot(keygen) is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/shadow/layout-tests-can-access-shadow.html b/LayoutTests/fast/dom/shadow/layout-tests-can-access-shadow.html
new file mode 100644 (file)
index 0000000..64c0feb
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<keygen id="keys" />
+<p id="peas" />
+<pre id="console">
+This tests that LayoutTestController can access shadow DOM.
+
+</pre>
+<script>
+if (window.layoutTestController) {
+    // Make assertions about a built-in shadow
+    var keygen = document.getElementById('keys');
+    var shadow = layoutTestController.shadowRoot(keygen);
+    shouldBe('shadow.nodeName', '"#shadow-root"');
+
+    // Shadow roots should not have shadows
+    shouldBe('layoutTestController.shadowRoot(shadow)', 'null');
+
+    // Ordinary element should not have shadow
+    var p = document.getElementById('peas');
+    shouldBe('layoutTestController.shadowRoot(p)', 'null');
+
+    // LayoutTestController can bless ordinary elements with shadows
+    shadow = layoutTestController.ensureShadowRoot(p);
+    shouldBe('shadow.nodeName', '"#shadow-root"');
+    shouldBe('shadow === layoutTestController.shadowRoot(p)', 'true');
+
+    // LayoutTestController can strip elements of shadows
+    layoutTestController.removeShadowRoot(keygen);
+    shouldBe('layoutTestController.shadowRoot(keygen)', 'null');
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 3450cce..d061ea9 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Test: fast/dom/shadow/layout-tests-can-access-shadow.html
+
+        * WebCore.exp.in: Mac DRT needs to see Element::ensure/removeShadowRoot
+
 2011-04-20  Pratik Solanki  <psolanki@apple.com>
 
         Reviewed by Ryosuke Niwa.
index 718f775..4ca6bae 100644 (file)
@@ -802,6 +802,8 @@ __ZN7WebCore6WidgetD2Ev
 __ZN7WebCore6toNodeEN3JSC7JSValueE
 __ZN7WebCore7Console21shouldPrintExceptionsEv
 __ZN7WebCore7Console24setShouldPrintExceptionsEb
+__ZN7WebCore7Element16ensureShadowRootEv
+__ZN7WebCore7Element16removeShadowRootEv
 __ZN7WebCore7IntRect5scaleEf
 __ZN7WebCore7IntRect5uniteERKS0_
 __ZN7WebCore7IntRect9intersectERKS0_
index 9b251cd..3f42bb1 100644 (file)
@@ -1,3 +1,18 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Chromium DRT relies on the Chromium WebKit API
+
+        * public/WebElement.h:
+        * src/WebElement.cpp:
+        (WebKit::WebElement::shadowRoot): don't steal a zero refcount
+        (WebKit::WebElement::ensureShadowRoot): added
+        (WebKit::WebElement::removeShadowRoot): added
+
 2011-04-20  Alexey Marinichev  <amarinichev@chromium.org>
 
         Reviewed by Kenneth Russell.
index 2072dd3..53b6aa3 100644 (file)
@@ -58,7 +58,10 @@ class WebNamedNodeMap;
         WEBKIT_API bool setAttribute(const WebString& name, const WebString& value);
         WEBKIT_API WebNamedNodeMap attributes() const;
         WEBKIT_API WebString innerText() const;
+
         WEBKIT_API WebNode shadowRoot();
+        WEBKIT_API WebNode ensureShadowRoot();
+        WEBKIT_API void removeShadowRoot();
 
         // Returns the language code specified for this element.  This attribute
         // is inherited, so the returned value is drawn from the closest parent
index 66e3e95..f9c1f0d 100644 (file)
@@ -92,7 +92,17 @@ WebString WebElement::innerText() const
 
 WebNode WebElement::shadowRoot()
 {
-    return adoptRef(static_cast<Node*>(unwrap<Element>()->shadowRoot()));
+    return PassRefPtr<Node>(static_cast<Node*>(unwrap<Element>()->shadowRoot()));
+}
+
+WebNode WebElement::ensureShadowRoot()
+{
+    return PassRefPtr<Node>(static_cast<Node*>(unwrap<Element>()->ensureShadowRoot()));
+}
+
+void WebElement::removeShadowRoot()
+{
+    unwrap<Element>()->removeShadowRoot();
 }
 
 WebString WebElement::computeInheritedLanguage() const
index f1531d5..76e365c 100644 (file)
@@ -1,3 +1,17 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Support for new methods in GTK DRT.
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::ensureShadowRoot):
+        (DumpRenderTreeSupportGtk::removeShadowRoot):
+        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
+
 2011-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Reviewed by Martin Robinson.
index 1ce0ada..69f1ed6 100644 (file)
@@ -664,6 +664,28 @@ JSValueRef DumpRenderTreeSupportGtk::shadowRoot(JSContextRef context, JSValueRef
     return toRef(exec, toJS(exec, element->shadowRoot()));
 }
 
+JSValueRef DumpRenderTreeSupportGtk::ensureShadowRoot(JSContextRef context, JSValueRef value)
+{
+    JSLock lock(SilenceAssertionsOnly);
+    JSC::ExecState* exec = toJS(context);
+    Element* element = toElement(toJS(exec, value));
+    if (!element)
+        return JSValueMakeNull(context);
+
+    return toRef(exec, toJS(exec, element->ensureShadowRoot()));
+}
+
+void DumpRenderTreeSupportGtk::removeShadowRoot(JSContextRef context, JSValueRef value)
+{
+    JSLock lock(SilenceAssertionsOnly);
+    JSC::ExecState* exec = toJS(context);
+    Element* element = toElement(toJS(exec, value));
+    if (!element)
+        return;
+
+    element->removeShadowRoot();
+}
+
 unsigned int DumpRenderTreeSupportGtk::workerThreadCount()
 {
 #if ENABLE(WORKERS)
index 7731798..5d0afb5 100644 (file)
@@ -60,6 +60,9 @@ public:
     static void clearOpener(WebKitWebFrame*);
 
     static JSValueRef shadowRoot(JSContextRef, JSValueRef);
+    static JSValueRef ensureShadowRoot(JSContextRef, JSValueRef);
+    static void removeShadowRoot(JSContextRef, JSValueRef);
+
     static WebKitDOMRange* jsValueToDOMRange(JSContextRef, JSValueRef);
 
     // FIXME: Move these to webkitwebframe.h once their API has been discussed.
index d52dead..b6ca1b6 100644 (file)
@@ -1,3 +1,17 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Support for new methods in Mac DRT.
+
+        * DOM/WebDOMOperations.mm:
+        (-[DOMElement _ensureShadowRoot:]):
+        (-[DOMElement _removeShadowRoot]):
+        * DOM/WebDOMOperationsPrivate.h:
+
 2011-04-20  Eric Carlson  <eric.carlson@apple.com>
 
         Reviewed by Dan Bernstein.
index 20e9ace..7a7e049 100644 (file)
@@ -81,6 +81,18 @@ using namespace JSC;
     return toRef(execState, toJS(execState, core(self)->shadowRoot()));
 }
 
+- (JSValueRef)_ensureShadowRoot:(JSContextRef)context
+{
+    JSLock lock(SilenceAssertionsOnly);
+    ExecState* execState = toJS(context);
+    return toRef(execState, toJS(execState, core(self)->ensureShadowRoot()));
+}
+
+- (void)_removeShadowRoot
+{
+    core(self)->removeShadowRoot();
+}
+
 @end
 
 @implementation DOMNode (WebDOMNodeOperations)
index cd5ff20..b35af1d 100644 (file)
@@ -33,6 +33,8 @@
 + (DOMElement *)_DOMElementFromJSContext:(JSContextRef)context value:(JSValueRef)value;
 - (NSString *)_markerTextForListItem;
 - (JSValueRef)_shadowRoot:(JSContextRef)context;
+- (JSValueRef)_ensureShadowRoot:(JSContextRef)context;
+- (void)_removeShadowRoot;
 @end
 
 @interface DOMDocument (WebDOMDocumentOperationsPrivate)
index 02589b5..c16c812 100644 (file)
@@ -1,3 +1,17 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Support for new methods in Qt DRT.
+
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::ensureShadowRoot):
+        (DumpRenderTreeSupportQt::removeShadowRoot):
+        * WebCoreSupport/DumpRenderTreeSupportQt.h:
+
 2011-04-20  Balazs Kelemen  <kbalazs@webkit.org>
 
         Reviewed by Csaba Osztrogon√°c.
index 81102c3..55df562 100644 (file)
@@ -1077,6 +1077,23 @@ QVariant DumpRenderTreeSupportQt::shadowRoot(const QWebElement& element)
     return QVariant::fromValue(QDRTNode(webShadowRoot));
 }
 
+QVariant DumpRenderTreeSupportQt::ensureShadowRoot(const QWebElement& element)
+{
+    WebCore::Element* webElement = element.m_element;
+    if (!webElement)
+        return QVariant();
+
+    return QVariant::fromValue(QDRTNode(webElement->ensureShadowRoot()));
+}
+
+void DumpRenderTreeSupportQt::removeShadowRoot(const QWebElement& element)
+{
+    WebCore::Element* webElement = element.m_element;
+    if (!webElement)
+        return;
+    webElement->removeShadowRoot();
+}
+
 // Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release
 
 void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* frame)
index 4be6053..701434d 100644 (file)
@@ -202,6 +202,8 @@ public:
     static void setAlternateHtml(QWebFrame*, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl);
 
     static QVariant shadowRoot(const QWebElement&);
+    static QVariant ensureShadowRoot(const QWebElement&);
+    static void removeShadowRoot(const QWebElement&);
 };
 
 #endif
index 7c85e02..513ebca 100644 (file)
@@ -1,3 +1,22 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Support for new methods in WK2 WebKitTestRunner.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+        (WKBundleNodeHandleCopyElementEnsureShadowRoot):
+        (WKBundleNodeHandleRemoveShadowRoot):
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::InjectedBundleNodeHandle::elementShadowRoot):
+        (WebKit::InjectedBundleNodeHandle::elementEnsureShadowRoot):
+        (WebKit::InjectedBundleNodeHandle::elementRemoveShadowRoot):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
+
 2011-04-20  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index 292b022..60f970e 100644 (file)
@@ -67,6 +67,17 @@ WKBundleNodeHandleRef WKBundleNodeHandleCopyElementShadowRoot(WKBundleNodeHandle
     return toAPI(nodeHandle.release().releaseRef());
 }
 
+WKBundleNodeHandleRef WKBundleNodeHandleCopyElementEnsureShadowRoot(WKBundleNodeHandleRef elementHandleRef)
+{
+    RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(elementHandleRef)->elementEnsureShadowRoot();
+    return toAPI(nodeHandle.release().releaseRef());
+}
+
+void WKBundleNodeHandleRemoveShadowRoot(WKBundleNodeHandleRef elementHandleRef)
+{
+    toImpl(elementHandleRef)->elementRemoveShadowRoot();
+}
+
 void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandleRef, WKStringRef valueRef)
 {
     toImpl(htmlInputElementHandleRef)->setHTMLInputElementValueForUser(toWTFString(valueRef));
index 3655194..399b094 100644 (file)
@@ -47,6 +47,8 @@ WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandl
 /* Element Specific Operations */
 WK_EXPORT WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandle);
 WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyElementShadowRoot(WKBundleNodeHandleRef elementHandle);
+WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyElementEnsureShadowRoot(WKBundleNodeHandleRef elementHandle);
+WK_EXPORT void WKBundleNodeHandleRemoveShadowRoot(WKBundleNodeHandleRef elementHandle);
 
 /* HTMLInputElement Specific Operations */
 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value);
index bef3f90..e5787f5 100644 (file)
@@ -173,6 +173,22 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::elementShadowRoot
     return getOrCreate(static_cast<Element*>(m_node.get())->shadowRoot());
 }
 
+PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::elementEnsureShadowRoot()
+{
+    if (!m_node->isElementNode())
+        return 0;
+
+    return getOrCreate(static_cast<Element*>(m_node.get())->ensureShadowRoot());
+}
+
+void InjectedBundleNodeHandle::elementRemoveShadowRoot()
+{
+    if (!m_node->isElementNode())
+        return;
+
+    static_cast<Element*>(m_node.get())->removeShadowRoot();
+}
+
 PassRefPtr<WebFrame> InjectedBundleNodeHandle::documentFrame()
 {
     if (!m_node->isDocumentNode())
index e1003e8..af8eeb3 100644 (file)
@@ -69,6 +69,8 @@ public:
     PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove();
 
     PassRefPtr<InjectedBundleNodeHandle> elementShadowRoot();
+    PassRefPtr<InjectedBundleNodeHandle> elementEnsureShadowRoot();
+    void elementRemoveShadowRoot();
 
     PassRefPtr<WebFrame> documentFrame();
     PassRefPtr<WebFrame> htmlFrameElementContentFrame();
index acc7a49..fd48cc3 100644 (file)
@@ -1,3 +1,43 @@
+2011-04-20  Dominic Cooney  <dominicc@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        layoutTestController can create and destroy shadow DOM
+        https://bugs.webkit.org/show_bug.cgi?id=59058
+
+        Chromium, Mac, GTK and Qt DRT; and WK2 test runner.
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (ensureShadowRootCallback):
+        (removeShadowRootCallback):
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::ensureShadowRoot):
+        (LayoutTestController::removeShadowRoot):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::ensureShadowRoot):
+        (LayoutTestController::removeShadowRoot):
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::shadowRoot):
+        (LayoutTestController::ensureShadowRoot):
+        (LayoutTestController::removeShadowRoot):
+        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+        (LayoutTestController::ensureShadowRoot):
+        (LayoutTestController::removeShadowRoot):
+        * DumpRenderTree/qt/LayoutTestControllerQt.h:
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::ensureShadowRoot):
+        (LayoutTestController::removeShadowRoot):
+        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::shadowRoot):
+        (WTR::LayoutTestController::ensureShadowRoot):
+        (WTR::LayoutTestController::removeShadowRoot):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+
 2011-04-20  Dirk Pranke  <dpranke@chromium.org>
 
         Reviewed by Eric Seidel.
index 3105ce4..4ca90d8 100644 (file)
@@ -1715,6 +1715,25 @@ static JSValueRef shadowRootCallback(JSContextRef context, JSObjectRef function,
     return controller->shadowRoot(context, arguments[0]);
 }
 
+static JSValueRef ensureShadowRootCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount != 1)
+        return JSValueMakeUndefined(context);
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    return controller->ensureShadowRoot(context, arguments[0]);
+}
+
+static JSValueRef removeShadowRootCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount != 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->removeShadowRoot(context, arguments[0]);
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
@@ -2196,6 +2215,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "ensureShadowRoot", ensureShadowRootCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -2216,6 +2236,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "suspendAnimations", suspendAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "resumeAnimations", resumeAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "removeShadowRoot", removeShadowRootCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index a429dbf..a31e908 100644 (file)
@@ -122,7 +122,10 @@ public:
     void setSpatialNavigationEnabled(bool enable);
     void setScrollbarPolicy(JSStringRef orientation, JSStringRef policy);
     void setEditingBehavior(const char* editingBehavior);
+
     JSValueRef shadowRoot(JSContextRef, JSValueRef);
+    JSValueRef ensureShadowRoot(JSContextRef, JSValueRef);
+    void removeShadowRoot(JSContextRef, JSValueRef);
 
     void waitForPolicyDelegate();
     size_t webHistoryItemCount();
index 72c05b1..7ee8f5f 100644 (file)
@@ -105,6 +105,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("dumpStatusCallbacks", &LayoutTestController::dumpWindowStatusChanges);
     bindMethod("dumpTitleChanges", &LayoutTestController::dumpTitleChanges);
     bindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::elementDoesAutoCompleteForElementWithId);
+    bindMethod("ensureShadowRoot", &LayoutTestController::ensureShadowRoot);
     bindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspector);
     bindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScriptInIsolatedWorld);
     bindMethod("execCommand", &LayoutTestController::execCommand);
@@ -131,6 +132,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("queueNonLoadingScript", &LayoutTestController::queueNonLoadingScript);
     bindMethod("queueReload", &LayoutTestController::queueReload);
     bindMethod("removeOriginAccessWhitelistEntry", &LayoutTestController::removeOriginAccessWhitelistEntry);
+    bindMethod("removeShadowRoot", &LayoutTestController::removeShadowRoot);
     bindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHorizontally);
     bindMethod("resumeAnimations", &LayoutTestController::resumeAnimations);
     bindMethod("sampleSVGAnimationForElementAtTime", &LayoutTestController::sampleSVGAnimationForElementAtTime);
@@ -672,6 +674,34 @@ void LayoutTestController::shadowRoot(const CppArgumentList& arguments, CppVaria
     result->set(WebBindings::makeNode(shadowRoot));
 }
 
+void LayoutTestController::ensureShadowRoot(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() != 1 || !arguments[0].isObject()) {
+        result->setNull();
+        return;
+    }
+
+    WebElement element;
+    if (!WebBindings::getElement(arguments[0].value.objectValue, &element)) {
+        result->setNull();
+        return;
+    }
+
+    result->set(WebBindings::makeNode(element.ensureShadowRoot()));
+}
+
+void LayoutTestController::removeShadowRoot(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() != 1 || !arguments[0].isObject())
+        return;
+
+    WebElement element;
+    if (!WebBindings::getElement(arguments[0].value.objectValue, &element))
+        return;
+
+    element.removeShadowRoot();
+}
+
 void LayoutTestController::showWebInspector(const CppArgumentList&, CppVariant* result)
 {
     m_shell->showDevTools();
index 5df7153..44ac2cd 100644 (file)
@@ -272,6 +272,8 @@ public:
     void setAllowFileAccessFromFileURLs(const CppArgumentList&, CppVariant*);
 
     void shadowRoot(const CppArgumentList&, CppVariant*);
+    void ensureShadowRoot(const CppArgumentList&, CppVariant*);
+    void removeShadowRoot(const CppArgumentList&, CppVariant*);
 
     // The fallback method is called when a nonexistent method is called on
     // the layout test controller object.
index 29742be..e9404e9 100644 (file)
@@ -924,6 +924,16 @@ JSValueRef LayoutTestController::shadowRoot(JSContextRef context, JSValueRef ele
     return DumpRenderTreeSupportGtk::shadowRoot(context, element);
 }
 
+JSValueRef LayoutTestController::ensureShadowRoot(JSContextRef context, JSValueRef element)
+{
+    return DumpRenderTreeSupportGtk::ensureShadowRoot(context, element);
+}
+
+void LayoutTestController::removeShadowRoot(JSContextRef context, JSValueRef element)
+{
+    DumpRenderTreeSupportGtk::removeShadowRoot(context, element);
+}
+
 void LayoutTestController::abortModal()
 {
 }
index 4ebf271..15b312f 100644 (file)
@@ -1070,12 +1070,28 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior)
 
 JSValueRef LayoutTestController::shadowRoot(JSContextRef context, JSValueRef jsElement)
 {
-    DOMElement *element = [DOMElement _DOMElementFromJSContext:context value:jsElement];
+    DOMElementelement = [DOMElement _DOMElementFromJSContext:context value:jsElement];
     if (!element)
         return JSValueMakeNull(context);
     return [element _shadowRoot:context];
 }
 
+JSValueRef LayoutTestController::ensureShadowRoot(JSContextRef context, JSValueRef jsElement)
+{
+    DOMElement* element = [DOMElement _DOMElementFromJSContext:context value:jsElement];
+    if (!element)
+        return JSValueMakeNull(context);
+    return [element _ensureShadowRoot:context];
+}
+
+void LayoutTestController::removeShadowRoot(JSContextRef context, JSValueRef jsElement)
+{
+    DOMElement* element = [DOMElement _DOMElementFromJSContext:context value:jsElement];
+    if (!element)
+        return;
+    [element _removeShadowRoot];
+}
+
 void LayoutTestController::abortModal()
 {
     [NSApp abortModal];
index d9f1a74..2e25cb6 100644 (file)
@@ -785,6 +785,16 @@ QVariant LayoutTestController::shadowRoot(const QWebElement& element)
     return DumpRenderTreeSupportQt::shadowRoot(element);
 }
 
+QVariant LayoutTestController::ensureShadowRoot(const QWebElement& element)
+{
+    return DumpRenderTreeSupportQt::ensureShadowRoot(element);
+}
+
+void LayoutTestController::removeShadowRoot(const QWebElement& element)
+{
+    DumpRenderTreeSupportQt::removeShadowRoot(element);
+}
+
 int LayoutTestController::numberOfPendingGeolocationPermissionRequests()
 {
     int pendingPermissionCount = 0;
index 2c33401..a5f446e 100644 (file)
@@ -250,6 +250,8 @@ public slots:
     void setEditingBehavior(const QString& editingBehavior);
 
     QVariant shadowRoot(const QWebElement&);
+    QVariant ensureShadowRoot(const QWebElement&);
+    void removeShadowRoot(const QWebElement&);
 
     void evaluateScriptInIsolatedWorld(int worldID, const QString& script);
     bool isPageBoxVisible(int pageIndex);
index 2086ae7..ae3cd97 100644 (file)
@@ -1447,6 +1447,17 @@ JSValueRef LayoutTestController::shadowRoot(JSContextRef context, JSValueRef jsE
     return JSValueMakeUndefined(context);
 }
 
+JSValueRef LayoutTestController::ensureShadowRoot(JSContextRef context, JSValueRef jsElement)
+{
+    // FIXME: Implement this.
+    return JSValueMakeUndefined(context);
+}
+
+void LayoutTestController::removeShadowRoot(JSContextRef context, JSValueRef jsElement)
+{
+    // FIXME: Implement this.
+}
+
 void LayoutTestController::abortModal()
 {
 }
index 0593840..aad568d 100644 (file)
@@ -58,7 +58,11 @@ module WTR {
         boolean isCommandEnabled(in DOMString name);
         DOMString markerTextForListItem(in object element);
         unsigned long windowCount();
+
+        // Shadow DOM.
         object shadowRoot(in object element);
+        object ensureShadowRoot(in object element);
+        void removeShadowRoot(in object element);
 
         // Repaint testing.
         void testRepaint();
index 45725b4..fd007a0 100644 (file)
@@ -367,11 +367,45 @@ JSValueRef LayoutTestController::shadowRoot(JSValueRef element)
     if (!domElement)
         return JSValueMakeNull(context);
 
-    WKRetainPtr<WKBundleNodeHandleRef> shadowRootDOMElement = adoptWK(WKBundleNodeHandleCopyElementShadowRoot(domElement.get()));
-    if (!shadowRootDOMElement)
+    WKRetainPtr<WKBundleNodeHandleRef> shadowRootDOMNode = adoptWK(WKBundleNodeHandleCopyElementShadowRoot(domElement.get()));
+    if (!shadowRootDOMNode)
         return JSValueMakeNull(context);
 
-    return WKBundleFrameGetJavaScriptWrapperForNodeForWorld(mainFrame, shadowRootDOMElement.get(), WKBundleScriptWorldNormalWorld());
+    return WKBundleFrameGetJavaScriptWrapperForNodeForWorld(mainFrame, shadowRootDOMNode.get(), WKBundleScriptWorldNormalWorld());
+}
+
+JSValueRef LayoutTestController::ensureShadowRoot(JSValueRef element)
+{
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+    if (!element || !JSValueIsObject(context, element))
+        return JSValueMakeNull(context);
+
+    WKRetainPtr<WKBundleNodeHandleRef> domElement = adoptWK(WKBundleNodeHandleCreate(context, const_cast<JSObjectRef>(element)));
+    if (!domElement)
+        return JSValueMakeNull(context);
+
+    WKRetainPtr<WKBundleNodeHandleRef> shadowRootDOMNode = adoptWK(WKBundleNodeHandleCopyElementEnsureShadowRoot(domElement.get()));
+    if (!shadowRootDOMNode)
+        return JSValueMakeNull(context);
+
+    return WKBundleFrameGetJavaScriptWrapperForNodeForWorld(mainFrame, shadowRootDOMNode.get(), WKBundleScriptWorldNormalWorld());
+}
+
+void LayoutTestController::removeShadowRoot(JSValueRef element)
+{
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+    if (!element || !JSValueIsObject(context, element))
+        return;
+
+    WKRetainPtr<WKBundleNodeHandleRef> domElement = adoptWK(WKBundleNodeHandleCreate(context, const_cast<JSObjectRef>(element)));
+    if (!domElement)
+        return;
+
+    WKBundleNodeHandleRemoveShadowRoot(domElement.get());
 }
 
 void LayoutTestController::clearBackForwardList()
index 00d7e57..3d7dcc4 100644 (file)
@@ -86,7 +86,11 @@ public:
     bool isCommandEnabled(JSStringRef name);
     JSRetainPtr<JSStringRef> markerTextForListItem(JSValueRef element);
     unsigned windowCount();
+
+    // Shadow DOM.
     JSValueRef shadowRoot(JSValueRef element);
+    JSValueRef ensureShadowRoot(JSValueRef element);
+    void removeShadowRoot(JSValueRef element);
 
     // Repaint testing.
     void testRepaint() { m_testRepaint = true; }