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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 RenderLayer::RenderLayer(RenderLayerModelObject* renderer) | 108 RenderLayer::RenderLayer(RenderLayerModelObject* renderer) |
109 : m_normalFlowListDirty(true) | 109 : m_normalFlowListDirty(true) |
110 , m_hasSelfPaintingLayerDescendant(false) | 110 , m_hasSelfPaintingLayerDescendant(false) |
111 , m_hasSelfPaintingLayerDescendantDirty(false) | 111 , m_hasSelfPaintingLayerDescendantDirty(false) |
112 , m_hasOutOfFlowPositionedDescendant(false) | 112 , m_hasOutOfFlowPositionedDescendant(false) |
113 , m_hasOutOfFlowPositionedDescendantDirty(true) | 113 , m_hasOutOfFlowPositionedDescendantDirty(true) |
114 , m_hasUnclippedDescendant(false) | 114 , m_hasUnclippedDescendant(false) |
115 , m_isUnclippedDescendant(false) | 115 , m_isUnclippedDescendant(false) |
116 , m_needsCompositedScrolling(false) | 116 , m_needsCompositedScrolling(false) |
117 , m_needsCompositedScrollingHasBeenRecorded(false) | 117 , m_needsToBeStackingContainerHasBeenRecorded(false) |
118 , m_willUseCompositedScrollingHasBeenRecorded(false) | 118 , m_willUseCompositedScrollingHasBeenRecorded(false) |
119 , m_isScrollableAreaHasBeenRecorded(false) | 119 , m_isScrollableAreaHasBeenRecorded(false) |
120 , m_canBePromotedToStackingContainer(false) | 120 , m_needsToBeStackingContainer(false) |
121 , m_canBePromotedToStackingContainerDirty(true) | 121 , m_descendantsAreContiguousInStackingOrder(false) |
| 122 , m_descendantsAreContiguousInStackingOrderDirty(true) |
122 , m_isRootLayer(renderer->isRenderView()) | 123 , m_isRootLayer(renderer->isRenderView()) |
123 , m_usedTransparency(false) | 124 , m_usedTransparency(false) |
124 , m_childLayerHasBlendMode(false) | 125 , m_childLayerHasBlendMode(false) |
125 , m_childLayerHasBlendModeStatusDirty(false) | 126 , m_childLayerHasBlendModeStatusDirty(false) |
126 , m_paintingInsideReflection(false) | 127 , m_paintingInsideReflection(false) |
127 , m_visibleContentStatusDirty(true) | 128 , m_visibleContentStatusDirty(true) |
128 , m_hasVisibleContent(false) | 129 , m_hasVisibleContent(false) |
129 , m_visibleDescendantStatusDirty(false) | 130 , m_visibleDescendantStatusDirty(false) |
130 , m_hasVisibleDescendant(false) | 131 , m_hasVisibleDescendant(false) |
131 , m_isPaginated(false) | 132 , m_isPaginated(false) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return false; | 404 return false; |
404 | 405 |
405 const Settings* settings = renderer()->document().settings(); | 406 const Settings* settings = renderer()->document().settings(); |
406 return settings && settings->isCompositorDrivenAcceleratedScrollingEnabled()
; | 407 return settings && settings->isCompositorDrivenAcceleratedScrollingEnabled()
; |
407 } | 408 } |
408 | 409 |
409 // Determine whether the current layer can be promoted to a stacking container. | 410 // Determine whether the current layer can be promoted to a stacking container. |
410 // We do this by computing what positive and negative z-order lists would look | 411 // We do this by computing what positive and negative z-order lists would look |
411 // like before and after promotion, and ensuring that proper stacking order is | 412 // like before and after promotion, and ensuring that proper stacking order is |
412 // preserved between the two sets of lists. | 413 // preserved between the two sets of lists. |
413 void RenderLayer::updateCanBeStackingContainer() | 414 void RenderLayer::updateDescendantsAreContiguousInStackingOrder() |
414 { | 415 { |
415 TRACE_EVENT0("blink_rendering,comp-scroll", "RenderLayer::updateCanBeStackin
gContainer"); | 416 TRACE_EVENT0("blink_rendering,comp-scroll", "RenderLayer::updateDescendantsA
reContiguousInStackingOrder"); |
416 | 417 |
417 if (isStackingContext() || !m_canBePromotedToStackingContainerDirty || !acce
leratedCompositingForOverflowScrollEnabled()) | 418 if (isStackingContext() || !m_descendantsAreContiguousInStackingOrderDirty |
| !acceleratedCompositingForOverflowScrollEnabled()) |
418 return; | 419 return; |
419 | 420 |
420 FrameView* frameView = renderer()->view()->frameView(); | 421 FrameView* frameView = renderer()->view()->frameView(); |
421 if (!frameView || !frameView->containsScrollableArea(scrollableArea())) | 422 if (!frameView || !frameView->containsScrollableArea(scrollableArea())) |
422 return; | 423 return; |
423 | 424 |
424 RenderLayer* ancestorStackingContext = this->ancestorStackingContext(); | 425 RenderLayer* ancestorStackingContext = this->ancestorStackingContext(); |
425 if (!ancestorStackingContext) | 426 if (!ancestorStackingContext) |
426 return; | 427 return; |
427 | 428 |
428 OwnPtr<Vector<RenderLayer*> > posZOrderListBeforePromote = adoptPtr(new Vect
or<RenderLayer*>); | 429 OwnPtr<Vector<RenderLayer*> > posZOrderListBeforePromote = adoptPtr(new Vect
or<RenderLayer*>); |
429 OwnPtr<Vector<RenderLayer*> > negZOrderListBeforePromote = adoptPtr(new Vect
or<RenderLayer*>); | 430 OwnPtr<Vector<RenderLayer*> > negZOrderListBeforePromote = adoptPtr(new Vect
or<RenderLayer*>); |
430 OwnPtr<Vector<RenderLayer*> > posZOrderListAfterPromote = adoptPtr(new Vecto
r<RenderLayer*>); | 431 OwnPtr<Vector<RenderLayer*> > posZOrderListAfterPromote = adoptPtr(new Vecto
r<RenderLayer*>); |
431 OwnPtr<Vector<RenderLayer*> > negZOrderListAfterPromote = adoptPtr(new Vecto
r<RenderLayer*>); | 432 OwnPtr<Vector<RenderLayer*> > negZOrderListAfterPromote = adoptPtr(new Vecto
r<RenderLayer*>); |
432 | 433 |
433 collectBeforePromotionZOrderList(ancestorStackingContext, posZOrderListBefor
ePromote, negZOrderListBeforePromote); | 434 collectBeforePromotionZOrderList(ancestorStackingContext, posZOrderListBefor
ePromote, negZOrderListBeforePromote); |
434 collectAfterPromotionZOrderList(ancestorStackingContext, posZOrderListAfterP
romote, negZOrderListAfterPromote); | 435 collectAfterPromotionZOrderList(ancestorStackingContext, posZOrderListAfterP
romote, negZOrderListAfterPromote); |
435 | 436 |
436 size_t maxIndex = std::min(posZOrderListAfterPromote->size() + negZOrderList
AfterPromote->size(), posZOrderListBeforePromote->size() + negZOrderListBeforePr
omote->size()); | 437 size_t maxIndex = std::min(posZOrderListAfterPromote->size() + negZOrderList
AfterPromote->size(), posZOrderListBeforePromote->size() + negZOrderListBeforePr
omote->size()); |
437 | 438 |
438 m_canBePromotedToStackingContainerDirty = false; | 439 m_descendantsAreContiguousInStackingOrderDirty = false; |
439 m_canBePromotedToStackingContainer = false; | 440 m_descendantsAreContiguousInStackingOrder = false; |
440 | 441 |
441 const RenderLayer* layerAfterPromote = 0; | 442 const RenderLayer* layerAfterPromote = 0; |
442 for (size_t i = 0; i < maxIndex && layerAfterPromote != this; ++i) { | 443 for (size_t i = 0; i < maxIndex && layerAfterPromote != this; ++i) { |
443 const RenderLayer* layerBeforePromote = i < negZOrderListBeforePromote->
size() | 444 const RenderLayer* layerBeforePromote = i < negZOrderListBeforePromote->
size() |
444 ? negZOrderListBeforePromote->at(i) | 445 ? negZOrderListBeforePromote->at(i) |
445 : posZOrderListBeforePromote->at(i - negZOrderListBeforePromote->siz
e()); | 446 : posZOrderListBeforePromote->at(i - negZOrderListBeforePromote->siz
e()); |
446 layerAfterPromote = i < negZOrderListAfterPromote->size() | 447 layerAfterPromote = i < negZOrderListAfterPromote->size() |
447 ? negZOrderListAfterPromote->at(i) | 448 ? negZOrderListAfterPromote->at(i) |
448 : posZOrderListAfterPromote->at(i - negZOrderListAfterPromote->size(
)); | 449 : posZOrderListAfterPromote->at(i - negZOrderListAfterPromote->size(
)); |
449 | 450 |
450 if (layerBeforePromote != layerAfterPromote && (layerAfterPromote != thi
s || renderer()->hasBackground())) | 451 if (layerBeforePromote != layerAfterPromote && (layerAfterPromote != thi
s || renderer()->hasBackground())) |
451 return; | 452 return; |
452 } | 453 } |
453 | 454 |
454 layerAfterPromote = 0; | 455 layerAfterPromote = 0; |
455 for (size_t i = 0; i < maxIndex && layerAfterPromote != this; ++i) { | 456 for (size_t i = 0; i < maxIndex && layerAfterPromote != this; ++i) { |
456 const RenderLayer* layerBeforePromote = i < posZOrderListBeforePromote->
size() | 457 const RenderLayer* layerBeforePromote = i < posZOrderListBeforePromote->
size() |
457 ? posZOrderListBeforePromote->at(posZOrderListBeforePromote->size()
- i - 1) | 458 ? posZOrderListBeforePromote->at(posZOrderListBeforePromote->size()
- i - 1) |
458 : negZOrderListBeforePromote->at(negZOrderListBeforePromote->size()
+ posZOrderListBeforePromote->size() - i - 1); | 459 : negZOrderListBeforePromote->at(negZOrderListBeforePromote->size()
+ posZOrderListBeforePromote->size() - i - 1); |
459 layerAfterPromote = i < posZOrderListAfterPromote->size() | 460 layerAfterPromote = i < posZOrderListAfterPromote->size() |
460 ? posZOrderListAfterPromote->at(posZOrderListAfterPromote->size() -
i - 1) | 461 ? posZOrderListAfterPromote->at(posZOrderListAfterPromote->size() -
i - 1) |
461 : negZOrderListAfterPromote->at(negZOrderListAfterPromote->size() +
posZOrderListAfterPromote->size() - i - 1); | 462 : negZOrderListAfterPromote->at(negZOrderListAfterPromote->size() +
posZOrderListAfterPromote->size() - i - 1); |
462 | 463 |
463 if (layerBeforePromote != layerAfterPromote && layerAfterPromote != this
) | 464 if (layerBeforePromote != layerAfterPromote && layerAfterPromote != this
) |
464 return; | 465 return; |
465 } | 466 } |
466 | 467 |
467 m_canBePromotedToStackingContainer = true; | 468 m_descendantsAreContiguousInStackingOrder = true; |
468 } | 469 } |
469 | 470 |
470 static inline bool isPositionedContainer(const RenderLayer* layer) | 471 static inline bool isPositionedContainer(const RenderLayer* layer) |
471 { | 472 { |
472 // FIXME: This is not in sync with containingBlock. | 473 // FIXME: This is not in sync with containingBlock. |
473 // RenderObject::canContainFixedPositionedObject() should probably be used | 474 // RenderObject::canContainFixedPositionedObject() should probably be used |
474 // instead. | 475 // instead. |
475 RenderLayerModelObject* layerRenderer = layer->renderer(); | 476 RenderLayerModelObject* layerRenderer = layer->renderer(); |
476 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr
ansform(); | 477 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr
ansform(); |
477 } | 478 } |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { | 899 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { |
899 if (curr->renderer()->hasColumns()) { | 900 if (curr->renderer()->hasColumns()) { |
900 m_isPaginated = checkContainingBlockChainForPagination(renderer(), c
urr->renderBox()); | 901 m_isPaginated = checkContainingBlockChainForPagination(renderer(), c
urr->renderBox()); |
901 return; | 902 return; |
902 } | 903 } |
903 if (curr == ancestorStackingContainer) | 904 if (curr == ancestorStackingContainer) |
904 return; | 905 return; |
905 } | 906 } |
906 } | 907 } |
907 | 908 |
908 bool RenderLayer::canBeStackingContainer() const | 909 bool RenderLayer::descendantsAreContiguousInStackingOrder() const |
909 { | 910 { |
910 if (isStackingContext() || !ancestorStackingContainer()) | 911 if (isStackingContext() || !ancestorStackingContainer()) |
911 return true; | 912 return true; |
912 | 913 |
913 ASSERT(!m_canBePromotedToStackingContainerDirty); | 914 ASSERT(!m_descendantsAreContiguousInStackingOrderDirty); |
914 return m_canBePromotedToStackingContainer; | 915 return m_descendantsAreContiguousInStackingOrder; |
915 } | 916 } |
916 | 917 |
917 void RenderLayer::setHasVisibleContent() | 918 void RenderLayer::setHasVisibleContent() |
918 { | 919 { |
919 if (m_hasVisibleContent && !m_visibleContentStatusDirty) { | 920 if (m_hasVisibleContent && !m_visibleContentStatusDirty) { |
920 ASSERT(!parent() || parent()->hasVisibleDescendant()); | 921 ASSERT(!parent() || parent()->hasVisibleDescendant()); |
921 return; | 922 return; |
922 } | 923 } |
923 | 924 |
924 m_visibleContentStatusDirty = false; | 925 m_visibleContentStatusDirty = false; |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 // requirements since we may be able to mark more layers as having | 1679 // requirements since we may be able to mark more layers as having |
1679 // an 'unclipped' descendant. | 1680 // an 'unclipped' descendant. |
1680 compositor()->setNeedsUpdateCompositingRequirementsState(); | 1681 compositor()->setNeedsUpdateCompositingRequirementsState(); |
1681 setAncestorChainHasOutOfFlowPositionedDescendant(); | 1682 setAncestorChainHasOutOfFlowPositionedDescendant(); |
1682 } | 1683 } |
1683 | 1684 |
1684 // When we first dirty a layer, we will also dirty all the siblings in that | 1685 // When we first dirty a layer, we will also dirty all the siblings in that |
1685 // layer's stacking context. We need to manually do it here as well, in case | 1686 // layer's stacking context. We need to manually do it here as well, in case |
1686 // we're adding this layer after the stacking context has already been | 1687 // we're adding this layer after the stacking context has already been |
1687 // updated. | 1688 // updated. |
1688 child->m_canBePromotedToStackingContainerDirty = true; | 1689 child->m_descendantsAreContiguousInStackingOrderDirty = true; |
1689 compositor()->layerWasAdded(this, child); | 1690 compositor()->layerWasAdded(this, child); |
1690 } | 1691 } |
1691 | 1692 |
1692 RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) | 1693 RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) |
1693 { | 1694 { |
1694 if (!renderer()->documentBeingDestroyed()) | 1695 if (!renderer()->documentBeingDestroyed()) |
1695 compositor()->layerWillBeRemoved(this, oldChild); | 1696 compositor()->layerWillBeRemoved(this, oldChild); |
1696 | 1697 |
1697 // remove the child | 1698 // remove the child |
1698 if (oldChild->previousSibling()) | 1699 if (oldChild->previousSibling()) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 { | 1944 { |
1944 RenderBox* box = renderBox(); | 1945 RenderBox* box = renderBox(); |
1945 | 1946 |
1946 // Scroll form controls on the main thread so they exhibit correct touch scr
oll event bubbling | 1947 // Scroll form controls on the main thread so they exhibit correct touch scr
oll event bubbling |
1947 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr
isticallyScrollable(HorizontalScrollbar))) | 1948 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr
isticallyScrollable(HorizontalScrollbar))) |
1948 return false; | 1949 return false; |
1949 | 1950 |
1950 return compositedLayerMapping() && compositedLayerMapping()->scrollingLayer(
); | 1951 return compositedLayerMapping() && compositedLayerMapping()->scrollingLayer(
); |
1951 } | 1952 } |
1952 | 1953 |
1953 bool RenderLayer::needsCompositedScrolling() const | 1954 bool RenderLayer::adjustForForceCompositedScrollingMode(bool value) const |
1954 { | |
1955 if (!compositorDrivenAcceleratedScrollingEnabled()) | |
1956 return needsToBeStackingContainer(); | |
1957 if (FrameView* frameView = renderer()->view()->frameView()) | |
1958 return frameView->containsScrollableArea(scrollableArea()); | |
1959 return false; | |
1960 } | |
1961 | |
1962 bool RenderLayer::needsToBeStackingContainer() const | |
1963 { | 1955 { |
1964 switch (m_forceNeedsCompositedScrolling) { | 1956 switch (m_forceNeedsCompositedScrolling) { |
1965 case DoNotForceCompositedScrolling: | 1957 case DoNotForceCompositedScrolling: |
1966 return m_needsCompositedScrolling; | 1958 return value; |
1967 case CompositedScrollingAlwaysOn: | 1959 case CompositedScrollingAlwaysOn: |
1968 return true; | 1960 return true; |
1969 case CompositedScrollingAlwaysOff: | 1961 case CompositedScrollingAlwaysOff: |
1970 return false; | 1962 return false; |
1971 } | 1963 } |
1972 | 1964 |
1973 ASSERT_NOT_REACHED(); | 1965 ASSERT_NOT_REACHED(); |
1974 return m_needsCompositedScrolling; | 1966 return value; |
| 1967 } |
| 1968 |
| 1969 bool RenderLayer::needsCompositedScrolling() const |
| 1970 { |
| 1971 return adjustForForceCompositedScrollingMode(m_needsCompositedScrolling); |
| 1972 } |
| 1973 |
| 1974 bool RenderLayer::needsToBeStackingContainer() const |
| 1975 { |
| 1976 return adjustForForceCompositedScrollingMode(m_needsToBeStackingContainer); |
1975 } | 1977 } |
1976 | 1978 |
1977 RenderLayer* RenderLayer::scrollParent() const | 1979 RenderLayer* RenderLayer::scrollParent() const |
1978 { | 1980 { |
1979 if (!compositorDrivenAcceleratedScrollingEnabled()) | 1981 if (!compositorDrivenAcceleratedScrollingEnabled()) |
1980 return 0; | 1982 return 0; |
1981 | 1983 |
1982 // A layer scrolls with its containing block. So to find the overflow scroll
ing layer | 1984 // A layer scrolls with its containing block. So to find the overflow scroll
ing layer |
1983 // that we scroll with respect to, we must ascend the layer tree until we re
ach the | 1985 // that we scroll with respect to, we must ascend the layer tree until we re
ach the |
1984 // first overflow scrolling div at or above our containing block. I will ref
er to this | 1986 // first overflow scrolling div at or above our containing block. I will ref
er to this |
1985 // layer as our 'scrolling ancestor'. | 1987 // layer as our 'scrolling ancestor'. |
1986 // | 1988 // |
1987 // Now, if we reside in a normal flow list, then we will naturally scroll wi
th our scrolling | 1989 // Now, if we reside in a normal flow list, then we will naturally scroll wi
th our scrolling |
1988 // ancestor, and we need not be composited. If, on the other hand, we reside
in a z-order | 1990 // ancestor, and we need not be composited. If, on the other hand, we reside
in a z-order |
1989 // list, and on our walk upwards to our scrolling ancestor we find no layer
that is a stacking | 1991 // list, and on our walk upwards to our scrolling ancestor we find no layer
that is a stacking |
1990 // context, then we know that in the stacking tree, we will not be in the su
btree rooted at | 1992 // context, then we know that in the stacking tree, we will not be in the su
btree rooted at |
1991 // our scrolling ancestor, and we will therefore not scroll with it. In this
case, we must | 1993 // our scrolling ancestor, and we will therefore not scroll with it. In this
case, we must |
1992 // be a composited layer since the compositor will need to take special meas
ures to ensure | 1994 // be a composited layer since the compositor will need to take special meas
ures to ensure |
1993 // that we scroll with our scrolling ancestor and it cannot do this if we do
not promote. | 1995 // that we scroll with our scrolling ancestor and it cannot do this if we do
not promote. |
1994 RenderLayer* scrollParent = ancestorScrollingLayer(); | 1996 RenderLayer* scrollParent = ancestorScrollingLayer(); |
1995 | 1997 |
1996 if (!scrollParent || scrollParent->isStackingContext()) | 1998 if (!scrollParent || scrollParent->isStackingContainer()) |
1997 return 0; | 1999 return 0; |
1998 | 2000 |
1999 // If we hit a stacking context on our way up to the ancestor scrolling laye
r, it will already | 2001 // If we hit a stacking context on our way up to the ancestor scrolling laye
r, it will already |
2000 // be composited due to an overflow scrolling parent, so we don't need to. | 2002 // be composited due to an overflow scrolling parent, so we don't need to. |
2001 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent;
ancestor = ancestor->parent()) { | 2003 for (RenderLayer* ancestor = parent(); ancestor && ancestor != scrollParent;
ancestor = ancestor->parent()) { |
2002 if (ancestor->isStackingContext()) | 2004 if (ancestor->isStackingContainer()) |
2003 return 0; | 2005 return 0; |
2004 } | 2006 } |
2005 | 2007 |
2006 return scrollParent; | 2008 return scrollParent; |
2007 } | 2009 } |
2008 | 2010 |
2009 RenderLayer* RenderLayer::clipParent() const | 2011 RenderLayer* RenderLayer::clipParent() const |
2010 { | 2012 { |
2011 const bool needsAncestorClip = compositor()->clippedByAncestor(this); | 2013 const bool needsAncestorClip = compositor()->clippedByAncestor(this); |
2012 | 2014 |
2013 RenderLayer* clipParent = 0; | 2015 RenderLayer* clipParent = 0; |
2014 if ((compositingReasons() & CompositingReasonOutOfFlowClipping) && !needsAnc
estorClip) { | 2016 if ((compositingReasons() & CompositingReasonOutOfFlowClipping) && !needsAnc
estorClip) { |
2015 if (RenderObject* containingBlock = renderer()->containingBlock()) | 2017 if (RenderObject* containingBlock = renderer()->containingBlock()) |
2016 clipParent = containingBlock->enclosingLayer()->enclosingCompositing
Layer(true); | 2018 clipParent = containingBlock->enclosingLayer()->enclosingCompositing
Layer(true); |
2017 } | 2019 } |
2018 | 2020 |
2019 return clipParent; | 2021 return clipParent; |
2020 } | 2022 } |
2021 | 2023 |
2022 void RenderLayer::updateNeedsCompositedScrolling() | 2024 void RenderLayer::updateNeedsCompositedScrolling() |
2023 { | 2025 { |
2024 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); | 2026 TRACE_EVENT0("comp-scroll", "RenderLayer::updateNeedsCompositedScrolling"); |
2025 | 2027 |
2026 updateCanBeStackingContainer(); | 2028 updateDescendantsAreContiguousInStackingOrder(); |
2027 updateDescendantDependentFlags(); | 2029 updateDescendantDependentFlags(); |
2028 | 2030 |
2029 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c
ontainsScrollableArea(scrollableArea())); | 2031 ASSERT(renderer()->view()->frameView() && renderer()->view()->frameView()->c
ontainsScrollableArea(scrollableArea())); |
2030 bool needsCompositedScrolling = acceleratedCompositingForOverflowScrollEnabl
ed() | 2032 const bool needsToBeStackingContainer = acceleratedCompositingForOverflowScr
ollEnabled() |
2031 && canBeStackingContainer() | 2033 && descendantsAreContiguousInStackingOrder() |
2032 && !hasUnclippedDescendant(); | 2034 && !hasUnclippedDescendant(); |
2033 | 2035 |
| 2036 const bool needsToBeStackingContainerDidChange = setNeedsToBeStackingContain
er(needsToBeStackingContainer); |
| 2037 |
| 2038 const bool needsCompositedScrolling = needsToBeStackingContainer |
| 2039 || compositorDrivenAcceleratedScrollingEnabled(); |
| 2040 |
2034 // We gather a boolean value for use with Google UMA histograms to | 2041 // We gather a boolean value for use with Google UMA histograms to |
2035 // quantify the actual effects of a set of patches attempting to | 2042 // quantify the actual effects of a set of patches attempting to |
2036 // relax composited scrolling requirements, thereby increasing the | 2043 // relax composited scrolling requirements, thereby increasing the |
2037 // number of composited overflow divs. | 2044 // number of composited overflow divs. |
2038 if (acceleratedCompositingForOverflowScrollEnabled()) | 2045 if (acceleratedCompositingForOverflowScrollEnabled()) |
2039 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScrollin
g", needsCompositedScrolling, 2); | 2046 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScrollin
g", needsCompositedScrolling, 2); |
2040 | 2047 |
2041 setNeedsCompositedScrolling(needsCompositedScrolling); | 2048 const bool needsCompositedScrollingDidChange = setNeedsCompositedScrolling(n
eedsCompositedScrolling); |
| 2049 |
| 2050 if (needsToBeStackingContainerDidChange || needsCompositedScrollingDidChange
) { |
| 2051 // Note, the z-order lists may need to be rebuilt, but our code guarante
es |
| 2052 // that we have not affected stacking, so we will not dirty |
| 2053 // m_descendantsAreContiguousInStackingOrder for either us or our stacki
ng |
| 2054 // context or container. |
| 2055 didUpdateNeedsCompositedScrolling(); |
| 2056 } |
2042 } | 2057 } |
2043 | 2058 |
2044 enum CompositedScrollingHistogramBuckets { | 2059 enum CompositedScrollingHistogramBuckets { |
2045 IsScrollableAreaBucket = 0, | 2060 IsScrollableAreaBucket = 0, |
2046 NeedsToBeStackingContainerBucket = 1, | 2061 NeedsToBeStackingContainerBucket = 1, |
2047 WillUseCompositedScrollingBucket = 2, | 2062 WillUseCompositedScrollingBucket = 2, |
2048 CompositedScrollingHistogramMax = 3 | 2063 CompositedScrollingHistogramMax = 3 |
2049 }; | 2064 }; |
2050 | 2065 |
2051 void RenderLayer::setNeedsCompositedScrolling(bool needsCompositedScrolling) | 2066 bool RenderLayer::setNeedsCompositedScrolling(bool needsCompositedScrolling) |
2052 { | 2067 { |
2053 if (m_needsCompositedScrolling == needsCompositedScrolling) | 2068 if (m_needsCompositedScrolling == needsCompositedScrolling) |
2054 return; | 2069 return false; |
2055 | |
2056 // Count the total number of RenderLayers which need to be stacking | |
2057 // containers some point. This should be recorded at most once per | |
2058 // RenderLayer, so we check m_needsCompositedScrollingHasBeenRecorded. | |
2059 if (acceleratedCompositingForOverflowScrollEnabled() && !m_needsCompositedSc
rollingHasBeenRecorded) { | |
2060 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", N
eedsToBeStackingContainerBucket, CompositedScrollingHistogramMax); | |
2061 m_needsCompositedScrollingHasBeenRecorded = true; | |
2062 } | |
2063 | 2070 |
2064 // Count the total number of RenderLayers which need composited scrolling at | 2071 // Count the total number of RenderLayers which need composited scrolling at |
2065 // some point. This should be recorded at most once per RenderLayer, so we | 2072 // some point. This should be recorded at most once per RenderLayer, so we |
2066 // check m_willUseCompositedScrollingHasBeenRecorded. | 2073 // check m_willUseCompositedScrollingHasBeenRecorded. |
2067 // | |
2068 // FIXME: Currently, this computes the exact same value as the above. | |
2069 // However, it will soon be expanded to cover more than just stacking | |
2070 // containers (see crbug.com/249354). When this happens, we should see a | |
2071 // spike in "WillUseCompositedScrolling", while "NeedsToBeStackingContainer" | |
2072 // will remain relatively static. | |
2073 if (acceleratedCompositingForOverflowScrollEnabled() && !m_willUseComposited
ScrollingHasBeenRecorded) { | 2074 if (acceleratedCompositingForOverflowScrollEnabled() && !m_willUseComposited
ScrollingHasBeenRecorded) { |
2074 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", W
illUseCompositedScrollingBucket, CompositedScrollingHistogramMax); | 2075 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", W
illUseCompositedScrollingBucket, CompositedScrollingHistogramMax); |
2075 m_willUseCompositedScrollingHasBeenRecorded = true; | 2076 m_willUseCompositedScrollingHasBeenRecorded = true; |
2076 } | 2077 } |
2077 | 2078 |
2078 m_needsCompositedScrolling = needsCompositedScrolling; | 2079 m_needsCompositedScrolling = needsCompositedScrolling; |
2079 | 2080 |
2080 // Note, the z-order lists may need to be rebuilt, but our code guarantees | 2081 return true; |
2081 // that we have not affected stacking, so we will not dirty | 2082 } |
2082 // m_canBePromotedToStackingContainer for either us or our stacking context | 2083 |
2083 // or container. | 2084 bool RenderLayer::setNeedsToBeStackingContainer(bool needsToBeStackingContainer) |
2084 didUpdateNeedsCompositedScrolling(); | 2085 { |
| 2086 if (m_needsToBeStackingContainer == needsToBeStackingContainer) |
| 2087 return false; |
| 2088 |
| 2089 // Count the total number of RenderLayers which need to be stacking |
| 2090 // containers some point. This should be recorded at most once per |
| 2091 // RenderLayer, so we check m_needsToBeStackingContainerHasBeenRecorded. |
| 2092 if (acceleratedCompositingForOverflowScrollEnabled() && !m_needsToBeStacking
ContainerHasBeenRecorded) { |
| 2093 HistogramSupport::histogramEnumeration("Renderer.CompositedScrolling", N
eedsToBeStackingContainerBucket, CompositedScrollingHistogramMax); |
| 2094 m_needsToBeStackingContainerHasBeenRecorded = true; |
| 2095 } |
| 2096 |
| 2097 m_needsToBeStackingContainer = needsToBeStackingContainer; |
| 2098 |
| 2099 return true; |
2085 } | 2100 } |
2086 | 2101 |
2087 void RenderLayer::setForceNeedsCompositedScrolling(RenderLayer::ForceNeedsCompos
itedScrollingMode mode) | 2102 void RenderLayer::setForceNeedsCompositedScrolling(RenderLayer::ForceNeedsCompos
itedScrollingMode mode) |
2088 { | 2103 { |
2089 if (m_forceNeedsCompositedScrolling == mode) | 2104 if (m_forceNeedsCompositedScrolling == mode) |
2090 return; | 2105 return; |
2091 | 2106 |
2092 m_forceNeedsCompositedScrolling = mode; | 2107 m_forceNeedsCompositedScrolling = mode; |
2093 didUpdateNeedsCompositedScrolling(); | 2108 didUpdateNeedsCompositedScrolling(); |
2094 } | 2109 } |
(...skipping 2542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4637 } | 4652 } |
4638 | 4653 |
4639 // Helper for the sorting of layers by z-index. | 4654 // Helper for the sorting of layers by z-index. |
4640 static inline bool compareZIndex(RenderLayer* first, RenderLayer* second) | 4655 static inline bool compareZIndex(RenderLayer* first, RenderLayer* second) |
4641 { | 4656 { |
4642 return first->zIndex() < second->zIndex(); | 4657 return first->zIndex() < second->zIndex(); |
4643 } | 4658 } |
4644 | 4659 |
4645 void RenderLayer::dirtyNormalFlowListCanBePromotedToStackingContainer() | 4660 void RenderLayer::dirtyNormalFlowListCanBePromotedToStackingContainer() |
4646 { | 4661 { |
4647 m_canBePromotedToStackingContainerDirty = true; | 4662 m_descendantsAreContiguousInStackingOrderDirty = true; |
4648 | 4663 |
4649 if (m_normalFlowListDirty || !normalFlowList()) | 4664 if (m_normalFlowListDirty || !normalFlowList()) |
4650 return; | 4665 return; |
4651 | 4666 |
4652 for (size_t index = 0; index < normalFlowList()->size(); ++index) | 4667 for (size_t index = 0; index < normalFlowList()->size(); ++index) |
4653 normalFlowList()->at(index)->dirtyNormalFlowListCanBePromotedToStackingC
ontainer(); | 4668 normalFlowList()->at(index)->dirtyNormalFlowListCanBePromotedToStackingC
ontainer(); |
4654 } | 4669 } |
4655 | 4670 |
4656 void RenderLayer::dirtySiblingStackingContextCanBePromotedToStackingContainer() | 4671 void RenderLayer::dirtySiblingStackingContextCanBePromotedToStackingContainer() |
4657 { | 4672 { |
4658 RenderLayer* ancestorStackingContext = this->ancestorStackingContext(); | 4673 RenderLayer* ancestorStackingContext = this->ancestorStackingContext(); |
4659 if (!ancestorStackingContext) | 4674 if (!ancestorStackingContext) |
4660 return; | 4675 return; |
4661 | 4676 |
4662 if (!ancestorStackingContext->m_zOrderListsDirty && ancestorStackingContext-
>posZOrderList()) { | 4677 if (!ancestorStackingContext->m_zOrderListsDirty && ancestorStackingContext-
>posZOrderList()) { |
4663 for (size_t index = 0; index < ancestorStackingContext->posZOrderList()-
>size(); ++index) | 4678 for (size_t index = 0; index < ancestorStackingContext->posZOrderList()-
>size(); ++index) |
4664 ancestorStackingContext->posZOrderList()->at(index)->m_canBePromoted
ToStackingContainerDirty = true; | 4679 ancestorStackingContext->posZOrderList()->at(index)->m_descendantsAr
eContiguousInStackingOrderDirty = true; |
4665 } | 4680 } |
4666 | 4681 |
4667 ancestorStackingContext->dirtyNormalFlowListCanBePromotedToStackingContainer
(); | 4682 ancestorStackingContext->dirtyNormalFlowListCanBePromotedToStackingContainer
(); |
4668 | 4683 |
4669 if (!ancestorStackingContext->m_zOrderListsDirty && ancestorStackingContext-
>negZOrderList()) { | 4684 if (!ancestorStackingContext->m_zOrderListsDirty && ancestorStackingContext-
>negZOrderList()) { |
4670 for (size_t index = 0; index < ancestorStackingContext->negZOrderList()-
>size(); ++index) | 4685 for (size_t index = 0; index < ancestorStackingContext->negZOrderList()-
>size(); ++index) |
4671 ancestorStackingContext->negZOrderList()->at(index)->m_canBePromoted
ToStackingContainerDirty = true; | 4686 ancestorStackingContext->negZOrderList()->at(index)->m_descendantsAr
eContiguousInStackingOrderDirty = true; |
4672 } | 4687 } |
4673 } | 4688 } |
4674 | 4689 |
4675 void RenderLayer::dirtyZOrderLists() | 4690 void RenderLayer::dirtyZOrderLists() |
4676 { | 4691 { |
4677 ASSERT(m_layerListMutationAllowed); | 4692 ASSERT(m_layerListMutationAllowed); |
4678 ASSERT(isStackingContainer()); | 4693 ASSERT(isStackingContainer()); |
4679 | 4694 |
4680 if (m_posZOrderList) | 4695 if (m_posZOrderList) |
4681 m_posZOrderList->clear(); | 4696 m_posZOrderList->clear(); |
4682 if (m_negZOrderList) | 4697 if (m_negZOrderList) |
4683 m_negZOrderList->clear(); | 4698 m_negZOrderList->clear(); |
4684 m_zOrderListsDirty = true; | 4699 m_zOrderListsDirty = true; |
4685 | 4700 |
4686 m_canBePromotedToStackingContainerDirty = true; | 4701 m_descendantsAreContiguousInStackingOrderDirty = true; |
4687 | 4702 |
4688 if (!renderer()->documentBeingDestroyed()) { | 4703 if (!renderer()->documentBeingDestroyed()) { |
4689 compositor()->setNeedsUpdateCompositingRequirementsState(); | 4704 compositor()->setNeedsUpdateCompositingRequirementsState(); |
4690 compositor()->setCompositingLayersNeedRebuild(); | 4705 compositor()->setCompositingLayersNeedRebuild(); |
4691 if (acceleratedCompositingForOverflowScrollEnabled()) | 4706 if (acceleratedCompositingForOverflowScrollEnabled()) |
4692 compositor()->setShouldReevaluateCompositingAfterLayout(); | 4707 compositor()->setShouldReevaluateCompositingAfterLayout(); |
4693 } | 4708 } |
4694 } | 4709 } |
4695 | 4710 |
4696 void RenderLayer::dirtyStackingContainerZOrderLists() | 4711 void RenderLayer::dirtyStackingContainerZOrderLists() |
4697 { | 4712 { |
4698 // Any siblings in the ancestor stacking context could also be affected. | 4713 // Any siblings in the ancestor stacking context could also be affected. |
4699 // Changing z-index, for example, could cause us to stack in between a | 4714 // Changing z-index, for example, could cause us to stack in between a |
4700 // sibling's descendants, meaning that we have to recompute | 4715 // sibling's descendants, meaning that we have to recompute |
4701 // m_canBePromotedToStackingContainer for that sibling. | 4716 // m_descendantsAreContiguousInStackingOrder for that sibling. |
4702 dirtySiblingStackingContextCanBePromotedToStackingContainer(); | 4717 dirtySiblingStackingContextCanBePromotedToStackingContainer(); |
4703 | 4718 |
4704 RenderLayer* stackingContainer = this->ancestorStackingContainer(); | 4719 RenderLayer* stackingContainer = this->ancestorStackingContainer(); |
4705 if (stackingContainer) | 4720 if (stackingContainer) |
4706 stackingContainer->dirtyZOrderLists(); | 4721 stackingContainer->dirtyZOrderLists(); |
4707 | 4722 |
4708 // Any change that could affect our stacking container's z-order list could | 4723 // Any change that could affect our stacking container's z-order list could |
4709 // cause other RenderLayers in our stacking context to either opt in or out | 4724 // cause other RenderLayers in our stacking context to either opt in or out |
4710 // of composited scrolling. It is important that we make our stacking | 4725 // of composited scrolling. It is important that we make our stacking |
4711 // context aware of these z-order changes so the appropriate updating can | 4726 // context aware of these z-order changes so the appropriate updating can |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5576 } | 5591 } |
5577 } | 5592 } |
5578 | 5593 |
5579 void showLayerTree(const WebCore::RenderObject* renderer) | 5594 void showLayerTree(const WebCore::RenderObject* renderer) |
5580 { | 5595 { |
5581 if (!renderer) | 5596 if (!renderer) |
5582 return; | 5597 return; |
5583 showLayerTree(renderer->enclosingLayer()); | 5598 showLayerTree(renderer->enclosingLayer()); |
5584 } | 5599 } |
5585 #endif | 5600 #endif |
OLD | NEW |