- Revision
- 126275
- Author
- [email protected]
- Date
- 2012-08-22 01:20:40 -0700 (Wed, 22 Aug 2012)
Log Message
Dynamically styling ShadowDom content on a node distributed to another shadow insertion point fails.
https://bugs.webkit.org/show_bug.cgi?id=92899
Patch by Takashi Sakamoto <[email protected]> on 2012-08-22
Reviewed by Hajime Morita.
Source/WebCore:
Since childNeedsStyleRecalc is not cleared when parent nodes are
attached, setNeedsStyleRecalc flag is not reached Document. So,
document() doesn't run re-layout.
Test: fast/dom/shadow/shadowdom-dynamic-styling.html
* dom/ContainerNode.h:
(ContainerNode):
(WebCore::ContainerNode::detachAsNode):
Removed detachAsNode, because the below change made the method
not-used.
* dom/Element.cpp:
(WebCore::Element::detach):
Modify to invoke ContainerNode::detach when any shadow subtree is
attached. ContainerNode::detach takes care of childNeedsStyleRecalc
flag.
* dom/ElementShadow.cpp:
(WebCore::ElementShadow::invalidateDistribution):
Use SetAttached for lazyAttach instead of DoNotSetAttached, because
it is reuired to invoke ContainerNode::detach. If not, attached() is
false and reattach() invokes only attach(). This causes to leave
shadow host's childNeedsStyleRecalc flag true after
Element::recalcStyle.
LayoutTests:
* fast/dom/shadow/shadowdom-dynamic-styling-expected.txt: Added.
* fast/dom/shadow/shadowdom-dynamic-styling.html: Added.
* editing/shadow/delete-characters-in-distributed-node-crash.html:
Made the layout test robust. This patch causes commit-queue- and the
failed test is delete-characters-in-distributed-node-crash.html.
However the layout test passes when locally running run_webkit_test
i.e. no difference between actual and expected texts. And looking at
the commit-queue's report, the actual text has "PASS" message (no
crash messages).
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (126274 => 126275)
--- trunk/LayoutTests/ChangeLog 2012-08-22 08:11:52 UTC (rev 126274)
+++ trunk/LayoutTests/ChangeLog 2012-08-22 08:20:40 UTC (rev 126275)
@@ -1,3 +1,20 @@
+2012-08-22 Takashi Sakamoto <[email protected]>
+
+ Dynamically styling ShadowDom content on a node distributed to another shadow insertion point fails.
+ https://bugs.webkit.org/show_bug.cgi?id=92899
+
+ Reviewed by Hajime Morita.
+
+ * fast/dom/shadow/shadowdom-dynamic-styling-expected.txt: Added.
+ * fast/dom/shadow/shadowdom-dynamic-styling.html: Added.
+ * editing/shadow/delete-characters-in-distributed-node-crash.html:
+ Made the layout test robust. This patch causes commit-queue- and the
+ failed test is delete-characters-in-distributed-node-crash.html.
+ However the layout test passes when locally running run_webkit_test
+ i.e. no difference between actual and expected texts. And looking at
+ the commit-queue's report, the actual text has "PASS" message (no
+ crash messages).
+
2012-08-22 Dominic Cooney <[email protected]>
[Chromium] Unreviewed gardening.
Modified: trunk/LayoutTests/editing/shadow/delete-characters-in-distributed-node-crash-expected.txt (126274 => 126275)
--- trunk/LayoutTests/editing/shadow/delete-characters-in-distributed-node-crash-expected.txt 2012-08-22 08:11:52 UTC (rev 126274)
+++ trunk/LayoutTests/editing/shadow/delete-characters-in-distributed-node-crash-expected.txt 2012-08-22 08:20:40 UTC (rev 126275)
@@ -1,4 +1,3 @@
This tests the deletion of text in distributed node does not crash. To run it outside of DRT, you must delete text, 'foo', manually.
-
PASS
Modified: trunk/LayoutTests/editing/shadow/delete-characters-in-distributed-node-crash.html (126274 => 126275)
--- trunk/LayoutTests/editing/shadow/delete-characters-in-distributed-node-crash.html 2012-08-22 08:11:52 UTC (rev 126274)
+++ trunk/LayoutTests/editing/shadow/delete-characters-in-distributed-node-crash.html 2012-08-22 08:20:40 UTC (rev 126275)
@@ -2,7 +2,7 @@
<html>
<body>
<p id="description">This tests the deletion of text in distributed node does not crash. To run it outside of DRT, you must delete text, 'foo', manually.</p>
-<div id="shadowhost" contenteditable><div>foo</div></div>
+<div id="wrapper"><div id="shadowhost" contenteditable><div>foo</div></div></div>
<script>
if (window.testRunner)
testRunner.dumpAsText();
@@ -13,7 +13,7 @@
window.getSelection().setBaseAndExtent(textNode, 0, textNode, 3);
document.execCommand('Delete');
-document.write('PASS');
+document.getElementById("wrapper").innerHTML = "PASS";
</script>
</body>
</html>
Added: trunk/LayoutTests/fast/dom/shadow/shadowdom-dynamic-styling-expected.txt (0 => 126275)
--- trunk/LayoutTests/fast/dom/shadow/shadowdom-dynamic-styling-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadowdom-dynamic-styling-expected.txt 2012-08-22 08:20:40 UTC (rev 126275)
@@ -0,0 +1,10 @@
+Test for https://bugs.webkit.org/show_bug.cgi?id=92899. Dynamically styling ShadowDom content on a node distributed to another shadow insertion point fails.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(target).backgroundColor is "rgb(255, 0, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/shadow/shadowdom-dynamic-styling.html (0 => 126275)
--- trunk/LayoutTests/fast/dom/shadow/shadowdom-dynamic-styling.html (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadowdom-dynamic-styling.html 2012-08-22 08:20:40 UTC (rev 126275)
@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+<head>
+ <script src=""
+ <script>
+description("Test for https://bugs.webkit.org/show_bug.cgi?id=92899. Dynamically styling ShadowDom content on a node distributed to another shadow insertion point fails.");
+
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+</script>
+</head>
+<body>
+ <div id="box" style="border: 1px solid black;">
+ <div id="item"><div>Content required here to reproduce bug.</div></div>
+ </div>
+<script>
+var box = document.querySelector("#box");
+var oldestShadowRoot = new WebKitShadowRoot(box);
+oldestShadowRoot.innerHTML = "<content></content>";
+
+var youngestShadowRoot = new WebKitShadowRoot(document.querySelector("#item"));
+youngestShadowRoot.innerHTML = "<style>" +
+ ".selected {background: red;}" +
+ "</style>" +
+ "<div id='target'>Content</div>";
+
+document.body.offsetLeft;
+
+target = youngestShadowRoot.querySelector("div");
+target.classList.add("selected");
+shouldBe('window.getComputedStyle(target).backgroundColor', '"rgb(255, 0, 0)"');
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (126274 => 126275)
--- trunk/Source/WebCore/ChangeLog 2012-08-22 08:11:52 UTC (rev 126274)
+++ trunk/Source/WebCore/ChangeLog 2012-08-22 08:20:40 UTC (rev 126275)
@@ -1,3 +1,34 @@
+2012-08-22 Takashi Sakamoto <[email protected]>
+
+ Dynamically styling ShadowDom content on a node distributed to another shadow insertion point fails.
+ https://bugs.webkit.org/show_bug.cgi?id=92899
+
+ Reviewed by Hajime Morita.
+
+ Since childNeedsStyleRecalc is not cleared when parent nodes are
+ attached, setNeedsStyleRecalc flag is not reached Document. So,
+ document() doesn't run re-layout.
+
+ Test: fast/dom/shadow/shadowdom-dynamic-styling.html
+
+ * dom/ContainerNode.h:
+ (ContainerNode):
+ (WebCore::ContainerNode::detachAsNode):
+ Removed detachAsNode, because the below change made the method
+ not-used.
+ * dom/Element.cpp:
+ (WebCore::Element::detach):
+ Modify to invoke ContainerNode::detach when any shadow subtree is
+ attached. ContainerNode::detach takes care of childNeedsStyleRecalc
+ flag.
+ * dom/ElementShadow.cpp:
+ (WebCore::ElementShadow::invalidateDistribution):
+ Use SetAttached for lazyAttach instead of DoNotSetAttached, because
+ it is reuired to invoke ContainerNode::detach. If not, attached() is
+ false and reattach() invokes only attach(). This causes to leave
+ shadow host's childNeedsStyleRecalc flag true after
+ Element::recalcStyle.
+
2012-08-22 Taiju Tsuiki <[email protected]>
Web Inspector: Add deleteEntry command and deletionCompleted event to FileSystemAgent
Modified: trunk/Source/WebCore/dom/ContainerNode.h (126274 => 126275)
--- trunk/Source/WebCore/dom/ContainerNode.h 2012-08-22 08:11:52 UTC (rev 126274)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2012-08-22 08:20:40 UTC (rev 126275)
@@ -92,7 +92,6 @@
void attachChildren();
void attachChildrenIfNeeded();
void attachChildrenLazily();
- void detachAsNode();
void detachChildren();
void detachChildrenIfNeeded();
@@ -188,11 +187,6 @@
child->lazyAttach();
}
-inline void ContainerNode::detachAsNode()
-{
- Node::detach();
-}
-
inline void ContainerNode::detachChildrenIfNeeded()
{
for (Node* child = firstChild(); child; child = child->nextSibling()) {
Modified: trunk/Source/WebCore/dom/Element.cpp (126274 => 126275)
--- trunk/Source/WebCore/dom/Element.cpp 2012-08-22 08:11:52 UTC (rev 126274)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-08-22 08:20:40 UTC (rev 126275)
@@ -999,9 +999,8 @@
if (ElementShadow* shadow = this->shadow()) {
detachChildrenIfNeeded();
shadow->detach();
- detachAsNode();
- } else
- ContainerNode::detach();
+ }
+ ContainerNode::detach();
RenderWidget::resumeWidgetHierarchyUpdates();
}
Modified: trunk/Source/WebCore/dom/ElementShadow.cpp (126274 => 126275)
--- trunk/Source/WebCore/dom/ElementShadow.cpp 2012-08-22 08:11:52 UTC (rev 126274)
+++ trunk/Source/WebCore/dom/ElementShadow.cpp 2012-08-22 08:20:40 UTC (rev 126275)
@@ -206,7 +206,7 @@
if (needsReattach && host->attached()) {
host->detach();
- host->lazyAttach(Node::DoNotSetAttached);
+ host->lazyAttach();
}
if (needsInvalidation)