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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 1308273010: Adapt and reland old position sticky implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove redundant invalidation in LayoutBlock::tryLayoutDoingPositionedMovementOnly Created 4 years, 9 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
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 namespace blink { 93 namespace blink {
94 94
95 namespace { 95 namespace {
96 96
97 static CompositingQueryMode gCompositingQueryMode = 97 static CompositingQueryMode gCompositingQueryMode =
98 CompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases; 98 CompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases;
99 99
100 struct SameSizeAsPaintLayer : DisplayItemClient { 100 struct SameSizeAsPaintLayer : DisplayItemClient {
101 int bitFields; 101 int bitFields;
102 void* pointers[9]; 102 void* pointers[10];
103 LayoutUnit layoutUnits[4]; 103 LayoutUnit layoutUnits[4];
104 IntSize size; 104 IntSize size;
105 OwnPtrWillBePersistent<PaintLayerScrollableArea> scrollableArea; 105 OwnPtrWillBePersistent<PaintLayerScrollableArea> scrollableArea;
106 struct { 106 struct {
107 IntRect rect; 107 IntRect rect;
108 void* pointers[2]; 108 void* pointers[2];
109 } ancestorCompositingInputs; 109 } ancestorCompositingInputs;
110 struct { 110 struct {
111 IntSize size; 111 IntSize size;
112 void* pointer; 112 void* pointer;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 , m_hasNonIsolatedDescendantWithBlendMode(false) 166 , m_hasNonIsolatedDescendantWithBlendMode(false)
167 , m_hasAncestorWithClipPath(false) 167 , m_hasAncestorWithClipPath(false)
168 , m_layoutObject(layoutObject) 168 , m_layoutObject(layoutObject)
169 , m_parent(0) 169 , m_parent(0)
170 , m_previous(0) 170 , m_previous(0)
171 , m_next(0) 171 , m_next(0)
172 , m_first(0) 172 , m_first(0)
173 , m_last(0) 173 , m_last(0)
174 , m_staticInlinePosition(0) 174 , m_staticInlinePosition(0)
175 , m_staticBlockPosition(0) 175 , m_staticBlockPosition(0)
176 , m_ancestorOverflowLayer(nullptr)
176 { 177 {
177 updateStackingNode(); 178 updateStackingNode();
178 179
179 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 180 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
180 181
181 if (!layoutObject->slowFirstChild() && layoutObject->style()) { 182 if (!layoutObject->slowFirstChild() && layoutObject->style()) {
182 m_visibleContentStatusDirty = false; 183 m_visibleContentStatusDirty = false;
183 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE; 184 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE;
184 } 185 }
185 186
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // in this case, there is no need to dirty our ancestors further. 346 // in this case, there is no need to dirty our ancestors further.
346 if (layer->isSelfPaintingLayer()) { 347 if (layer->isSelfPaintingLayer()) {
347 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant); 348 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant);
348 break; 349 break;
349 } 350 }
350 } 351 }
351 } 352 }
352 353
353 bool PaintLayer::scrollsWithViewport() const 354 bool PaintLayer::scrollsWithViewport() const
354 { 355 {
355 return layoutObject()->style()->position() == FixedPosition && layoutObject( )->containerForFixedPosition() == layoutObject()->view(); 356 return (layoutObject()->style()->position() == FixedPosition && layoutObject ()->containerForFixedPosition() == layoutObject()->view())
357 || (layoutObject()->style()->position() == StickyPosition && !ancestorSc rollingLayer());
356 } 358 }
357 359
358 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const 360 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const
359 { 361 {
360 if (scrollsWithViewport() != other->scrollsWithViewport()) 362 if (scrollsWithViewport() != other->scrollsWithViewport())
361 return true; 363 return true;
362 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); 364 return ancestorScrollingLayer() != other->ancestorScrollingLayer();
363 } 365 }
364 366
365 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta) 367 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta)
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 766 }
765 767
766 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs 768 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs
767 // the m_has3DTransformedDescendant set. 769 // the m_has3DTransformedDescendant set.
768 if (preserves3D()) 770 if (preserves3D())
769 return has3DTransform() || m_has3DTransformedDescendant; 771 return has3DTransform() || m_has3DTransformedDescendant;
770 772
771 return has3DTransform(); 773 return has3DTransform();
772 } 774 }
773 775
774 bool PaintLayer::updateLayerPosition() 776 void PaintLayer::updateLayerPosition()
775 { 777 {
776 LayoutPoint localPoint; 778 LayoutPoint localPoint;
777 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. 779 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done.
778 780
779 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { 781 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) {
780 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); 782 LayoutInline* inlineFlow = toLayoutInline(layoutObject());
781 IntRect lineBox = inlineFlow->linesBoundingBox(); 783 IntRect lineBox = inlineFlow->linesBoundingBox();
782 m_size = lineBox.size(); 784 m_size = lineBox.size();
783 inlineBoundingBoxOffset = lineBox.location(); 785 inlineBoundingBoxOffset = lineBox.location();
784 localPoint.moveBy(inlineBoundingBoxOffset); 786 localPoint.moveBy(inlineBoundingBoxOffset);
(...skipping 30 matching lines...) Expand all
815 817
816 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) { 818 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) {
817 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); 819 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject()));
818 localPoint += offset; 820 localPoint += offset;
819 } 821 }
820 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { 822 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) {
821 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); 823 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset();
822 localPoint -= scrollOffset; 824 localPoint -= scrollOffset;
823 } 825 }
824 826
825 bool positionOrOffsetChanged = false;
826 if (layoutObject()->isInFlowPositioned()) { 827 if (layoutObject()->isInFlowPositioned()) {
827 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); 828 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition();
828 positionOrOffsetChanged = newOffset != offsetForInFlowPosition();
829 if (m_rareData || !newOffset.isZero()) 829 if (m_rareData || !newOffset.isZero())
830 ensureRareData().offsetForInFlowPosition = newOffset; 830 ensureRareData().offsetForInFlowPosition = newOffset;
831 localPoint.move(newOffset); 831 localPoint.move(newOffset);
832 } else if (m_rareData) { 832 } else if (m_rareData) {
833 m_rareData->offsetForInFlowPosition = LayoutSize(); 833 m_rareData->offsetForInFlowPosition = LayoutSize();
834 } 834 }
835 835
836 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects. 836 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects.
837 localPoint.moveBy(-inlineBoundingBoxOffset); 837 localPoint.moveBy(-inlineBoundingBoxOffset);
838 838
839 if (m_location != localPoint) { 839 if (m_location != localPoint) {
840 positionOrOffsetChanged = true;
841 setNeedsRepaint(); 840 setNeedsRepaint();
842 } 841 }
843 m_location = localPoint; 842 m_location = localPoint;
844 843
845 #if ENABLE(ASSERT) 844 #if ENABLE(ASSERT)
846 m_needsPositionUpdate = false; 845 m_needsPositionUpdate = false;
847 #endif 846 #endif
848 return positionOrOffsetChanged;
849 } 847 }
850 848
851 TransformationMatrix PaintLayer::perspectiveTransform() const 849 TransformationMatrix PaintLayer::perspectiveTransform() const
852 { 850 {
853 if (!layoutObject()->hasTransformRelatedProperty()) 851 if (!layoutObject()->hasTransformRelatedProperty())
854 return TransformationMatrix(); 852 return TransformationMatrix();
855 853
856 const ComputedStyle& style = layoutObject()->styleRef(); 854 const ComputedStyle& style = layoutObject()->styleRef();
857 if (!style.hasPerspective()) 855 if (!style.hasPerspective())
858 return TransformationMatrix(); 856 return TransformationMatrix();
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 if (beforeChild) { 1199 if (beforeChild) {
1202 beforeChild->setPreviousSibling(child); 1200 beforeChild->setPreviousSibling(child);
1203 child->setNextSibling(beforeChild); 1201 child->setNextSibling(beforeChild);
1204 ASSERT(beforeChild != child); 1202 ASSERT(beforeChild != child);
1205 } else { 1203 } else {
1206 setLastChild(child); 1204 setLastChild(child);
1207 } 1205 }
1208 1206
1209 child->m_parent = this; 1207 child->m_parent = this;
1210 1208
1209 // The ancestor overflow layer is calculated during compositing inputs updat e and should not be set yet.
1210 ASSERT(!child->ancestorOverflowLayer());
1211
1211 setNeedsCompositingInputsUpdate(); 1212 setNeedsCompositingInputsUpdate();
1212 1213
1213 if (!child->stackingNode()->isStacked() && !layoutObject()->documentBeingDes troyed()) 1214 if (!child->stackingNode()->isStacked() && !layoutObject()->documentBeingDes troyed())
1214 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 1215 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
1215 1216
1216 if (child->stackingNode()->isStacked() || child->firstChild()) { 1217 if (child->stackingNode()->isStacked() || child->firstChild()) {
1217 // Dirty the z-order list in which we are contained. The ancestorStackin gContextNode() can be null in the 1218 // Dirty the z-order list in which we are contained. The ancestorStackin gContextNode() can be null in the
1218 // case where we're building up generated content layers. This is ok, si nce the lists will start 1219 // case where we're building up generated content layers. This is ok, si nce the lists will start
1219 // off dirty in that case anyway. 1220 // off dirty in that case anyway.
1220 child->stackingNode()->dirtyStackingContextZOrderLists(); 1221 child->stackingNode()->dirtyStackingContextZOrderLists();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 // |stackingContext| value. 1255 // |stackingContext| value.
1255 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); 1256 oldChild->stackingNode()->dirtyStackingContextZOrderLists();
1256 } 1257 }
1257 1258
1258 if (layoutObject()->style()->visibility() != VISIBLE) 1259 if (layoutObject()->style()->visibility() != VISIBLE)
1259 dirtyVisibleContentStatus(); 1260 dirtyVisibleContentStatus();
1260 1261
1261 oldChild->setPreviousSibling(0); 1262 oldChild->setPreviousSibling(0);
1262 oldChild->setNextSibling(0); 1263 oldChild->setNextSibling(0);
1263 oldChild->m_parent = 0; 1264 oldChild->m_parent = 0;
1265 if (oldChild->ancestorOverflowLayer())
chrishtr 2016/03/24 17:36:03 Do you have a layout test involving removal of pai
flackr 2016/03/29 16:02:32 sticky-overflow-changed.html does test layer remov
1266 oldChild->ancestorOverflowLayer()->getScrollableArea()->invalidateSticky ConstraintsFor(oldChild);
1267 oldChild->updateAncestorOverflowLayer(nullptr);
1264 1268
1265 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); 1269 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
1266 1270
1267 oldChild->updateDescendantDependentFlags(); 1271 oldChild->updateDescendantDependentFlags();
1268 1272
1269 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) 1273 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant)
1270 dirtyAncestorChainVisibleDescendantStatus(); 1274 dirtyAncestorChainVisibleDescendantStatus();
1271 1275
1272 if (oldChild->enclosingPaginationLayer()) 1276 if (oldChild->enclosingPaginationLayer())
1273 oldChild->clearPaginationRecursive(); 1277 oldChild->clearPaginationRecursive();
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 2839
2836 void showLayerTree(const blink::LayoutObject* layoutObject) 2840 void showLayerTree(const blink::LayoutObject* layoutObject)
2837 { 2841 {
2838 if (!layoutObject) { 2842 if (!layoutObject) {
2839 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2843 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2840 return; 2844 return;
2841 } 2845 }
2842 showLayerTree(layoutObject->enclosingLayer()); 2846 showLayerTree(layoutObject->enclosingLayer());
2843 } 2847 }
2844 #endif 2848 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698