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 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1372 location += LayoutSize(absPos.x(), absPos.y()); | 1372 location += LayoutSize(absPos.x(), absPos.y()); |
1373 return ancestorLayer; | 1373 return ancestorLayer; |
1374 } | 1374 } |
1375 | 1375 |
1376 // For the fixed positioned elements inside a layout flow thread, we should also skip the code path below | 1376 // For the fixed positioned elements inside a layout flow thread, we should also skip the code path below |
1377 // Otherwise, for the case of ancestorLayer == rootLayer and fixed positione d element child of a transformed | 1377 // Otherwise, for the case of ancestorLayer == rootLayer and fixed positione d element child of a transformed |
1378 // element in layout flow thread, we will hit the fixed positioned container before hitting the ancestor layer. | 1378 // element in layout flow thread, we will hit the fixed positioned container before hitting the ancestor layer. |
1379 if (position == FixedPosition) { | 1379 if (position == FixedPosition) { |
1380 // For a fixed layers, we need to walk up to the root to see if there's a fixed position container | 1380 // For a fixed layers, we need to walk up to the root to see if there's a fixed position container |
1381 // (e.g. a transformed layer). It's an error to call convertToLayerCoord s() across a layer with a transform, | 1381 // (e.g. a transformed layer). It's an error to call convertToLayerCoord s() across a layer with a transform, |
1382 // so we should always find the ancestor at or before we find the fixed position container. | 1382 // so we should always find the ancestor at or before we find the fixed position container, if |
1383 // the container is transformed. | |
1383 DeprecatedPaintLayer* fixedPositionContainerLayer = 0; | 1384 DeprecatedPaintLayer* fixedPositionContainerLayer = 0; |
1384 bool foundAncestor = false; | 1385 bool foundAncestor = false; |
1385 for (DeprecatedPaintLayer* currLayer = layer->parent(); currLayer; currL ayer = currLayer->parent()) { | 1386 for (DeprecatedPaintLayer* currLayer = layer->parent(); currLayer; currL ayer = currLayer->parent()) { |
1386 if (currLayer == ancestorLayer) | 1387 if (currLayer == ancestorLayer) |
1387 foundAncestor = true; | 1388 foundAncestor = true; |
1388 | 1389 |
1389 if (isFixedPositionedContainer(currLayer)) { | 1390 if (isFixedPositionedContainer(currLayer)) { |
1390 fixedPositionContainerLayer = currLayer; | 1391 fixedPositionContainerLayer = currLayer; |
1391 ASSERT_UNUSED(foundAncestor, foundAncestor); | 1392 // A layer that has a transform-related property but not a |
1393 // transform still acts as a fixed-position container. | |
1394 // Accumulating offsets across such layers is allowed. | |
1395 if (currLayer->transform()) | |
1396 ASSERT_UNUSED(foundAncestor, foundAncestor); | |
1392 break; | 1397 break; |
1393 } | 1398 } |
1394 } | 1399 } |
1395 | 1400 |
1396 ASSERT(fixedPositionContainerLayer); // We should have hit the LayoutVie w's layer at least. | 1401 ASSERT(fixedPositionContainerLayer); // We should have hit the LayoutVie w's layer at least. |
1397 | 1402 |
1398 if (fixedPositionContainerLayer != ancestorLayer) { | 1403 if (fixedPositionContainerLayer != ancestorLayer) { |
1399 LayoutPoint fixedContainerCoords; | 1404 LayoutPoint fixedContainerCoords; |
1400 layer->convertToLayerCoords(fixedPositionContainerLayer, fixedContai nerCoords); | 1405 layer->convertToLayerCoords(fixedPositionContainerLayer, fixedContai nerCoords); |
1406 location += fixedContainerCoords; | |
1401 | 1407 |
1402 LayoutPoint ancestorCoords; | 1408 if (foundAncestor) { |
chrishtr
2015/04/30 17:46:01
Why would it not find the ancestor? What does this
ajuma
2015/04/30 17:57:15
The code previously assumed that ancestorLayer was
| |
1403 ancestorLayer->convertToLayerCoords(fixedPositionContainerLayer, anc estorCoords); | 1409 LayoutPoint ancestorCoords; |
1404 | 1410 ancestorLayer->convertToLayerCoords(fixedPositionContainerLayer, ancestorCoords); |
1405 location += (fixedContainerCoords - ancestorCoords); | 1411 location += -ancestorCoords; |
1412 } | |
1406 } else { | 1413 } else { |
1407 // LayoutView has been handled in the first top-level 'if' block abo ve. | 1414 // LayoutView has been handled in the first top-level 'if' block abo ve. |
1408 ASSERT(ancestorLayer != layoutObject->view()->layer()); | 1415 ASSERT(ancestorLayer != layoutObject->view()->layer()); |
1409 ASSERT(ancestorLayer->hasTransformRelatedProperty()); | 1416 ASSERT(ancestorLayer->hasTransformRelatedProperty()); |
1410 | 1417 |
1411 location += layer->location(); | 1418 location += layer->location(); |
1412 } | 1419 } |
1413 return ancestorLayer; | 1420 return foundAncestor ? ancestorLayer : fixedPositionContainerLayer; |
1414 } | 1421 } |
1415 | 1422 |
1416 DeprecatedPaintLayer* parentLayer; | 1423 DeprecatedPaintLayer* parentLayer; |
1417 if (position == AbsolutePosition) { | 1424 if (position == AbsolutePosition) { |
1418 // Do what enclosingPositionedAncestor() does, but check for ancestorLay er along the way. | 1425 // Do what enclosingPositionedAncestor() does, but check for ancestorLay er along the way. |
1419 parentLayer = layer->parent(); | 1426 parentLayer = layer->parent(); |
1420 bool foundAncestorFirst = false; | 1427 bool foundAncestorFirst = false; |
1421 while (parentLayer) { | 1428 while (parentLayer) { |
1422 // LayoutFlowThread is a positioned container, child of LayoutView, positioned at (0,0). | 1429 // LayoutFlowThread is a positioned container, child of LayoutView, positioned at (0,0). |
1423 // This implies that, for out-of-flow positioned elements inside a L ayoutFlowThread, | 1430 // This implies that, for out-of-flow positioned elements inside a L ayoutFlowThread, |
(...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2970 } | 2977 } |
2971 } | 2978 } |
2972 | 2979 |
2973 void showLayerTree(const blink::LayoutObject* layoutObject) | 2980 void showLayerTree(const blink::LayoutObject* layoutObject) |
2974 { | 2981 { |
2975 if (!layoutObject) | 2982 if (!layoutObject) |
2976 return; | 2983 return; |
2977 showLayerTree(layoutObject->enclosingLayer()); | 2984 showLayerTree(layoutObject->enclosingLayer()); |
2978 } | 2985 } |
2979 #endif | 2986 #endif |
OLD | NEW |