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

Unified Diff: third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp

Issue 1833493003: Remove ForceHorriblySlowRectMapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pi
Patch Set: Created 4 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
Index: third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp
diff --git a/third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp b/third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp
index c028923fec57512ec3e6b4dec38e6a62fffbbc24..6c95a926533bb4d7d7170c1b41aa566fbe3979da 100644
--- a/third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp
+++ b/third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp
@@ -21,36 +21,28 @@
namespace blink {
-static bool isAbsolutePositionUnderRelativePositionInline(const LayoutObject& object)
-{
- if (object.styleRef().position() != AbsolutePosition)
- return false;
- if (LayoutObject* container = object.container())
- return container->isAnonymousBlock() && container->styleRef().position() == RelativePosition;
- return false;
-}
-
static bool supportsCachedOffsets(const LayoutObject& object)
{
- // TODO(wangxianzhu): Move some conditions to fast path if possible.
return !object.hasTransformRelatedProperty()
&& !object.hasReflection()
&& !object.hasFilter()
&& !object.isLayoutFlowThread()
&& !object.isLayoutMultiColumnSpannerPlaceholder()
- && object.styleRef().position() != FixedPosition
&& !object.styleRef().isFlippedBlocksWritingMode()
- // TODO(crbug.com/598094): Handle this in fast path.
- && !isAbsolutePositionUnderRelativePositionInline(object);
+ && !(object.isLayoutBlock() && object.isSVG());
}
PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vector<LayoutObject*>& pendingDelayedPaintInvalidations)
: m_currentObject(layoutView)
- , m_clipped(false)
- , m_cachedOffsetsEnabled(true)
, m_forcedSubtreeInvalidationWithinContainer(false)
, m_forcedSubtreeInvalidationRectUpdateWithinContainer(false)
- , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation())
+ , m_clipped(false)
+ , m_clippedForAbsolutePosition(false)
+ , m_cachedOffsetsEnabled(true)
+ , m_cachedOffsetsForAbsolutePositionEnabled(true)
+ , m_paintInvalidationContainer(&layoutView.containerForPaintInvalidation())
+ , m_paintInvalidationContainerForStackedContents(m_paintInvalidationContainer)
+ , m_containerForAbsolutePosition(layoutView)
, m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations)
, m_enclosingSelfPaintingLayer(*layoutView.layer())
#if ENABLE(ASSERT)
@@ -62,41 +54,26 @@ PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec
return;
}
- FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates);
+ FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), m_paintInvalidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates);
m_paintOffset = LayoutSize(point.x(), point.y());
-}
-
-// TODO(wangxianzhu): This is temporary for positioned object whose paintInvalidationContainer is different from
-// the one we find during tree walk. Remove this after we fix the issue with tree walk in DOM-order.
-PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& parentState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject& paintInvalidationContainer)
- : m_currentObject(currentObject)
- , m_clipped(parentState.m_clipped)
- , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled)
- , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInvalidationWithinContainer)
- , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedSubtreeInvalidationRectUpdateWithinContainer)
- , m_clipRect(parentState.m_clipRect)
- , m_paintOffset(parentState.m_paintOffset)
- , m_paintInvalidationContainer(paintInvalidationContainer)
- , m_svgTransform(parentState.m_svgTransform)
- , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalidationTargets())
- , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(currentObject))
-#if ENABLE(ASSERT)
- , m_didUpdateForChildren(true)
-#endif
-{
- ASSERT(parentState.m_didUpdateForChildren);
- ASSERT(!m_cachedOffsetsEnabled);
+ m_paintOffsetForAbsolutePosition = m_paintOffset;
}
PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& parentState, const LayoutObject& currentObject)
: m_currentObject(currentObject)
- , m_clipped(parentState.m_clipped)
- , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled)
, m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInvalidationWithinContainer)
, m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedSubtreeInvalidationRectUpdateWithinContainer)
+ , m_clipped(parentState.m_clipped)
+ , m_clippedForAbsolutePosition(parentState.m_clippedForAbsolutePosition)
, m_clipRect(parentState.m_clipRect)
+ , m_clipRectForAbsolutePosition(parentState.m_clipRectForAbsolutePosition)
, m_paintOffset(parentState.m_paintOffset)
- , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer() ? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContainer)
+ , m_paintOffsetForAbsolutePosition(parentState.m_paintOffsetForAbsolutePosition)
+ , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled)
+ , m_cachedOffsetsForAbsolutePositionEnabled(parentState.m_cachedOffsetsForAbsolutePositionEnabled)
+ , m_paintInvalidationContainer(parentState.m_paintInvalidationContainer)
+ , m_paintInvalidationContainerForStackedContents(parentState.m_paintInvalidationContainerForStackedContents)
+ , m_containerForAbsolutePosition(currentObject.canContainAbsolutePositionObjects() ? currentObject : parentState.m_containerForAbsolutePosition)
, m_svgTransform(parentState.m_svgTransform)
, m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalidationTargets())
, m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(currentObject))
@@ -116,11 +93,37 @@ PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par
ASSERT(parentState.m_didUpdateForChildren);
+ EPosition position = currentObject.styleRef().position();
+
+ if (currentObject.isPaintInvalidationContainer()) {
+ m_paintInvalidationContainer = toLayoutBoxModelObject(&currentObject);
+ if (currentObject.styleRef().isStackingContext()) {
+ m_paintInvalidationContainerForStackedContents = toLayoutBoxModelObject(&currentObject);
+
+ // Disable cached offsets for absolute-position objects if this object is not a container for
+ // absolute-position because absolute-position objects' locations are determined by something
+ // above their paint invalidation container.
+ if (m_currentObject != m_containerForAbsolutePosition)
+ m_cachedOffsetsForAbsolutePositionEnabled = false;
+ }
+ } else if (currentObject.isLayoutView()) {
+ // m_paintInvalidationContainerForStackedContents doesn't cross frame boundary.
+ m_paintInvalidationContainerForStackedContents = m_paintInvalidationContainer;
+ } else if (currentObject.styleRef().isStacked()
+ // This is to exclude some objects (e.g. LayoutText) inheriting stacked style from parent but aren't actually stacked.
+ && currentObject.hasLayer()
+ && m_paintInvalidationContainer != m_paintInvalidationContainerForStackedContents) {
+ m_paintInvalidationContainer = m_paintInvalidationContainerForStackedContents;
+ // We are changing paint invalidation container, but didn't track paint offset from
+ // m_paintInvalidationContainerForStackedContents, so disable cached offsets.
+ m_cachedOffsetsEnabled = false;
+ }
+
if (!currentObject.isBoxModelObject() && !currentObject.isSVG())
return;
- if (m_cachedOffsetsEnabled && !supportsCachedOffsets(currentObject))
- m_cachedOffsetsEnabled = false;
+ if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer)
+ m_cachedOffsetsEnabled = !supportsCachedOffsets(currentObject);
if (currentObject.isSVG()) {
if (currentObject.isSVGRoot()) {
@@ -156,6 +159,34 @@ PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par
return;
}
+ if (position == FixedPosition) {
+ if (m_paintInvalidationContainer != currentObject.view() && m_paintInvalidationContainer->view() == currentObject.view()) {
+ // TODO(crbug.com/598762): localToAncestorPoint() is incorrect for fixed-position when paintInvalidationContainer
+ // is under the containing LayoutView.
+ m_cachedOffsetsEnabled = false;
+ return;
+ }
+ FloatPoint fixedOffset = currentObject.localToAncestorPoint(FloatPoint(), m_paintInvalidationContainer, TraverseDocumentBoundaries);
+ m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y());
+ // Ancestor clippings are ignored for simplicity.
+ m_clipped = false;
+ return;
+ }
+
+ if (position == AbsolutePosition) {
+ m_cachedOffsetsEnabled = m_cachedOffsetsForAbsolutePositionEnabled;
+ if (!m_cachedOffsetsEnabled)
+ return;
+
+ m_paintOffset = m_paintOffsetForAbsolutePosition;
+ m_clipped = m_clippedForAbsolutePosition;
+ m_clipRect = m_clipRectForAbsolutePosition;
+
+ const LayoutObject& container = parentState.m_containerForAbsolutePosition;
+ if (container.isInFlowPositioned() && container.isLayoutInline())
+ m_paintOffset += toLayoutInline(container).offsetForInFlowPositionedInline(toLayoutBox(m_currentObject));
+ }
+
if (currentObject.isBox())
m_paintOffset += toLayoutBox(currentObject).locationOffset();
@@ -170,6 +201,24 @@ void PaintInvalidationState::updateForChildren()
m_didUpdateForChildren = true;
#endif
+ updateForNormalChildren();
+
+ if (m_currentObject == m_containerForAbsolutePosition) {
+ if (m_paintInvalidationContainer == m_paintInvalidationContainerForStackedContents) {
+ m_cachedOffsetsForAbsolutePositionEnabled = m_cachedOffsetsEnabled;
+ if (m_cachedOffsetsEnabled) {
+ m_paintOffsetForAbsolutePosition = m_paintOffset;
+ m_clippedForAbsolutePosition = m_clipped;
+ m_clipRectForAbsolutePosition = m_clipRect;
+ }
+ } else {
+ m_cachedOffsetsForAbsolutePositionEnabled = false;
+ }
+ }
+}
+
+void PaintInvalidationState::updateForNormalChildren()
+{
if (!m_cachedOffsetsEnabled)
return;
@@ -222,7 +271,7 @@ LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking(
ASSERT(!m_didUpdateForChildren);
FloatPoint point;
- if (m_paintInvalidationContainer != m_currentObject) {
+ if (m_paintInvalidationContainer != &m_currentObject) {
if (m_cachedOffsetsEnabled) {
if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
point = m_svgTransform.mapPoint(point);
@@ -232,12 +281,12 @@ LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking(
// ASSERT(point == slowLocalOriginToAncestorPoint(m_currentObject, m_paintInvalidationContainer, FloatPoint());
#endif
} else {
- point = slowLocalToAncestorPoint(m_currentObject, m_paintInvalidationContainer, FloatPoint());
+ point = slowLocalToAncestorPoint(m_currentObject, *m_paintInvalidationContainer, FloatPoint());
}
}
- if (m_paintInvalidationContainer.layer()->groupedMapping())
- PaintLayer::mapPointInPaintInvalidationContainerToBacking(m_paintInvalidationContainer, point);
+ if (m_paintInvalidationContainer->layer()->groupedMapping())
+ PaintLayer::mapPointInPaintInvalidationContainerToBacking(*m_paintInvalidationContainer, point);
return LayoutPoint(point);
}
@@ -264,7 +313,7 @@ LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG()
if (m_clipped)
rect.intersect(m_clipRect);
#if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH
- LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_currentObject, m_paintInvalidationContainer);
+ LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_currentObject, *m_paintInvalidationContainer);
// TODO(crbug.com/597902): Slow path misses clipping of paintInvalidationContainer.
if (m_clipped)
slowPathRect.intersect(m_clipRect);
@@ -274,11 +323,11 @@ LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG()
} else {
// TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't mean we can't use cached
// m_svgTransform. We can use hybrid fast-path (for SVG) and slow-path (for things above the SVGRoot).
- rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_currentObject, m_paintInvalidationContainer);
+ rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_currentObject, *m_paintInvalidationContainer);
}
- if (m_paintInvalidationContainer.layer()->groupedMapping())
- PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalidationContainer, rect);
+ if (m_paintInvalidationContainer->layer()->groupedMapping())
+ PaintLayer::mapRectInPaintInvalidationContainerToBacking(*m_paintInvalidationContainer, rect);
return rect;
}
@@ -306,7 +355,7 @@ void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
if (m_cachedOffsetsEnabled) {
#if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH
LayoutRect slowPathRect(rect);
- slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidationContainer, slowPathRect);
+ slowMapToVisibleRectInAncestorSpace(m_currentObject, *m_paintInvalidationContainer, slowPathRect);
#endif
rect.move(m_paintOffset);
if (m_clipped)
@@ -319,15 +368,16 @@ void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
// TODO(wangxianzhu): The isLayoutView() condition is for cases that a sub-frame creates a
// root PaintInvalidationState which doesn't inherit clip from ancestor frames.
// Remove the condition when we eliminate the latter case of PaintInvalidationState(const LayoutView&, ...).
+ // We ignore ancestor clipping for FixedPosition in fast path.
// TODO(crbug.com/597903): Fast path and slow path should generate equal empty rects.
- ASSERT(m_currentObject.isLayoutView() || (rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRect);
+ ASSERT(m_currentObject.isLayoutView() || m_currentObject.styleRef().position() == FixedPosition || (rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRect);
#endif
} else {
- slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidationContainer, rect);
+ slowMapToVisibleRectInAncestorSpace(m_currentObject, *m_paintInvalidationContainer, rect);
}
- if (m_paintInvalidationContainer.layer()->groupedMapping())
- PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalidationContainer, rect);
+ if (m_paintInvalidationContainer->layer()->groupedMapping())
+ PaintLayer::mapRectInPaintInvalidationContainerToBacking(*m_paintInvalidationContainer, rect);
}
void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect)

Powered by Google App Engine
This is Rietveld 408576698