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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1126 return const_cast<RenderLayer*>(this); | 1126 return const_cast<RenderLayer*>(this); |
1127 | 1127 |
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 void RenderLayer::clearAncestorDependentPropertyCache() | |
1137 { | |
1138 ASSERT(isInCompositingUpdate()); | |
1139 m_ancestorDependentPropertyCache.clear(); | |
1140 } | |
1141 | |
1142 void RenderLayer::ensureAncestorDependentPropertyCache() const | |
1143 { | |
1144 ASSERT(isInCompositingUpdate()); | |
1145 if (m_ancestorDependentPropertyCache) | |
1146 return; | |
1147 m_ancestorDependentPropertyCache = adoptPtr(new AncestorDependentPropertyCac he()); | |
1148 } | |
1149 | |
1136 RenderLayer* RenderLayer::ancestorCompositedScrollingLayer() const | 1150 RenderLayer* RenderLayer::ancestorCompositedScrollingLayer() const |
1137 { | 1151 { |
1138 ASSERT(isAllowedToQueryCompositingState()); | |
1139 | |
1140 if (!renderer()->acceleratedCompositingForOverflowScrollEnabled()) | 1152 if (!renderer()->acceleratedCompositingForOverflowScrollEnabled()) |
1141 return 0; | 1153 return 0; |
1142 | 1154 |
1155 ASSERT(isInCompositingUpdate() || !m_ancestorDependentPropertyCache); | |
1156 | |
1157 if (m_ancestorDependentPropertyCache && !m_ancestorDependentPropertyCache->a ncestorCompositedScrollingLayerDirty) | |
1158 return m_ancestorDependentPropertyCache->ancestorCompositedScrollingLaye r; | |
1159 | |
1143 RenderObject* containingBlock = renderer()->containingBlock(); | 1160 RenderObject* containingBlock = renderer()->containingBlock(); |
1144 if (!containingBlock) | 1161 if (!containingBlock) |
1145 return 0; | 1162 return 0; |
1146 | 1163 |
1164 if (isInCompositingUpdate()) | |
1165 ensureAncestorDependentPropertyCache(); | |
1166 | |
1167 RenderLayer* ancestorCompositedScrollingLayer = 0; | |
1147 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { | 1168 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { |
1148 if (ancestorLayer->needsCompositedScrolling()) | 1169 if (ancestorLayer->needsCompositedScrolling()) { |
1149 return ancestorLayer; | 1170 ancestorCompositedScrollingLayer = ancestorLayer; |
1171 break; | |
1172 } | |
1150 } | 1173 } |
1151 | 1174 |
1152 return 0; | 1175 if (m_ancestorDependentPropertyCache) { |
1176 m_ancestorDependentPropertyCache->ancestorCompositedScrollingLayer = anc estorCompositedScrollingLayer; | |
1177 m_ancestorDependentPropertyCache->ancestorCompositedScrollingLayerDirty = false; | |
abarth-chromium
2014/03/20 22:49:15
I probably would have made this a setter that enca
Ian Vollick
2014/03/21 00:01:11
Done.
| |
1178 } | |
1179 | |
1180 return ancestorCompositedScrollingLayer; | |
1153 } | 1181 } |
1154 | 1182 |
1155 RenderLayer* RenderLayer::ancestorScrollingLayer() const | 1183 RenderLayer* RenderLayer::ancestorScrollingLayer() const |
1156 { | 1184 { |
1157 RenderObject* containingBlock = renderer()->containingBlock(); | 1185 RenderObject* containingBlock = renderer()->containingBlock(); |
1158 if (!containingBlock) | 1186 if (!containingBlock) |
1159 return 0; | 1187 return 0; |
1160 | 1188 |
1161 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { | 1189 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto rLayer; ancestorLayer = ancestorLayer->parent()) { |
1162 if (ancestorLayer->scrollsOverflow()) | 1190 if (ancestorLayer->scrollsOverflow()) |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1670 RenderLayer* RenderLayer::scrollParent() const | 1698 RenderLayer* RenderLayer::scrollParent() const |
1671 { | 1699 { |
1672 if (!renderer()->compositorDrivenAcceleratedScrollingEnabled()) | 1700 if (!renderer()->compositorDrivenAcceleratedScrollingEnabled()) |
1673 return 0; | 1701 return 0; |
1674 | 1702 |
1675 // Normal flow elements will be parented under the main scrolling layer, so | 1703 // 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. | 1704 // we don't need a scroll parent/child relationship to get them to scroll. |
1677 if (stackingNode()->isNormalFlowOnly()) | 1705 if (stackingNode()->isNormalFlowOnly()) |
1678 return 0; | 1706 return 0; |
1679 | 1707 |
1708 // We should never have an ancestor dependent property cache outside of the | |
1709 // compositing update phase. | |
1710 ASSERT(isInCompositingUpdate() || !m_ancestorDependentPropertyCache); | |
1711 | |
1680 // A layer scrolls with its containing block. So to find the overflow scroll ing layer | 1712 // 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 | 1713 // 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 | 1714 // first overflow scrolling div at or above our containing block. I will ref er to this |
1683 // layer as our 'scrolling ancestor'. | 1715 // layer as our 'scrolling ancestor'. |
1684 // | 1716 // |
1685 // Now, if we reside in a normal flow list, then we will naturally scroll wi th our scrolling | 1717 // 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 | 1718 // 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 | 1719 // 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 | 1720 // 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 | 1721 // 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 | 1722 // 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. | 1723 // that we scroll with our scrolling ancestor and it cannot do this if we do not promote. |
1724 if (m_ancestorDependentPropertyCache && !m_ancestorDependentPropertyCache->s crollParentDirty) | |
1725 return m_ancestorDependentPropertyCache->scrollParent; | |
1726 | |
1692 RenderLayer* scrollParent = ancestorCompositedScrollingLayer(); | 1727 RenderLayer* scrollParent = ancestorCompositedScrollingLayer(); |
1693 | |
1694 if (!scrollParent || scrollParent->stackingNode()->isStackingContainer()) | 1728 if (!scrollParent || scrollParent->stackingNode()->isStackingContainer()) |
1695 return 0; | 1729 return 0; |
1696 | 1730 |
1697 // If we hit a stacking context on our way up to the ancestor scrolling laye r, it will already | 1731 // 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. | 1732 // 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()) { | 1733 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent; ancestor = ancestor->parent()) { |
1700 if (ancestor->stackingNode()->isStackingContainer()) | 1734 if (ancestor->stackingNode()->isStackingContainer()) |
1701 return 0; | 1735 return 0; |
1736 if (!isInCompositingUpdate()) | |
1737 continue; | |
1738 if (AncestorDependentPropertyCache* ancestorCache = ancestor->m_ancestor DependentPropertyCache.get()) { | |
1739 if (ancestorCache->ancestorCompositedScrollingLayer == scrollParent) { | |
abarth-chromium
2014/03/20 22:49:15
Don't we need to check the dirty bit here?
Ian Vollick
2014/03/21 00:01:11
Fixed. While I was adding the setters in response
| |
1740 scrollParent = ancestorCache->scrollParent; | |
1741 break; | |
1742 } | |
1743 } | |
1744 } | |
1745 | |
1746 if (m_ancestorDependentPropertyCache) { | |
1747 m_ancestorDependentPropertyCache->scrollParent = scrollParent; | |
1748 m_ancestorDependentPropertyCache->scrollParentDirty = false; | |
abarth-chromium
2014/03/20 22:49:15
ditto
Ian Vollick
2014/03/21 00:01:11
Done.
| |
1702 } | 1749 } |
1703 | 1750 |
1704 return scrollParent; | 1751 return scrollParent; |
1705 } | 1752 } |
1706 | 1753 |
1707 RenderLayer* RenderLayer::clipParent() const | 1754 RenderLayer* RenderLayer::clipParent() const |
1708 { | 1755 { |
1709 if (compositingReasons() & CompositingReasonOutOfFlowClipping && !compositor ()->clippedByAncestor(this)) { | 1756 if (compositingReasons() & CompositingReasonOutOfFlowClipping && !compositor ()->clippedByAncestor(this)) { |
1710 if (RenderObject* containingBlock = renderer()->containingBlock()) | 1757 if (RenderObject* containingBlock = renderer()->containingBlock()) |
1711 return containingBlock->enclosingLayer()->enclosingCompositingLayer( ); | 1758 return containingBlock->enclosingLayer()->enclosingCompositingLayer( ); |
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3513 return PaintsIntoOwnBacking; | 3560 return PaintsIntoOwnBacking; |
3514 } | 3561 } |
3515 | 3562 |
3516 bool RenderLayer::isAllowedToQueryCompositingState() const | 3563 bool RenderLayer::isAllowedToQueryCompositingState() const |
3517 { | 3564 { |
3518 if (gCompositingQueryMode == CompositingQueriesAreAllowed) | 3565 if (gCompositingQueryMode == CompositingQueriesAreAllowed) |
3519 return true; | 3566 return true; |
3520 return renderer()->document().lifecycle().state() >= DocumentLifecycle::InCo mpositingUpdate; | 3567 return renderer()->document().lifecycle().state() >= DocumentLifecycle::InCo mpositingUpdate; |
3521 } | 3568 } |
3522 | 3569 |
3570 bool RenderLayer::isInCompositingUpdate() const | |
3571 { | |
3572 return renderer()->document().lifecycle().state() == DocumentLifecycle::InCo mpositingUpdate; | |
3573 } | |
3574 | |
3523 CompositedLayerMappingPtr RenderLayer::compositedLayerMapping() const | 3575 CompositedLayerMappingPtr RenderLayer::compositedLayerMapping() const |
3524 { | 3576 { |
3525 ASSERT(isAllowedToQueryCompositingState()); | 3577 ASSERT(isAllowedToQueryCompositingState()); |
3526 return m_compositedLayerMapping.get(); | 3578 return m_compositedLayerMapping.get(); |
3527 } | 3579 } |
3528 | 3580 |
3529 CompositedLayerMappingPtr RenderLayer::ensureCompositedLayerMapping() | 3581 CompositedLayerMappingPtr RenderLayer::ensureCompositedLayerMapping() |
3530 { | 3582 { |
3531 if (!m_compositedLayerMapping) { | 3583 if (!m_compositedLayerMapping) { |
3532 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(*this)); | 3584 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(*this)); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4052 rects.set(this, rect); | 4104 rects.set(this, rect); |
4053 } | 4105 } |
4054 } | 4106 } |
4055 } | 4107 } |
4056 | 4108 |
4057 DisableCompositingQueryAsserts::DisableCompositingQueryAsserts() | 4109 DisableCompositingQueryAsserts::DisableCompositingQueryAsserts() |
4058 : m_disabler(gCompositingQueryMode, CompositingQueriesAreAllowed) { } | 4110 : m_disabler(gCompositingQueryMode, CompositingQueriesAreAllowed) { } |
4059 | 4111 |
4060 COMPILE_ASSERT(1 << RenderLayer::ViewportConstrainedNotCompositedReasonBits >= R enderLayer::NumNotCompositedReasons, too_many_viewport_constrained_not_compositi ng_reasons); | 4112 COMPILE_ASSERT(1 << RenderLayer::ViewportConstrainedNotCompositedReasonBits >= R enderLayer::NumNotCompositedReasons, too_many_viewport_constrained_not_compositi ng_reasons); |
4061 | 4113 |
4114 RenderLayer::AncestorDependentPropertyCache::AncestorDependentPropertyCache() | |
4115 : ancestorCompositedScrollingLayer(0) | |
4116 , scrollParent(0) | |
4117 , ancestorCompositedScrollingLayerDirty(true) | |
4118 , scrollParentDirty(true) { } | |
4119 | |
4062 } // namespace WebCore | 4120 } // namespace WebCore |
4063 | 4121 |
4064 #ifndef NDEBUG | 4122 #ifndef NDEBUG |
4065 void showLayerTree(const WebCore::RenderLayer* layer) | 4123 void showLayerTree(const WebCore::RenderLayer* layer) |
4066 { | 4124 { |
4067 if (!layer) | 4125 if (!layer) |
4068 return; | 4126 return; |
4069 | 4127 |
4070 if (WebCore::LocalFrame* frame = layer->renderer()->frame()) { | 4128 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); | 4129 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()); | 4130 fprintf(stderr, "%s\n", output.utf8().data()); |
4073 } | 4131 } |
4074 } | 4132 } |
4075 | 4133 |
4076 void showLayerTree(const WebCore::RenderObject* renderer) | 4134 void showLayerTree(const WebCore::RenderObject* renderer) |
4077 { | 4135 { |
4078 if (!renderer) | 4136 if (!renderer) |
4079 return; | 4137 return; |
4080 showLayerTree(renderer->enclosingLayer()); | 4138 showLayerTree(renderer->enclosingLayer()); |
4081 } | 4139 } |
4082 #endif | 4140 #endif |
OLD | NEW |