| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
| 10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 String debugName() const; | 76 String debugName() const; |
| 77 | 77 |
| 78 RenderLayerModelObject* renderer() const { return m_renderer; } | 78 RenderLayerModelObject* renderer() const { return m_renderer; } |
| 79 RenderBox* renderBox() const { return m_renderer && m_renderer->isBox() ? to
RenderBox(m_renderer) : 0; } | 79 RenderBox* renderBox() const { return m_renderer && m_renderer->isBox() ? to
RenderBox(m_renderer) : 0; } |
| 80 RenderLayer* parent() const { return m_parent; } | 80 RenderLayer* parent() const { return m_parent; } |
| 81 RenderLayer* previousSibling() const { return m_previous; } | 81 RenderLayer* previousSibling() const { return m_previous; } |
| 82 RenderLayer* nextSibling() const { return m_next; } | 82 RenderLayer* nextSibling() const { return m_next; } |
| 83 RenderLayer* firstChild() const { return m_first; } | 83 RenderLayer* firstChild() const { return m_first; } |
| 84 RenderLayer* lastChild() const { return m_last; } | 84 RenderLayer* lastChild() const { return m_last; } |
| 85 | 85 |
| 86 const RenderLayer* compositingContainer() const; | |
| 87 | |
| 88 void addChild(RenderLayer* newChild, RenderLayer* beforeChild = 0); | 86 void addChild(RenderLayer* newChild, RenderLayer* beforeChild = 0); |
| 89 RenderLayer* removeChild(RenderLayer*); | 87 RenderLayer* removeChild(RenderLayer*); |
| 90 | 88 |
| 91 void removeOnlyThisLayer(); | 89 void removeOnlyThisLayer(); |
| 92 void insertOnlyThisLayer(); | 90 void insertOnlyThisLayer(); |
| 93 | 91 |
| 94 void styleChanged(StyleDifference, const RenderStyle* oldStyle); | 92 void styleChanged(StyleDifference, const RenderStyle* oldStyle); |
| 95 | 93 |
| 96 // FIXME: Many people call this function while it has out-of-date informatio
n. | 94 // FIXME: Many people call this function while it has out-of-date informatio
n. |
| 97 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } | 95 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 bool hasNonEmptyChildRenderers() const; | 134 bool hasNonEmptyChildRenderers() const; |
| 137 | 135 |
| 138 bool usedTransparency() const { return m_usedTransparency; } | 136 bool usedTransparency() const { return m_usedTransparency; } |
| 139 | 137 |
| 140 // Gets the nearest enclosing positioned ancestor layer (also includes | 138 // Gets the nearest enclosing positioned ancestor layer (also includes |
| 141 // the <html> layer and the root layer). | 139 // the <html> layer and the root layer). |
| 142 RenderLayer* enclosingPositionedAncestor() const; | 140 RenderLayer* enclosingPositionedAncestor() const; |
| 143 | 141 |
| 144 RenderLayer* enclosingOverflowClipLayer(IncludeSelfOrNot = IncludeSelf) cons
t; | 142 RenderLayer* enclosingOverflowClipLayer(IncludeSelfOrNot = IncludeSelf) cons
t; |
| 145 | 143 |
| 144 const RenderLayer* compositingContainer() const; |
| 146 RenderLayer* enclosingFilterLayer(IncludeSelfOrNot = IncludeSelf) const; | 145 RenderLayer* enclosingFilterLayer(IncludeSelfOrNot = IncludeSelf) const; |
| 147 bool hasAncestorWithFilterOutsets() const; | 146 bool hasAncestorWithFilterOutsets() const; |
| 148 | 147 |
| 149 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&) co
nst; | 148 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&) co
nst; |
| 150 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&) con
st; | 149 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&) con
st; |
| 151 | 150 |
| 152 // The two main functions that use the layer system. The paint method | 151 // The two main functions that use the layer system. The paint method |
| 153 // paints the layers that intersect the damage rect from back to | 152 // paints the layers that intersect the damage rect from back to |
| 154 // front. The hitTest method looks for mouse events by walking | 153 // front. The hitTest method looks for mouse events by walking |
| 155 // layers that intersect the point from front to back. | 154 // layers that intersect the point from front to back. |
| 156 // paint() assumes that the caller will clip to the bounds of damageRect if
necessary. | 155 // paint() assumes that the caller will clip to the bounds of damageRect if
necessary. |
| 157 void paint(GraphicsContext*, const LayoutRect& damageRect, RenderObject* pai
ntingRoot = 0); | 156 void paint(GraphicsContext*, const LayoutRect& damageRect, RenderObject* pai
ntingRoot = 0); |
| 158 bool hitTest(const HitTestRequest&, HitTestResult&); | 157 bool hitTest(const HitTestRequest&, HitTestResult&); |
| 159 bool hitTest(const HitTestRequest&, const HitTestLocation&, HitTestResult&); | 158 bool hitTest(const HitTestRequest&, const HitTestLocation&, HitTestResult&); |
| 160 | 159 |
| 161 // Pass offsetFromRoot if known. | 160 // Pass offsetFromRoot if known. |
| 162 bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& d
amageRect, const RenderLayer* rootLayer, const LayoutPoint* offsetFromRoot = 0)
const; | 161 bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& d
amageRect, const RenderLayer* rootLayer, const LayoutPoint* offsetFromRoot = 0)
const; |
| 163 | 162 |
| 164 // Bounding box relative to some ancestor layer. Pass offsetFromRoot if know
n. | 163 // Bounding box relative to some ancestor layer. Pass offsetFromRoot if know
n. |
| 165 LayoutRect physicalBoundingBox(const RenderLayer* ancestorLayer, const Layou
tPoint* offsetFromRoot = 0) const; | 164 LayoutRect physicalBoundingBox(const RenderLayer* ancestorLayer, const Layou
tPoint* offsetFromRoot = 0) const; |
| 166 LayoutRect physicalBoundingBoxIncludingReflectionAndStackingChildren(const R
enderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const; | 165 LayoutRect physicalBoundingBoxIncludingReflectionAndStackingChildren(const R
enderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const; |
| 167 | 166 |
| 168 // FIXME: This function is inconsistent as to whether the returned rect has
been flipped for writing mode. | |
| 169 LayoutRect boundingBoxForCompositingOverlapTest() const { return overlapBoun
dsIncludeChildren() ? boundingBoxForCompositing() : logicalBoundingBox(); } | |
| 170 | |
| 171 // If true, this layer's children are included in its bounds for overlap tes
ting. | 167 // If true, this layer's children are included in its bounds for overlap tes
ting. |
| 172 // We can't rely on the children's positions if this layer has a filter that
could have moved the children's pixels around. | 168 // We can't rely on the children's positions if this layer has a filter that
could have moved the children's pixels around. |
| 173 bool overlapBoundsIncludeChildren() const { return hasFilter() && renderer()
->style()->filter().hasFilterThatMovesPixels(); } | 169 bool overlapBoundsIncludeChildren() const { return hasFilter() && renderer()
->style()->filter().hasFilterThatMovesPixels(); } |
| 174 | 170 |
| 175 enum CalculateBoundsOptions { | 171 LayoutRect boundingBoxForCompositing(const RenderLayer* ancestorLayer = 0) c
onst; |
| 176 ApplyBoundsChickenEggHacks, | |
| 177 DoNotApplyBoundsChickenEggHacks, | |
| 178 }; | |
| 179 LayoutRect boundingBoxForCompositing(const RenderLayer* ancestorLayer = 0, C
alculateBoundsOptions = DoNotApplyBoundsChickenEggHacks) const; | |
| 180 | 172 |
| 181 LayoutUnit staticInlinePosition() const { return m_staticInlinePosition; } | 173 LayoutUnit staticInlinePosition() const { return m_staticInlinePosition; } |
| 182 LayoutUnit staticBlockPosition() const { return m_staticBlockPosition; } | 174 LayoutUnit staticBlockPosition() const { return m_staticBlockPosition; } |
| 183 | 175 |
| 184 void setStaticInlinePosition(LayoutUnit position) { m_staticInlinePosition =
position; } | 176 void setStaticInlinePosition(LayoutUnit position) { m_staticInlinePosition =
position; } |
| 185 void setStaticBlockPosition(LayoutUnit position) { m_staticBlockPosition = p
osition; } | 177 void setStaticBlockPosition(LayoutUnit position) { m_staticBlockPosition = p
osition; } |
| 186 | 178 |
| 187 LayoutSize subpixelAccumulation() const; | 179 LayoutSize subpixelAccumulation() const; |
| 188 void setSubpixelAccumulation(const LayoutSize&); | 180 void setSubpixelAccumulation(const LayoutSize&); |
| 189 | 181 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 RenderLayerClipper& clipper() { return m_clipper; } | 236 RenderLayerClipper& clipper() { return m_clipper; } |
| 245 const RenderLayerClipper& clipper() const { return m_clipper; } | 237 const RenderLayerClipper& clipper() const { return m_clipper; } |
| 246 | 238 |
| 247 inline bool isPositionedContainer() const | 239 inline bool isPositionedContainer() const |
| 248 { | 240 { |
| 249 // FIXME: This is not in sync with containingBlock. | 241 // FIXME: This is not in sync with containingBlock. |
| 250 RenderLayerModelObject* layerRenderer = renderer(); | 242 RenderLayerModelObject* layerRenderer = renderer(); |
| 251 return isRootLayer() || layerRenderer->isPositioned() || hasTransform(); | 243 return isRootLayer() || layerRenderer->isPositioned() || hasTransform(); |
| 252 } | 244 } |
| 253 | 245 |
| 254 class AncestorDependentCompositingInputs { | |
| 255 public: | |
| 256 AncestorDependentCompositingInputs() | |
| 257 : opacityAncestor(0) | |
| 258 , transformAncestor(0) | |
| 259 , filterAncestor(0) | |
| 260 , clippingContainer(0) | |
| 261 , ancestorScrollingLayer(0) | |
| 262 , scrollParent(0) | |
| 263 , clipParent(0) | |
| 264 , isUnclippedDescendant(false) | |
| 265 , hasAncestorWithClipPath(false) | |
| 266 { } | |
| 267 | |
| 268 IntRect clippedAbsoluteBoundingBox; | |
| 269 const RenderLayer* opacityAncestor; | |
| 270 const RenderLayer* transformAncestor; | |
| 271 const RenderLayer* filterAncestor; | |
| 272 const RenderObject* clippingContainer; | |
| 273 const RenderLayer* ancestorScrollingLayer; | |
| 274 | |
| 275 // A scroll parent is a compositor concept. It's only needed in blink | |
| 276 // because we need to use it as a promotion trigger. A layer has a | |
| 277 // scroll parent if neither its compositor scrolling ancestor, nor any | |
| 278 // other layer scrolled by this ancestor, is a stacking ancestor of this | |
| 279 // layer. Layers with scroll parents must be scrolled with the main | |
| 280 // scrolling layer by the compositor. | |
| 281 const RenderLayer* scrollParent; | |
| 282 | |
| 283 // A clip parent is another compositor concept that has leaked into | |
| 284 // blink so that it may be used as a promotion trigger. Layers with clip | |
| 285 // parents escape the clip of a stacking tree ancestor. The compositor | |
| 286 // needs to know about clip parents in order to circumvent its normal | |
| 287 // clipping logic. | |
| 288 const RenderLayer* clipParent; | |
| 289 | |
| 290 // The "is unclipped descendant" concept is now only being used for one | |
| 291 // purpose: when traversing the RenderLayers in stacking order, we check | |
| 292 // if we scroll wrt to these unclipped descendants. We do this to | |
| 293 // proactively promote in the same way that we do for animated layers. | |
| 294 // Since we have no idea where scrolled content will scroll to, we just | |
| 295 // assume that it can overlap the unclipped thing at some point, so we | |
| 296 // promote. But this is unfortunate. We should be able to inflate the | |
| 297 // bounds of scrolling content for overlap the same way we're doing for | |
| 298 // animation and only promote what's necessary. Once we're doing that, | |
| 299 // we won't need to use the "unclipped" concept for promotion any | |
| 300 // longer. | |
| 301 unsigned isUnclippedDescendant : 1; | |
| 302 unsigned hasAncestorWithClipPath : 1; | |
| 303 }; | |
| 304 | |
| 305 class DescendantDependentCompositingInputs { | |
| 306 public: | |
| 307 DescendantDependentCompositingInputs() | |
| 308 : hasDescendantWithClipPath(false) | |
| 309 | |
| 310 { } | |
| 311 | |
| 312 unsigned hasDescendantWithClipPath : 1; | |
| 313 }; | |
| 314 | |
| 315 bool childNeedsCompositingInputsUpdate() const { return m_childNeedsComposit
ingInputsUpdate; } | |
| 316 bool needsCompositingInputsUpdate() const | |
| 317 { | |
| 318 // While we're updating the compositing inputs, these values may differ. | |
| 319 // We should never be asking for this value when that is the case. | |
| 320 ASSERT(m_needsDescendantDependentCompositingInputsUpdate == m_needsAnces
torDependentCompositingInputsUpdate); | |
| 321 return m_needsDescendantDependentCompositingInputsUpdate; | |
| 322 } | |
| 323 | |
| 324 void updateAncestorDependentCompositingInputs(const AncestorDependentComposi
tingInputs&); | |
| 325 void updateDescendantDependentCompositingInputs(const DescendantDependentCom
positingInputs&); | |
| 326 | |
| 327 const AncestorDependentCompositingInputs& ancestorDependentCompositingInputs
() const { ASSERT(!m_needsAncestorDependentCompositingInputsUpdate); return m_an
cestorDependentCompositingInputs; } | |
| 328 const DescendantDependentCompositingInputs& descendantDependentCompositingIn
puts() const { ASSERT(!m_needsDescendantDependentCompositingInputsUpdate); retur
n m_descendantDependentCompositingInputs; } | |
| 329 | |
| 330 IntRect clippedAbsoluteBoundingBox() const { return ancestorDependentComposi
tingInputs().clippedAbsoluteBoundingBox; } | |
| 331 const RenderLayer* opacityAncestor() const { return ancestorDependentComposi
tingInputs().opacityAncestor; } | |
| 332 const RenderLayer* transformAncestor() const { return ancestorDependentCompo
sitingInputs().transformAncestor; } | |
| 333 const RenderLayer* filterAncestor() const { return ancestorDependentComposit
ingInputs().filterAncestor; } | |
| 334 const RenderObject* clippingContainer() const { return ancestorDependentComp
ositingInputs().clippingContainer; } | |
| 335 const RenderLayer* ancestorScrollingLayer() const { return ancestorDependent
CompositingInputs().ancestorScrollingLayer; } | |
| 336 RenderLayer* scrollParent() const { return const_cast<RenderLayer*>(ancestor
DependentCompositingInputs().scrollParent); } | |
| 337 RenderLayer* clipParent() const { return const_cast<RenderLayer*>(ancestorDe
pendentCompositingInputs().clipParent); } | |
| 338 bool isUnclippedDescendant() const { return ancestorDependentCompositingInpu
ts().isUnclippedDescendant; } | |
| 339 bool hasAncestorWithClipPath() const { return ancestorDependentCompositingIn
puts().hasAncestorWithClipPath; } | |
| 340 bool hasDescendantWithClipPath() const { return descendantDependentCompositi
ngInputs().hasDescendantWithClipPath; } | |
| 341 | |
| 342 bool lostGroupedMapping() const { return m_lostGroupedMapping; } | 246 bool lostGroupedMapping() const { return m_lostGroupedMapping; } |
| 343 void setLostGroupedMapping(bool b) { m_lostGroupedMapping = b; } | 247 void setLostGroupedMapping(bool b) { m_lostGroupedMapping = b; } |
| 344 | 248 |
| 345 bool hasCompositingDescendant() const { return m_hasCompositingDescendant; } | |
| 346 void setHasCompositingDescendant(bool); | |
| 347 | |
| 348 void updateOrRemoveFilterEffectRenderer(); | 249 void updateOrRemoveFilterEffectRenderer(); |
| 349 | 250 |
| 350 void updateSelfPaintingLayer(); | 251 void updateSelfPaintingLayer(); |
| 351 | 252 |
| 352 RenderLayer* enclosingTransformedAncestor() const; | |
| 353 LayoutPoint computeOffsetFromTransformedAncestor() const; | |
| 354 | |
| 355 private: | 253 private: |
| 356 // TODO(ojan): Get rid of this. These are basically layer-tree-only paint ph
ases. | 254 // TODO(ojan): Get rid of this. These are basically layer-tree-only paint ph
ases. |
| 357 enum PaintLayerFlags { | 255 enum PaintLayerFlags { |
| 358 PaintContent, | 256 PaintContent, |
| 359 }; | 257 }; |
| 360 | 258 |
| 361 // Bounding box in the coordinates of this layer. | 259 // Bounding box in the coordinates of this layer. |
| 362 LayoutRect logicalBoundingBox() const; | 260 LayoutRect logicalBoundingBox() const; |
| 363 | 261 |
| 364 void setAncestorChainHasSelfPaintingLayerDescendant(); | 262 void setAncestorChainHasSelfPaintingLayerDescendant(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 unsigned m_usedTransparency : 1; // Tracks whether we need to close a transp
arent layer, i.e., whether | 353 unsigned m_usedTransparency : 1; // Tracks whether we need to close a transp
arent layer, i.e., whether |
| 456 // we ended up painting this layer or any desce
ndants (and therefore need to | 354 // we ended up painting this layer or any desce
ndants (and therefore need to |
| 457 // blend). | 355 // blend). |
| 458 | 356 |
| 459 unsigned m_3DTransformedDescendantStatusDirty : 1; | 357 unsigned m_3DTransformedDescendantStatusDirty : 1; |
| 460 // Set on a stacking context layer that has 3D descendants anywhere | 358 // Set on a stacking context layer that has 3D descendants anywhere |
| 461 // in a preserves3D hierarchy. Hint to do 3D-aware hit testing. | 359 // in a preserves3D hierarchy. Hint to do 3D-aware hit testing. |
| 462 unsigned m_has3DTransformedDescendant : 1; | 360 unsigned m_has3DTransformedDescendant : 1; |
| 463 | 361 |
| 464 unsigned m_hasFilterInfo : 1; | 362 unsigned m_hasFilterInfo : 1; |
| 465 unsigned m_needsAncestorDependentCompositingInputsUpdate : 1; | |
| 466 unsigned m_needsDescendantDependentCompositingInputsUpdate : 1; | |
| 467 unsigned m_childNeedsCompositingInputsUpdate : 1; | |
| 468 | |
| 469 // Used only while determining what layers should be composited. Applies to
the tree of z-order lists. | |
| 470 unsigned m_hasCompositingDescendant : 1; | |
| 471 | 363 |
| 472 // True if this render layer just lost its grouped mapping due to the Compos
itedLayerMapping being destroyed, | 364 // True if this render layer just lost its grouped mapping due to the Compos
itedLayerMapping being destroyed, |
| 473 // and we don't yet know to what graphics layer this RenderLayer will be ass
igned. | 365 // and we don't yet know to what graphics layer this RenderLayer will be ass
igned. |
| 474 unsigned m_lostGroupedMapping : 1; | 366 unsigned m_lostGroupedMapping : 1; |
| 475 | 367 |
| 476 RenderLayerModelObject* m_renderer; | 368 RenderLayerModelObject* m_renderer; |
| 477 | 369 |
| 478 RenderLayer* m_parent; | 370 RenderLayer* m_parent; |
| 479 RenderLayer* m_previous; | 371 RenderLayer* m_previous; |
| 480 RenderLayer* m_next; | 372 RenderLayer* m_next; |
| 481 RenderLayer* m_first; | 373 RenderLayer* m_first; |
| 482 RenderLayer* m_last; | 374 RenderLayer* m_last; |
| 483 | 375 |
| 484 // Cached normal flow values for absolute positioned elements with static le
ft/top values. | 376 // Cached normal flow values for absolute positioned elements with static le
ft/top values. |
| 485 LayoutUnit m_staticInlinePosition; | 377 LayoutUnit m_staticInlinePosition; |
| 486 LayoutUnit m_staticBlockPosition; | 378 LayoutUnit m_staticBlockPosition; |
| 487 | 379 |
| 488 OwnPtr<TransformationMatrix> m_transform; | 380 OwnPtr<TransformationMatrix> m_transform; |
| 489 | 381 |
| 490 DescendantDependentCompositingInputs m_descendantDependentCompositingInputs; | |
| 491 AncestorDependentCompositingInputs m_ancestorDependentCompositingInputs; | |
| 492 | |
| 493 RenderLayerClipper m_clipper; // FIXME: Lazily allocate? | 382 RenderLayerClipper m_clipper; // FIXME: Lazily allocate? |
| 494 OwnPtr<RenderLayerStackingNode> m_stackingNode; | 383 OwnPtr<RenderLayerStackingNode> m_stackingNode; |
| 495 | 384 |
| 496 LayoutSize m_subpixelAccumulation; // The accumulated subpixel offset of a c
omposited layer's composited bounds compared to absolute coordinates. | 385 LayoutSize m_subpixelAccumulation; // The accumulated subpixel offset of a c
omposited layer's composited bounds compared to absolute coordinates. |
| 497 }; | 386 }; |
| 498 | 387 |
| 499 } // namespace blink | 388 } // namespace blink |
| 500 | 389 |
| 501 #ifndef NDEBUG | 390 #ifndef NDEBUG |
| 502 // Outside the WebCore namespace for ease of invocation from gdb. | 391 // Outside the WebCore namespace for ease of invocation from gdb. |
| 503 void showLayerTree(const blink::RenderLayer*); | 392 void showLayerTree(const blink::RenderLayer*); |
| 504 void showLayerTree(const blink::RenderObject*); | 393 void showLayerTree(const blink::RenderObject*); |
| 505 #endif | 394 #endif |
| 506 | 395 |
| 507 #endif // SKY_ENGINE_CORE_RENDERING_RENDERLAYER_H_ | 396 #endif // SKY_ENGINE_CORE_RENDERING_RENDERLAYER_H_ |
| OLD | NEW |