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(isSimpleContainerCompositingLayer()); | 349 updateDrawsContent(); |
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(isSimpleContainerCompositingLayer()); | 517 updateBackgroundColor(); |
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 | 631 |
632 // Set transform property, if it is not animating. We have to do this here b
ecause the transform | 632 // Set transform property, if it is not animating. We have to do this here b
ecause the transform |
633 // is affected by the layer dimensions. | 633 // is affected by the layer dimensions. |
634 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransform
)) | 634 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransform
)) |
635 updateTransform(renderer()->style()); | 635 updateTransform(renderer()->style()); |
636 | 636 |
637 // Set opacity, if it is not animating. | 637 // Set opacity, if it is not animating. |
638 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity)) | 638 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity)) |
639 updateOpacity(renderer()->style()); | 639 updateOpacity(renderer()->style()); |
640 | 640 |
641 bool isSimpleContainer = isSimpleContainerCompositingLayer(); | |
642 | |
643 m_owningLayer->updateDescendantDependentFlags(); | 641 m_owningLayer->updateDescendantDependentFlags(); |
644 | 642 |
645 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a
nd its non-compositing | 643 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a
nd its non-compositing |
646 // descendants. So, the visibility flag for m_graphicsLayer should be true i
f there are any | 644 // descendants. So, the visibility flag for m_graphicsLayer should be true i
f there are any |
647 // non-compositing visible layers. | 645 // non-compositing visible layers. |
648 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo
mpositingDescendantLayers(); | 646 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo
mpositingDescendantLayers(); |
649 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i
sVideo()) { | 647 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i
sVideo()) { |
650 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node()); | 648 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node()); |
651 if (mediaElement->isFullscreen()) | 649 if (mediaElement->isFullscreen()) |
652 contentsVisible = false; | 650 contentsVisible = false; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 848 |
851 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit
edLayerMapping | 849 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit
edLayerMapping |
852 // since it depends on whether compAncestor draws content, which gets update
d later. | 850 // since it depends on whether compAncestor draws content, which gets update
d later. |
853 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); | 851 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); |
854 | 852 |
855 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { | 853 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { |
856 updateLayerBlendMode(style); | 854 updateLayerBlendMode(style); |
857 updateIsRootForIsolatedGroup(); | 855 updateIsRootForIsolatedGroup(); |
858 } | 856 } |
859 | 857 |
860 updateContentsRect(isSimpleContainer); | 858 updateContentsRect(); |
861 updateBackgroundColor(isSimpleContainer); | 859 updateBackgroundColor(); |
862 updateDrawsContent(isSimpleContainer); | 860 updateDrawsContent(); |
863 updateContentsOpaque(); | 861 updateContentsOpaque(); |
864 updateAfterWidgetResize(); | 862 updateAfterWidgetResize(); |
865 updateRenderingContext(); | 863 updateRenderingContext(); |
866 updateShouldFlattenTransform(); | 864 updateShouldFlattenTransform(); |
867 updateChildrenTransform(); | 865 updateChildrenTransform(); |
868 registerScrollingLayers(); | 866 registerScrollingLayers(); |
869 | 867 |
870 updateCompositingReasons(); | 868 updateCompositingReasons(); |
871 | 869 |
872 return updateType; | 870 return updateType; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 | 937 |
940 if (m_ancestorClippingLayer) | 938 if (m_ancestorClippingLayer) |
941 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get())
; | 939 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get())
; |
942 else | 940 else |
943 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); | 941 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); |
944 | 942 |
945 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); | 943 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); |
946 } | 944 } |
947 } | 945 } |
948 | 946 |
949 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) | 947 void CompositedLayerMapping::updateContentsRect() |
950 { | 948 { |
951 LayoutRect contentsRect; | 949 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox())); |
952 if (isSimpleContainer && renderer()->hasBackground()) | |
953 contentsRect = backgroundBox(); | |
954 else | |
955 contentsRect = contentsBox(); | |
956 | |
957 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsRect)); | |
958 } | 950 } |
959 | 951 |
960 void CompositedLayerMapping::updateDrawsContent(bool isSimpleContainer) | 952 void CompositedLayerMapping::updateDrawsContent() |
961 { | 953 { |
962 if (m_scrollingLayer) { | 954 if (m_scrollingLayer) { |
963 // 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. |
964 // 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. |
965 // m_scrollingLayer never has backing store. | 957 // m_scrollingLayer never has backing store. |
966 // 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. |
967 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent()
&& m_owningLayer->hasBoxDecorationsOrBackground(); | 959 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent()
&& m_owningLayer->hasBoxDecorationsOrBackground(); |
968 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); | 960 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); |
969 | 961 |
970 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() &&
(renderer()->hasBackground() || paintsChildren()); | 962 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() &&
(renderer()->hasBackground() || paintsChildren()); |
971 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); | 963 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); |
972 return; | 964 return; |
973 } | 965 } |
974 | 966 |
975 bool hasPaintedContent = containsPaintedContent(isSimpleContainer); | 967 bool hasPaintedContent = containsPaintedContent(); |
976 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { | 968 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { |
977 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node()
)->renderingContext(); | 969 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node()
)->renderingContext(); |
978 // Content layer may be null if context is lost. | 970 // Content layer may be null if context is lost. |
979 if (blink::WebLayer* contentLayer = context->platformLayer()) { | 971 if (blink::WebLayer* contentLayer = context->platformLayer()) { |
980 Color bgColor(Color::transparent); | 972 Color bgColor(Color::transparent); |
981 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { | 973 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { |
982 bgColor = rendererBackgroundColor(); | 974 bgColor = rendererBackgroundColor(); |
983 hasPaintedContent = false; | 975 hasPaintedContent = false; |
984 } | 976 } |
985 contentLayer->setBackgroundColor(bgColor.rgb()); | 977 contentLayer->setBackgroundColor(bgColor.rgb()); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 | 1491 |
1500 Color CompositedLayerMapping::rendererBackgroundColor() const | 1492 Color CompositedLayerMapping::rendererBackgroundColor() const |
1501 { | 1493 { |
1502 RenderObject* backgroundRenderer = renderer(); | 1494 RenderObject* backgroundRenderer = renderer(); |
1503 if (backgroundRenderer->isRoot()) | 1495 if (backgroundRenderer->isRoot()) |
1504 backgroundRenderer = backgroundRenderer->rendererForRootBackground(); | 1496 backgroundRenderer = backgroundRenderer->rendererForRootBackground(); |
1505 | 1497 |
1506 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor); | 1498 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor); |
1507 } | 1499 } |
1508 | 1500 |
1509 void CompositedLayerMapping::updateBackgroundColor(bool isSimpleContainer) | 1501 void CompositedLayerMapping::updateBackgroundColor() |
1510 { | 1502 { |
1511 Color backgroundColor = rendererBackgroundColor(); | 1503 m_graphicsLayer->setBackgroundColor(rendererBackgroundColor()); |
1512 if (isSimpleContainer) { | |
1513 m_graphicsLayer->setContentsToSolidColor(backgroundColor); | |
1514 m_graphicsLayer->setBackgroundColor(Color::transparent); | |
1515 } else { | |
1516 m_graphicsLayer->setContentsToSolidColor(Color::transparent); | |
1517 m_graphicsLayer->setBackgroundColor(backgroundColor); | |
1518 } | |
1519 } | |
1520 | |
1521 static bool supportsDirectBoxDecorationsComposition(const RenderObject* renderer
) | |
1522 { | |
1523 if (renderer->hasClip()) | |
1524 return false; | |
1525 | |
1526 if (hasBoxDecorationsOrBackgroundImage(renderer->style())) | |
1527 return false; | |
1528 | |
1529 // FIXME: we should be able to allow backgroundComposite; However since this
is not a common use case it has been deferred for now. | |
1530 if (renderer->style()->backgroundComposite() != CompositeSourceOver) | |
1531 return false; | |
1532 | |
1533 if (renderer->style()->backgroundClip() == TextFillBox) | |
1534 return false; | |
1535 | |
1536 return true; | |
1537 } | |
1538 | |
1539 bool CompositedLayerMapping::paintsBoxDecorations() const | |
1540 { | |
1541 if (!m_owningLayer->hasVisibleBoxDecorations()) | |
1542 return false; | |
1543 | |
1544 if (!supportsDirectBoxDecorationsComposition(renderer())) | |
1545 return true; | |
1546 | |
1547 return false; | |
1548 } | 1504 } |
1549 | 1505 |
1550 bool CompositedLayerMapping::paintsChildren() const | 1506 bool CompositedLayerMapping::paintsChildren() const |
1551 { | 1507 { |
1552 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen
derers()) | 1508 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen
derers()) |
1553 return true; | 1509 return true; |
1554 | 1510 |
1555 if (hasVisibleNonCompositingDescendantLayers()) | 1511 if (hasVisibleNonCompositingDescendantLayers()) |
1556 return true; | 1512 return true; |
1557 | 1513 |
1558 return false; | 1514 return false; |
1559 } | 1515 } |
1560 | 1516 |
1561 static bool isCompositedPlugin(RenderObject* renderer) | 1517 static bool isCompositedPlugin(RenderObject* renderer) |
1562 { | 1518 { |
1563 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all
owsAcceleratedCompositing(); | 1519 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all
owsAcceleratedCompositing(); |
1564 } | 1520 } |
1565 | 1521 |
1566 // A "simple container layer" is a RenderLayer which has no visible content to r
ender. | |
1567 // It may have no children, or all its children may be themselves composited. | |
1568 // This is a useful optimization, because it allows us to avoid allocating backi
ng store. | |
1569 bool CompositedLayerMapping::isSimpleContainerCompositingLayer() const | |
1570 { | |
1571 RenderObject* renderObject = renderer(); | |
1572 if (renderObject->hasMask()) // masks require special treatment | |
1573 return false; | |
1574 | |
1575 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject)) | |
1576 return false; | |
1577 | |
1578 if (paintsBoxDecorations() || paintsChildren()) | |
1579 return false; | |
1580 | |
1581 if (renderObject->isRenderRegion()) | |
1582 return false; | |
1583 | |
1584 if (renderObject->node() && renderObject->node()->isDocumentNode()) { | |
1585 // Look to see if the root object has a non-simple background | |
1586 RenderObject* rootObject = renderObject->document().documentElement() ?
renderObject->document().documentElement()->renderer() : 0; | |
1587 if (!rootObject) | |
1588 return false; | |
1589 | |
1590 RenderStyle* style = rootObject->style(); | |
1591 | |
1592 // Reject anything that has a border, a border-radius or outline, | |
1593 // or is not a simple background (no background, or solid color). | |
1594 if (hasBoxDecorationsOrBackgroundImage(style)) | |
1595 return false; | |
1596 | |
1597 // Now look at the body's renderer. | |
1598 HTMLElement* body = renderObject->document().body(); | |
1599 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body-
>renderer() : 0; | |
1600 if (!bodyObject) | |
1601 return false; | |
1602 | |
1603 style = bodyObject->style(); | |
1604 | |
1605 if (hasBoxDecorationsOrBackgroundImage(style)) | |
1606 return false; | |
1607 } | |
1608 | |
1609 return true; | |
1610 } | |
1611 | |
1612 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent) | 1522 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent) |
1613 { | 1523 { |
1614 if (!parent->hasVisibleDescendant()) | 1524 if (!parent->hasVisibleDescendant()) |
1615 return false; | 1525 return false; |
1616 | 1526 |
1617 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. | 1527 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. |
1618 parent->stackingNode()->updateLayerListsIfNeeded(); | 1528 parent->stackingNode()->updateLayerListsIfNeeded(); |
1619 | 1529 |
1620 #if !ASSERT_DISABLED | 1530 #if !ASSERT_DISABLED |
1621 LayerListMutationDetector mutationChecker(parent->stackingNode()); | 1531 LayerListMutationDetector mutationChecker(parent->stackingNode()); |
(...skipping 12 matching lines...) Expand all Loading... |
1634 } | 1544 } |
1635 | 1545 |
1636 // FIXME: By name the implementation is correct. But the code that uses this fun
ction means something | 1546 // FIXME: By name the implementation is correct. But the code that uses this fun
ction means something |
1637 // very slightly different - the implementation needs to also include composited
descendants that | 1547 // very slightly different - the implementation needs to also include composited
descendants that |
1638 // don't paint into their own backing, and instead paint into this backing. | 1548 // don't paint into their own backing, and instead paint into this backing. |
1639 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const | 1549 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const |
1640 { | 1550 { |
1641 return hasVisibleNonCompositingDescendant(m_owningLayer); | 1551 return hasVisibleNonCompositingDescendant(m_owningLayer); |
1642 } | 1552 } |
1643 | 1553 |
1644 bool CompositedLayerMapping::containsPaintedContent(bool isSimpleContainer) cons
t | 1554 bool CompositedLayerMapping::containsPaintedContent() const |
1645 { | 1555 { |
1646 if (isSimpleContainer || paintsIntoCompositedAncestor() || m_artificiallyInf
latedBounds || m_owningLayer->isReflection()) | 1556 if (paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owni
ngLayer->isReflection()) |
1647 return false; | 1557 return false; |
1648 | 1558 |
1649 if (isDirectlyCompositedImage()) | 1559 if (isDirectlyCompositedImage()) |
1650 return false; | 1560 return false; |
1651 | 1561 |
| 1562 RenderObject* renderObject = renderer(); |
1652 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, | 1563 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, |
1653 // and set background color on the layer in that case, instead of allocating
backing store and painting. | 1564 // and set background color on the layer in that case, instead of allocating
backing store and painting. |
1654 if (renderer()->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo()
) | 1565 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo
()) |
1655 return m_owningLayer->hasBoxDecorationsOrBackground(); | 1566 return m_owningLayer->hasBoxDecorationsOrBackground(); |
1656 | 1567 |
1657 return true; | 1568 if (m_owningLayer->hasVisibleBoxDecorations()) |
| 1569 return true; |
| 1570 |
| 1571 if (renderObject->hasMask()) // masks require special treatment |
| 1572 return true; |
| 1573 |
| 1574 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject)) |
| 1575 return true; |
| 1576 |
| 1577 if (renderObject->isRenderRegion()) |
| 1578 return true; |
| 1579 |
| 1580 if (renderObject->node() && renderObject->node()->isDocumentNode()) { |
| 1581 // Look to see if the root object has a non-simple background |
| 1582 RenderObject* rootObject = renderObject->document().documentElement() ?
renderObject->document().documentElement()->renderer() : 0; |
| 1583 // Reject anything that has a border, a border-radius or outline, |
| 1584 // or is not a simple background (no background, or solid color). |
| 1585 if (rootObject && hasBoxDecorationsOrBackgroundImage(rootObject->style()
)) |
| 1586 return true; |
| 1587 |
| 1588 // Now look at the body's renderer. |
| 1589 HTMLElement* body = renderObject->document().body(); |
| 1590 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body-
>renderer() : 0; |
| 1591 if (bodyObject && hasBoxDecorationsOrBackgroundImage(bodyObject->style()
)) |
| 1592 return true; |
| 1593 } |
| 1594 |
| 1595 // FIXME: it's O(n^2). A better solution is needed. |
| 1596 return paintsChildren(); |
1658 } | 1597 } |
1659 | 1598 |
1660 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations | 1599 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations |
1661 // that require painting. Direct compositing saves backing store. | 1600 // that require painting. Direct compositing saves backing store. |
1662 bool CompositedLayerMapping::isDirectlyCompositedImage() const | 1601 bool CompositedLayerMapping::isDirectlyCompositedImage() const |
1663 { | 1602 { |
1664 RenderObject* renderObject = renderer(); | 1603 RenderObject* renderObject = renderer(); |
1665 | 1604 |
1666 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground
() || renderObject->hasClip()) | 1605 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground
() || renderObject->hasClip()) |
1667 return false; | 1606 return false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1703 Image* image = cachedImage->imageForRenderer(imageRenderer); | 1642 Image* image = cachedImage->imageForRenderer(imageRenderer); |
1704 if (!image) | 1643 if (!image) |
1705 return; | 1644 return; |
1706 | 1645 |
1707 // We have to wait until the image is fully loaded before setting it on the
layer. | 1646 // We have to wait until the image is fully loaded before setting it on the
layer. |
1708 if (!cachedImage->isLoaded()) | 1647 if (!cachedImage->isLoaded()) |
1709 return; | 1648 return; |
1710 | 1649 |
1711 // This is a no-op if the layer doesn't have an inner layer for the image. | 1650 // This is a no-op if the layer doesn't have an inner layer for the image. |
1712 m_graphicsLayer->setContentsToImage(image); | 1651 m_graphicsLayer->setContentsToImage(image); |
1713 bool isSimpleContainer = false; | 1652 updateDrawsContent(); |
1714 updateDrawsContent(isSimpleContainer); | |
1715 | 1653 |
1716 // Image animation is "lazy", in that it automatically stops unless someone
is drawing | 1654 // Image animation is "lazy", in that it automatically stops unless someone
is drawing |
1717 // the image. So we have to kick the animation each time; this has the downs
ide that the | 1655 // the image. So we have to kick the animation each time; this has the downs
ide that the |
1718 // image will keep animating, even if its layer is not visible. | 1656 // image will keep animating, even if its layer is not visible. |
1719 image->startAnimation(); | 1657 image->startAnimation(); |
1720 } | 1658 } |
1721 | 1659 |
1722 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const | 1660 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const |
1723 { | 1661 { |
1724 RenderStyle* style = renderer()->style(); | 1662 RenderStyle* style = renderer()->style(); |
(...skipping 26 matching lines...) Expand all Loading... |
1751 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()); | 1689 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()); |
1752 } | 1690 } |
1753 | 1691 |
1754 LayoutRect CompositedLayerMapping::contentsBox() const | 1692 LayoutRect CompositedLayerMapping::contentsBox() const |
1755 { | 1693 { |
1756 LayoutRect contentsBox = contentsRect(renderer()); | 1694 LayoutRect contentsBox = contentsRect(renderer()); |
1757 contentsBox.move(contentOffsetInCompostingLayer()); | 1695 contentsBox.move(contentOffsetInCompostingLayer()); |
1758 return contentsBox; | 1696 return contentsBox; |
1759 } | 1697 } |
1760 | 1698 |
1761 IntRect CompositedLayerMapping::backgroundBox() const | |
1762 { | |
1763 LayoutRect backgroundBox = backgroundRect(renderer()); | |
1764 backgroundBox.move(contentOffsetInCompostingLayer()); | |
1765 return pixelSnappedIntRect(backgroundBox); | |
1766 } | |
1767 | |
1768 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const | 1699 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const |
1769 { | 1700 { |
1770 if (m_scrollingContentsLayer) | 1701 if (m_scrollingContentsLayer) |
1771 return m_scrollingContentsLayer.get(); | 1702 return m_scrollingContentsLayer.get(); |
1772 | 1703 |
1773 if (m_childContainmentLayer) | 1704 if (m_childContainmentLayer) |
1774 return m_childContainmentLayer.get(); | 1705 return m_childContainmentLayer.get(); |
1775 | 1706 |
1776 if (m_childTransformLayer) | 1707 if (m_childTransformLayer) |
1777 return m_childTransformLayer.get(); | 1708 return m_childTransformLayer.get(); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2118 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2188 name = "Scrolling Contents Layer"; | 2119 name = "Scrolling Contents Layer"; |
2189 } else { | 2120 } else { |
2190 ASSERT_NOT_REACHED(); | 2121 ASSERT_NOT_REACHED(); |
2191 } | 2122 } |
2192 | 2123 |
2193 return name; | 2124 return name; |
2194 } | 2125 } |
2195 | 2126 |
2196 } // namespace WebCore | 2127 } // namespace WebCore |
OLD | NEW |