OLD | NEW |
---|---|
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 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1243 EPosition position = layoutObject->style()->position(); | 1243 EPosition position = layoutObject->style()->position(); |
1244 | 1244 |
1245 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutO bject->view()->layer())) { | 1245 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutO bject->view()->layer())) { |
1246 // If the fixed layer's container is the root, just add in the offset of the view. We can obtain this by calling | 1246 // If the fixed layer's container is the root, just add in the offset of the view. We can obtain this by calling |
1247 // localToAbsolute() on the LayoutView. | 1247 // localToAbsolute() on the LayoutView. |
1248 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed) ; | 1248 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed) ; |
1249 location += LayoutSize(absPos.x(), absPos.y()); | 1249 location += LayoutSize(absPos.x(), absPos.y()); |
1250 return ancestorLayer; | 1250 return ancestorLayer; |
1251 } | 1251 } |
1252 | 1252 |
1253 if (position == FixedPosition) { | |
1254 // For a fixed layers, we need to walk up to the root to see if there's a fixed position container | |
1255 // (e.g. a transformed layer). It's an error to call convertToLayerCoord s() across a layer with a transform, | |
1256 // so we should always find the ancestor at or before we find the fixed position container, if | |
1257 // the container is transformed. | |
1258 DeprecatedPaintLayer* fixedPositionContainerLayer = 0; | |
1259 bool foundAncestor = false; | |
1260 for (DeprecatedPaintLayer* currLayer = layer->parent(); currLayer; currL ayer = currLayer->parent()) { | |
1261 if (currLayer == ancestorLayer) | |
1262 foundAncestor = true; | |
1263 | |
1264 if (isFixedPositionedContainer(currLayer)) { | |
1265 fixedPositionContainerLayer = currLayer; | |
1266 // A layer that has a transform-related property but not a | |
1267 // transform still acts as a fixed-position container. | |
1268 // Accumulating offsets across such layers is allowed. | |
1269 if (currLayer->transform()) | |
1270 ASSERT_UNUSED(foundAncestor, foundAncestor); | |
1271 break; | |
1272 } | |
1273 } | |
1274 | |
1275 ASSERT(fixedPositionContainerLayer); // We should have hit the LayoutVie w's layer at least. | |
1276 | |
1277 if (fixedPositionContainerLayer != ancestorLayer) { | |
1278 LayoutPoint fixedContainerCoords; | |
1279 layer->convertToLayerCoords(fixedPositionContainerLayer, fixedContai nerCoords); | |
1280 location += fixedContainerCoords; | |
1281 | |
1282 if (foundAncestor) { | |
1283 LayoutPoint ancestorCoords; | |
1284 ancestorLayer->convertToLayerCoords(fixedPositionContainerLayer, ancestorCoords); | |
1285 location += -ancestorCoords; | |
1286 } | |
1287 } else { | |
1288 // LayoutView has been handled in the first top-level 'if' block abo ve. | |
1289 ASSERT(ancestorLayer != layoutObject->view()->layer()); | |
1290 ASSERT(ancestorLayer->hasTransformRelatedProperty()); | |
1291 | |
1292 location += layer->location(); | |
1293 } | |
1294 return foundAncestor ? ancestorLayer : fixedPositionContainerLayer; | |
1295 } | |
1296 | |
1297 DeprecatedPaintLayer* parentLayer; | 1253 DeprecatedPaintLayer* parentLayer; |
1298 if (position == AbsolutePosition) { | 1254 if (position == AbsolutePosition || position == FixedPosition) { |
1299 bool foundAncestorFirst; | 1255 bool foundAncestorFirst; |
1300 parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAn cestorFirst); | 1256 parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAn cestorFirst); |
1301 | 1257 |
1302 if (foundAncestorFirst) { | 1258 if (foundAncestorFirst) { |
1303 // Found ancestorLayer before the abs. positioned container, so comp ute offset of both relative | 1259 // Found ancestorLayer before the container of the out-of-flow objec t, so compute offset |
1304 // to the positioned ancestor and subtract. | 1260 // of both relative to the positioned ancestor and subtract. |
Julien - ping for review
2015/07/29 23:10:52
s/positioned ancestor/container (as fixed position
mstensho (USE GERRIT)
2015/07/30 09:32:06
Done.
| |
1305 | 1261 |
1306 LayoutPoint thisCoords; | 1262 LayoutPoint thisCoords; |
1307 layer->convertToLayerCoords(parentLayer, thisCoords); | 1263 layer->convertToLayerCoords(parentLayer, thisCoords); |
1308 | 1264 |
1309 LayoutPoint ancestorCoords; | 1265 LayoutPoint ancestorCoords; |
1310 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords); | 1266 ancestorLayer->convertToLayerCoords(parentLayer, ancestorCoords); |
1311 | 1267 |
1312 location += (thisCoords - ancestorCoords); | 1268 location += (thisCoords - ancestorCoords); |
1313 return ancestorLayer; | 1269 return ancestorLayer; |
1314 } | 1270 } |
1315 } else if (layoutObject->isColumnSpanAll()) { | 1271 } else if (layoutObject->isColumnSpanAll()) { |
1316 LayoutBlock* multicolContainer = layoutObject->containingBlock(); | 1272 LayoutBlock* multicolContainer = layoutObject->containingBlock(); |
1317 ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread()); | 1273 ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread()); |
1318 parentLayer = multicolContainer->layer(); | 1274 parentLayer = multicolContainer->layer(); |
1319 ASSERT(parentLayer); | 1275 ASSERT(parentLayer); |
1320 } else { | 1276 } else { |
1321 parentLayer = layer->parent(); | 1277 parentLayer = layer->parent(); |
1322 } | 1278 } |
1323 | 1279 |
1324 if (!parentLayer) | 1280 if (!parentLayer) |
1325 return 0; | 1281 return nullptr; |
1326 | 1282 |
1327 location += layer->location(); | 1283 location += layer->location(); |
1328 return parentLayer; | 1284 return parentLayer; |
1329 } | 1285 } |
1330 | 1286 |
1331 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutPoint& location) const | 1287 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutPoint& location) const |
1332 { | 1288 { |
1333 if (ancestorLayer == this) | 1289 if (ancestorLayer == this) |
1334 return; | 1290 return; |
1335 | 1291 |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2698 | 2654 |
2699 void showLayerTree(const blink::LayoutObject* layoutObject) | 2655 void showLayerTree(const blink::LayoutObject* layoutObject) |
2700 { | 2656 { |
2701 if (!layoutObject) { | 2657 if (!layoutObject) { |
2702 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2658 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
2703 return; | 2659 return; |
2704 } | 2660 } |
2705 showLayerTree(layoutObject->enclosingLayer()); | 2661 showLayerTree(layoutObject->enclosingLayer()); |
2706 } | 2662 } |
2707 #endif | 2663 #endif |
OLD | NEW |