Title: [208605] trunk/Source/WebCore
Revision
208605
Author
[email protected]
Date
2016-11-11 13:20:01 -0800 (Fri, 11 Nov 2016)

Log Message

RenderFlowThread's containing block cache should be invalidated before calling styleDidChange.
https://bugs.webkit.org/show_bug.cgi?id=164646

Reviewed by Simon Fraser.

We have to invalidate the containing block cache for RenderFlowThreads soon after the containing block context
changes. Invalidating it in RenderBlock::styleDidChange is too late since we might run some code in some
of the subclasses that use this stale containing block cache.

No known behaviour change.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleDidChange): This change could trigger double invalidation.
However running this code twice shouldn't impact performance greatly.
(WebCore::RenderBlock::resetFlowThreadContainingBlockAndChildInfoIncludingDescendants):
(WebCore::RenderBlock::invalidateFlowThreadContainingBlockIncludingDescendants): Deleted.
* rendering/RenderBlock.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::setStyle): We don't need to call the invalidation from initializeStyle(), since
we don't yet have cache at that point.
* rendering/RenderInline.cpp:
(WebCore::RenderInline::splitInlines):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208604 => 208605)


--- trunk/Source/WebCore/ChangeLog	2016-11-11 20:38:57 UTC (rev 208604)
+++ trunk/Source/WebCore/ChangeLog	2016-11-11 21:20:01 UTC (rev 208605)
@@ -1,3 +1,28 @@
+2016-11-11  Zalan Bujtas  <[email protected]>
+
+        RenderFlowThread's containing block cache should be invalidated before calling styleDidChange.
+        https://bugs.webkit.org/show_bug.cgi?id=164646
+
+        Reviewed by Simon Fraser.
+
+        We have to invalidate the containing block cache for RenderFlowThreads soon after the containing block context
+        changes. Invalidating it in RenderBlock::styleDidChange is too late since we might run some code in some
+        of the subclasses that use this stale containing block cache.  
+
+        No known behaviour change.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::styleDidChange): This change could trigger double invalidation.
+        However running this code twice shouldn't impact performance greatly.
+        (WebCore::RenderBlock::resetFlowThreadContainingBlockAndChildInfoIncludingDescendants):
+        (WebCore::RenderBlock::invalidateFlowThreadContainingBlockIncludingDescendants): Deleted.
+        * rendering/RenderBlock.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::setStyle): We don't need to call the invalidation from initializeStyle(), since
+        we don't yet have cache at that point.
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::splitInlines):
+
 2016-11-11  Darin Adler  <[email protected]>
 
         Move Node from ExceptionCode to ExceptionOr

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (208604 => 208605)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2016-11-11 20:38:57 UTC (rev 208604)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2016-11-11 21:20:01 UTC (rev 208605)
@@ -423,20 +423,13 @@
 
 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
-    auto& newStyle = style();
-
     bool hadTransform = hasTransform();
-    bool flowThreadContainingBlockInvalidated = false;
-    if (oldStyle && oldStyle->position() != newStyle.position()) {
-        invalidateFlowThreadContainingBlockIncludingDescendants();
-        flowThreadContainingBlockInvalidated = true;
-    }
-
     RenderBox::styleDidChange(diff, oldStyle);
 
-    if (hadTransform != hasTransform() && !flowThreadContainingBlockInvalidated)
-        invalidateFlowThreadContainingBlockIncludingDescendants();
+    if (hadTransform != hasTransform())
+        resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
 
+    auto& newStyle = style();
     if (!isAnonymousBlock()) {
         // Ensure that all of our continuation blocks pick up the new style.
         for (RenderBlock* currCont = blockElementContinuation(); currCont; currCont = currCont->blockElementContinuation()) {
@@ -3382,7 +3375,7 @@
     return rareData->m_flowThreadContainingBlock.value();
 }
 
-void RenderBlock::invalidateFlowThreadContainingBlockIncludingDescendants()
+void RenderBlock::resetFlowThreadContainingBlockAndChildInfoIncludingDescendants()
 {
     if (flowThreadState() == NotInsideFlowThread)
         return;
@@ -3400,7 +3393,7 @@
         if (flowThread)
             flowThread->removeFlowChildInfo(child);
         if (is<RenderBlock>(child))
-            downcast<RenderBlock>(child).invalidateFlowThreadContainingBlockIncludingDescendants();
+            downcast<RenderBlock>(child).resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (208604 => 208605)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2016-11-11 20:38:57 UTC (rev 208604)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2016-11-11 21:20:01 UTC (rev 208605)
@@ -307,7 +307,7 @@
     RenderFlowThread* cachedFlowThreadContainingBlock() const;
     void setCachedFlowThreadContainingBlockNeedsUpdate();
     virtual bool cachedFlowThreadContainingBlockNeedsUpdate() const;
-    void invalidateFlowThreadContainingBlockIncludingDescendants();
+    void resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
 
 protected:
     RenderFlowThread* locateFlowThreadContainingBlock() const override;

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (208604 => 208605)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2016-11-11 20:38:57 UTC (rev 208604)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2016-11-11 21:20:01 UTC (rev 208605)
@@ -408,6 +408,12 @@
     auto oldStyle = WTFMove(m_style);
     m_style = WTFMove(style);
     bool detachedFromParent = !parent();
+
+    // Make sure we invalidate the containing block cache for flows when the contianing block context changes
+    // so that styleDidChange can safely use RenderBlock::locateFlowThreadContainingBlock()
+    if (is<RenderBlock>(*this) && oldStyle.position() != m_style.position())
+        downcast<RenderBlock>(*this).resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
+
     styleDidChange(diff, &oldStyle);
 
     // Text renderers use their parent style. Notify them about the change.

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (208604 => 208605)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2016-11-11 20:38:57 UTC (rev 208604)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2016-11-11 21:20:01 UTC (rev 208605)
@@ -523,7 +523,7 @@
 
     // Clear the flow thread containing blocks cached during the detached state insertions.
     for (auto& cloneBlockChild : childrenOfType<RenderBlock>(*cloneInline))
-        cloneBlockChild.invalidateFlowThreadContainingBlockIncludingDescendants();
+        cloneBlockChild.resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
 
     // Now we are at the block level. We need to put the clone into the toBlock.
     toBlock->insertChildInternal(cloneInline.leakPtr(), nullptr, NotifyChildren);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to