Title: [124196] trunk
Revision
124196
Author
[email protected]
Date
2012-07-31 06:15:26 -0700 (Tue, 31 Jul 2012)

Log Message

Older ShadowDOM is still rendered when a new ShadowDOM is added when they don't have any InsertionPoints.
https://bugs.webkit.org/show_bug.cgi?id=92456

Reviewed by Hajime Morita.

Source/WebCore:

When adding a new ShadowRoot to an element having other ShadowRoots, and they don't have any InsretionPoint,
the older ShadowDOM is still rendered.

When ContentDistributor's validity is 'Undetermined', ElementShadow reattaches the host and the whole shadow
subtree. Since adding a new ShadowRoot makes the validity 'Undetermined', we have had to make it 'Undetermined'.

This change enables us to remove a unnecessary InvalidationType flag from the code. We should call
setValidityUndetermined() instead of using InvalidateAndForceReattach.

Test: fast/dom/shadow/invalidate-distribution.html

* dom/ElementShadow.cpp:
(WebCore::ElementShadow::addShadowRoot): Calls setValidityUndetermined().
(WebCore::ElementShadow::removeAllShadowRoots):
(WebCore::ElementShadow::setValidityUndetermined):
(WebCore::ElementShadow::invalidateDistribution): When validity is undetermined, we will reattach the
host and the shadow subtree.
* dom/ElementShadow.h:
(ElementShadow):
* html/shadow/ContentDistributor.cpp:
* html/shadow/ContentDistributor.h:
(WebCore::ContentDistributor::setValidity):
(ContentDistributor):
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::insertedInto): Calls setValidityUndetermined().

LayoutTests:

* fast/dom/shadow/invalidate-distribution-expected.html: Added.
* fast/dom/shadow/invalidate-distribution.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124195 => 124196)


--- trunk/LayoutTests/ChangeLog	2012-07-31 13:02:39 UTC (rev 124195)
+++ trunk/LayoutTests/ChangeLog	2012-07-31 13:15:26 UTC (rev 124196)
@@ -1,3 +1,13 @@
+2012-07-31  Shinya Kawanaka  <[email protected]>
+
+        Older ShadowDOM is still rendered when a new ShadowDOM is added when they don't have any InsertionPoints.
+        https://bugs.webkit.org/show_bug.cgi?id=92456
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/shadow/invalidate-distribution-expected.html: Added.
+        * fast/dom/shadow/invalidate-distribution.html: Added.
+
 2012-07-31  Csaba Osztrogonác  <[email protected]>
 
         [Qt] Unreviewed gardening, remove unnecessary expected files.

Added: trunk/LayoutTests/fast/dom/shadow/invalidate-distribution-expected.html (0 => 124196)


--- trunk/LayoutTests/fast/dom/shadow/invalidate-distribution-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/invalidate-distribution-expected.html	2012-07-31 13:15:26 UTC (rev 124196)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="host"><p>younger shadow</p></div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/dom/shadow/invalidate-distribution.html (0 => 124196)


--- trunk/LayoutTests/fast/dom/shadow/invalidate-distribution.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/invalidate-distribution.html	2012-07-31 13:15:26 UTC (rev 124196)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<div id="host"></div>
+
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+var shadowRoot = new WebKitShadowRoot(host);
+shadowRoot.innerHTML = "<p>oldest shadow</p>"
+
+setTimeout(function() {
+    var shadowRoot2 = new WebKitShadowRoot(host);
+    shadowRoot2.innerHTML = "<p>younger shadow</p>";
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 0);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (124195 => 124196)


--- trunk/Source/WebCore/ChangeLog	2012-07-31 13:02:39 UTC (rev 124195)
+++ trunk/Source/WebCore/ChangeLog	2012-07-31 13:15:26 UTC (rev 124196)
@@ -1,3 +1,36 @@
+2012-07-31  Shinya Kawanaka  <[email protected]>
+
+        Older ShadowDOM is still rendered when a new ShadowDOM is added when they don't have any InsertionPoints.
+        https://bugs.webkit.org/show_bug.cgi?id=92456
+
+        Reviewed by Hajime Morita.
+
+        When adding a new ShadowRoot to an element having other ShadowRoots, and they don't have any InsretionPoint,
+        the older ShadowDOM is still rendered.
+
+        When ContentDistributor's validity is 'Undetermined', ElementShadow reattaches the host and the whole shadow
+        subtree. Since adding a new ShadowRoot makes the validity 'Undetermined', we have had to make it 'Undetermined'.
+
+        This change enables us to remove a unnecessary InvalidationType flag from the code. We should call
+        setValidityUndetermined() instead of using InvalidateAndForceReattach.
+
+        Test: fast/dom/shadow/invalidate-distribution.html
+
+        * dom/ElementShadow.cpp:
+        (WebCore::ElementShadow::addShadowRoot): Calls setValidityUndetermined().
+        (WebCore::ElementShadow::removeAllShadowRoots):
+        (WebCore::ElementShadow::setValidityUndetermined):
+        (WebCore::ElementShadow::invalidateDistribution): When validity is undetermined, we will reattach the
+        host and the shadow subtree.
+        * dom/ElementShadow.h:
+        (ElementShadow):
+        * html/shadow/ContentDistributor.cpp:
+        * html/shadow/ContentDistributor.h:
+        (WebCore::ContentDistributor::setValidity):
+        (ContentDistributor):
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::insertedInto): Calls setValidityUndetermined().
+
 2012-07-31  Tommy Widenflycht  <[email protected]>
 
         Introduce a minimal RTCPeerConnection together with Dictionary changes

Modified: trunk/Source/WebCore/dom/ElementShadow.cpp (124195 => 124196)


--- trunk/Source/WebCore/dom/ElementShadow.cpp	2012-07-31 13:02:39 UTC (rev 124195)
+++ trunk/Source/WebCore/dom/ElementShadow.cpp	2012-07-31 13:15:26 UTC (rev 124196)
@@ -79,7 +79,8 @@
     shadowRoot->setHost(shadowHost);
     shadowRoot->setParentTreeScope(shadowHost->treeScope());
     m_shadowRoots.push(shadowRoot.get());
-    invalidateDistribution(shadowHost, InvalidateIfNeeded);
+    setValidityUndetermined();
+    invalidateDistribution(shadowHost);
     ChildNodeInsertionNotifier(shadowHost).notify(shadowRoot.get());
 
     if (shadowHost->attached() && !shadowRoot->attached())
@@ -108,7 +109,7 @@
         ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get());
     }
 
-    invalidateDistribution(shadowHost, InvalidateIfNeeded);
+    invalidateDistribution(shadowHost);
 }
 
 void ElementShadow::attach()
@@ -188,19 +189,21 @@
     m_distributor.distribute(host());
 }
 
-void ElementShadow::invalidateDistribution(InvalidationType type)
+void ElementShadow::setValidityUndetermined()
 {
-    invalidateDistribution(host(), type);
+    m_distributor.setValidity(ContentDistributor::Undetermined);
 }
 
-void ElementShadow::invalidateDistribution(Element* host, InvalidationType type)
+void ElementShadow::invalidateDistribution()
 {
-    bool needsReattach = (type == InvalidateAndForceReattach);
+    invalidateDistribution(host());
+}
+
+void ElementShadow::invalidateDistribution(Element* host)
+{
     bool needsInvalidation = m_distributor.needsInvalidation();
+    bool needsReattach = needsInvalidation ? m_distributor.invalidate(host) : false;
 
-    if (needsInvalidation)
-        needsReattach |= m_distributor.invalidate(host);
-
     if (needsReattach && host->attached()) {
         host->detach();
         host->lazyAttach(Node::DoNotSetAttached);

Modified: trunk/Source/WebCore/dom/ElementShadow.h (124195 => 124196)


--- trunk/Source/WebCore/dom/ElementShadow.h	2012-07-31 13:02:39 UTC (rev 124195)
+++ trunk/Source/WebCore/dom/ElementShadow.h	2012-07-31 13:15:26 UTC (rev 124196)
@@ -62,12 +62,8 @@
     bool needsStyleRecalc();
     void recalcStyle(Node::StyleChange);
 
-    enum InvalidationType {
-        InvalidateIfNeeded,
-        InvalidateAndForceReattach
-    };
-
-    void invalidateDistribution(InvalidationType = InvalidateIfNeeded);
+    void setValidityUndetermined();
+    void invalidateDistribution();
     void ensureDistribution();
  
     InsertionPoint* insertionPointFor(const Node*) const;
@@ -76,7 +72,7 @@
     const ContentDistributor& distributor() const;
 
 private:
-    void invalidateDistribution(Element* host, InvalidationType);
+    void invalidateDistribution(Element* host);
 
     DoublyLinkedList<ShadowRoot> m_shadowRoots;
     ContentDistributor m_distributor;

Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (124195 => 124196)


--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2012-07-31 13:02:39 UTC (rev 124195)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp	2012-07-31 13:15:26 UTC (rev 124196)
@@ -49,7 +49,6 @@
     return m_nodeToInsertionPoint.get(key);
 }
 
-
 void ContentDistributor::distribute(Element* host)
 {
     ASSERT(needsDistribution());

Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.h (124195 => 124196)


--- trunk/Source/WebCore/html/shadow/ContentDistributor.h	2012-07-31 13:02:39 UTC (rev 124195)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.h	2012-07-31 13:15:26 UTC (rev 124196)
@@ -60,6 +60,8 @@
 
     InsertionPoint* findInsertionPointFor(const Node* key) const;
 
+    void setValidity(Validity validity) { m_validity = validity; }
+
     void distribute(Element* host);
     bool invalidate(Element* host);
     void finishInivalidation();

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (124195 => 124196)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2012-07-31 13:02:39 UTC (rev 124195)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2012-07-31 13:15:26 UTC (rev 124196)
@@ -118,8 +118,10 @@
 {
     HTMLElement::insertedInto(insertionPoint);
     if (insertionPoint->inDocument()) {
-        if (ShadowRoot* root = shadowRoot())
-            root->owner()->invalidateDistribution(ElementShadow::InvalidateAndForceReattach);
+        if (ShadowRoot* root = shadowRoot()) {
+            root->owner()->setValidityUndetermined();
+            root->owner()->invalidateDistribution();
+        }
     }
 
     return InsertionDone;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to