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