| 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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1089 |
| 1090 if (m_backgroundLayer) | 1090 if (m_backgroundLayer) |
| 1091 m_backgroundLayer->setDrawsContent(hasPaintedContent); | 1091 m_backgroundLayer->setDrawsContent(hasPaintedContent); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 void CompositedLayerMapping::updateChildrenTransform() | 1094 void CompositedLayerMapping::updateChildrenTransform() |
| 1095 { | 1095 { |
| 1096 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { | 1096 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { |
| 1097 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); | 1097 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); |
| 1098 childTransformLayer->setTransformOrigin(FloatPoint3D(childTransformLayer
->size().width() * 0.5f, childTransformLayer->size().height() * 0.5f, 0.f)); | 1098 childTransformLayer->setTransformOrigin(FloatPoint3D(childTransformLayer
->size().width() * 0.5f, childTransformLayer->size().height() * 0.5f, 0.f)); |
| 1099 bool hasPerspective = false; | 1099 } |
| 1100 if (RenderStyle* style = m_owningLayer.renderer()->style()) | |
| 1101 hasPerspective = style->hasPerspective(); | |
| 1102 if (hasPerspective) | |
| 1103 childTransformLayer->setShouldFlattenTransform(false); | |
| 1104 | 1100 |
| 1105 // Note, if the target is the scrolling layer, we need to ensure that th
e | 1101 updateShouldFlattenTransform(); |
| 1106 // scrolling content layer doesn't flatten the transform. (It would be n
ice | |
| 1107 // if we could apply transform to the scrolling content layer, but that'
s | |
| 1108 // too late, we need the children transform to be applied _before_ the | |
| 1109 // scrolling offset.) | |
| 1110 if (childTransformLayer == m_scrollingLayer.get()) | |
| 1111 m_scrollingContentsLayer->setShouldFlattenTransform(false); | |
| 1112 } | |
| 1113 } | 1102 } |
| 1114 | 1103 |
| 1115 // Return true if the layers changed. | 1104 // Return true if the layers changed. |
| 1116 bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, bool n
eedsDescendantClip) | 1105 bool CompositedLayerMapping::updateClippingLayers(bool needsAncestorClip, bool n
eedsDescendantClip) |
| 1117 { | 1106 { |
| 1118 bool layersChanged = false; | 1107 bool layersChanged = false; |
| 1119 | 1108 |
| 1120 if (needsAncestorClip) { | 1109 if (needsAncestorClip) { |
| 1121 if (!m_ancestorClippingLayer) { | 1110 if (!m_ancestorClippingLayer) { |
| 1122 m_ancestorClippingLayer = createGraphicsLayer(CompositingReasonLayer
ForAncestorClip); | 1111 m_ancestorClippingLayer = createGraphicsLayer(CompositingReasonLayer
ForAncestorClip); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1147 } | 1136 } |
| 1148 | 1137 |
| 1149 bool CompositedLayerMapping::updateChildTransformLayer(bool needsChildTransformL
ayer) | 1138 bool CompositedLayerMapping::updateChildTransformLayer(bool needsChildTransformL
ayer) |
| 1150 { | 1139 { |
| 1151 bool layersChanged = false; | 1140 bool layersChanged = false; |
| 1152 | 1141 |
| 1153 if (needsChildTransformLayer) { | 1142 if (needsChildTransformLayer) { |
| 1154 if (!m_childTransformLayer) { | 1143 if (!m_childTransformLayer) { |
| 1155 m_childTransformLayer = createGraphicsLayer(CompositingReasonLayerFo
rPerspective); | 1144 m_childTransformLayer = createGraphicsLayer(CompositingReasonLayerFo
rPerspective); |
| 1156 m_childTransformLayer->setDrawsContent(false); | 1145 m_childTransformLayer->setDrawsContent(false); |
| 1157 m_childTransformLayer->setShouldFlattenTransform(false); | |
| 1158 layersChanged = true; | 1146 layersChanged = true; |
| 1159 } | 1147 } |
| 1160 } else if (m_childTransformLayer) { | 1148 } else if (m_childTransformLayer) { |
| 1161 m_childTransformLayer->removeFromParent(); | 1149 m_childTransformLayer->removeFromParent(); |
| 1162 m_childTransformLayer = nullptr; | 1150 m_childTransformLayer = nullptr; |
| 1163 layersChanged = true; | 1151 layersChanged = true; |
| 1164 } | 1152 } |
| 1165 | 1153 |
| 1154 updateShouldFlattenTransform(); |
| 1166 return layersChanged; | 1155 return layersChanged; |
| 1167 } | 1156 } |
| 1168 | 1157 |
| 1169 void CompositedLayerMapping::setBackgroundLayerPaintsFixedRootBackground(bool ba
ckgroundLayerPaintsFixedRootBackground) | 1158 void CompositedLayerMapping::setBackgroundLayerPaintsFixedRootBackground(bool ba
ckgroundLayerPaintsFixedRootBackground) |
| 1170 { | 1159 { |
| 1171 m_backgroundLayerPaintsFixedRootBackground = backgroundLayerPaintsFixedRootB
ackground; | 1160 m_backgroundLayerPaintsFixedRootBackground = backgroundLayerPaintsFixedRootB
ackground; |
| 1172 } | 1161 } |
| 1173 | 1162 |
| 1174 // Only a member function so it can call createGraphicsLayer. | 1163 // Only a member function so it can call createGraphicsLayer. |
| 1175 bool CompositedLayerMapping::toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&
layer, bool needsLayer, CompositingReasons reason) | 1164 bool CompositedLayerMapping::toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&
layer, bool needsLayer, CompositingReasons reason) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 if ((mode & ApplyToCoreLayers) && mapping->childTransformLayer()) | 1262 if ((mode & ApplyToCoreLayers) && mapping->childTransformLayer()) |
| 1274 f(mapping->childTransformLayer()); | 1263 f(mapping->childTransformLayer()); |
| 1275 if ((mode & ApplyToCoreLayers) && mapping->ancestorClippingLayer()) | 1264 if ((mode & ApplyToCoreLayers) && mapping->ancestorClippingLayer()) |
| 1276 f(mapping->ancestorClippingLayer()); | 1265 f(mapping->ancestorClippingLayer()); |
| 1277 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping
->mainGraphicsLayer()) | 1266 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping
->mainGraphicsLayer()) |
| 1278 f(mapping->mainGraphicsLayer()); | 1267 f(mapping->mainGraphicsLayer()); |
| 1279 if ((mode & ApplyToCoreLayers) && mapping->clippingLayer()) | 1268 if ((mode & ApplyToCoreLayers) && mapping->clippingLayer()) |
| 1280 f(mapping->clippingLayer()); | 1269 f(mapping->clippingLayer()); |
| 1281 if ((mode & ApplyToCoreLayers) && mapping->scrollingLayer()) | 1270 if ((mode & ApplyToCoreLayers) && mapping->scrollingLayer()) |
| 1282 f(mapping->scrollingLayer()); | 1271 f(mapping->scrollingLayer()); |
| 1272 if ((mode & ApplyToCoreLayers) && mapping->scrollingBlockSelectionLayer()) |
| 1273 f(mapping->scrollingBlockSelectionLayer()); |
| 1283 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping
->scrollingContentsLayer()) | 1274 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping
->scrollingContentsLayer()) |
| 1284 f(mapping->scrollingContentsLayer()); | 1275 f(mapping->scrollingContentsLayer()); |
| 1285 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping
->foregroundLayer()) | 1276 if (((mode & ApplyToCoreLayers) || (mode & ApplyToContentLayers)) && mapping
->foregroundLayer()) |
| 1286 f(mapping->foregroundLayer()); | 1277 f(mapping->foregroundLayer()); |
| 1287 | 1278 |
| 1288 if ((mode & ApplyToSquashingLayer) && mapping->squashingLayer()) | 1279 if ((mode & ApplyToSquashingLayer) && mapping->squashingLayer()) |
| 1289 f(mapping->squashingLayer()); | 1280 f(mapping->squashingLayer()); |
| 1290 | 1281 |
| 1291 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping
->maskLayer()) | 1282 if (((mode & ApplyToMaskLayers) || (mode & ApplyToContentLayers)) && mapping
->maskLayer()) |
| 1292 f(mapping->maskLayer()); | 1283 f(mapping->maskLayer()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 bool shouldFlatten; | 1329 bool shouldFlatten; |
| 1339 }; | 1330 }; |
| 1340 | 1331 |
| 1341 void CompositedLayerMapping::updateShouldFlattenTransform() | 1332 void CompositedLayerMapping::updateShouldFlattenTransform() |
| 1342 { | 1333 { |
| 1343 // All CLM-managed layers that could affect a descendant layer should update
their | 1334 // All CLM-managed layers that could affect a descendant layer should update
their |
| 1344 // should-flatten-transform value (the other layers' transforms don't matter
here). | 1335 // should-flatten-transform value (the other layers' transforms don't matter
here). |
| 1345 UpdateShouldFlattenTransformFunctor functor = { !m_owningLayer.shouldPreserv
e3D() }; | 1336 UpdateShouldFlattenTransformFunctor functor = { !m_owningLayer.shouldPreserv
e3D() }; |
| 1346 ApplyToGraphicsLayersMode mode = ApplyToCoreLayers; | 1337 ApplyToGraphicsLayersMode mode = ApplyToCoreLayers; |
| 1347 ApplyToGraphicsLayers(this, functor, mode); | 1338 ApplyToGraphicsLayers(this, functor, mode); |
| 1339 |
| 1340 // Note, if we apply perspective, we have to set should flatten differently |
| 1341 // so that the transform propagates to child layers correctly. |
| 1342 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { |
| 1343 bool hasPerspective = false; |
| 1344 if (RenderStyle* style = m_owningLayer.renderer()->style()) |
| 1345 hasPerspective = style->hasPerspective(); |
| 1346 if (hasPerspective) |
| 1347 childTransformLayer->setShouldFlattenTransform(false); |
| 1348 |
| 1349 // Note, if the target is the scrolling layer, we need to ensure that th
e |
| 1350 // scrolling content layer doesn't flatten the transform. (It would be n
ice |
| 1351 // if we could apply transform to the scrolling content layer, but that'
s |
| 1352 // too late, we need the children transform to be applied _before_ the |
| 1353 // scrolling offset.) |
| 1354 if (childTransformLayer == m_scrollingLayer.get()) { |
| 1355 m_scrollingContentsLayer->setShouldFlattenTransform(false); |
| 1356 m_scrollingBlockSelectionLayer->setShouldFlattenTransform(false); |
| 1357 } |
| 1358 } |
| 1348 } | 1359 } |
| 1349 | 1360 |
| 1350 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) | 1361 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) |
| 1351 { | 1362 { |
| 1352 bool layerChanged = false; | 1363 bool layerChanged = false; |
| 1353 if (needsForegroundLayer) { | 1364 if (needsForegroundLayer) { |
| 1354 if (!m_foregroundLayer) { | 1365 if (!m_foregroundLayer) { |
| 1355 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor
eground); | 1366 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor
eground); |
| 1356 m_foregroundLayer->setDrawsContent(true); | 1367 m_foregroundLayer->setDrawsContent(true); |
| 1357 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); | 1368 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2252 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
| 2242 name = "Scrolling Block Selection Layer"; | 2253 name = "Scrolling Block Selection Layer"; |
| 2243 } else { | 2254 } else { |
| 2244 ASSERT_NOT_REACHED(); | 2255 ASSERT_NOT_REACHED(); |
| 2245 } | 2256 } |
| 2246 | 2257 |
| 2247 return name; | 2258 return name; |
| 2248 } | 2259 } |
| 2249 | 2260 |
| 2250 } // namespace WebCore | 2261 } // namespace WebCore |
| OLD | NEW |