OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // behave as if it lives in an unclipped universe so it can prepaint, etc. | 548 // behave as if it lives in an unclipped universe so it can prepaint, etc. |
549 // This means that we need to check if we are actually clipped before | 549 // This means that we need to check if we are actually clipped before |
550 // setting up m_ancestorClippingLayer otherwise | 550 // setting up m_ancestorClippingLayer otherwise |
551 // updateAncestorClippingLayerGeometry will fail as the clip rect will be | 551 // updateAncestorClippingLayerGeometry will fail as the clip rect will be |
552 // infinite. | 552 // infinite. |
553 // FIXME: this should use cached clip rects, but this sometimes give | 553 // FIXME: this should use cached clip rects, but this sometimes give |
554 // inaccurate results (and trips the ASSERTS in PaintLayerClipper). | 554 // inaccurate results (and trips the ASSERTS in PaintLayerClipper). |
555 ClipRectsContext clipRectsContext(compositingAncestor, UncachedClipRects, | 555 ClipRectsContext clipRectsContext(compositingAncestor, UncachedClipRects, |
556 IgnoreOverlayScrollbarSize); | 556 IgnoreOverlayScrollbarSize); |
557 clipRectsContext.setIgnoreOverflowClip(); | 557 clipRectsContext.setIgnoreOverflowClip(); |
558 LayoutRect unsnappedParentClipRect = | 558 |
559 m_owningLayer.clipper(PaintLayer::DoNotUseGeometryMapper) | 559 ClipRect clipRect; |
560 .backgroundClipRect(clipRectsContext) | 560 m_owningLayer.clipper(PaintLayer::DoNotUseGeometryMapper) |
561 .rect(); | 561 .calculateBackgroundClipRect(clipRectsContext, clipRect); |
562 IntRect parentClipRect = pixelSnappedIntRect(unsnappedParentClipRect); | 562 IntRect parentClipRect = pixelSnappedIntRect(clipRect.rect()); |
563 owningLayerIsClipped = parentClipRect != LayoutRect::infiniteIntRect(); | 563 owningLayerIsClipped = parentClipRect != LayoutRect::infiniteIntRect(); |
564 | 564 |
565 // TODO(schenney): CSS clips are not applied to composited children, and | 565 // TODO(schenney): CSS clips are not applied to composited children, and |
566 // should be via mask or by compositing the parent too. | 566 // should be via mask or by compositing the parent too. |
567 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870 | 567 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870 |
568 DCHECK(clippingContainer->style()); | 568 DCHECK(clippingContainer->style()); |
569 owningLayerIsMasked = | 569 owningLayerIsMasked = |
570 owningLayerIsClipped && clippingContainer->style()->hasBorderRadius() && | 570 owningLayerIsClipped && clippingContainer->style()->hasBorderRadius() && |
571 !ancestorRoundedCornersWontClip(layoutObject(), *clippingContainer); | 571 !ancestorRoundedCornersWontClip(layoutObject(), *clippingContainer); |
572 } | 572 } |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 void CompositedLayerMapping::updateAncestorClippingLayerGeometry( | 1145 void CompositedLayerMapping::updateAncestorClippingLayerGeometry( |
1146 const PaintLayer* compositingContainer, | 1146 const PaintLayer* compositingContainer, |
1147 const IntPoint& snappedOffsetFromCompositedAncestor, | 1147 const IntPoint& snappedOffsetFromCompositedAncestor, |
1148 IntPoint& graphicsLayerParentLocation) { | 1148 IntPoint& graphicsLayerParentLocation) { |
1149 if (!compositingContainer || !m_ancestorClippingLayer) | 1149 if (!compositingContainer || !m_ancestorClippingLayer) |
1150 return; | 1150 return; |
1151 | 1151 |
1152 ClipRectsContext clipRectsContext(compositingContainer, | 1152 ClipRectsContext clipRectsContext(compositingContainer, |
1153 PaintingClipRectsIgnoringOverflowClip, | 1153 PaintingClipRectsIgnoringOverflowClip, |
1154 IgnoreOverlayScrollbarSize); | 1154 IgnoreOverlayScrollbarSize); |
1155 IntRect parentClipRect = pixelSnappedIntRect( | 1155 |
1156 m_owningLayer.clipper(PaintLayer::DoNotUseGeometryMapper) | 1156 ClipRect parentClipRect; |
1157 .backgroundClipRect(clipRectsContext) | 1157 m_owningLayer.clipper(PaintLayer::DoNotUseGeometryMapper) |
1158 .rect()); | 1158 .calculateBackgroundClipRect(clipRectsContext, parentClipRect); |
1159 ASSERT(parentClipRect != LayoutRect::infiniteIntRect()); | 1159 |
1160 m_ancestorClippingLayer->setPosition( | 1160 IntRect snappedParentClipRect(pixelSnappedIntRect(parentClipRect.rect())); |
1161 FloatPoint(parentClipRect.location() - graphicsLayerParentLocation)); | 1161 |
1162 m_ancestorClippingLayer->setSize(FloatSize(parentClipRect.size())); | 1162 DCHECK(snappedParentClipRect != LayoutRect::infiniteIntRect()); |
| 1163 m_ancestorClippingLayer->setPosition(FloatPoint( |
| 1164 snappedParentClipRect.location() - graphicsLayerParentLocation)); |
| 1165 m_ancestorClippingLayer->setSize(FloatSize(snappedParentClipRect.size())); |
1163 | 1166 |
1164 // backgroundRect is relative to compositingContainer, so subtract | 1167 // backgroundRect is relative to compositingContainer, so subtract |
1165 // snappedOffsetFromCompositedAncestor.X/snappedOffsetFromCompositedAncestor.Y | 1168 // snappedOffsetFromCompositedAncestor.X/snappedOffsetFromCompositedAncestor.Y |
1166 // to get back to local coords. | 1169 // to get back to local coords. |
1167 m_ancestorClippingLayer->setOffsetFromLayoutObject( | 1170 m_ancestorClippingLayer->setOffsetFromLayoutObject( |
1168 parentClipRect.location() - snappedOffsetFromCompositedAncestor); | 1171 snappedParentClipRect.location() - snappedOffsetFromCompositedAncestor); |
1169 | 1172 |
1170 if (m_ancestorClippingMaskLayer) { | 1173 if (m_ancestorClippingMaskLayer) { |
1171 m_ancestorClippingMaskLayer->setOffsetFromLayoutObject( | 1174 m_ancestorClippingMaskLayer->setOffsetFromLayoutObject( |
1172 m_ancestorClippingLayer->offsetFromLayoutObject()); | 1175 m_ancestorClippingLayer->offsetFromLayoutObject()); |
1173 m_ancestorClippingMaskLayer->setSize(m_ancestorClippingLayer->size()); | 1176 m_ancestorClippingMaskLayer->setSize(m_ancestorClippingLayer->size()); |
1174 m_ancestorClippingMaskLayer->setNeedsDisplay(); | 1177 m_ancestorClippingMaskLayer->setNeedsDisplay(); |
1175 } | 1178 } |
1176 | 1179 |
1177 // The primary layer is then parented in, and positioned relative to this | 1180 // The primary layer is then parented in, and positioned relative to this |
1178 // clipping layer. | 1181 // clipping layer. |
1179 graphicsLayerParentLocation = parentClipRect.location(); | 1182 graphicsLayerParentLocation = snappedParentClipRect.location(); |
1180 } | 1183 } |
1181 | 1184 |
1182 void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry( | 1185 void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry( |
1183 const PaintLayer* compositingStackingContext, | 1186 const PaintLayer* compositingStackingContext, |
1184 const PaintLayer* compositingContainer, | 1187 const PaintLayer* compositingContainer, |
1185 IntPoint graphicsLayerParentLocation) { | 1188 IntPoint graphicsLayerParentLocation) { |
1186 if (!m_overflowControlsHostLayer) | 1189 if (!m_overflowControlsHostLayer) |
1187 return; | 1190 return; |
1188 | 1191 |
1189 // To position and clip the scrollbars correctly, m_overflowControlsHostLayer | 1192 // To position and clip the scrollbars correctly, m_overflowControlsHostLayer |
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 containingSquashedLayer(clippingContainer, layers, layers.size()); | 2872 containingSquashedLayer(clippingContainer, layers, layers.size()); |
2870 // Must be there, otherwise | 2873 // Must be there, otherwise |
2871 // CompositingLayerAssigner::canSquashIntoCurrentSquashingOwner would have | 2874 // CompositingLayerAssigner::canSquashIntoCurrentSquashingOwner would have |
2872 // disallowed squashing. | 2875 // disallowed squashing. |
2873 ASSERT(ancestorPaintInfo); | 2876 ASSERT(ancestorPaintInfo); |
2874 | 2877 |
2875 // FIXME: this is a potential performance issue. We should consider caching | 2878 // FIXME: this is a potential performance issue. We should consider caching |
2876 // these clip rects or otherwise optimizing. | 2879 // these clip rects or otherwise optimizing. |
2877 ClipRectsContext clipRectsContext(ancestorPaintInfo->paintLayer, | 2880 ClipRectsContext clipRectsContext(ancestorPaintInfo->paintLayer, |
2878 UncachedClipRects); | 2881 UncachedClipRects); |
2879 IntRect parentClipRect = pixelSnappedIntRect( | 2882 ClipRect parentClipRect; |
2880 paintInfo.paintLayer->clipper(PaintLayer::DoNotUseGeometryMapper) | 2883 paintInfo.paintLayer->clipper(PaintLayer::DoNotUseGeometryMapper) |
2881 .backgroundClipRect(clipRectsContext) | 2884 .calculateBackgroundClipRect(clipRectsContext, parentClipRect); |
2882 .rect()); | 2885 |
2883 ASSERT(parentClipRect != LayoutRect::infiniteIntRect()); | 2886 IntRect snappedParentClipRect(pixelSnappedIntRect(parentClipRect.rect())); |
| 2887 DCHECK(snappedParentClipRect != LayoutRect::infiniteIntRect()); |
2884 | 2888 |
2885 // Convert from ancestor to local coordinates. | 2889 // Convert from ancestor to local coordinates. |
2886 IntSize ancestorToLocalOffset = paintInfo.offsetFromLayoutObject - | 2890 IntSize ancestorToLocalOffset = paintInfo.offsetFromLayoutObject - |
2887 ancestorPaintInfo->offsetFromLayoutObject; | 2891 ancestorPaintInfo->offsetFromLayoutObject; |
2888 parentClipRect.move(ancestorToLocalOffset); | 2892 snappedParentClipRect.move(ancestorToLocalOffset); |
2889 return parentClipRect; | 2893 return snappedParentClipRect; |
2890 } | 2894 } |
2891 | 2895 |
2892 void CompositedLayerMapping::doPaintTask( | 2896 void CompositedLayerMapping::doPaintTask( |
2893 const GraphicsLayerPaintInfo& paintInfo, | 2897 const GraphicsLayerPaintInfo& paintInfo, |
2894 const GraphicsLayer& graphicsLayer, | 2898 const GraphicsLayer& graphicsLayer, |
2895 const PaintLayerFlags& paintLayerFlags, | 2899 const PaintLayerFlags& paintLayerFlags, |
2896 GraphicsContext& context, | 2900 GraphicsContext& context, |
2897 const IntRect& clip /* In the coords of rootLayer */) const { | 2901 const IntRect& clip /* In the coords of rootLayer */) const { |
2898 FontCachePurgePreventer fontCachePurgePreventer; | 2902 FontCachePurgePreventer fontCachePurgePreventer; |
2899 | 2903 |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3488 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { | 3492 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { |
3489 name = "Decoration Layer"; | 3493 name = "Decoration Layer"; |
3490 } else { | 3494 } else { |
3491 ASSERT_NOT_REACHED(); | 3495 ASSERT_NOT_REACHED(); |
3492 } | 3496 } |
3493 | 3497 |
3494 return name; | 3498 return name; |
3495 } | 3499 } |
3496 | 3500 |
3497 } // namespace blink | 3501 } // namespace blink |
OLD | NEW |