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