Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp b/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp |
| index af5149f80469b94eaac9903df786c583cf5a18c7..da8ed5389ee8780577d57e198e063325a2618213 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp |
| @@ -210,24 +210,18 @@ LayoutRect PaintLayerClipper::localClipRect( |
| const PaintLayer* clippingRootLayer) const { |
| ClipRectsContext context(clippingRootLayer, PaintingClipRects); |
| if (m_geometryMapper) { |
| - ClipRect clipRect = applyOverflowClipToBackgroundRectWithGeometryMapper( |
| - context, clipRectWithGeometryMapper(context, false)); |
| + LayoutRect clippedRectInLocalSpace( |
| + applyOverflowClipToBackgroundRectWithGeometryMapper( |
| + context, clipRectWithGeometryMapper(context, false)) |
| + .rect()); |
| // The rect now needs to be transformed to the local space of this |
| // PaintLayer. |
| - bool success = false; |
| - FloatRect clippedRectInLocalSpace = |
| - m_geometryMapper->mapRectToDestinationSpace( |
| - FloatRect(clipRect.rect()), *clippingRootLayer->layoutObject() |
| - ->paintProperties() |
| - ->localBorderBoxProperties(), |
| - *m_layer.layoutObject() |
| - ->paintProperties() |
| - ->localBorderBoxProperties(), |
| - success); |
| - DCHECK(success); |
| - |
| - return LayoutRect(clippedRectInLocalSpace); |
| + LayoutPoint clippingRootOffset; |
|
chrishtr
2017/01/12 00:16:27
The simplest thing to do here is to just offset to
chrishtr
2017/01/12 00:28:14
This statement is incorrect. PaintLayer::physicalB
chrishtr
2017/01/12 00:42:54
Fixed.
|
| + m_layer.convertToLayerCoords(clippingRootLayer, clippingRootOffset); |
| + clippedRectInLocalSpace.moveBy(-clippingRootOffset); |
| + |
| + return clippedRectInLocalSpace; |
| } |
| LayoutRect layerBounds; |
| @@ -255,21 +249,22 @@ LayoutRect PaintLayerClipper::localClipRect( |
| void PaintLayerClipper::mapLocalToRootWithGeometryMapper( |
| const ClipRectsContext& context, |
| - LayoutRect& layoutRect) const { |
| + LayoutRect& rectToMap) const { |
| DCHECK(m_geometryMapper); |
| bool success; |
| const auto* layerBorderBoxProperties = |
| m_layer.layoutObject()->paintProperties()->localBorderBoxProperties(); |
| - FloatRect localRect(layoutRect); |
| + FloatRect localRect(rectToMap); |
| localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset())); |
| - layoutRect = LayoutRect(m_geometryMapper->mapRectToDestinationSpace( |
| + rectToMap = LayoutRect(m_geometryMapper->mapRectToDestinationSpace( |
| localRect, *layerBorderBoxProperties, *context.rootLayer->layoutObject() |
| ->paintProperties() |
| ->localBorderBoxProperties(), |
| success)); |
| DCHECK(success); |
| + rectToMap.moveBy(-context.rootLayer->layoutObject()->paintOffset()); |
| } |
| void PaintLayerClipper::calculateRectsWithGeometryMapper( |
| @@ -437,25 +432,41 @@ ClipRect PaintLayerClipper::clipRectWithGeometryMapper( |
| bool success = false; |
| const auto* properties = m_layer.layoutObject()->paintProperties(); |
| DCHECK(properties && properties->localBorderBoxProperties()); |
| - PropertyTreeState propertyTreeState = *properties->localBorderBoxProperties(); |
| - |
| - if (isForeground && shouldClipOverflow(context) && properties->overflowClip()) |
| - propertyTreeState.setClip(properties->overflowClip()); |
| + PropertyTreeState propertyTreeState = *properties->localBorderBoxProperties(); |
| const auto* ancestorProperties = |
| context.rootLayer->layoutObject()->paintProperties(); |
| DCHECK(ancestorProperties && ancestorProperties->localBorderBoxProperties()); |
| PropertyTreeState destinationPropertyTreeState = |
| *ancestorProperties->localBorderBoxProperties(); |
| - if (!context.rootLayer->clipper().shouldRespectOverflowClip(context)) { |
| - if (ancestorProperties->overflowClip()) |
| + |
| + if (&m_layer == context.rootLayer) { |
|
chrishtr
2017/01/12 00:16:26
Overflow clips are applied if
1. We're not ignori
|
| + // Set the overflow clip for |propertyTreeState| so that it differs from |
| + // destinationPropertyTreeState| in its clip. |
| + if (isForeground && context.respectOverflowClip == RespectOverflowClip && |
| + properties->overflowClip()) |
| + propertyTreeState.setClip(properties->overflowClip()); |
| + } else { |
| + // Set the clip of |destinationPropertyTreeState| to be inside the |
| + // ancestor's |
|
wkorman
2017/01/12 00:29:18
fix wrapping
chrishtr
2017/01/12 00:42:54
Done.
|
| + // overflow clip, so that that clip is not applied. |
| + if (context.respectOverflowClip == IgnoreOverflowClip && |
| + ancestorProperties->overflowClip()) |
| destinationPropertyTreeState.setClip(ancestorProperties->overflowClip()); |
| + |
| + // Set the overflow clip for |propertyTreeState| so that it differs from |
| + // destinationPropertyTreeState| in its clip. |
| + if (isForeground && properties->overflowClip()) |
| + propertyTreeState.setClip(properties->overflowClip()); |
| } |
| + |
| FloatRect clippedRectInRootLayerSpace = |
| m_geometryMapper->mapToVisualRectInDestinationSpace( |
| FloatRect(source), propertyTreeState, destinationPropertyTreeState, |
| success); |
| DCHECK(success); |
| + clippedRectInRootLayerSpace.moveBy( |
| + -FloatPoint(context.rootLayer->layoutObject()->paintOffset())); |
| return ClipRect(LayoutRect(clippedRectInRootLayerSpace)); |
| } |