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

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

Issue 1284203004: Generate scroll/clip display item hierarchy for SPv2 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: stripped localPaintingInfo cleanup and fixed-pos workarounds Created 5 years, 3 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 704 }
705 705
706 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs 706 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs
707 // the m_has3DTransformedDescendant set. 707 // the m_has3DTransformedDescendant set.
708 if (preserves3D()) 708 if (preserves3D())
709 return has3DTransform() || m_has3DTransformedDescendant; 709 return has3DTransform() || m_has3DTransformedDescendant;
710 710
711 return has3DTransform(); 711 return has3DTransform();
712 } 712 }
713 713
714 LayoutPoint DeprecatedPaintLayer::locationExcludingOverflowScroll() const
715 {
716 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
717
718 // Our m_location already has scroll offset baked-in. We have to revert it h ere.
719 IntSize scrollOffset;
720 DeprecatedPaintLayer* scrollParent = layoutObject()->isOutOfFlowPositioned() ? enclosingPositionedAncestor() : parent();
721 if (scrollParent && scrollParent->layoutObject()->hasOverflowClip())
722 scrollOffset = scrollParent->layoutBox()->scrolledContentOffset();
723 return m_location + LayoutSize(scrollOffset);
724 }
725
714 bool DeprecatedPaintLayer::updateLayerPosition() 726 bool DeprecatedPaintLayer::updateLayerPosition()
715 { 727 {
716 LayoutPoint localPoint; 728 LayoutPoint localPoint;
717 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. 729 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done.
718 730
719 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { 731 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) {
720 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); 732 LayoutInline* inlineFlow = toLayoutInline(layoutObject());
721 IntRect lineBox = inlineFlow->linesBoundingBox(); 733 IntRect lineBox = inlineFlow->linesBoundingBox();
722 m_size = lineBox.size(); 734 m_size = lineBox.size();
723 inlineBoundingBoxOffset = lineBox.location(); 735 inlineBoundingBoxOffset = lineBox.location();
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 1249
1238 // Remove all descendant layers from the hierarchy and add them to the new p osition. 1250 // Remove all descendant layers from the hierarchy and add them to the new p osition.
1239 for (LayoutObject* curr = layoutObject()->slowFirstChild(); curr; curr = cur r->nextSibling()) 1251 for (LayoutObject* curr = layoutObject()->slowFirstChild(); curr; curr = cur r->nextSibling())
1240 curr->moveLayers(m_parent, this); 1252 curr->moveLayers(m_parent, this);
1241 1253
1242 // Clear out all the clip rects. 1254 // Clear out all the clip rects.
1243 m_clipper.clearClipRectsIncludingDescendants(); 1255 m_clipper.clearClipRectsIncludingDescendants();
1244 } 1256 }
1245 1257
1246 // Returns the layer reached on the walk up towards the ancestor. 1258 // Returns the layer reached on the walk up towards the ancestor.
1247 static inline const DeprecatedPaintLayer* accumulateOffsetTowardsAncestor(const DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* ancestorLayer, LayoutPo int& location) 1259 static inline const DeprecatedPaintLayer* accumulateOffsetTowardsAncestor(const DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* ancestorLayer, LayoutPo int& location, DeprecatedPaintLayer::LocationQueryBehavior behavior)
1248 { 1260 {
1249 ASSERT(ancestorLayer != layer); 1261 ASSERT(ancestorLayer != layer);
1250 1262
1251 const LayoutBoxModelObject* layoutObject = layer->layoutObject(); 1263 const LayoutBoxModelObject* layoutObject = layer->layoutObject();
1252 EPosition position = layoutObject->style()->position(); 1264 EPosition position = layoutObject->style()->position();
1253 1265
1254 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutO bject->view()->layer())) { 1266 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutO bject->view()->layer())) {
1255 // If the fixed layer's container is the root, just add in the offset of the view. We can obtain this by calling 1267 // If the fixed layer's container is the root, just add in the offset of the view. We can obtain this by calling
1256 // localToAbsolute() on the LayoutView. 1268 // localToAbsolute() on the LayoutView.
1257 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed) ; 1269 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed) ;
1258 location += LayoutSize(absPos.x(), absPos.y()); 1270 location += LayoutSize(absPos.x(), absPos.y());
1259 return ancestorLayer; 1271 return ancestorLayer;
1260 } 1272 }
1261 1273
1262 DeprecatedPaintLayer* parentLayer; 1274 DeprecatedPaintLayer* parentLayer;
1263 if (position == AbsolutePosition || position == FixedPosition) { 1275 if (position == AbsolutePosition || position == FixedPosition) {
1264 bool foundAncestorFirst; 1276 bool foundAncestorFirst;
1265 parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAn cestorFirst); 1277 parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAn cestorFirst);
1266 1278
1267 if (foundAncestorFirst) { 1279 if (foundAncestorFirst) {
1268 // Found ancestorLayer before the container of the out-of-flow objec t, so compute offset 1280 // Found ancestorLayer before the container of the out-of-flow objec t, so compute offset
1269 // of both relative to the container and subtract. 1281 // of both relative to the container and subtract.
1270 1282
1271 LayoutPoint thisCoords; 1283 LayoutPoint thisCoords;
1272 layer->convertToLayerCoords(parentLayer, thisCoords); 1284 layer->convertToLayerCoords(parentLayer, thisCoords, behavior);
1273 1285
1274 LayoutPoint ancestorCoords; 1286 LayoutPoint ancestorCoords;
1275 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords); 1287 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords, beh avior);
1276 1288
1277 location += (thisCoords - ancestorCoords); 1289 location += (thisCoords - ancestorCoords);
1278 return ancestorLayer; 1290 return ancestorLayer;
1279 } 1291 }
1280 } else if (layoutObject->isColumnSpanAll()) { 1292 } else if (layoutObject->isColumnSpanAll()) {
1281 LayoutBlock* multicolContainer = layoutObject->containingBlock(); 1293 LayoutBlock* multicolContainer = layoutObject->containingBlock();
1282 ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread()); 1294 ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread());
1283 parentLayer = multicolContainer->layer(); 1295 parentLayer = multicolContainer->layer();
1284 ASSERT(parentLayer); 1296 ASSERT(parentLayer);
1285 } else { 1297 } else {
1286 parentLayer = layer->parent(); 1298 parentLayer = layer->parent();
1287 } 1299 }
1288 1300
1289 if (!parentLayer) 1301 if (!parentLayer)
1290 return nullptr; 1302 return nullptr;
1291 1303
1292 location += layer->location(); 1304 location += layer->location(behavior);
chrishtr 2015/09/17 18:07:53 I think this introduces n^2 performance, because o
1293 return parentLayer; 1305 return parentLayer;
1294 } 1306 }
1295 1307
1296 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutPoint& location) const 1308 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutPoint& location, LocationQueryBehavior behavior) const
1297 { 1309 {
1298 if (ancestorLayer == this) 1310 if (ancestorLayer == this)
1299 return; 1311 return;
1300 1312
1301 const DeprecatedPaintLayer* currLayer = this; 1313 const DeprecatedPaintLayer* currLayer = this;
1302 while (currLayer && currLayer != ancestorLayer) 1314 while (currLayer && currLayer != ancestorLayer)
1303 currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, lo cation); 1315 currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, lo cation, behavior);
1304 } 1316 }
1305 1317
1306 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutRect& rect) const 1318 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutRect& rect) const
1307 { 1319 {
1308 LayoutPoint delta; 1320 LayoutPoint delta;
1309 convertToLayerCoords(ancestorLayer, delta); 1321 convertToLayerCoords(ancestorLayer, delta);
1310 rect.moveBy(delta); 1322 rect.moveBy(delta);
1311 } 1323 }
1312 1324
1313 LayoutPoint DeprecatedPaintLayer::visualOffsetFromAncestor(const DeprecatedPaint Layer* ancestorLayer) const 1325 LayoutPoint DeprecatedPaintLayer::visualOffsetFromAncestor(const DeprecatedPaint Layer* ancestorLayer) const
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 2723
2712 void showLayerTree(const blink::LayoutObject* layoutObject) 2724 void showLayerTree(const blink::LayoutObject* layoutObject)
2713 { 2725 {
2714 if (!layoutObject) { 2726 if (!layoutObject) {
2715 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2727 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2716 return; 2728 return;
2717 } 2729 }
2718 showLayerTree(layoutObject->enclosingLayer()); 2730 showLayerTree(layoutObject->enclosingLayer());
2719 } 2731 }
2720 #endif 2732 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698