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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 , m_first(0) | 132 , m_first(0) |
133 , m_last(0) | 133 , m_last(0) |
134 , m_staticInlinePosition(0) | 134 , m_staticInlinePosition(0) |
135 , m_staticBlockPosition(0) | 135 , m_staticBlockPosition(0) |
136 , m_enclosingPaginationLayer(0) | 136 , m_enclosingPaginationLayer(0) |
137 , m_potentialCompositingReasonsFromStyle(CompositingReasonNone) | 137 , m_potentialCompositingReasonsFromStyle(CompositingReasonNone) |
138 , m_compositingReasons(CompositingReasonNone) | 138 , m_compositingReasons(CompositingReasonNone) |
139 , m_groupedMapping(0) | 139 , m_groupedMapping(0) |
140 , m_repainter(*renderer) | 140 , m_repainter(*renderer) |
141 , m_clipper(*renderer) | 141 , m_clipper(*renderer) |
142 , m_blendInfo(*renderer) | |
143 { | 142 { |
144 updateStackingNode(); | 143 updateStackingNode(); |
145 | 144 |
146 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); | 145 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); |
147 | 146 |
148 if (!renderer->slowFirstChild() && renderer->style()) { | 147 if (!renderer->slowFirstChild() && renderer->style()) { |
149 m_visibleContentStatusDirty = false; | 148 m_visibleContentStatusDirty = false; |
150 m_hasVisibleContent = renderer->style()->visibility() == VISIBLE; | 149 m_hasVisibleContent = renderer->style()->visibility() == VISIBLE; |
151 } | 150 } |
152 | 151 |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 | 662 |
664 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant) { | 663 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant) { |
665 m_hasVisibleDescendant = true; | 664 m_hasVisibleDescendant = true; |
666 break; | 665 break; |
667 } | 666 } |
668 } | 667 } |
669 | 668 |
670 m_visibleDescendantStatusDirty = false; | 669 m_visibleDescendantStatusDirty = false; |
671 } | 670 } |
672 | 671 |
673 if (m_blendInfo.childLayerHasBlendModeStatusDirty()) { | |
674 m_blendInfo.setChildLayerHasBlendMode(false); | |
675 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin
g()) { | |
676 if (!child->stackingNode()->isStackingContext()) | |
677 child->updateDescendantDependentFlags(); | |
678 | |
679 bool childLayerHadBlendMode = child->blendInfo().childLayerHasBlendM
odeWhileDirty(); | |
680 bool childLayerHasBlendMode = childLayerHadBlendMode || child->blend
Info().hasBlendMode(); | |
681 | |
682 m_blendInfo.setChildLayerHasBlendMode(childLayerHasBlendMode); | |
683 | |
684 if (childLayerHasBlendMode) | |
685 break; | |
686 } | |
687 m_blendInfo.setChildLayerHasBlendModeStatusDirty(false); | |
688 } | |
689 | |
690 if (m_visibleContentStatusDirty) { | 672 if (m_visibleContentStatusDirty) { |
691 bool previouslyHasVisibleContent = m_hasVisibleContent; | 673 bool previouslyHasVisibleContent = m_hasVisibleContent; |
692 if (renderer()->style()->visibility() == VISIBLE) | 674 if (renderer()->style()->visibility() == VISIBLE) |
693 m_hasVisibleContent = true; | 675 m_hasVisibleContent = true; |
694 else { | 676 else { |
695 // layer may be hidden but still have some visible content, check fo
r this | 677 // layer may be hidden but still have some visible content, check fo
r this |
696 m_hasVisibleContent = false; | 678 m_hasVisibleContent = false; |
697 RenderObject* r = renderer()->slowFirstChild(); | 679 RenderObject* r = renderer()->slowFirstChild(); |
698 while (r) { | 680 while (r) { |
699 if (r->style()->visibility() == VISIBLE && !r->hasLayer()) { | 681 if (r->style()->visibility() == VISIBLE && !r->hasLayer()) { |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 return clipRect; | 1167 return clipRect; |
1186 } | 1168 } |
1187 | 1169 |
1188 LayoutRect RenderLayer::paintingExtent(const RenderLayer* rootLayer, const Layou
tRect& paintDirtyRect, const LayoutSize& subPixelAccumulation, PaintBehavior pai
ntBehavior) | 1170 LayoutRect RenderLayer::paintingExtent(const RenderLayer* rootLayer, const Layou
tRect& paintDirtyRect, const LayoutSize& subPixelAccumulation, PaintBehavior pai
ntBehavior) |
1189 { | 1171 { |
1190 return intersection(transparencyClipBox(this, rootLayer, PaintingTransparenc
yClipBox, RootOfTransparencyClipBox, subPixelAccumulation, paintBehavior), paint
DirtyRect); | 1172 return intersection(transparencyClipBox(this, rootLayer, PaintingTransparenc
yClipBox, RootOfTransparencyClipBox, subPixelAccumulation, paintBehavior), paint
DirtyRect); |
1191 } | 1173 } |
1192 | 1174 |
1193 void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const Render
Layer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAc
cumulation, PaintBehavior paintBehavior) | 1175 void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const Render
Layer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAc
cumulation, PaintBehavior paintBehavior) |
1194 { | 1176 { |
1195 bool createTransparencyLayerForBlendMode = m_stackingNode->isStackingContext
() && m_blendInfo.childLayerHasBlendMode(); | 1177 bool createTransparencyLayerForBlendMode = m_stackingNode->isStackingContext
() && hasDescendantWithBlendMode(); |
1196 if ((paintsWithTransparency(paintBehavior) || paintsWithBlendMode() || creat
eTransparencyLayerForBlendMode) && m_usedTransparency) | 1178 if ((paintsWithTransparency(paintBehavior) || paintsWithBlendMode() || creat
eTransparencyLayerForBlendMode) && m_usedTransparency) |
1197 return; | 1179 return; |
1198 | 1180 |
1199 RenderLayer* ancestor = transparentPaintingAncestor(); | 1181 RenderLayer* ancestor = transparentPaintingAncestor(); |
1200 if (ancestor) | 1182 if (ancestor) |
1201 ancestor->beginTransparencyLayers(context, rootLayer, paintDirtyRect, su
bPixelAccumulation, paintBehavior); | 1183 ancestor->beginTransparencyLayers(context, rootLayer, paintDirtyRect, su
bPixelAccumulation, paintBehavior); |
1202 | 1184 |
1203 if (paintsWithTransparency(paintBehavior) || paintsWithBlendMode() || create
TransparencyLayerForBlendMode) { | 1185 if (paintsWithTransparency(paintBehavior) || paintsWithBlendMode() || create
TransparencyLayerForBlendMode) { |
1204 m_usedTransparency = true; | 1186 m_usedTransparency = true; |
1205 context->save(); | 1187 context->save(); |
1206 LayoutRect clipRect = paintingExtent(rootLayer, paintDirtyRect, subPixel
Accumulation, paintBehavior); | 1188 LayoutRect clipRect = paintingExtent(rootLayer, paintDirtyRect, subPixel
Accumulation, paintBehavior); |
1207 context->clip(clipRect); | 1189 context->clip(clipRect); |
1208 | 1190 |
1209 if (paintsWithBlendMode()) | 1191 if (paintsWithBlendMode()) |
1210 context->setCompositeOperation(context->compositeOperation(), m_blen
dInfo.blendMode()); | 1192 context->setCompositeOperation(context->compositeOperation(), m_rend
erer->style()->blendMode()); |
1211 | 1193 |
1212 context->beginTransparencyLayer(renderer()->opacity()); | 1194 context->beginTransparencyLayer(renderer()->opacity()); |
1213 | 1195 |
1214 if (paintsWithBlendMode()) | 1196 if (paintsWithBlendMode()) |
1215 context->setCompositeOperation(context->compositeOperation(), blink:
:WebBlendModeNormal); | 1197 context->setCompositeOperation(context->compositeOperation(), blink:
:WebBlendModeNormal); |
1216 #ifdef REVEAL_TRANSPARENCY_LAYERS | 1198 #ifdef REVEAL_TRANSPARENCY_LAYERS |
1217 context->setFillColor(Color(0.0f, 0.0f, 0.5f, 0.2f)); | 1199 context->setFillColor(Color(0.0f, 0.0f, 0.5f, 0.2f)); |
1218 context->fillRect(clipRect); | 1200 context->fillRect(clipRect); |
1219 #endif | 1201 #endif |
1220 } | 1202 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 // Dirty the z-order list in which we are contained. The ancestorStackin
gContextNode() can be null in the | 1240 // Dirty the z-order list in which we are contained. The ancestorStackin
gContextNode() can be null in the |
1259 // case where we're building up generated content layers. This is ok, si
nce the lists will start | 1241 // case where we're building up generated content layers. This is ok, si
nce the lists will start |
1260 // off dirty in that case anyway. | 1242 // off dirty in that case anyway. |
1261 child->stackingNode()->dirtyStackingContextZOrderLists(); | 1243 child->stackingNode()->dirtyStackingContextZOrderLists(); |
1262 } | 1244 } |
1263 | 1245 |
1264 dirtyAncestorChainVisibleDescendantStatus(); | 1246 dirtyAncestorChainVisibleDescendantStatus(); |
1265 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | 1247 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); |
1266 | 1248 |
1267 child->updateDescendantDependentFlags(); | 1249 child->updateDescendantDependentFlags(); |
1268 | |
1269 if (child->blendInfo().hasBlendMode() || child->blendInfo().childLayerHasBle
ndMode()) | |
1270 m_blendInfo.setAncestorChainBlendedDescendant(); | |
1271 } | 1250 } |
1272 | 1251 |
1273 RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) | 1252 RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) |
1274 { | 1253 { |
1275 if (oldChild->previousSibling()) | 1254 if (oldChild->previousSibling()) |
1276 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling()); | 1255 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling()); |
1277 if (oldChild->nextSibling()) | 1256 if (oldChild->nextSibling()) |
1278 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling())
; | 1257 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling())
; |
1279 | 1258 |
1280 if (m_first == oldChild) | 1259 if (m_first == oldChild) |
(...skipping 18 matching lines...) Expand all Loading... |
1299 oldChild->setNextSibling(0); | 1278 oldChild->setNextSibling(0); |
1300 oldChild->m_parent = 0; | 1279 oldChild->m_parent = 0; |
1301 | 1280 |
1302 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | 1281 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); |
1303 | 1282 |
1304 oldChild->updateDescendantDependentFlags(); | 1283 oldChild->updateDescendantDependentFlags(); |
1305 | 1284 |
1306 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) | 1285 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) |
1307 dirtyAncestorChainVisibleDescendantStatus(); | 1286 dirtyAncestorChainVisibleDescendantStatus(); |
1308 | 1287 |
1309 if (oldChild->m_blendInfo.hasBlendMode() || oldChild->blendInfo().childLayer
HasBlendMode()) | |
1310 m_blendInfo.dirtyAncestorChainBlendedDescendantStatus(); | |
1311 | |
1312 return oldChild; | 1288 return oldChild; |
1313 } | 1289 } |
1314 | 1290 |
1315 void RenderLayer::removeOnlyThisLayer() | 1291 void RenderLayer::removeOnlyThisLayer() |
1316 { | 1292 { |
1317 if (!m_parent) | 1293 if (!m_parent) |
1318 return; | 1294 return; |
1319 | 1295 |
1320 m_clipper.clearClipRectsIncludingDescendants(); | 1296 m_clipper.clearClipRectsIncludingDescendants(); |
1321 repainter().repaintIncludingNonCompositingDescendants(); | 1297 repainter().repaintIncludingNonCompositingDescendants(); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 paintingInfo.paintDirtyRect, context, clipperContext)) { | 1771 paintingInfo.paintDirtyRect, context, clipperContext)) { |
1796 // No need to post-apply the clipper if this failed. | 1772 // No need to post-apply the clipper if this failed. |
1797 resourceClipper = 0; | 1773 resourceClipper = 0; |
1798 } | 1774 } |
1799 } | 1775 } |
1800 } | 1776 } |
1801 } | 1777 } |
1802 | 1778 |
1803 // Blending operations must be performed only with the nearest ancestor stac
king context. | 1779 // Blending operations must be performed only with the nearest ancestor stac
king context. |
1804 // Note that there is no need to create a transparency layer if we're painti
ng the root. | 1780 // Note that there is no need to create a transparency layer if we're painti
ng the root. |
1805 bool createTransparencyLayerForBlendMode = !renderer()->isDocumentElement()
&& m_stackingNode->isStackingContext() && m_blendInfo.childLayerHasBlendMode(); | 1781 bool createTransparencyLayerForBlendMode = !renderer()->isDocumentElement()
&& m_stackingNode->isStackingContext() && hasDescendantWithBlendMode(); |
1806 | 1782 |
1807 if (createTransparencyLayerForBlendMode) | 1783 if (createTransparencyLayerForBlendMode) |
1808 beginTransparencyLayers(context, paintingInfo.rootLayer, paintingInfo.pa
intDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); | 1784 beginTransparencyLayers(context, paintingInfo.rootLayer, paintingInfo.pa
intDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); |
1809 | 1785 |
1810 LayerPaintingInfo localPaintingInfo(paintingInfo); | 1786 LayerPaintingInfo localPaintingInfo(paintingInfo); |
1811 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte
rs()); | 1787 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte
rs()); |
1812 if (filterPainter.haveFilterEffect()) { | 1788 if (filterPainter.haveFilterEffect()) { |
1813 ASSERT(this->filterInfo()); | 1789 ASSERT(this->filterInfo()); |
1814 | 1790 |
1815 if (!rootRelativeBoundsComputed) | 1791 if (!rootRelativeBoundsComputed) |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 } | 3230 } |
3255 } | 3231 } |
3256 | 3232 |
3257 CompositedLayerMapping* RenderLayer::ensureCompositedLayerMapping() | 3233 CompositedLayerMapping* RenderLayer::ensureCompositedLayerMapping() |
3258 { | 3234 { |
3259 if (!m_compositedLayerMapping) { | 3235 if (!m_compositedLayerMapping) { |
3260 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(*this)); | 3236 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(*this)); |
3261 m_compositedLayerMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdat
eSubtree); | 3237 m_compositedLayerMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdat
eSubtree); |
3262 | 3238 |
3263 updateOrRemoveFilterEffectRenderer(); | 3239 updateOrRemoveFilterEffectRenderer(); |
3264 | |
3265 if (RuntimeEnabledFeatures::cssCompositingEnabled()) | |
3266 compositedLayerMapping()->setBlendMode(m_blendInfo.blendMode()); | |
3267 } | 3240 } |
3268 return m_compositedLayerMapping.get(); | 3241 return m_compositedLayerMapping.get(); |
3269 } | 3242 } |
3270 | 3243 |
3271 void RenderLayer::clearCompositedLayerMapping(bool layerBeingDestroyed) | 3244 void RenderLayer::clearCompositedLayerMapping(bool layerBeingDestroyed) |
3272 { | 3245 { |
3273 if (!layerBeingDestroyed) { | 3246 if (!layerBeingDestroyed) { |
3274 // We need to make sure our decendants get a geometry update. In princip
le, | 3247 // We need to make sure our decendants get a geometry update. In princip
le, |
3275 // we could call setNeedsGraphicsLayerUpdate on our children, but that w
ould | 3248 // we could call setNeedsGraphicsLayerUpdate on our children, but that w
ould |
3276 // require walking the z-order lists to find them. Instead, we over-inva
lidate | 3249 // require walking the z-order lists to find them. Instead, we over-inva
lidate |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3318 return compositor()->clipsCompositingDescendants(this) && style->hasBorderRa
dius(); | 3291 return compositor()->clipsCompositingDescendants(this) && style->hasBorderRa
dius(); |
3319 } | 3292 } |
3320 | 3293 |
3321 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const | 3294 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const |
3322 { | 3295 { |
3323 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer
s) || compositingState() != PaintsIntoOwnBacking); | 3296 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer
s) || compositingState() != PaintsIntoOwnBacking); |
3324 } | 3297 } |
3325 | 3298 |
3326 bool RenderLayer::paintsWithBlendMode() const | 3299 bool RenderLayer::paintsWithBlendMode() const |
3327 { | 3300 { |
3328 return m_blendInfo.hasBlendMode() && compositingState() != PaintsIntoOwnBack
ing; | 3301 return m_renderer->hasBlendMode() && compositingState() != PaintsIntoOwnBack
ing; |
3329 } | 3302 } |
3330 | 3303 |
3331 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect)
const | 3304 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect)
const |
3332 { | 3305 { |
3333 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) | 3306 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) |
3334 return false; | 3307 return false; |
3335 | 3308 |
3336 if (paintsWithTransparency(PaintBehaviorNormal)) | 3309 if (paintsWithTransparency(PaintBehaviorNormal)) |
3337 return false; | 3310 return false; |
3338 | 3311 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3539 | 3512 |
3540 // Overlay scrollbars can make this layer self-painting so we need | 3513 // Overlay scrollbars can make this layer self-painting so we need |
3541 // to recompute the bit once scrollbars have been updated. | 3514 // to recompute the bit once scrollbars have been updated. |
3542 updateSelfPaintingLayer(); | 3515 updateSelfPaintingLayer(); |
3543 | 3516 |
3544 if (!oldStyle || !renderer()->style()->reflectionDataEquivalent(oldStyle)) { | 3517 if (!oldStyle || !renderer()->style()->reflectionDataEquivalent(oldStyle)) { |
3545 ASSERT(!oldStyle || diff.needsFullLayout()); | 3518 ASSERT(!oldStyle || diff.needsFullLayout()); |
3546 updateReflectionInfo(oldStyle); | 3519 updateReflectionInfo(oldStyle); |
3547 } | 3520 } |
3548 | 3521 |
3549 if (RuntimeEnabledFeatures::cssCompositingEnabled()) | |
3550 m_blendInfo.updateBlendMode(); | |
3551 | |
3552 updateDescendantDependentFlags(); | 3522 updateDescendantDependentFlags(); |
3553 | 3523 |
3554 updateTransform(oldStyle, renderer()->style()); | 3524 updateTransform(oldStyle, renderer()->style()); |
3555 updateFilters(oldStyle, renderer()->style()); | 3525 updateFilters(oldStyle, renderer()->style()); |
3556 | 3526 |
3557 setNeedsCompositingInputsUpdate(); | 3527 setNeedsCompositingInputsUpdate(); |
3558 } | 3528 } |
3559 | 3529 |
3560 bool RenderLayer::scrollsOverflow() const | 3530 bool RenderLayer::scrollsOverflow() const |
3561 { | 3531 { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3716 } | 3686 } |
3717 } | 3687 } |
3718 | 3688 |
3719 void showLayerTree(const blink::RenderObject* renderer) | 3689 void showLayerTree(const blink::RenderObject* renderer) |
3720 { | 3690 { |
3721 if (!renderer) | 3691 if (!renderer) |
3722 return; | 3692 return; |
3723 showLayerTree(renderer->enclosingLayer()); | 3693 showLayerTree(renderer->enclosingLayer()); |
3724 } | 3694 } |
3725 #endif | 3695 #endif |
OLD | NEW |