OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 default: | 1254 default: |
1255 break; | 1255 break; |
1256 } | 1256 } |
1257 } | 1257 } |
1258 return false; | 1258 return false; |
1259 } | 1259 } |
1260 | 1260 |
1261 bool ComputedStyle::requireTransformOrigin( | 1261 bool ComputedStyle::requireTransformOrigin( |
1262 ApplyTransformOrigin applyOrigin, | 1262 ApplyTransformOrigin applyOrigin, |
1263 ApplyMotionPath applyMotionPath) const { | 1263 ApplyMotionPath applyMotionPath) const { |
1264 const Vector<RefPtr<TransformOperation>>& transformOperations = | |
1265 transform().operations(); | |
1266 | |
1267 // transform-origin brackets the transform with translate operations. | 1264 // transform-origin brackets the transform with translate operations. |
1268 // Optimize for the case where the only transform is a translation, since the | 1265 // Optimize for the case where the only transform is a translation, since the |
1269 // transform-origin is irrelevant in that case. | 1266 // transform-origin is irrelevant in that case. |
1270 if (applyOrigin != IncludeTransformOrigin) | 1267 if (applyOrigin != IncludeTransformOrigin) |
1271 return false; | 1268 return false; |
1272 | 1269 |
1273 if (applyMotionPath == IncludeMotionPath) | 1270 if (applyMotionPath == IncludeMotionPath) |
1274 return true; | 1271 return true; |
1275 | 1272 |
1276 unsigned size = transformOperations.size(); | 1273 for (const auto& operation : transform().operations()) { |
1277 for (unsigned i = 0; i < size; ++i) { | 1274 TransformOperation::OperationType type = operation->type(); |
1278 TransformOperation::OperationType type = transformOperations[i]->type(); | |
1279 if (type != TransformOperation::TranslateX && | 1275 if (type != TransformOperation::TranslateX && |
1280 type != TransformOperation::TranslateY && | 1276 type != TransformOperation::TranslateY && |
1281 type != TransformOperation::Translate && | 1277 type != TransformOperation::Translate && |
1282 type != TransformOperation::TranslateZ && | 1278 type != TransformOperation::TranslateZ && |
1283 type != TransformOperation::Translate3D) | 1279 type != TransformOperation::Translate3D) |
1284 return true; | 1280 return true; |
1285 } | 1281 } |
1286 | 1282 |
1287 return scale() || rotate(); | 1283 return scale() || rotate(); |
1288 } | 1284 } |
(...skipping 15 matching lines...) Expand all Loading... |
1304 const FloatRect& boundingBox, | 1300 const FloatRect& boundingBox, |
1305 ApplyTransformOrigin applyOrigin, | 1301 ApplyTransformOrigin applyOrigin, |
1306 ApplyMotionPath applyMotionPath, | 1302 ApplyMotionPath applyMotionPath, |
1307 ApplyIndependentTransformProperties applyIndependentTransformProperties) | 1303 ApplyIndependentTransformProperties applyIndependentTransformProperties) |
1308 const { | 1304 const { |
1309 if (!hasOffset()) | 1305 if (!hasOffset()) |
1310 applyMotionPath = ExcludeMotionPath; | 1306 applyMotionPath = ExcludeMotionPath; |
1311 bool applyTransformOrigin = | 1307 bool applyTransformOrigin = |
1312 requireTransformOrigin(applyOrigin, applyMotionPath); | 1308 requireTransformOrigin(applyOrigin, applyMotionPath); |
1313 | 1309 |
1314 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; | |
1315 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; | |
1316 | |
1317 float originX = 0; | 1310 float originX = 0; |
1318 float originY = 0; | 1311 float originY = 0; |
1319 float originZ = 0; | 1312 float originZ = 0; |
1320 | 1313 |
| 1314 const FloatSize& boxSize = boundingBox.size(); |
1321 if (applyTransformOrigin || | 1315 if (applyTransformOrigin || |
1322 // We need to calculate originX and originY for applying motion path. | 1316 // We need to calculate originX and originY for applying motion path. |
1323 applyMotionPath == ComputedStyle::IncludeMotionPath) { | 1317 applyMotionPath == IncludeMotionPath) { |
| 1318 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; |
1324 originX = | 1319 originX = |
1325 floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX; | 1320 floatValueForLength(transformOriginX(), boxSize.width()) + offsetX; |
| 1321 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; |
1326 originY = | 1322 originY = |
1327 floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY; | 1323 floatValueForLength(transformOriginY(), boxSize.height()) + offsetY; |
1328 if (applyTransformOrigin) { | 1324 if (applyTransformOrigin) { |
1329 originZ = transformOriginZ(); | 1325 originZ = transformOriginZ(); |
1330 result.translate3d(originX, originY, originZ); | 1326 result.translate3d(originX, originY, originZ); |
1331 } | 1327 } |
1332 } | 1328 } |
1333 | 1329 |
1334 if (applyIndependentTransformProperties == | 1330 if (applyIndependentTransformProperties == |
1335 IncludeIndependentTransformProperties) { | 1331 IncludeIndependentTransformProperties) { |
1336 if (translate()) | 1332 if (translate()) |
1337 translate()->apply(result, boundingBox.size()); | 1333 translate()->apply(result, boxSize); |
1338 | 1334 |
1339 if (rotate()) | 1335 if (rotate()) |
1340 rotate()->apply(result, boundingBox.size()); | 1336 rotate()->apply(result, boxSize); |
1341 | 1337 |
1342 if (scale()) | 1338 if (scale()) |
1343 scale()->apply(result, boundingBox.size()); | 1339 scale()->apply(result, boxSize); |
1344 } | 1340 } |
1345 | 1341 |
1346 if (applyMotionPath == ComputedStyle::IncludeMotionPath) | 1342 if (applyMotionPath == IncludeMotionPath) |
1347 applyMotionPathTransform(originX, originY, result); | 1343 applyMotionPathTransform(originX, originY, result); |
1348 | 1344 |
1349 const Vector<RefPtr<TransformOperation>>& transformOperations = | 1345 for (const auto& operation : transform().operations()) |
1350 transform().operations(); | 1346 operation->apply(result, boxSize); |
1351 unsigned size = transformOperations.size(); | |
1352 for (unsigned i = 0; i < size; ++i) | |
1353 transformOperations[i]->apply(result, boundingBox.size()); | |
1354 | 1347 |
1355 if (applyTransformOrigin) { | 1348 if (applyTransformOrigin) { |
1356 result.translate3d(-originX, -originY, -originZ); | 1349 result.translate3d(-originX, -originY, -originZ); |
1357 } | 1350 } |
1358 } | 1351 } |
1359 | 1352 |
1360 void ComputedStyle::applyMotionPathTransform( | 1353 void ComputedStyle::applyMotionPathTransform( |
1361 float originX, | 1354 float originX, |
1362 float originY, | 1355 float originY, |
1363 TransformationMatrix& transform) const { | 1356 TransformationMatrix& transform) const { |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 if (value < 0) | 2393 if (value < 0) |
2401 fvalue -= 0.5f; | 2394 fvalue -= 0.5f; |
2402 else | 2395 else |
2403 fvalue += 0.5f; | 2396 fvalue += 0.5f; |
2404 } | 2397 } |
2405 | 2398 |
2406 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 2399 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
2407 } | 2400 } |
2408 | 2401 |
2409 } // namespace blink | 2402 } // namespace blink |
OLD | NEW |