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

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

Issue 2698123002: Avoid false-positives of paint offset change detection (method 2) (Closed)
Patch Set: - Created 3 years, 10 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/paint/PaintPropertyTreeBuilder.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
index 34b7942e959e2e6c6f757736832a8ca09f7c4a95..ced31e0017a8c47e82ca52ff038562d1552d2a04 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -215,17 +215,18 @@ void PaintPropertyTreeBuilder::updateProperties(
frameView.setTotalPropertyTreeStateForContents(std::move(contentsState));
}
-void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
+static bool calculatePaintOffsetTranslation(
const LayoutObject& object,
- PaintPropertyTreeBuilderContext& context) {
+ const LayoutPoint& paintOffset,
+ IntPoint& roundedPaintOffset,
+ LayoutPoint& fractionalPaintOffset) {
bool usesPaintOffsetTranslation = false;
if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
object.isLayoutView()) {
// Root layer scrolling always creates a translation node for LayoutView to
// ensure fixed and absolute contexts use the correct transform space.
usesPaintOffsetTranslation = true;
- } else if (object.isBoxModelObject() &&
- context.current.paintOffset != LayoutPoint()) {
+ } else if (object.isBoxModelObject() && paintOffset != LayoutPoint()) {
PaintLayer* layer = toLayoutBoxModelObject(object).layer();
if (layer &&
layer->paintsWithTransform(GlobalPaintFlattenCompositingLayers))
@@ -239,10 +240,22 @@ void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
// called "subpixel accumulation". For more information, see
// PaintLayer::subpixelAccumulation() and
// PaintLayerPainter::paintFragmentByApplyingTransform.
- IntPoint roundedPaintOffset = roundedIntPoint(context.current.paintOffset);
- LayoutPoint fractionalPaintOffset =
- LayoutPoint(context.current.paintOffset - roundedPaintOffset);
+ if (usesPaintOffsetTranslation) {
+ roundedPaintOffset = roundedIntPoint(paintOffset);
+ fractionalPaintOffset = LayoutPoint(paintOffset - roundedPaintOffset);
+ }
+
+ return usesPaintOffsetTranslation;
+}
+void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
+ const LayoutObject& object,
+ PaintPropertyTreeBuilderContext& context) {
+ IntPoint roundedPaintOffset;
+ LayoutPoint fractionalPaintOffset;
+ bool usesPaintOffsetTranslation = calculatePaintOffsetTranslation(
+ object, context.current.paintOffset, roundedPaintOffset,
+ fractionalPaintOffset);
if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) {
if (usesPaintOffsetTranslation) {
auto& properties = object.getMutableForPainting().ensurePaintProperties();
@@ -863,7 +876,7 @@ void PaintPropertyTreeBuilder::updateOutOfFlowContext(
}
}
-void PaintPropertyTreeBuilder::updateContextForBoxPosition(
+void PaintPropertyTreeBuilder::updateContextForLocation(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (!object.isBoxModelObject())
@@ -930,15 +943,29 @@ void PaintPropertyTreeBuilder::updateContextForBoxPosition(
}
}
+ IntPoint roundedPaintOffset;
+ LayoutPoint paintOffsetAfterTranslation = context.current.paintOffset;
+ if (calculatePaintOffsetTranslation(
+ toLayoutBoxModelObject(object), context.current.paintOffset,
+ roundedPaintOffset, paintOffsetAfterTranslation)) {
+ const auto* properties = object.paintProperties();
+ if (!properties || !properties->paintOffsetTranslation() ||
+ properties->paintOffsetTranslation()->matrix().to2DTranslation() !=
+ FloatSize(roundedPaintOffset.x(), roundedPaintOffset.y()))
+ object.getMutableForPainting().setNeedsPaintPropertyUpdate();
+ }
+
// Many paint properties depend on paint offset so we force an update of
// the entire subtree on paint offset changes.
- if (object.paintOffset() != context.current.paintOffset)
+ if (object.paintOffset() != paintOffsetAfterTranslation)
context.forceSubtreeUpdate = true;
}
void PaintPropertyTreeBuilder::updatePropertiesForSelf(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
+ updateContextForLocation(object, context);
+
#if DCHECK_IS_ON()
FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context);
#endif

Powered by Google App Engine
This is Rietveld 408576698