[RenderTreeBuilder] Move RenderElement::removeAnonymousWrappersForInlinesIfNecessary...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 15:40:21 +0000 (15:40 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 15:40:21 +0000 (15:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182582
<rdar://problem/37327890>

Reviewed by Antti Koivisto.

Tree mutation -> RenderTreeBuilder.

No change in functionality

* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleDidChange):
(WebCore::RenderElement::removeAnonymousWrappersForInlinesIfNecessary): Deleted.
* rendering/RenderElement.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::removeAnonymousWrappersForInlinesIfNecessary):
(WebCore::RenderTreeBuilder::childFlowStateChangesAndNoLongerAffectsParentBlock):
(WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
* rendering/updating/RenderTreeBuilder.h:

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
Source/WebCore/rendering/updating/RenderTreeBuilder.h

index eadeef0..d4c1cc8 100644 (file)
@@ -1,3 +1,25 @@
+2018-02-08  Zalan Bujtas  <zalan@apple.com>
+
+        [RenderTreeBuilder] Move RenderElement::removeAnonymousWrappersForInlinesIfNecessary to RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182582
+        <rdar://problem/37327890>
+
+        Reviewed by Antti Koivisto.
+
+        Tree mutation -> RenderTreeBuilder.
+
+        No change in functionality
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::styleDidChange):
+        (WebCore::RenderElement::removeAnonymousWrappersForInlinesIfNecessary): Deleted.
+        * rendering/RenderElement.h:
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::removeAnonymousWrappersForInlinesIfNecessary):
+        (WebCore::RenderTreeBuilder::childFlowStateChangesAndNoLongerAffectsParentBlock):
+        (WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
+        * rendering/updating/RenderTreeBuilder.h:
+
 2018-02-08  Philippe Normand  <pnormand@igalia.com>
 
         [GStreamer] LayoutTest webaudio/silent-audio-interrupted-in-background.html makes its subsequent test flaky crash
 2018-02-08  Philippe Normand  <pnormand@igalia.com>
 
         [GStreamer] LayoutTest webaudio/silent-audio-interrupted-in-background.html makes its subsequent test flaky crash
index 7380df6..b740d98 100644 (file)
@@ -915,35 +915,6 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
         view().frameView().updateExtendBackgroundIfNecessary();
 }
 
         view().frameView().updateExtendBackgroundIfNecessary();
 }
 
-void RenderElement::removeAnonymousWrappersForInlinesIfNecessary()
-{
-    // FIXME: Move to RenderBlock.
-    if (!is<RenderBlock>(*this))
-        return;
-    RenderBlock& thisBlock = downcast<RenderBlock>(*this);
-    if (!thisBlock.canDropAnonymousBlockChild())
-        return;
-
-    // We have changed to floated or out-of-flow positioning so maybe all our parent's
-    // children can be inline now. Bail if there are any block children left on the line,
-    // otherwise we can proceed to stripping solitary anonymous wrappers from the inlines.
-    // FIXME: We should also handle split inlines here - we exclude them at the moment by returning
-    // if we find a continuation.
-    RenderObject* current = firstChild();
-    while (current && ((current->isAnonymousBlock() && !downcast<RenderBlock>(*current).isContinuation()) || current->style().isFloating() || current->style().hasOutOfFlowPosition()))
-        current = current->nextSibling();
-
-    if (current)
-        return;
-
-    RenderObject* next;
-    for (current = firstChild(); current; current = next) {
-        next = current->nextSibling();
-        if (current->isAnonymousBlock())
-            thisBlock.dropAnonymousBoxChild(downcast<RenderBlock>(*current));
-    }
-}
-
 #if !PLATFORM(IOS)
 static bool areNonIdenticalCursorListsEqual(const RenderStyle* a, const RenderStyle* b)
 {
 #if !PLATFORM(IOS)
 static bool areNonIdenticalCursorListsEqual(const RenderStyle* a, const RenderStyle* b)
 {
@@ -975,7 +946,7 @@ void RenderElement::styleDidChange(StyleDifference diff, const RenderStyle* oldS
     }
 
     if (s_noLongerAffectsParentBlock)
     }
 
     if (s_noLongerAffectsParentBlock)
-        parent()->removeAnonymousWrappersForInlinesIfNecessary();
+        RenderTreeBuilder::current()->childFlowStateChangesAndNoLongerAffectsParentBlock(*this);
 
     SVGRenderSupport::styleChanged(*this, oldStyle);
 
 
     SVGRenderSupport::styleChanged(*this, oldStyle);
 
index 907d219..ceab7c8 100644 (file)
@@ -220,8 +220,6 @@ public:
     // the child.
     virtual void updateAnonymousChildStyle(RenderStyle&) const { };
 
     // the child.
     virtual void updateAnonymousChildStyle(RenderStyle&) const { };
 
-    void removeAnonymousWrappersForInlinesIfNecessary();
-
     bool hasContinuationChainNode() const { return m_hasContinuationChainNode; }
     bool isContinuation() const { return m_isContinuation; }
     void setIsContinuation() { m_isContinuation = true; }
     bool hasContinuationChainNode() const { return m_hasContinuationChainNode; }
     bool isContinuation() const { return m_isContinuation; }
     void setIsContinuation() { m_isContinuation = true; }
index bf6ac02..f6224a8 100644 (file)
@@ -318,6 +318,40 @@ void RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock(RenderElement
     }
 }
 
     }
 }
 
+void RenderTreeBuilder::removeAnonymousWrappersForInlineChildrenIfNeeded(RenderElement& parent)
+{
+    if (!is<RenderBlock>(parent))
+        return;
+    auto& blockParent = downcast<RenderBlock>(parent);
+    if (!blockParent.canDropAnonymousBlockChild())
+        return;
+
+    // We have changed to floated or out-of-flow positioning so maybe all our parent's
+    // children can be inline now. Bail if there are any block children left on the line,
+    // otherwise we can proceed to stripping solitary anonymous wrappers from the inlines.
+    // FIXME: We should also handle split inlines here - we exclude them at the moment by returning
+    // if we find a continuation.
+    auto* current = blockParent.firstChild();
+    while (current && ((current->isAnonymousBlock() && !downcast<RenderBlock>(*current).isContinuation()) || current->style().isFloating() || current->style().hasOutOfFlowPosition()))
+        current = current->nextSibling();
+
+    if (current)
+        return;
+
+    RenderObject* next;
+    for (current = blockParent.firstChild(); current; current = next) {
+        next = current->nextSibling();
+        if (current->isAnonymousBlock())
+            blockParent.dropAnonymousBoxChild(downcast<RenderBlock>(*current));
+    }
+}
+
+void RenderTreeBuilder::childFlowStateChangesAndNoLongerAffectsParentBlock(RenderElement& child)
+{
+    ASSERT(child.parent());
+    removeAnonymousWrappersForInlineChildrenIfNeeded(*child.parent());
+}
+
 static bool isAnonymousAndSafeToDelete(RenderElement& element)
 {
     if (!element.isAnonymous())
 static bool isAnonymousAndSafeToDelete(RenderElement& element)
 {
     if (!element.isAnonymous())
@@ -359,7 +393,7 @@ void RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers(Re
 
     auto& destroyRootParent = *destroyRoot.parent();
     destroyRootParent.removeAndDestroyChild(*this, destroyRoot);
 
     auto& destroyRootParent = *destroyRoot.parent();
     destroyRootParent.removeAndDestroyChild(*this, destroyRoot);
-    destroyRootParent.removeAnonymousWrappersForInlinesIfNecessary();
+    removeAnonymousWrappersForInlineChildrenIfNeeded(destroyRootParent);
 
     // Anonymous parent might have become empty, try to delete it too.
     if (isAnonymousAndSafeToDelete(destroyRootParent) && !destroyRootParent.firstChild())
 
     // Anonymous parent might have become empty, try to delete it too.
     if (isAnonymousAndSafeToDelete(destroyRootParent) && !destroyRootParent.firstChild())
index 912d3bb..bca8636 100644 (file)
@@ -76,6 +76,7 @@ public:
     RenderObject* splitAnonymousBoxesAroundChild(RenderBox& parent, RenderObject* beforeChild);
     void moveRubyChildren(RenderRubyBase& from, RenderRubyBase& to);
     void childFlowStateChangesAndAffectsParentBlock(RenderElement& child);
     RenderObject* splitAnonymousBoxesAroundChild(RenderBox& parent, RenderObject* beforeChild);
     void moveRubyChildren(RenderRubyBase& from, RenderRubyBase& to);
     void childFlowStateChangesAndAffectsParentBlock(RenderElement& child);
+    void childFlowStateChangesAndNoLongerAffectsParentBlock(RenderElement& child);
     RenderObject* resolveMovedChildForMultiColumnFlow(RenderFragmentedFlow& enclosingFragmentedFlow, RenderObject* beforeChild);
     void removeFromParentAndDestroyCleaningUpAnonymousWrappers(RenderObject& child);
 
     RenderObject* resolveMovedChildForMultiColumnFlow(RenderFragmentedFlow& enclosingFragmentedFlow, RenderObject* beforeChild);
     void removeFromParentAndDestroyCleaningUpAnonymousWrappers(RenderObject& child);
 
@@ -92,6 +93,8 @@ private:
     class SVG;
     class MathML;
 
     class SVG;
     class MathML;
 
+    void removeAnonymousWrappersForInlineChildrenIfNeeded(RenderElement& parent);
+
     FirstLetter& firstLetterBuilder() { return *m_firstLetterBuilder; }
     List& listBuilder() { return *m_listBuilder; }
     MultiColumn& multiColumnBuilder() { return *m_multiColumnBuilder; }
     FirstLetter& firstLetterBuilder() { return *m_firstLetterBuilder; }
     List& listBuilder() { return *m_listBuilder; }
     MultiColumn& multiColumnBuilder() { return *m_multiColumnBuilder; }