Index: Source/core/rendering/RenderObject.cpp |
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp |
index d55645e614dfe44aece0455d296605469d0c60a7..60d0788319b45a749c4d07739310f7925c2623c9 100644 |
--- a/Source/core/rendering/RenderObject.cpp |
+++ b/Source/core/rendering/RenderObject.cpp |
@@ -82,6 +82,7 @@ |
#include "platform/graphics/GraphicsContext.h" |
#include "wtf/RefCountedLeakCounter.h" |
#include "wtf/text/StringBuilder.h" |
+#include "wtf/text/WTFString.h" |
#include <algorithm> |
#ifndef NDEBUG |
#include <stdio.h> |
@@ -1367,6 +1368,10 @@ RenderLayerModelObject* RenderObject::containerForRepaint() const |
void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintContainer, const IntRect& r) const |
{ |
+ TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::repaintUsingContainer()", |
+ "object", TRACE_STR_COPY(this->debugName().ascii().data()), |
+ "rect", TRACE_STR_COPY(String::format("%d,%d %dx%d", r.x(), r.y(), r.width(), r.height()).ascii().data())); |
+ |
if (!repaintContainer) { |
view()->repaintViewRectangle(r); |
return; |
@@ -1439,6 +1444,9 @@ void RenderObject::repaint() const |
if (view->document().printing()) |
return; // Don't repaint if we're printing. |
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::repaint()", |
+ "object", TRACE_STR_COPY(this->debugName().ascii().data())); |
+ |
// FIXME: really, we're in the repaint phase here, and the following queries are legal. |
// Until those states are fully fledged, I'll just disable the ASSERTS. |
DisableCompositingQueryAsserts disabler; |
@@ -1456,6 +1464,9 @@ void RenderObject::repaintRectangle(const LayoutRect& r) const |
if (view->document().printing()) |
return; // Don't repaint if we're printing. |
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::repaintRectangle()", |
+ "object", TRACE_STR_COPY(this->debugName().ascii().data())); |
+ |
LayoutRect dirtyRect(r); |
if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { |
@@ -1474,6 +1485,26 @@ IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const |
return pixelSnappedIntRect(absoluteClippedOverflowRect()); |
} |
+const char* RenderObject::invalidationReasonToString(const InvalidationReason reason) const |
+{ |
+ switch (reason) { |
+ case InvalidationIncremental: |
+ return "incremental"; |
+ case InvalidationSelfLayout: |
+ return "self layout"; |
+ case InvalidationBorderFitLines: |
+ return "border fit lines"; |
+ case InvalidationBorderRadius: |
+ return "border radius"; |
+ case InvalidationBoundsChangeWithBackground: |
+ return "bounds change with background"; |
+ case InvalidationBoundsChange: |
+ return "bounds change"; |
+ default: |
+ return "unknown"; |
Julien - ping for review
2014/03/31 18:26:45
ASSERT_NOT_REACHED()?
dsinclair
2014/03/31 19:24:34
Done.
|
+ } |
+} |
+ |
bool RenderObject::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repaintContainer, bool wasSelfLayout, |
const LayoutRect& oldBounds, const LayoutRect* newBoundsPtr) |
{ |
@@ -1481,34 +1512,46 @@ bool RenderObject::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repa |
if (v->document().printing()) |
return false; // Don't repaint if we're printing. |
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject::repaintAfterLayoutIfNeeded", |
+ "object", TRACE_STR_COPY(this->debugName().ascii().data())); |
+ |
// This ASSERT fails due to animations. See https://bugs.webkit.org/show_bug.cgi?id=37048 |
// ASSERT(!newBoundsPtr || *newBoundsPtr == clippedOverflowRectForRepaint(repaintContainer)); |
LayoutRect newBounds = newBoundsPtr ? *newBoundsPtr : clippedOverflowRectForRepaint(repaintContainer); |
- bool fullRepaint = wasSelfLayout; |
+ InvalidationReason invalidationReason = InvalidationIncremental; |
+ if (wasSelfLayout) |
+ invalidationReason = InvalidationSelfLayout; |
Julien - ping for review
2014/03/31 18:26:45
We should just use the ternary operator ? here as
dsinclair
2014/03/31 19:24:34
Done.
|
+ |
// Presumably a background or a border exists if border-fit:lines was specified. |
- if (!fullRepaint && style()->borderFit() == BorderFitLines) |
- fullRepaint = true; |
- if (!fullRepaint && style()->hasBorderRadius()) { |
+ if (invalidationReason == InvalidationIncremental && style()->borderFit() == BorderFitLines) |
+ invalidationReason = InvalidationBorderFitLines; |
+ |
+ if (invalidationReason == InvalidationIncremental&& style()->hasBorderRadius()) { |
// If a border-radius exists and width/height is smaller than |
// radius width/height, we cannot use delta-repaint. |
RoundedRect oldRoundedRect = style()->getRoundedBorderFor(oldBounds); |
RoundedRect newRoundedRect = style()->getRoundedBorderFor(newBounds); |
- fullRepaint = oldRoundedRect.radii() != newRoundedRect.radii(); |
+ if (oldRoundedRect.radii() != newRoundedRect.radii()) |
+ invalidationReason = InvalidationBorderRadius; |
} |
- if (!fullRepaint && (mustRepaintBackgroundOrBorder() && (newBounds != oldBounds))) |
- fullRepaint = true; |
+ if (invalidationReason == InvalidationIncremental && (mustRepaintBackgroundOrBorder() && (newBounds != oldBounds))) |
+ invalidationReason = InvalidationBoundsChangeWithBackground; |
// If we shifted, we don't know the exact reason so we are conservative and trigger a full invalidation. Shifting could |
// be caused by some layout property (left / top) or some in-flow renderer inserted / removed before us in the tree. |
- if (!fullRepaint && newBounds.location() != oldBounds.location()) |
- fullRepaint = true; |
+ if (invalidationReason == InvalidationIncremental && newBounds.location() != oldBounds.location()) |
+ invalidationReason = InvalidationBoundsChange; |
if (!repaintContainer) |
repaintContainer = v; |
- if (fullRepaint) { |
+ if (invalidationReason != InvalidationIncremental) { |
+ TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "invalidation_reason", |
+ "object", TRACE_STR_COPY(this->debugName().ascii().data()), |
+ "reason", invalidationReasonToString(invalidationReason)); |
Julien - ping for review
2014/03/31 18:26:45
Why don't we just pass the invalidation reason to
dsinclair
2014/03/31 19:24:34
Done.
|
+ |
repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds)); |
if (newBounds != oldBounds) |
repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBounds)); |
@@ -1518,6 +1561,10 @@ bool RenderObject::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repa |
if (oldBounds == newBounds) |
return false; |
+ TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "invalidation_reason", |
+ "object", TRACE_STR_COPY(this->debugName().ascii().data()), |
+ "reason", invalidationReasonToString(invalidationReason)); |
+ |
LayoutUnit deltaLeft = newBounds.x() - oldBounds.x(); |
if (deltaLeft > 0) |
repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.x(), oldBounds.y(), deltaLeft, oldBounds.height())); |