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

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: WIP - fix on release, still hits CHECK in LayoutGeometryMap.cpp:156 Created 4 years, 10 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // in this case, there is no need to dirty our ancestors further. 347 // in this case, there is no need to dirty our ancestors further.
348 if (layer->isSelfPaintingLayer()) { 348 if (layer->isSelfPaintingLayer()) {
349 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant); 349 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || parent()->m_hasSelfPaintingLayerDescendant);
350 break; 350 break;
351 } 351 }
352 } 352 }
353 } 353 }
354 354
355 bool PaintLayer::scrollsWithViewport() const 355 bool PaintLayer::scrollsWithViewport() const
356 { 356 {
357 return layoutObject()->style()->position() == FixedPosition && layoutObject( )->containerForFixedPosition() == layoutObject()->view(); 357 return (layoutObject()->style()->position() == FixedPosition && layoutObject ()->containerForFixedPosition() == layoutObject()->view())
358 || (layoutObject()->style()->position() == StickyPosition && !ancestorSc rollingLayer());
358 } 359 }
359 360
360 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const 361 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const
361 { 362 {
362 if (scrollsWithViewport() != other->scrollsWithViewport()) 363 if (scrollsWithViewport() != other->scrollsWithViewport())
363 return true; 364 return true;
364 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); 365 return ancestorScrollingLayer() != other->ancestorScrollingLayer();
365 } 366 }
366 367
367 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta) 368 void PaintLayer::updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrol lDelta)
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 } 747 }
747 748
748 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs 749 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs
749 // the m_has3DTransformedDescendant set. 750 // the m_has3DTransformedDescendant set.
750 if (preserves3D()) 751 if (preserves3D())
751 return has3DTransform() || m_has3DTransformedDescendant; 752 return has3DTransform() || m_has3DTransformedDescendant;
752 753
753 return has3DTransform(); 754 return has3DTransform();
754 } 755 }
755 756
756 bool PaintLayer::updateLayerPosition() 757 void PaintLayer::updateLayerPosition()
757 { 758 {
758 LayoutPoint localPoint; 759 LayoutPoint localPoint;
759 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. 760 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done.
760 761
761 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { 762 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) {
762 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); 763 LayoutInline* inlineFlow = toLayoutInline(layoutObject());
763 IntRect lineBox = inlineFlow->linesBoundingBox(); 764 IntRect lineBox = inlineFlow->linesBoundingBox();
764 m_size = lineBox.size(); 765 m_size = lineBox.size();
765 inlineBoundingBoxOffset = lineBox.location(); 766 inlineBoundingBoxOffset = lineBox.location();
766 localPoint.moveBy(inlineBoundingBoxOffset); 767 localPoint.moveBy(inlineBoundingBoxOffset);
(...skipping 30 matching lines...) Expand all
797 798
798 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) { 799 if (containingLayer->layoutObject()->isInFlowPositioned() && containingL ayer->layoutObject()->isLayoutInline()) {
799 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); 800 LayoutSize offset = toLayoutInline(containingLayer->layoutObject())- >offsetForInFlowPositionedInline(*toLayoutBox(layoutObject()));
800 localPoint += offset; 801 localPoint += offset;
801 } 802 }
802 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { 803 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) {
803 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); 804 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset();
804 localPoint -= scrollOffset; 805 localPoint -= scrollOffset;
805 } 806 }
806 807
807 bool positionOrOffsetChanged = false;
808 if (layoutObject()->isInFlowPositioned()) { 808 if (layoutObject()->isInFlowPositioned()) {
809 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); 809 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition();
810 positionOrOffsetChanged = newOffset != offsetForInFlowPosition();
811 if (m_rareData || !newOffset.isZero()) 810 if (m_rareData || !newOffset.isZero())
812 ensureRareData().offsetForInFlowPosition = newOffset; 811 ensureRareData().offsetForInFlowPosition = newOffset;
813 localPoint.move(newOffset); 812 localPoint.move(newOffset);
814 } else if (m_rareData) { 813 } else if (m_rareData) {
815 m_rareData->offsetForInFlowPosition = LayoutSize(); 814 m_rareData->offsetForInFlowPosition = LayoutSize();
816 } 815 }
817 816
818 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects. 817 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects.
819 localPoint.moveBy(-inlineBoundingBoxOffset); 818 localPoint.moveBy(-inlineBoundingBoxOffset);
820 819
821 if (m_location != localPoint) { 820 if (m_location != localPoint) {
822 positionOrOffsetChanged = true;
823 setNeedsRepaint(); 821 setNeedsRepaint();
824 } 822 }
825 m_location = localPoint; 823 m_location = localPoint;
826 824
827 #if ENABLE(ASSERT) 825 #if ENABLE(ASSERT)
828 m_needsPositionUpdate = false; 826 m_needsPositionUpdate = false;
829 #endif 827 #endif
830 return positionOrOffsetChanged;
831 } 828 }
832 829
833 TransformationMatrix PaintLayer::perspectiveTransform() const 830 TransformationMatrix PaintLayer::perspectiveTransform() const
834 { 831 {
835 if (!layoutObject()->hasTransformRelatedProperty()) 832 if (!layoutObject()->hasTransformRelatedProperty())
836 return TransformationMatrix(); 833 return TransformationMatrix();
837 834
838 const ComputedStyle& style = layoutObject()->styleRef(); 835 const ComputedStyle& style = layoutObject()->styleRef();
839 if (!style.hasPerspective()) 836 if (!style.hasPerspective())
840 return TransformationMatrix(); 837 return TransformationMatrix();
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 2799
2803 void showLayerTree(const blink::LayoutObject* layoutObject) 2800 void showLayerTree(const blink::LayoutObject* layoutObject)
2804 { 2801 {
2805 if (!layoutObject) { 2802 if (!layoutObject) {
2806 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2803 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2807 return; 2804 return;
2808 } 2805 }
2809 showLayerTree(layoutObject->enclosingLayer()); 2806 showLayerTree(layoutObject->enclosingLayer());
2810 } 2807 }
2811 #endif 2808 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698