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 bf1341e06917afcfb28654a31892b81382ba8985..b1f001052c6743435f78247f42d1a6d02ec2956e 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
@@ -214,6 +214,45 @@ static PassRefPtr<EffectPaintPropertyNode> createEffectIfNeeded(const LayoutObje |
return newEffectNode.release(); |
} |
+void createCSSClipIfNeeded(RefPtr<ClipPaintPropertyNode>& newClipNodeForCSSClip, RefPtr<ClipPaintPropertyNode>& newClipNodeForCSSClipFixedPosition, const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
+{ |
+ if (!object.hasClip()) |
+ return; |
+ ASSERT(object.canContainAbsolutePositionObjects()); |
+ |
+ // Create clip node for descendants that are not fixed position. |
+ // We don't have to setup context.clipForAbsolutePosition here because this object must be |
+ // a container for absolute position descendants, and will copy from in-flow context later |
+ // at updateOutOfFlowContext() step. |
+ LayoutRect clipRect = toLayoutBox(object).clipRect(context.paintOffset); |
+ newClipNodeForCSSClip = ClipPaintPropertyNode::create( |
+ context.currentTransform, |
+ FloatRoundedRect(FloatRect(clipRect)), |
+ context.currentClip); |
+ context.currentClip = newClipNodeForCSSClip.get(); |
+ |
+ // Again, we don't have to setup context.clipForFixedPosition here if this object is |
+ // a container for fixed position descendants. It will copy from in-flow context at |
+ // updateOutOfFlowContext() step later. |
+ // TODO(pdr): Remove the !object.isLayoutView() condition when removing FrameView |
pdr.
2016/03/23 00:53:31
TODO(trchen)! :)
trchen
2016/03/23 01:45:42
It is copied from updateOutOfFlowContext(). The co
|
+ // paint properties for rootLayerScrolls. |
+ if (!object.isLayoutView() && object.canContainFixedPositionObjects()) |
+ return; |
+ |
+ // Now, before creating clip node for fixed position, check whether in-flow context and |
+ // fixed-position context has exactly the same clip. Reuse if possible. |
+ if (context.currentClip->parent() == context.clipForFixedPosition) { |
+ context.clipForFixedPosition = context.currentClip; |
+ return; |
+ } |
+ |
+ newClipNodeForCSSClipFixedPosition = ClipPaintPropertyNode::create( |
+ context.currentTransform, |
+ FloatRoundedRect(FloatRect(clipRect)), |
+ context.clipForFixedPosition); |
+ context.clipForFixedPosition = newClipNodeForCSSClipFixedPosition.get(); |
+} |
+ |
// TODO(trchen): Remove this once we bake the paint offset into frameRect. |
static PassRefPtr<TransformPaintPropertyNode> createScrollbarPaintOffsetIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
{ |
@@ -354,6 +393,9 @@ void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre |
RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext); |
RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTransformIfNeeded(object, localContext); |
RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext); |
+ RefPtr<ClipPaintPropertyNode> newClipNodeForCSSClip; |
+ RefPtr<ClipPaintPropertyNode> newClipNodeForCSSClipFixedPosition; |
+ createCSSClipIfNeeded(newClipNodeForCSSClip, newClipNodeForCSSClipFixedPosition, object, localContext); |
OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> newRecordedContext = recordTreeContextIfNeeded(object, localContext); |
RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollbarPaintOffset = createScrollbarPaintOffsetIfNeeded(object, localContext); |
RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowClipIfNeeded(object, localContext); |
@@ -363,11 +405,13 @@ void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre |
RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = createScrollTranslationIfNeeded(object, localContext); |
updateOutOfFlowContext(object, localContext); |
- if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransform || newEffectNode || newClipNodeForOverflowClip || newTransformNodeForPerspective || newTransformNodeForScrollTranslation || newTransformNodeForScrollbarPaintOffset || newRecordedContext) { |
+ if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransform || newEffectNode || newClipNodeForCSSClip || newClipNodeForCSSClipFixedPosition || newClipNodeForOverflowClip || newTransformNodeForPerspective || newTransformNodeForScrollTranslation || newTransformNodeForScrollbarPaintOffset || newRecordedContext) { |
OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProperties::create( |
newTransformNodeForPaintOffsetTranslation.release(), |
newTransformNodeForTransform.release(), |
newEffectNode.release(), |
+ newClipNodeForCSSClip.release(), |
+ newClipNodeForCSSClipFixedPosition.release(), |
newClipNodeForOverflowClip.release(), |
newTransformNodeForPerspective.release(), |
newTransformNodeForScrollTranslation.release(), |