Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(703)

Side by Side Diff: Source/core/rendering/RenderLayer.cpp

Issue 14999005: Fix RenderLayer::collectLayers logic bug. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressing 2nd review Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 { 585 {
586 // FIXME: This is not in sync with containingBlock. 586 // FIXME: This is not in sync with containingBlock.
587 // RenderObject::canContainFixedPositionedObject() should probably be used 587 // RenderObject::canContainFixedPositionedObject() should probably be used
588 // instead. 588 // instead.
589 RenderLayerModelObject* layerRenderer = layer->renderer(); 589 RenderLayerModelObject* layerRenderer = layer->renderer();
590 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); 590 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform();
591 } 591 }
592 592
593 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote) 593 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote)
594 { 594 {
595 // FIXME: TemporaryChange should support bit fields. 595 ancestorStackingContext->rebuildZOrderLists(posZOrderListBeforePromote, negZ OrderListBeforePromote, this, OnlyStackingContextsCanBeStackingContainers);
596 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling;
597 bool oldIsNormalFlowOnly = m_isNormalFlowOnly;
598
599 m_needsCompositedScrolling = false;
600 m_isNormalFlowOnly = shouldBeNormalFlowOnly();
601
602 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListBeforePromote, negZOrderListBeforePromote, 0);
603
604 m_needsCompositedScrolling = oldNeedsCompositedScrolling;
605 m_isNormalFlowOnly = oldIsNormalFlowOnly;
606 596
607 const RenderLayer* positionedAncestor = parent(); 597 const RenderLayer* positionedAncestor = parent();
608 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) 598 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext())
609 positionedAncestor = positionedAncestor->parent(); 599 positionedAncestor = positionedAncestor->parent();
610 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) 600 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext()))
611 positionedAncestor = 0; 601 positionedAncestor = 0;
612 602
613 if (!posZOrderListBeforePromote) 603 if (!posZOrderListBeforePromote)
614 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>()); 604 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>());
615 else if (posZOrderListBeforePromote->find(this) != notFound) 605 else if (posZOrderListBeforePromote->find(this) != notFound)
(...skipping 10 matching lines...) Expand all
626 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) { 616 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) {
627 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { 617 if (posZOrderListBeforePromote->at(index) == positionedAncestor) {
628 posZOrderListBeforePromote->insert(index + 1, this); 618 posZOrderListBeforePromote->insert(index + 1, this);
629 return; 619 return;
630 } 620 }
631 } 621 }
632 } 622 }
633 623
634 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote) 624 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote)
635 { 625 {
636 // FIXME: TemporaryChange should support bit fields. 626 ancestorStackingContext->rebuildZOrderLists(posZOrderListAfterPromote, negZO rderListAfterPromote, this, ForceLayerToStackingContainer);
637 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling;
638 bool oldIsNormalFlowOnly = m_isNormalFlowOnly;
639
640 m_isNormalFlowOnly = false;
641 m_needsCompositedScrolling = true;
642
643 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListAfterPromote, negZOrderListAfterPromote, this);
644
645 m_needsCompositedScrolling = oldNeedsCompositedScrolling;
646 m_isNormalFlowOnly = oldIsNormalFlowOnly;
647 } 627 }
648 628
649 // Compute what positive and negative z-order lists would look like before and 629 // Compute what positive and negative z-order lists would look like before and
650 // after promotion, so we can later ensure that proper stacking order is 630 // after promotion, so we can later ensure that proper stacking order is
651 // preserved between the two sets of lists. 631 // preserved between the two sets of lists.
652 // 632 //
653 // A few examples: 633 // A few examples:
654 // c = currentLayer 634 // c = currentLayer
655 // - = negative z-order child of currentLayer 635 // - = negative z-order child of currentLayer
656 // + = positive z-order child of currentLayer 636 // + = positive z-order child of currentLayer
(...skipping 4936 matching lines...) Expand 10 before | Expand all | Expand 10 after
5593 compositor()->setCompositingLayersNeedRebuild(); 5573 compositor()->setCompositingLayersNeedRebuild();
5594 if (acceleratedCompositingForOverflowScrollEnabled()) 5574 if (acceleratedCompositingForOverflowScrollEnabled())
5595 compositor()->setShouldReevaluateCompositingAfterLayout(); 5575 compositor()->setShouldReevaluateCompositingAfterLayout();
5596 } 5576 }
5597 } 5577 }
5598 5578
5599 void RenderLayer::rebuildZOrderLists() 5579 void RenderLayer::rebuildZOrderLists()
5600 { 5580 {
5601 ASSERT(m_layerListMutationAllowed); 5581 ASSERT(m_layerListMutationAllowed);
5602 ASSERT(isDirtyStackingContainer()); 5582 ASSERT(isDirtyStackingContainer());
5603 rebuildZOrderLists(StopAtStackingContainers, m_posZOrderList, m_negZOrderLis t); 5583 rebuildZOrderLists(m_posZOrderList, m_negZOrderList);
5604 m_zOrderListsDirty = false; 5584 m_zOrderListsDirty = false;
5605 } 5585 }
5606 5586
5607 void RenderLayer::rebuildZOrderLists(CollectLayersBehavior behavior, OwnPtr<Vect or<RenderLayer*> >& posZOrderList, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForceAsStackingContainer) 5587 void RenderLayer::rebuildZOrderLists(OwnPtr<Vector<RenderLayer*> >& posZOrderLis t, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForce AsStackingContainer, CollectLayersBehavior collectLayersBehavior)
5608 { 5588 {
5609 bool includeHiddenLayers = compositor()->inCompositingMode(); 5589 bool includeHiddenLayers = compositor()->inCompositingMode();
5610 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) 5590 for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
5611 if (!m_reflection || reflectionLayer() != child) 5591 if (!m_reflection || reflectionLayer() != child)
5612 child->collectLayers(includeHiddenLayers, behavior, posZOrderList, n egZOrderList, layerToForceAsStackingContainer); 5592 child->collectLayers(includeHiddenLayers, posZOrderList, negZOrderLi st, layerToForceAsStackingContainer, collectLayersBehavior);
5613 5593
5614 // Sort the two lists. 5594 // Sort the two lists.
5615 if (posZOrderList) 5595 if (posZOrderList)
5616 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); 5596 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex);
5617 5597
5618 if (negZOrderList) 5598 if (negZOrderList)
5619 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); 5599 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex);
5620 5600
5621 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. 5601 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes.
5622 // The renderers of top layer elements are children of the view, sorted in t op layer stacking order. 5602 // The renderers of top layer elements are children of the view, sorted in t op layer stacking order.
(...skipping 21 matching lines...) Expand all
5644 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { 5624 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) {
5645 if (!m_normalFlowList) 5625 if (!m_normalFlowList)
5646 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); 5626 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>);
5647 m_normalFlowList->append(child); 5627 m_normalFlowList->append(child);
5648 } 5628 }
5649 } 5629 }
5650 5630
5651 m_normalFlowListDirty = false; 5631 m_normalFlowListDirty = false;
5652 } 5632 }
5653 5633
5654 void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior behavior, OwnPtr<Vector<RenderLayer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer) 5634 void RenderLayer::collectLayers(bool includeHiddenLayers, OwnPtr<Vector<RenderLa yer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer, CollectLayersBehavior collectLayersBehavior)
5655 { 5635 {
5656 if (isInTopLayer()) 5636 if (isInTopLayer())
5657 return; 5637 return;
5658 5638
5659 updateDescendantDependentFlags(); 5639 updateDescendantDependentFlags();
5660 5640
5661 bool isStacking = false; 5641 bool isStacking = false;
5642 bool isNormalFlow = false;
5662 5643
5663 switch (behavior) { 5644 switch (collectLayersBehavior) {
5664 case StopAtStackingContexts: 5645 case ForceLayerToStackingContainer:
5665 isStacking = (this == layerToForceAsStackingContainer) || isStacking Context(); 5646 ASSERT(layerToForceAsStackingContainer);
5666 break; 5647 if (this == layerToForceAsStackingContainer) {
5667 5648 isStacking = true;
5668 case StopAtStackingContainers: 5649 isNormalFlow = false;
5669 isStacking = (this == layerToForceAsStackingContainer) || isStacking Container(); 5650 } else {
5670 break; 5651 isStacking = isStackingContext();
5652 isNormalFlow = shouldBeNormalFlowOnly(false);
5653 }
5654 break;
5655 case OverflowScrollCanBeStackingContainers:
5656 ASSERT(!layerToForceAsStackingContainer);
5657 isStacking = isStackingContainer();
5658 isNormalFlow = isNormalFlowOnly();
5659 break;
5660 case OnlyStackingContextsCanBeStackingContainers:
5661 isStacking = isStackingContext();
5662 isNormalFlow = shouldBeNormalFlowOnly(false);
5663 break;
5671 } 5664 }
5672 5665
5673 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. 5666 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists.
5674 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); 5667 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking));
5675 if (includeHiddenLayer && !isNormalFlowOnly() && !isOutOfFlowRenderFlowThrea d()) { 5668 if (includeHiddenLayer && !isNormalFlow && !isOutOfFlowRenderFlowThread()) {
5676 // Determine which buffer the child should be in. 5669 // Determine which buffer the child should be in.
5677 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; 5670 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer;
5678 5671
5679 // Create the buffer if it doesn't exist yet. 5672 // Create the buffer if it doesn't exist yet.
5680 if (!buffer) 5673 if (!buffer)
5681 buffer = adoptPtr(new Vector<RenderLayer*>); 5674 buffer = adoptPtr(new Vector<RenderLayer*>);
5682 5675
5683 // Append ourselves at the end of the appropriate buffer. 5676 // Append ourselves at the end of the appropriate buffer.
5684 buffer->append(this); 5677 buffer->append(this);
5685 } 5678 }
5686 5679
5687 // Recur into our children to collect more layers, but only if we don't esta blish 5680 // Recur into our children to collect more layers, but only if we don't esta blish
5688 // a stacking context/container. 5681 // a stacking context/container.
5689 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { 5682 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) {
5690 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { 5683 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) {
5691 // Ignore reflections. 5684 // Ignore reflections.
5692 if (!m_reflection || reflectionLayer() != child) 5685 if (!m_reflection || reflectionLayer() != child)
5693 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer, layerToForceAsStackingContainer); 5686 child->collectLayers(includeHiddenLayers, posBuffer, negBuffer, layerToForceAsStackingContainer, collectLayersBehavior);
5694 } 5687 }
5695 } 5688 }
5696 } 5689 }
5697 5690
5698 void RenderLayer::updateLayerListsIfNeeded() 5691 void RenderLayer::updateLayerListsIfNeeded()
5699 { 5692 {
5700 updateZOrderLists(); 5693 updateZOrderLists();
5701 updateNormalFlowList(); 5694 updateNormalFlowList();
5702 5695
5703 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { 5696 if (RenderLayer* reflectionLayer = this->reflectionLayer()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5750 void RenderLayer::repaintIncludingNonCompositingDescendants(RenderLayerModelObje ct* repaintContainer) 5743 void RenderLayer::repaintIncludingNonCompositingDescendants(RenderLayerModelObje ct* repaintContainer)
5751 { 5744 {
5752 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer))); 5745 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer)));
5753 5746
5754 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { 5747 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) {
5755 if (!curr->isComposited()) 5748 if (!curr->isComposited())
5756 curr->repaintIncludingNonCompositingDescendants(repaintContainer); 5749 curr->repaintIncludingNonCompositingDescendants(repaintContainer);
5757 } 5750 }
5758 } 5751 }
5759 5752
5760 bool RenderLayer::shouldBeNormalFlowOnly() const 5753 bool RenderLayer::shouldBeNormalFlowOnly(bool canNeedCompositedScrolling) const
5761 { 5754 {
5762 return (renderer()->hasOverflowClip() 5755 bool needsCompositedScrolling;
5763 || renderer()->hasReflection() 5756 if (canNeedCompositedScrolling)
5764 || renderer()->hasMask() 5757 needsCompositedScrolling = this->needsCompositedScrolling();
5765 || renderer()->isCanvas() 5758 else
5766 || renderer()->isVideo() 5759 needsCompositedScrolling = false;
5767 || renderer()->isEmbeddedObject() 5760
5768 || renderer()->isRenderIFrame() 5761 const bool couldBeNormalFlow = renderer()->hasOverflowClip()
5769 || (renderer()->style()->specifiesColumns() && !isRootLayer())) 5762 || renderer()->hasReflection()
5770 && !renderer()->isPositioned() 5763 || renderer()->hasMask()
5771 && !renderer()->hasTransform() 5764 || renderer()->isCanvas()
5772 && !renderer()->hasClipPath() 5765 || renderer()->isVideo()
5773 && !renderer()->hasFilter() 5766 || renderer()->isEmbeddedObject()
5774 && !renderer()->hasBlendMode() 5767 || renderer()->isRenderIFrame()
5775 && !isTransparent() 5768 || (renderer()->style()->specifiesColumns() && !isRootLayer());
5776 && !needsCompositedScrolling() 5769 const bool hasExceptionThatCannotBeNormalFlow = renderer()->isPositioned()
5777 && !renderer()->isFloatingWithShapeOutside() 5770 || renderer()->hasTransform()
5778 ; 5771 || renderer()->hasClipPath()
5772 || renderer()->hasFilter()
5773 || renderer()->hasBlendMode()
5774 || isTransparent()
5775 || needsCompositedScrolling
5776 || renderer()->isFloatingWithShapeOutside();
5777
5778 return couldBeNormalFlow && !hasExceptionThatCannotBeNormalFlow;
5779 } 5779 }
5780 5780
5781 void RenderLayer::updateIsNormalFlowOnly() 5781 void RenderLayer::updateIsNormalFlowOnly()
5782 { 5782 {
5783 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); 5783 bool isNormalFlowOnly = shouldBeNormalFlowOnly();
5784 if (isNormalFlowOnly == m_isNormalFlowOnly) 5784 if (isNormalFlowOnly == m_isNormalFlowOnly)
5785 return; 5785 return;
5786 5786
5787 m_isNormalFlowOnly = isNormalFlowOnly; 5787 m_isNormalFlowOnly = isNormalFlowOnly;
5788 if (RenderLayer* p = parent()) 5788 if (RenderLayer* p = parent())
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
6391 } 6391 }
6392 } 6392 }
6393 6393
6394 void showLayerTree(const WebCore::RenderObject* renderer) 6394 void showLayerTree(const WebCore::RenderObject* renderer)
6395 { 6395 {
6396 if (!renderer) 6396 if (!renderer)
6397 return; 6397 return;
6398 showLayerTree(renderer->enclosingLayer()); 6398 showLayerTree(renderer->enclosingLayer());
6399 } 6399 }
6400 #endif 6400 #endif
OLDNEW
« Source/core/rendering/RenderLayer.h ('K') | « Source/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698