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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 { | 570 { |
571 // FIXME: This is not in sync with containingBlock. | 571 // FIXME: This is not in sync with containingBlock. |
572 // RenderObject::canContainFixedPositionedObject() should probably be used | 572 // RenderObject::canContainFixedPositionedObject() should probably be used |
573 // instead. | 573 // instead. |
574 RenderLayerModelObject* layerRenderer = layer->renderer(); | 574 RenderLayerModelObject* layerRenderer = layer->renderer(); |
575 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); | 575 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); |
576 } | 576 } |
577 | 577 |
578 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote) | 578 void RenderLayer::collectBeforePromotionZOrderList(RenderLayer* ancestorStacking Context, OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, OwnPtr<Vecto r<RenderLayer*> >& negZOrderListBeforePromote) |
579 { | 579 { |
580 // FIXME: TemporaryChange should support bit fields. | 580 ancestorStackingContext->rebuildZOrderLists(posZOrderListBeforePromote, negZ OrderListBeforePromote, this, OnlyStackingContextsCanBeStackingContainers); |
581 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | |
582 bool oldIsNormalFlowOnly = m_isNormalFlowOnly; | |
583 | |
584 m_needsCompositedScrolling = false; | |
585 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); | |
586 | |
587 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListBeforePromote, negZOrderListBeforePromote, 0); | |
588 | |
589 m_needsCompositedScrolling = oldNeedsCompositedScrolling; | |
590 m_isNormalFlowOnly = oldIsNormalFlowOnly; | |
591 | 581 |
592 const RenderLayer* positionedAncestor = parent(); | 582 const RenderLayer* positionedAncestor = parent(); |
593 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) | 583 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) |
594 positionedAncestor = positionedAncestor->parent(); | 584 positionedAncestor = positionedAncestor->parent(); |
595 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) | 585 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) |
596 positionedAncestor = 0; | 586 positionedAncestor = 0; |
597 | 587 |
598 if (!posZOrderListBeforePromote) | 588 if (!posZOrderListBeforePromote) |
599 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>()); | 589 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>()); |
600 else if (posZOrderListBeforePromote->find(this) != notFound) | 590 else if (posZOrderListBeforePromote->find(this) != notFound) |
(...skipping 10 matching lines...) Expand all Loading... | |
611 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) { | 601 for (size_t index = 0; index < posZOrderListBeforePromote->size(); index++) { |
612 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { | 602 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { |
613 posZOrderListBeforePromote->insert(index + 1, this); | 603 posZOrderListBeforePromote->insert(index + 1, this); |
614 return; | 604 return; |
615 } | 605 } |
616 } | 606 } |
617 } | 607 } |
618 | 608 |
619 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote) | 609 void RenderLayer::collectAfterPromotionZOrderList(RenderLayer* ancestorStackingC ontext, OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, OwnPtr<Vector< RenderLayer*> >& negZOrderListAfterPromote) |
620 { | 610 { |
621 // FIXME: TemporaryChange should support bit fields. | 611 ancestorStackingContext->rebuildZOrderLists(posZOrderListAfterPromote, negZO rderListAfterPromote, this, ForceLayerToStackingContainer); |
622 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | |
623 bool oldIsNormalFlowOnly = m_isNormalFlowOnly; | |
624 | |
625 m_isNormalFlowOnly = false; | |
626 m_needsCompositedScrolling = true; | |
627 | |
628 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListAfterPromote, negZOrderListAfterPromote, this); | |
629 | |
630 m_needsCompositedScrolling = oldNeedsCompositedScrolling; | |
631 m_isNormalFlowOnly = oldIsNormalFlowOnly; | |
632 } | 612 } |
633 | 613 |
634 // Compute what positive and negative z-order lists would look like before and | 614 // Compute what positive and negative z-order lists would look like before and |
635 // after promotion, so we can later ensure that proper stacking order is | 615 // after promotion, so we can later ensure that proper stacking order is |
636 // preserved between the two sets of lists. | 616 // preserved between the two sets of lists. |
637 // | 617 // |
638 // A few examples: | 618 // A few examples: |
639 // c = currentLayer | 619 // c = currentLayer |
640 // - = negative z-order child of currentLayer | 620 // - = negative z-order child of currentLayer |
641 // + = positive z-order child of currentLayer | 621 // + = positive z-order child of currentLayer |
(...skipping 4930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5572 compositor()->setCompositingLayersNeedRebuild(); | 5552 compositor()->setCompositingLayersNeedRebuild(); |
5573 if (acceleratedCompositingForOverflowScrollEnabled()) | 5553 if (acceleratedCompositingForOverflowScrollEnabled()) |
5574 compositor()->setShouldReevaluateCompositingAfterLayout(); | 5554 compositor()->setShouldReevaluateCompositingAfterLayout(); |
5575 } | 5555 } |
5576 } | 5556 } |
5577 | 5557 |
5578 void RenderLayer::rebuildZOrderLists() | 5558 void RenderLayer::rebuildZOrderLists() |
5579 { | 5559 { |
5580 ASSERT(m_layerListMutationAllowed); | 5560 ASSERT(m_layerListMutationAllowed); |
5581 ASSERT(isDirtyStackingContainer()); | 5561 ASSERT(isDirtyStackingContainer()); |
5582 rebuildZOrderLists(StopAtStackingContainers, m_posZOrderList, m_negZOrderLis t); | 5562 rebuildZOrderLists(m_posZOrderList, m_negZOrderList); |
5583 m_zOrderListsDirty = false; | 5563 m_zOrderListsDirty = false; |
5584 } | 5564 } |
5585 | 5565 |
5586 void RenderLayer::rebuildZOrderLists(CollectLayersBehavior behavior, OwnPtr<Vect or<RenderLayer*> >& posZOrderList, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForceAsStackingContainer) | 5566 void RenderLayer::rebuildZOrderLists(OwnPtr<Vector<RenderLayer*> >& posZOrderLis t, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForce AsStackingContainer, CollectLayersBehavior collectLayersBehavior) |
5587 { | 5567 { |
5588 bool includeHiddenLayers = compositor()->inCompositingMode(); | 5568 bool includeHiddenLayers = compositor()->inCompositingMode(); |
5589 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) | 5569 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) |
5590 if (!m_reflection || reflectionLayer() != child) | 5570 if (!m_reflection || reflectionLayer() != child) |
5591 child->collectLayers(includeHiddenLayers, behavior, posZOrderList, n egZOrderList, layerToForceAsStackingContainer); | 5571 child->collectLayers(includeHiddenLayers, posZOrderList, negZOrderLi st, layerToForceAsStackingContainer, collectLayersBehavior); |
5592 | 5572 |
5593 // Sort the two lists. | 5573 // Sort the two lists. |
5594 if (posZOrderList) | 5574 if (posZOrderList) |
5595 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); | 5575 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); |
5596 | 5576 |
5597 if (negZOrderList) | 5577 if (negZOrderList) |
5598 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); | 5578 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); |
5599 | 5579 |
5600 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. | 5580 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. |
5601 // The renderers of top layer elements are children of the view, sorted in t op layer stacking order. | 5581 // 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... | |
5623 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { | 5603 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { |
5624 if (!m_normalFlowList) | 5604 if (!m_normalFlowList) |
5625 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); | 5605 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); |
5626 m_normalFlowList->append(child); | 5606 m_normalFlowList->append(child); |
5627 } | 5607 } |
5628 } | 5608 } |
5629 | 5609 |
5630 m_normalFlowListDirty = false; | 5610 m_normalFlowListDirty = false; |
5631 } | 5611 } |
5632 | 5612 |
5633 void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior behavior, OwnPtr<Vector<RenderLayer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer) | 5613 void RenderLayer::collectLayers(bool includeHiddenLayers, OwnPtr<Vector<RenderLa yer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContainer, CollectLayersBehavior collectLayersBehavior) |
5634 { | 5614 { |
5635 if (isInTopLayer()) | 5615 if (isInTopLayer()) |
5636 return; | 5616 return; |
5637 | 5617 |
5638 updateDescendantDependentFlags(); | 5618 updateDescendantDependentFlags(); |
5639 | 5619 |
5640 bool isStacking = false; | 5620 bool isStacking = false; |
5621 bool isNormalFlow = false; | |
5641 | 5622 |
5642 switch (behavior) { | 5623 switch (collectLayersBehavior) { |
5643 case StopAtStackingContexts: | 5624 case ForceLayerToStackingContainer: |
5644 isStacking = (this == layerToForceAsStackingContainer) || isStacking Context(); | 5625 ASSERT(layerToForceAsStackingContainer); |
5645 break; | 5626 if (this == layerToForceAsStackingContainer) { |
5646 | 5627 isStacking = true; |
5647 case StopAtStackingContainers: | 5628 isNormalFlow = false; |
5648 isStacking = (this == layerToForceAsStackingContainer) || isStacking Container(); | 5629 } else { |
5649 break; | 5630 isStacking = isStackingContext(); |
5631 isNormalFlow = shouldBeNormalFlowOnlyWithoutCompositedScrolling(); | |
5632 } | |
5633 break; | |
5634 case OverflowScrollCanBeStackingContainers: | |
5635 ASSERT(!layerToForceAsStackingContainer); | |
5636 isStacking = isStackingContainer(); | |
5637 isNormalFlow = isNormalFlowOnly(); | |
5638 break; | |
5639 case OnlyStackingContextsCanBeStackingContainers: | |
5640 isStacking = isStackingContext(); | |
5641 isNormalFlow = shouldBeNormalFlowOnlyWithoutCompositedScrolling(); | |
5642 break; | |
5650 } | 5643 } |
5651 | 5644 |
5652 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. | 5645 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. |
5653 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); | 5646 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); |
5654 if (includeHiddenLayer && !isNormalFlowOnly() && !isOutOfFlowRenderFlowThrea d()) { | 5647 if (includeHiddenLayer && !isNormalFlow && !isOutOfFlowRenderFlowThread()) { |
5655 // Determine which buffer the child should be in. | 5648 // Determine which buffer the child should be in. |
5656 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; | 5649 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; |
5657 | 5650 |
5658 // Create the buffer if it doesn't exist yet. | 5651 // Create the buffer if it doesn't exist yet. |
5659 if (!buffer) | 5652 if (!buffer) |
5660 buffer = adoptPtr(new Vector<RenderLayer*>); | 5653 buffer = adoptPtr(new Vector<RenderLayer*>); |
5661 | 5654 |
5662 // Append ourselves at the end of the appropriate buffer. | 5655 // Append ourselves at the end of the appropriate buffer. |
5663 buffer->append(this); | 5656 buffer->append(this); |
5664 } | 5657 } |
5665 | 5658 |
5666 // Recur into our children to collect more layers, but only if we don't esta blish | 5659 // Recur into our children to collect more layers, but only if we don't esta blish |
5667 // a stacking context/container. | 5660 // a stacking context/container. |
5668 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { | 5661 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { |
5669 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { | 5662 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { |
5670 // Ignore reflections. | 5663 // Ignore reflections. |
5671 if (!m_reflection || reflectionLayer() != child) | 5664 if (!m_reflection || reflectionLayer() != child) |
5672 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer, layerToForceAsStackingContainer); | 5665 child->collectLayers(includeHiddenLayers, posBuffer, negBuffer, layerToForceAsStackingContainer, collectLayersBehavior); |
5673 } | 5666 } |
5674 } | 5667 } |
5675 } | 5668 } |
5676 | 5669 |
5677 void RenderLayer::updateLayerListsIfNeeded() | 5670 void RenderLayer::updateLayerListsIfNeeded() |
5678 { | 5671 { |
5679 updateZOrderLists(); | 5672 updateZOrderLists(); |
5680 updateNormalFlowList(); | 5673 updateNormalFlowList(); |
5681 | 5674 |
5682 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { | 5675 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5724 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer))); | 5717 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend erer()->clippedOverflowRectForRepaint(repaintContainer))); |
5725 | 5718 |
5726 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { | 5719 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { |
5727 if (!curr->isComposited()) | 5720 if (!curr->isComposited()) |
5728 curr->repaintIncludingNonCompositingDescendants(repaintContainer); | 5721 curr->repaintIncludingNonCompositingDescendants(repaintContainer); |
5729 } | 5722 } |
5730 } | 5723 } |
5731 | 5724 |
5732 bool RenderLayer::shouldBeNormalFlowOnly() const | 5725 bool RenderLayer::shouldBeNormalFlowOnly() const |
5733 { | 5726 { |
5734 return (renderer()->hasOverflowClip() | 5727 return shouldBeNormalFlowOnlyWithoutCompositedScrolling() && !needsComposite dScrolling(); |
5735 || renderer()->hasReflection() | 5728 } |
5736 || renderer()->hasMask() | 5729 |
5737 || renderer()->isCanvas() | 5730 bool RenderLayer::shouldBeNormalFlowOnlyWithoutCompositedScrolling() const |
Julien - ping for review
2013/06/03 14:41:47
Nit: I would name it shouldBeNormalFlowOnlyIgnorin
hartmanng
2013/06/03 14:54:30
Done.
| |
5738 || renderer()->isVideo() | 5731 { |
5739 || renderer()->isEmbeddedObject() | 5732 const bool couldBeNormalFlow = renderer()->hasOverflowClip() |
5740 || renderer()->isRenderIFrame() | 5733 || renderer()->hasReflection() |
5741 || (renderer()->style()->specifiesColumns() && !isRootLayer())) | 5734 || renderer()->hasMask() |
5742 && !renderer()->isPositioned() | 5735 || renderer()->isCanvas() |
5743 && !renderer()->hasTransform() | 5736 || renderer()->isVideo() |
5744 && !renderer()->hasClipPath() | 5737 || renderer()->isEmbeddedObject() |
5745 && !renderer()->hasFilter() | 5738 || renderer()->isRenderIFrame() |
5746 && !renderer()->hasBlendMode() | 5739 || (renderer()->style()->specifiesColumns() && !isRootLayer()); |
5747 && !isTransparent() | 5740 const bool hasExceptionThatCannotBeNormalFlow = renderer()->isPositioned() |
Julien - ping for review
2013/06/03 14:41:47
Maybe better name preventsElementFromBeingNormalFl
hartmanng
2013/06/03 14:54:30
Done.
| |
5748 && !needsCompositedScrolling() | 5741 || renderer()->hasTransform() |
5749 && !renderer()->isFloatingWithShapeOutside() | 5742 || renderer()->hasClipPath() |
5750 ; | 5743 || renderer()->hasFilter() |
5744 || renderer()->hasBlendMode() | |
5745 || isTransparent() | |
5746 || renderer()->isFloatingWithShapeOutside(); | |
5747 | |
5748 return couldBeNormalFlow && !hasExceptionThatCannotBeNormalFlow; | |
5751 } | 5749 } |
5752 | 5750 |
5753 void RenderLayer::updateIsNormalFlowOnly() | 5751 void RenderLayer::updateIsNormalFlowOnly() |
5754 { | 5752 { |
5755 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 5753 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
5756 if (isNormalFlowOnly == m_isNormalFlowOnly) | 5754 if (isNormalFlowOnly == m_isNormalFlowOnly) |
5757 return; | 5755 return; |
5758 | 5756 |
5759 m_isNormalFlowOnly = isNormalFlowOnly; | 5757 m_isNormalFlowOnly = isNormalFlowOnly; |
5760 if (RenderLayer* p = parent()) | 5758 if (RenderLayer* p = parent()) |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6360 } | 6358 } |
6361 } | 6359 } |
6362 | 6360 |
6363 void showLayerTree(const WebCore::RenderObject* renderer) | 6361 void showLayerTree(const WebCore::RenderObject* renderer) |
6364 { | 6362 { |
6365 if (!renderer) | 6363 if (!renderer) |
6366 return; | 6364 return; |
6367 showLayerTree(renderer->enclosingLayer()); | 6365 showLayerTree(renderer->enclosingLayer()); |
6368 } | 6366 } |
6369 #endif | 6367 #endif |
OLD | NEW |