Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(818)

Unified Diff: Source/core/rendering/LayoutRepainter.cpp

Issue 171843005: Avoid repainting non needs-self-layout container (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Improve the description of the test. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/LayoutRepainter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/LayoutRepainter.cpp
diff --git a/Source/core/rendering/LayoutRepainter.cpp b/Source/core/rendering/LayoutRepainter.cpp
index 0e1f7791ce75f65c0d9aed0d2a2077bdb2f42991..b6f3851ba199ca51c0770333c08264013ca6d010 100644
--- a/Source/core/rendering/LayoutRepainter.cpp
+++ b/Source/core/rendering/LayoutRepainter.cpp
@@ -26,15 +26,20 @@
#include "config.h"
#include "core/rendering/LayoutRepainter.h"
+#include "core/rendering/RenderBlockFlow.h"
+#include "core/rendering/RenderBox.h"
#include "core/rendering/RenderLayer.h"
-#include "core/rendering/RenderObject.h"
namespace WebCore {
+static const int gUnsetValue = -1;
+
LayoutRepainter::LayoutRepainter(RenderObject& object, bool checkForRepaint)
: m_object(object)
, m_repaintContainer(0)
, m_checkForRepaint(checkForRepaint)
+ , m_oldLogicalWidth(gUnsetValue)
+ , m_oldLogicalHeight(gUnsetValue)
{
if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
return;
@@ -47,6 +52,11 @@ LayoutRepainter::LayoutRepainter(RenderObject& object, bool checkForRepaint)
m_oldBounds = m_object.clippedOverflowRectForRepaint(m_repaintContainer);
}
m_oldOutlineBox = m_object.outlineBoundsForRepaint(m_repaintContainer);
+ if (m_object.isBox()) {
+ const RenderBox& box = *toRenderBox(&m_object);
+ m_oldLogicalWidth = box.logicalWidth();
+ m_oldLogicalHeight = box.logicalHeight();
+ }
}
}
@@ -55,10 +65,58 @@ bool LayoutRepainter::repaintAfterLayout()
if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
return false;
+ if (!m_checkForRepaint)
+ return false;
+
+ if (canSkipRepaint())
+ return false;
+
// Hits in compositing/video/video-controls-layer-creation.html
DisableCompositingQueryAsserts disabler;
- return m_checkForRepaint ? m_object.repaintAfterLayoutIfNeeded(m_repaintContainer, m_object.selfNeedsLayout(), m_oldBounds, m_oldOutlineBox) : false;
+ return m_object.repaintAfterLayoutIfNeeded(m_repaintContainer, m_object.selfNeedsLayout(), m_oldBounds, m_oldOutlineBox);
+}
+
+static bool hasChildrenNeedingRepaintFromContainingBlock(const RenderBlock& containingBlock)
+{
+ // FIXME: We currently disable this optimization for floats as they need to be
+ // correctly repainted by their (not marked for self-layout) block-flow container.
+ return containingBlock.containsFloats();
+}
+
+bool LayoutRepainter::canSkipRepaint() const
+{
+ // If we needed layout, our content could have changed so we have to repaint.
+ if (m_object.selfNeedsLayout())
+ return false;
+
+ // FIXME: We disable the optimization for SVG text renderers as they
+ // are the one repainting their inline content.
+ if (m_object.isSVGText())
+ return false;
+
+ if (m_oldLogicalWidth == gUnsetValue) {
+ ASSERT(m_oldLogicalHeight == gUnsetValue);
+ return false;
+ }
+
+ ASSERT(m_oldLogicalWidth != gUnsetValue);
+ ASSERT(m_oldLogicalHeight != gUnsetValue);
+
+ // We don't repaint box containers that are not marked for self-layout and didn't change size.
+ // This is valid because:
+ // - if their content changed, they would be marked for self-layout.
+ // - their descendant(s) that actually changed should repaint themselves correctly.
+ // FIXME: It should be possible to avoid repainting size changes but we have to be careful with
+ // some cases (e.g. gradient or repeated backgrounds).
+ const RenderBox& box = *toRenderBox(&m_object);
+ if (m_oldLogicalWidth != box.logicalWidth() || m_oldLogicalHeight != box.logicalHeight())
+ return false;
+
+ if (!m_object.isRenderBlock())
+ return true;
+
+ return !hasChildrenNeedingRepaintFromContainingBlock(*toRenderBlock(&box));
}
} // namespace WebCore
« no previous file with comments | « Source/core/rendering/LayoutRepainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698