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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 { | 589 { |
| 590 // FIXME: This is not in sync with containingBlock. | 590 // FIXME: This is not in sync with containingBlock. |
| 591 // RenderObject::canContainFixedPositionedObject() should probably be used | 591 // RenderObject::canContainFixedPositionedObject() should probably be used |
| 592 // instead. | 592 // instead. |
| 593 RenderLayerModelObject* layerRenderer = layer->renderer(); | 593 RenderLayerModelObject* layerRenderer = layer->renderer(); |
| 594 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); | 594 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote) | 597 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote) |
| 598 { | 598 { |
| 599 // FIXME: TemporaryChange should support bit fields. | 599 ancestorStackingContext->rebuildZOrderLists(posZOrderListBeforePromote, negZ OrderListBeforePromote, this, AcceleratedCompositingForOverflowScrollDisabled); |
| 600 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | |
| 601 bool oldIsNormalFlowOnly = m_isNormalFlowOnly; | |
| 602 | |
| 603 m_needsCompositedScrolling = false; | |
| 604 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); | |
| 605 | |
| 606 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListBeforePromote, negZOrderListBeforePromote, 0); | |
| 607 | |
| 608 m_needsCompositedScrolling = oldNeedsCompositedScrolling; | |
| 609 m_isNormalFlowOnly = oldIsNormalFlowOnly; | |
| 610 | 600 |
| 611 const RenderLayer* positionedAncestor = parent(); | 601 const RenderLayer* positionedAncestor = parent(); |
| 612 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) | 602 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) |
| 613 positionedAncestor = positionedAncestor->parent(); | 603 positionedAncestor = positionedAncestor->parent(); |
| 614 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) | 604 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) |
| 615 positionedAncestor = 0; | 605 positionedAncestor = 0; |
| 616 | 606 |
| 617 if (!posZOrderListBeforePromote) | 607 if (!posZOrderListBeforePromote) |
| 618 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>()); | 608 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>()); |
| 619 else if (posZOrderListBeforePromote->find(this) != notFound) | 609 else if (posZOrderListBeforePromote->find(this) != notFound) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 630 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) { | 620 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) { |
| 631 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { | 621 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { |
| 632 posZOrderListBeforePromote->insert(index + 1, this); | 622 posZOrderListBeforePromote->insert(index + 1, this); |
| 633 return; | 623 return; |
| 634 } | 624 } |
| 635 } | 625 } |
| 636 } | 626 } |
| 637 | 627 |
| 638 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote) | 628 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote) |
| 639 { | 629 { |
| 640 // FIXME: TemporaryChange should support bit fields. | 630 ancestorStackingContext->rebuildZOrderLists(posZOrderListAfterPromote, negZO rderListAfterPromote, this, AcceleratedCompositingForOverflowScrollAlwaysOn); |
| 641 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | |
| 642 bool oldIsNormalFlowOnly = m_isNormalFlowOnly; | |
| 643 | |
| 644 m_isNormalFlowOnly = false; | |
| 645 m_needsCompositedScrolling = true; | |
| 646 | |
| 647 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListAfterPromote, negZOrderListAfterPromote, this); | |
| 648 | |
| 649 m_needsCompositedScrolling = oldNeedsCompositedScrolling; | |
| 650 m_isNormalFlowOnly = oldIsNormalFlowOnly; | |
| 651 } | 631 } |
| 652 | 632 |
| 653 // Compute what positive and negative z-order lists would look like before and | 633 // Compute what positive and negative z-order lists would look like before and |
| 654 // after promotion, so we can later ensure that proper stacking order is | 634 // after promotion, so we can later ensure that proper stacking order is |
| 655 // preserved between the two sets of lists. | 635 // preserved between the two sets of lists. |
| 656 // | 636 // |
| 657 // A few examples: | 637 // A few examples: |
| 658 // c = currentLayer | 638 // c = currentLayer |
| 659 // - = negative z-order child of currentLayer | 639 // - = negative z-order child of currentLayer |
| 660 // + = positive z-order child of currentLayer | 640 // + = positive z-order child of currentLayer |
| (...skipping 4950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5611 compositor()->setCompositingLayersNeedRebuild(); | 5591 compositor()->setCompositingLayersNeedRebuild(); |
| 5612 if (acceleratedCompositingForOverflowScrollEnabled()) | 5592 if (acceleratedCompositingForOverflowScrollEnabled()) |
| 5613 compositor()->setShouldReevaluateCompositingAfterLayout(); | 5593 compositor()->setShouldReevaluateCompositingAfterLayout(); |
| 5614 } | 5594 } |
| 5615 } | 5595 } |
| 5616 | 5596 |
| 5617 void RenderLayer::rebuildZOrderLists() | 5597 void RenderLayer::rebuildZOrderLists() |
| 5618 { | 5598 { |
| 5619 ASSERT(m_layerListMutationAllowed); | 5599 ASSERT(m_layerListMutationAllowed); |
| 5620 ASSERT(isDirtyStackingContainer()); | 5600 ASSERT(isDirtyStackingContainer()); |
| 5621 rebuildZOrderLists(StopAtStackingContainers, m_posZOrderList, m_negZOrderLis t); | 5601 rebuildZOrderLists(m_posZOrderList, m_negZOrderList); |
| 5622 m_zOrderListsDirty = false; | 5602 m_zOrderListsDirty = false; |
| 5623 } | 5603 } |
| 5624 | 5604 |
| 5625 void RenderLayer::rebuildZOrderLists(CollectLayersBehavior behavior, OwnPtr<Vect or<RenderLayer*> >& posZOrderList, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForceAsStackingContainer) | 5605 void RenderLayer::rebuildZOrderLists(OwnPtr<Vector<RenderLayer*> >& posZOrderLis t, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForce AsStackingContainer, AcceleratedCompositingForOverflowScrollEnabledMode accelera tedCompositingForOverflowScrollEnabledMode) |
| 5626 { | 5606 { |
| 5627 bool includeHiddenLayers = compositor()->inCompositingMode(); | 5607 bool includeHiddenLayers = compositor()->inCompositingMode(); |
| 5628 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) | 5608 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) |
| 5629 if (!m_reflection || reflectionLayer() != child) | 5609 if (!m_reflection || reflectionLayer() != child) |
| 5630 child->collectLayers(includeHiddenLayers, behavior, posZOrderList, n egZOrderList, layerToForceAsStackingContainer); | 5610 child->collectLayers(includeHiddenLayers, posZOrderList, negZOrderLi st, layerToForceAsStackingContainer, acceleratedCompositingForOverflowScrollEnab ledMode); |
| 5631 | 5611 |
| 5632 // Sort the two lists. | 5612 // Sort the two lists. |
| 5633 if (posZOrderList) | 5613 if (posZOrderList) |
| 5634 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); | 5614 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); |
| 5635 | 5615 |
| 5636 if (negZOrderList) | 5616 if (negZOrderList) |
| 5637 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); | 5617 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); |
| 5638 | 5618 |
| 5639 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. | 5619 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. |
| 5640 // The renderers of top layer elements are children of the view, sorted in t op layer stacking order. | 5620 // The renderers of top layer elements are children of the view, sorted in t op layer stacking order. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 5662 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { | 5642 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { |
| 5663 if (!m_normalFlowList) | 5643 if (!m_normalFlowList) |
| 5664 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); | 5644 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); |
| 5665 m_normalFlowList->append(child); | 5645 m_normalFlowList->append(child); |
| 5666 } | 5646 } |
| 5667 } | 5647 } |
| 5668 | 5648 |
| 5669 m_normalFlowListDirty = false; | 5649 m_normalFlowListDirty = false; |
| 5670 } | 5650 } |
| 5671 | 5651 |
| 5672 void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior behavior, OwnPtr<Vector<RenderLayer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer) | 5652 void RenderLayer::collectLayers(bool includeHiddenLayers, OwnPtr<Vector<RenderLa yer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer, AcceleratedCompositingForOverflowScrollEnabled Mode acceleratedCompositingForOverflowScrollEnabledMode) |
| 5673 { | 5653 { |
| 5674 if (isInTopLayer()) | 5654 if (isInTopLayer()) |
| 5675 return; | 5655 return; |
| 5676 | 5656 |
| 5677 updateDescendantDependentFlags(); | 5657 updateDescendantDependentFlags(); |
| 5678 | 5658 |
| 5679 bool isStacking = false; | 5659 bool isStacking = false; |
| 5660 bool isNormalFlow = false; | |
| 5680 | 5661 |
| 5681 switch (behavior) { | 5662 // To decide whether to treat the current layers as a stacking context or |
| 5682 case StopAtStackingContexts: | 5663 // normal flow only, we have to take the current state of |
| 5683 isStacking = (this == layerToForceAsStackingContainer) || isStacking Context(); | 5664 // AcceleratedCompositingForOverflowScrollEnabledMode into account. |
| 5665 if (this == layerToForceAsStackingContainer) { | |
|
shawnsingh
2013/05/16 09:47:54
OK, so I think I'm gradually overcoming the confus
hartmanng
2013/05/20 15:09:10
https://codereview.chromium.org/14858004/ is where
| |
| 5666 switch (acceleratedCompositingForOverflowScrollEnabledMode) { | |
| 5667 case AcceleratedCompositingForOverflowScrollAlwaysOn: | |
| 5668 isStacking = true; | |
| 5669 isNormalFlow = false; | |
| 5684 break; | 5670 break; |
| 5685 | 5671 case AcceleratedCompositingForOverflowScrollDisabled: |
| 5686 case StopAtStackingContainers: | 5672 isStacking = isStackingContext(); |
| 5687 isStacking = (this == layerToForceAsStackingContainer) || isStacking Container(); | 5673 isNormalFlow = shouldBeNormalFlowOnly(AcceleratedCompositingForOverf lowScrollDisabled); |
| 5688 break; | 5674 break; |
| 5675 case AcceleratedCompositingForOverflowScrollEnabled: | |
| 5676 // If we've supplied a layer to force, we should either be forcing o n or off. | |
| 5677 ASSERT_NOT_REACHED(); | |
| 5678 break; | |
| 5679 } | |
| 5680 } else if (acceleratedCompositingForOverflowScrollEnabledMode == Accelerated CompositingForOverflowScrollEnabled) { | |
| 5681 isStacking = isStackingContainer(); | |
| 5682 isNormalFlow = isNormalFlowOnly(); | |
| 5683 } else { | |
| 5684 // If we get to this case, we need to descend to stacking containers, | |
| 5685 // and therefore composited-ness should not be taken into account at | |
| 5686 // all. | |
| 5687 isStacking = isStackingContext(); | |
| 5688 isNormalFlow = shouldBeNormalFlowOnly(AcceleratedCompositingForOverflowS crollDisabled); | |
| 5689 } | 5689 } |
| 5690 | 5690 |
| 5691 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. | 5691 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. |
| 5692 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); | 5692 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); |
| 5693 if (includeHiddenLayer && !isNormalFlowOnly() && !isOutOfFlowRenderFlowThrea d()) { | 5693 if (includeHiddenLayer && !isNormalFlow && !isOutOfFlowRenderFlowThread()) { |
| 5694 // Determine which buffer the child should be in. | 5694 // Determine which buffer the child should be in. |
| 5695 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; | 5695 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; |
| 5696 | 5696 |
| 5697 // Create the buffer if it doesn't exist yet. | 5697 // Create the buffer if it doesn't exist yet. |
| 5698 if (!buffer) | 5698 if (!buffer) |
| 5699 buffer = adoptPtr(new Vector<RenderLayer*>); | 5699 buffer = adoptPtr(new Vector<RenderLayer*>); |
| 5700 | 5700 |
| 5701 // Append ourselves at the end of the appropriate buffer. | 5701 // Append ourselves at the end of the appropriate buffer. |
| 5702 buffer->append(this); | 5702 buffer->append(this); |
| 5703 } | 5703 } |
| 5704 | 5704 |
| 5705 // Recur into our children to collect more layers, but only if we don't esta blish | 5705 // Recur into our children to collect more layers, but only if we don't esta blish |
| 5706 // a stacking context/container. | 5706 // a stacking context/container. |
| 5707 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { | 5707 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { |
| 5708 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { | 5708 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { |
| 5709 // Ignore reflections. | 5709 // Ignore reflections. |
| 5710 if (!m_reflection || reflectionLayer() != child) | 5710 if (!m_reflection || reflectionLayer() != child) |
| 5711 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer, layerToForceAsStackingContainer); | 5711 child->collectLayers(includeHiddenLayers, posBuffer, negBuffer, layerToForceAsStackingContainer, acceleratedCompositingForOverflowScrollEnabledM ode); |
| 5712 } | 5712 } |
| 5713 } | 5713 } |
| 5714 } | 5714 } |
| 5715 | 5715 |
| 5716 void RenderLayer::updateLayerListsIfNeeded() | 5716 void RenderLayer::updateLayerListsIfNeeded() |
| 5717 { | 5717 { |
| 5718 updateZOrderLists(); | 5718 updateZOrderLists(); |
| 5719 updateNormalFlowList(); | 5719 updateNormalFlowList(); |
| 5720 | 5720 |
| 5721 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { | 5721 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5768 void RenderLayer::repaintIncludingNonCompositingDescendants(RenderLayerModelObje ct* repaintContainer) | 5768 void RenderLayer::repaintIncludingNonCompositingDescendants(RenderLayerModelObje ct* repaintContainer) |
| 5769 { | 5769 { |
| 5770 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer))); | 5770 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer))); |
| 5771 | 5771 |
| 5772 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { | 5772 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { |
| 5773 if (!curr->isComposited()) | 5773 if (!curr->isComposited()) |
| 5774 curr->repaintIncludingNonCompositingDescendants(repaintContainer); | 5774 curr->repaintIncludingNonCompositingDescendants(repaintContainer); |
| 5775 } | 5775 } |
| 5776 } | 5776 } |
| 5777 | 5777 |
| 5778 bool RenderLayer::shouldBeNormalFlowOnly() const | 5778 bool RenderLayer::shouldBeNormalFlowOnly(AcceleratedCompositingForOverflowScroll EnabledMode acceleratedCompositingForOverflowScrollEnabledMode) const |
| 5779 { | 5779 { |
| 5780 const bool shouldNeedCompositedScrolling = ((acceleratedCompositingForOverfl owScrollEnabledMode == AcceleratedCompositingForOverflowScrollDisabled) || !need sCompositedScrolling()); | |
|
shawnsingh
2013/05/16 09:47:54
I think we're trying to hide actual conditional lo
shawnsingh
2013/05/16 09:53:23
Hmm, maybe this could be even a bit more intuitive
hartmanng
2013/05/20 15:09:10
Done.
hartmanng
2013/05/20 15:09:10
Done.
| |
| 5780 return (renderer()->hasOverflowClip() | 5781 return (renderer()->hasOverflowClip() |
| 5781 || renderer()->hasReflection() | 5782 || renderer()->hasReflection() |
| 5782 || renderer()->hasMask() | 5783 || renderer()->hasMask() |
| 5783 || renderer()->isCanvas() | 5784 || renderer()->isCanvas() |
| 5784 || renderer()->isVideo() | 5785 || renderer()->isVideo() |
| 5785 || renderer()->isEmbeddedObject() | 5786 || renderer()->isEmbeddedObject() |
| 5786 || renderer()->isRenderIFrame() | 5787 || renderer()->isRenderIFrame() |
| 5787 || (renderer()->style()->specifiesColumns() && !isRootLayer())) | 5788 || (renderer()->style()->specifiesColumns() && !isRootLayer())) |
| 5788 && !renderer()->isPositioned() | 5789 && !renderer()->isPositioned() |
| 5789 && !renderer()->hasTransform() | 5790 && !renderer()->hasTransform() |
| 5790 && !renderer()->hasClipPath() | 5791 && !renderer()->hasClipPath() |
| 5791 && !renderer()->hasFilter() | 5792 && !renderer()->hasFilter() |
| 5792 && !renderer()->hasBlendMode() | 5793 && !renderer()->hasBlendMode() |
| 5793 && !isTransparent() | 5794 && !isTransparent() |
| 5794 && !needsCompositedScrolling() | 5795 && shouldNeedCompositedScrolling |
| 5795 && !renderer()->isFloatingWithShapeOutside() | 5796 && !renderer()->isFloatingWithShapeOutside() |
| 5796 ; | 5797 ; |
| 5797 } | 5798 } |
| 5798 | 5799 |
| 5799 void RenderLayer::updateIsNormalFlowOnly() | 5800 void RenderLayer::updateIsNormalFlowOnly() |
| 5800 { | 5801 { |
| 5801 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 5802 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
| 5802 if (isNormalFlowOnly == m_isNormalFlowOnly) | 5803 if (isNormalFlowOnly == m_isNormalFlowOnly) |
| 5803 return; | 5804 return; |
| 5804 | 5805 |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6409 } | 6410 } |
| 6410 } | 6411 } |
| 6411 | 6412 |
| 6412 void showLayerTree(const WebCore::RenderObject* renderer) | 6413 void showLayerTree(const WebCore::RenderObject* renderer) |
| 6413 { | 6414 { |
| 6414 if (!renderer) | 6415 if (!renderer) |
| 6415 return; | 6416 return; |
| 6416 showLayerTree(renderer->enclosingLayer()); | 6417 showLayerTree(renderer->enclosingLayer()); |
| 6417 } | 6418 } |
| 6418 #endif | 6419 #endif |
| OLD | NEW |