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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
702 { | 702 { |
703 // FIXME: This is not in sync with containingBlock. | 703 // FIXME: This is not in sync with containingBlock. |
704 // RenderObject::canContainFixedPositionedObject() should probably be used | 704 // RenderObject::canContainFixedPositionedObject() should probably be used |
705 // instead. | 705 // instead. |
706 RenderLayerModelObject* layerRenderer = layer->renderer(); | 706 RenderLayerModelObject* layerRenderer = layer->renderer(); |
707 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); | 707 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); |
708 } | 708 } |
709 | 709 |
710 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote) | 710 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote) |
711 { | 711 { |
712 // FIXME: TemporaryChange should support bit fields. | 712 ancestorStackingContext->rebuildZOrderLists(posZOrderListBeforePromote, negZ OrderListBeforePromote, this, ForceCompositedScrollingOff); |
713 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | |
714 bool oldIsNormalFlowOnly = m_isNormalFlowOnly; | |
715 | |
716 m_needsCompositedScrolling = false; | |
717 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); | |
718 | |
719 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListBeforePromote, negZOrderListBeforePromote, 0); | |
720 | |
721 m_needsCompositedScrolling = oldNeedsCompositedScrolling; | |
722 m_isNormalFlowOnly = oldIsNormalFlowOnly; | |
723 | 713 |
724 const RenderLayer* positionedAncestor = parent(); | 714 const RenderLayer* positionedAncestor = parent(); |
725 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) | 715 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) |
726 positionedAncestor = positionedAncestor->parent(); | 716 positionedAncestor = positionedAncestor->parent(); |
727 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) | 717 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) |
728 positionedAncestor = 0; | 718 positionedAncestor = 0; |
729 | 719 |
730 if (!posZOrderListBeforePromote) | 720 if (!posZOrderListBeforePromote) |
731 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>()); | 721 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>()); |
732 else if (posZOrderListBeforePromote->find(this) != notFound) | 722 else if (posZOrderListBeforePromote->find(this) != notFound) |
(...skipping 10 matching lines...) Expand all Loading... | |
743 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) { | 733 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) { |
744 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { | 734 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { |
745 posZOrderListBeforePromote->insert(index + 1, this); | 735 posZOrderListBeforePromote->insert(index + 1, this); |
746 return; | 736 return; |
747 } | 737 } |
748 } | 738 } |
749 } | 739 } |
750 | 740 |
751 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote) | 741 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote) |
752 { | 742 { |
753 // FIXME: TemporaryChange should support bit fields. | 743 ancestorStackingContext->rebuildZOrderLists(posZOrderListAfterPromote, negZO rderListAfterPromote, this, ForceCompositedScrollingOn); |
754 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | |
755 bool oldIsNormalFlowOnly = m_isNormalFlowOnly; | |
756 | |
757 m_isNormalFlowOnly = false; | |
758 m_needsCompositedScrolling = true; | |
759 | |
760 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListAfterPromote, negZOrderListAfterPromote, this); | |
761 | |
762 m_needsCompositedScrolling = oldNeedsCompositedScrolling; | |
763 m_isNormalFlowOnly = oldIsNormalFlowOnly; | |
764 } | 744 } |
765 | 745 |
766 // Compute what positive and negative z-order lists would look like before and | 746 // Compute what positive and negative z-order lists would look like before and |
767 // after promotion, so we can later ensure that proper stacking order is | 747 // after promotion, so we can later ensure that proper stacking order is |
768 // preserved between the two sets of lists. | 748 // preserved between the two sets of lists. |
769 // | 749 // |
770 // A few examples: | 750 // A few examples: |
771 // c = currentLayer | 751 // c = currentLayer |
772 // - = negative z-order child of currentLayer | 752 // - = negative z-order child of currentLayer |
773 // + = positive z-order child of currentLayer | 753 // + = positive z-order child of currentLayer |
(...skipping 4934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5708 compositor()->setCompositingLayersNeedRebuild(); | 5688 compositor()->setCompositingLayersNeedRebuild(); |
5709 if (acceleratedCompositingForOverflowScrollEnabled()) | 5689 if (acceleratedCompositingForOverflowScrollEnabled()) |
5710 compositor()->setShouldReevaluateCompositingAfterLayout(); | 5690 compositor()->setShouldReevaluateCompositingAfterLayout(); |
5711 } | 5691 } |
5712 } | 5692 } |
5713 | 5693 |
5714 void RenderLayer::rebuildZOrderLists() | 5694 void RenderLayer::rebuildZOrderLists() |
5715 { | 5695 { |
5716 ASSERT(m_layerListMutationAllowed); | 5696 ASSERT(m_layerListMutationAllowed); |
5717 ASSERT(isDirtyStackingContainer()); | 5697 ASSERT(isDirtyStackingContainer()); |
5718 rebuildZOrderLists(StopAtStackingContainers, m_posZOrderList, m_negZOrderLis t); | 5698 rebuildZOrderLists(m_posZOrderList, m_negZOrderList); |
5719 m_zOrderListsDirty = false; | 5699 m_zOrderListsDirty = false; |
5720 } | 5700 } |
5721 | 5701 |
5722 void RenderLayer::rebuildZOrderLists(CollectLayersBehavior behavior, OwnPtr<Vect or<RenderLayer*> >& posZOrderList, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForceAsStackingContainer) | 5702 void RenderLayer::rebuildZOrderLists(OwnPtr<Vector<RenderLayer*> >& posZOrderLis t, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForce AsStackingContainer, ForceNeedsCompositedScrollingMode forceMode) |
5723 { | 5703 { |
5724 bool includeHiddenLayers = compositor()->inCompositingMode(); | 5704 bool includeHiddenLayers = compositor()->inCompositingMode(); |
5725 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) | 5705 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) |
5726 if (!m_reflection || reflectionLayer() != child) | 5706 if (!m_reflection || reflectionLayer() != child) |
5727 child->collectLayers(includeHiddenLayers, behavior, posZOrderList, n egZOrderList, layerToForceAsStackingContainer); | 5707 child->collectLayers(includeHiddenLayers, posZOrderList, negZOrderLi st, layerToForceAsStackingContainer, forceMode); |
5728 | 5708 |
5729 // Sort the two lists. | 5709 // Sort the two lists. |
5730 if (posZOrderList) | 5710 if (posZOrderList) |
5731 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); | 5711 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); |
5732 | 5712 |
5733 if (negZOrderList) | 5713 if (negZOrderList) |
5734 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); | 5714 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); |
5735 | 5715 |
5736 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. | 5716 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. |
5737 // The renderers of top layer elements are children of the view, sorted in t op layer stacking order. | 5717 // 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... | |
5759 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { | 5739 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { |
5760 if (!m_normalFlowList) | 5740 if (!m_normalFlowList) |
5761 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); | 5741 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); |
5762 m_normalFlowList->append(child); | 5742 m_normalFlowList->append(child); |
5763 } | 5743 } |
5764 } | 5744 } |
5765 | 5745 |
5766 m_normalFlowListDirty = false; | 5746 m_normalFlowListDirty = false; |
5767 } | 5747 } |
5768 | 5748 |
5769 void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior behavior, OwnPtr<Vector<RenderLayer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer) | 5749 void RenderLayer::collectLayers(bool includeHiddenLayers, OwnPtr<Vector<RenderLa yer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer, ForceNeedsCompositedScrollingMode forceMode) |
5770 { | 5750 { |
5771 if (isInTopLayer()) | 5751 if (isInTopLayer()) |
5772 return; | 5752 return; |
5773 | 5753 |
5774 updateDescendantDependentFlags(); | 5754 updateDescendantDependentFlags(); |
5775 | 5755 |
5776 bool isStacking = false; | 5756 bool isStacking = false; |
5757 bool isNormalFlow = false; | |
5777 | 5758 |
5778 switch (behavior) { | 5759 // To decide whether to treat the current layers as a stacking context or |
5779 case StopAtStackingContexts: | 5760 // normal flow only, we have to take the current state of |
5780 isStacking = (this == layerToForceAsStackingContainer) || isStacking Context(); | 5761 // ForceNeedsCompositedScrollingMode into account. |
5762 if (this == layerToForceAsStackingContainer) { | |
5763 switch (forceMode) { | |
5764 case ForceCompositedScrollingOn: | |
5765 isStacking = true; | |
5766 isNormalFlow = false; | |
5781 break; | 5767 break; |
5782 | 5768 case ForceCompositedScrollingOff: |
5783 case StopAtStackingContainers: | 5769 isStacking = isStackingContext(); |
5784 isStacking = (this == layerToForceAsStackingContainer) || isStacking Container(); | 5770 isNormalFlow = shouldBeNormalFlowOnly(ForceCompositedScrollingOff); |
5785 break; | 5771 break; |
5772 case DoNotForceCompositedScrolling: | |
shawnsingh
2013/05/07 00:47:42
It might be more robust to future code changes to
hartmanng
2013/05/13 19:27:06
Based on https://codereview.chromium.org/14458008/
| |
5773 // If we've supplied a layer to force, we should either be forcing o n or off. | |
5774 ASSERT_NOT_REACHED(); | |
5775 break; | |
5776 } | |
5777 } else if (forceMode == DoNotForceCompositedScrolling) { | |
5778 isStacking = isStackingContainer(); | |
5779 isNormalFlow = isNormalFlowOnly(); | |
5780 } else { | |
5781 // If we get to this case, we need to descend to stacking containers, | |
5782 // and therefore composited-ness should not be taken into account at | |
5783 // all. | |
5784 isStacking = isStackingContext(); | |
5785 isNormalFlow = shouldBeNormalFlowOnly(ForceCompositedScrollingOff); | |
5786 } | 5786 } |
5787 | 5787 |
5788 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. | 5788 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. |
5789 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); | 5789 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); |
5790 if (includeHiddenLayer && !isNormalFlowOnly() && !isOutOfFlowRenderFlowThrea d()) { | 5790 if (includeHiddenLayer && !isNormalFlow && !isOutOfFlowRenderFlowThread()) { |
5791 // Determine which buffer the child should be in. | 5791 // Determine which buffer the child should be in. |
5792 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; | 5792 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; |
5793 | 5793 |
5794 // Create the buffer if it doesn't exist yet. | 5794 // Create the buffer if it doesn't exist yet. |
5795 if (!buffer) | 5795 if (!buffer) |
5796 buffer = adoptPtr(new Vector<RenderLayer*>); | 5796 buffer = adoptPtr(new Vector<RenderLayer*>); |
5797 | 5797 |
5798 // Append ourselves at the end of the appropriate buffer. | 5798 // Append ourselves at the end of the appropriate buffer. |
5799 buffer->append(this); | 5799 buffer->append(this); |
5800 } | 5800 } |
5801 | 5801 |
5802 // Recur into our children to collect more layers, but only if we don't esta blish | 5802 // Recur into our children to collect more layers, but only if we don't esta blish |
5803 // a stacking context/container. | 5803 // a stacking context/container. |
5804 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { | 5804 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { |
5805 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { | 5805 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { |
5806 // Ignore reflections. | 5806 // Ignore reflections. |
5807 if (!m_reflection || reflectionLayer() != child) | 5807 if (!m_reflection || reflectionLayer() != child) |
5808 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer, layerToForceAsStackingContainer); | 5808 child->collectLayers(includeHiddenLayers, posBuffer, negBuffer, layerToForceAsStackingContainer, forceMode); |
5809 } | 5809 } |
5810 } | 5810 } |
5811 } | 5811 } |
5812 | 5812 |
5813 void RenderLayer::updateLayerListsIfNeeded() | 5813 void RenderLayer::updateLayerListsIfNeeded() |
5814 { | 5814 { |
5815 updateZOrderLists(); | 5815 updateZOrderLists(); |
5816 updateNormalFlowList(); | 5816 updateNormalFlowList(); |
5817 | 5817 |
5818 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { | 5818 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5865 void RenderLayer::repaintIncludingNonCompositingDescendants(RenderLayerModelObje ct* repaintContainer) | 5865 void RenderLayer::repaintIncludingNonCompositingDescendants(RenderLayerModelObje ct* repaintContainer) |
5866 { | 5866 { |
5867 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer))); | 5867 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer))); |
5868 | 5868 |
5869 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { | 5869 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { |
5870 if (!curr->isComposited()) | 5870 if (!curr->isComposited()) |
5871 curr->repaintIncludingNonCompositingDescendants(repaintContainer); | 5871 curr->repaintIncludingNonCompositingDescendants(repaintContainer); |
5872 } | 5872 } |
5873 } | 5873 } |
5874 | 5874 |
5875 bool RenderLayer::shouldBeNormalFlowOnly() const | 5875 bool RenderLayer::shouldBeNormalFlowOnly(ForceNeedsCompositedScrollingMode force Mode) const |
5876 { | 5876 { |
5877 const bool needsCompositedScrollingGivenForceMode = ((forceMode == ForceComp ositedScrollingOff) || !needsCompositedScrolling()); | |
shawnsingh
2013/05/07 00:47:42
I think this variable name is a little unclear --
hartmanng
2013/05/13 19:27:06
Good point, it is a bit confusing. I was trying to
| |
5877 return (renderer()->hasOverflowClip() | 5878 return (renderer()->hasOverflowClip() |
5878 || renderer()->hasReflection() | 5879 || renderer()->hasReflection() |
5879 || renderer()->hasMask() | 5880 || renderer()->hasMask() |
5880 || renderer()->isCanvas() | 5881 || renderer()->isCanvas() |
5881 || renderer()->isVideo() | 5882 || renderer()->isVideo() |
5882 || renderer()->isEmbeddedObject() | 5883 || renderer()->isEmbeddedObject() |
5883 || renderer()->isRenderIFrame() | 5884 || renderer()->isRenderIFrame() |
5884 || (renderer()->style()->specifiesColumns() && !isRootLayer())) | 5885 || (renderer()->style()->specifiesColumns() && !isRootLayer())) |
5885 && !renderer()->isPositioned() | 5886 && !renderer()->isPositioned() |
5886 && !renderer()->hasTransform() | 5887 && !renderer()->hasTransform() |
5887 && !renderer()->hasClipPath() | 5888 && !renderer()->hasClipPath() |
5888 && !renderer()->hasFilter() | 5889 && !renderer()->hasFilter() |
5889 #if ENABLE(CSS_COMPOSITING) | 5890 #if ENABLE(CSS_COMPOSITING) |
5890 && !renderer()->hasBlendMode() | 5891 && !renderer()->hasBlendMode() |
5891 #endif | 5892 #endif |
5892 && !isTransparent() | 5893 && !isTransparent() |
5893 && !needsCompositedScrolling() | 5894 && needsCompositedScrollingGivenForceMode |
5894 && !renderer()->isFloatingWithShapeOutside() | 5895 && !renderer()->isFloatingWithShapeOutside() |
5895 ; | 5896 ; |
5896 } | 5897 } |
5897 | 5898 |
5898 void RenderLayer::updateIsNormalFlowOnly() | 5899 void RenderLayer::updateIsNormalFlowOnly() |
5899 { | 5900 { |
5900 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 5901 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
5901 if (isNormalFlowOnly == m_isNormalFlowOnly) | 5902 if (isNormalFlowOnly == m_isNormalFlowOnly) |
5902 return; | 5903 return; |
5903 | 5904 |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6493 } | 6494 } |
6494 } | 6495 } |
6495 | 6496 |
6496 void showLayerTree(const WebCore::RenderObject* renderer) | 6497 void showLayerTree(const WebCore::RenderObject* renderer) |
6497 { | 6498 { |
6498 if (!renderer) | 6499 if (!renderer) |
6499 return; | 6500 return; |
6500 showLayerTree(renderer->enclosingLayer()); | 6501 showLayerTree(renderer->enclosingLayer()); |
6501 } | 6502 } |
6502 #endif | 6503 #endif |
OLD | NEW |