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

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

Issue 2539693002: Early-out from the prepaint tree walk (Closed)
Patch Set: Do not force subtree updates for all paint invalidation reasons, add todo to track paint offset cha… Created 4 years 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 c55093609fcf2552bd1ee594b7ec6f0adc0e8026..404df3d2df9fdb2fe5cd1b245aff5e18b7fbd135 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -34,7 +34,7 @@ PaintPropertyTreeBuilder::setupInitialContext() {
return context;
}
-void updateFrameViewPreTranslation(
+PropertyWasCreated updatePreTranslation(
FrameView& frameView,
PassRefPtr<const TransformPaintPropertyNode> parent,
const TransformationMatrix& matrix,
@@ -42,13 +42,14 @@ void updateFrameViewPreTranslation(
DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled());
if (auto* existingPreTranslation = frameView.preTranslation()) {
existingPreTranslation->update(std::move(parent), matrix, origin);
- } else {
- frameView.setPreTranslation(
- TransformPaintPropertyNode::create(std::move(parent), matrix, origin));
+ return DidNotCreateProperty;
}
+ frameView.setPreTranslation(
+ TransformPaintPropertyNode::create(std::move(parent), matrix, origin));
+ return CreatedProperty;
}
-void updateFrameViewContentClip(
+PropertyWasCreated updateContentClip(
FrameView& frameView,
PassRefPtr<const ClipPaintPropertyNode> parent,
PassRefPtr<const TransformPaintPropertyNode> localTransformSpace,
@@ -57,13 +58,14 @@ void updateFrameViewContentClip(
if (auto* existingContentClip = frameView.contentClip()) {
existingContentClip->update(std::move(parent),
std::move(localTransformSpace), clipRect);
- } else {
- frameView.setContentClip(ClipPaintPropertyNode::create(
- std::move(parent), std::move(localTransformSpace), clipRect));
+ return DidNotCreateProperty;
}
+ frameView.setContentClip(ClipPaintPropertyNode::create(
+ std::move(parent), std::move(localTransformSpace), clipRect));
+ return CreatedProperty;
}
-void updateFrameViewScrollTranslation(
+PropertyWasCreated updateScrollTranslation(
FrameView& frameView,
PassRefPtr<const TransformPaintPropertyNode> parent,
const TransformationMatrix& matrix,
@@ -71,13 +73,14 @@ void updateFrameViewScrollTranslation(
DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled());
if (auto* existingScrollTranslation = frameView.scrollTranslation()) {
existingScrollTranslation->update(std::move(parent), matrix, origin);
- } else {
- frameView.setScrollTranslation(
- TransformPaintPropertyNode::create(std::move(parent), matrix, origin));
+ return DidNotCreateProperty;
}
+ frameView.setScrollTranslation(
+ TransformPaintPropertyNode::create(std::move(parent), matrix, origin));
+ return CreatedProperty;
}
-void updateFrameViewScroll(
+PropertyWasCreated updateScroll(
FrameView& frameView,
PassRefPtr<const ScrollPaintPropertyNode> parent,
PassRefPtr<const TransformPaintPropertyNode> scrollOffset,
@@ -91,12 +94,13 @@ void updateFrameViewScroll(
existingScroll->update(std::move(parent), std::move(scrollOffset), clip,
bounds, userScrollableHorizontal,
userScrollableVertical, mainThreadScrollingReasons);
- } else {
- frameView.setScroll(ScrollPaintPropertyNode::create(
- std::move(parent), std::move(scrollOffset), clip, bounds,
- userScrollableHorizontal, userScrollableVertical,
- mainThreadScrollingReasons));
+ return DidNotCreateProperty;
}
+ frameView.setScroll(ScrollPaintPropertyNode::create(
+ std::move(parent), std::move(scrollOffset), clip, bounds,
+ userScrollableHorizontal, userScrollableVertical,
+ mainThreadScrollingReasons));
+ return CreatedProperty;
}
void PaintPropertyTreeBuilder::updateProperties(
@@ -116,28 +120,32 @@ void PaintPropertyTreeBuilder::updateProperties(
return;
}
+ if (context.forceSubtreeUpdate)
+ frameView.setNeedsPaintPropertyUpdateWithoutMarkingAncestors();
+
#if DCHECK_IS_ON()
- FindFrameViewPropertiesNeedingUpdateScope checkNeedsUpdateScope(&frameView);
+ FindFrameViewPropertiesNeedingUpdateScope checkScope(&frameView, context);
#endif
if (frameView.needsPaintPropertyUpdate()) {
TransformationMatrix frameTranslate;
frameTranslate.translate(frameView.x() + context.current.paintOffset.x(),
frameView.y() + context.current.paintOffset.y());
- updateFrameViewPreTranslation(frameView, context.current.transform,
- frameTranslate, FloatPoint3D());
+ context.forceSubtreeUpdate |= updatePreTranslation(
chrishtr 2016/12/01 02:36:35 Did you consider passing context.forceSubtreeUpdat
+ frameView, context.current.transform, frameTranslate, FloatPoint3D());
FloatRoundedRect contentClip(
IntRect(IntPoint(), frameView.visibleContentSize()));
- updateFrameViewContentClip(frameView, context.current.clip,
- frameView.preTranslation(), contentClip);
+ context.forceSubtreeUpdate |=
+ updateContentClip(frameView, context.current.clip,
+ frameView.preTranslation(), contentClip);
ScrollOffset scrollOffset = frameView.scrollOffset();
if (frameView.isScrollable() || !scrollOffset.isZero()) {
TransformationMatrix frameScroll;
frameScroll.translate(-scrollOffset.width(), -scrollOffset.height());
- updateFrameViewScrollTranslation(frameView, frameView.preTranslation(),
- frameScroll, FloatPoint3D());
+ context.forceSubtreeUpdate |= updateScrollTranslation(
+ frameView, frameView.preTranslation(), frameScroll, FloatPoint3D());
IntSize scrollClip = frameView.visibleContentSize();
IntSize scrollBounds = frameView.contentsSize();
@@ -153,14 +161,19 @@ void PaintPropertyTreeBuilder::updateProperties(
reasons |=
MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects;
}
- updateFrameViewScroll(frameView, context.current.scroll,
- frameView.scrollTranslation(), scrollClip,
- scrollBounds, userScrollableHorizontal,
- userScrollableVertical, reasons);
+ context.forceSubtreeUpdate |= updateScroll(
+ frameView, context.current.scroll, frameView.scrollTranslation(),
+ scrollClip, scrollBounds, userScrollableHorizontal,
+ userScrollableVertical, reasons);
} else {
- // Ensure pre-existing properties are cleared when there is no scrolling.
- frameView.setScrollTranslation(nullptr);
- frameView.setScroll(nullptr);
+ if (frameView.scrollTranslation() || frameView.scroll()) {
+ // Ensure pre-existing properties are cleared if there is no scrolling.
+ frameView.setScrollTranslation(nullptr);
+ frameView.setScroll(nullptr);
+
+ // Rebuild all descendant properties because a property was removed.
+ context.forceSubtreeUpdate = true;
+ }
}
}
@@ -224,17 +237,16 @@ void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
if (object.needsPaintPropertyUpdate()) {
if (usesPaintOffsetTranslation) {
- object.getMutableForPainting()
- .ensurePaintProperties()
- .updatePaintOffsetTranslation(
- context.current.transform,
- TransformationMatrix().translate(roundedPaintOffset.x(),
- roundedPaintOffset.y()),
- FloatPoint3D(), context.current.shouldFlattenInheritedTransform,
- context.current.renderingContextID);
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updatePaintOffsetTranslation(
+ context.current.transform,
+ TransformationMatrix().translate(roundedPaintOffset.x(),
+ roundedPaintOffset.y()),
+ FloatPoint3D(), context.current.shouldFlattenInheritedTransform,
+ context.current.renderingContextID);
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearPaintOffsetTranslation();
+ context.forceSubtreeUpdate |= properties->clearPaintOffsetTranslation();
}
}
@@ -283,12 +295,13 @@ void PaintPropertyTreeBuilder::updateTransformForNonRootSVG(
// identity matrix.
if (!transform.isIdentity()) {
// The origin is included in the local transform, so leave origin empty.
- object.getMutableForPainting().ensurePaintProperties().updateTransform(
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updateTransform(
context.current.transform, TransformationMatrix(transform),
FloatPoint3D());
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearTransform();
+ context.forceSubtreeUpdate |= properties->clearTransform();
}
}
@@ -325,13 +338,14 @@ void PaintPropertyTreeBuilder::updateTransform(
if (style.preserves3D() && !renderingContextID)
renderingContextID = PtrHash<const LayoutObject>::hash(&object);
- object.getMutableForPainting().ensurePaintProperties().updateTransform(
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updateTransform(
context.current.transform, matrix,
transformOrigin(toLayoutBox(object)),
context.current.shouldFlattenInheritedTransform, renderingContextID);
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearTransform();
+ context.forceSubtreeUpdate |= properties->clearTransform();
}
}
@@ -357,7 +371,7 @@ void PaintPropertyTreeBuilder::updateEffect(
if (!style.isStackingContext()) {
if (object.needsPaintPropertyUpdate()) {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearEffect();
+ context.forceSubtreeUpdate |= properties->clearEffect();
}
return;
}
@@ -408,12 +422,13 @@ void PaintPropertyTreeBuilder::updateEffect(
}
if (effectNodeNeeded) {
- object.getMutableForPainting().ensurePaintProperties().updateEffect(
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updateEffect(
context.currentEffect, context.current.transform, outputClip,
std::move(filter), opacity);
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearEffect();
+ context.forceSubtreeUpdate |= properties->clearEffect();
}
}
@@ -443,12 +458,13 @@ void PaintPropertyTreeBuilder::updateCssClip(
DCHECK(object.canContainAbsolutePositionObjects());
LayoutRect clipRect =
toLayoutBox(object).clipRect(context.current.paintOffset);
- object.getMutableForPainting().ensurePaintProperties().updateCssClip(
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updateCssClip(
context.current.clip, context.current.transform,
FloatRoundedRect(FloatRect(clipRect)));
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearCssClip();
+ context.forceSubtreeUpdate |= properties->clearCssClip();
}
}
@@ -485,7 +501,7 @@ void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(
// TODO(trchen): Remove this once we bake the paint offset into frameRect.
void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(
const LayoutObject& object,
- const PaintPropertyTreeBuilderContext& context) {
+ PaintPropertyTreeBuilderContext& context) {
if (!object.needsPaintPropertyUpdate())
return;
@@ -496,10 +512,10 @@ void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(
if (area->horizontalScrollbar() || area->verticalScrollbar()) {
auto paintOffset = TransformationMatrix().translate(
roundedPaintOffset.x(), roundedPaintOffset.y());
- object.getMutableForPainting()
- .ensurePaintProperties()
- .updateScrollbarPaintOffset(context.current.transform, paintOffset,
- FloatPoint3D());
+ auto& properties =
+ object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updateScrollbarPaintOffset(
+ context.current.transform, paintOffset, FloatPoint3D());
needsScrollbarPaintOffset = true;
}
}
@@ -507,7 +523,7 @@ void PaintPropertyTreeBuilder::updateScrollbarPaintOffset(
auto* properties = object.getMutableForPainting().paintProperties();
if (!needsScrollbarPaintOffset && properties)
- properties->clearScrollbarPaintOffset();
+ context.forceSubtreeUpdate |= properties->clearScrollbarPaintOffset();
}
void PaintPropertyTreeBuilder::updateOverflowClip(
@@ -533,29 +549,27 @@ void PaintPropertyTreeBuilder::updateOverflowClip(
box.overflowClipRect(context.current.paintOffset)));
} else {
if (auto* properties = object.getMutableForPainting().paintProperties()) {
- properties->clearInnerBorderRadiusClip();
- properties->clearOverflowClip();
+ context.forceSubtreeUpdate |= properties->clearInnerBorderRadiusClip();
+ context.forceSubtreeUpdate |= properties->clearOverflowClip();
}
return;
}
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
const auto* currentClip = context.current.clip;
if (box.styleRef().hasBorderRadius()) {
auto innerBorder = box.styleRef().getRoundedInnerBorderFor(
LayoutRect(context.current.paintOffset, box.size()));
- object.getMutableForPainting()
- .ensurePaintProperties()
- .updateInnerBorderRadiusClip(context.current.clip,
- context.current.transform, innerBorder);
- currentClip = object.paintProperties()->innerBorderRadiusClip();
- } else if (auto* properties =
- object.getMutableForPainting().paintProperties()) {
- properties->clearInnerBorderRadiusClip();
+ context.forceSubtreeUpdate |= properties.updateInnerBorderRadiusClip(
+ context.current.clip, context.current.transform, innerBorder);
+ currentClip = properties.innerBorderRadiusClip();
+ } else {
+ context.forceSubtreeUpdate |= properties.clearInnerBorderRadiusClip();
}
- object.getMutableForPainting().ensurePaintProperties().updateOverflowClip(
- currentClip, context.current.transform,
- FloatRoundedRect(FloatRect(clipRect)));
+ context.forceSubtreeUpdate |=
+ properties.updateOverflowClip(currentClip, context.current.transform,
+ FloatRoundedRect(FloatRect(clipRect)));
}
const auto* properties = object.paintProperties();
@@ -584,13 +598,14 @@ void PaintPropertyTreeBuilder::updatePerspective(
TransformationMatrix().applyPerspective(style.perspective());
FloatPoint3D origin = perspectiveOrigin(toLayoutBox(object)) +
toLayoutSize(context.current.paintOffset);
- object.getMutableForPainting().ensurePaintProperties().updatePerspective(
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updatePerspective(
context.current.transform, matrix, origin,
context.current.shouldFlattenInheritedTransform,
context.current.renderingContextID);
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearPerspective();
+ context.forceSubtreeUpdate |= properties->clearPerspective();
}
}
@@ -612,13 +627,15 @@ void PaintPropertyTreeBuilder::updateSvgLocalToBorderBoxTransform(
SVGRootPainter(toLayoutSVGRoot(object))
.transformToPixelSnappedBorderBox(context.current.paintOffset);
if (!transformToBorderBox.isIdentity()) {
- object.getMutableForPainting()
- .ensurePaintProperties()
- .updateSvgLocalToBorderBoxTransform(
+ auto& properties = object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |=
+ properties.updateSvgLocalToBorderBoxTransform(
context.current.transform, transformToBorderBox, FloatPoint3D());
} else {
- if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearSvgLocalToBorderBoxTransform();
+ if (auto* properties = object.getMutableForPainting().paintProperties()) {
+ context.forceSubtreeUpdate |=
+ properties->clearSvgLocalToBorderBoxTransform();
+ }
}
}
@@ -642,14 +659,14 @@ void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(
const PaintLayerScrollableArea* scrollableArea = box.getScrollableArea();
IntSize scrollOffset = box.scrolledContentOffset();
if (!scrollOffset.isZero() || scrollableArea->scrollsOverflow()) {
+ auto& properties =
+ object.getMutableForPainting().ensurePaintProperties();
TransformationMatrix matrix = TransformationMatrix().translate(
-scrollOffset.width(), -scrollOffset.height());
- object.getMutableForPainting()
- .ensurePaintProperties()
- .updateScrollTranslation(
- context.current.transform, matrix, FloatPoint3D(),
- context.current.shouldFlattenInheritedTransform,
- context.current.renderingContextID);
+ context.forceSubtreeUpdate |= properties.updateScrollTranslation(
+ context.current.transform, matrix, FloatPoint3D(),
+ context.current.shouldFlattenInheritedTransform,
+ context.current.renderingContextID);
IntSize scrollClip = scrollableArea->visibleContentRect().size();
IntSize scrollBounds = scrollableArea->contentsSize();
@@ -671,9 +688,8 @@ void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(
reasons |=
MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects;
}
- object.getMutableForPainting().ensurePaintProperties().updateScroll(
- context.current.scroll,
- object.paintProperties()->scrollTranslation(), scrollClip,
+ context.forceSubtreeUpdate |= properties.updateScroll(
+ context.current.scroll, properties.scrollTranslation(), scrollClip,
scrollBounds, userScrollableHorizontal, userScrollableVertical,
reasons);
} else {
@@ -681,8 +697,8 @@ void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(
// scrolling.
auto* properties = object.getMutableForPainting().paintProperties();
if (properties) {
- properties->clearScrollTranslation();
- properties->clearScroll();
+ context.forceSubtreeUpdate |= properties->clearScrollTranslation();
+ context.forceSubtreeUpdate |= properties->clearScroll();
}
}
}
@@ -732,12 +748,12 @@ void PaintPropertyTreeBuilder::updateOutOfFlowContext(
context.fixedPosition.clip = cssClip;
} else {
if (object.needsPaintPropertyUpdate()) {
- object.getMutableForPainting()
- .ensurePaintProperties()
- .updateCssClipFixedPosition(context.fixedPosition.clip,
- const_cast<TransformPaintPropertyNode*>(
+ auto& properties =
+ object.getMutableForPainting().ensurePaintProperties();
+ context.forceSubtreeUpdate |= properties.updateCssClipFixedPosition(
+ context.fixedPosition.clip, const_cast<TransformPaintPropertyNode*>(
cssClip->localTransformSpace()),
- cssClip->clipRect());
+ cssClip->clipRect());
}
const auto* properties = object.paintProperties();
if (properties && properties->cssClipFixedPosition())
@@ -748,7 +764,7 @@ void PaintPropertyTreeBuilder::updateOutOfFlowContext(
if (object.needsPaintPropertyUpdate()) {
if (auto* properties = object.getMutableForPainting().paintProperties())
- properties->clearCssClipFixedPosition();
+ context.forceSubtreeUpdate |= properties->clearCssClipFixedPosition();
}
}
@@ -879,8 +895,13 @@ void PaintPropertyTreeBuilder::updatePropertiesForSelf(
if (!object.isBoxModelObject() && !object.isSVG())
return;
+ if (context.forceSubtreeUpdate) {
+ object.getMutableForPainting()
+ .setNeedsPaintPropertyUpdateWithoutMarkingAncestors();
+ }
+
#if DCHECK_IS_ON()
- FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object);
+ FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context);
#endif
deriveBorderBoxFromContainerContext(object, context);
@@ -899,8 +920,13 @@ void PaintPropertyTreeBuilder::updatePropertiesForChildren(
if (!object.isBoxModelObject() && !object.isSVG())
return;
+ if (context.forceSubtreeUpdate) {
+ // This should have been set by |updatePropertiesForSelf|.
+ DCHECK(object.needsPaintPropertyUpdate());
+ }
+
#if DCHECK_IS_ON()
- FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object);
+ FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context);
#endif
updateOverflowClip(object, context);

Powered by Google App Engine
This is Rietveld 408576698