Index: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp b/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
index d6e05ed112949823acd0f2522df469b6bab35b3c..24300b7bf5068b5e3b96729f9962677f66588587 100644 |
--- a/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
+++ b/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
@@ -15,25 +15,23 @@ |
namespace blink { |
struct PrePaintTreeWalkContext { |
+ USING_FAST_MALLOC(PrePaintTreeWalkContext); |
+ |
+ public: |
PrePaintTreeWalkContext() |
- : treeBuilderContext( |
- WTF::wrapUnique(new PaintPropertyTreeBuilderContext)), |
- paintInvalidatorContext(*treeBuilderContext), |
+ : treeBuilderContext(), |
+ paintInvalidatorContext(treeBuilderContext), |
ancestorOverflowPaintLayer(nullptr), |
ancestorTransformedOrRootPaintLayer(nullptr) {} |
PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext) |
- : treeBuilderContext(WTF::wrapUnique(new PaintPropertyTreeBuilderContext( |
- *parentContext.treeBuilderContext))), |
- paintInvalidatorContext(*treeBuilderContext, |
+ : treeBuilderContext(parentContext.treeBuilderContext), |
+ paintInvalidatorContext(treeBuilderContext, |
parentContext.paintInvalidatorContext), |
ancestorOverflowPaintLayer(parentContext.ancestorOverflowPaintLayer), |
ancestorTransformedOrRootPaintLayer( |
parentContext.ancestorTransformedOrRootPaintLayer) {} |
- // PaintPropertyTreeBuilderContext is large and can lead to stack overflows |
- // when recursion is deep so this context object is allocated on the heap. |
- // See: https://crbug.com/698653. |
- std::unique_ptr<PaintPropertyTreeBuilderContext> treeBuilderContext; |
+ PaintPropertyTreeBuilderContext treeBuilderContext; |
PaintInvalidatorContext paintInvalidatorContext; |
@@ -49,7 +47,7 @@ void PrePaintTreeWalk::walk(FrameView& rootFrame) { |
DocumentLifecycle::InPrePaint); |
PrePaintTreeWalkContext initialContext; |
- m_propertyTreeBuilder.setupInitialContext(*initialContext.treeBuilderContext); |
+ m_propertyTreeBuilder.setupInitialContext(initialContext.treeBuilderContext); |
initialContext.ancestorTransformedOrRootPaintLayer = |
rootFrame.layoutView()->layer(); |
@@ -73,8 +71,7 @@ void PrePaintTreeWalk::walk(FrameView& frameView, |
PrePaintTreeWalkContext context(parentContext); |
// ancestorOverflowLayer does not cross frame boundaries. |
context.ancestorOverflowPaintLayer = nullptr; |
- m_propertyTreeBuilder.updateProperties(frameView, |
- *context.treeBuilderContext); |
+ m_propertyTreeBuilder.updateProperties(frameView, context.treeBuilderContext); |
m_paintInvalidator.invalidatePaintIfNeeded(frameView, |
context.paintInvalidatorContext); |
@@ -186,8 +183,8 @@ void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( |
FloatClipRect clipRect; |
const EffectPaintPropertyNode* effect = |
- context.treeBuilderContext->currentEffect; |
- computeClipRectForContext(context.treeBuilderContext->current, effect, |
+ context.treeBuilderContext.currentEffect; |
+ computeClipRectForContext(context.treeBuilderContext.current, effect, |
ancestorState, ancestorPaintOffset, hasClip, |
clipRect); |
clipRects->setOverflowClipRect(clipRect); |
@@ -197,7 +194,7 @@ void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( |
<< "rect= " << clipRects->overflowClipRect().toString(); |
#endif |
- computeClipRectForContext(context.treeBuilderContext->fixedPosition, effect, |
+ computeClipRectForContext(context.treeBuilderContext.fixedPosition, effect, |
ancestorState, ancestorPaintOffset, hasClip, |
clipRect); |
clipRects->setFixedClipRect(clipRect); |
@@ -206,8 +203,8 @@ void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( |
<< " fixed=" << clipRects->fixedClipRect().toString(); |
#endif |
- computeClipRectForContext(context.treeBuilderContext->absolutePosition, |
- effect, ancestorState, ancestorPaintOffset, hasClip, |
+ computeClipRectForContext(context.treeBuilderContext.absolutePosition, effect, |
+ ancestorState, ancestorPaintOffset, hasClip, |
clipRect); |
clipRects->setPosClipRect(clipRect); |
#ifdef CHECK_CLIP_RECTS |
@@ -237,7 +234,7 @@ bool PrePaintTreeWalk::shouldEndWalkBefore( |
return ( |
!object.needsPaintPropertyUpdate() && |
!object.descendantNeedsPaintPropertyUpdate() && |
- !context.treeBuilderContext->forceSubtreeUpdate && |
+ !context.treeBuilderContext.forceSubtreeUpdate && |
!context.paintInvalidatorContext.forcedSubtreeInvalidationFlags && |
!object |
.shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()); |
@@ -255,11 +252,11 @@ void PrePaintTreeWalk::walk(const LayoutObject& object, |
updateAuxiliaryObjectProperties(object, context); |
m_propertyTreeBuilder.updatePropertiesForSelf(object, |
- *context.treeBuilderContext); |
+ context.treeBuilderContext); |
m_paintInvalidator.invalidatePaintIfNeeded(object, |
context.paintInvalidatorContext); |
- m_propertyTreeBuilder.updatePropertiesForChildren( |
- object, *context.treeBuilderContext); |
+ m_propertyTreeBuilder.updatePropertiesForChildren(object, |
+ context.treeBuilderContext); |
invalidatePaintLayerOptimizationsIfNeeded(object, context); |
@@ -276,11 +273,11 @@ void PrePaintTreeWalk::walk(const LayoutObject& object, |
const LayoutPart& layoutPart = toLayoutPart(object); |
FrameViewBase* frameViewBase = layoutPart.frameViewBase(); |
if (frameViewBase && frameViewBase->isFrameView()) { |
- context.treeBuilderContext->current.paintOffset += |
+ context.treeBuilderContext.current.paintOffset += |
layoutPart.replacedContentRect().location() - |
frameViewBase->frameRect().location(); |
- context.treeBuilderContext->current.paintOffset = |
- roundedIntPoint(context.treeBuilderContext->current.paintOffset); |
+ context.treeBuilderContext.current.paintOffset = |
+ roundedIntPoint(context.treeBuilderContext.current.paintOffset); |
walk(*toFrameView(frameViewBase), context); |
} |
// TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |