| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 return; | 907 return; |
| 908 | 908 |
| 909 // If the clip rect has been tainted by a border radius, then we have to wal
k up our layer chain applying the clips from | 909 // If the clip rect has been tainted by a border radius, then we have to wal
k up our layer chain applying the clips from |
| 910 // any layers with overflow. The condition for being able to apply these cli
ps is that the overflow object be in our | 910 // any layers with overflow. The condition for being able to apply these cli
ps is that the overflow object be in our |
| 911 // containing block chain so we check that also. | 911 // containing block chain so we check that also. |
| 912 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? this : parent
(); layer; layer = layer->parent()) { | 912 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? this : parent
(); layer; layer = layer->parent()) { |
| 913 // Composited scrolling layers handle border-radius clip in the composit
or via a mask layer. We do not | 913 // Composited scrolling layers handle border-radius clip in the composit
or via a mask layer. We do not |
| 914 // want to apply a border-radius clip to the layer contents itself, beca
use that would require re-rastering | 914 // want to apply a border-radius clip to the layer contents itself, beca
use that would require re-rastering |
| 915 // every frame to update the clip. We only want to make sure that the ma
sk layer is properly clipped so | 915 // every frame to update the clip. We only want to make sure that the ma
sk layer is properly clipped so |
| 916 // that it can in turn clip the scrolled contents in the compositor. | 916 // that it can in turn clip the scrolled contents in the compositor. |
| 917 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti
ngChildClippingMaskPhase)) | 917 if (layer->needsCompositedScrolling()) |
| 918 break; | 918 break; |
| 919 | 919 |
| 920 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->
hasBorderRadius() && inContainingBlockChain(this, layer)) { | 920 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->
hasBorderRadius() && inContainingBlockChain(this, layer)) { |
| 921 LayoutPoint delta; | 921 LayoutPoint delta; |
| 922 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); | 922 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); |
| 923 context->clipRoundedRect(layer->renderer()->style()->getRoundedI
nnerBorderFor(LayoutRect(delta, layer->size()))); | 923 context->clipRoundedRect(layer->renderer()->style()->getRoundedI
nnerBorderFor(LayoutRect(delta, layer->size()))); |
| 924 } | 924 } |
| 925 | 925 |
| 926 if (layer == localPaintingInfo.rootLayer) | 926 if (layer == localPaintingInfo.rootLayer) |
| 927 break; | 927 break; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 941 // It's ok not to draw, because later on, when all the stylesheets do load,
updateStyleSelector on the Document | 941 // It's ok not to draw, because later on, when all the stylesheets do load,
updateStyleSelector on the Document |
| 942 // will do a full paintInvalidationForWholeRenderer(). | 942 // will do a full paintInvalidationForWholeRenderer(). |
| 943 if (layer->renderer()->document().didLayoutWithPendingStylesheets() && !laye
r->isRootLayer() && !layer->renderer()->isDocumentElement()) | 943 if (layer->renderer()->document().didLayoutWithPendingStylesheets() && !laye
r->isRootLayer() && !layer->renderer()->isDocumentElement()) |
| 944 return true; | 944 return true; |
| 945 | 945 |
| 946 return false; | 946 return false; |
| 947 } | 947 } |
| 948 | 948 |
| 949 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint
Flags, const RenderObject* renderer) | 949 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint
Flags, const RenderObject* renderer) |
| 950 { | 950 { |
| 951 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai
ntLayerPaintingChildClippingMaskPhase && renderer->hasClipPath())) ? IgnoreOverf
lowClip : RespectOverflowClip; | 951 return (paintFlags & PaintLayerPaintingOverflowContents) ? IgnoreOverflowCli
p : RespectOverflowClip; |
| 952 } | 952 } |
| 953 | 953 |
| 954 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
paintingInfo, PaintLayerFlags paintFlags) | 954 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo&
paintingInfo, PaintLayerFlags paintFlags) |
| 955 { | 955 { |
| 956 // Non self-painting leaf layers don't need to be painted as their renderer(
) should properly paint itself. | 956 // Non self-painting leaf layers don't need to be painted as their renderer(
) should properly paint itself. |
| 957 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) | 957 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) |
| 958 return; | 958 return; |
| 959 | 959 |
| 960 if (shouldSuppressPaintingLayer(this)) | 960 if (shouldSuppressPaintingLayer(this)) |
| 961 return; | 961 return; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 LayoutRect rootRelativeBounds; | 1055 LayoutRect rootRelativeBounds; |
| 1056 bool rootRelativeBoundsComputed = false; | 1056 bool rootRelativeBoundsComputed = false; |
| 1057 | 1057 |
| 1058 // Apply clip-path to context. | 1058 // Apply clip-path to context. |
| 1059 GraphicsContextStateSaver clipStateSaver(*context, false); | 1059 GraphicsContextStateSaver clipStateSaver(*context, false); |
| 1060 RenderStyle* style = renderer()->style(); | 1060 RenderStyle* style = renderer()->style(); |
| 1061 | 1061 |
| 1062 // Clip-path, like border radius, must not be applied to the contents of a c
omposited-scrolling container. | 1062 // Clip-path, like border radius, must not be applied to the contents of a c
omposited-scrolling container. |
| 1063 // It must, however, still be applied to the mask layer, so that the composi
tor can properly mask the | 1063 // It must, however, still be applied to the mask layer, so that the composi
tor can properly mask the |
| 1064 // scrolling contents and scrollbars. | 1064 // scrolling contents and scrollbars. |
| 1065 if (renderer()->hasClipPath() && style && (!needsCompositedScrolling() || pa
intFlags & PaintLayerPaintingChildClippingMaskPhase)) { | 1065 if (renderer()->hasClipPath() && style && !needsCompositedScrolling()) { |
| 1066 ASSERT(style->clipPath()); | 1066 ASSERT(style->clipPath()); |
| 1067 if (style->clipPath()->type() == ClipPathOperation::SHAPE) { | 1067 if (style->clipPath()->type() == ClipPathOperation::SHAPE) { |
| 1068 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style->c
lipPath()); | 1068 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style->c
lipPath()); |
| 1069 if (clipPath->isValid()) { | 1069 if (clipPath->isValid()) { |
| 1070 clipStateSaver.save(); | 1070 clipStateSaver.save(); |
| 1071 | 1071 |
| 1072 if (!rootRelativeBoundsComputed) { | 1072 if (!rootRelativeBoundsComputed) { |
| 1073 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA
ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 1073 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA
ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 1074 rootRelativeBoundsComputed = true; | 1074 rootRelativeBoundsComputed = true; |
| 1075 } | 1075 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 paintingRootForRenderer = localPaintingInfo.paintingRoot; | 1149 paintingRootForRenderer = localPaintingInfo.paintingRoot; |
| 1150 | 1150 |
| 1151 ASSERT(!(localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText)); | 1151 ASSERT(!(localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText)); |
| 1152 | 1152 |
| 1153 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPaintCo
ntent; | 1153 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPaintCo
ntent; |
| 1154 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintingOve
rflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackground
); | 1154 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintingOve
rflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackground
); |
| 1155 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPaintC
ontent; | 1155 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPaintC
ontent; |
| 1156 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForeground
; | 1156 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForeground
; |
| 1157 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; | 1157 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; |
| 1158 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase)
&& shouldPaintContent && renderer()->hasMask(); | 1158 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase)
&& shouldPaintContent && renderer()->hasMask(); |
| 1159 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping
MaskPhase) && shouldPaintContent; | |
| 1160 | 1159 |
| 1161 // FIXME(sky): Get rid of PaintBehavior argument now that it's always Normal
. | 1160 // FIXME(sky): Get rid of PaintBehavior argument now that it's always Normal
. |
| 1162 PaintBehavior paintBehavior = PaintBehaviorNormal; | 1161 PaintBehavior paintBehavior = PaintBehaviorNormal; |
| 1163 | 1162 |
| 1164 if (shouldPaintBackground) { | 1163 if (shouldPaintBackground) { |
| 1165 paintBackgroundForFragments(layerFragments, context, transparencyLayerCo
ntext, paintingInfo.paintDirtyRect, haveTransparency, | 1164 paintBackgroundForFragments(layerFragments, context, transparencyLayerCo
ntext, paintingInfo.paintDirtyRect, haveTransparency, |
| 1166 localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag
s); | 1165 localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag
s); |
| 1167 } | 1166 } |
| 1168 | 1167 |
| 1169 if (shouldPaintNegZOrderList) | 1168 if (shouldPaintNegZOrderList) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1193 context = filterPainter.applyFilterEffect(); | 1192 context = filterPainter.applyFilterEffect(); |
| 1194 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); | 1193 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); |
| 1195 } | 1194 } |
| 1196 | 1195 |
| 1197 // Make sure that we now use the original transparency context. | 1196 // Make sure that we now use the original transparency context. |
| 1198 ASSERT(transparencyLayerContext == context); | 1197 ASSERT(transparencyLayerContext == context); |
| 1199 | 1198 |
| 1200 if (shouldPaintMask) | 1199 if (shouldPaintMask) |
| 1201 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForRenderer, paintFlags); | 1200 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForRenderer, paintFlags); |
| 1202 | 1201 |
| 1203 if (shouldPaintClippingMask) { | |
| 1204 // Paint the border radius mask for the fragments. | |
| 1205 paintChildClippingMaskForFragments(layerFragments, context, localPaintin
gInfo, paintingRootForRenderer, paintFlags); | |
| 1206 } | |
| 1207 | |
| 1208 // End our transparency layer | 1202 // End our transparency layer |
| 1209 if (haveTransparency && m_usedTransparency) { | 1203 if (haveTransparency && m_usedTransparency) { |
| 1210 context->endLayer(); | 1204 context->endLayer(); |
| 1211 context->restore(); | 1205 context->restore(); |
| 1212 m_usedTransparency = false; | 1206 m_usedTransparency = false; |
| 1213 } | 1207 } |
| 1214 } | 1208 } |
| 1215 | 1209 |
| 1216 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint&
translationOffset) | 1210 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint&
translationOffset) |
| 1217 { | 1211 { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 // Paint the mask. | 1385 // Paint the mask. |
| 1392 // FIXME: Eventually we will collect the region from the fragment itself
instead of just from the paint info. | 1386 // FIXME: Eventually we will collect the region from the fragment itself
instead of just from the paint info. |
| 1393 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect
.rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local
PaintingInfo.rootLayer->renderer()); | 1387 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect
.rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local
PaintingInfo.rootLayer->renderer()); |
| 1394 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r
enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); | 1388 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r
enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); |
| 1395 | 1389 |
| 1396 if (localPaintingInfo.clipToDirtyRect) | 1390 if (localPaintingInfo.clipToDirtyRect) |
| 1397 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back
groundRect); | 1391 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back
groundRect); |
| 1398 } | 1392 } |
| 1399 } | 1393 } |
| 1400 | 1394 |
| 1401 void RenderLayer::paintChildClippingMaskForFragments(const LayerFragments& layer
Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, | |
| 1402 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) | |
| 1403 { | |
| 1404 for (size_t i = 0; i < layerFragments.size(); ++i) { | |
| 1405 const LayerFragment& fragment = layerFragments.at(i); | |
| 1406 if (!fragment.shouldPaintContent) | |
| 1407 continue; | |
| 1408 | |
| 1409 if (localPaintingInfo.clipToDirtyRect) | |
| 1410 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain
tFlags, IncludeSelfForBorderRadius); // Child clipping mask painting will handle
clipping to self. | |
| 1411 | |
| 1412 // Paint the the clipped mask. | |
| 1413 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect
.rect()), PaintPhaseClippingMask, PaintBehaviorNormal, paintingRootForRenderer,
0, localPaintingInfo.rootLayer->renderer()); | |
| 1414 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r
enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); | |
| 1415 | |
| 1416 if (localPaintingInfo.clipToDirtyRect) | |
| 1417 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore
groundRect); | |
| 1418 } | |
| 1419 } | |
| 1420 | |
| 1421 void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF
ragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
PaintLayerFlags paintFlags) | 1395 void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF
ragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
PaintLayerFlags paintFlags) |
| 1422 { | 1396 { |
| 1423 for (size_t i = 0; i < layerFragments.size(); ++i) { | 1397 for (size_t i = 0; i < layerFragments.size(); ++i) { |
| 1424 const LayerFragment& fragment = layerFragments.at(i); | 1398 const LayerFragment& fragment = layerFragments.at(i); |
| 1425 clipToRect(localPaintingInfo, context, fragment.backgroundRect, paintFla
gs); | 1399 clipToRect(localPaintingInfo, context, fragment.backgroundRect, paintFla
gs); |
| 1426 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea()) | 1400 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea()) |
| 1427 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi
nt(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.sub
PixelAccumulation)), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); | 1401 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi
nt(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.sub
PixelAccumulation)), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); |
| 1428 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou
ndRect); | 1402 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou
ndRect); |
| 1429 } | 1403 } |
| 1430 } | 1404 } |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 } | 2205 } |
| 2232 } | 2206 } |
| 2233 | 2207 |
| 2234 void showLayerTree(const blink::RenderObject* renderer) | 2208 void showLayerTree(const blink::RenderObject* renderer) |
| 2235 { | 2209 { |
| 2236 if (!renderer) | 2210 if (!renderer) |
| 2237 return; | 2211 return; |
| 2238 showLayerTree(renderer->enclosingLayer()); | 2212 showLayerTree(renderer->enclosingLayer()); |
| 2239 } | 2213 } |
| 2240 #endif | 2214 #endif |
| OLD | NEW |