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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #include "HTMLFrameElement.h" | 71 #include "HTMLFrameElement.h" |
| 72 #include "HTMLFrameOwnerElement.h" | 72 #include "HTMLFrameOwnerElement.h" |
| 73 #include "HTMLNames.h" | 73 #include "HTMLNames.h" |
| 74 #include "HistogramSupport.h" | 74 #include "HistogramSupport.h" |
| 75 #include "HitTestingTransformState.h" | 75 #include "HitTestingTransformState.h" |
| 76 #include "HitTestRequest.h" | 76 #include "HitTestRequest.h" |
| 77 #include "HitTestResult.h" | 77 #include "HitTestResult.h" |
| 78 #include "OverflowEvent.h" | 78 #include "OverflowEvent.h" |
| 79 #include "OverlapTestRequestClient.h" | 79 #include "OverlapTestRequestClient.h" |
| 80 #include "Page.h" | 80 #include "Page.h" |
| 81 #include "PaintOrderLists.h" | |
| 81 #include "PlatformMouseEvent.h" | 82 #include "PlatformMouseEvent.h" |
| 82 #include "RenderArena.h" | 83 #include "RenderArena.h" |
| 83 #include "RenderFlowThread.h" | 84 #include "RenderFlowThread.h" |
| 84 #include "RenderGeometryMap.h" | 85 #include "RenderGeometryMap.h" |
| 85 #include "RenderInline.h" | 86 #include "RenderInline.h" |
| 86 #include "RenderLayerBacking.h" | 87 #include "RenderLayerBacking.h" |
| 87 #include "RenderLayerCompositor.h" | 88 #include "RenderLayerCompositor.h" |
| 88 #include "RenderMarquee.h" | 89 #include "RenderMarquee.h" |
| 89 #include "RenderReplica.h" | 90 #include "RenderReplica.h" |
| 90 #include "RenderSVGResourceClipper.h" | 91 #include "RenderSVGResourceClipper.h" |
| 91 #include "RenderScrollbar.h" | 92 #include "RenderScrollbar.h" |
| 92 #include "RenderScrollbarPart.h" | 93 #include "RenderScrollbarPart.h" |
| 93 #include "RenderTheme.h" | 94 #include "RenderTheme.h" |
| 94 #include "RenderTreeAsText.h" | 95 #include "RenderTreeAsText.h" |
| 95 #include "RenderView.h" | 96 #include "RenderView.h" |
| 96 #include "ScaleTransformOperation.h" | 97 #include "ScaleTransformOperation.h" |
| 97 #include "ScrollAnimator.h" | 98 #include "ScrollAnimator.h" |
| 98 #include "Scrollbar.h" | 99 #include "Scrollbar.h" |
| 99 #include "ScrollbarTheme.h" | 100 #include "ScrollbarTheme.h" |
| 100 #include "ScrollingCoordinator.h" | 101 #include "ScrollingCoordinator.h" |
| 101 #include "Settings.h" | 102 #include "Settings.h" |
| 102 #include "ShadowRoot.h" | 103 #include "ShadowRoot.h" |
| 103 #include "SourceGraphic.h" | 104 #include "SourceGraphic.h" |
| 105 #include "StaticHashSetNodeList.h" | |
| 104 #include "StylePropertySet.h" | 106 #include "StylePropertySet.h" |
| 105 #include "StyleResolver.h" | 107 #include "StyleResolver.h" |
| 106 #include "TextStream.h" | 108 #include "TextStream.h" |
| 107 #include "TransformationMatrix.h" | 109 #include "TransformationMatrix.h" |
| 108 #include "TranslateTransformOperation.h" | 110 #include "TranslateTransformOperation.h" |
| 109 #include "WebCoreMemoryInstrumentation.h" | 111 #include "WebCoreMemoryInstrumentation.h" |
| 110 #include <wtf/MemoryInstrumentationVector.h> | 112 #include <wtf/MemoryInstrumentationVector.h> |
| 111 #include <wtf/StdLibExtras.h> | 113 #include <wtf/StdLibExtras.h> |
| 112 #include <wtf/UnusedParam.h> | 114 #include <wtf/UnusedParam.h> |
| 113 #include <wtf/text/CString.h> | 115 #include <wtf/text/CString.h> |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 | 668 |
| 667 if (!isStackingContext()) { | 669 if (!isStackingContext()) { |
| 668 bool newValue = maxIndex - minIndex == count; | 670 bool newValue = maxIndex - minIndex == count; |
| 669 bool didUpdate = newValue != m_descendantsAreContiguousInStackingOrder; | 671 bool didUpdate = newValue != m_descendantsAreContiguousInStackingOrder; |
| 670 m_descendantsAreContiguousInStackingOrder = newValue; | 672 m_descendantsAreContiguousInStackingOrder = newValue; |
| 671 if (didUpdate) | 673 if (didUpdate) |
| 672 updateNeedsCompositedScrolling(); | 674 updateNeedsCompositedScrolling(); |
| 673 } | 675 } |
| 674 } | 676 } |
| 675 | 677 |
| 678 static inline bool isPositionedContainer(const RenderLayer* layer) | |
| 679 { | |
| 680 // FIXME: This is not in sync with containingBlock. | |
| 681 // RenderObject::canContainFixedPositionedObject() should probably be used | |
| 682 // instead. | |
| 683 RenderLayerModelObject* layerRenderer = layer->renderer(); | |
| 684 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); | |
| 685 } | |
| 686 | |
| 687 enum StackingOrderDirection { FromBackground, FromForeground }; | |
| 688 | |
| 689 // We'd like to be able to iterate through a single paint order list, but for | |
| 690 // efficiency's sake, we hang onto two lists instead (namely, the pos and neg | |
| 691 // z-order lists produced by CollectLayers). This function allows us to index | |
| 692 // into these two lists as if they were one. It also allows us to index into | |
| 693 // this virtual list either from the start or from the end (i.e., in either | |
| 694 // stacking order direction). | |
| 695 static const RenderLayer* getStackingOrderElementAt(const Vector<RenderLayer*>* posZOrderList, const Vector<RenderLayer*>* negZOrderList, const StackingOrderDir ection direction, const size_t index) | |
| 696 { | |
| 697 size_t negZOrderListSize = negZOrderList ? negZOrderList->size() : 0; | |
| 698 | |
| 699 if (direction == FromBackground) { | |
| 700 if (index < negZOrderListSize) | |
| 701 return negZOrderList->at(index); | |
| 702 | |
| 703 return posZOrderList->at(index - negZOrderListSize); | |
| 704 } | |
| 705 | |
| 706 size_t posZOrderListSize = posZOrderList ? posZOrderList->size() : 0; | |
| 707 | |
| 708 if (index < posZOrderListSize) | |
| 709 return posZOrderList->at(posZOrderListSize - index - 1); | |
| 710 | |
| 711 return negZOrderList->at(negZOrderListSize - (index - posZOrderListSize) - 1 ); | |
| 712 } | |
| 713 | |
| 714 void RenderLayer::collectBeforeAfterPromotionZOrderLists(RenderLayer* ancestorSt ackingContext, | |
| 715 OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, | |
| 716 OwnPtr<Vector<RenderLayer*> >& negZOrderListBeforePromote, | |
| 717 OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, | |
| 718 OwnPtr<Vector<RenderLayer*> >& negZOrderListAfterPromote) | |
| 719 { | |
| 720 // We can't use TemporaryChange<> here since m_needsCompositedScrolling and | |
| 721 // m_isNormalFlowOnly are both bitfields, so we have to do it the | |
| 722 // old-fashioned way. | |
| 723 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | |
| 724 bool oldIsNormalFlowOnly = m_isNormalFlowOnly; | |
| 725 | |
| 726 // Set the flag on the current layer, then rebuild ancestor stacking | |
| 727 // context's lists. This way, we can see the exact effects that promoting | |
| 728 // this layer would cause. | |
| 729 m_needsCompositedScrolling = false; | |
| 730 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); | |
| 731 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListBeforePromote, negZOrderListBeforePromote, 0); | |
| 732 | |
| 733 m_isNormalFlowOnly = false; | |
| 734 m_needsCompositedScrolling = true; | |
| 735 ancestorStackingContext->rebuildZOrderLists(StopAtStackingContexts, posZOrde rListAfterPromote, negZOrderListAfterPromote, this); | |
| 736 | |
| 737 m_needsCompositedScrolling = oldNeedsCompositedScrolling; | |
| 738 m_isNormalFlowOnly = oldIsNormalFlowOnly; | |
| 739 } | |
| 740 | |
| 741 // Compute what positive and negative z-order lists would look like before and | |
| 742 // after promotion, so we can later ensure that proper stacking order is | |
| 743 // preserved between the two sets of lists. | |
| 744 // | |
| 745 // A few examples: | |
| 746 // c = currentLayer | |
| 747 // - = negative z-order child of currentLayer | |
| 748 // + = positive z-order child of currentLayer | |
| 749 // a = positioned ancestor of currentLayer | |
| 750 // x = any other RenderLayer in the list | |
| 751 // | |
| 752 // (a) xxxxx-----++a+++x | |
| 753 // (b) xxx-----c++++++xx | |
| 754 // | |
| 755 // | |
| 756 // Normally the current layer would be painted in the normal flow list if it | |
| 757 // doesn't already appear in the positive z-order list. However, in the case | |
| 758 // that the layer has a positioned ancestor, it will paint directly after the | |
| 759 // positioned ancestor. In example (a), the current layer would be painted in | |
| 760 // the middle of its own positive z-order children, so promoting would cause a | |
| 761 // change in paint order (since a promoted layer will paint all of its positive | |
| 762 // z-order children strictly after it paints itself). | |
| 763 // | |
| 764 // In example (b), it is ok to promote the current layer only if it does not | |
| 765 // have a background. If it has a background, the background gets painted before | |
| 766 // the layer's negative z-order children, so again, a promotion would cause a | |
| 767 // change in paint order (causing the background to get painted after the | |
| 768 // negative z-order children instead of before). | |
| 769 void RenderLayer::getPaintOrderLists(RenderLayer* ancestorStackingContext, | |
| 770 OwnPtr<Vector<RenderLayer*> >& posZOrderListBeforePromote, | |
| 771 OwnPtr<Vector<RenderLayer*> >& negZOrderListBeforePromote, | |
| 772 OwnPtr<Vector<RenderLayer*> >& posZOrderListAfterPromote, | |
| 773 OwnPtr<Vector<RenderLayer*> >& negZOrderListAfterPromote) | |
| 774 { | |
| 775 collectBeforeAfterPromotionZOrderLists(ancestorStackingContext, | |
| 776 posZOrderListBeforePromote, negZOrderListBeforePromote, | |
| 777 posZOrderListAfterPromote, negZOrderListAfterPromote); | |
| 778 | |
| 779 size_t posZOrderListSizeBeforePromote = posZOrderListBeforePromote ? posZOrd erListBeforePromote->size() : 0; | |
| 780 | |
| 781 const RenderLayer* positionedAncestor = parent(); | |
| 782 while (positionedAncestor && !isPositionedContainer(positionedAncestor) && ! positionedAncestor->isStackingContext()) | |
| 783 positionedAncestor = positionedAncestor->parent(); | |
| 784 if (positionedAncestor && (!isPositionedContainer(positionedAncestor) || pos itionedAncestor->isStackingContext())) | |
| 785 positionedAncestor = 0; | |
| 786 | |
| 787 bool currentLayerIsInPosZOrderListBeforePromote = false; | |
| 788 | |
| 789 for (size_t index = 0; index < posZOrderListSizeBeforePromote; index++) { | |
| 790 if (posZOrderListBeforePromote->at(index) == this) { | |
| 791 currentLayerIsInPosZOrderListBeforePromote = true; | |
| 792 break; | |
| 793 } | |
| 794 } | |
| 795 | |
| 796 // Insert this into the posZOrderistBeforePromote directly after the | |
| 797 // positioned ancestor, if there is one. Otherwise, add it to the very | |
| 798 // beginning. | |
| 799 // | |
| 800 // The current layer will appear in the z-order lists after promotion, so | |
| 801 // for a meaningful comparison, we must insert it in the z-order lists | |
| 802 // before promotion if it does not appear there already. | |
| 803 if (!currentLayerIsInPosZOrderListBeforePromote) { | |
| 804 if (!positionedAncestor) { | |
| 805 if (!posZOrderListBeforePromote) | |
| 806 posZOrderListBeforePromote = adoptPtr(new Vector<RenderLayer*>() ); | |
| 807 | |
| 808 posZOrderListBeforePromote->prepend(this); | |
| 809 posZOrderListSizeBeforePromote++; | |
| 810 } else { | |
| 811 for (size_t index = 0; index < posZOrderListSizeBeforePromote; index ++) { | |
| 812 if (posZOrderListBeforePromote->at(index) == positionedAncestor) { | |
| 813 posZOrderListBeforePromote->insert(index + 1, this); | |
| 814 posZOrderListSizeBeforePromote++; | |
| 815 break; | |
| 816 } | |
| 817 } | |
| 818 } | |
| 819 } | |
| 820 } | |
| 821 | |
| 822 String RenderLayer::paintOrderListsAsText() | |
| 823 { | |
| 824 OwnPtr<Vector<RenderLayer*> > posZOrderListBeforePromote; | |
| 825 OwnPtr<Vector<RenderLayer*> > negZOrderListBeforePromote; | |
| 826 OwnPtr<Vector<RenderLayer*> > posZOrderListAfterPromote; | |
| 827 OwnPtr<Vector<RenderLayer*> > negZOrderListAfterPromote; | |
| 828 | |
| 829 RenderLayer* ancestorStackingContext = this; | |
| 830 | |
| 831 while (ancestorStackingContext) { | |
| 832 if (ancestorStackingContext != this && ancestorStackingContext->isStacki ngContext()) | |
| 833 break; | |
| 834 ancestorStackingContext = ancestorStackingContext->parent(); | |
| 835 } | |
| 836 | |
| 837 if (!ancestorStackingContext) | |
| 838 return String(); | |
| 839 | |
| 840 getPaintOrderLists(ancestorStackingContext, | |
| 841 posZOrderListBeforePromote, negZOrderListBeforePromote, | |
| 842 posZOrderListAfterPromote, negZOrderListAfterPromote); | |
| 843 | |
| 844 size_t posZOrderListSizeBeforePromote = posZOrderListBeforePromote ? posZOrd erListBeforePromote->size() : 0; | |
| 845 size_t negZOrderListSizeBeforePromote = negZOrderListBeforePromote ? negZOrd erListBeforePromote->size() : 0; | |
| 846 size_t posZOrderListSizeAfterPromote = posZOrderListAfterPromote ? posZOrder ListAfterPromote->size() : 0; | |
| 847 size_t negZOrderListSizeAfterPromote = negZOrderListAfterPromote ? negZOrder ListAfterPromote->size() : 0; | |
| 848 | |
| 849 size_t sizeBeforePromote = posZOrderListSizeBeforePromote + negZOrderListSiz eBeforePromote; | |
| 850 size_t sizeAfterPromote = posZOrderListSizeAfterPromote + negZOrderListSizeA fterPromote; | |
| 851 | |
| 852 TextStream ts; | |
| 853 | |
| 854 ts << "Layer: " << this << " \"" << name() << "\", z-index: " << renderer()- >style()->zIndex() << "\n"; | |
| 855 | |
| 856 ts << " stacking context's paint order list BEFORE promote:\n"; | |
| 857 for (size_t index = 0; index < sizeBeforePromote; index++) { | |
| 858 const RenderLayer* layerBeforePromote = getStackingOrderElementAt(posZOr derListBeforePromote.get(), negZOrderListBeforePromote.get(), FromBackground, in dex); | |
| 859 ts << " " << layerBeforePromote << " \"" << layerBeforePromote->name( ) << "\", z-index: " << layerBeforePromote->renderer()->style()->zIndex() << "\n "; | |
| 860 } | |
| 861 | |
| 862 ts << " stacking context's paint order list AFTER promote:\n"; | |
| 863 for (size_t index = 0; index < sizeAfterPromote; index++) { | |
| 864 const RenderLayer* layerAfterPromote = getStackingOrderElementAt(posZOrd erListAfterPromote.get(), negZOrderListAfterPromote.get(), FromBackground, index ); | |
| 865 ts << " " << layerAfterPromote << " \"" << layerAfterPromote->name() << "\", z-index: " << layerAfterPromote->renderer()->style()->zIndex() << "\n"; | |
| 866 } | |
| 867 | |
| 868 return ts.release(); | |
| 869 } | |
| 870 | |
| 871 PassRefPtr<PaintOrderLists> RenderLayer::paintOrderLists() | |
| 872 { | |
| 873 OwnPtr<Vector<RenderLayer*> > posZOrderListBeforePromote; | |
| 874 OwnPtr<Vector<RenderLayer*> > negZOrderListBeforePromote; | |
| 875 OwnPtr<Vector<RenderLayer*> > posZOrderListAfterPromote; | |
| 876 OwnPtr<Vector<RenderLayer*> > negZOrderListAfterPromote; | |
| 877 | |
| 878 RenderLayer* ancestorStackingContext = this; | |
| 879 | |
| 880 while (ancestorStackingContext) { | |
| 881 if (ancestorStackingContext != this && ancestorStackingContext->isStacki ngContext()) | |
| 882 break; | |
| 883 ancestorStackingContext = ancestorStackingContext->parent(); | |
| 884 } | |
| 885 | |
| 886 if (!ancestorStackingContext) | |
| 887 return 0; | |
| 888 | |
| 889 getPaintOrderLists(ancestorStackingContext, | |
| 890 posZOrderListBeforePromote, negZOrderListBeforePromote, | |
| 891 posZOrderListAfterPromote, negZOrderListAfterPromote); | |
| 892 | |
| 893 size_t posZOrderListSizeBeforePromote = posZOrderListBeforePromote ? posZOrd erListBeforePromote->size() : 0; | |
| 894 size_t negZOrderListSizeBeforePromote = negZOrderListBeforePromote ? negZOrd erListBeforePromote->size() : 0; | |
| 895 size_t posZOrderListSizeAfterPromote = posZOrderListAfterPromote ? posZOrder ListAfterPromote->size() : 0; | |
| 896 size_t negZOrderListSizeAfterPromote = negZOrderListAfterPromote ? negZOrder ListAfterPromote->size() : 0; | |
| 897 | |
| 898 size_t sizeBeforePromote = posZOrderListSizeBeforePromote + negZOrderListSiz eBeforePromote; | |
| 899 size_t sizeAfterPromote = posZOrderListSizeAfterPromote + negZOrderListSizeA fterPromote; | |
| 900 | |
| 901 ListHashSet<RefPtr<Node> > listBeforePromote; | |
| 902 for (size_t index = 0; index < sizeBeforePromote; index++) { | |
| 903 const RenderLayer* layerBeforePromote = getStackingOrderElementAt(posZOr derListBeforePromote.get(), negZOrderListBeforePromote.get(), FromBackground, in dex); | |
| 904 listBeforePromote.add(layerBeforePromote->renderer()->node()); | |
| 905 } | |
| 906 | |
| 907 ListHashSet<RefPtr<Node> > listAfterPromote; | |
| 908 for (size_t index = 0; index < sizeAfterPromote; index++) { | |
| 909 const RenderLayer* layerAfterPromote = getStackingOrderElementAt(posZOrd erListAfterPromote.get(), negZOrderListAfterPromote.get(), FromBackground, index ); | |
| 910 listAfterPromote.add(layerAfterPromote->renderer()->node()); | |
| 911 } | |
| 912 | |
| 913 PassRefPtr<PaintOrderLists> paintOrderLists = adoptRef(new PaintOrderLists(S taticHashSetNodeList::adopt(listBeforePromote), StaticHashSetNodeList::adopt(lis tAfterPromote))); | |
| 914 return paintOrderLists; | |
| 915 } | |
| 916 | |
| 917 | |
| 676 void RenderLayer::computeRepaintRects(const RenderLayerModelObject* repaintConta iner, const RenderGeometryMap* geometryMap) | 918 void RenderLayer::computeRepaintRects(const RenderLayerModelObject* repaintConta iner, const RenderGeometryMap* geometryMap) |
| 677 { | 919 { |
| 678 ASSERT(!m_visibleContentStatusDirty); | 920 ASSERT(!m_visibleContentStatusDirty); |
| 679 | 921 |
| 680 m_repaintRect = renderer()->clippedOverflowRectForRepaint(repaintContainer); | 922 m_repaintRect = renderer()->clippedOverflowRectForRepaint(repaintContainer); |
| 681 m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer, geometr yMap); | 923 m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer, geometr yMap); |
| 682 } | 924 } |
| 683 | 925 |
| 684 | 926 |
| 685 void RenderLayer::computeRepaintRectsIncludingDescendants() | 927 void RenderLayer::computeRepaintRectsIncludingDescendants() |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1284 RenderLayer* RenderLayer::stackingContainer() const | 1526 RenderLayer* RenderLayer::stackingContainer() const |
| 1285 { | 1527 { |
| 1286 RenderLayer* layer = parent(); | 1528 RenderLayer* layer = parent(); |
| 1287 while (layer && !layer->isStackingContainer()) | 1529 while (layer && !layer->isStackingContainer()) |
| 1288 layer = layer->parent(); | 1530 layer = layer->parent(); |
| 1289 | 1531 |
| 1290 ASSERT(!layer || layer->isStackingContainer()); | 1532 ASSERT(!layer || layer->isStackingContainer()); |
| 1291 return layer; | 1533 return layer; |
| 1292 } | 1534 } |
| 1293 | 1535 |
| 1294 static inline bool isPositionedContainer(RenderLayer* layer) | |
| 1295 { | |
| 1296 RenderLayerModelObject* layerRenderer = layer->renderer(); | |
| 1297 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); | |
| 1298 } | |
| 1299 | |
| 1300 static inline bool isFixedPositionedContainer(RenderLayer* layer) | 1536 static inline bool isFixedPositionedContainer(RenderLayer* layer) |
| 1301 { | 1537 { |
| 1302 return layer->isRootLayer() || layer->hasTransform(); | 1538 return layer->isRootLayer() || layer->hasTransform(); |
| 1303 } | 1539 } |
| 1304 | 1540 |
| 1305 RenderLayer* RenderLayer::enclosingPositionedAncestor() const | 1541 RenderLayer* RenderLayer::enclosingPositionedAncestor() const |
| 1306 { | 1542 { |
| 1307 RenderLayer* curr = parent(); | 1543 RenderLayer* curr = parent(); |
| 1308 while (curr && !isPositionedContainer(curr)) | 1544 while (curr && !isPositionedContainer(curr)) |
| 1309 curr = curr->parent(); | 1545 curr = curr->parent(); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1941 bool RenderLayer::usesCompositedScrolling() const | 2177 bool RenderLayer::usesCompositedScrolling() const |
| 1942 { | 2178 { |
| 1943 return isComposited() && backing()->scrollingLayer(); | 2179 return isComposited() && backing()->scrollingLayer(); |
| 1944 } | 2180 } |
| 1945 | 2181 |
| 1946 bool RenderLayer::needsCompositedScrolling() const | 2182 bool RenderLayer::needsCompositedScrolling() const |
| 1947 { | 2183 { |
| 1948 return m_needsCompositedScrolling; | 2184 return m_needsCompositedScrolling; |
| 1949 } | 2185 } |
| 1950 | 2186 |
| 2187 void RenderLayer::updateIsNormalFlowOnly() | |
| 2188 { | |
| 2189 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | |
| 2190 if (isNormalFlowOnly != m_isNormalFlowOnly) { | |
| 2191 m_isNormalFlowOnly = isNormalFlowOnly; | |
| 2192 RenderLayer* p = parent(); | |
| 2193 if (p) | |
| 2194 p->dirtyNormalFlowList(); | |
| 2195 dirtyStackingContainerZOrderLists(); | |
| 2196 } | |
| 2197 } | |
| 2198 | |
| 2199 | |
| 1951 void RenderLayer::updateNeedsCompositedScrolling() | 2200 void RenderLayer::updateNeedsCompositedScrolling() |
| 1952 { | 2201 { |
| 1953 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; | 2202 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; |
| 1954 | 2203 |
| 1955 FrameView* frameView = renderer()->view()->frameView(); | 2204 FrameView* frameView = renderer()->view()->frameView(); |
| 1956 if (!frameView || !frameView->containsScrollableArea(this)) | 2205 if (!frameView || !frameView->containsScrollableArea(this)) |
| 1957 m_needsCompositedScrolling = false; | 2206 m_needsCompositedScrolling = false; |
| 1958 else { | 2207 else { |
| 1959 bool forceUseCompositedScrolling = acceleratedCompositingForOverflowScro llEnabled() | 2208 bool forceUseCompositedScrolling = acceleratedCompositingForOverflowScro llEnabled() |
| 1960 && canBeStackingContainer() | 2209 && canBeStackingContainer() |
| 1961 && !hasOutOfFlowPositionedDescendant(); | 2210 && !hasOutOfFlowPositionedDescendant(); |
| 1962 | 2211 |
| 1963 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) | 2212 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) |
| 1964 m_needsCompositedScrolling = forceUseCompositedScrolling || renderer()-> style()->useTouchOverflowScrolling(); | 2213 m_needsCompositedScrolling = forceUseCompositedScrolling || renderer()-> style()->useTouchOverflowScrolling(); |
| 1965 #else | 2214 #else |
| 1966 m_needsCompositedScrolling = forceUseCompositedScrolling; | 2215 m_needsCompositedScrolling = forceUseCompositedScrolling; |
| 1967 #endif | 2216 #endif |
| 1968 // We gather a boolean value for use with Google UMA histograms to | 2217 // We gather a boolean value for use with Google UMA histograms to |
| 1969 // quantify the actual effects of a set of patches attempting to | 2218 // quantify the actual effects of a set of patches attempting to |
| 1970 // relax composited scrolling requirements, thereby increasing the | 2219 // relax composited scrolling requirements, thereby increasing the |
| 1971 // number of composited overflow divs. | 2220 // number of composited overflow divs. |
| 1972 if (acceleratedCompositingForOverflowScrollEnabled()) | 2221 if (acceleratedCompositingForOverflowScrollEnabled()) |
| 1973 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScro lling", m_needsCompositedScrolling, 2); | 2222 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScro lling", m_needsCompositedScrolling, 2); |
| 1974 } | 2223 } |
| 1975 | 2224 |
| 1976 if (oldNeedsCompositedScrolling != m_needsCompositedScrolling) { | 2225 if (oldNeedsCompositedScrolling != m_needsCompositedScrolling) { |
| 2226 updateIsNormalFlowOnly(); | |
|
shawnsingh
2013/04/09 20:16:07
I'm under the impression this is a drive-by bugfix
| |
| 1977 updateSelfPaintingLayer(); | 2227 updateSelfPaintingLayer(); |
| 1978 if (isStackingContainer()) | 2228 if (isStackingContainer()) |
| 1979 dirtyZOrderLists(); | 2229 dirtyZOrderLists(); |
| 1980 else | 2230 else |
| 1981 clearZOrderLists(); | 2231 clearZOrderLists(); |
| 1982 | 2232 |
| 1983 dirtyStackingContainerZOrderLists(); | 2233 dirtyStackingContainerZOrderLists(); |
| 1984 | 2234 |
| 1985 compositor()->setShouldReevaluateCompositingAfterLayout(); | 2235 compositor()->setShouldReevaluateCompositingAfterLayout(); |
| 1986 compositor()->setCompositingLayersNeedRebuild(); | 2236 compositor()->setCompositingLayersNeedRebuild(); |
| (...skipping 3565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5552 } | 5802 } |
| 5553 | 5803 |
| 5554 void RenderLayer::rebuildZOrderLists() | 5804 void RenderLayer::rebuildZOrderLists() |
| 5555 { | 5805 { |
| 5556 ASSERT(m_layerListMutationAllowed); | 5806 ASSERT(m_layerListMutationAllowed); |
| 5557 ASSERT(isDirtyStackingContainer()); | 5807 ASSERT(isDirtyStackingContainer()); |
| 5558 rebuildZOrderLists(StopAtStackingContainers, m_posZOrderList, m_negZOrderLis t); | 5808 rebuildZOrderLists(StopAtStackingContainers, m_posZOrderList, m_negZOrderLis t); |
| 5559 m_zOrderListsDirty = false; | 5809 m_zOrderListsDirty = false; |
| 5560 } | 5810 } |
| 5561 | 5811 |
| 5562 void RenderLayer::rebuildZOrderLists(CollectLayersBehavior behavior, OwnPtr<Vect or<RenderLayer*> >& posZOrderList, OwnPtr<Vector<RenderLayer*> >& negZOrderList) | 5812 void RenderLayer::rebuildZOrderLists(CollectLayersBehavior behavior, OwnPtr<Vect or<RenderLayer*> >& posZOrderList, OwnPtr<Vector<RenderLayer*> >& negZOrderList, const RenderLayer* layerToForceAsStackingContext) |
| 5563 { | 5813 { |
| 5564 bool includeHiddenLayers = compositor()->inCompositingMode(); | 5814 bool includeHiddenLayers = compositor()->inCompositingMode(); |
| 5565 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) | 5815 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) |
| 5566 if (!m_reflection || reflectionLayer() != child) | 5816 if (!m_reflection || reflectionLayer() != child) |
| 5567 child->collectLayers(includeHiddenLayers, behavior, posZOrderList, n egZOrderList); | 5817 child->collectLayers(includeHiddenLayers, behavior, posZOrderList, n egZOrderList, layerToForceAsStackingContext); |
| 5568 | 5818 |
| 5569 // Sort the two lists. | 5819 // Sort the two lists. |
| 5570 if (posZOrderList) | 5820 if (posZOrderList) |
| 5571 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); | 5821 std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZI ndex); |
| 5572 | 5822 |
| 5573 if (negZOrderList) | 5823 if (negZOrderList) |
| 5574 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); | 5824 std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZI ndex); |
| 5575 | 5825 |
| 5576 #if ENABLE(DIALOG_ELEMENT) | 5826 #if ENABLE(DIALOG_ELEMENT) |
| 5577 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. | 5827 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 5602 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { | 5852 if (child->isNormalFlowOnly() && (!m_reflection || reflectionLayer() != child)) { |
| 5603 if (!m_normalFlowList) | 5853 if (!m_normalFlowList) |
| 5604 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); | 5854 m_normalFlowList = adoptPtr(new Vector<RenderLayer*>); |
| 5605 m_normalFlowList->append(child); | 5855 m_normalFlowList->append(child); |
| 5606 } | 5856 } |
| 5607 } | 5857 } |
| 5608 | 5858 |
| 5609 m_normalFlowListDirty = false; | 5859 m_normalFlowListDirty = false; |
| 5610 } | 5860 } |
| 5611 | 5861 |
| 5612 void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior behavior, OwnPtr<Vector<RenderLayer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer) | 5862 void RenderLayer::collectLayers(bool includeHiddenLayers, CollectLayersBehavior behavior, OwnPtr<Vector<RenderLayer*> >& posBuffer, OwnPtr<Vector<RenderLayer*> >& negBuffer, const RenderLayer* layerToForceAsStackingContext) |
| 5613 { | 5863 { |
| 5614 #if ENABLE(DIALOG_ELEMENT) | 5864 #if ENABLE(DIALOG_ELEMENT) |
| 5615 if (isInTopLayer()) | 5865 if (isInTopLayer()) |
| 5616 return; | 5866 return; |
| 5617 #endif | 5867 #endif |
| 5618 | 5868 |
| 5619 updateDescendantDependentFlags(); | 5869 updateDescendantDependentFlags(); |
| 5620 | 5870 |
| 5621 bool isStacking = behavior == StopAtStackingContexts ? isStackingContext() : isStackingContainer(); | 5871 bool isStacking = (this == layerToForceAsStackingContext) || (behavior == St opAtStackingContexts ? isStackingContext() : isStackingContainer()); |
| 5622 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. | 5872 // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. |
| 5623 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); | 5873 bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_ hasVisibleDescendant && isStacking)); |
| 5624 if (includeHiddenLayer && !isNormalFlowOnly() && !isOutOfFlowRenderFlowThrea d()) { | 5874 if (includeHiddenLayer && !isNormalFlowOnly() && !isOutOfFlowRenderFlowThrea d()) { |
| 5625 // Determine which buffer the child should be in. | 5875 // Determine which buffer the child should be in. |
| 5626 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; | 5876 OwnPtr<Vector<RenderLayer*> >& buffer = (zIndex() >= 0) ? posBuffer : ne gBuffer; |
| 5627 | 5877 |
| 5628 // Create the buffer if it doesn't exist yet. | 5878 // Create the buffer if it doesn't exist yet. |
| 5629 if (!buffer) | 5879 if (!buffer) |
| 5630 buffer = adoptPtr(new Vector<RenderLayer*>); | 5880 buffer = adoptPtr(new Vector<RenderLayer*>); |
| 5631 | 5881 |
| 5632 // Append ourselves at the end of the appropriate buffer. | 5882 // Append ourselves at the end of the appropriate buffer. |
| 5633 buffer->append(this); | 5883 buffer->append(this); |
| 5634 } | 5884 } |
| 5635 | 5885 |
| 5636 // Recur into our children to collect more layers, but only if we don't esta blish | 5886 // Recur into our children to collect more layers, but only if we don't esta blish |
| 5637 // a stacking context/container. | 5887 // a stacking context/container. |
| 5638 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { | 5888 if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStacking) { |
| 5639 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { | 5889 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { |
| 5640 // Ignore reflections. | 5890 // Ignore reflections. |
| 5641 if (!m_reflection || reflectionLayer() != child) | 5891 if (!m_reflection || reflectionLayer() != child) |
| 5642 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer); | 5892 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer, layerToForceAsStackingContext); |
| 5643 } | 5893 } |
| 5644 } | 5894 } |
| 5645 } | 5895 } |
| 5646 | 5896 |
| 5647 void RenderLayer::updateLayerListsIfNeeded() | 5897 void RenderLayer::updateLayerListsIfNeeded() |
| 5648 { | 5898 { |
| 5649 bool shouldUpdateDescendantsAreContiguousInStackingOrder = isStackingContext () && (m_zOrderListsDirty || m_normalFlowListDirty); | 5899 bool shouldUpdateDescendantsAreContiguousInStackingOrder = isStackingContext () && (m_zOrderListsDirty || m_normalFlowListDirty); |
| 5650 updateZOrderLists(); | 5900 updateZOrderLists(); |
| 5651 updateNormalFlowList(); | 5901 updateNormalFlowList(); |
| 5652 | 5902 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5836 | 6086 |
| 5837 void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldS tyle) | 6087 void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldS tyle) |
| 5838 { | 6088 { |
| 5839 if (!oldStyle) | 6089 if (!oldStyle) |
| 5840 return; | 6090 return; |
| 5841 | 6091 |
| 5842 bool wasStackingContext = isStackingContext(oldStyle); | 6092 bool wasStackingContext = isStackingContext(oldStyle); |
| 5843 bool isStackingContext = this->isStackingContext(); | 6093 bool isStackingContext = this->isStackingContext(); |
| 5844 if (isStackingContext != wasStackingContext) { | 6094 if (isStackingContext != wasStackingContext) { |
| 5845 dirtyStackingContainerZOrderLists(); | 6095 dirtyStackingContainerZOrderLists(); |
| 5846 if (isStackingContext) | 6096 if (isStackingContainer()) |
|
shawnsingh
2013/04/09 20:16:07
Same here - it seems to me this is unrelated to th
| |
| 5847 dirtyZOrderLists(); | 6097 dirtyZOrderLists(); |
| 5848 else | 6098 else |
| 5849 clearZOrderLists(); | 6099 clearZOrderLists(); |
| 5850 return; | 6100 return; |
| 5851 } | 6101 } |
| 5852 | 6102 |
| 5853 // FIXME: RenderLayer already handles visibility changes through our visibli ty dirty bits. This logic could | 6103 // FIXME: RenderLayer already handles visibility changes through our visibli ty dirty bits. This logic could |
| 5854 // likely be folded along with the rest. | 6104 // likely be folded along with the rest. |
| 5855 if (oldStyle->zIndex() != renderer()->style()->zIndex() || oldStyle->visibil ity() != renderer()->style()->visibility()) { | 6105 if (oldStyle->zIndex() != renderer()->style()->zIndex() || oldStyle->visibil ity() != renderer()->style()->visibility()) { |
| 5856 dirtyStackingContainerZOrderLists(); | 6106 dirtyStackingContainerZOrderLists(); |
| 5857 if (isStackingContext) | 6107 if (isStackingContainer()) |
| 5858 dirtyZOrderLists(); | 6108 dirtyZOrderLists(); |
| 5859 } | 6109 } |
| 5860 } | 6110 } |
| 5861 | 6111 |
| 5862 static bool overflowRequiresScrollbar(EOverflow overflow) | 6112 static bool overflowRequiresScrollbar(EOverflow overflow) |
| 5863 { | 6113 { |
| 5864 return overflow == OSCROLL; | 6114 return overflow == OSCROLL; |
| 5865 } | 6115 } |
| 5866 | 6116 |
| 5867 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) | 6117 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6010 // FilterEffectRenderer is intended to render software filters and shouldn't be needed for accelerated filters. | 6260 // FilterEffectRenderer is intended to render software filters and shouldn't be needed for accelerated filters. |
| 6011 // We should extract the SVG graph building functionality out of FilterEffec tRenderer, and it should happen in RenderLayer::computeFilterOperations. | 6261 // We should extract the SVG graph building functionality out of FilterEffec tRenderer, and it should happen in RenderLayer::computeFilterOperations. |
| 6012 // https://bugs.webkit.org/show_bug.cgi?id=114051 | 6262 // https://bugs.webkit.org/show_bug.cgi?id=114051 |
| 6013 if (shouldUpdateFilters && newStyle->filter().hasReferenceFilter()) | 6263 if (shouldUpdateFilters && newStyle->filter().hasReferenceFilter()) |
| 6014 backing()->updateFilters(renderer()->style()); | 6264 backing()->updateFilters(renderer()->style()); |
| 6015 } | 6265 } |
| 6016 #endif | 6266 #endif |
| 6017 | 6267 |
| 6018 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) | 6268 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) |
| 6019 { | 6269 { |
| 6020 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 6270 updateIsNormalFlowOnly(); |
| 6021 if (isNormalFlowOnly != m_isNormalFlowOnly) { | |
| 6022 m_isNormalFlowOnly = isNormalFlowOnly; | |
| 6023 RenderLayer* p = parent(); | |
| 6024 if (p) | |
| 6025 p->dirtyNormalFlowList(); | |
| 6026 dirtyStackingContainerZOrderLists(); | |
| 6027 } | |
| 6028 | 6271 |
| 6029 if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->mar queeBehavior() != MNONE && renderer()->isBox()) { | 6272 if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->mar queeBehavior() != MNONE && renderer()->isBox()) { |
| 6030 if (!m_marquee) | 6273 if (!m_marquee) |
| 6031 m_marquee = adoptPtr(new RenderMarquee(this)); | 6274 m_marquee = adoptPtr(new RenderMarquee(this)); |
| 6032 FeatureObserver::observe(renderer()->document(), renderer()->isHTMLMarqu ee() ? FeatureObserver::HTMLMarqueeElement : FeatureObserver::CSSOverflowMarquee ); | 6275 FeatureObserver::observe(renderer()->document(), renderer()->isHTMLMarqu ee() ? FeatureObserver::HTMLMarqueeElement : FeatureObserver::CSSOverflowMarquee ); |
| 6033 m_marquee->updateMarqueeStyle(); | 6276 m_marquee->updateMarqueeStyle(); |
| 6034 } | 6277 } |
| 6035 else if (m_marquee) { | 6278 else if (m_marquee) { |
| 6036 m_marquee.clear(); | 6279 m_marquee.clear(); |
| 6037 } | 6280 } |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6356 } | 6599 } |
| 6357 } | 6600 } |
| 6358 | 6601 |
| 6359 void showLayerTree(const WebCore::RenderObject* renderer) | 6602 void showLayerTree(const WebCore::RenderObject* renderer) |
| 6360 { | 6603 { |
| 6361 if (!renderer) | 6604 if (!renderer) |
| 6362 return; | 6605 return; |
| 6363 showLayerTree(renderer->enclosingLayer()); | 6606 showLayerTree(renderer->enclosingLayer()); |
| 6364 } | 6607 } |
| 6365 #endif | 6608 #endif |
| OLD | NEW |