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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayer.cpp

Issue 1199673003: Have enclosingPositionedAncestor() detect whether it walked past a certain ancestor. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 } 766 }
767 curr = curr->parent(); 767 curr = curr->parent();
768 } 768 }
769 if (curr->isBox() && curr->isTableRow()) { 769 if (curr->isBox() && curr->isTableRow()) {
770 // Put ourselves into the row coordinate space. 770 // Put ourselves into the row coordinate space.
771 localPoint.moveBy(-toLayoutBox(curr)->topLeftLocation()); 771 localPoint.moveBy(-toLayoutBox(curr)->topLeftLocation());
772 } 772 }
773 } 773 }
774 774
775 // Subtract our parent's scroll offset. 775 // Subtract our parent's scroll offset.
776 if (layoutObject()->isOutOfFlowPositioned() && enclosingPositionedAncestor() ) { 776 if (DeprecatedPaintLayer* positionedParent = layoutObject()->isOutOfFlowPosi tioned() ? enclosingPositionedAncestor() : nullptr) {
777 DeprecatedPaintLayer* positionedParent = enclosingPositionedAncestor();
778
779 // For positioned layers, we subtract out the enclosing positioned layer 's scroll offset. 777 // For positioned layers, we subtract out the enclosing positioned layer 's scroll offset.
780 if (positionedParent->layoutObject()->hasOverflowClip()) { 778 if (positionedParent->layoutObject()->hasOverflowClip()) {
781 IntSize offset = positionedParent->layoutBox()->scrolledContentOffse t(); 779 IntSize offset = positionedParent->layoutBox()->scrolledContentOffse t();
782 localPoint -= offset; 780 localPoint -= offset;
783 } 781 }
784 782
785 if (positionedParent->layoutObject()->isRelPositioned() && positionedPar ent->layoutObject()->isLayoutInline()) { 783 if (positionedParent->layoutObject()->isRelPositioned() && positionedPar ent->layoutObject()->isLayoutInline()) {
786 LayoutSize offset = toLayoutInline(positionedParent->layoutObject()) ->offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); 784 LayoutSize offset = toLayoutInline(positionedParent->layoutObject()) ->offsetForInFlowPositionedInline(*toLayoutBox(layoutObject()));
787 localPoint += offset; 785 localPoint += offset;
788 } 786 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 const ComputedStyle& style = layoutObject()->styleRef(); 835 const ComputedStyle& style = layoutObject()->styleRef();
838 836
839 return FloatPoint(floatValueForLength(style.perspectiveOriginX(), borderBox. width().toFloat()), floatValueForLength(style.perspectiveOriginY(), borderBox.he ight().toFloat())); 837 return FloatPoint(floatValueForLength(style.perspectiveOriginX(), borderBox. width().toFloat()), floatValueForLength(style.perspectiveOriginY(), borderBox.he ight().toFloat()));
840 } 838 }
841 839
842 static inline bool isFixedPositionedContainer(DeprecatedPaintLayer* layer) 840 static inline bool isFixedPositionedContainer(DeprecatedPaintLayer* layer)
843 { 841 {
844 return layer->isRootLayer() || layer->hasTransformRelatedProperty(); 842 return layer->isRootLayer() || layer->hasTransformRelatedProperty();
845 } 843 }
846 844
847 DeprecatedPaintLayer* DeprecatedPaintLayer::enclosingPositionedAncestor() const 845 DeprecatedPaintLayer* DeprecatedPaintLayer::enclosingPositionedAncestor(const De precatedPaintLayer* ancestor, bool* skippedAncestor) const
848 { 846 {
847 ASSERT(!ancestor || skippedAncestor); // If we have specified an ancestor, s urely the caller needs to know whether we skipped it.
848 if (skippedAncestor)
849 *skippedAncestor = false;
849 if (layoutObject()->style()->position() == FixedPosition) { 850 if (layoutObject()->style()->position() == FixedPosition) {
850 DeprecatedPaintLayer* curr = parent(); 851 DeprecatedPaintLayer* curr = parent();
851 while (curr && !isFixedPositionedContainer(curr)) 852 while (curr && !isFixedPositionedContainer(curr)) {
853 if (skippedAncestor && curr == ancestor)
854 *skippedAncestor = true;
852 curr = curr->parent(); 855 curr = curr->parent();
856 }
853 857
854 return curr; 858 return curr;
855 } 859 }
856 860
857 DeprecatedPaintLayer* curr = parent(); 861 DeprecatedPaintLayer* curr = parent();
858 while (curr && !curr->isPositionedContainer()) 862 while (curr && !curr->isPositionedContainer()) {
863 if (skippedAncestor && curr == ancestor)
864 *skippedAncestor = true;
859 curr = curr->parent(); 865 curr = curr->parent();
866 }
860 867
861 return curr; 868 return curr;
862 } 869 }
863 870
864 DeprecatedPaintLayer* DeprecatedPaintLayer::enclosingTransformedAncestor() const 871 DeprecatedPaintLayer* DeprecatedPaintLayer::enclosingTransformedAncestor() const
865 { 872 {
866 DeprecatedPaintLayer* curr = parent(); 873 DeprecatedPaintLayer* curr = parent();
867 while (curr && !curr->isRootLayer() && !curr->layoutObject()->hasTransformRe latedProperty()) 874 while (curr && !curr->isRootLayer() && !curr->layoutObject()->hasTransformRe latedProperty())
868 curr = curr->parent(); 875 curr = curr->parent();
869 876
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 ASSERT(ancestorLayer != layoutObject->view()->layer()); 1320 ASSERT(ancestorLayer != layoutObject->view()->layer());
1314 ASSERT(ancestorLayer->hasTransformRelatedProperty()); 1321 ASSERT(ancestorLayer->hasTransformRelatedProperty());
1315 1322
1316 location += layer->location(); 1323 location += layer->location();
1317 } 1324 }
1318 return foundAncestor ? ancestorLayer : fixedPositionContainerLayer; 1325 return foundAncestor ? ancestorLayer : fixedPositionContainerLayer;
1319 } 1326 }
1320 1327
1321 DeprecatedPaintLayer* parentLayer; 1328 DeprecatedPaintLayer* parentLayer;
1322 if (position == AbsolutePosition) { 1329 if (position == AbsolutePosition) {
1323 // Do what enclosingPositionedAncestor() does, but check for ancestorLay er along the way. 1330 bool foundAncestorFirst;
1324 parentLayer = layer->parent(); 1331 parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAn cestorFirst);
1325 bool foundAncestorFirst = false;
1326 while (parentLayer) {
1327 if (parentLayer->isPositionedContainer())
1328 break;
1329
1330 if (parentLayer == ancestorLayer) {
1331 foundAncestorFirst = true;
1332 break;
1333 }
1334
1335 parentLayer = parentLayer->parent();
1336 }
1337 1332
1338 if (foundAncestorFirst) { 1333 if (foundAncestorFirst) {
1339 // Found ancestorLayer before the abs. positioned container, so comp ute offset of both relative 1334 // Found ancestorLayer before the abs. positioned container, so comp ute offset of both relative
1340 // to enclosingPositionedAncestor and subtract. 1335 // to the positioned ancestor and subtract.
1341 DeprecatedPaintLayer* positionedAncestor = parentLayer->enclosingPos itionedAncestor();
1342 1336
1343 LayoutPoint thisCoords; 1337 LayoutPoint thisCoords;
1344 layer->convertToLayerCoords(positionedAncestor, thisCoords); 1338 layer->convertToLayerCoords(parentLayer, thisCoords);
1345 1339
1346 LayoutPoint ancestorCoords; 1340 LayoutPoint ancestorCoords;
1347 ancestorLayer->convertToLayerCoords(positionedAncestor, ancestorCoor ds); 1341 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords);
1348 1342
1349 location += (thisCoords - ancestorCoords); 1343 location += (thisCoords - ancestorCoords);
1350 return ancestorLayer; 1344 return ancestorLayer;
1351 } 1345 }
1352 } else if (layoutObject->isColumnSpanAll()) { 1346 } else if (layoutObject->isColumnSpanAll()) {
1353 LayoutBlock* multicolContainer = layoutObject->containingBlock(); 1347 LayoutBlock* multicolContainer = layoutObject->containingBlock();
1354 ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread()); 1348 ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread());
1355 parentLayer = multicolContainer->layer(); 1349 parentLayer = multicolContainer->layer();
1356 ASSERT(parentLayer); 1350 ASSERT(parentLayer);
1357 } else { 1351 } else {
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 2734
2741 void showLayerTree(const blink::LayoutObject* layoutObject) 2735 void showLayerTree(const blink::LayoutObject* layoutObject)
2742 { 2736 {
2743 if (!layoutObject) { 2737 if (!layoutObject) {
2744 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2738 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2745 return; 2739 return;
2746 } 2740 }
2747 showLayerTree(layoutObject->enclosingLayer()); 2741 showLayerTree(layoutObject->enclosingLayer());
2748 } 2742 }
2749 #endif 2743 #endif
OLDNEW
« Source/core/paint/DeprecatedPaintLayer.h ('K') | « Source/core/paint/DeprecatedPaintLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698