Common invalidateTreeIfNeeded()

Extract common part of invalidateTreeIfNeeded() of
RenderLayerModelObject and RenderSVGModelObject.

This is preparation of letting setShouldDoFullPaintInvalidation() work
for RenderText (to avoid invalidatePaintForWholeRenderer from
DocumentMarkerController).

No functional change.

BUG=394133

Review URL: https://codereview.chromium.org/535633002

git-svn-id: svn://svn.chromium.org/blink/trunk@181571 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent dd00997d
...@@ -1516,13 +1516,6 @@ bool RenderBox::paintInvalidationLayerRectsForImage(WrappedImagePtr image, const ...@@ -1516,13 +1516,6 @@ bool RenderBox::paintInvalidationLayerRectsForImage(WrappedImagePtr image, const
InvalidationReason RenderBox::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState, const RenderLayerModelObject& newPaintInvalidationContainer) InvalidationReason RenderBox::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState, const RenderLayerModelObject& newPaintInvalidationContainer)
{ {
const LayoutRect oldPaintInvalidationRect = previousPaintInvalidationRect();
const LayoutPoint oldPositionFromPaintInvalidationContainer = previousPositionFromPaintInvalidationContainer();
setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(&newPaintInvalidationContainer, &paintInvalidationState));
setPreviousPositionFromPaintInvalidationContainer(RenderLayer::positionFromPaintInvalidationContainer(this, &newPaintInvalidationContainer, &paintInvalidationState));
InvalidationReason reason = InvalidationNone;
// If we are set to do a full paint invalidation that means the RenderView will be // If we are set to do a full paint invalidation that means the RenderView will be
// issue paint invalidations. We can then skip issuing of paint invalidations for the child // issue paint invalidations. We can then skip issuing of paint invalidations for the child
// renderers as they'll be covered by the RenderView. // renderers as they'll be covered by the RenderView.
...@@ -1533,8 +1526,11 @@ InvalidationReason RenderBox::invalidatePaintIfNeeded(const PaintInvalidationSta ...@@ -1533,8 +1526,11 @@ InvalidationReason RenderBox::invalidatePaintIfNeeded(const PaintInvalidationSta
&& layer()->isSelfPaintingLayer())) { && layer()->isSelfPaintingLayer())) {
setShouldDoFullPaintInvalidation(true, MarkOnlyThis); setShouldDoFullPaintInvalidation(true, MarkOnlyThis);
} }
}
reason = RenderObject::invalidatePaintIfNeeded(newPaintInvalidationContainer, oldPaintInvalidationRect, oldPositionFromPaintInvalidationContainer, paintInvalidationState); InvalidationReason reason = RenderBoxModelObject::invalidatePaintIfNeeded(paintInvalidationState, newPaintInvalidationContainer);
if (!view()->doingFullPaintInvalidation()) {
if (reason == InvalidationNone || reason == InvalidationIncremental) if (reason == InvalidationNone || reason == InvalidationIncremental)
invalidatePaintForOverflowIfNeeded(); invalidatePaintForOverflowIfNeeded();
......
...@@ -166,25 +166,8 @@ void RenderLayerModelObject::addLayerHitTestRects(LayerHitTestRects& rects, cons ...@@ -166,25 +166,8 @@ void RenderLayerModelObject::addLayerHitTestRects(LayerHitTestRects& rects, cons
} }
} }
InvalidationReason RenderLayerModelObject::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState, const RenderLayerModelObject& newPaintInvalidationContainer)
{
const LayoutRect oldPaintInvalidationRect = previousPaintInvalidationRect();
const LayoutPoint oldPositionFromPaintInvalidationContainer = previousPositionFromPaintInvalidationContainer();
setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(&newPaintInvalidationContainer, &paintInvalidationState));
setPreviousPositionFromPaintInvalidationContainer(RenderLayer::positionFromPaintInvalidationContainer(this, &newPaintInvalidationContainer, &paintInvalidationState));
// If we are set to do a full paint invalidation that means the RenderView will issue
// paint invalidations. We can then skip issuing of paint invalidations for the child
// renderers as they'll be covered by the RenderView.
if (view()->doingFullPaintInvalidation())
return InvalidationNone;
return RenderObject::invalidatePaintIfNeeded(newPaintInvalidationContainer, oldPaintInvalidationRect, oldPositionFromPaintInvalidationContainer, paintInvalidationState);
}
void RenderLayerModelObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState) void RenderLayerModelObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState)
{ {
// FIXME: SVG should probably also go through this unified paint invalidation system.
ASSERT(!needsLayout()); ASSERT(!needsLayout());
if (!shouldCheckForPaintInvalidation(paintInvalidationState)) if (!shouldCheckForPaintInvalidation(paintInvalidationState))
...@@ -195,11 +178,12 @@ void RenderLayerModelObject::invalidateTreeIfNeeded(const PaintInvalidationState ...@@ -195,11 +178,12 @@ void RenderLayerModelObject::invalidateTreeIfNeeded(const PaintInvalidationState
ASSERT(&newPaintInvalidationContainer == containerForPaintInvalidation()); ASSERT(&newPaintInvalidationContainer == containerForPaintInvalidation());
InvalidationReason reason = invalidatePaintIfNeeded(paintInvalidationState, newPaintInvalidationContainer); InvalidationReason reason = invalidatePaintIfNeeded(paintInvalidationState, newPaintInvalidationContainer);
clearPaintInvalidationState(paintInvalidationState);
PaintInvalidationState childTreeWalkState(paintInvalidationState, *this, newPaintInvalidationContainer); PaintInvalidationState childTreeWalkState(paintInvalidationState, *this, newPaintInvalidationContainer);
if (reason == InvalidationLocationChange || reason == InvalidationFull) if (reason == InvalidationLocationChange || reason == InvalidationFull)
childTreeWalkState.setForceCheckForPaintInvalidation(); childTreeWalkState.setForceCheckForPaintInvalidation();
RenderObject::invalidateTreeIfNeeded(childTreeWalkState); invalidatePaintOfSubtreesIfNeeded(childTreeWalkState);
} }
} // namespace blink } // namespace blink
......
...@@ -73,7 +73,6 @@ protected: ...@@ -73,7 +73,6 @@ protected:
virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer*, const LayoutPoint&, const LayoutRect&) const OVERRIDE; virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer*, const LayoutPoint&, const LayoutRect&) const OVERRIDE;
virtual InvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&, const RenderLayerModelObject& newPaintInvalidationContainer);
private: private:
virtual bool isLayerModelObject() const OVERRIDE FINAL { return true; } virtual bool isLayerModelObject() const OVERRIDE FINAL { return true; }
......
...@@ -1591,13 +1591,20 @@ const char* RenderObject::invalidationReasonToString(InvalidationReason reason) ...@@ -1591,13 +1591,20 @@ const char* RenderObject::invalidationReasonToString(InvalidationReason reason)
void RenderObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState) void RenderObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState)
{ {
ASSERT(!needsLayout());
// If we didn't need paint invalidation then our children don't need as well. // If we didn't need paint invalidation then our children don't need as well.
// Skip walking down the tree as everything should be fine below us. // Skip walking down the tree as everything should be fine below us.
if (!shouldCheckForPaintInvalidation(paintInvalidationState)) if (!shouldCheckForPaintInvalidation(paintInvalidationState))
return; return;
invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationState.paintInvalidationContainer());
clearPaintInvalidationState(paintInvalidationState); clearPaintInvalidationState(paintInvalidationState);
invalidatePaintOfSubtreesIfNeeded(paintInvalidationState);
}
void RenderObject::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState& paintInvalidationState)
{
for (RenderObject* child = slowFirstChild(); child; child = child->nextSibling()) { for (RenderObject* child = slowFirstChild(); child; child = child->nextSibling()) {
if (!child->isOutOfFlowPositioned()) if (!child->isOutOfFlowPositioned())
child->invalidateTreeIfNeeded(paintInvalidationState); child->invalidateTreeIfNeeded(paintInvalidationState);
...@@ -1612,19 +1619,24 @@ static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForOldAndNewRe ...@@ -1612,19 +1619,24 @@ static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForOldAndNewRe
return value; return value;
} }
InvalidationReason RenderObject::invalidatePaintIfNeeded(const RenderLayerModelObject& paintInvalidationContainer, const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const PaintInvalidationState& paintInvalidationState) InvalidationReason RenderObject::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState, const RenderLayerModelObject& paintInvalidationContainer)
{ {
RenderView* v = view(); RenderView* v = view();
if (v->document().printing()) if (v->document().printing())
return InvalidationNone; // Don't invalidate paints if we're printing. return InvalidationNone; // Don't invalidate paints if we're printing.
const LayoutRect& newBounds = previousPaintInvalidationRect(); const LayoutRect oldBounds = previousPaintInvalidationRect();
const LayoutPoint& newLocation = previousPositionFromPaintInvalidationContainer(); const LayoutPoint oldLocation = previousPositionFromPaintInvalidationContainer();
const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidationContainer, &paintInvalidationState);
// FIXME: PaintInvalidationState should not be required here, but the call to flipForWritingMode const LayoutPoint newLocation = RenderLayer::positionFromPaintInvalidationContainer(this, &paintInvalidationContainer, &paintInvalidationState);
// in mapRectToPaintInvalidationBacking will give us the wrong results with it disabled. setPreviousPaintInvalidationRect(newBounds);
// crbug.com/393762 setPreviousPositionFromPaintInvalidationContainer(newLocation);
ASSERT(newBounds == boundsRectForPaintInvalidation(&paintInvalidationContainer, &paintInvalidationState));
// If we are set to do a full paint invalidation that means the RenderView will issue
// paint invalidations. We can then skip issuing of paint invalidations for the child
// renderers as they'll be covered by the RenderView.
if (view()->doingFullPaintInvalidation())
return InvalidationNone;
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::invalidatePaintIfNeeded()", TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::invalidatePaintIfNeeded()",
"object", this->debugName().ascii(), "object", this->debugName().ascii(),
......
...@@ -866,9 +866,6 @@ public: ...@@ -866,9 +866,6 @@ public:
// Invalidate the paint of a specific subrectangle within a given object. The rect |r| is in the object's coordinate space. // Invalidate the paint of a specific subrectangle within a given object. The rect |r| is in the object's coordinate space.
void invalidatePaintRectangle(const LayoutRect&) const; void invalidatePaintRectangle(const LayoutRect&) const;
InvalidationReason invalidatePaintIfNeeded(const RenderLayerModelObject& paintInvalidationContainer,
const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalidationContainer, const PaintInvalidationState&);
// Walk the tree after layout issuing paint invalidations for renderers that have changed or moved, updating bounds that have changed, and clearing paint invalidation state. // Walk the tree after layout issuing paint invalidations for renderers that have changed or moved, updating bounds that have changed, and clearing paint invalidation state.
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&); virtual void invalidateTreeIfNeeded(const PaintInvalidationState&);
...@@ -1145,6 +1142,9 @@ protected: ...@@ -1145,6 +1142,9 @@ protected:
} }
#endif #endif
void invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState&);
virtual InvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&, const RenderLayerModelObject& paintInvalidationContainer);
private: private:
// Invalidate the paint of the entire object. This is only used when a renderer is to be removed. // Invalidate the paint of the entire object. This is only used when a renderer is to be removed.
// For other cases, the caller should call setShouldDoFullPaintInvalidation() instead. // For other cases, the caller should call setShouldDoFullPaintInvalidation() instead.
......
...@@ -189,6 +189,9 @@ private: ...@@ -189,6 +189,9 @@ private:
bool isText() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check. bool isText() const WTF_DELETED_FUNCTION; // This will catch anyone doing an unnecessary check.
// FIXME: This is temporarily empty. Will let it actually work in following steps.
virtual InvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&, const RenderLayerModelObject&) OVERRIDE FINAL { return InvalidationNone; }
// We put the bitfield first to minimize padding on 64-bit. // We put the bitfield first to minimize padding on 64-bit.
bool m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines. bool m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines.
bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> with '\n'). bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> with '\n').
......
...@@ -125,37 +125,11 @@ void RenderSVGModelObject::absoluteFocusRingQuads(Vector<FloatQuad>& quads) ...@@ -125,37 +125,11 @@ void RenderSVGModelObject::absoluteFocusRingQuads(Vector<FloatQuad>& quads)
quads.append(localToAbsoluteQuad(FloatQuad(paintInvalidationRectInLocalCoordinates()))); quads.append(localToAbsoluteQuad(FloatQuad(paintInvalidationRectInLocalCoordinates())));
} }
void RenderSVGModelObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState) InvalidationReason RenderSVGModelObject::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState, const RenderLayerModelObject& paintInvalidationContainer)
{
// Note: This is a reduced version of RenderBox::invalidateTreeIfNeeded().
// FIXME: Should share code with RenderBox::invalidateTreeIfNeeded().
ASSERT(!needsLayout());
if (!shouldCheckForPaintInvalidation(paintInvalidationState))
return;
invalidatePaintIfNeeded(paintInvalidationState);
RenderObject::invalidateTreeIfNeeded(paintInvalidationState);
}
void RenderSVGModelObject::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState)
{ {
ForceHorriblySlowRectMapping slowRectMapping(&paintInvalidationState); ForceHorriblySlowRectMapping slowRectMapping(&paintInvalidationState);
const LayoutRect oldPaintInvalidationRect = previousPaintInvalidationRect(); return RenderObject::invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationContainer);
const LayoutPoint oldPositionFromPaintInvalidationContainer = previousPositionFromPaintInvalidationContainer();
ASSERT(paintInvalidationState.paintInvalidationContainer() == containerForPaintInvalidation());
setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(&paintInvalidationState.paintInvalidationContainer(), &paintInvalidationState));
setPreviousPositionFromPaintInvalidationContainer(RenderLayer::positionFromPaintInvalidationContainer(this, &paintInvalidationState.paintInvalidationContainer(), &paintInvalidationState));
// If we are set to do a full paint invalidation that means the RenderView will be
// issue paint invalidations. We can then skip issuing of paint invalidations for the child
// renderers as they'll be covered by the RenderView.
if (view()->doingFullPaintInvalidation())
return;
RenderObject::invalidatePaintIfNeeded(paintInvalidationState.paintInvalidationContainer(), oldPaintInvalidationRect, oldPositionFromPaintInvalidationContainer, paintInvalidationState);
} }
} // namespace blink } // namespace blink
...@@ -67,8 +67,6 @@ public: ...@@ -67,8 +67,6 @@ public:
virtual bool isSVG() const OVERRIDE FINAL { return true; } virtual bool isSVG() const OVERRIDE FINAL { return true; }
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) OVERRIDE;
protected: protected:
virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentCompositedLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const OVERRIDE FINAL; virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentCompositedLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const OVERRIDE FINAL;
virtual void willBeDestroyed() OVERRIDE; virtual void willBeDestroyed() OVERRIDE;
...@@ -81,7 +79,7 @@ private: ...@@ -81,7 +79,7 @@ private:
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE FINAL; virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE FINAL;
virtual void absoluteFocusRingQuads(Vector<FloatQuad>&) OVERRIDE FINAL; virtual void absoluteFocusRingQuads(Vector<FloatQuad>&) OVERRIDE FINAL;
void invalidatePaintIfNeeded(const PaintInvalidationState&); InvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&, const RenderLayerModelObject& paintInvalidationContainer) OVERRIDE FINAL;
}; };
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment