| 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 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 } | 1259 } |
| 1260 | 1260 |
| 1261 // Returns the layer reached on the walk up towards the ancestor. | 1261 // Returns the layer reached on the walk up towards the ancestor. |
| 1262 static inline const DeprecatedPaintLayer* accumulateOffsetTowardsAncestor(const
DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* ancestorLayer, LayoutPo
int& location) | 1262 static inline const DeprecatedPaintLayer* accumulateOffsetTowardsAncestor(const
DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* ancestorLayer, LayoutPo
int& location) |
| 1263 { | 1263 { |
| 1264 ASSERT(ancestorLayer != layer); | 1264 ASSERT(ancestorLayer != layer); |
| 1265 | 1265 |
| 1266 const LayoutBoxModelObject* layoutObject = layer->layoutObject(); | 1266 const LayoutBoxModelObject* layoutObject = layer->layoutObject(); |
| 1267 EPosition position = layoutObject->style()->position(); | 1267 EPosition position = layoutObject->style()->position(); |
| 1268 | 1268 |
| 1269 // FIXME: Positioning of out-of-flow(fixed, absolute) elements collected in
a LayoutFlowThread | |
| 1270 // may need to be revisited in a future patch. | |
| 1271 // If the fixed layoutObject is inside a LayoutFlowThread, we should not com
pute location using localToAbsolute, | |
| 1272 // since localToAbsolute maps the coordinates from flow thread to column set
coordinates and column sets can be | |
| 1273 // positioned in a completely different place in the viewport (LayoutView). | |
| 1274 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutO
bject->view()->layer())) { | 1269 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutO
bject->view()->layer())) { |
| 1275 // If the fixed layer's container is the root, just add in the offset of
the view. We can obtain this by calling | 1270 // If the fixed layer's container is the root, just add in the offset of
the view. We can obtain this by calling |
| 1276 // localToAbsolute() on the LayoutView. | 1271 // localToAbsolute() on the LayoutView. |
| 1277 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed)
; | 1272 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed)
; |
| 1278 location += LayoutSize(absPos.x(), absPos.y()); | 1273 location += LayoutSize(absPos.x(), absPos.y()); |
| 1279 return ancestorLayer; | 1274 return ancestorLayer; |
| 1280 } | 1275 } |
| 1281 | 1276 |
| 1282 // For the fixed positioned elements inside a layout flow thread, we should
also skip the code path below | |
| 1283 // Otherwise, for the case of ancestorLayer == rootLayer and fixed positione
d element child of a transformed | |
| 1284 // element in layout flow thread, we will hit the fixed positioned container
before hitting the ancestor layer. | |
| 1285 if (position == FixedPosition) { | 1277 if (position == FixedPosition) { |
| 1286 // For a fixed layers, we need to walk up to the root to see if there's
a fixed position container | 1278 // For a fixed layers, we need to walk up to the root to see if there's
a fixed position container |
| 1287 // (e.g. a transformed layer). It's an error to call convertToLayerCoord
s() across a layer with a transform, | 1279 // (e.g. a transformed layer). It's an error to call convertToLayerCoord
s() across a layer with a transform, |
| 1288 // so we should always find the ancestor at or before we find the fixed
position container, if | 1280 // so we should always find the ancestor at or before we find the fixed
position container, if |
| 1289 // the container is transformed. | 1281 // the container is transformed. |
| 1290 DeprecatedPaintLayer* fixedPositionContainerLayer = 0; | 1282 DeprecatedPaintLayer* fixedPositionContainerLayer = 0; |
| 1291 bool foundAncestor = false; | 1283 bool foundAncestor = false; |
| 1292 for (DeprecatedPaintLayer* currLayer = layer->parent(); currLayer; currL
ayer = currLayer->parent()) { | 1284 for (DeprecatedPaintLayer* currLayer = layer->parent(); currLayer; currL
ayer = currLayer->parent()) { |
| 1293 if (currLayer == ancestorLayer) | 1285 if (currLayer == ancestorLayer) |
| 1294 foundAncestor = true; | 1286 foundAncestor = true; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1325 } | 1317 } |
| 1326 return foundAncestor ? ancestorLayer : fixedPositionContainerLayer; | 1318 return foundAncestor ? ancestorLayer : fixedPositionContainerLayer; |
| 1327 } | 1319 } |
| 1328 | 1320 |
| 1329 DeprecatedPaintLayer* parentLayer; | 1321 DeprecatedPaintLayer* parentLayer; |
| 1330 if (position == AbsolutePosition) { | 1322 if (position == AbsolutePosition) { |
| 1331 // Do what enclosingPositionedAncestor() does, but check for ancestorLay
er along the way. | 1323 // Do what enclosingPositionedAncestor() does, but check for ancestorLay
er along the way. |
| 1332 parentLayer = layer->parent(); | 1324 parentLayer = layer->parent(); |
| 1333 bool foundAncestorFirst = false; | 1325 bool foundAncestorFirst = false; |
| 1334 while (parentLayer) { | 1326 while (parentLayer) { |
| 1335 // LayoutFlowThread is a positioned container, child of LayoutView,
positioned at (0,0). | |
| 1336 // This implies that, for out-of-flow positioned elements inside a L
ayoutFlowThread, | |
| 1337 // we are bailing out before reaching root layer. | |
| 1338 if (parentLayer->isPositionedContainer()) | 1327 if (parentLayer->isPositionedContainer()) |
| 1339 break; | 1328 break; |
| 1340 | 1329 |
| 1341 if (parentLayer == ancestorLayer) { | 1330 if (parentLayer == ancestorLayer) { |
| 1342 foundAncestorFirst = true; | 1331 foundAncestorFirst = true; |
| 1343 break; | 1332 break; |
| 1344 } | 1333 } |
| 1345 | 1334 |
| 1346 parentLayer = parentLayer->parent(); | 1335 parentLayer = parentLayer->parent(); |
| 1347 } | 1336 } |
| 1348 | 1337 |
| 1349 // We should not reach LayoutView layer past the LayoutFlowThread layer
for any | |
| 1350 // children of the LayoutFlowThread. | |
| 1351 ASSERT(!layoutObject->flowThreadContainingBlock() || parentLayer != layo
utObject->view()->layer()); | |
| 1352 | |
| 1353 if (foundAncestorFirst) { | 1338 if (foundAncestorFirst) { |
| 1354 // Found ancestorLayer before the abs. positioned container, so comp
ute offset of both relative | 1339 // Found ancestorLayer before the abs. positioned container, so comp
ute offset of both relative |
| 1355 // to enclosingPositionedAncestor and subtract. | 1340 // to enclosingPositionedAncestor and subtract. |
| 1356 DeprecatedPaintLayer* positionedAncestor = parentLayer->enclosingPos
itionedAncestor(); | 1341 DeprecatedPaintLayer* positionedAncestor = parentLayer->enclosingPos
itionedAncestor(); |
| 1357 | 1342 |
| 1358 LayoutPoint thisCoords; | 1343 LayoutPoint thisCoords; |
| 1359 layer->convertToLayerCoords(positionedAncestor, thisCoords); | 1344 layer->convertToLayerCoords(positionedAncestor, thisCoords); |
| 1360 | 1345 |
| 1361 LayoutPoint ancestorCoords; | 1346 LayoutPoint ancestorCoords; |
| 1362 ancestorLayer->convertToLayerCoords(positionedAncestor, ancestorCoor
ds); | 1347 ancestorLayer->convertToLayerCoords(positionedAncestor, ancestorCoor
ds); |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2755 | 2740 |
| 2756 void showLayerTree(const blink::LayoutObject* layoutObject) | 2741 void showLayerTree(const blink::LayoutObject* layoutObject) |
| 2757 { | 2742 { |
| 2758 if (!layoutObject) { | 2743 if (!layoutObject) { |
| 2759 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2744 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
| 2760 return; | 2745 return; |
| 2761 } | 2746 } |
| 2762 showLayerTree(layoutObject->enclosingLayer()); | 2747 showLayerTree(layoutObject->enclosingLayer()); |
| 2763 } | 2748 } |
| 2764 #endif | 2749 #endif |
| OLD | NEW |