| 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 4942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5584 compositor()->setCompositingLayersNeedRebuild(); | 5564 compositor()->setCompositingLayersNeedRebuild(); |
| 5585 if (acceleratedCompositingForOverflowScrollEnabled()) | 5565 if (acceleratedCompositingForOverflowScrollEnabled()) |
| 5586 compositor()->setShouldReevaluateCompositingAfterLayout(); | 5566 compositor()->setShouldReevaluateCompositingAfterLayout(); |
| 5587 } | 5567 } |
| 5588 } | 5568 } |
| 5589 | 5569 |
| 5590 void RenderLayer::rebuildZOrderLists() | 5570 void RenderLayer::rebuildZOrderLists() |
| 5591 { | 5571 { |
| 5592 ASSERT(m_layerListMutationAllowed); | 5572 ASSERT(m_layerListMutationAllowed); |
| 5593 ASSERT(isDirtyStackingContainer()); | 5573 ASSERT(isDirtyStackingContainer()); |
| 5594 rebuildZOrderLists(StopAtStackingContainers, m_posZOrderList, m_negZOrderLis
t); | 5574 rebuildZOrderLists(m_posZOrderList, m_negZOrderList); |
| 5595 m_zOrderListsDirty = false; | 5575 m_zOrderListsDirty = false; |
| 5596 } | 5576 } |
| 5597 | 5577 |
| 5598 void RenderLayer::rebuildZOrderLists(CollectLayersBehavior behavior, OwnPtr<Vect
or<RenderLayer*> >& posZOrderList, OwnPtr<Vector<RenderLayer*> >& negZOrderList,
const RenderLayer* layerToForceAsStackingContainer) | 5578 void RenderLayer::rebuildZOrderLists(OwnPtr<Vector<RenderLayer*> >& posZOrderLis
t, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForce
AsStackingContainer, CollectLayersBehavior collectLayersBehavior) |
| 5599 { | 5579 { |
| 5600 bool includeHiddenLayers = compositor()->inCompositingMode(); | 5580 bool includeHiddenLayers = compositor()->inCompositingMode(); |
| 5601 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) | 5581 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) |
| 5602 if (!m_reflection || reflectionLayer() != child) | 5582 if (!m_reflection || reflectionLayer() != child) |
| 5603 child->collectLayers(includeHiddenLayers, behavior, posZOrderList, n
egZOrderList, layerToForceAsStackingContainer); | 5583 child->collectLayers(includeHiddenLayers, posZOrderList, negZOrderLi
st, layerToForceAsStackingContainer, collectLayersBehavior); |
| 5604 | 5584 |
| 5605 // Sort the two lists. | 5585 // Sort the two lists. |
| 5606 if (posZOrderList) | 5586 if (posZOrderList) |
| 5607 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI
ndex); | 5587 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI
ndex); |
| 5608 | 5588 |
| 5609 if (negZOrderList) | 5589 if (negZOrderList) |
| 5610 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI
ndex); | 5590 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI
ndex); |
| 5611 | 5591 |
| 5612 // Append layers for top layer elements after normal layer collection, to en
sure they are on top regardless of z-indexes. | 5592 // Append layers for top layer elements after normal layer collection, to en
sure they are on top regardless of z-indexes. |
| 5613 // The renderers of top layer elements are children of the view, sorted in t
op layer stacking order. | 5593 // 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... |
| 5635 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() !=
child)) { | 5615 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() !=
child)) { |
| 5636 if (!m_normalFlowList) | 5616 if (!m_normalFlowList) |
| 5637 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); | 5617 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); |
| 5638 m_normalFlowList->append(child); | 5618 m_normalFlowList->append(child); |
| 5639 } | 5619 } |
| 5640 } | 5620 } |
| 5641 | 5621 |
| 5642 m_normalFlowListDirty = false; | 5622 m_normalFlowListDirty = false; |
| 5643 } | 5623 } |
| 5644 | 5624 |
| 5645 void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior
behavior, OwnPtr<Vector<RenderLayer*> >& posBuffer, OwnPtr<Vector<RenderLayer*>
>& negBuffer, const RenderLayer* layerToForceAsStackingContainer) | 5625 void RenderLayer::collectLayers(bool includeHiddenLayers, OwnPtr<Vector<RenderLa
yer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer*
layerToForceAsStackingContainer, CollectLayersBehavior collectLayersBehavior) |
| 5646 { | 5626 { |
| 5647 if (isInTopLayer()) | 5627 if (isInTopLayer()) |
| 5648 return; | 5628 return; |
| 5649 | 5629 |
| 5650 updateDescendantDependentFlags(); | 5630 updateDescendantDependentFlags(); |
| 5651 | 5631 |
| 5652 bool isStacking = false; | 5632 bool isStacking = false; |
| 5633 bool isNormalFlow = false; |
| 5653 | 5634 |
| 5654 switch (behavior) { | 5635 switch (collectLayersBehavior) { |
| 5655 case StopAtStackingContexts: | 5636 case ForceLayerToStackingContainer: |
| 5656 isStacking = (this == layerToForceAsStackingContainer) || isStacking
Context(); | 5637 ASSERT(layerToForceAsStackingContainer); |
| 5657 break; | 5638 if (this == layerToForceAsStackingContainer) { |
| 5658 | 5639 isStacking = true; |
| 5659 case StopAtStackingContainers: | 5640 isNormalFlow = false; |
| 5660 isStacking = (this == layerToForceAsStackingContainer) || isStacking
Container(); | 5641 } else { |
| 5661 break; | 5642 isStacking = isStackingContext(); |
| 5643 isNormalFlow = shouldBeNormalFlowOnlyIgnoringCompositedScrolling(); |
| 5644 } |
| 5645 break; |
| 5646 case OverflowScrollCanBeStackingContainers: |
| 5647 ASSERT(!layerToForceAsStackingContainer); |
| 5648 isStacking = isStackingContainer(); |
| 5649 isNormalFlow = isNormalFlowOnly(); |
| 5650 break; |
| 5651 case OnlyStackingContextsCanBeStackingContainers: |
| 5652 isStacking = isStackingContext(); |
| 5653 isNormalFlow = shouldBeNormalFlowOnlyIgnoringCompositedScrolling(); |
| 5654 break; |
| 5662 } | 5655 } |
| 5663 | 5656 |
| 5664 // Overflow layers are just painted by their enclosing layers, so they don't
get put in zorder lists. | 5657 // Overflow layers are just painted by their enclosing layers, so they don't
get put in zorder lists. |
| 5665 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_
hasVisibleDescendant && isStacking)); | 5658 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_
hasVisibleDescendant && isStacking)); |
| 5666 if (includeHiddenLayer && !isNormalFlowOnly() && !isOutOfFlowRenderFlowThrea
d()) { | 5659 if (includeHiddenLayer && !isNormalFlow && !isOutOfFlowRenderFlowThread()) { |
| 5667 // Determine which buffer the child should be in. | 5660 // Determine which buffer the child should be in. |
| 5668 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne
gBuffer; | 5661 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne
gBuffer; |
| 5669 | 5662 |
| 5670 // Create the buffer if it doesn't exist yet. | 5663 // Create the buffer if it doesn't exist yet. |
| 5671 if (!buffer) | 5664 if (!buffer) |
| 5672 buffer = adoptPtr(new Vector<RenderLayer*>); | 5665 buffer = adoptPtr(new Vector<RenderLayer*>); |
| 5673 | 5666 |
| 5674 // Append ourselves at the end of the appropriate buffer. | 5667 // Append ourselves at the end of the appropriate buffer. |
| 5675 buffer->append(this); | 5668 buffer->append(this); |
| 5676 } | 5669 } |
| 5677 | 5670 |
| 5678 // Recur into our children to collect more layers, but only if we don't esta
blish | 5671 // Recur into our children to collect more layers, but only if we don't esta
blish |
| 5679 // a stacking context/container. | 5672 // a stacking context/container. |
| 5680 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { | 5673 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { |
| 5681 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin
g()) { | 5674 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin
g()) { |
| 5682 // Ignore reflections. | 5675 // Ignore reflections. |
| 5683 if (!m_reflection || reflectionLayer() != child) | 5676 if (!m_reflection || reflectionLayer() != child) |
| 5684 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n
egBuffer, layerToForceAsStackingContainer); | 5677 child->collectLayers(includeHiddenLayers, posBuffer, negBuffer,
layerToForceAsStackingContainer, collectLayersBehavior); |
| 5685 } | 5678 } |
| 5686 } | 5679 } |
| 5687 } | 5680 } |
| 5688 | 5681 |
| 5689 void RenderLayer::updateLayerListsIfNeeded() | 5682 void RenderLayer::updateLayerListsIfNeeded() |
| 5690 { | 5683 { |
| 5691 updateZOrderLists(); | 5684 updateZOrderLists(); |
| 5692 updateNormalFlowList(); | 5685 updateNormalFlowList(); |
| 5693 | 5686 |
| 5694 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { | 5687 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5736 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend
erer()->clippedOverflowRectForRepaint(repaintContainer))); | 5729 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(rend
erer()->clippedOverflowRectForRepaint(repaintContainer))); |
| 5737 | 5730 |
| 5738 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { | 5731 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) { |
| 5739 if (!curr->isComposited()) | 5732 if (!curr->isComposited()) |
| 5740 curr->repaintIncludingNonCompositingDescendants(repaintContainer); | 5733 curr->repaintIncludingNonCompositingDescendants(repaintContainer); |
| 5741 } | 5734 } |
| 5742 } | 5735 } |
| 5743 | 5736 |
| 5744 bool RenderLayer::shouldBeNormalFlowOnly() const | 5737 bool RenderLayer::shouldBeNormalFlowOnly() const |
| 5745 { | 5738 { |
| 5746 return (renderer()->hasOverflowClip() | 5739 return shouldBeNormalFlowOnlyIgnoringCompositedScrolling() && !needsComposit
edScrolling(); |
| 5747 || renderer()->hasReflection() | 5740 } |
| 5748 || renderer()->hasMask() | 5741 |
| 5749 || renderer()->isCanvas() | 5742 bool RenderLayer::shouldBeNormalFlowOnlyIgnoringCompositedScrolling() const |
| 5750 || renderer()->isVideo() | 5743 { |
| 5751 || renderer()->isEmbeddedObject() | 5744 const bool couldBeNormalFlow = renderer()->hasOverflowClip() |
| 5752 || renderer()->isRenderIFrame() | 5745 || renderer()->hasReflection() |
| 5753 || (renderer()->style()->specifiesColumns() && !isRootLayer())) | 5746 || renderer()->hasMask() |
| 5754 && !renderer()->isPositioned() | 5747 || renderer()->isCanvas() |
| 5755 && !renderer()->hasTransform() | 5748 || renderer()->isVideo() |
| 5756 && !renderer()->hasClipPath() | 5749 || renderer()->isEmbeddedObject() |
| 5757 && !renderer()->hasFilter() | 5750 || renderer()->isRenderIFrame() |
| 5758 && !renderer()->hasBlendMode() | 5751 || (renderer()->style()->specifiesColumns() && !isRootLayer()); |
| 5759 && !isTransparent() | 5752 const bool preventsElementFromBeingNormalFlow = renderer()->isPositioned() |
| 5760 && !needsCompositedScrolling() | 5753 || renderer()->hasTransform() |
| 5761 && !renderer()->isFloatingWithShapeOutside() | 5754 || renderer()->hasClipPath() |
| 5762 ; | 5755 || renderer()->hasFilter() |
| 5756 || renderer()->hasBlendMode() |
| 5757 || isTransparent() |
| 5758 || renderer()->isFloatingWithShapeOutside(); |
| 5759 |
| 5760 return couldBeNormalFlow && !preventsElementFromBeingNormalFlow; |
| 5763 } | 5761 } |
| 5764 | 5762 |
| 5765 void RenderLayer::updateIsNormalFlowOnly() | 5763 void RenderLayer::updateIsNormalFlowOnly() |
| 5766 { | 5764 { |
| 5767 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 5765 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
| 5768 if (isNormalFlowOnly == m_isNormalFlowOnly) | 5766 if (isNormalFlowOnly == m_isNormalFlowOnly) |
| 5769 return; | 5767 return; |
| 5770 | 5768 |
| 5771 m_isNormalFlowOnly = isNormalFlowOnly; | 5769 m_isNormalFlowOnly = isNormalFlowOnly; |
| 5772 if (RenderLayer* p = parent()) | 5770 if (RenderLayer* p = parent()) |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6372 } | 6370 } |
| 6373 } | 6371 } |
| 6374 | 6372 |
| 6375 void showLayerTree(const WebCore::RenderObject* renderer) | 6373 void showLayerTree(const WebCore::RenderObject* renderer) |
| 6376 { | 6374 { |
| 6377 if (!renderer) | 6375 if (!renderer) |
| 6378 return; | 6376 return; |
| 6379 showLayerTree(renderer->enclosingLayer()); | 6377 showLayerTree(renderer->enclosingLayer()); |
| 6380 } | 6378 } |
| 6381 #endif | 6379 #endif |
| OLD | NEW |