WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP
bug-82607-20120402195143.patch (text/plain), 7.59 KB, created by
Shinya Kawanaka
on 2012-04-02 03:51:45 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Shinya Kawanaka
Created:
2012-04-02 03:51:45 PDT
Size:
7.59 KB
patch
obsolete
>Subversion Revision: 112823 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 47aab7af1ca490c14f44ca462500b7a2a3c5411a..868c8d9edd565299aff0630d1c30cc7b8c43c3df 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,28 @@ >+2012-04-02 Shinya Kawanaka <shinyak@chromium.org> >+ >+ Shadow DOM is exposed in JS. >+ https://bugs.webkit.org/show_bug.cgi?id=82607 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ DOMSelection didn't consider nested shadow trees. This patch make DOMSelection >+ take nested shadow trees into account. >+ >+ To test the element is not in a shadow tree, Internals has treeScopeRootNode method >+ which returns the root node of the belonging tree scope. >+ >+ Test: fast/dom/shadow/selection-doesnt-expose-shadow-dom.html >+ >+ * page/DOMSelection.cpp: >+ (WebCore::selectionShadowAncestor): >+ (WebCore): >+ * testing/Internals.cpp: >+ (WebCore::Internals::treeScopeRootNode): >+ (WebCore): >+ * testing/Internals.h: >+ (Internals): >+ * testing/Internals.idl: >+ > 2012-04-01 Jon Lee <jonlee@apple.com> > > Rename notification properties and functions >diff --git a/Source/WebCore/dom/TreeScope.h b/Source/WebCore/dom/TreeScope.h >index 5719f95d0eea2b86e331eb806e412ab2bec6c4f5..c8b40bc109a80aeec1dab2dac1fd9c9a333c2037 100644 >--- a/Source/WebCore/dom/TreeScope.h >+++ b/Source/WebCore/dom/TreeScope.h >@@ -107,4 +107,3 @@ inline bool TreeScope::containsMultipleElementsWithId(const AtomicString& id) co > } // namespace WebCore > > #endif // TreeScope_h >- >diff --git a/Source/WebCore/page/DOMSelection.cpp b/Source/WebCore/page/DOMSelection.cpp >index 97a438dd030baeb223a2fba7b491cde93a54e818..83896dee9f0b0fd68e29601f7a2bedd01b970f74 100644 >--- a/Source/WebCore/page/DOMSelection.cpp >+++ b/Source/WebCore/page/DOMSelection.cpp >@@ -38,6 +38,7 @@ > #include "PlatformString.h" > #include "Range.h" > #include "TextIterator.h" >+#include "TreeScope.h" > #include "htmlediting.h" > > namespace WebCore { >@@ -47,12 +48,18 @@ static Node* selectionShadowAncestor(Frame* frame) > Node* node = frame->selection()->selection().base().anchorNode(); > if (!node) > return 0; >- Node* shadowAncestor = node->shadowAncestorNode(); >- if (shadowAncestor == node) >+ >+ if (!node->treeScope()->rootNode()->isShadowRoot()) > return 0; >+ >+ Node* shadowAncestor = node->shadowAncestorNode(); >+ while (shadowAncestor->treeScope()->rootNode()->isShadowRoot()) >+ shadowAncestor = shadowAncestor->shadowAncestorNode(); >+ > return shadowAncestor; > } > >+ > DOMSelection::DOMSelection(Frame* frame) > : DOMWindowProperty(frame) > { >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 108a396597421e6a3181c526811ca6390a2d1159..c0e2e6e3a607b889f17c45917314aa7233305e7c 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -58,6 +58,7 @@ > #include "ShadowTree.h" > #include "SpellChecker.h" > #include "TextIterator.h" >+#include "TreeScope.h" > > #if ENABLE(INPUT_TYPE_COLOR) > #include "ColorChooser.h" >@@ -177,6 +178,16 @@ bool Internals::isValidContentSelect(Element* insertionPoint, ExceptionCode& ec) > 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) { >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index 87b8761bb4346f9a058b036d14e33c2683c495d1..23e9f5acbc712882dc30765e68d63924f040a460 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -81,6 +81,7 @@ public: > 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&); > >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index 8822e25a261a1d237a8696c560d179b22a4278a6..01b9961a95f683e6e4717795d51d8599714ba48b 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -54,6 +54,7 @@ module window { > 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 nextSiblingInReifiedTree(in Node node) raises(DOMException); > Node firstChildInReifiedTree(in Node node) raises(DOMException); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index a772324945c4d8dd9127f8ddcf34e0d50aadbc70..668eb65a3aee23f5704b518f420fa3571f8e0b66 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2012-04-02 Shinya Kawanaka <shinyak@chromium.org> >+ >+ Shadow DOM is exposed in JS. >+ https://bugs.webkit.org/show_bug.cgi?id=82607 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/dom/shadow/selection-doesnt-expose-shadow-dom.html: Added. >+ > 2012-04-01 Eric Seidel <eric@webkit.org> > > Unreviewed, rolling out r112760. >diff --git a/LayoutTests/fast/dom/shadow/selection-doesnt-expose-shadow-dom.html b/LayoutTests/fast/dom/shadow/selection-doesnt-expose-shadow-dom.html >new file mode 100644 >index 0000000000000000000000000000000000000000..60f772a51b28582c08f3056a4dd87fa9b181e0c8 >--- /dev/null >+++ b/LayoutTests/fast/dom/shadow/selection-doesnt-expose-shadow-dom.html >@@ -0,0 +1,57 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</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="../../js/resources/js-test-post.js"></script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 82607
:
134560
|
135038
|
135060
|
135064
|
135076
|
135079
|
135096
|
135108
|
135252
|
135515
|
135743