Changeset 205927 in webkit


Ignore:
Timestamp:
Sep 14, 2016, 1:51:41 PM (9 years ago)
Author:
Antti Koivisto
Message:

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):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205926 r205927  
     12016-09-14  Antti Koivisto  <antti@apple.com>
     2
     3        Move more code out from RenderObject
     4        https://bugs.webkit.org/show_bug.cgi?id=161980
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Move some functions that are only needed for RenderElement there.
     9        Move collapsing anonymous table rows to RenderTableRow.
     10
     11        * rendering/RenderElement.cpp:
     12        (WebCore::RenderElement::hasOutlineAnnotation):
     13        (WebCore::RenderElement::hasSelfPaintingLayer):
     14        (WebCore::RenderElement::checkForRepaintDuringLayout):
     15        * rendering/RenderElement.h:
     16        (WebCore::RenderElement::hasOutline):
     17        (WebCore::RenderElement::hasHiddenBackface): Deleted.
     18        * rendering/RenderLayerCompositor.cpp:
     19        (WebCore::RenderLayerCompositor::rootOrBodyStyleChanged):
     20        * rendering/RenderObject.cpp:
     21        (WebCore::RenderObject::pixelSnappedAbsoluteClippedOverflowRect):
     22        (WebCore::RenderObject::destroyAndCleanupAnonymousWrappers):
     23        (WebCore::RenderObject::hasSelfPaintingLayer): Deleted.
     24        (WebCore::RenderObject::checkForRepaintDuringLayout): Deleted.
     25        (WebCore::RenderObject::hasOutlineAnnotation): Deleted.
     26        (WebCore::RenderObject::hasEntirelyFixedBackground): Deleted.
     27        (WebCore::collapseAnonymousTableRowsIfNeeded): Deleted.
     28        * rendering/RenderObject.h:
     29        (WebCore::RenderObject::hasLayer):
     30        (WebCore::RenderObject::canBeSelectionLeaf):
     31        (WebCore::RenderObject::hasOutline): Deleted.
     32        (WebCore::RenderObject::hasSelectedChildren): Deleted.
     33        * rendering/RenderTableRow.cpp:
     34        (WebCore::RenderTableRow::destroyAndCollapseAnonymousSiblingRows):
     35        * rendering/RenderTableRow.h:
     36        * rendering/RenderView.cpp:
     37        (WebCore::RenderView::rootBackgroundIsEntirelyFixed):
     38
    1392016-09-14  Daniel Bates  <dabates@apple.com>
    240
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r205818 r205927  
    21742174}
    21752175
     2176bool RenderElement::hasOutlineAnnotation() const
     2177{
     2178    return element() && element()->isLink() && document().printing();
     2179}
     2180
     2181bool RenderElement::hasSelfPaintingLayer() const
     2182{
     2183    if (!hasLayer())
     2184        return false;
     2185    auto& layerModelObject = downcast<RenderLayerModelObject>(*this);
     2186    return layerModelObject.hasSelfPaintingLayer();
     2187}
     2188
     2189bool RenderElement::checkForRepaintDuringLayout() const
     2190{
     2191    return !document().view()->needsFullRepaint() && everHadLayout() && !hasSelfPaintingLayer();
     2192}
     2193
    21762194#if ENABLE(IOS_TEXT_AUTOSIZING)
    21772195static RenderObject::BlockContentHeightType includeNonFixedHeight(const RenderObject& renderer)
  • trunk/Source/WebCore/rendering/RenderElement.h

    r204667 r205927  
    162162    bool hasClipPath() const { return style().clipPath(); }
    163163    bool hasHiddenBackface() const { return style().backfaceVisibility() == BackfaceVisibilityHidden; }
     164    bool hasOutlineAnnotation() const;
     165    bool hasOutline() const { return style().hasOutline() || hasOutlineAnnotation(); }
     166    bool hasSelfPaintingLayer() const;
     167
     168    bool checkForRepaintDuringLayout() const;
    164169
    165170    // anchorRect() is conceptually similar to absoluteBoundingBoxRect(), but is intended for scrolling to an anchor.
     
    177182#endif
    178183    }
     184
    179185
    180186#if ENABLE(CSS_COMPOSITING)
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r205818 r205927  
    32343234
    32353235    bool hadFixedBackground = oldStyle && oldStyle->hasEntirelyFixedBackground();
    3236     if (hadFixedBackground != renderer.hasEntirelyFixedBackground()) {
     3236    if (hadFixedBackground != renderer.style().hasEntirelyFixedBackground()) {
    32373237        setCompositingLayersNeedRebuild();
    32383238        scheduleCompositingLayerUpdate();
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r205920 r205927  
    6363#include "RenderScrollbarPart.h"
    6464#include "RenderTableRow.h"
    65 #include "RenderTableSection.h"
    6665#include "RenderTheme.h"
    6766#include "RenderView.h"
     
    908907    return snappedIntRect(absoluteClippedOverflowRect());
    909908}
    910 
    911 bool RenderObject::hasSelfPaintingLayer() const
    912 {
    913     if (!hasLayer())
    914         return false;
    915     auto* layer = downcast<RenderLayerModelObject>(*this).layer();
    916     if (!layer)
    917         return false;
    918     return layer->isSelfPaintingLayer();
    919 }
    920909   
    921 bool RenderObject::checkForRepaintDuringLayout() const
    922 {
    923     return !document().view()->needsFullRepaint() && everHadLayout() && !hasSelfPaintingLayer();
    924 }
    925 
    926910LayoutRect RenderObject::rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const
    927911{
     
    13751359}
    13761360
    1377 bool RenderObject::hasOutlineAnnotation() const
    1378 {
    1379     return node() && node()->isLink() && document().printing();
    1380 }
    1381 
    1382 bool RenderObject::hasEntirelyFixedBackground() const
    1383 {
    1384     return style().hasEntirelyFixedBackground();
    1385 }
    1386 
    13871361static inline RenderElement* containerForElement(const RenderObject& renderer, const RenderLayerModelObject* repaintContainer, bool* repaintContainerSkipped)
    13881362{
     
    15391513}
    15401514
    1541 static void collapseAnonymousTableRowsIfNeeded(const RenderObject& rendererToBeDestroyed)
    1542 {
    1543     if (!is<RenderTableRow>(rendererToBeDestroyed))
    1544         return;
    1545 
    1546     auto& rowToBeDestroyed = downcast<RenderTableRow>(rendererToBeDestroyed);
    1547     auto* section = downcast<RenderTableSection>(rowToBeDestroyed.parent());
    1548     if (!section)
    1549         return;
    1550 
    1551     // All siblings generated?
    1552     for (auto* current = section->firstRow(); current; current = current->nextRow()) {
    1553         if (current == &rendererToBeDestroyed)
    1554             continue;
    1555         if (!current->isAnonymous())
    1556             return;
    1557     }
    1558 
    1559     RenderTableRow* rowToInsertInto = nullptr;
    1560     auto* currentRow = section->firstRow();
    1561     while (currentRow) {
    1562         if (currentRow == &rendererToBeDestroyed) {
    1563             currentRow = currentRow->nextRow();
    1564             continue;
    1565         }
    1566         if (!rowToInsertInto) {
    1567             rowToInsertInto = currentRow;
    1568             currentRow = currentRow->nextRow();
    1569             continue;
    1570         }
    1571         currentRow->moveAllChildrenTo(rowToInsertInto);
    1572         auto* destroyThis = currentRow;
    1573         currentRow = currentRow->nextRow();
    1574         destroyThis->destroy();
    1575     }
    1576     if (rowToInsertInto)
    1577         rowToInsertInto->setNeedsLayout();
    1578 }
    1579 
    15801515void RenderObject::destroyAndCleanupAnonymousWrappers()
    15811516{
     
    15981533        destroyRootParent = destroyRootParent->parent();
    15991534    }
    1600     collapseAnonymousTableRowsIfNeeded(*destroyRoot);
     1535
     1536    if (is<RenderTableRow>(*destroyRoot)) {
     1537        downcast<RenderTableRow>(*destroyRoot).destroyAndCollapseAnonymousSiblingRows();
     1538        return;
     1539    }
     1540
    16011541    destroyRoot->destroy();
    16021542    // WARNING: |this| is deleted here.
  • trunk/Source/WebCore/rendering/RenderObject.h

    r205551 r205927  
    462462
    463463    bool hasLayer() const { return m_bitfields.hasLayer(); }
    464     bool hasSelfPaintingLayer() const;
    465464
    466465    enum BoxDecorationState {
     
    472471    bool hasVisibleBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
    473472    bool backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset);
    474     bool hasEntirelyFixedBackground() const;
    475473
    476474    bool needsLayout() const
     
    520518    Document& document() const { return m_node.document(); }
    521519    Frame& frame() const;
    522 
    523     bool hasOutlineAnnotation() const;
    524     bool hasOutline() const { return style().hasOutline() || hasOutlineAnnotation(); }
    525520
    526521    // Returns the object containing this one. Can be different from parent for positioned elements.
     
    677672    // Repaint a slow repaint object, which, at this time, means we are repainting an object with background-attachment:fixed.
    678673    void repaintSlowRepaintObject() const;
    679 
    680     bool checkForRepaintDuringLayout() const;
    681674
    682675    // Returns the rect that should be repainted whenever this object changes.  The rect is in the view's
     
    736729
    737730    virtual bool canBeSelectionLeaf() const { return false; }
    738     bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
    739731
    740732    // Whether or not a given block needs to paint selection gaps.
  • trunk/Source/WebCore/rendering/RenderTableRow.cpp

    r203708 r205927  
    273273}
    274274
     275void RenderTableRow::destroyAndCollapseAnonymousSiblingRows()
     276{
     277    auto collapseAnonymousSiblingRows = [&] {
     278        auto* section = this->section();
     279        if (!section)
     280            return;
     281
     282        // All siblings generated?
     283        for (auto* current = section->firstRow(); current; current = current->nextRow()) {
     284            if (current == this)
     285                continue;
     286            if (!current->isAnonymous())
     287                return;
     288        }
     289
     290        RenderTableRow* rowToInsertInto = nullptr;
     291        auto* currentRow = section->firstRow();
     292        while (currentRow) {
     293            if (currentRow == this) {
     294                currentRow = currentRow->nextRow();
     295                continue;
     296            }
     297            if (!rowToInsertInto) {
     298                rowToInsertInto = currentRow;
     299                currentRow = currentRow->nextRow();
     300                continue;
     301            }
     302            currentRow->moveAllChildrenTo(rowToInsertInto);
     303            auto* destroyThis = currentRow;
     304            currentRow = currentRow->nextRow();
     305            destroyThis->destroy();
     306        }
     307        if (rowToInsertInto)
     308            rowToInsertInto->setNeedsLayout();
     309    };
     310
     311    collapseAnonymousSiblingRows();
     312    destroy();
     313}
     314
    275315} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderTableRow.h

    r203708 r205927  
    6363
    6464    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
     65
     66    void destroyAndCollapseAnonymousSiblingRows();
    6567
    6668private:
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r205818 r205927  
    11381138        return false;
    11391139
    1140     return rootObject->rendererForRootBackground().hasEntirelyFixedBackground();
     1140    return rootObject->rendererForRootBackground().style().hasEntirelyFixedBackground();
    11411141}
    11421142   
Note: See TracChangeset for help on using the changeset viewer.