Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 scrollingConfigChanged = true; | 445 scrollingConfigChanged = true; |
| 446 } | 446 } |
| 447 | 447 |
| 448 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer(), needsAncestorClip)) | 448 if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), require sVerticalScrollbarLayer(), requiresScrollCornerLayer(), needsAncestorClip)) |
| 449 layerConfigChanged = true; | 449 layerConfigChanged = true; |
| 450 | 450 |
| 451 bool hasPerspective = false; | 451 bool hasPerspective = false; |
| 452 // FIXME: Can |style| be really null that late in the DocumentCycle? | 452 // FIXME: Can |style| be really null that late in the DocumentCycle? |
| 453 if (const ComputedStyle* style = renderer->style()) | 453 if (const ComputedStyle* style = renderer->style()) |
| 454 hasPerspective = style->hasPerspective(); | 454 hasPerspective = style->hasPerspective(); |
| 455 bool needsChildTransformLayer = hasPerspective && (layerForChildrenTransform () == m_childTransformLayer.get()) && renderer->isBox(); | 455 bool needsChildTransformLayer = hasPerspective && renderer->isBox(); |
| 456 if (updateChildTransformLayer(needsChildTransformLayer)) | 456 if (updateChildTransformLayer(needsChildTransformLayer)) |
| 457 layerConfigChanged = true; | 457 layerConfigChanged = true; |
| 458 | 458 |
| 459 if (updateSquashingLayers(!m_squashedLayers.isEmpty())) | 459 if (updateSquashingLayers(!m_squashedLayers.isEmpty())) |
| 460 layerConfigChanged = true; | 460 layerConfigChanged = true; |
| 461 | 461 |
| 462 updateScrollParent(scrollParent); | 462 updateScrollParent(scrollParent); |
| 463 updateClipParent(); | 463 updateClipParent(); |
| 464 | 464 |
| 465 if (layerConfigChanged) | 465 if (layerConfigChanged) |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 // m_foregroundLayer has to be inserted in the correct order with child laye rs, | 1053 // m_foregroundLayer has to be inserted in the correct order with child laye rs, |
| 1054 // so it's not inserted here. | 1054 // so it's not inserted here. |
| 1055 if (m_ancestorClippingLayer) | 1055 if (m_ancestorClippingLayer) |
| 1056 m_ancestorClippingLayer->removeAllChildren(); | 1056 m_ancestorClippingLayer->removeAllChildren(); |
| 1057 | 1057 |
| 1058 m_graphicsLayer->removeFromParent(); | 1058 m_graphicsLayer->removeFromParent(); |
| 1059 | 1059 |
| 1060 if (m_ancestorClippingLayer) | 1060 if (m_ancestorClippingLayer) |
| 1061 m_ancestorClippingLayer->addChild(m_graphicsLayer.get()); | 1061 m_ancestorClippingLayer->addChild(m_graphicsLayer.get()); |
| 1062 | 1062 |
| 1063 if (m_childContainmentLayer) | 1063 // Layer to which children should be attached as we build the hierarchy. |
| 1064 m_graphicsLayer->addChild(m_childContainmentLayer.get()); | 1064 GraphicsLayer* bottomLayer = m_graphicsLayer.get(); |
| 1065 else if (m_childTransformLayer) | 1065 auto updateBottomLayer = [&bottomLayer](GraphicsLayer* layer) { |
| 1066 m_graphicsLayer->addChild(m_childTransformLayer.get()); | 1066 if (layer) { |
| 1067 bottomLayer->addChild(layer); | |
| 1068 bottomLayer = layer; | |
| 1069 } | |
| 1070 }; | |
| 1067 | 1071 |
| 1068 if (m_scrollingLayer) { | 1072 updateBottomLayer(m_childTransformLayer.get()); |
| 1069 GraphicsLayer* superLayer = m_graphicsLayer.get(); | 1073 updateBottomLayer(m_childContainmentLayer.get()); |
| 1074 updateBottomLayer(m_scrollingLayer.get()); | |
| 1070 | 1075 |
| 1071 if (m_childContainmentLayer) | 1076 // Now constructing the subtree for the overflow controls. |
| 1072 superLayer = m_childContainmentLayer.get(); | 1077 bottomLayer = m_graphicsLayer.get(); |
| 1073 | 1078 updateBottomLayer(m_overflowControlsClippingLayer.get()); |
| 1074 if (m_childTransformLayer) | 1079 updateBottomLayer(m_overflowControlsHostLayer.get()); |
| 1075 superLayer = m_childTransformLayer.get(); | |
| 1076 | |
| 1077 superLayer->addChild(m_scrollingLayer.get()); | |
| 1078 } | |
| 1079 | |
| 1080 // The clip for child layers does not include space for overflow controls, s o they exist as | |
| 1081 // siblings of the clipping layer if we have one. Normal children of this la yer are set as | |
| 1082 // children of the clipping layer. | |
| 1083 if (m_overflowControlsClippingLayer) { | |
| 1084 ASSERT(m_overflowControlsHostLayer); | |
| 1085 m_graphicsLayer->addChild(m_overflowControlsClippingLayer.get()); | |
| 1086 m_overflowControlsClippingLayer->addChild(m_overflowControlsHostLayer.ge t()); | |
| 1087 } else if (m_overflowControlsHostLayer) { | |
| 1088 m_graphicsLayer->addChild(m_overflowControlsHostLayer.get()); | |
| 1089 } | |
| 1090 | |
| 1091 if (m_layerForHorizontalScrollbar) | 1080 if (m_layerForHorizontalScrollbar) |
| 1092 m_overflowControlsHostLayer->addChild(m_layerForHorizontalScrollbar.get( )); | 1081 m_overflowControlsHostLayer->addChild(m_layerForHorizontalScrollbar.get( )); |
| 1093 if (m_layerForVerticalScrollbar) | 1082 if (m_layerForVerticalScrollbar) |
| 1094 m_overflowControlsHostLayer->addChild(m_layerForVerticalScrollbar.get()) ; | 1083 m_overflowControlsHostLayer->addChild(m_layerForVerticalScrollbar.get()) ; |
| 1095 if (m_layerForScrollCorner) | 1084 if (m_layerForScrollCorner) |
| 1096 m_overflowControlsHostLayer->addChild(m_layerForScrollCorner.get()); | 1085 m_overflowControlsHostLayer->addChild(m_layerForScrollCorner.get()); |
| 1097 | 1086 |
| 1098 // The squashing containment layer, if it exists, becomes a no-op parent. | 1087 // The squashing containment layer, if it exists, becomes a no-op parent. |
| 1099 if (m_squashingLayer) { | 1088 if (m_squashingLayer) { |
| 1100 ASSERT((m_ancestorClippingLayer && !m_squashingContainmentLayer) || (!m_ ancestorClippingLayer && m_squashingContainmentLayer)); | 1089 ASSERT((m_ancestorClippingLayer && !m_squashingContainmentLayer) || (!m_ ancestorClippingLayer && m_squashingContainmentLayer)); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1226 | 1215 |
| 1227 if (m_maskLayer) | 1216 if (m_maskLayer) |
| 1228 m_maskLayer->setDrawsContent(true); | 1217 m_maskLayer->setDrawsContent(true); |
| 1229 | 1218 |
| 1230 if (m_childClippingMaskLayer) | 1219 if (m_childClippingMaskLayer) |
| 1231 m_childClippingMaskLayer->setDrawsContent(true); | 1220 m_childClippingMaskLayer->setDrawsContent(true); |
| 1232 } | 1221 } |
| 1233 | 1222 |
| 1234 void CompositedDeprecatedPaintLayerMapping::updateChildrenTransform() | 1223 void CompositedDeprecatedPaintLayerMapping::updateChildrenTransform() |
| 1235 { | 1224 { |
| 1236 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { | 1225 if (GraphicsLayer* childTransformLayer = this->childTransformLayer()) { |
| 1237 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); | 1226 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); |
| 1238 childTransformLayer->setTransformOrigin(FloatPoint3D(childTransformLayer ->size().width() * 0.5f, childTransformLayer->size().height() * 0.5f, 0.f)); | 1227 childTransformLayer->setTransformOrigin(owningLayer().perspectiveOrigin( )); |
| 1239 } | 1228 } |
| 1240 | 1229 |
| 1241 updateShouldFlattenTransform(); | 1230 updateShouldFlattenTransform(); |
| 1242 } | 1231 } |
| 1243 | 1232 |
| 1244 // Return true if the layers changed. | 1233 // Return true if the layers changed. |
| 1245 bool CompositedDeprecatedPaintLayerMapping::updateClippingLayers(bool needsAnces torClip, bool needsDescendantClip) | 1234 bool CompositedDeprecatedPaintLayerMapping::updateClippingLayers(bool needsAnces torClip, bool needsDescendantClip) |
| 1246 { | 1235 { |
| 1247 bool layersChanged = false; | 1236 bool layersChanged = false; |
| 1248 | 1237 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1383 return false; | 1372 return false; |
| 1384 } | 1373 } |
| 1385 | 1374 |
| 1386 enum ApplyToGraphicsLayersModeFlags { | 1375 enum ApplyToGraphicsLayersModeFlags { |
| 1387 ApplyToLayersAffectedByPreserve3D = (1 << 0), | 1376 ApplyToLayersAffectedByPreserve3D = (1 << 0), |
| 1388 ApplyToSquashingLayer = (1 << 1), | 1377 ApplyToSquashingLayer = (1 << 1), |
| 1389 ApplyToScrollbarLayers = (1 << 2), | 1378 ApplyToScrollbarLayers = (1 << 2), |
| 1390 ApplyToBackgroundLayer = (1 << 3), | 1379 ApplyToBackgroundLayer = (1 << 3), |
| 1391 ApplyToMaskLayers = (1 << 4), | 1380 ApplyToMaskLayers = (1 << 4), |
| 1392 ApplyToContentLayers = (1 << 5), | 1381 ApplyToContentLayers = (1 << 5), |
| 1382 ApplyToChildContainingLayers = (1 << 6), // layers between m_graphicsLayer a nd children | |
|
Ian Vollick
2015/04/01 18:00:09
bikeshed: ApplyToGraphicsLayerDescendants
Ian Vollick
2015/04/01 18:18:18
Chatted with Jeremy about this offline. My bikeshe
jbroman
2015/04/02 15:34:15
Acknowledged.
| |
| 1393 ApplyToAllGraphicsLayers = (ApplyToSquashingLayer | ApplyToScrollbarLayers | ApplyToBackgroundLayer | ApplyToMaskLayers | ApplyToLayersAffectedByPreserve3D | ApplyToContentLayers) | 1383 ApplyToAllGraphicsLayers = (ApplyToSquashingLayer | ApplyToScrollbarLayers | ApplyToBackgroundLayer | ApplyToMaskLayers | ApplyToLayersAffectedByPreserve3D | ApplyToContentLayers) |
| 1394 }; | 1384 }; |
| 1395 typedef unsigned ApplyToGraphicsLayersMode; | 1385 typedef unsigned ApplyToGraphicsLayersMode; |
| 1396 | 1386 |
| 1397 template <typename Func> | 1387 template <typename Func> |
| 1398 static void ApplyToGraphicsLayers(const CompositedDeprecatedPaintLayerMapping* m apping, const Func& f, ApplyToGraphicsLayersMode mode) | 1388 static void ApplyToGraphicsLayers(const CompositedDeprecatedPaintLayerMapping* m apping, const Func& f, ApplyToGraphicsLayersMode mode) |
| 1399 { | 1389 { |
| 1400 ASSERT(mode); | 1390 ASSERT(mode); |
| 1401 | 1391 |
| 1402 if ((mode & ApplyToLayersAffectedByPreserve3D) && mapping->childTransformLay er()) | 1392 if ((mode & ApplyToLayersAffectedByPreserve3D) && mapping->childTransformLay er()) |
| 1403 f(mapping->childTransformLayer()); | 1393 f(mapping->childTransformLayer()); |
| 1404 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToContentLay ers)) && mapping->mainGraphicsLayer()) | 1394 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToContentLay ers)) && mapping->mainGraphicsLayer()) |
| 1405 f(mapping->mainGraphicsLayer()); | 1395 f(mapping->mainGraphicsLayer()); |
| 1406 if ((mode & ApplyToLayersAffectedByPreserve3D) && mapping->clippingLayer()) | 1396 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToChildConta iningLayers)) && mapping->clippingLayer()) |
| 1407 f(mapping->clippingLayer()); | 1397 f(mapping->clippingLayer()); |
| 1408 if ((mode & ApplyToLayersAffectedByPreserve3D) && mapping->scrollingLayer()) | 1398 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToChildConta iningLayers)) && mapping->scrollingLayer()) |
| 1409 f(mapping->scrollingLayer()); | 1399 f(mapping->scrollingLayer()); |
| 1410 if ((mode & ApplyToLayersAffectedByPreserve3D) && mapping->scrollingBlockSel ectionLayer()) | 1400 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToChildConta iningLayers)) && mapping->scrollingBlockSelectionLayer()) |
| 1411 f(mapping->scrollingBlockSelectionLayer()); | 1401 f(mapping->scrollingBlockSelectionLayer()); |
| 1412 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToContentLay ers)) && mapping->scrollingContentsLayer()) | 1402 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToContentLay ers) || (mode & ApplyToChildContainingLayers)) && mapping->scrollingContentsLaye r()) |
| 1413 f(mapping->scrollingContentsLayer()); | 1403 f(mapping->scrollingContentsLayer()); |
| 1414 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToContentLay ers)) && mapping->foregroundLayer()) | 1404 if (((mode & ApplyToLayersAffectedByPreserve3D) || (mode & ApplyToContentLay ers)) && mapping->foregroundLayer()) |
| 1415 f(mapping->foregroundLayer()); | 1405 f(mapping->foregroundLayer()); |
| 1416 | 1406 |
| 1407 if ((mode & ApplyToChildContainingLayers) && mapping->childTransformLayer()) | |
| 1408 f(mapping->childTransformLayer()); | |
| 1409 | |
| 1417 if ((mode & ApplyToSquashingLayer) && mapping->squashingLayer()) | 1410 if ((mode & ApplyToSquashingLayer) && mapping->squashingLayer()) |
| 1418 f(mapping->squashingLayer()); | 1411 f(mapping->squashingLayer()); |
| 1419 | 1412 |
| 1420 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping ->maskLayer()) | 1413 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping ->maskLayer()) |
| 1421 f(mapping->maskLayer()); | 1414 f(mapping->maskLayer()); |
| 1422 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping ->childClippingMaskLayer()) | 1415 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping ->childClippingMaskLayer()) |
| 1423 f(mapping->childClippingMaskLayer()); | 1416 f(mapping->childClippingMaskLayer()); |
| 1424 | 1417 |
| 1425 if (((mode & ApplyToBackgroundLayer) || (mode & ApplyToContentLayers)) && ma pping->backgroundLayer()) | 1418 if (((mode & ApplyToBackgroundLayer) || (mode & ApplyToContentLayers)) && ma pping->backgroundLayer()) |
| 1426 f(mapping->backgroundLayer()); | 1419 f(mapping->backgroundLayer()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1470 void CompositedDeprecatedPaintLayerMapping::updateShouldFlattenTransform() | 1463 void CompositedDeprecatedPaintLayerMapping::updateShouldFlattenTransform() |
| 1471 { | 1464 { |
| 1472 // All CLM-managed layers that could affect a descendant layer should update their | 1465 // All CLM-managed layers that could affect a descendant layer should update their |
| 1473 // should-flatten-transform value (the other layers' transforms don't matter here). | 1466 // should-flatten-transform value (the other layers' transforms don't matter here). |
| 1474 UpdateShouldFlattenTransformFunctor functor = { !m_owningLayer.shouldPreserv e3D() }; | 1467 UpdateShouldFlattenTransformFunctor functor = { !m_owningLayer.shouldPreserv e3D() }; |
| 1475 ApplyToGraphicsLayersMode mode = ApplyToLayersAffectedByPreserve3D; | 1468 ApplyToGraphicsLayersMode mode = ApplyToLayersAffectedByPreserve3D; |
| 1476 ApplyToGraphicsLayers(this, functor, mode); | 1469 ApplyToGraphicsLayers(this, functor, mode); |
| 1477 | 1470 |
| 1478 // Note, if we apply perspective, we have to set should flatten differently | 1471 // Note, if we apply perspective, we have to set should flatten differently |
| 1479 // so that the transform propagates to child layers correctly. | 1472 // so that the transform propagates to child layers correctly. |
| 1480 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { | 1473 if (hasChildTransformLayer()) { |
| 1481 bool hasPerspective = false; | 1474 ApplyToGraphicsLayers(this, [](GraphicsLayer* layer) { |
| 1482 // FIXME: Can |style| be really null here? | 1475 layer->setShouldFlattenTransform(false); |
| 1483 if (const ComputedStyle* style = m_owningLayer.layoutObject()->style()) | 1476 }, ApplyToChildContainingLayers); |
| 1484 hasPerspective = style->hasPerspective(); | |
| 1485 if (hasPerspective) | |
| 1486 childTransformLayer->setShouldFlattenTransform(false); | |
| 1487 | |
| 1488 // Note, if the target is the scrolling layer, we need to ensure that th e | |
| 1489 // scrolling content layer doesn't flatten the transform. (It would be n ice | |
| 1490 // if we could apply transform to the scrolling content layer, but that' s | |
| 1491 // too late, we need the children transform to be applied _before_ the | |
| 1492 // scrolling offset.) | |
| 1493 if (childTransformLayer == m_scrollingLayer.get()) { | |
| 1494 m_scrollingContentsLayer->setShouldFlattenTransform(false); | |
| 1495 m_scrollingBlockSelectionLayer->setShouldFlattenTransform(false); | |
| 1496 } | |
| 1497 } | 1477 } |
| 1498 } | 1478 } |
| 1499 | 1479 |
| 1500 bool CompositedDeprecatedPaintLayerMapping::updateForegroundLayer(bool needsFore groundLayer) | 1480 bool CompositedDeprecatedPaintLayerMapping::updateForegroundLayer(bool needsFore groundLayer) |
| 1501 { | 1481 { |
| 1502 bool layerChanged = false; | 1482 bool layerChanged = false; |
| 1503 if (needsForegroundLayer) { | 1483 if (needsForegroundLayer) { |
| 1504 if (!m_foregroundLayer) { | 1484 if (!m_foregroundLayer) { |
| 1505 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor eground); | 1485 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor eground); |
| 1506 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); | 1486 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1985 { | 1965 { |
| 1986 if (m_squashingContainmentLayer) | 1966 if (m_squashingContainmentLayer) |
| 1987 return m_squashingContainmentLayer.get(); | 1967 return m_squashingContainmentLayer.get(); |
| 1988 | 1968 |
| 1989 if (m_ancestorClippingLayer) | 1969 if (m_ancestorClippingLayer) |
| 1990 return m_ancestorClippingLayer.get(); | 1970 return m_ancestorClippingLayer.get(); |
| 1991 | 1971 |
| 1992 return m_graphicsLayer.get(); | 1972 return m_graphicsLayer.get(); |
| 1993 } | 1973 } |
| 1994 | 1974 |
| 1995 GraphicsLayer* CompositedDeprecatedPaintLayerMapping::layerForChildrenTransform( ) const | |
| 1996 { | |
| 1997 if (GraphicsLayer* clipLayer = clippingLayer()) | |
| 1998 return clipLayer; | |
| 1999 if (m_scrollingLayer) | |
| 2000 return m_scrollingLayer.get(); | |
| 2001 return m_childTransformLayer.get(); | |
| 2002 } | |
| 2003 | |
| 2004 void CompositedDeprecatedPaintLayerMapping::setBlendMode(WebBlendMode blendMode) | 1975 void CompositedDeprecatedPaintLayerMapping::setBlendMode(WebBlendMode blendMode) |
| 2005 { | 1976 { |
| 2006 if (m_ancestorClippingLayer) { | 1977 if (m_ancestorClippingLayer) { |
| 2007 m_ancestorClippingLayer->setBlendMode(blendMode); | 1978 m_ancestorClippingLayer->setBlendMode(blendMode); |
| 2008 m_graphicsLayer->setBlendMode(WebBlendModeNormal); | 1979 m_graphicsLayer->setBlendMode(WebBlendModeNormal); |
| 2009 } else { | 1980 } else { |
| 2010 m_graphicsLayer->setBlendMode(blendMode); | 1981 m_graphicsLayer->setBlendMode(blendMode); |
| 2011 } | 1982 } |
| 2012 } | 1983 } |
| 2013 | 1984 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2373 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2344 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
| 2374 name = "Scrolling Block Selection Layer"; | 2345 name = "Scrolling Block Selection Layer"; |
| 2375 } else { | 2346 } else { |
| 2376 ASSERT_NOT_REACHED(); | 2347 ASSERT_NOT_REACHED(); |
| 2377 } | 2348 } |
| 2378 | 2349 |
| 2379 return name; | 2350 return name; |
| 2380 } | 2351 } |
| 2381 | 2352 |
| 2382 } // namespace blink | 2353 } // namespace blink |
| OLD | NEW |