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 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 | |
637 m_owningLayer->updateDescendantDependentFlags(); | 635 m_owningLayer->updateDescendantDependentFlags(); |
638 | 636 |
639 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a nd its non-compositing | 637 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a nd its non-compositing |
640 // descendants. So, the visibility flag for m_graphicsLayer should be true i f there are any | 638 // descendants. So, the visibility flag for m_graphicsLayer should be true i f there are any |
641 // non-compositing visible layers. | 639 // non-compositing visible layers. |
642 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo mpositingDescendantLayers(); | 640 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo mpositingDescendantLayers(); |
643 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i sVideo()) { | 641 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i sVideo()) { |
644 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node()); | 642 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node()); |
645 if (mediaElement->isFullscreen()) | 643 if (mediaElement->isFullscreen()) |
646 contentsVisible = false; | 644 contentsVisible = false; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 | 842 |
845 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping | 843 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping |
846 // since it depends on whether compAncestor draws content, which gets update d later. | 844 // since it depends on whether compAncestor draws content, which gets update d later. |
847 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); | 845 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); |
848 | 846 |
849 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { | 847 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { |
850 updateLayerBlendMode(style); | 848 updateLayerBlendMode(style); |
851 updateIsRootForIsolatedGroup(); | 849 updateIsRootForIsolatedGroup(); |
852 } | 850 } |
853 | 851 |
854 updateContentsRect(isSimpleContainer); | 852 updateContentsRect(); |
855 updateBackgroundColor(isSimpleContainer); | 853 updateBackgroundColor(); |
856 updateDrawsContent(isSimpleContainer); | 854 updateDrawsContent(); |
857 updateContentsOpaque(); | 855 updateContentsOpaque(); |
858 updateAfterWidgetResize(); | 856 updateAfterWidgetResize(); |
859 updateRenderingContext(); | 857 updateRenderingContext(); |
860 updateShouldFlattenTransform(); | 858 updateShouldFlattenTransform(); |
861 updateChildrenTransform(); | 859 updateChildrenTransform(); |
862 registerScrollingLayers(); | 860 registerScrollingLayers(); |
863 | 861 |
864 updateCompositingReasons(); | 862 updateCompositingReasons(); |
865 } | 863 } |
866 | 864 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
931 | 929 |
932 if (m_ancestorClippingLayer) | 930 if (m_ancestorClippingLayer) |
933 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ; | 931 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ; |
934 else | 932 else |
935 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); | 933 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); |
936 | 934 |
937 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); | 935 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); |
938 } | 936 } |
939 } | 937 } |
940 | 938 |
941 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) | 939 void CompositedLayerMapping::updateContentsRect() |
942 { | 940 { |
943 LayoutRect contentsRect; | 941 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox())); |
944 if (isSimpleContainer && renderer()->hasBackground()) | |
945 contentsRect = backgroundBox(); | |
946 else | |
947 contentsRect = contentsBox(); | |
948 | |
949 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsRect)); | |
950 } | 942 } |
951 | 943 |
952 void CompositedLayerMapping::updateDrawsContent(bool isSimpleContainer) | 944 void CompositedLayerMapping::updateDrawsContent() |
953 { | 945 { |
954 if (m_scrollingLayer) { | 946 if (m_scrollingLayer) { |
955 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere. | 947 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere. |
956 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint. | 948 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint. |
957 // m_scrollingLayer never has backing store. | 949 // m_scrollingLayer never has backing store. |
958 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint. | 950 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint. |
959 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent() && m_owningLayer->hasBoxDecorationsOrBackground(); | 951 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent() && m_owningLayer->hasBoxDecorationsOrBackground(); |
960 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); | 952 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); |
961 | 953 |
962 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() && (renderer()->hasBackground() || paintsChildren()); | 954 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() && (renderer()->hasBackground() || paintsChildren()); |
963 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); | 955 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); |
964 return; | 956 return; |
965 } | 957 } |
966 | 958 |
967 bool hasPaintedContent = containsPaintedContent(isSimpleContainer); | 959 bool hasPaintedContent = containsPaintedContent(); |
968 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { | 960 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { |
969 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext(); | 961 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext(); |
970 // Content layer may be null if context is lost. | 962 // Content layer may be null if context is lost. |
971 if (blink::WebLayer* contentLayer = context->platformLayer()) { | 963 if (blink::WebLayer* contentLayer = context->platformLayer()) { |
972 Color bgColor(Color::transparent); | 964 Color bgColor(Color::transparent); |
973 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { | 965 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { |
974 bgColor = rendererBackgroundColor(); | 966 bgColor = rendererBackgroundColor(); |
975 hasPaintedContent = false; | 967 hasPaintedContent = false; |
976 } | 968 } |
977 contentLayer->setBackgroundColor(bgColor.rgb()); | 969 contentLayer->setBackgroundColor(bgColor.rgb()); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1491 | 1483 |
1492 Color CompositedLayerMapping::rendererBackgroundColor() const | 1484 Color CompositedLayerMapping::rendererBackgroundColor() const |
1493 { | 1485 { |
1494 RenderObject* backgroundRenderer = renderer(); | 1486 RenderObject* backgroundRenderer = renderer(); |
1495 if (backgroundRenderer->isRoot()) | 1487 if (backgroundRenderer->isRoot()) |
1496 backgroundRenderer = backgroundRenderer->rendererForRootBackground(); | 1488 backgroundRenderer = backgroundRenderer->rendererForRootBackground(); |
1497 | 1489 |
1498 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor); | 1490 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor); |
1499 } | 1491 } |
1500 | 1492 |
1501 void CompositedLayerMapping::updateBackgroundColor(bool isSimpleContainer) | 1493 void CompositedLayerMapping::updateBackgroundColor() |
1502 { | 1494 { |
1503 Color backgroundColor = rendererBackgroundColor(); | 1495 m_graphicsLayer->setBackgroundColor(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; | |
1540 } | 1496 } |
1541 | 1497 |
1542 bool CompositedLayerMapping::paintsChildren() const | 1498 bool CompositedLayerMapping::paintsChildren() const |
1543 { | 1499 { |
1544 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen derers()) | 1500 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen derers()) |
1545 return true; | 1501 return true; |
1546 | 1502 |
1547 if (hasVisibleNonCompositingDescendantLayers()) | 1503 if (hasVisibleNonCompositingDescendantLayers()) |
1548 return true; | 1504 return true; |
1549 | 1505 |
1550 return false; | 1506 return false; |
1551 } | 1507 } |
1552 | 1508 |
1553 static bool isCompositedPlugin(RenderObject* renderer) | 1509 static bool isCompositedPlugin(RenderObject* renderer) |
1554 { | 1510 { |
1555 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all owsAcceleratedCompositing(); | 1511 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all owsAcceleratedCompositing(); |
1556 } | 1512 } |
1557 | 1513 |
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 | |
1604 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent) | 1514 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent) |
1605 { | 1515 { |
1606 if (!parent->hasVisibleDescendant()) | 1516 if (!parent->hasVisibleDescendant()) |
1607 return false; | 1517 return false; |
1608 | 1518 |
1609 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. | 1519 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. |
1610 parent->stackingNode()->updateLayerListsIfNeeded(); | 1520 parent->stackingNode()->updateLayerListsIfNeeded(); |
1611 | 1521 |
1612 #if !ASSERT_DISABLED | 1522 #if !ASSERT_DISABLED |
1613 LayerListMutationDetector mutationChecker(parent->stackingNode()); | 1523 LayerListMutationDetector mutationChecker(parent->stackingNode()); |
(...skipping 12 matching lines...) Expand all Loading... | |
1626 } | 1536 } |
1627 | 1537 |
1628 // FIXME: By name the implementation is correct. But the code that uses this fun ction means something | 1538 // FIXME: By name the implementation is correct. But the code that uses this fun ction means something |
1629 // very slightly different - the implementation needs to also include composited descendants that | 1539 // very slightly different - the implementation needs to also include composited descendants that |
1630 // don't paint into their own backing, and instead paint into this backing. | 1540 // don't paint into their own backing, and instead paint into this backing. |
1631 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const | 1541 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const |
1632 { | 1542 { |
1633 return hasVisibleNonCompositingDescendant(m_owningLayer); | 1543 return hasVisibleNonCompositingDescendant(m_owningLayer); |
1634 } | 1544 } |
1635 | 1545 |
1636 bool CompositedLayerMapping::containsPaintedContent(bool isSimpleContainer) cons t | 1546 bool CompositedLayerMapping::containsPaintedContent() const |
1637 { | 1547 { |
1638 if (isSimpleContainer || paintsIntoCompositedAncestor() || m_artificiallyInf latedBounds || m_owningLayer->isReflection()) | 1548 if (paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owni ngLayer->isReflection()) |
1639 return false; | 1549 return false; |
1640 | 1550 |
1641 if (isDirectlyCompositedImage()) | 1551 if (isDirectlyCompositedImage()) |
1642 return false; | 1552 return false; |
1643 | 1553 |
1554 RenderObject* renderObject = renderer(); | |
1644 // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely, | 1555 // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely, |
1645 // and set background color on the layer in that case, instead of allocating backing store and painting. | 1556 // and set background color on the layer in that case, instead of allocating backing store and painting. |
1646 if (renderer()->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo() ) | 1557 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo ()) |
1647 return m_owningLayer->hasBoxDecorationsOrBackground(); | 1558 return m_owningLayer->hasBoxDecorationsOrBackground(); |
1648 | 1559 |
1649 return true; | 1560 if (m_owningLayer->hasVisibleBoxDecorations()) |
1561 return true; | |
1562 | |
1563 if (renderObject->hasMask()) // masks require special treatment | |
1564 return true; | |
1565 | |
1566 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject)) | |
1567 return true; | |
1568 | |
1569 if (renderObject->isRenderRegion()) | |
1570 return true; | |
1571 | |
1572 if (renderObject->node() && renderObject->node()->isDocumentNode() && render Object->document().documentElement()) { | |
alokp
2014/03/04 19:19:04
nit: I prefer the original code.
RenderObject* roo
| |
1573 // Look to see if the root object has a non-simple background | |
1574 RenderObject* rootObject = renderObject->document().documentElement()->r enderer(); | |
1575 // Reject anything that has a border, a border-radius or outline, | |
1576 // or is not a simple background (no background, or solid color). | |
1577 if (rootObject && hasBoxDecorationsOrBackgroundImage(rootObject->style() )) | |
1578 return true; | |
1579 | |
1580 // Now look at the body's renderer. | |
1581 HTMLElement* body = renderObject->document().body(); | |
1582 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body- >renderer() : 0; | |
1583 if (bodyObject && hasBoxDecorationsOrBackgroundImage(bodyObject->style() )) | |
1584 return true; | |
1585 } | |
1586 | |
1587 // FIXME: it's O(n^2). A better solution is needed. | |
1588 return paintsChildren(); | |
1650 } | 1589 } |
1651 | 1590 |
1652 // An image can be directly compositing if it's the sole content of the layer, a nd has no box decorations | 1591 // An image can be directly compositing if it's the sole content of the layer, a nd has no box decorations |
1653 // that require painting. Direct compositing saves backing store. | 1592 // that require painting. Direct compositing saves backing store. |
1654 bool CompositedLayerMapping::isDirectlyCompositedImage() const | 1593 bool CompositedLayerMapping::isDirectlyCompositedImage() const |
1655 { | 1594 { |
1656 RenderObject* renderObject = renderer(); | 1595 RenderObject* renderObject = renderer(); |
1657 | 1596 |
1658 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground () || renderObject->hasClip()) | 1597 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground () || renderObject->hasClip()) |
1659 return false; | 1598 return false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1695 Image* image = cachedImage->imageForRenderer(imageRenderer); | 1634 Image* image = cachedImage->imageForRenderer(imageRenderer); |
1696 if (!image) | 1635 if (!image) |
1697 return; | 1636 return; |
1698 | 1637 |
1699 // We have to wait until the image is fully loaded before setting it on the layer. | 1638 // We have to wait until the image is fully loaded before setting it on the layer. |
1700 if (!cachedImage->isLoaded()) | 1639 if (!cachedImage->isLoaded()) |
1701 return; | 1640 return; |
1702 | 1641 |
1703 // This is a no-op if the layer doesn't have an inner layer for the image. | 1642 // This is a no-op if the layer doesn't have an inner layer for the image. |
1704 m_graphicsLayer->setContentsToImage(image); | 1643 m_graphicsLayer->setContentsToImage(image); |
1705 bool isSimpleContainer = false; | 1644 updateDrawsContent(); |
1706 updateDrawsContent(isSimpleContainer); | |
1707 | 1645 |
1708 // Image animation is "lazy", in that it automatically stops unless someone is drawing | 1646 // Image animation is "lazy", in that it automatically stops unless someone is drawing |
1709 // the image. So we have to kick the animation each time; this has the downs ide that the | 1647 // the image. So we have to kick the animation each time; this has the downs ide that the |
1710 // image will keep animating, even if its layer is not visible. | 1648 // image will keep animating, even if its layer is not visible. |
1711 image->startAnimation(); | 1649 image->startAnimation(); |
1712 } | 1650 } |
1713 | 1651 |
1714 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde rBox) const | 1652 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde rBox) const |
1715 { | 1653 { |
1716 RenderStyle* style = renderer()->style(); | 1654 RenderStyle* style = renderer()->style(); |
(...skipping 26 matching lines...) Expand all Loading... | |
1743 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()); | 1681 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()); |
1744 } | 1682 } |
1745 | 1683 |
1746 LayoutRect CompositedLayerMapping::contentsBox() const | 1684 LayoutRect CompositedLayerMapping::contentsBox() const |
1747 { | 1685 { |
1748 LayoutRect contentsBox = contentsRect(renderer()); | 1686 LayoutRect contentsBox = contentsRect(renderer()); |
1749 contentsBox.move(contentOffsetInCompostingLayer()); | 1687 contentsBox.move(contentOffsetInCompostingLayer()); |
1750 return contentsBox; | 1688 return contentsBox; |
1751 } | 1689 } |
1752 | 1690 |
1753 IntRect CompositedLayerMapping::backgroundBox() const | |
1754 { | |
1755 LayoutRect backgroundBox = backgroundRect(renderer()); | |
1756 backgroundBox.move(contentOffsetInCompostingLayer()); | |
1757 return pixelSnappedIntRect(backgroundBox); | |
1758 } | |
1759 | |
1760 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const | 1691 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const |
1761 { | 1692 { |
1762 if (m_scrollingContentsLayer) | 1693 if (m_scrollingContentsLayer) |
1763 return m_scrollingContentsLayer.get(); | 1694 return m_scrollingContentsLayer.get(); |
1764 | 1695 |
1765 if (m_childContainmentLayer) | 1696 if (m_childContainmentLayer) |
1766 return m_childContainmentLayer.get(); | 1697 return m_childContainmentLayer.get(); |
1767 | 1698 |
1768 if (m_childTransformLayer) | 1699 if (m_childTransformLayer) |
1769 return m_childTransformLayer.get(); | 1700 return m_childTransformLayer.get(); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2157 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2088 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2158 name = "Scrolling Contents Layer"; | 2089 name = "Scrolling Contents Layer"; |
2159 } else { | 2090 } else { |
2160 ASSERT_NOT_REACHED(); | 2091 ASSERT_NOT_REACHED(); |
2161 } | 2092 } |
2162 | 2093 |
2163 return name; | 2094 return name; |
2164 } | 2095 } |
2165 | 2096 |
2166 } // namespace WebCore | 2097 } // namespace WebCore |
OLD | NEW |