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..14294b9cec355ece66bdc6391a98e1182aa80ee7 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
@@ -251,6 +251,19 @@ static bool shouldRepaintSubsequence( |
return needsRepaint; |
} |
+void adjustOffsetForAncestorClippingMask( |
chrishtr
2016/12/07 19:16:24
This is now dead code.
|
+ const PaintLayer& childLayer, |
+ const PaintLayer& ancestorLayer, |
+ LayoutPoint& offset) |
+{ |
+ // Adjust the offset to reflect the fact that the fragment is |
+ // positioned for the clipping container object. |
+ LayoutPoint childOffsetToAncestor; |
+ childLayer.convertToLayerCoords(&ancestorLayer, childOffsetToAncestor); |
+ offset.move( |
+ LayoutSize(-childOffsetToAncestor.x(), -childOffsetToAncestor.y())); |
+} |
+ |
PaintResult PaintLayerPainter::paintLayerContents( |
GraphicsContext& context, |
const PaintLayerPaintingInfo& paintingInfoArg, |
@@ -374,7 +387,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 +444,45 @@ PaintResult PaintLayerPainter::paintLayerContents( |
// TODO(trchen): We haven't decided how to handle visual fragmentation with |
// SPv2. Related thread |
// https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/81XuWFf-mxM |
+ LayoutPoint offsetToClipper; |
+ PaintLayer* paintLayerForFragments = &m_paintLayer; |
+ if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { |
+ // Compute fragments and their clips with respect to the clipping |
+ // container. The paint rect is in this layer's space, so convert it |
+ // to the clipper's layer's space. The rootLayer is also changed to |
+ // the clipper's layer to simplify coordinate system adjustments. |
+ paintLayerForFragments = m_paintLayer.clippingContainer()->enclosingLayer(); |
+ localPaintingInfo.rootLayer = paintLayerForFragments; |
+ m_paintLayer.convertToLayerCoords(localPaintingInfo.rootLayer, offsetToClipper); |
+ localPaintingInfo.paintDirtyRect.moveBy(offsetToClipper); |
+ } |
+ |
if (fragmentPolicy == ForceSingleFragment || |
- RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
- m_paintLayer.appendSingleFragmentIgnoringPagination( |
+ RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
+ paintLayerForFragments->appendSingleFragmentIgnoringPagination( |
layerFragments, localPaintingInfo.rootLayer, |
localPaintingInfo.paintDirtyRect, cacheSlot, |
- IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
- localPaintingInfo.subPixelAccumulation); |
- else |
- m_paintLayer.collectFragments(layerFragments, localPaintingInfo.rootLayer, |
- localPaintingInfo.paintDirtyRect, cacheSlot, |
- IgnoreOverlayScrollbarSize, |
- respectOverflowClip, &offsetFromRoot, |
- localPaintingInfo.subPixelAccumulation); |
+ IgnoreOverlayScrollbarSize, respectOverflowClip, |
+ &offsetFromRoot, localPaintingInfo.subPixelAccumulation); |
+ } else { |
+ paintLayerForFragments->collectFragments( |
+ layerFragments, localPaintingInfo.rootLayer, |
+ localPaintingInfo.paintDirtyRect, cacheSlot, |
+ IgnoreOverlayScrollbarSize, respectOverflowClip, |
+ &offsetFromRoot, localPaintingInfo.subPixelAccumulation); |
+ } |
+ |
+ if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { |
+ // Fragment offsets have been computed in the clipping container's |
+ // layer's coordinate system, but for the rest of painting we need |
+ // them in the layer coordinate. So move them and the foreground rect |
+ // that is also in the clipper's space. |
+ LayoutSize negativeOffset(-offsetToClipper.x(), -offsetToClipper.y()); |
+ for (auto& fragment: layerFragments) { |
+ fragment.foregroundRect.move(negativeOffset); |
+ fragment.paginationOffset.move(negativeOffset); |
+ } |
+ } |
if (shouldPaintContent) { |
// TODO(wangxianzhu): This is for old slow scrolling. Implement similar |
@@ -546,7 +586,8 @@ PaintResult PaintLayerPainter::paintLayerContents( |
shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && |
!selectionOnly; |
bool shouldPaintClippingMask = |
- (paintFlags & PaintLayerPaintingChildClippingMaskPhase) && |
+ (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | |
+ PaintLayerPaintingAncestorClippingMaskPhase)) && |
shouldPaintContent && !selectionOnly; |
if (shouldPaintMask) |
@@ -625,6 +666,7 @@ PaintResult PaintLayerPainter::paintLayerWithTransform( |
object->container() == view && view->pageLogicalHeight(); |
PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer(); |
PaintLayerFragments fragments; |
+ |
// TODO(crbug.com/619094): Figure out the correct behaviour for fixed position |
// objects in paged media with vertical writing modes. |
if (isFixedPosObjectInPagedMedia && view->isHorizontalWritingMode()) { |
@@ -721,7 +763,7 @@ PaintResult PaintLayerPainter::paintLayerWithTransform( |
UseCounter::ClipCssOfFixedPositionElement); |
clipRecorder.emplace(context, *parentLayer->layoutObject(), |
DisplayItem::kClipLayerParent, clipRectForFragment, |
- &paintingInfo, fragment.paginationOffset, |
+ paintingInfo.rootLayer, fragment.paginationOffset, |
paintFlags); |
} |
} |
@@ -859,7 +901,8 @@ void PaintLayerPainter::paintOverflowControlsForFragments( |
if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { |
clipRecorder.emplace(context, *m_paintLayer.layoutObject(), |
DisplayItem::kClipLayerOverflowControls, |
- fragment.backgroundRect, &localPaintingInfo, |
+ fragment.backgroundRect, |
+ localPaintingInfo.rootLayer, |
fragment.paginationOffset, paintFlags); |
} |
@@ -910,8 +953,8 @@ void PaintLayerPainter::paintFragmentWithPhase( |
} |
clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, |
- clipRect, &paintingInfo, fragment.paginationOffset, |
- paintFlags, clippingRule); |
+ clipRect, paintingInfo.rootLayer, |
+ fragment.paginationOffset, paintFlags, clippingRule); |
} |
LayoutRect newCullRect(clipRect.rect()); |
@@ -983,7 +1026,8 @@ void PaintLayerPainter::paintForegroundForFragments( |
needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) { |
clipRecorder.emplace(context, *m_paintLayer.layoutObject(), |
DisplayItem::kClipLayerForeground, |
- layerFragments[0].foregroundRect, &localPaintingInfo, |
+ layerFragments[0].foregroundRect, |
+ localPaintingInfo.rootLayer, |
layerFragments[0].paginationOffset, paintFlags); |
clipState = HasClipped; |
} |