Make outline: auto repaint rect inflate more explicit.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 02:57:32 +0000 (02:57 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Aug 2015 02:57:32 +0000 (02:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148263

Reviewed by Simon Fraser.

Use RenderObject::adjustRectWithMaximumOutline() when inflating is conditional and call
RenderView::maximalOutlineSize() when it is not.
After this changeset, we can clearly tell calls when inflating is unconditional (adjusting the size of the compositing layer) apart from
calls when we just simply inflate the repaint rect during outline painting phase.

No change in behaviour.

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paint):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paint):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlock):
* rendering/RenderDetailsMarker.cpp:
(WebCore::RenderDetailsMarker::paint):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::computeMaxOutlineSize):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLineBoxList.cpp:
(WebCore::isOutlinePhase):
(WebCore::RenderLineBoxList::lineIntersectsDirtyRect):
(WebCore::RenderLineBoxList::paint):
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::paint):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::adjustRectWithMaximumOutline):
(WebCore::RenderObject::maximalOutlineSize): Deleted.
* rendering/RenderObject.h:
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::overflowRectForFlowThreadPortion):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::shouldPaint):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::paint):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintCollapsedBorders):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::paintObject):
* rendering/RenderView.cpp:
(WebCore::RenderView::setMaximalOutlineSize):
(WebCore::RenderView::RenderView): Deleted.
* rendering/RenderView.h:

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderDetailsMarker.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLineBoxList.cpp
Source/WebCore/rendering/RenderListMarker.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderRegion.cpp
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderView.h

index ded1fb6..1100605 100644 (file)
@@ -1,3 +1,54 @@
+2015-08-20  Zalan Bujtas  <zalan@apple.com>
+
+        Make outline: auto repaint rect inflate more explicit.
+        https://bugs.webkit.org/show_bug.cgi?id=148263
+
+        Reviewed by Simon Fraser.
+
+        Use RenderObject::adjustRectWithMaximumOutline() when inflating is conditional and call
+        RenderView::maximalOutlineSize() when it is not.
+        After this changeset, we can clearly tell calls when inflating is unconditional (adjusting the size of the compositing layer) apart from
+        calls when we just simply inflate the repaint rect during outline painting phase.
+
+        No change in behaviour.
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::paint):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paint):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::layoutBlock):
+        * rendering/RenderDetailsMarker.cpp:
+        (WebCore::RenderDetailsMarker::paint):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::computeMaxOutlineSize):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLineBoxList.cpp:
+        (WebCore::isOutlinePhase):
+        (WebCore::RenderLineBoxList::lineIntersectsDirtyRect):
+        (WebCore::RenderLineBoxList::paint):
+        * rendering/RenderListMarker.cpp:
+        (WebCore::RenderListMarker::paint):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::adjustRectWithMaximumOutline):
+        (WebCore::RenderObject::maximalOutlineSize): Deleted.
+        * rendering/RenderObject.h:
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::overflowRectForFlowThreadPortion):
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::shouldPaint):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::paint):
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::paintCollapsedBorders):
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::paintObject):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::setMaximalOutlineSize):
+        (WebCore::RenderView::RenderView): Deleted.
+        * rendering/RenderView.h:
+
 2015-08-20  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [OS X] Cleaup after r188591
index 2d6fb69..359bed6 100644 (file)
@@ -1126,7 +1126,7 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
         return;
 
     LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom));
-    overflowRect.inflate(renderer().maximalOutlineSize(paintInfo.phase));
+    renderer().adjustRectWithMaximumOutline(paintInfo.phase, overflowRect);
     flipForWritingMode(overflowRect);
     overflowRect.moveBy(paintOffset);
     
index 585b650..9ade794 100644 (file)
@@ -1400,7 +1400,7 @@ void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     if (!isRoot()) {
         LayoutRect overflowBox = overflowRectForPaintRejection(namedFlowFragment);
         flipForWritingMode(overflowBox);
-        overflowBox.inflate(maximalOutlineSize(phase));
+        adjustRectWithMaximumOutline(phase, overflowBox);
         overflowBox.moveBy(adjustedPaintOffset);
         if (!overflowBox.intersects(paintInfo.rect)
 #if PLATFORM(IOS)
index f603657..67d7214 100644 (file)
@@ -561,7 +561,7 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH
         else
             repaintRect = LayoutRect(repaintLogicalTop, repaintLogicalLeft, repaintLogicalBottom - repaintLogicalTop, repaintLogicalRight - repaintLogicalLeft);
 
-        repaintRect.inflate(maximalOutlineSize(PaintPhaseOutline));
+        repaintRect.inflate(view().maximalOutlineSize());
         
         if (hasOverflowClip()) {
             // Adjust repaint rect for scroll offset
index cef34d2..5eef762 100644 (file)
@@ -124,7 +124,7 @@ void RenderDetailsMarker::paint(PaintInfo& paintInfo, const LayoutPoint& paintOf
     LayoutPoint boxOrigin(paintOffset + location());
     LayoutRect overflowRect(visualOverflowRect());
     overflowRect.moveBy(boxOrigin);
-    overflowRect.inflate(maximalOutlineSize(paintInfo.phase));
+    adjustRectWithMaximumOutline(paintInfo.phase, overflowRect);
 
     if (!paintInfo.rect.intersects(snappedIntRect(overflowRect)))
         return;
index 0a3df3b..258204e 100644 (file)
@@ -374,7 +374,7 @@ void RenderElement::computeMaxOutlineSize() const
     if (m_style->outlineStyleIsAuto())
         maxOutlineSize = std::max(theme().platformFocusRingWidth() + m_style->outlineOffset(), maxOutlineSize);
 
-    if (maxOutlineSize < maximalOutlineSize(PaintPhaseOutline))
+    if (maxOutlineSize < view().maximalOutlineSize())
         return;
 
     view().setMaximalOutlineSize(maxOutlineSize);
index 41e61e4..b859dfe 100644 (file)
@@ -5612,7 +5612,7 @@ void RenderLayer::calculateRects(const ClipRectsContext& clipRectsContext, const
         // If the region does not clip its overflow, inflate the outline rect.
         if (namedFlowFragment) {
             if (!(namedFlowFragment->parent()->hasOverflowClip() && (&namedFlowFragment->fragmentContainerLayer() != clipRectsContext.rootLayer || clipRectsContext.respectOverflowClip == RespectOverflowClip)))
-                outlineRect.inflate(renderer().maximalOutlineSize(PaintPhaseOutline));
+                outlineRect.inflate(renderer().view().maximalOutlineSize());
         }
     }
 
@@ -5830,7 +5830,7 @@ LayoutRect RenderLayer::localBoundingBox(CalculateLayerBoundsFlags flags) const
         }
     }
 
-    result.inflate(renderer().view().maximalOutlineSize()); // Used to apply a fudge factor to dirty-rect checks on blocks/tables.
+    result.inflate(renderer().view().maximalOutlineSize());
     return result;
 }
 
index e1cfca5..f741b48 100644 (file)
@@ -200,11 +200,17 @@ bool RenderLineBoxList::anyLineIntersectsRect(RenderBoxModelObject* renderer, co
     return rangeIntersectsRect(renderer, logicalTop, logicalBottom, rect, offset);
 }
 
+static bool isOutlinePhase(PaintPhase phase)
+{
+    return phase == PaintPhaseOutline || phase == PaintPhaseSelfOutline || phase == PaintPhaseChildOutlines;
+}
+
 bool RenderLineBoxList::lineIntersectsDirtyRect(RenderBoxModelObject* renderer, InlineFlowBox* box, const PaintInfo& paintInfo, const LayoutPoint& offset) const
 {
     const RootInlineBox& rootBox = box->root();
-    LayoutUnit logicalTop = std::min<LayoutUnit>(box->logicalTopVisualOverflow(rootBox.lineTop()), rootBox.selectionTop()) - renderer->maximalOutlineSize(paintInfo.phase);
-    LayoutUnit logicalBottom = box->logicalBottomVisualOverflow(rootBox.lineBottom()) + renderer->maximalOutlineSize(paintInfo.phase);
+    const LayoutUnit outlineSize = isOutlinePhase(paintInfo.phase) ? renderer->view().maximalOutlineSize() : 0;
+    LayoutUnit logicalTop = std::min(box->logicalTopVisualOverflow(rootBox.lineTop()), rootBox.selectionTop()) - outlineSize;
+    LayoutUnit logicalBottom = box->logicalBottomVisualOverflow(rootBox.lineBottom()) + outlineSize;
     
     return rangeIntersectsRect(renderer, logicalTop, logicalBottom, paintInfo.rect, offset);
 }
@@ -221,7 +227,7 @@ void RenderLineBoxList::paint(RenderBoxModelObject* renderer, PaintInfo& paintIn
     // NSViews.  Do not add any more code for this.
     RenderView& v = renderer->view();
     bool usePrintRect = !v.printRect().isEmpty();
-    LayoutUnit outlineSize = renderer->maximalOutlineSize(paintInfo.phase);
+    LayoutUnit outlineSize = isOutlinePhase(paintInfo.phase) ? v.maximalOutlineSize() : 0;
     if (!anyLineIntersectsRect(renderer, paintInfo.rect, paintOffset, usePrintRect, outlineSize))
         return;
 
index 900c870..a855a48 100644 (file)
@@ -1184,7 +1184,7 @@ void RenderListMarker::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
     LayoutPoint boxOrigin(paintOffset + location());
     LayoutRect overflowRect(visualOverflowRect());
     overflowRect.moveBy(boxOrigin);
-    overflowRect.inflate(maximalOutlineSize(paintInfo.phase));
+    adjustRectWithMaximumOutline(paintInfo.phase, overflowRect);
 
     if (!paintInfo.rect.intersects(overflowRect))
         return;
index fbec338..1707f06 100644 (file)
@@ -1878,11 +1878,11 @@ void RenderObject::collectAnnotatedRegions(Vector<AnnotatedRegionValue>& regions
 }
 #endif
 
-int RenderObject::maximalOutlineSize(PaintPhase p) const
+void RenderObject::adjustRectWithMaximumOutline(PaintPhase phase, LayoutRect& rect) const
 {
-    if (p != PaintPhaseOutline && p != PaintPhaseSelfOutline && p != PaintPhaseChildOutlines)
-        return 0;
-    return view().maximalOutlineSize();
+    if (phase != PaintPhaseOutline && phase != PaintPhaseSelfOutline && phase != PaintPhaseChildOutlines)
+        return;
+    rect.inflate(view().maximalOutlineSize());
 }
 
 int RenderObject::caretMinOffset() const
index 68078ac..cbc0b90 100644 (file)
@@ -764,7 +764,7 @@ public:
     bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
 
     // Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
-    int maximalOutlineSize(PaintPhase) const;
+    void adjustRectWithMaximumOutline(PaintPhase, LayoutRect&) const;
 
     enum SelectionState {
         SelectionNone, // The object is not selected.
index d29d671..59aacb7 100644 (file)
@@ -159,7 +159,7 @@ LayoutRect RenderRegion::overflowRectForFlowThreadPortion(const LayoutRect& flow
     LayoutRect flowThreadOverflow = overflowType == VisualOverflow ? visualOverflowRectForBox(*m_flowThread) : layoutOverflowRectForBox(m_flowThread);
 
     // We are interested about the outline size only when computing the visual overflow.
-    LayoutUnit outlineSize = overflowType == VisualOverflow ? LayoutUnit(maximalOutlineSize(PaintPhaseOutline)) : LayoutUnit();
+    LayoutUnit outlineSize = overflowType == VisualOverflow ? LayoutUnit(view().maximalOutlineSize()) : LayoutUnit();
     LayoutRect clipRect;
     if (m_flowThread->isHorizontalWritingMode()) {
         LayoutUnit minY = isFirstPortion ? (flowThreadOverflow.y() - outlineSize) : flowThreadPortionRect.y();
index bdcd3d8..8c98bba 100644 (file)
@@ -233,7 +233,7 @@ bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, const LayoutPoint& paintO
     }
     
     LayoutRect localRepaintRect = paintInfo.rect;
-    localRepaintRect.inflate(maximalOutlineSize(paintInfo.phase));
+    adjustRectWithMaximumOutline(paintInfo.phase, localRepaintRect);
     if (adjustedPaintOffset.x() + visualOverflowRect().x() >= localRepaintRect.maxX() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= localRepaintRect.x())
         return false;
 
index 04a7698..5823a8b 100644 (file)
@@ -661,8 +661,8 @@ void RenderTable::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 
     if (!isRoot()) {
         LayoutRect overflowBox = visualOverflowRect();
+        adjustRectWithMaximumOutline(paintInfo.phase, overflowBox);
         flipForWritingMode(overflowBox);
-        overflowBox.inflate(maximalOutlineSize(paintInfo.phase));
         overflowBox.moveBy(adjustedPaintOffset);
         if (!overflowBox.intersects(paintInfo.rect))
             return;
index ef24923..17e5ac4 100644 (file)
@@ -1192,7 +1192,7 @@ void RenderTableCell::paintCollapsedBorders(PaintInfo& paintInfo, const LayoutPo
         return;
 
     LayoutRect localRepaintRect = paintInfo.rect;
-    localRepaintRect.inflate(maximalOutlineSize(paintInfo.phase));
+    adjustRectWithMaximumOutline(paintInfo.phase, localRepaintRect);
 
     LayoutRect paintRect = LayoutRect(paintOffset + location(), snappedIntRect(frameRect()).size());
     if (paintRect.y() - table()->outerBorderTop() >= localRepaintRect.maxY())
index 4b1714a..c910ab6 100644 (file)
@@ -1228,11 +1228,9 @@ static BoxSide physicalBorderForDirection(RenderStyle* styleForCellFlow, Collaps
 
 void RenderTableSection::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    PaintPhase paintPhase = paintInfo.phase;
-
     LayoutRect localRepaintRect = paintInfo.rect;
+    adjustRectWithMaximumOutline(paintInfo.phase, localRepaintRect);
     localRepaintRect.moveBy(-paintOffset);
-    localRepaintRect.inflate(maximalOutlineSize(paintPhase));
 
     LayoutRect tableAlignedRect = logicalRectForWritingModeAndDirection(localRepaintRect);
 
index 428c160..d3922fe 100644 (file)
@@ -122,7 +122,6 @@ RenderView::RenderView(Document& document, Ref<RenderStyle>&& style)
     , m_selectionUnsplitStartPos(-1)
     , m_selectionUnsplitEndPos(-1)
     , m_rendererCount(0)
-    , m_maximalOutlineSize(0)
     , m_lazyRepaintTimer(*this, &RenderView::lazyRepaintTimerFired)
     , m_pageLogicalHeight(0)
     , m_pageLogicalHeightChanged(false)
@@ -854,14 +853,15 @@ void RenderView::repaintSubtreeSelection(const SelectionSubtreeRoot& root) const
 // Compositing layer dimensions take outline size into account, so we have to recompute layer
 // bounds when it changes.
 // FIXME: This is ugly; it would be nice to have a better way to do this.
-void RenderView::setMaximalOutlineSize(int o)
+void RenderView::setMaximalOutlineSize(int outlineSize)
 {
-    if (o != m_maximalOutlineSize) {
-        m_maximalOutlineSize = o;
-
-        // maximalOutlineSize affects compositing layer dimensions.
-        compositor().setCompositingLayersNeedRebuild();    // FIXME: this really just needs to be a geometry update.
-    }
+    if (outlineSize == m_maximalOutlineSize)
+        return;
+    
+    m_maximalOutlineSize = outlineSize;
+    // maximalOutlineSize affects compositing layer dimensions.
+    // FIXME: this really just needs to be a geometry update.
+    compositor().setCompositingLayersNeedRebuild();
 }
 
 void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode blockRepaintMode)
index c335111..b8ea137 100644 (file)
@@ -98,7 +98,7 @@ public:
     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const override;
     virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override;
 
-    void setMaximalOutlineSize(int o);
+    void setMaximalOutlineSize(int);
     int maximalOutlineSize() const { return m_maximalOutlineSize; }
 
     LayoutRect viewRect() const;
@@ -345,7 +345,8 @@ private:
     LegacyPrinting m_legacyPrinting;
     // End deprecated members.
 
-    int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect checks on blocks/tables.
+    // Used to inflate compositing layers and repaint rects.
+    int m_maximalOutlineSize { 0 };
 
     bool shouldUsePrintingLayout() const;