Move more code out from RenderObject
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 20:51:41 +0000 (20:51 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 20:51:41 +0000 (20:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161980

Reviewed by Zalan Bujtas.

Move some functions that are only needed for RenderElement there.
Move collapsing anonymous table rows to RenderTableRow.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::hasOutlineAnnotation):
(WebCore::RenderElement::hasSelfPaintingLayer):
(WebCore::RenderElement::checkForRepaintDuringLayout):
* rendering/RenderElement.h:
(WebCore::RenderElement::hasOutline):
(WebCore::RenderElement::hasHiddenBackface): Deleted.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::rootOrBodyStyleChanged):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::pixelSnappedAbsoluteClippedOverflowRect):
(WebCore::RenderObject::destroyAndCleanupAnonymousWrappers):
(WebCore::RenderObject::hasSelfPaintingLayer): Deleted.
(WebCore::RenderObject::checkForRepaintDuringLayout): Deleted.
(WebCore::RenderObject::hasOutlineAnnotation): Deleted.
(WebCore::RenderObject::hasEntirelyFixedBackground): Deleted.
(WebCore::collapseAnonymousTableRowsIfNeeded): Deleted.
* rendering/RenderObject.h:
(WebCore::RenderObject::hasLayer):
(WebCore::RenderObject::canBeSelectionLeaf):
(WebCore::RenderObject::hasOutline): Deleted.
(WebCore::RenderObject::hasSelectedChildren): Deleted.
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::destroyAndCollapseAnonymousSiblingRows):
* rendering/RenderTableRow.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::rootBackgroundIsEntirelyFixed):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderTableRow.cpp
Source/WebCore/rendering/RenderTableRow.h
Source/WebCore/rendering/RenderView.cpp

index 80a8081..0403792 100644 (file)
@@ -1,3 +1,41 @@
+2016-09-14  Antti Koivisto  <antti@apple.com>
+
+        Move more code out from RenderObject
+        https://bugs.webkit.org/show_bug.cgi?id=161980
+
+        Reviewed by Zalan Bujtas.
+
+        Move some functions that are only needed for RenderElement there.
+        Move collapsing anonymous table rows to RenderTableRow.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::hasOutlineAnnotation):
+        (WebCore::RenderElement::hasSelfPaintingLayer):
+        (WebCore::RenderElement::checkForRepaintDuringLayout):
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::hasOutline):
+        (WebCore::RenderElement::hasHiddenBackface): Deleted.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::rootOrBodyStyleChanged):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::pixelSnappedAbsoluteClippedOverflowRect):
+        (WebCore::RenderObject::destroyAndCleanupAnonymousWrappers):
+        (WebCore::RenderObject::hasSelfPaintingLayer): Deleted.
+        (WebCore::RenderObject::checkForRepaintDuringLayout): Deleted.
+        (WebCore::RenderObject::hasOutlineAnnotation): Deleted.
+        (WebCore::RenderObject::hasEntirelyFixedBackground): Deleted.
+        (WebCore::collapseAnonymousTableRowsIfNeeded): Deleted.
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::hasLayer):
+        (WebCore::RenderObject::canBeSelectionLeaf):
+        (WebCore::RenderObject::hasOutline): Deleted.
+        (WebCore::RenderObject::hasSelectedChildren): Deleted.
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::destroyAndCollapseAnonymousSiblingRows):
+        * rendering/RenderTableRow.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::rootBackgroundIsEntirelyFixed):
+
 2016-09-14  Daniel Bates  <dabates@apple.com>
 
         Switch CSSParser to use CSSParserFastPaths::isKeywordPropertyID()
index c5097f7..8250186 100644 (file)
@@ -2173,6 +2173,24 @@ void RenderElement::updateOutlineAutoAncestor(bool hasOutlineAuto)
         downcast<RenderBoxModelObject>(*this).continuation()->updateOutlineAutoAncestor(hasOutlineAuto);
 }
 
+bool RenderElement::hasOutlineAnnotation() const
+{
+    return element() && element()->isLink() && document().printing();
+}
+
+bool RenderElement::hasSelfPaintingLayer() const
+{
+    if (!hasLayer())
+        return false;
+    auto& layerModelObject = downcast<RenderLayerModelObject>(*this);
+    return layerModelObject.hasSelfPaintingLayer();
+}
+
+bool RenderElement::checkForRepaintDuringLayout() const
+{
+    return !document().view()->needsFullRepaint() && everHadLayout() && !hasSelfPaintingLayer();
+}
+
 #if ENABLE(IOS_TEXT_AUTOSIZING)
 static RenderObject::BlockContentHeightType includeNonFixedHeight(const RenderObject& renderer)
 {
index 5db6a2c..0c875d7 100644 (file)
@@ -161,6 +161,11 @@ public:
     bool hasClipOrOverflowClip() const { return hasClip() || hasOverflowClip(); }
     bool hasClipPath() const { return style().clipPath(); }
     bool hasHiddenBackface() const { return style().backfaceVisibility() == BackfaceVisibilityHidden; }
+    bool hasOutlineAnnotation() const;
+    bool hasOutline() const { return style().hasOutline() || hasOutlineAnnotation(); }
+    bool hasSelfPaintingLayer() const;
+
+    bool checkForRepaintDuringLayout() const;
 
     // anchorRect() is conceptually similar to absoluteBoundingBoxRect(), but is intended for scrolling to an anchor.
     // For inline renderers, this gets the logical top left of the first leaf child and the logical bottom right of the
@@ -177,6 +182,7 @@ public:
 #endif
     }
 
+
 #if ENABLE(CSS_COMPOSITING)
     bool hasBlendMode() const { return style().hasBlendMode(); }
 #else
index 08c32ca..223f60c 100644 (file)
@@ -3233,7 +3233,7 @@ void RenderLayerCompositor::rootOrBodyStyleChanged(RenderElement& renderer, cons
         rootBackgroundTransparencyChanged();
 
     bool hadFixedBackground = oldStyle && oldStyle->hasEntirelyFixedBackground();
-    if (hadFixedBackground != renderer.hasEntirelyFixedBackground()) {
+    if (hadFixedBackground != renderer.style().hasEntirelyFixedBackground()) {
         setCompositingLayersNeedRebuild();
         scheduleCompositingLayerUpdate();
     }
index cd62a26..1d0871e 100644 (file)
@@ -62,7 +62,6 @@
 #include "RenderSVGResourceContainer.h"
 #include "RenderScrollbarPart.h"
 #include "RenderTableRow.h"
-#include "RenderTableSection.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
@@ -907,22 +906,7 @@ IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const
 {
     return snappedIntRect(absoluteClippedOverflowRect());
 }
-
-bool RenderObject::hasSelfPaintingLayer() const
-{
-    if (!hasLayer())
-        return false;
-    auto* layer = downcast<RenderLayerModelObject>(*this).layer();
-    if (!layer)
-        return false;
-    return layer->isSelfPaintingLayer();
-}
     
-bool RenderObject::checkForRepaintDuringLayout() const
-{
-    return !document().view()->needsFullRepaint() && everHadLayout() && !hasSelfPaintingLayer();
-}
-
 LayoutRect RenderObject::rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const
 {
     LayoutRect r(clippedOverflowRectForRepaint(repaintContainer));
@@ -1374,16 +1358,6 @@ RespectImageOrientationEnum RenderObject::shouldRespectImageOrientation() const
     return (frame().settings().shouldRespectImageOrientation() && is<HTMLImageElement>(node())) ? RespectImageOrientation : DoNotRespectImageOrientation;
 }
 
-bool RenderObject::hasOutlineAnnotation() const
-{
-    return node() && node()->isLink() && document().printing();
-}
-
-bool RenderObject::hasEntirelyFixedBackground() const
-{
-    return style().hasEntirelyFixedBackground();
-}
-
 static inline RenderElement* containerForElement(const RenderObject& renderer, const RenderLayerModelObject* repaintContainer, bool* repaintContainerSkipped)
 {
     // This method is extremely similar to containingBlock(), but with a few notable
@@ -1538,45 +1512,6 @@ void RenderObject::invalidateFlowThreadContainingBlockIncludingDescendants(Rende
         child.invalidateFlowThreadContainingBlockIncludingDescendants(flowThread);
 }
 
-static void collapseAnonymousTableRowsIfNeeded(const RenderObject& rendererToBeDestroyed)
-{
-    if (!is<RenderTableRow>(rendererToBeDestroyed))
-        return;
-
-    auto& rowToBeDestroyed = downcast<RenderTableRow>(rendererToBeDestroyed);
-    auto* section = downcast<RenderTableSection>(rowToBeDestroyed.parent());
-    if (!section)
-        return;
-
-    // All siblings generated?
-    for (auto* current = section->firstRow(); current; current = current->nextRow()) {
-        if (current == &rendererToBeDestroyed)
-            continue;
-        if (!current->isAnonymous())
-            return;
-    }
-
-    RenderTableRow* rowToInsertInto = nullptr;
-    auto* currentRow = section->firstRow();
-    while (currentRow) {
-        if (currentRow == &rendererToBeDestroyed) {
-            currentRow = currentRow->nextRow();
-            continue;
-        }
-        if (!rowToInsertInto) {
-            rowToInsertInto = currentRow;
-            currentRow = currentRow->nextRow();
-            continue;
-        }
-        currentRow->moveAllChildrenTo(rowToInsertInto);
-        auto* destroyThis = currentRow;
-        currentRow = currentRow->nextRow();
-        destroyThis->destroy();
-    }
-    if (rowToInsertInto)
-        rowToInsertInto->setNeedsLayout();
-}
-
 void RenderObject::destroyAndCleanupAnonymousWrappers()
 {
     // If the tree is destroyed, there is no need for a clean-up phase.
@@ -1597,7 +1532,12 @@ void RenderObject::destroyAndCleanupAnonymousWrappers()
         destroyRoot = destroyRootParent;
         destroyRootParent = destroyRootParent->parent();
     }
-    collapseAnonymousTableRowsIfNeeded(*destroyRoot);
+
+    if (is<RenderTableRow>(*destroyRoot)) {
+        downcast<RenderTableRow>(*destroyRoot).destroyAndCollapseAnonymousSiblingRows();
+        return;
+    }
+
     destroyRoot->destroy();
     // WARNING: |this| is deleted here.
 }
index 54ac3ba..00a21fb 100644 (file)
@@ -461,7 +461,6 @@ public:
     VisibleInViewportState visibleInViewportState() { return m_bitfields.hasRareData() ? rareData().visibleInViewportState() : VisibilityUnknown; }
 
     bool hasLayer() const { return m_bitfields.hasLayer(); }
-    bool hasSelfPaintingLayer() const;
 
     enum BoxDecorationState {
         NoBoxDecorations,
@@ -471,7 +470,6 @@ public:
     };
     bool hasVisibleBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
     bool backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset);
-    bool hasEntirelyFixedBackground() const;
 
     bool needsLayout() const
     {
@@ -520,9 +518,6 @@ public:
     Document& document() const { return m_node.document(); }
     Frame& frame() const;
 
-    bool hasOutlineAnnotation() const;
-    bool hasOutline() const { return style().hasOutline() || hasOutlineAnnotation(); }
-
     // Returns the object containing this one. Can be different from parent for positioned elements.
     // If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
     // is true if the renderer returned is an ancestor of repaintContainer.
@@ -677,8 +672,6 @@ public:
     // Repaint a slow repaint object, which, at this time, means we are repainting an object with background-attachment:fixed.
     void repaintSlowRepaintObject() const;
 
-    bool checkForRepaintDuringLayout() const;
-
     // Returns the rect that should be repainted whenever this object changes.  The rect is in the view's
     // coordinate space.  This method deals with outlines and overflow.
     LayoutRect absoluteClippedOverflowRect() const
@@ -735,7 +728,6 @@ public:
     virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return LayoutRect(); }
 
     virtual bool canBeSelectionLeaf() const { return false; }
-    bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
 
     // Whether or not a given block needs to paint selection gaps.
     virtual bool shouldPaintSelectionGaps() const { return false; }
index b41b373..11992e2 100644 (file)
@@ -272,4 +272,44 @@ std::unique_ptr<RenderTableRow> RenderTableRow::createAnonymousWithParentRendere
     return RenderTableRow::createTableRowWithStyle(parent.document(), parent.style());
 }
 
+void RenderTableRow::destroyAndCollapseAnonymousSiblingRows()
+{
+    auto collapseAnonymousSiblingRows = [&] {
+        auto* section = this->section();
+        if (!section)
+            return;
+
+        // All siblings generated?
+        for (auto* current = section->firstRow(); current; current = current->nextRow()) {
+            if (current == this)
+                continue;
+            if (!current->isAnonymous())
+                return;
+        }
+
+        RenderTableRow* rowToInsertInto = nullptr;
+        auto* currentRow = section->firstRow();
+        while (currentRow) {
+            if (currentRow == this) {
+                currentRow = currentRow->nextRow();
+                continue;
+            }
+            if (!rowToInsertInto) {
+                rowToInsertInto = currentRow;
+                currentRow = currentRow->nextRow();
+                continue;
+            }
+            currentRow->moveAllChildrenTo(rowToInsertInto);
+            auto* destroyThis = currentRow;
+            currentRow = currentRow->nextRow();
+            destroyThis->destroy();
+        }
+        if (rowToInsertInto)
+            rowToInsertInto->setNeedsLayout();
+    };
+
+    collapseAnonymousSiblingRows();
+    destroy();
+}
+
 } // namespace WebCore
index e42e3e1..3da7c60 100644 (file)
@@ -63,6 +63,8 @@ public:
 
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
 
+    void destroyAndCollapseAnonymousSiblingRows();
+
 private:
     static std::unique_ptr<RenderTableRow> createTableRowWithStyle(Document&, const RenderStyle&);
 
index f52968f..2dc51f3 100644 (file)
@@ -1137,7 +1137,7 @@ bool RenderView::rootBackgroundIsEntirelyFixed() const
     if (!rootObject)
         return false;
 
-    return rootObject->rendererForRootBackground().hasEntirelyFixedBackground();
+    return rootObject->rendererForRootBackground().style().hasEntirelyFixedBackground();
 }
     
 LayoutRect RenderView::unextendedBackgroundRect() const