Index: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
index 7c500884885c0045d20b7a4ca37ac354ba8e12ab..662930434c38d209cc0ee28aa51968e4d271221a 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
@@ -374,7 +374,8 @@ PaintResult PaintLayerPainter::paintLayerContents( |
// scrolling contents and scrollbars. |
if (m_paintLayer.layoutObject()->hasClipPath() && |
(!m_paintLayer.needsCompositedScrolling() || |
- (paintFlags & PaintLayerPaintingChildClippingMaskPhase))) { |
+ (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | |
+ PaintLayerPaintingAncestorClippingMaskPhase)))) { |
paintingInfo.ancestorHasClipPathClipping = true; |
LayoutRect referenceBox(m_paintLayer.boxForClipPath()); |
@@ -430,19 +431,34 @@ PaintResult PaintLayerPainter::paintLayerContents( |
// TODO(trchen): We haven't decided how to handle visual fragmentation with |
chrishtr
2016/12/02 19:21:47
This comment belongs down by line 446.
Stephen Chennney
2016/12/07 21:39:38
Done.
|
// SPv2. Related thread |
// https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/81XuWFf-mxM |
+ PaintLayer* paintLayerForFragmentsAndClip = &m_paintLayer; |
+ LayoutPoint offsetFromRootForFragmentsAndClip = offsetFromRoot; |
+ if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { |
+ // Compute fragments and their clips with respect to the clipping |
+ // container, and then convert them back to this layer's space. |
+ // We need a new offset from root. |
+ paintLayerForFragmentsAndClip = |
+ m_paintLayer.clippingContainer()->enclosingLayer(); |
+ paintLayerForFragmentsAndClip->convertToLayerCoords( |
chrishtr
2016/12/02 19:21:47
You can't map from an ancestor to a descendant Pai
Stephen Chennney
2016/12/07 21:39:38
Done.
|
+ m_paintLayer.root(), offsetFromRootForFragmentsAndClip); |
+ } |
+ |
if (fragmentPolicy == ForceSingleFragment || |
- RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
- m_paintLayer.appendSingleFragmentIgnoringPagination( |
+ RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
+ paintLayerForFragmentsAndClip->appendSingleFragmentIgnoringPagination( |
layerFragments, localPaintingInfo.rootLayer, |
localPaintingInfo.paintDirtyRect, cacheSlot, |
- IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
+ IgnoreOverlayScrollbarSize, respectOverflowClip, |
+ &offsetFromRootForFragmentsAndClip, |
localPaintingInfo.subPixelAccumulation); |
- else |
- m_paintLayer.collectFragments(layerFragments, localPaintingInfo.rootLayer, |
- localPaintingInfo.paintDirtyRect, cacheSlot, |
- IgnoreOverlayScrollbarSize, |
- respectOverflowClip, &offsetFromRoot, |
- localPaintingInfo.subPixelAccumulation); |
+ } else { |
+ paintLayerForFragmentsAndClip->collectFragments( |
+ layerFragments, localPaintingInfo.rootLayer, |
+ localPaintingInfo.paintDirtyRect, cacheSlot, |
+ IgnoreOverlayScrollbarSize, respectOverflowClip, |
+ &offsetFromRootForFragmentsAndClip, |
+ localPaintingInfo.subPixelAccumulation); |
+ } |
if (shouldPaintContent) { |
// TODO(wangxianzhu): This is for old slow scrolling. Implement similar |
@@ -546,7 +562,8 @@ PaintResult PaintLayerPainter::paintLayerContents( |
shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && |
!selectionOnly; |
bool shouldPaintClippingMask = |
- (paintFlags & PaintLayerPaintingChildClippingMaskPhase) && |
+ (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | |
+ PaintLayerPaintingAncestorClippingMaskPhase)) && |
shouldPaintContent && !selectionOnly; |
if (shouldPaintMask) |
@@ -625,6 +642,7 @@ PaintResult PaintLayerPainter::paintLayerWithTransform( |
object->container() == view && view->pageLogicalHeight(); |
PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer(); |
PaintLayerFragments fragments; |
+ |
chrishtr
2016/12/02 19:21:47
Super nit: spurious.
Stephen Chennney
2016/12/07 21:39:38
Done.
|
// TODO(crbug.com/619094): Figure out the correct behaviour for fixed position |
// objects in paged media with vertical writing modes. |
if (isFixedPosObjectInPagedMedia && view->isHorizontalWritingMode()) { |
@@ -881,6 +899,22 @@ void PaintLayerPainter::paintOverflowControlsForFragments( |
} |
} |
+void adjustPaintOffsetForAncestorClippingMask( |
+ PaintLayer& layer, LayoutPoint& paintOffset) |
+{ |
+ // Adjust the paint offset to reflect the fact that the fragment is |
+ // positioned for the clipping container object. |
+ LayoutPoint clippersOffsetToRoot; |
+ PaintLayer* paintLayerForMask = |
+ layer.clippingContainer()->enclosingLayer(); |
+ paintLayerForMask->convertToLayerCoords(layer.root(), |
chrishtr
2016/12/02 19:21:47
This duplicates line 442 I think?
|
+ clippersOffsetToRoot); |
+ LayoutPoint paintersOffsetToRoot; |
+ layer.convertToLayerCoords(layer.root(), paintersOffsetToRoot); |
+ |
+ paintOffset.move(paintersOffsetToRoot - clippersOffsetToRoot); |
+} |
+ |
void PaintLayerPainter::paintFragmentWithPhase( |
PaintPhase phase, |
const PaintLayerFragment& fragment, |
@@ -909,9 +943,21 @@ void PaintLayerPainter::paintFragmentWithPhase( |
break; |
} |
- clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, |
- clipRect, &paintingInfo, fragment.paginationOffset, |
- paintFlags, clippingRule); |
+ // When painting the clipping mask for a composited child, we pass |
+ // the clipping container object as the layoutObject to provide the clip. |
+ // The recorder assumes the fragment is positioned in that objects's |
+ // layer coordinates, so we also convert that. |
+ if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { |
+ clipRecorder.emplace( |
+ context, *(toLayoutBoxModelObject(m_paintLayer.clippingContainer())), |
chrishtr
2016/12/02 19:21:47
Might be easier to read if you make a local variab
|
+ clipType, clipRect, &paintingInfo, |
+ fragment.paginationOffset, |
+ paintFlags, clippingRule); |
+ } else { |
+ clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, |
+ clipRect, &paintingInfo, fragment.paginationOffset, |
+ paintFlags, clippingRule); |
+ } |
} |
LayoutRect newCullRect(clipRect.rect()); |
@@ -945,6 +991,9 @@ void PaintLayerPainter::paintFragmentWithPhase( |
paintingInfo.getGlobalPaintFlags(), paintFlags, |
paintingInfo.rootLayer->layoutObject()); |
+ if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) |
+ adjustPaintOffsetForAncestorClippingMask(m_paintLayer, paintOffset); |
+ |
m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); |
} |