Title: [113276] trunk
Revision
113276
Author
[email protected]
Date
2012-04-04 19:28:15 -0700 (Wed, 04 Apr 2012)

Log Message

Shadow DOM is exposed in JS.
https://bugs.webkit.org/show_bug.cgi?id=82607

Reviewed by Hajime Morita.

.:

* Source/autotools/symbols.filter:

Source/WebCore:

DOMSelection didn't consider nested shadow trees. This patch makes DOMSelection
take nested shadow trees into account.

To test that the element is not in a shadow tree, Internals has a treeScopeRootNode method
which returns the root node of the belonging tree scope.

Test: fast/dom/shadow/selection-shouldnt-expose-shadow-dom.html

* WebCore.exp.in:
* page/DOMSelection.cpp:
(WebCore::selectionShadowAncestor):
(WebCore):
* testing/Internals.cpp:
(WebCore::Internals::treeScopeRootNode):
(WebCore):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

Source/WebKit2:

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

LayoutTests:

* fast/dom/shadow/selection-shouldnt-expose-shadow-dom-expected.txt: Added.
* fast/dom/shadow/selection-shouldnt-expose-shadow-dom.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (113275 => 113276)


--- trunk/ChangeLog	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/ChangeLog	2012-04-05 02:28:15 UTC (rev 113276)
@@ -1,3 +1,12 @@
+2012-04-04  Shinya Kawanaka  <[email protected]>
+
+        Shadow DOM is exposed in JS.
+        https://bugs.webkit.org/show_bug.cgi?id=82607
+
+        Reviewed by Hajime Morita.
+
+        * Source/autotools/symbols.filter:
+
 2012-04-03  Tony Chang  <[email protected]>
 
         remove WebKit files from .gitattributes

Modified: trunk/LayoutTests/ChangeLog (113275 => 113276)


--- trunk/LayoutTests/ChangeLog	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/LayoutTests/ChangeLog	2012-04-05 02:28:15 UTC (rev 113276)
@@ -1,3 +1,13 @@
+2012-04-04  Shinya Kawanaka  <[email protected]>
+
+        Shadow DOM is exposed in JS.
+        https://bugs.webkit.org/show_bug.cgi?id=82607
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/shadow/selection-shouldnt-expose-shadow-dom-expected.txt: Added.
+        * fast/dom/shadow/selection-shouldnt-expose-shadow-dom.html: Added.
+
 2012-04-04  Hayato Ito  <[email protected]>
 
         Update a layout test, adding a case for traversing a ShadowRoot which does not have any children.

Added: trunk/LayoutTests/fast/dom/shadow/selection-shouldnt-expose-shadow-dom-expected.txt (0 => 113276)


--- trunk/LayoutTests/fast/dom/shadow/selection-shouldnt-expose-shadow-dom-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/selection-shouldnt-expose-shadow-dom-expected.txt	2012-04-05 02:28:15 UTC (rev 113276)
@@ -0,0 +1,6 @@
+PASS internals.treeScopeRootNode(selection.anchorNode) is document
+PASS internals.treeScopeRootNode(selection.focusNode) is document
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/selection-shouldnt-expose-shadow-dom.html (0 => 113276)


--- trunk/LayoutTests/fast/dom/shadow/selection-shouldnt-expose-shadow-dom.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/selection-shouldnt-expose-shadow-dom.html	2012-04-05 02:28:15 UTC (rev 113276)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<pre id="console"></pre>
+<div id="container"></div>
+
+<script>
+function moveTo(element) {
+    var x = element.offsetLeft + element.offsetWidth / 2;
+    var y = element.offsetTop + element.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+}
+
+function dragFromTo(elementFrom, elementTo) {
+    moveTo(elementFrom);
+    eventSender.mouseDown();
+    moveTo(elementTo);
+    eventSender.mouseUp();
+}
+
+var container = document.getElementById('container');
+
+var shadowRoot1 = new WebKitShadowRoot(container);
+shadowRoot1.innerHTML =
+    '<div id="div1" title="div1">You Satoh</div>' +
+    '<div id="div2" title="div2">Sen Yarizui</div>' +
+    '<div id="div3" title="div3">Ayame Shaga</div>';
+var div1 = shadowRoot1.getElementById('div1');
+var div2 = shadowRoot1.getElementById('div2');
+var div3 = shadowRoot1.getElementById('div3');
+
+var shadowRoot2 = new WebKitShadowRoot(div2);
+shadowRoot2.innerHTML =
+    '<div id="div4" title="div4">Hana Oshiroi</div>' +
+    '<div id="div5" title="div5">Ume Shiraume</div>' +
+    '<div id="div6" title="div6">Mikoto Uzu</div>';
+var div4 = shadowRoot2.getElementById('div4');
+var div5 = shadowRoot2.getElementById('div5');
+var div6 = shadowRoot2.getElementById('div6');
+
+dragFromTo(div4, div6);
+var selection = window.getSelection();
+
+// If anchodeNode and focusNode are not in Shadow tree, document is returned
+// by internals.treeScopeRootNode().
+shouldBe('internals.treeScopeRootNode(selection.anchorNode)', 'document');
+shouldBe('internals.treeScopeRootNode(selection.focusNode)', 'document');
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (113275 => 113276)


--- trunk/Source/WebCore/ChangeLog	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebCore/ChangeLog	2012-04-05 02:28:15 UTC (rev 113276)
@@ -1,3 +1,29 @@
+2012-04-04  Shinya Kawanaka  <[email protected]>
+
+        Shadow DOM is exposed in JS.
+        https://bugs.webkit.org/show_bug.cgi?id=82607
+
+        Reviewed by Hajime Morita.
+
+        DOMSelection didn't consider nested shadow trees. This patch makes DOMSelection
+        take nested shadow trees into account.
+
+        To test that the element is not in a shadow tree, Internals has a treeScopeRootNode method
+        which returns the root node of the belonging tree scope.
+
+        Test: fast/dom/shadow/selection-shouldnt-expose-shadow-dom.html
+
+        * WebCore.exp.in:
+        * page/DOMSelection.cpp:
+        (WebCore::selectionShadowAncestor):
+        (WebCore):
+        * testing/Internals.cpp:
+        (WebCore::Internals::treeScopeRootNode):
+        (WebCore):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-04-04  Luke Macpherson  <[email protected]>
 
         Replace further usage of int with CSSPropertyID.

Modified: trunk/Source/WebCore/WebCore.exp.in (113275 => 113276)


--- trunk/Source/WebCore/WebCore.exp.in	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-04-05 02:28:15 UTC (rev 113276)
@@ -1173,6 +1173,7 @@
 __ZN7WebCore5Image7setDataEN3WTF10PassRefPtrINS_12SharedBufferEEEb
 __ZNK3JSC8Bindings10RootObject12globalObjectEv
 __ZNK3WTF6String14createCFStringEv
+__ZNK7WebCore4Node9treeScopeEv
 __ZNK7WebCore10Credential11hasPasswordEv
 __ZNK7WebCore10Credential11persistenceEv
 __ZNK7WebCore10Credential4userEv

Modified: trunk/Source/WebCore/page/DOMSelection.cpp (113275 => 113276)


--- trunk/Source/WebCore/page/DOMSelection.cpp	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebCore/page/DOMSelection.cpp	2012-04-05 02:28:15 UTC (rev 113276)
@@ -38,6 +38,7 @@
 #include "PlatformString.h"
 #include "Range.h"
 #include "TextIterator.h"
+#include "TreeScope.h"
 #include "htmlediting.h"
 
 namespace WebCore {
@@ -47,9 +48,13 @@
     Node* node = frame->selection()->selection().base().anchorNode();
     if (!node)
         return 0;
+
+    if (!node->isInShadowTree())
+        return 0;
+
     Node* shadowAncestor = node->shadowAncestorNode();
-    if (shadowAncestor == node)
-        return 0;
+    while (shadowAncestor->isInShadowTree())
+        shadowAncestor = shadowAncestor->shadowAncestorNode();
     return shadowAncestor;
 }
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (113275 => 113276)


--- trunk/Source/WebCore/testing/Internals.cpp	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebCore/testing/Internals.cpp	2012-04-05 02:28:15 UTC (rev 113276)
@@ -59,6 +59,7 @@
 #include "ShadowTree.h"
 #include "SpellChecker.h"
 #include "TextIterator.h"
+#include "TreeScope.h"
 
 #if ENABLE(INPUT_TYPE_COLOR)
 #include "ColorChooser.h"
@@ -178,6 +179,16 @@
     return toInsertionPoint(insertionPoint)->isSelectValid();
 }
 
+Node* Internals::treeScopeRootNode(Node* node, ExceptionCode& ec)
+{
+    if (!node) {
+        ec = INVALID_ACCESS_ERR;
+        return 0;
+    }
+
+    return node->treeScope()->rootNode();
+}
+
 bool Internals::attached(Node* node, ExceptionCode& ec)
 {
     if (!node) {

Modified: trunk/Source/WebCore/testing/Internals.h (113275 => 113276)


--- trunk/Source/WebCore/testing/Internals.h	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebCore/testing/Internals.h	2012-04-05 02:28:15 UTC (rev 113276)
@@ -81,6 +81,7 @@
     PassRefPtr<Element> createContentElement(Document*, ExceptionCode&);
     Element* getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode&);
     bool isValidContentSelect(Element* insertionPoint, ExceptionCode&);
+    Node* treeScopeRootNode(Node*, ExceptionCode&);
 
     bool attached(Node*, ExceptionCode&);
 

Modified: trunk/Source/WebCore/testing/Internals.idl (113275 => 113276)


--- trunk/Source/WebCore/testing/Internals.idl	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebCore/testing/Internals.idl	2012-04-05 02:28:15 UTC (rev 113276)
@@ -54,6 +54,7 @@
         Element createContentElement(in Document document) raises(DOMException);
         Element getElementByIdInShadowRoot(in Node shadowRoot, in DOMString id) raises(DOMException);
         boolean isValidContentSelect(in Element contentElement) raises(DOMException);
+        Node treeScopeRootNode(in Node node) raises (DOMException);
 
         Node nextSiblingByWalker(in Node node) raises(DOMException);
         Node firstChildByWalker(in Node node) raises(DOMException);

Modified: trunk/Source/WebKit2/ChangeLog (113275 => 113276)


--- trunk/Source/WebKit2/ChangeLog	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-05 02:28:15 UTC (rev 113276)
@@ -1,3 +1,13 @@
+2012-04-04  Shinya Kawanaka  <[email protected]>
+
+        Shadow DOM is exposed in JS.
+        https://bugs.webkit.org/show_bug.cgi?id=82607
+
+        Reviewed by Hajime Morita.
+
+        * win/WebKit2.def:
+        * win/WebKit2CFLite.def:
+
 2012-04-04  Anders Carlsson  <[email protected]>
 
         Text input doesn't work for some Flash forms

Modified: trunk/Source/WebKit2/win/WebKit2.def (113275 => 113276)


--- trunk/Source/WebKit2/win/WebKit2.def	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebKit2/win/WebKit2.def	2012-04-05 02:28:15 UTC (rev 113276)
@@ -238,6 +238,7 @@
         ?toRange@WebCore@@YAPAVRange@1@VJSValue@JSC@@@Z
         ?traverseNextNode@ReifiedTreeTraversal@WebCore@@SAPAVNode@2@PBV32@@Z
         ?traversePreviousNode@ReifiedTreeTraversal@WebCore@@SAPAVNode@2@PBV32@@Z
+        ?treeScope@Node@WebCore@@QBEPAVTreeScope@2@XZ
         ?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
         ?userPreferredLanguages@WebCore@@YA?AV?$Vector@VString@WTF@@$0A@@WTF@@XZ
         ?utf8@String@WTF@@QBE?AVCString@2@_N@Z

Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (113275 => 113276)


--- trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-04-05 02:28:15 UTC (rev 113276)
@@ -231,6 +231,7 @@
         ?toRange@WebCore@@YAPAVRange@1@VJSValue@JSC@@@Z
         ?traverseNextNode@ReifiedTreeTraversal@WebCore@@SAPAVNode@2@PBV32@@Z
         ?traversePreviousNode@ReifiedTreeTraversal@WebCore@@SAPAVNode@2@PBV32@@Z
+        ?treeScope@Node@WebCore@@QBEPAVTreeScope@2@XZ
         ?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
         ?userPreferredLanguages@WebCore@@YA?AV?$Vector@VString@WTF@@$0A@@WTF@@XZ
         ?utf8@String@WTF@@QBE?AVCString@2@_N@Z

Modified: trunk/Source/autotools/symbols.filter (113275 => 113276)


--- trunk/Source/autotools/symbols.filter	2012-04-05 02:07:27 UTC (rev 113275)
+++ trunk/Source/autotools/symbols.filter	2012-04-05 02:28:15 UTC (rev 113276)
@@ -91,6 +91,7 @@
 _ZN7WebCore9JSElement6s_infoE;
 _ZN7WebCore9toElementEN3JSC7JSValueE;
 _ZNK7WebCore4Node31numberOfScopedHTMLStyleChildrenEv;
+_ZNK7WebCore4Node9treeScopeEv;
 _ZNK7WebCore12RenderObject23absoluteBoundingBoxRectEb;
 _ZNK7WebCore16HTMLInputElement14suggestedValueEv;
 _ZNK7WebCore17JSDOMGlobalObject22scriptExecutionContextEv;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to