| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 static bool hasNonZeroTransformOrigin(const RenderObject* renderer) | 331 static bool hasNonZeroTransformOrigin(const RenderObject* renderer) |
| 332 { | 332 { |
| 333 RenderStyle* style = renderer->style(); | 333 RenderStyle* style = renderer->style(); |
| 334 return (style->transformOriginX().type() == Fixed && style->transformOriginX
().value()) | 334 return (style->transformOriginX().type() == Fixed && style->transformOriginX
().value()) |
| 335 || (style->transformOriginY().type() == Fixed && style->transformOriginY
().value()); | 335 || (style->transformOriginY().type() == Fixed && style->transformOriginY
().value()); |
| 336 } | 336 } |
| 337 | 337 |
| 338 static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer*
layer) | |
| 339 { | |
| 340 for (RenderLayer* curr = layer; curr; curr = curr->parent()) { | |
| 341 if (curr->hasTransform() || curr->needsCompositedScrolling()) | |
| 342 return true; | |
| 343 } | |
| 344 | |
| 345 return false; | |
| 346 } | |
| 347 | |
| 348 bool CompositedLayerMapping::shouldClipCompositedBounds() const | |
| 349 { | |
| 350 // Scrollbar layers use this layer for relative positioning, so don't clip. | |
| 351 if (layerForHorizontalScrollbar() || layerForVerticalScrollbar()) | |
| 352 return false; | |
| 353 | |
| 354 if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(&m_owningLayer)) | |
| 355 return false; | |
| 356 | |
| 357 // Scrolled composited layers are clipped by their ancestor clipping layer, | |
| 358 // so don't clip these, either. | |
| 359 if (compositor()->clippedByNonAncestorInStackingTree(&m_owningLayer) | |
| 360 && m_owningLayer.renderer()->containingBlock()->enclosingLayer() == m_ow
ningLayer.ancestorScrollingLayer()) | |
| 361 return false; | |
| 362 | |
| 363 return true; | |
| 364 } | |
| 365 | |
| 366 void CompositedLayerMapping::updateCompositedBounds(GraphicsLayerUpdater::Update
Type updateType) | 338 void CompositedLayerMapping::updateCompositedBounds(GraphicsLayerUpdater::Update
Type updateType) |
| 367 { | 339 { |
| 368 if (!shouldUpdateGraphicsLayer(updateType)) | 340 if (!shouldUpdateGraphicsLayer(updateType)) |
| 369 return; | 341 return; |
| 370 | 342 |
| 371 // We need to know if we draw content in order to update our bounds (this ha
s an effect | 343 // We need to know if we draw content in order to update our bounds (this ha
s an effect |
| 372 // on whether or not descendands will paint into our backing). Update this v
alue now. | 344 // on whether or not descendands will paint into our backing). Update this v
alue now. |
| 373 updateDrawsContent(); | 345 updateDrawsContent(); |
| 374 | 346 |
| 375 LayoutRect layerBounds = m_owningLayer.boundingBoxForCompositing(); | 347 LayoutRect layerBounds = m_owningLayer.boundingBoxForCompositing(); |
| 376 | 348 |
| 377 // Clip to the size of the document or enclosing overflow-scroll layer. | |
| 378 // If this or an ancestor is transformed, we can't currently compute the cor
rect rect to intersect with. | |
| 379 // We'd need RenderObject::convertContainerToLocalQuad(), which doesn't yet
exist. | |
| 380 if (shouldClipCompositedBounds()) { | |
| 381 RenderView* view = m_owningLayer.renderer()->view(); | |
| 382 RenderLayer* rootLayer = view->layer(); | |
| 383 | |
| 384 LayoutRect clippingBounds; | |
| 385 if (renderer()->style()->position() == FixedPosition && renderer()->cont
ainer() == view) | |
| 386 clippingBounds = view->frameView()->viewportConstrainedVisibleConten
tRect(); | |
| 387 else | |
| 388 clippingBounds = view->unscaledDocumentRect(); | |
| 389 | |
| 390 if (&m_owningLayer != rootLayer) | |
| 391 clippingBounds.intersect(m_owningLayer.clipper().backgroundClipRect(
ClipRectsContext(rootLayer, AbsoluteClipRects)).rect()); | |
| 392 | |
| 393 LayoutPoint delta; | |
| 394 m_owningLayer.convertToLayerCoords(rootLayer, delta); | |
| 395 clippingBounds.move(-delta.x(), -delta.y()); | |
| 396 | |
| 397 layerBounds.intersect(clippingBounds); | |
| 398 } | |
| 399 | |
| 400 // If the element has a transform-origin that has fixed lengths, and the ren
derer has zero size, | 349 // If the element has a transform-origin that has fixed lengths, and the ren
derer has zero size, |
| 401 // then we need to ensure that the compositing layer has non-zero size so th
at we can apply | 350 // then we need to ensure that the compositing layer has non-zero size so th
at we can apply |
| 402 // the transform-origin via the GraphicsLayer anchorPoint (which is expresse
d as a fractional value). | 351 // the transform-origin via the GraphicsLayer anchorPoint (which is expresse
d as a fractional value). |
| 403 if (layerBounds.isEmpty() && hasNonZeroTransformOrigin(renderer())) { | 352 if (layerBounds.isEmpty() && hasNonZeroTransformOrigin(renderer())) { |
| 404 layerBounds.setWidth(1); | 353 layerBounds.setWidth(1); |
| 405 layerBounds.setHeight(1); | 354 layerBounds.setHeight(1); |
| 406 m_artificiallyInflatedBounds = true; | 355 m_artificiallyInflatedBounds = true; |
| 407 } else { | 356 } else { |
| 408 m_artificiallyInflatedBounds = false; | 357 m_artificiallyInflatedBounds = false; |
| 409 } | 358 } |
| (...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2155 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2104 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2156 name = "Scrolling Contents Layer"; | 2105 name = "Scrolling Contents Layer"; |
| 2157 } else { | 2106 } else { |
| 2158 ASSERT_NOT_REACHED(); | 2107 ASSERT_NOT_REACHED(); |
| 2159 } | 2108 } |
| 2160 | 2109 |
| 2161 return name; | 2110 return name; |
| 2162 } | 2111 } |
| 2163 | 2112 |
| 2164 } // namespace WebCore | 2113 } // namespace WebCore |
| OLD | NEW |