| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 if (m_owningLayer->renderer()->containingBlock()->enclosingLayer() != m_owni
ngLayer->ancestorScrollingLayer()) | 339 if (m_owningLayer->renderer()->containingBlock()->enclosingLayer() != m_owni
ngLayer->ancestorScrollingLayer()) |
| 340 return true; | 340 return true; |
| 341 | 341 |
| 342 return false; | 342 return false; |
| 343 } | 343 } |
| 344 | 344 |
| 345 void CompositedLayerMapping::updateCompositedBounds() | 345 void CompositedLayerMapping::updateCompositedBounds() |
| 346 { | 346 { |
| 347 // We need to know if we draw content in order to update our bounds (this ha
s an effect | 347 // We need to know if we draw content in order to update our bounds (this ha
s an effect |
| 348 // on whether or not descendands will paint into our backing). Update this v
alue now. | 348 // on whether or not descendands will paint into our backing). Update this v
alue now. |
| 349 updateDrawsContent(); | 349 updateDrawsContent(isSimpleContainerCompositingLayer()); |
| 350 | 350 |
| 351 LayoutRect layerBounds = compositor()->calculateCompositedBounds(m_owningLay
er, m_owningLayer); | 351 LayoutRect layerBounds = compositor()->calculateCompositedBounds(m_owningLay
er, m_owningLayer); |
| 352 | 352 |
| 353 // Clip to the size of the document or enclosing overflow-scroll layer. | 353 // Clip to the size of the document or enclosing overflow-scroll layer. |
| 354 // If this or an ancestor is transformed, we can't currently compute the cor
rect rect to intersect with. | 354 // If this or an ancestor is transformed, we can't currently compute the cor
rect rect to intersect with. |
| 355 // We'd need RenderObject::convertContainerToLocalQuad(), which doesn't yet
exist. | 355 // We'd need RenderObject::convertContainerToLocalQuad(), which doesn't yet
exist. |
| 356 if (shouldClipCompositedBounds()) { | 356 if (shouldClipCompositedBounds()) { |
| 357 RenderView* view = m_owningLayer->renderer()->view(); | 357 RenderView* view = m_owningLayer->renderer()->view(); |
| 358 RenderLayer* rootLayer = view->layer(); | 358 RenderLayer* rootLayer = view->layer(); |
| 359 | 359 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 507 |
| 508 if (m_owningLayer->reflectionInfo()) { | 508 if (m_owningLayer->reflectionInfo()) { |
| 509 if (m_owningLayer->reflectionInfo()->reflectionLayer()->hasCompositedLay
erMapping()) { | 509 if (m_owningLayer->reflectionInfo()->reflectionLayer()->hasCompositedLay
erMapping()) { |
| 510 GraphicsLayer* reflectionLayer = m_owningLayer->reflectionInfo()->re
flectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); | 510 GraphicsLayer* reflectionLayer = m_owningLayer->reflectionInfo()->re
flectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); |
| 511 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); | 511 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); |
| 512 } | 512 } |
| 513 } else { | 513 } else { |
| 514 m_graphicsLayer->setReplicatedByLayer(0); | 514 m_graphicsLayer->setReplicatedByLayer(0); |
| 515 } | 515 } |
| 516 | 516 |
| 517 updateBackgroundColor(); | 517 updateBackgroundColor(isSimpleContainerCompositingLayer()); |
| 518 | 518 |
| 519 if (isDirectlyCompositedImage()) | 519 if (isDirectlyCompositedImage()) |
| 520 updateImageContents(); | 520 updateImageContents(); |
| 521 | 521 |
| 522 if (renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->allows
AcceleratedCompositing()) { | 522 if (renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->allows
AcceleratedCompositing()) { |
| 523 PluginView* pluginView = toPluginView(toRenderWidget(renderer)->widget()
); | 523 PluginView* pluginView = toPluginView(toRenderWidget(renderer)->widget()
); |
| 524 m_graphicsLayer->setContentsToPlatformLayer(pluginView->platformLayer())
; | 524 m_graphicsLayer->setContentsToPlatformLayer(pluginView->platformLayer())
; |
| 525 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to
HTMLFrameOwnerElement(renderer->node())->contentFrame()) { | 525 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to
HTMLFrameOwnerElement(renderer->node())->contentFrame()) { |
| 526 blink::WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->cont
entFrame()->remotePlatformLayer(); | 526 blink::WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->cont
entFrame()->remotePlatformLayer(); |
| 527 if (layer) | 527 if (layer) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 | 625 |
| 626 // Set transform property, if it is not animating. We have to do this here b
ecause the transform | 626 // Set transform property, if it is not animating. We have to do this here b
ecause the transform |
| 627 // is affected by the layer dimensions. | 627 // is affected by the layer dimensions. |
| 628 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransform
)) | 628 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransform
)) |
| 629 updateTransform(renderer()->style()); | 629 updateTransform(renderer()->style()); |
| 630 | 630 |
| 631 // Set opacity, if it is not animating. | 631 // Set opacity, if it is not animating. |
| 632 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity)) | 632 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity)) |
| 633 updateOpacity(renderer()->style()); | 633 updateOpacity(renderer()->style()); |
| 634 | 634 |
| 635 bool isSimpleContainer = isSimpleContainerCompositingLayer(); |
| 636 |
| 635 m_owningLayer->updateDescendantDependentFlags(); | 637 m_owningLayer->updateDescendantDependentFlags(); |
| 636 | 638 |
| 637 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a
nd its non-compositing | 639 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a
nd its non-compositing |
| 638 // descendants. So, the visibility flag for m_graphicsLayer should be true i
f there are any | 640 // descendants. So, the visibility flag for m_graphicsLayer should be true i
f there are any |
| 639 // non-compositing visible layers. | 641 // non-compositing visible layers. |
| 640 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo
mpositingDescendantLayers(); | 642 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo
mpositingDescendantLayers(); |
| 641 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i
sVideo()) { | 643 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i
sVideo()) { |
| 642 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node()); | 644 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node()); |
| 643 if (mediaElement->isFullscreen()) | 645 if (mediaElement->isFullscreen()) |
| 644 contentsVisible = false; | 646 contentsVisible = false; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 844 |
| 843 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit
edLayerMapping | 845 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit
edLayerMapping |
| 844 // since it depends on whether compAncestor draws content, which gets update
d later. | 846 // since it depends on whether compAncestor draws content, which gets update
d later. |
| 845 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); | 847 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); |
| 846 | 848 |
| 847 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { | 849 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { |
| 848 updateLayerBlendMode(style); | 850 updateLayerBlendMode(style); |
| 849 updateIsRootForIsolatedGroup(); | 851 updateIsRootForIsolatedGroup(); |
| 850 } | 852 } |
| 851 | 853 |
| 852 updateContentsRect(); | 854 updateContentsRect(isSimpleContainer); |
| 853 updateBackgroundColor(); | 855 updateBackgroundColor(isSimpleContainer); |
| 854 updateDrawsContent(); | 856 updateDrawsContent(isSimpleContainer); |
| 855 updateContentsOpaque(); | 857 updateContentsOpaque(); |
| 856 updateAfterWidgetResize(); | 858 updateAfterWidgetResize(); |
| 857 updateRenderingContext(); | 859 updateRenderingContext(); |
| 858 updateShouldFlattenTransform(); | 860 updateShouldFlattenTransform(); |
| 859 updateChildrenTransform(); | 861 updateChildrenTransform(); |
| 860 registerScrollingLayers(); | 862 registerScrollingLayers(); |
| 861 | 863 |
| 862 updateCompositingReasons(); | 864 updateCompositingReasons(); |
| 863 } | 865 } |
| 864 | 866 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 931 |
| 930 if (m_ancestorClippingLayer) | 932 if (m_ancestorClippingLayer) |
| 931 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get())
; | 933 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get())
; |
| 932 else | 934 else |
| 933 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); | 935 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); |
| 934 | 936 |
| 935 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); | 937 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); |
| 936 } | 938 } |
| 937 } | 939 } |
| 938 | 940 |
| 939 void CompositedLayerMapping::updateContentsRect() | 941 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) |
| 940 { | 942 { |
| 941 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox())); | 943 LayoutRect contentsRect; |
| 944 if (isSimpleContainer && renderer()->hasBackground()) |
| 945 contentsRect = backgroundBox(); |
| 946 else |
| 947 contentsRect = contentsBox(); |
| 948 |
| 949 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsRect)); |
| 942 } | 950 } |
| 943 | 951 |
| 944 void CompositedLayerMapping::updateDrawsContent() | 952 void CompositedLayerMapping::updateDrawsContent(bool isSimpleContainer) |
| 945 { | 953 { |
| 946 if (m_scrollingLayer) { | 954 if (m_scrollingLayer) { |
| 947 // We don't have to consider overflow controls, because we know that the
scrollbars are drawn elsewhere. | 955 // We don't have to consider overflow controls, because we know that the
scrollbars are drawn elsewhere. |
| 948 // m_graphicsLayer only needs backing store if the non-scrolling parts (
background, outlines, borders, shadows etc) need to paint. | 956 // m_graphicsLayer only needs backing store if the non-scrolling parts (
background, outlines, borders, shadows etc) need to paint. |
| 949 // m_scrollingLayer never has backing store. | 957 // m_scrollingLayer never has backing store. |
| 950 // m_scrollingContentsLayer only needs backing store if the scrolled con
tents need to paint. | 958 // m_scrollingContentsLayer only needs backing store if the scrolled con
tents need to paint. |
| 951 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent()
&& m_owningLayer->hasBoxDecorationsOrBackground(); | 959 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent()
&& m_owningLayer->hasBoxDecorationsOrBackground(); |
| 952 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); | 960 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); |
| 953 | 961 |
| 954 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() &&
(renderer()->hasBackground() || paintsChildren()); | 962 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() &&
(renderer()->hasBackground() || paintsChildren()); |
| 955 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); | 963 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); |
| 956 return; | 964 return; |
| 957 } | 965 } |
| 958 | 966 |
| 959 bool hasPaintedContent = containsPaintedContent(); | 967 bool hasPaintedContent = containsPaintedContent(isSimpleContainer); |
| 960 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { | 968 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { |
| 961 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node()
)->renderingContext(); | 969 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node()
)->renderingContext(); |
| 962 // Content layer may be null if context is lost. | 970 // Content layer may be null if context is lost. |
| 963 if (blink::WebLayer* contentLayer = context->platformLayer()) { | 971 if (blink::WebLayer* contentLayer = context->platformLayer()) { |
| 964 Color bgColor(Color::transparent); | 972 Color bgColor(Color::transparent); |
| 965 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { | 973 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { |
| 966 bgColor = rendererBackgroundColor(); | 974 bgColor = rendererBackgroundColor(); |
| 967 hasPaintedContent = false; | 975 hasPaintedContent = false; |
| 968 } | 976 } |
| 969 contentLayer->setBackgroundColor(bgColor.rgb()); | 977 contentLayer->setBackgroundColor(bgColor.rgb()); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 | 1491 |
| 1484 Color CompositedLayerMapping::rendererBackgroundColor() const | 1492 Color CompositedLayerMapping::rendererBackgroundColor() const |
| 1485 { | 1493 { |
| 1486 RenderObject* backgroundRenderer = renderer(); | 1494 RenderObject* backgroundRenderer = renderer(); |
| 1487 if (backgroundRenderer->isRoot()) | 1495 if (backgroundRenderer->isRoot()) |
| 1488 backgroundRenderer = backgroundRenderer->rendererForRootBackground(); | 1496 backgroundRenderer = backgroundRenderer->rendererForRootBackground(); |
| 1489 | 1497 |
| 1490 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor); | 1498 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor); |
| 1491 } | 1499 } |
| 1492 | 1500 |
| 1493 void CompositedLayerMapping::updateBackgroundColor() | 1501 void CompositedLayerMapping::updateBackgroundColor(bool isSimpleContainer) |
| 1494 { | 1502 { |
| 1495 m_graphicsLayer->setBackgroundColor(rendererBackgroundColor()); | 1503 Color backgroundColor = rendererBackgroundColor(); |
| 1504 if (isSimpleContainer) { |
| 1505 m_graphicsLayer->setContentsToSolidColor(backgroundColor); |
| 1506 m_graphicsLayer->setBackgroundColor(Color::transparent); |
| 1507 } else { |
| 1508 m_graphicsLayer->setContentsToSolidColor(Color::transparent); |
| 1509 m_graphicsLayer->setBackgroundColor(backgroundColor); |
| 1510 } |
| 1511 } |
| 1512 |
| 1513 static bool supportsDirectBoxDecorationsComposition(const RenderObject* renderer
) |
| 1514 { |
| 1515 if (renderer->hasClip()) |
| 1516 return false; |
| 1517 |
| 1518 if (hasBoxDecorationsOrBackgroundImage(renderer->style())) |
| 1519 return false; |
| 1520 |
| 1521 // FIXME: we should be able to allow backgroundComposite; However since this
is not a common use case it has been deferred for now. |
| 1522 if (renderer->style()->backgroundComposite() != CompositeSourceOver) |
| 1523 return false; |
| 1524 |
| 1525 if (renderer->style()->backgroundClip() == TextFillBox) |
| 1526 return false; |
| 1527 |
| 1528 return true; |
| 1529 } |
| 1530 |
| 1531 bool CompositedLayerMapping::paintsBoxDecorations() const |
| 1532 { |
| 1533 if (!m_owningLayer->hasVisibleBoxDecorations()) |
| 1534 return false; |
| 1535 |
| 1536 if (!supportsDirectBoxDecorationsComposition(renderer())) |
| 1537 return true; |
| 1538 |
| 1539 return false; |
| 1496 } | 1540 } |
| 1497 | 1541 |
| 1498 bool CompositedLayerMapping::paintsChildren() const | 1542 bool CompositedLayerMapping::paintsChildren() const |
| 1499 { | 1543 { |
| 1500 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen
derers()) | 1544 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen
derers()) |
| 1501 return true; | 1545 return true; |
| 1502 | 1546 |
| 1503 if (hasVisibleNonCompositingDescendantLayers()) | 1547 if (hasVisibleNonCompositingDescendantLayers()) |
| 1504 return true; | 1548 return true; |
| 1505 | 1549 |
| 1506 return false; | 1550 return false; |
| 1507 } | 1551 } |
| 1508 | 1552 |
| 1509 static bool isCompositedPlugin(RenderObject* renderer) | 1553 static bool isCompositedPlugin(RenderObject* renderer) |
| 1510 { | 1554 { |
| 1511 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all
owsAcceleratedCompositing(); | 1555 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all
owsAcceleratedCompositing(); |
| 1512 } | 1556 } |
| 1513 | 1557 |
| 1558 // A "simple container layer" is a RenderLayer which has no visible content to r
ender. |
| 1559 // It may have no children, or all its children may be themselves composited. |
| 1560 // This is a useful optimization, because it allows us to avoid allocating backi
ng store. |
| 1561 bool CompositedLayerMapping::isSimpleContainerCompositingLayer() const |
| 1562 { |
| 1563 RenderObject* renderObject = renderer(); |
| 1564 if (renderObject->hasMask()) // masks require special treatment |
| 1565 return false; |
| 1566 |
| 1567 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject)) |
| 1568 return false; |
| 1569 |
| 1570 if (paintsBoxDecorations() || paintsChildren()) |
| 1571 return false; |
| 1572 |
| 1573 if (renderObject->isRenderRegion()) |
| 1574 return false; |
| 1575 |
| 1576 if (renderObject->node() && renderObject->node()->isDocumentNode()) { |
| 1577 // Look to see if the root object has a non-simple background |
| 1578 RenderObject* rootObject = renderObject->document().documentElement() ?
renderObject->document().documentElement()->renderer() : 0; |
| 1579 if (!rootObject) |
| 1580 return false; |
| 1581 |
| 1582 RenderStyle* style = rootObject->style(); |
| 1583 |
| 1584 // Reject anything that has a border, a border-radius or outline, |
| 1585 // or is not a simple background (no background, or solid color). |
| 1586 if (hasBoxDecorationsOrBackgroundImage(style)) |
| 1587 return false; |
| 1588 |
| 1589 // Now look at the body's renderer. |
| 1590 HTMLElement* body = renderObject->document().body(); |
| 1591 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body-
>renderer() : 0; |
| 1592 if (!bodyObject) |
| 1593 return false; |
| 1594 |
| 1595 style = bodyObject->style(); |
| 1596 |
| 1597 if (hasBoxDecorationsOrBackgroundImage(style)) |
| 1598 return false; |
| 1599 } |
| 1600 |
| 1601 return true; |
| 1602 } |
| 1603 |
| 1514 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent) | 1604 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent) |
| 1515 { | 1605 { |
| 1516 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. | 1606 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. |
| 1517 parent->stackingNode()->updateLayerListsIfNeeded(); | 1607 parent->stackingNode()->updateLayerListsIfNeeded(); |
| 1518 | 1608 |
| 1519 #if !ASSERT_DISABLED | 1609 #if !ASSERT_DISABLED |
| 1520 LayerListMutationDetector mutationChecker(parent->stackingNode()); | 1610 LayerListMutationDetector mutationChecker(parent->stackingNode()); |
| 1521 #endif | 1611 #endif |
| 1522 | 1612 |
| 1523 RenderLayerStackingNodeIterator normalFlowIterator(*parent->stackingNode(),
NormalFlowChildren); | 1613 RenderLayerStackingNodeIterator normalFlowIterator(*parent->stackingNode(),
NormalFlowChildren); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1543 } | 1633 } |
| 1544 | 1634 |
| 1545 // FIXME: By name the implementation is correct. But the code that uses this fun
ction means something | 1635 // FIXME: By name the implementation is correct. But the code that uses this fun
ction means something |
| 1546 // very slightly different - the implementation needs to also include composited
descendants that | 1636 // very slightly different - the implementation needs to also include composited
descendants that |
| 1547 // don't paint into their own backing, and instead paint into this backing. | 1637 // don't paint into their own backing, and instead paint into this backing. |
| 1548 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const | 1638 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const |
| 1549 { | 1639 { |
| 1550 return hasVisibleNonCompositingDescendant(m_owningLayer); | 1640 return hasVisibleNonCompositingDescendant(m_owningLayer); |
| 1551 } | 1641 } |
| 1552 | 1642 |
| 1553 bool CompositedLayerMapping::containsPaintedContent() const | 1643 bool CompositedLayerMapping::containsPaintedContent(bool isSimpleContainer) cons
t |
| 1554 { | 1644 { |
| 1555 if (paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owni
ngLayer->isReflection()) | 1645 if (isSimpleContainer || paintsIntoCompositedAncestor() || m_artificiallyInf
latedBounds || m_owningLayer->isReflection()) |
| 1556 return false; | 1646 return false; |
| 1557 | 1647 |
| 1558 if (isDirectlyCompositedImage()) | 1648 if (isDirectlyCompositedImage()) |
| 1559 return false; | 1649 return false; |
| 1560 | 1650 |
| 1561 RenderObject* renderObject = renderer(); | |
| 1562 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, | 1651 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, |
| 1563 // and set background color on the layer in that case, instead of allocating
backing store and painting. | 1652 // and set background color on the layer in that case, instead of allocating
backing store and painting. |
| 1564 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo
()) | 1653 if (renderer()->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo()
) |
| 1565 return m_owningLayer->hasBoxDecorationsOrBackground(); | 1654 return m_owningLayer->hasBoxDecorationsOrBackground(); |
| 1566 | 1655 |
| 1567 if (m_owningLayer->hasVisibleBoxDecorations()) | 1656 return true; |
| 1568 return true; | |
| 1569 | |
| 1570 if (renderObject->hasMask()) // masks require special treatment | |
| 1571 return true; | |
| 1572 | |
| 1573 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject)) | |
| 1574 return true; | |
| 1575 | |
| 1576 if (renderObject->isRenderRegion()) | |
| 1577 return true; | |
| 1578 | |
| 1579 if (renderObject->node() && renderObject->node()->isDocumentNode() && render
Object->document().documentElement()) { | |
| 1580 // Look to see if the root object has a non-simple background | |
| 1581 RenderObject* rootObject = renderObject->document().documentElement()->r
enderer(); | |
| 1582 RenderStyle* style = rootObject->style(); | |
| 1583 | |
| 1584 // Reject anything that has a border, a border-radius or outline, | |
| 1585 // or is not a simple background (no background, or solid color). | |
| 1586 if (hasBoxDecorationsOrBackgroundImage(style)) | |
| 1587 return true; | |
| 1588 | |
| 1589 // Now look at the body's renderer. | |
| 1590 HTMLElement* body = renderObject->document().body(); | |
| 1591 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body-
>renderer() : 0; | |
| 1592 if (bodyObject) { | |
| 1593 style = bodyObject->style(); | |
| 1594 if (hasBoxDecorationsOrBackgroundImage(style)) | |
| 1595 return true; | |
| 1596 } | |
| 1597 } | |
| 1598 | |
| 1599 // FIXME: it's O(n^2). A better solution is needed. | |
| 1600 return paintsChildren(); | |
| 1601 } | 1657 } |
| 1602 | 1658 |
| 1603 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations | 1659 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations |
| 1604 // that require painting. Direct compositing saves backing store. | 1660 // that require painting. Direct compositing saves backing store. |
| 1605 bool CompositedLayerMapping::isDirectlyCompositedImage() const | 1661 bool CompositedLayerMapping::isDirectlyCompositedImage() const |
| 1606 { | 1662 { |
| 1607 RenderObject* renderObject = renderer(); | 1663 RenderObject* renderObject = renderer(); |
| 1608 | 1664 |
| 1609 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground
() || renderObject->hasClip()) | 1665 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground
() || renderObject->hasClip()) |
| 1610 return false; | 1666 return false; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 Image* image = cachedImage->imageForRenderer(imageRenderer); | 1702 Image* image = cachedImage->imageForRenderer(imageRenderer); |
| 1647 if (!image) | 1703 if (!image) |
| 1648 return; | 1704 return; |
| 1649 | 1705 |
| 1650 // We have to wait until the image is fully loaded before setting it on the
layer. | 1706 // We have to wait until the image is fully loaded before setting it on the
layer. |
| 1651 if (!cachedImage->isLoaded()) | 1707 if (!cachedImage->isLoaded()) |
| 1652 return; | 1708 return; |
| 1653 | 1709 |
| 1654 // This is a no-op if the layer doesn't have an inner layer for the image. | 1710 // This is a no-op if the layer doesn't have an inner layer for the image. |
| 1655 m_graphicsLayer->setContentsToImage(image); | 1711 m_graphicsLayer->setContentsToImage(image); |
| 1656 updateDrawsContent(); | 1712 bool isSimpleContainer = false; |
| 1713 updateDrawsContent(isSimpleContainer); |
| 1657 | 1714 |
| 1658 // Image animation is "lazy", in that it automatically stops unless someone
is drawing | 1715 // Image animation is "lazy", in that it automatically stops unless someone
is drawing |
| 1659 // the image. So we have to kick the animation each time; this has the downs
ide that the | 1716 // the image. So we have to kick the animation each time; this has the downs
ide that the |
| 1660 // image will keep animating, even if its layer is not visible. | 1717 // image will keep animating, even if its layer is not visible. |
| 1661 image->startAnimation(); | 1718 image->startAnimation(); |
| 1662 } | 1719 } |
| 1663 | 1720 |
| 1664 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const | 1721 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const |
| 1665 { | 1722 { |
| 1666 RenderStyle* style = renderer()->style(); | 1723 RenderStyle* style = renderer()->style(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1693 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()); | 1750 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()); |
| 1694 } | 1751 } |
| 1695 | 1752 |
| 1696 LayoutRect CompositedLayerMapping::contentsBox() const | 1753 LayoutRect CompositedLayerMapping::contentsBox() const |
| 1697 { | 1754 { |
| 1698 LayoutRect contentsBox = contentsRect(renderer()); | 1755 LayoutRect contentsBox = contentsRect(renderer()); |
| 1699 contentsBox.move(contentOffsetInCompostingLayer()); | 1756 contentsBox.move(contentOffsetInCompostingLayer()); |
| 1700 return contentsBox; | 1757 return contentsBox; |
| 1701 } | 1758 } |
| 1702 | 1759 |
| 1760 IntRect CompositedLayerMapping::backgroundBox() const |
| 1761 { |
| 1762 LayoutRect backgroundBox = backgroundRect(renderer()); |
| 1763 backgroundBox.move(contentOffsetInCompostingLayer()); |
| 1764 return pixelSnappedIntRect(backgroundBox); |
| 1765 } |
| 1766 |
| 1703 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const | 1767 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const |
| 1704 { | 1768 { |
| 1705 if (m_scrollingContentsLayer) | 1769 if (m_scrollingContentsLayer) |
| 1706 return m_scrollingContentsLayer.get(); | 1770 return m_scrollingContentsLayer.get(); |
| 1707 | 1771 |
| 1708 if (m_childContainmentLayer) | 1772 if (m_childContainmentLayer) |
| 1709 return m_childContainmentLayer.get(); | 1773 return m_childContainmentLayer.get(); |
| 1710 | 1774 |
| 1711 if (m_childTransformLayer) | 1775 if (m_childTransformLayer) |
| 1712 return m_childTransformLayer.get(); | 1776 return m_childTransformLayer.get(); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2164 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2101 name = "Scrolling Contents Layer"; | 2165 name = "Scrolling Contents Layer"; |
| 2102 } else { | 2166 } else { |
| 2103 ASSERT_NOT_REACHED(); | 2167 ASSERT_NOT_REACHED(); |
| 2104 } | 2168 } |
| 2105 | 2169 |
| 2106 return name; | 2170 return name; |
| 2107 } | 2171 } |
| 2108 | 2172 |
| 2109 } // namespace WebCore | 2173 } // namespace WebCore |
| OLD | NEW |