Move some RenderObject member functions to RenderElement.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 26 Oct 2014 22:25:00 +0000 (22:25 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 26 Oct 2014 22:25:00 +0000 (22:25 +0000)
<https://webkit.org/b/138085>

Reviewed by Chris Dumez.

Move these two functions to RenderElement:

    - handleDynamicFloatPositionChange()
    - removeAnonymousWrappersForInlinesIfNecessary()

Also make childBecameNonInline() take a RenderElement& since
that's all we ever pass to it.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::childBecameNonInline):
* rendering/RenderBlock.h:
* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::childBecameNonInline):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::handleDynamicFloatPositionChange):
(WebCore::RenderElement::removeAnonymousWrappersForInlinesIfNecessary):
* rendering/RenderElement.h:
* rendering/RenderInline.cpp:
(WebCore::RenderInline::childBecameNonInline):
* rendering/RenderInline.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::handleDynamicFloatPositionChange): Deleted.
(WebCore::RenderObject::removeAnonymousWrappersForInlinesIfNecessary): Deleted.
* rendering/RenderObject.h:

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h

index dcd4590..7abec2d 100644 (file)
@@ -1,5 +1,37 @@
 2014-10-26  Andreas Kling  <akling@apple.com>
 
+        Move some RenderObject member functions to RenderElement.
+        <https://webkit.org/b/138085>
+
+        Reviewed by Chris Dumez.
+
+        Move these two functions to RenderElement:
+
+            - handleDynamicFloatPositionChange()
+            - removeAnonymousWrappersForInlinesIfNecessary()
+
+        Also make childBecameNonInline() take a RenderElement& since
+        that's all we ever pass to it.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::childBecameNonInline):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::RenderBoxModelObject::childBecameNonInline):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::handleDynamicFloatPositionChange):
+        (WebCore::RenderElement::removeAnonymousWrappersForInlinesIfNecessary):
+        * rendering/RenderElement.h:
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::childBecameNonInline):
+        * rendering/RenderInline.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::handleDynamicFloatPositionChange): Deleted.
+        (WebCore::RenderObject::removeAnonymousWrappersForInlinesIfNecessary): Deleted.
+        * rendering/RenderObject.h:
+
+2014-10-26  Andreas Kling  <akling@apple.com>
+
         Move continuation teardown from subclasses to RenderBoxModelObject.
         <https://webkit.org/b/138081>
 
index fe50e94..5476dab 100644 (file)
@@ -3397,7 +3397,7 @@ const RenderStyle& RenderBlock::outlineStyleForRepaint() const
     return isAnonymousBlockContinuation() ? continuation()->style() : style();
 }
 
-void RenderBlock::childBecameNonInline(RenderObject*)
+void RenderBlock::childBecameNonInline(RenderElement&)
 {
     makeChildrenNonInline();
     if (isAnonymousBlock() && is<RenderBlock>(parent()))
index e4503d7..4932480 100644 (file)
@@ -457,7 +457,7 @@ private:
 
     virtual RenderElement* hoverAncestor() const override final;
     virtual void updateDragState(bool dragOn) override final;
-    virtual void childBecameNonInline(RenderObject* child) override final;
+    virtual void childBecameNonInline(RenderElement&) override final;
 
     virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool /*clipToVisibleContent*/) override final
     {
index 03af861..19558c6 100644 (file)
@@ -171,7 +171,7 @@ public:
 
     virtual LayoutUnit containingBlockLogicalWidthForContent() const;
 
-    virtual void childBecameNonInline(RenderObject* /*child*/) { }
+    virtual void childBecameNonInline(RenderElement&) { }
 
     void paintBorder(const PaintInfo&, const LayoutRect&, const RenderStyle&, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
     bool paintNinePieceImage(GraphicsContext*, const LayoutRect&, const RenderStyle&, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
index dea813f..485a470 100644 (file)
@@ -897,6 +897,51 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
         view().frameView().updateExtendBackgroundIfNecessary();
 }
 
+void RenderElement::handleDynamicFloatPositionChange()
+{
+    // We have gone from not affecting the inline status of the parent flow to suddenly
+    // having an impact.  See if there is a mismatch between the parent flow's
+    // childrenInline() state and our state.
+    setInline(style().isDisplayInlineType());
+    if (isInline() != parent()->childrenInline()) {
+        if (!isInline())
+            downcast<RenderBoxModelObject>(*parent()).childBecameNonInline(*this);
+        else {
+            // An anonymous block must be made to wrap this inline.
+            RenderBlock* block = downcast<RenderBlock>(*parent()).createAnonymousBlock();
+            parent()->insertChildInternal(block, this, RenderElement::NotifyChildren);
+            parent()->removeChildInternal(*this, RenderElement::NotifyChildren);
+            block->insertChildInternal(this, nullptr, RenderElement::NotifyChildren);
+        }
+    }
+}
+
+void RenderElement::removeAnonymousWrappersForInlinesIfNecessary()
+{
+    RenderBlock& parentBlock = downcast<RenderBlock>(*parent());
+    if (!parentBlock.canCollapseAnonymousBlockChild())
+        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 = parent()->firstChild();
+    while (current && ((current->isAnonymousBlock() && !downcast<RenderBlock>(*current).isAnonymousBlockContinuation()) || current->style().isFloating() || current->style().hasOutOfFlowPosition()))
+        current = current->nextSibling();
+
+    if (current)
+        return;
+
+    RenderObject* next;
+    for (current = parent()->firstChild(); current; current = next) {
+        next = current->nextSibling();
+        if (current->isAnonymousBlock())
+            parentBlock.collapseAnonymousBoxChild(parentBlock, downcast<RenderBlock>(current));
+    }
+}
+
 #if !PLATFORM(IOS)
 static bool areNonIdenticalCursorListsEqual(const RenderStyle* a, const RenderStyle* b)
 {
index 7052863..0530a0a 100644 (file)
@@ -217,6 +217,12 @@ private:
     virtual RenderObject* firstChildSlow() const override final { return firstChild(); }
     virtual RenderObject* lastChildSlow() const override final { return lastChild(); }
 
+    // Called when an object that was floating or positioned becomes a normal flow object
+    // again.  We have to make sure the render tree updates as needed to accommodate the new
+    // normal flow object.
+    void handleDynamicFloatPositionChange();
+    void removeAnonymousWrappersForInlinesIfNecessary();
+
     bool shouldRepaintForStyleDifference(StyleDifference) const;
     bool hasImmediateNonWhitespaceTextChildOrBorderOrOutline() const;
 
index 944e0a4..f806472 100644 (file)
@@ -1297,15 +1297,15 @@ void RenderInline::updateDragState(bool dragOn)
         continuation->updateDragState(dragOn);
 }
 
-void RenderInline::childBecameNonInline(RenderObject* child)
+void RenderInline::childBecameNonInline(RenderElement& child)
 {
     // We have to split the parent flow.
     RenderBlock* newBox = containingBlock()->createAnonymousBlock();
     RenderBoxModelObject* oldContinuation = continuation();
     setContinuation(newBox);
-    RenderObject* beforeChild = child->nextSibling();
-    removeChildInternal(*child, NotifyChildren);
-    splitFlow(beforeChild, newBox, child, oldContinuation);
+    RenderObject* beforeChild = child.nextSibling();
+    removeChildInternal(child, NotifyChildren);
+    splitFlow(beforeChild, newBox, &child, oldContinuation);
 }
 
 void RenderInline::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
index a4febd0..c4b3bb1 100644 (file)
@@ -161,7 +161,7 @@ private:
     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
     
-    virtual void childBecameNonInline(RenderObject* child) override final;
+    virtual void childBecameNonInline(RenderElement&) override final;
 
     virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) override final;
 
index abbc2b4..63dec8f 100644 (file)
@@ -1635,51 +1635,6 @@ void RenderObject::selectionStartEnd(int& spos, int& epos) const
     selectionRoot().selectionStartEndPositions(spos, epos);
 }
 
-void RenderObject::handleDynamicFloatPositionChange()
-{
-    // We have gone from not affecting the inline status of the parent flow to suddenly
-    // having an impact.  See if there is a mismatch between the parent flow's
-    // childrenInline() state and our state.
-    setInline(style().isDisplayInlineType());
-    if (isInline() != parent()->childrenInline()) {
-        if (!isInline())
-            downcast<RenderBoxModelObject>(*parent()).childBecameNonInline(this);
-        else {
-            // An anonymous block must be made to wrap this inline.
-            RenderBlock* block = downcast<RenderBlock>(*parent()).createAnonymousBlock();
-            parent()->insertChildInternal(block, this, RenderElement::NotifyChildren);
-            parent()->removeChildInternal(*this, RenderElement::NotifyChildren);
-            block->insertChildInternal(this, nullptr, RenderElement::NotifyChildren);
-        }
-    }
-}
-
-void RenderObject::removeAnonymousWrappersForInlinesIfNecessary()
-{
-    RenderBlock& parentBlock = downcast<RenderBlock>(*parent());
-    if (!parentBlock.canCollapseAnonymousBlockChild())
-        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 = parent()->firstChild();
-    while (current && ((current->isAnonymousBlock() && !downcast<RenderBlock>(*current).isAnonymousBlockContinuation()) || current->style().isFloating() || current->style().hasOutOfFlowPosition()))
-        current = current->nextSibling();
-
-    if (current)
-        return;
-
-    RenderObject* next;
-    for (current = parent()->firstChild(); current; current = next) {
-        next = current->nextSibling();
-        if (current->isAnonymousBlock())
-            parentBlock.collapseAnonymousBoxChild(parentBlock, downcast<RenderBlock>(current));
-    }
-}
-
 FloatPoint RenderObject::localToAbsolute(const FloatPoint& localPoint, MapCoordinatesFlags mode) const
 {
     TransformState transformState(TransformState::ApplyTransformDirection, localPoint);
index d7d3198..d1d8521 100644 (file)
@@ -245,12 +245,6 @@ public:
     // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
     // children.
     virtual RenderBlock* firstLineBlock() const;
-
-    // Called when an object that was floating or positioned becomes a normal flow object
-    // again.  We have to make sure the render tree updates as needed to accommodate the new
-    // normal flow object.
-    void handleDynamicFloatPositionChange();
-    void removeAnonymousWrappersForInlinesIfNecessary();
     
     // RenderObject tree manipulation
     //////////////////////////////////////////