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

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

Issue 1850703002: Revert "Adapt and reland old position sticky implementation from https://codereview.chromium.org/34… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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[10]; 102 void* pointers[9];
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 , m_hasNonIsolatedDescendantWithBlendMode(false) 165 , m_hasNonIsolatedDescendantWithBlendMode(false)
166 , m_hasAncestorWithClipPath(false) 166 , m_hasAncestorWithClipPath(false)
167 , m_layoutObject(layoutObject) 167 , m_layoutObject(layoutObject)
168 , m_parent(0) 168 , m_parent(0)
169 , m_previous(0) 169 , m_previous(0)
170 , m_next(0) 170 , m_next(0)
171 , m_first(0) 171 , m_first(0)
172 , m_last(0) 172 , m_last(0)
173 , m_staticInlinePosition(0) 173 , m_staticInlinePosition(0)
174 , m_staticBlockPosition(0) 174 , m_staticBlockPosition(0)
175 , m_ancestorOverflowLayer(nullptr)
176 { 175 {
177 updateStackingNode(); 176 updateStackingNode();
178 177
179 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 178 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
180 179
181 if (!layoutObject->slowFirstChild() && layoutObject->style()) { 180 if (!layoutObject->slowFirstChild() && layoutObject->style()) {
182 m_visibleContentStatusDirty = false; 181 m_visibleContentStatusDirty = false;
183 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE; 182 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE;
184 } 183 }
185 184
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // in this case, there is no need to dirty our ancestors further. 342 // in this case, there is no need to dirty our ancestors further.
344 if (layer->isSelfPaintingLayer()) { 343 if (layer->isSelfPaintingLayer()) {
345 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant); 344 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant);
346 break; 345 break;
347 } 346 }
348 } 347 }
349 } 348 }
350 349
351 bool PaintLayer::scrollsWithViewport() const 350 bool PaintLayer::scrollsWithViewport() const
352 { 351 {
353 return (layoutObject()->style()->position() == FixedPosition && layoutObject ()->containerForFixedPosition() == layoutObject()->view()) 352 return layoutObject()->style()->position() == FixedPosition && layoutObject( )->containerForFixedPosition() == layoutObject()->view();
354 || (layoutObject()->style()->position() == StickyPosition && !ancestorSc rollingLayer());
355 } 353 }
356 354
357 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const 355 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const
358 { 356 {
359 if (scrollsWithViewport() != other->scrollsWithViewport()) 357 if (scrollsWithViewport() != other->scrollsWithViewport())
360 return true; 358 return true;
361 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); 359 return ancestorScrollingLayer() != other->ancestorScrollingLayer();
362 } 360 }
363 361
364 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta) 362 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta)
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } 740 }
743 741
744 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs 742 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs
745 // the m_has3DTransformedDescendant set. 743 // the m_has3DTransformedDescendant set.
746 if (preserves3D()) 744 if (preserves3D())
747 return has3DTransform() || m_has3DTransformedDescendant; 745 return has3DTransform() || m_has3DTransformedDescendant;
748 746
749 return has3DTransform(); 747 return has3DTransform();
750 } 748 }
751 749
752 void PaintLayer::updateLayerPosition() 750 bool PaintLayer::updateLayerPosition()
753 { 751 {
754 LayoutPoint localPoint; 752 LayoutPoint localPoint;
755 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. 753 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done.
756 754
757 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { 755 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) {
758 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); 756 LayoutInline* inlineFlow = toLayoutInline(layoutObject());
759 IntRect lineBox = inlineFlow->linesBoundingBox(); 757 IntRect lineBox = inlineFlow->linesBoundingBox();
760 m_size = lineBox.size(); 758 m_size = lineBox.size();
761 inlineBoundingBoxOffset = lineBox.location(); 759 inlineBoundingBoxOffset = lineBox.location();
762 localPoint.moveBy(inlineBoundingBoxOffset); 760 localPoint.moveBy(inlineBoundingBoxOffset);
(...skipping 30 matching lines...) Expand all
793 791
794 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) { 792 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) {
795 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); 793 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject()));
796 localPoint += offset; 794 localPoint += offset;
797 } 795 }
798 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { 796 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) {
799 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); 797 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset();
800 localPoint -= scrollOffset; 798 localPoint -= scrollOffset;
801 } 799 }
802 800
801 bool positionOrOffsetChanged = false;
803 if (layoutObject()->isInFlowPositioned()) { 802 if (layoutObject()->isInFlowPositioned()) {
804 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); 803 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition();
804 positionOrOffsetChanged = newOffset != offsetForInFlowPosition();
805 if (m_rareData || !newOffset.isZero()) 805 if (m_rareData || !newOffset.isZero())
806 ensureRareData().offsetForInFlowPosition = newOffset; 806 ensureRareData().offsetForInFlowPosition = newOffset;
807 localPoint.move(newOffset); 807 localPoint.move(newOffset);
808 } else if (m_rareData) { 808 } else if (m_rareData) {
809 m_rareData->offsetForInFlowPosition = LayoutSize(); 809 m_rareData->offsetForInFlowPosition = LayoutSize();
810 } 810 }
811 811
812 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects. 812 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects.
813 localPoint.moveBy(-inlineBoundingBoxOffset); 813 localPoint.moveBy(-inlineBoundingBoxOffset);
814 814
815 if (m_location != localPoint) { 815 if (m_location != localPoint) {
816 positionOrOffsetChanged = true;
816 setNeedsRepaint(); 817 setNeedsRepaint();
817 } 818 }
818 m_location = localPoint; 819 m_location = localPoint;
819 820
820 #if ENABLE(ASSERT) 821 #if ENABLE(ASSERT)
821 m_needsPositionUpdate = false; 822 m_needsPositionUpdate = false;
822 #endif 823 #endif
824 return positionOrOffsetChanged;
823 } 825 }
824 826
825 TransformationMatrix PaintLayer::perspectiveTransform() const 827 TransformationMatrix PaintLayer::perspectiveTransform() const
826 { 828 {
827 if (!layoutObject()->hasTransformRelatedProperty()) 829 if (!layoutObject()->hasTransformRelatedProperty())
828 return TransformationMatrix(); 830 return TransformationMatrix();
829 831
830 const ComputedStyle& style = layoutObject()->styleRef(); 832 const ComputedStyle& style = layoutObject()->styleRef();
831 if (!style.hasPerspective()) 833 if (!style.hasPerspective())
832 return TransformationMatrix(); 834 return TransformationMatrix();
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 if (beforeChild) { 1177 if (beforeChild) {
1176 beforeChild->setPreviousSibling(child); 1178 beforeChild->setPreviousSibling(child);
1177 child->setNextSibling(beforeChild); 1179 child->setNextSibling(beforeChild);
1178 ASSERT(beforeChild != child); 1180 ASSERT(beforeChild != child);
1179 } else { 1181 } else {
1180 setLastChild(child); 1182 setLastChild(child);
1181 } 1183 }
1182 1184
1183 child->m_parent = this; 1185 child->m_parent = this;
1184 1186
1185 // The ancestor overflow layer is calculated during compositing inputs updat e and should not be set yet.
1186 ASSERT(!child->ancestorOverflowLayer());
1187
1188 setNeedsCompositingInputsUpdate(); 1187 setNeedsCompositingInputsUpdate();
1189 1188
1190 if (!child->stackingNode()->isStacked() && !layoutObject()->documentBeingDes troyed()) 1189 if (!child->stackingNode()->isStacked() && !layoutObject()->documentBeingDes troyed())
1191 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 1190 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
1192 1191
1193 if (child->stackingNode()->isStacked() || child->firstChild()) { 1192 if (child->stackingNode()->isStacked() || child->firstChild()) {
1194 // Dirty the z-order list in which we are contained. The ancestorStackin gContextNode() can be null in the 1193 // Dirty the z-order list in which we are contained. The ancestorStackin gContextNode() can be null in the
1195 // case where we're building up generated content layers. This is ok, si nce the lists will start 1194 // case where we're building up generated content layers. This is ok, si nce the lists will start
1196 // off dirty in that case anyway. 1195 // off dirty in that case anyway.
1197 child->stackingNode()->dirtyStackingContextZOrderLists(); 1196 child->stackingNode()->dirtyStackingContextZOrderLists();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 // |stackingContext| value. 1230 // |stackingContext| value.
1232 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); 1231 oldChild->stackingNode()->dirtyStackingContextZOrderLists();
1233 } 1232 }
1234 1233
1235 if (layoutObject()->style()->visibility() != VISIBLE) 1234 if (layoutObject()->style()->visibility() != VISIBLE)
1236 dirtyVisibleContentStatus(); 1235 dirtyVisibleContentStatus();
1237 1236
1238 oldChild->setPreviousSibling(0); 1237 oldChild->setPreviousSibling(0);
1239 oldChild->setNextSibling(0); 1238 oldChild->setNextSibling(0);
1240 oldChild->m_parent = 0; 1239 oldChild->m_parent = 0;
1241 if (oldChild->ancestorOverflowLayer())
1242 oldChild->ancestorOverflowLayer()->getScrollableArea()->invalidateSticky ConstraintsFor(oldChild);
1243 oldChild->updateAncestorOverflowLayer(nullptr);
1244 1240
1245 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); 1241 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
1246 1242
1247 oldChild->updateDescendantDependentFlags(); 1243 oldChild->updateDescendantDependentFlags();
1248 1244
1249 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) 1245 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant)
1250 dirtyAncestorChainVisibleDescendantStatus(); 1246 dirtyAncestorChainVisibleDescendantStatus();
1251 1247
1252 if (oldChild->enclosingPaginationLayer()) 1248 if (oldChild->enclosingPaginationLayer())
1253 oldChild->clearPaginationRecursive(); 1249 oldChild->clearPaginationRecursive();
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2821 2817
2822 void showLayerTree(const blink::LayoutObject* layoutObject) 2818 void showLayerTree(const blink::LayoutObject* layoutObject)
2823 { 2819 {
2824 if (!layoutObject) { 2820 if (!layoutObject) {
2825 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2821 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2826 return; 2822 return;
2827 } 2823 }
2828 showLayerTree(layoutObject->enclosingLayer()); 2824 showLayerTree(layoutObject->enclosingLayer());
2829 } 2825 }
2830 #endif 2826 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698