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

Unified Diff: third_party/WebKit/Source/core/paint/PaintInvalidator.cpp

Issue 2487273002: [No submit][SPInvalidation] Track paint offset change (Closed)
Patch Set: Created 4 years, 1 month 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/paint/PaintInvalidator.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
index ae82764dc2734a175579fa0bf7c61d7246ea600f..ca95d93dca0c9c8996d139183f7af9ddca39ac3e 100644
--- a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
@@ -192,6 +192,51 @@ LayoutPoint PaintInvalidator::computeLocationInBacking(
return LayoutPoint(point);
}
+static LayoutPoint computePaintOffset(const LayoutObject& object,
+ PaintInvalidatorContext& context) {
+ LayoutPoint paintOffset = context.treeBuilderContext.current.paintOffset;
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
+ return paintOffset;
+
+ if (object.isSVG() && !object.isSVGRoot())
+ return paintOffset;
+
+ if (object.isLayoutView() ||
+ (object.hasLayer() &&
+ toLayoutBoxModelObject(object).layer()->paintsWithTransform(
+ GlobalPaintNormalPhase))) {
+ if (object != context.paintInvalidationContainer) {
+ context.shouldAdjustPaintOffsetToContainer = false;
+ LOG(ERROR) << "reset shouldAdjustToContainer by " << object.debugName();
+ }
+ if (object != context.paintInvalidationContainerForStackedContents) {
+ LOG(ERROR) << "reset shouldAdjustToContainerForStackedContents by "
+ << object.debugName();
+ context.shouldAdjustPaintOffsetToContainerForStackedContents = false;
+ }
+ }
+
+ if (context.shouldAdjustPaintOffsetToContainer) {
+ LOG(ERROR) << object.debugName() << " adjust paint offset to "
+ << context.paintInvalidationContainer->debugName()
+ << " paint offset=" << paintOffset.toString();
+ paintOffset -= toIntSize(
+ roundedIntPoint(context.paintInvalidationContainer->paintProperties()
+ ->localBorderBoxProperties()
+ ->paintOffset));
+ LOG(ERROR) << " after adjustment=" << paintOffset.toString();
+ }
+ if (object != context.paintInvalidationContainer &&
+ context.paintInvalidationContainer->usesCompositedScrolling()) {
+ const LayoutBox* box = toLayoutBox(context.paintInvalidationContainer);
+ if (box->hasOverflowClip())
+ paintOffset += box->scrolledContentOffset();
+ LOG(ERROR) << " after adjustment for scroll offset="
+ << paintOffset.toString();
+ }
+ return paintOffset;
+}
+
void PaintInvalidator::updatePaintingLayer(const LayoutObject& object,
PaintInvalidatorContext& context) {
if (object.hasLayer() &&
@@ -264,9 +309,12 @@ void PaintInvalidator::updateContext(const LayoutObject& object,
if (object.isPaintInvalidationContainer()) {
context.paintInvalidationContainer = toLayoutBoxModelObject(&object);
- if (object.styleRef().isStackingContext())
+ context.shouldAdjustPaintOffsetToContainer = true;
+ if (object.styleRef().isStackingContext()) {
context.paintInvalidationContainerForStackedContents =
toLayoutBoxModelObject(&object);
+ context.shouldAdjustPaintOffsetToContainerForStackedContents = true;
+ }
} else if (object.isLayoutView()) {
// paintInvalidationContainerForStackedContents is only for stacked
// descendants in its own frame, because it doesn't establish stacking
@@ -275,6 +323,8 @@ void PaintInvalidator::updateContext(const LayoutObject& object,
// this frame's paintInvalidationContainer.
context.paintInvalidationContainerForStackedContents =
context.paintInvalidationContainer;
+ context.shouldAdjustPaintOffsetToContainerForStackedContents =
+ context.shouldAdjustPaintOffsetToContainer;
if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled())
undoFrameViewContentClipAndScroll.emplace(
*toLayoutView(object).frameView(), context);
@@ -289,11 +339,14 @@ void PaintInvalidator::updateContext(const LayoutObject& object,
// container on which the current object is painted.
context.paintInvalidationContainer =
context.paintInvalidationContainerForStackedContents;
+ context.shouldAdjustPaintOffsetToContainer =
+ context.shouldAdjustPaintOffsetToContainerForStackedContents;
if (context.forcedSubtreeInvalidationFlags &
PaintInvalidatorContext::
- ForcedSubtreeFullInvalidationForStackedContents)
+ ForcedSubtreeFullInvalidationForStackedContents) {
context.forcedSubtreeInvalidationFlags |=
PaintInvalidatorContext::ForcedSubtreeFullInvalidation;
+ }
}
if (object == context.paintInvalidationContainer) {
@@ -330,8 +383,10 @@ void PaintInvalidator::updateContext(const LayoutObject& object,
ObjectPaintInvalidator objectPaintInvalidator(object);
context.oldVisualRect = object.previousVisualRect();
context.oldLocation = objectPaintInvalidator.previousLocationInBacking();
+ context.oldPaintOffset = object.previousPaintOffset();
context.newVisualRect = computeVisualRectInBacking(object, context);
context.newLocation = computeLocationInBacking(object, context);
+ context.newPaintOffset = computePaintOffset(object, context);
IntSize adjustment = object.scrollAdjustmentForPaintInvalidation(
*context.paintInvalidationContainer);
@@ -339,6 +394,7 @@ void PaintInvalidator::updateContext(const LayoutObject& object,
context.newVisualRect.move(adjustment);
object.getMutableForPainting().setPreviousVisualRect(context.newVisualRect);
+ object.getMutableForPainting().setPreviousPaintOffset(context.newPaintOffset);
objectPaintInvalidator.setPreviousLocationInBacking(context.newLocation);
}
@@ -351,6 +407,8 @@ void PaintInvalidator::invalidatePaintIfNeeded(
context.paintInvalidationContainer =
context.paintInvalidationContainerForStackedContents =
&layoutView->containerForPaintInvalidation();
+ context.shouldAdjustPaintOffsetToContainer =
+ context.shouldAdjustPaintOffsetToContainerForStackedContents = true;
context.paintingLayer = layoutView->layer();
if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
@@ -369,18 +427,6 @@ void PaintInvalidator::invalidatePaintIfNeeded(
layoutView->sendMediaPositionChangeNotifications(visibleRect);
}
-static bool hasPercentageTransform(const ComputedStyle& style) {
- if (TransformOperation* translate = style.translate()) {
- if (translate->dependsOnBoxSize())
- return true;
- }
- return style.transform().dependsOnBoxSize() ||
- (style.transformOriginX() != Length(50, Percent) &&
- style.transformOriginX().isPercentOrCalc()) ||
- (style.transformOriginY() != Length(50, Percent) &&
- style.transformOriginY().isPercentOrCalc());
-}
-
void PaintInvalidator::invalidatePaintIfNeeded(
const LayoutObject& object,
PaintInvalidatorContext& context) {
@@ -430,16 +476,11 @@ void PaintInvalidator::invalidatePaintIfNeeded(
break;
}
- if (context.oldLocation != context.newLocation)
- context.forcedSubtreeInvalidationFlags |=
- PaintInvalidatorContext::ForcedSubtreeInvalidationChecking;
-
- // TODO(crbug.com/533277): This is a workaround for the bug. Remove when we
- // detect paint offset change.
- if (reason != PaintInvalidationNone &&
- hasPercentageTransform(object.styleRef()))
+ if (context.oldLocation != context.newLocation ||
+ context.oldPaintOffset != context.newPaintOffset) {
context.forcedSubtreeInvalidationFlags |=
PaintInvalidatorContext::ForcedSubtreeInvalidationChecking;
+ }
// TODO(crbug.com/490725): This is a workaround for the bug, to force
// descendant to update visual rects on clipping change.

Powered by Google App Engine
This is Rietveld 408576698