Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 for (const RenderLayer* curr = compositingContainer(); curr; curr = curr->co mpositingContainer()) { | 1128 for (const RenderLayer* curr = compositingContainer(); curr; curr = curr->co mpositingContainer()) { |
| 1129 if (curr->compositingState() == PaintsIntoOwnBacking || curr->compositin gState() == PaintsIntoGroupedBacking) | 1129 if (curr->compositingState() == PaintsIntoOwnBacking || curr->compositin gState() == PaintsIntoGroupedBacking) |
| 1130 return const_cast<RenderLayer*>(curr); | 1130 return const_cast<RenderLayer*>(curr); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 return 0; | 1133 return 0; |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 RenderLayer* RenderLayer::ancestorCompositedScrollingLayer() const | 1136 RenderLayer* RenderLayer::ancestorCompositedScrollingLayer() const |
| 1137 { | 1137 { |
| 1138 ASSERT(isAllowedToQueryCompositingState()); | 1138 ASSERT(isInCompositingUpdate()); |
|
Ian Vollick
2014/03/20 19:26:48
Changed the assert to enforce access only during c
| |
| 1139 | 1139 |
| 1140 if (!renderer()->acceleratedCompositingForOverflowScrollEnabled()) | 1140 if (!renderer()->acceleratedCompositingForOverflowScrollEnabled()) |
| 1141 return 0; | 1141 return 0; |
| 1142 | 1142 |
| 1143 if (m_ancestorDependentPropertyCache && m_ancestorDependentPropertyCache->co ntainingBlock) | |
| 1144 return m_ancestorDependentPropertyCache->ancestorCompositedScrollingLaye r; | |
|
Ian Vollick
2014/03/20 19:26:48
The old code made no use of the containing block.
| |
| 1145 | |
| 1143 RenderObject* containingBlock = renderer()->containingBlock(); | 1146 RenderObject* containingBlock = renderer()->containingBlock(); |
| 1144 if (!containingBlock) | 1147 if (!containingBlock) |
| 1145 return 0; | 1148 return 0; |
| 1146 | 1149 |
| 1150 const_cast<RenderLayer*>(this)->m_ancestorDependentPropertyCache = adoptPtr( new AncestorDependentPropertyCache()); | |
|
abarth-chromium
2014/03/20 20:04:54
The pattern we usually use for this is a function
Ian Vollick
2014/03/20 21:32:21
Done.
| |
| 1151 m_ancestorDependentPropertyCache->containingBlock = containingBlock; | |
| 1152 | |
| 1153 RenderLayer* ancestorCompositedScrollingLayer = 0; | |
| 1147 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { | 1154 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { |
| 1148 if (ancestorLayer->needsCompositedScrolling()) | 1155 if (ancestorLayer->needsCompositedScrolling()) { |
| 1149 return ancestorLayer; | 1156 ancestorCompositedScrollingLayer = ancestorLayer; |
| 1157 break; | |
| 1158 } | |
| 1150 } | 1159 } |
| 1151 | 1160 |
| 1152 return 0; | 1161 m_ancestorDependentPropertyCache->ancestorCompositedScrollingLayer = ancesto rCompositedScrollingLayer; |
| 1162 return ancestorCompositedScrollingLayer; | |
| 1153 } | 1163 } |
| 1154 | 1164 |
| 1155 RenderLayer* RenderLayer::ancestorScrollingLayer() const | 1165 RenderLayer* RenderLayer::ancestorScrollingLayer() const |
| 1156 { | 1166 { |
| 1157 RenderObject* containingBlock = renderer()->containingBlock(); | 1167 RenderObject* containingBlock = renderer()->containingBlock(); |
| 1158 if (!containingBlock) | 1168 if (!containingBlock) |
| 1159 return 0; | 1169 return 0; |
| 1160 | 1170 |
| 1161 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { | 1171 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { |
| 1162 if (ancestorLayer->scrollsOverflow()) | 1172 if (ancestorLayer->scrollsOverflow()) |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1662 | 1672 |
| 1663 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR ect& rect) const | 1673 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR ect& rect) const |
| 1664 { | 1674 { |
| 1665 LayoutPoint delta; | 1675 LayoutPoint delta; |
| 1666 convertToLayerCoords(ancestorLayer, delta); | 1676 convertToLayerCoords(ancestorLayer, delta); |
| 1667 rect.move(-delta.x(), -delta.y()); | 1677 rect.move(-delta.x(), -delta.y()); |
| 1668 } | 1678 } |
| 1669 | 1679 |
| 1670 RenderLayer* RenderLayer::scrollParent() const | 1680 RenderLayer* RenderLayer::scrollParent() const |
| 1671 { | 1681 { |
| 1682 ASSERT(isInCompositingUpdate()); | |
|
Ian Vollick
2014/03/20 19:26:48
Again, enforce that we access scrollParent only du
| |
| 1683 | |
| 1672 if (!renderer()->compositorDrivenAcceleratedScrollingEnabled()) | 1684 if (!renderer()->compositorDrivenAcceleratedScrollingEnabled()) |
| 1673 return 0; | 1685 return 0; |
| 1674 | 1686 |
| 1675 // Normal flow elements will be parented under the main scrolling layer, so | 1687 // Normal flow elements will be parented under the main scrolling layer, so |
| 1676 // we don't need a scroll parent/child relationship to get them to scroll. | 1688 // we don't need a scroll parent/child relationship to get them to scroll. |
| 1677 if (stackingNode()->isNormalFlowOnly()) | 1689 if (stackingNode()->isNormalFlowOnly()) |
| 1678 return 0; | 1690 return 0; |
| 1679 | 1691 |
| 1680 // A layer scrolls with its containing block. So to find the overflow scroll ing layer | 1692 // A layer scrolls with its containing block. So to find the overflow scroll ing layer |
| 1681 // that we scroll with respect to, we must ascend the layer tree until we re ach the | 1693 // that we scroll with respect to, we must ascend the layer tree until we re ach the |
| 1682 // first overflow scrolling div at or above our containing block. I will ref er to this | 1694 // first overflow scrolling div at or above our containing block. I will ref er to this |
| 1683 // layer as our 'scrolling ancestor'. | 1695 // layer as our 'scrolling ancestor'. |
| 1684 // | 1696 // |
| 1685 // Now, if we reside in a normal flow list, then we will naturally scroll wi th our scrolling | 1697 // Now, if we reside in a normal flow list, then we will naturally scroll wi th our scrolling |
| 1686 // ancestor, and we need not be composited. If, on the other hand, we reside in a z-order | 1698 // ancestor, and we need not be composited. If, on the other hand, we reside in a z-order |
| 1687 // list, and on our walk upwards to our scrolling ancestor we find no layer that is a stacking | 1699 // list, and on our walk upwards to our scrolling ancestor we find no layer that is a stacking |
| 1688 // context, then we know that in the stacking tree, we will not be in the su btree rooted at | 1700 // context, then we know that in the stacking tree, we will not be in the su btree rooted at |
| 1689 // our scrolling ancestor, and we will therefore not scroll with it. In this case, we must | 1701 // our scrolling ancestor, and we will therefore not scroll with it. In this case, we must |
| 1690 // be a composited layer since the compositor will need to take special meas ures to ensure | 1702 // be a composited layer since the compositor will need to take special meas ures to ensure |
| 1691 // that we scroll with our scrolling ancestor and it cannot do this if we do not promote. | 1703 // that we scroll with our scrolling ancestor and it cannot do this if we do not promote. |
| 1704 if (m_ancestorDependentPropertyCache) | |
| 1705 return m_ancestorDependentPropertyCache->scrollParent; | |
|
abarth-chromium
2014/03/20 20:04:54
Isn't it possible for m_ancestorDependentPropertyC
Ian Vollick
2014/03/20 21:32:21
It is possible, yes. If we've computed a valid con
| |
| 1706 | |
| 1692 RenderLayer* scrollParent = ancestorCompositedScrollingLayer(); | 1707 RenderLayer* scrollParent = ancestorCompositedScrollingLayer(); |
| 1693 | |
| 1694 if (!scrollParent || scrollParent->stackingNode()->isStackingContainer()) | 1708 if (!scrollParent || scrollParent->stackingNode()->isStackingContainer()) |
| 1695 return 0; | 1709 return 0; |
| 1696 | 1710 |
| 1697 // If we hit a stacking context on our way up to the ancestor scrolling laye r, it will already | 1711 // If we hit a stacking context on our way up to the ancestor scrolling laye r, it will already |
| 1698 // be composited due to an overflow scrolling parent, so we don't need to. | 1712 // be composited due to an overflow scrolling parent, so we don't need to. |
| 1699 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent; ancestor = ancestor->parent()) { | 1713 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent; ancestor = ancestor->parent()) { |
| 1700 if (ancestor->stackingNode()->isStackingContainer()) | 1714 if (ancestor->stackingNode()->isStackingContainer()) |
| 1701 return 0; | 1715 return 0; |
| 1716 if (AncestorDependentPropertyCache* ancestorCache = ancestor->m_ancestor DependentPropertyCache.get()) { | |
| 1717 if (ancestorCache->ancestorCompositedScrollingLayer == scrollParent) { | |
| 1718 scrollParent = ancestorCache->scrollParent; | |
| 1719 break; | |
| 1720 } | |
| 1721 } | |
| 1702 } | 1722 } |
| 1703 | 1723 |
| 1724 m_ancestorDependentPropertyCache->scrollParent = scrollParent; | |
| 1704 return scrollParent; | 1725 return scrollParent; |
| 1705 } | 1726 } |
| 1706 | 1727 |
| 1707 RenderLayer* RenderLayer::clipParent() const | 1728 RenderLayer* RenderLayer::clipParent() const |
| 1708 { | 1729 { |
| 1709 if (compositingReasons() & CompositingReasonOutOfFlowClipping && !compositor ()->clippedByAncestor(this)) { | 1730 if (compositingReasons() & CompositingReasonOutOfFlowClipping && !compositor ()->clippedByAncestor(this)) { |
| 1710 if (RenderObject* containingBlock = renderer()->containingBlock()) | 1731 if (RenderObject* containingBlock = renderer()->containingBlock()) |
| 1711 return containingBlock->enclosingLayer()->enclosingCompositingLayer( ); | 1732 return containingBlock->enclosingLayer()->enclosingCompositingLayer( ); |
| 1712 } | 1733 } |
| 1713 return 0; | 1734 return 0; |
| (...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3513 return PaintsIntoOwnBacking; | 3534 return PaintsIntoOwnBacking; |
| 3514 } | 3535 } |
| 3515 | 3536 |
| 3516 bool RenderLayer::isAllowedToQueryCompositingState() const | 3537 bool RenderLayer::isAllowedToQueryCompositingState() const |
| 3517 { | 3538 { |
| 3518 if (gCompositingQueryMode == CompositingQueriesAreAllowed) | 3539 if (gCompositingQueryMode == CompositingQueriesAreAllowed) |
| 3519 return true; | 3540 return true; |
| 3520 return renderer()->document().lifecycle().state() >= DocumentLifecycle::InCo mpositingUpdate; | 3541 return renderer()->document().lifecycle().state() >= DocumentLifecycle::InCo mpositingUpdate; |
| 3521 } | 3542 } |
| 3522 | 3543 |
| 3544 bool RenderLayer::isInCompositingUpdate() const | |
| 3545 { | |
| 3546 if (gCompositingQueryMode == CompositingQueriesAreAllowed) | |
| 3547 return true; | |
|
abarth-chromium
2014/03/20 20:04:54
Doesn't this mean these functions could be called
Ian Vollick
2014/03/20 21:32:21
Removed the ability to disable this. Since scrollP
| |
| 3548 return renderer()->document().lifecycle().state() == DocumentLifecycle::InCo mpositingUpdate; | |
| 3549 } | |
| 3550 | |
| 3523 CompositedLayerMappingPtr RenderLayer::compositedLayerMapping() const | 3551 CompositedLayerMappingPtr RenderLayer::compositedLayerMapping() const |
| 3524 { | 3552 { |
| 3525 ASSERT(isAllowedToQueryCompositingState()); | 3553 ASSERT(isAllowedToQueryCompositingState()); |
| 3526 return m_compositedLayerMapping.get(); | 3554 return m_compositedLayerMapping.get(); |
| 3527 } | 3555 } |
| 3528 | 3556 |
| 3529 CompositedLayerMappingPtr RenderLayer::ensureCompositedLayerMapping() | 3557 CompositedLayerMappingPtr RenderLayer::ensureCompositedLayerMapping() |
| 3530 { | 3558 { |
| 3531 if (!m_compositedLayerMapping) { | 3559 if (!m_compositedLayerMapping) { |
| 3532 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(*this)); | 3560 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(*this)); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4052 rects.set(this, rect); | 4080 rects.set(this, rect); |
| 4053 } | 4081 } |
| 4054 } | 4082 } |
| 4055 } | 4083 } |
| 4056 | 4084 |
| 4057 DisableCompositingQueryAsserts::DisableCompositingQueryAsserts() | 4085 DisableCompositingQueryAsserts::DisableCompositingQueryAsserts() |
| 4058 : m_disabler(gCompositingQueryMode, CompositingQueriesAreAllowed) { } | 4086 : m_disabler(gCompositingQueryMode, CompositingQueriesAreAllowed) { } |
| 4059 | 4087 |
| 4060 COMPILE_ASSERT(1 << RenderLayer::ViewportConstrainedNotCompositedReasonBits >= R enderLayer::NumNotCompositedReasons, too_many_viewport_constrained_not_compositi ng_reasons); | 4088 COMPILE_ASSERT(1 << RenderLayer::ViewportConstrainedNotCompositedReasonBits >= R enderLayer::NumNotCompositedReasons, too_many_viewport_constrained_not_compositi ng_reasons); |
| 4061 | 4089 |
| 4090 RenderLayer::AncestorDependentPropertyCache::AncestorDependentPropertyCache() | |
| 4091 : containingBlock(0) | |
| 4092 , ancestorCompositedScrollingLayer(0) | |
| 4093 , scrollParent(0) { } | |
| 4094 | |
| 4062 } // namespace WebCore | 4095 } // namespace WebCore |
| 4063 | 4096 |
| 4064 #ifndef NDEBUG | 4097 #ifndef NDEBUG |
| 4065 void showLayerTree(const WebCore::RenderLayer* layer) | 4098 void showLayerTree(const WebCore::RenderLayer* layer) |
| 4066 { | 4099 { |
| 4067 if (!layer) | 4100 if (!layer) |
| 4068 return; | 4101 return; |
| 4069 | 4102 |
| 4070 if (WebCore::LocalFrame* frame = layer->renderer()->frame()) { | 4103 if (WebCore::LocalFrame* frame = layer->renderer()->frame()) { |
| 4071 WTF::String output = externalRepresentation(frame, WebCore::RenderAsText ShowAllLayers | WebCore::RenderAsTextShowLayerNesting | WebCore::RenderAsTextSho wCompositedLayers | WebCore::RenderAsTextShowAddresses | WebCore::RenderAsTextSh owIDAndClass | WebCore::RenderAsTextDontUpdateLayout | WebCore::RenderAsTextShow LayoutState); | 4104 WTF::String output = externalRepresentation(frame, WebCore::RenderAsText ShowAllLayers | WebCore::RenderAsTextShowLayerNesting | WebCore::RenderAsTextSho wCompositedLayers | WebCore::RenderAsTextShowAddresses | WebCore::RenderAsTextSh owIDAndClass | WebCore::RenderAsTextDontUpdateLayout | WebCore::RenderAsTextShow LayoutState); |
| 4072 fprintf(stderr, "%s\n", output.utf8().data()); | 4105 fprintf(stderr, "%s\n", output.utf8().data()); |
| 4073 } | 4106 } |
| 4074 } | 4107 } |
| 4075 | 4108 |
| 4076 void showLayerTree(const WebCore::RenderObject* renderer) | 4109 void showLayerTree(const WebCore::RenderObject* renderer) |
| 4077 { | 4110 { |
| 4078 if (!renderer) | 4111 if (!renderer) |
| 4079 return; | 4112 return; |
| 4080 showLayerTree(renderer->enclosingLayer()); | 4113 showLayerTree(renderer->enclosingLayer()); |
| 4081 } | 4114 } |
| 4082 #endif | 4115 #endif |
| OLD | NEW |