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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 return const_cast<RenderLayer*>(this); | 1075 return const_cast<RenderLayer*>(this); |
1076 | 1076 |
1077 for (const RenderLayer* curr = compositingContainer(); curr; curr = curr->co
mpositingContainer()) { | 1077 for (const RenderLayer* curr = compositingContainer(); curr; curr = curr->co
mpositingContainer()) { |
1078 if (curr->isRepaintContainer()) | 1078 if (curr->isRepaintContainer()) |
1079 return const_cast<RenderLayer*>(curr); | 1079 return const_cast<RenderLayer*>(curr); |
1080 } | 1080 } |
1081 | 1081 |
1082 return 0; | 1082 return 0; |
1083 } | 1083 } |
1084 | 1084 |
1085 RenderLayer* RenderLayer::ancestorCompositedScrollingLayer() const | |
1086 { | |
1087 if (!compositor()->acceleratedCompositingForOverflowScrollEnabled()) | |
1088 return 0; | |
1089 | |
1090 RenderObject* containingBlock = renderer()->containingBlock(); | |
1091 if (!containingBlock) | |
1092 return 0; | |
1093 | |
1094 RenderLayer* ancestorCompositedScrollingLayer = 0; | |
1095 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto
rLayer; ancestorLayer = ancestorLayer->parent()) { | |
1096 if (ancestorLayer->needsCompositedScrolling()) { | |
1097 ancestorCompositedScrollingLayer = ancestorLayer; | |
1098 break; | |
1099 } | |
1100 } | |
1101 | |
1102 return ancestorCompositedScrollingLayer; | |
1103 } | |
1104 | |
1105 RenderLayer* RenderLayer::ancestorScrollingLayer() const | 1085 RenderLayer* RenderLayer::ancestorScrollingLayer() const |
1106 { | 1086 { |
1107 RenderObject* containingBlock = renderer()->containingBlock(); | 1087 RenderObject* containingBlock = renderer()->containingBlock(); |
1108 if (!containingBlock) | 1088 if (!containingBlock) |
1109 return 0; | 1089 return 0; |
1110 | 1090 |
1111 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto
rLayer; ancestorLayer = ancestorLayer->parent()) { | 1091 for (RenderLayer* ancestorLayer = containingBlock->enclosingLayer(); ancesto
rLayer; ancestorLayer = ancestorLayer->parent()) { |
1112 if (ancestorLayer->scrollsOverflow()) | 1092 if (ancestorLayer->scrollsOverflow()) |
1113 return ancestorLayer; | 1093 return ancestorLayer; |
1114 } | 1094 } |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 | 1575 |
1596 RenderLayer* RenderLayer::scrollParent() const | 1576 RenderLayer* RenderLayer::scrollParent() const |
1597 { | 1577 { |
1598 ASSERT(compositor()->acceleratedCompositingForOverflowScrollEnabled()); | 1578 ASSERT(compositor()->acceleratedCompositingForOverflowScrollEnabled()); |
1599 | 1579 |
1600 // Normal flow elements will be parented under the main scrolling layer, so | 1580 // Normal flow elements will be parented under the main scrolling layer, so |
1601 // we don't need a scroll parent/child relationship to get them to scroll. | 1581 // we don't need a scroll parent/child relationship to get them to scroll. |
1602 if (stackingNode()->isNormalFlowOnly()) | 1582 if (stackingNode()->isNormalFlowOnly()) |
1603 return 0; | 1583 return 0; |
1604 | 1584 |
1605 // A layer scrolls with its containing block. So to find the overflow scroll
ing layer | 1585 if (!parent()) |
1606 // that we scroll with respect to, we must ascend the layer tree until we re
ach the | |
1607 // first overflow scrolling div at or above our containing block. I will ref
er to this | |
1608 // layer as our 'scrolling ancestor'. | |
1609 // | |
1610 // Now, if we reside in a normal flow list, then we will naturally scroll wi
th our scrolling | |
1611 // ancestor, and we need not be composited. If, on the other hand, we reside
in a z-order | |
1612 // list, and on our walk upwards to our scrolling ancestor we find no layer
that is a stacking | |
1613 // context, then we know that in the stacking tree, we will not be in the su
btree rooted at | |
1614 // our scrolling ancestor, and we will therefore not scroll with it. In this
case, we must | |
1615 // be a composited layer since the compositor will need to take special meas
ures to ensure | |
1616 // that we scroll with our scrolling ancestor and it cannot do this if we do
not promote. | |
1617 | |
1618 RenderLayer* scrollParent = ancestorCompositedScrollingLayer(); | |
1619 if (!scrollParent || scrollParent->stackingNode()->isStackingContext()) | |
1620 return 0; | 1586 return 0; |
1621 | 1587 |
1622 // If we hit a stacking context on our way up to the ancestor scrolling laye
r, it will already | 1588 for (RenderLayer* current = renderer()->containingBlock()->enclosingLayer();
!current->stackingNode()->isStackingContext(); current = current->renderer()->c
ontainingBlock()->enclosingLayer()) { |
1623 // be composited due to an overflow scrolling parent, so we don't need to. | 1589 if (current->scrollsOverflow()) |
1624 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent;
ancestor = ancestor->parent()) { | 1590 return current; |
1625 if (ancestor->stackingNode()->isStackingContext()) { | |
1626 scrollParent = 0; | |
1627 break; | |
1628 } | |
1629 } | 1591 } |
1630 | 1592 |
1631 return scrollParent; | 1593 return 0; |
1632 } | 1594 } |
1633 | 1595 |
1634 RenderLayer* RenderLayer::clipParent() const | 1596 RenderLayer* RenderLayer::clipParent() const |
1635 { | 1597 { |
1636 if (compositingReasons() & CompositingReasonOutOfFlowClipping && !compositor
()->clippedByNonAncestorInStackingTree(this)) { | 1598 if (compositingReasons() & CompositingReasonOutOfFlowClipping && !compositor
()->clippedByNonAncestorInStackingTree(this)) { |
1637 if (RenderObject* containingBlock = renderer()->containingBlock()) | 1599 if (RenderObject* containingBlock = renderer()->containingBlock()) |
1638 return containingBlock->enclosingLayer()->enclosingCompositingLayer(
); | 1600 return containingBlock->enclosingLayer()->enclosingCompositingLayer(
); |
1639 } | 1601 } |
1640 return 0; | 1602 return 0; |
1641 } | 1603 } |
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3861 } | 3823 } |
3862 } | 3824 } |
3863 | 3825 |
3864 void showLayerTree(const WebCore::RenderObject* renderer) | 3826 void showLayerTree(const WebCore::RenderObject* renderer) |
3865 { | 3827 { |
3866 if (!renderer) | 3828 if (!renderer) |
3867 return; | 3829 return; |
3868 showLayerTree(renderer->enclosingLayer()); | 3830 showLayerTree(renderer->enclosingLayer()); |
3869 } | 3831 } |
3870 #endif | 3832 #endif |
OLD | NEW |