Chromium Code Reviews| 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 eea4ca3e7b43624d3f5d5a8380a852969219642a..aa6677513f8ea6b4701680449d1c69b363082369 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
| @@ -327,7 +327,8 @@ PaintLayerPainter::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()); |
| @@ -384,18 +385,21 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents( |
| // SPv2. Related thread |
| // https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/81XuWFf-mxM |
| if (fragmentPolicy == ForceSingleFragment || |
| - RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| + RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| m_paintLayer.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, |
| + paintFlags & PaintLayerPaintingAncestorClippingMaskPhase, |
| + &offsetFromRoot, localPaintingInfo.subPixelAccumulation); |
| + } else { |
| + m_paintLayer.collectFragments( |
| + layerFragments, localPaintingInfo.rootLayer, |
| + localPaintingInfo.paintDirtyRect, cacheSlot, |
| + IgnoreOverlayScrollbarSize, respectOverflowClip, |
| + paintFlags & PaintLayerPaintingAncestorClippingMaskPhase, |
| + &offsetFromRoot, localPaintingInfo.subPixelAccumulation); |
| + } |
| if (shouldPaintContent) { |
| // TODO(wangxianzhu): This is for old slow scrolling. Implement similar |
| @@ -492,7 +496,8 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents( |
| shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && |
| !selectionOnly; |
| bool shouldPaintClippingMask = |
| - (paintFlags & PaintLayerPaintingChildClippingMaskPhase) && |
| + (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | |
| + PaintLayerPaintingAncestorClippingMaskPhase)) && |
| shouldPaintContent && !selectionOnly; |
| if (shouldPaintMask) |
| @@ -571,6 +576,7 @@ PaintLayerPainter::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()) { |
| @@ -612,7 +618,7 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerWithTransform( |
| // here. |
| paginationLayer->collectFragments( |
| fragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, |
| - cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, 0, |
| + cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, false, 0, |
| paintingInfo.subPixelAccumulation, &transformedExtent); |
| } else { |
| // We don't need to collect any fragments in the regular way here. We have |
| @@ -828,6 +834,27 @@ void PaintLayerPainter::paintOverflowControlsForFragments( |
| } |
| } |
| +LayoutPoint PaintLayerPainter::fragmentOffsetForAncestorClipMask( |
| + const LayoutPoint& originalFragmentOffset) { |
| + // The clipping container that will be used to define the clip and the |
| + // child layer with respect to which the fragment offset is defined share |
| + // a layer root. When the clip is recorded we will be using the clipping |
| + // container's layer's offset to the root to position the clip. Hence we |
| + // must convert the fragment offset into a corresponding offset in the |
| + // clipping container's layer coordinates. To do that, we find the |
| + // originalFragmentOffset's coordinate in the root layer, fragmentDelta. |
| + // We also find the offset of the clipping container's origin in the root |
| + // layer's coordinates, clippingDelta. clippingDelta - fragmentDelta gives |
| + // the fragment's position in the root layer. But we need the position in |
| + // the clipping layer coords, and we subtract clippingDelta to get that. The |
| + // resulting offset is -fragmentDelta. |
| + DCHECK_EQ(m_paintLayer.root(), |
| + m_paintLayer.clippingContainer()->enclosingLayer()->root()); |
| + LayoutPoint fragmentDelta(originalFragmentOffset); |
| + m_paintLayer.convertToLayerCoords(m_paintLayer.root(), fragmentDelta); |
| + return LayoutPoint(-fragmentDelta.x(), -fragmentDelta.y()); |
| +} |
| + |
| void PaintLayerPainter::paintFragmentWithPhase( |
| PaintPhase phase, |
| const PaintLayerFragment& fragment, |
| @@ -856,9 +883,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())), |
| + clipType, clipRect, &paintingInfo, |
| + fragmentOffsetForAncestorClipMask(fragment.paginationOffset), |
| + paintFlags, clippingRule); |
| + } else { |
| + clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, |
| + clipRect, &paintingInfo, fragment.paginationOffset, |
| + paintFlags, clippingRule); |
| + } |
| } |
| LayoutRect newCullRect(clipRect.rect()); |
| @@ -892,6 +931,7 @@ void PaintLayerPainter::paintFragmentWithPhase( |
| paintingInfo.getGlobalPaintFlags(), paintFlags, |
| paintingInfo.rootLayer->layoutObject()); |
| + // TODO(schenney): This is the wrong object for painting AncestorClippingMask. |
|
Stephen Chennney
2016/11/08 21:42:52
No it's not. It's the wrong object for all the cli
|
| m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); |
| } |