Remove RenderElement::s_noLongerAffectsParentBlock
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Mar 2018 20:20:46 +0000 (20:20 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Mar 2018 20:20:46 +0000 (20:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183196
<rdar://problem/38030797>

Reviewed by Antti Koivisto.

Remove the hack to track floating/out-of-flow changes between styleWillChange and styleDidChange.

Covered by existing tests.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::styleDidChange):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleWillChange):
(WebCore::RenderElement::noLongerAffectsParentBlock const):
(WebCore::RenderElement::styleDidChange):
* rendering/RenderElement.h:
(WebCore::RenderElement::noLongerAffectsParentBlock const): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229137 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h

index be45947..f396a02 100644 (file)
@@ -1,3 +1,24 @@
+2018-03-01  Zalan Bujtas  <zalan@apple.com>
+
+        Remove RenderElement::s_noLongerAffectsParentBlock
+        https://bugs.webkit.org/show_bug.cgi?id=183196
+        <rdar://problem/38030797>
+
+        Reviewed by Antti Koivisto.
+
+        Remove the hack to track floating/out-of-flow changes between styleWillChange and styleDidChange.
+
+        Covered by existing tests.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::styleDidChange):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::styleWillChange):
+        (WebCore::RenderElement::noLongerAffectsParentBlock const):
+        (WebCore::RenderElement::styleDidChange):
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::noLongerAffectsParentBlock const): Deleted.
+
 2018-03-01  Chris Dumez  <cdumez@apple.com>
 
         imported/w3c/web-platform-tests/html/browsers/windows/browsing-context.html fails with async policy delegates
index 23ee182..0544025 100644 (file)
@@ -2022,7 +2022,7 @@ void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol
     }
     // Fresh floats need to be reparented if they actually belong to the previous anonymous block.
     // It copies the logic of RenderBlock::addChildIgnoringContinuation
-    if (noLongerAffectsParentBlock() && style().isFloating() && previousSibling() && previousSibling()->isAnonymousBlock())
+    if (oldStyle && noLongerAffectsParentBlock(*oldStyle) && style().isFloating() && previousSibling() && previousSibling()->isAnonymousBlock())
         RenderTreeBuilder::current()->move(downcast<RenderBoxModelObject>(*parent()), downcast<RenderBoxModelObject>(*previousSibling()), *this, RenderTreeBuilder::NormalizeAfterInsertion::No);
 
     if (diff >= StyleDifferenceRepaint) {
index 411a02b..bc79252 100644 (file)
@@ -94,8 +94,6 @@ struct SameSizeAsRenderElement : public RenderObject {
 
 static_assert(sizeof(RenderElement) == sizeof(SameSizeAsRenderElement), "RenderElement should stay small");
 
-bool RenderElement::s_noLongerAffectsParentBlock = false;
-    
 inline RenderElement::RenderElement(ContainerNode& elementOrDocument, RenderStyle&& style, BaseTypeFlags baseTypeFlags)
     : RenderObject(elementOrDocument)
     , m_baseTypeFlags(baseTypeFlags)
@@ -748,9 +746,6 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
             downcast<RenderBox>(*this).removeFloatingOrPositionedChildFromBlockLists();
         }
 
-        s_noLongerAffectsParentBlock = ((!isFloating() && newStyle.isFloating()) || (!isOutOfFlowPositioned() && newStyle.hasOutOfFlowPosition()))
-            && parent() && parent()->isRenderBlock();
-
         // reset style flags
         if (diff == StyleDifferenceLayout || diff == StyleDifferenceLayoutPositionedMovementOnly) {
             setFloating(false);
@@ -764,8 +759,7 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
         setHasOverflowClip(false);
         setHasTransformRelatedProperty(false);
         setHasReflection(false);
-    } else
-        s_noLongerAffectsParentBlock = false;
+    }
 
     bool newStyleSlowScroll = false;
     if (newStyle.hasFixedBackgroundImage() && !settings().fixedBackgroundsPaintRelativeToDocument()) {
@@ -798,6 +792,12 @@ static inline bool areCursorsEqual(const RenderStyle* a, const RenderStyle* b)
 }
 #endif
 
+bool RenderElement::noLongerAffectsParentBlock(const RenderStyle& oldStyle) const
+{
+    return parent() && parent()->isRenderBlock()
+        && ((!oldStyle.isFloating() && style().isFloating()) || (!oldStyle.hasOutOfFlowPosition() && style().hasOutOfFlowPosition()));
+}
+
 void RenderElement::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
     updateFillImages(oldStyle ? &oldStyle->backgroundLayers() : nullptr, m_style.backgroundLayers());
@@ -818,7 +818,7 @@ void RenderElement::styleDidChange(StyleDifference diff, const RenderStyle* oldS
             RenderTreeBuilder::current()->childFlowStateChangesAndAffectsParentBlock(*this);
     }
 
-    if (s_noLongerAffectsParentBlock)
+    if (oldStyle && noLongerAffectsParentBlock(*oldStyle))
         RenderTreeBuilder::current()->childFlowStateChangesAndNoLongerAffectsParentBlock(*this);
 
     SVGRenderSupport::styleChanged(*this, oldStyle);
index 161cfcb..7e658d9 100644 (file)
@@ -280,9 +280,10 @@ protected:
     void removeFromRenderFragmentedFlowIncludingDescendants(bool shouldUpdateState);
     void adjustFragmentedFlowStateOnContainingBlockChangeIfNeeded();
     
-    bool noLongerAffectsParentBlock() const { return s_noLongerAffectsParentBlock; }
     bool isVisibleInViewport() const;
 
+    bool noLongerAffectsParentBlock(const RenderStyle& oldStyle) const;
+
 private:
     RenderElement(ContainerNode&, RenderStyle&&, BaseTypeFlags);
     void node() const = delete;
@@ -348,10 +349,6 @@ private:
     RenderObject* m_lastChild;
 
     RenderStyle m_style;
-
-    // FIXME: Get rid of this hack.
-    // Store state between styleWillChange and styleDidChange
-    static bool s_noLongerAffectsParentBlock;
 };
 
 inline void RenderElement::setAncestorLineBoxDirty(bool f)