Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 #include "core/style/ComputedStyleConstants.h" | 38 #include "core/style/ComputedStyleConstants.h" |
| 39 #include "core/style/ContentData.h" | 39 #include "core/style/ContentData.h" |
| 40 #include "core/style/CursorData.h" | 40 #include "core/style/CursorData.h" |
| 41 #include "core/style/DataEquivalency.h" | 41 #include "core/style/DataEquivalency.h" |
| 42 #include "core/style/QuotesData.h" | 42 #include "core/style/QuotesData.h" |
| 43 #include "core/style/ShadowList.h" | 43 #include "core/style/ShadowList.h" |
| 44 #include "core/style/StyleImage.h" | 44 #include "core/style/StyleImage.h" |
| 45 #include "core/style/StyleInheritedData.h" | 45 #include "core/style/StyleInheritedData.h" |
| 46 #include "core/style/StyleInheritedVariables.h" | 46 #include "core/style/StyleInheritedVariables.h" |
| 47 #include "core/style/StyleNonInheritedVariables.h" | 47 #include "core/style/StyleNonInheritedVariables.h" |
| 48 #include "core/style/StyleRay.h" | |
| 48 #include "platform/LengthFunctions.h" | 49 #include "platform/LengthFunctions.h" |
| 49 #include "platform/RuntimeEnabledFeatures.h" | 50 #include "platform/RuntimeEnabledFeatures.h" |
| 50 #include "platform/fonts/Font.h" | 51 #include "platform/fonts/Font.h" |
| 51 #include "platform/fonts/FontSelector.h" | 52 #include "platform/fonts/FontSelector.h" |
| 52 #include "platform/geometry/FloatRoundedRect.h" | 53 #include "platform/geometry/FloatRoundedRect.h" |
| 53 #include "platform/graphics/GraphicsContext.h" | 54 #include "platform/graphics/GraphicsContext.h" |
| 54 #include "platform/transforms/RotateTransformOperation.h" | 55 #include "platform/transforms/RotateTransformOperation.h" |
| 55 #include "platform/transforms/ScaleTransformOperation.h" | 56 #include "platform/transforms/ScaleTransformOperation.h" |
| 56 #include "platform/transforms/TranslateTransformOperation.h" | 57 #include "platform/transforms/TranslateTransformOperation.h" |
| 57 #include "platform/wtf/MathExtras.h" | 58 #include "platform/wtf/MathExtras.h" |
| (...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1324 const FloatRect& bounding_box, | 1325 const FloatRect& bounding_box, |
| 1325 TransformationMatrix& transform) const { | 1326 TransformationMatrix& transform) const { |
| 1326 const StyleMotionData& motion_data = | 1327 const StyleMotionData& motion_data = |
| 1327 rare_non_inherited_data_->transform_->motion_; | 1328 rare_non_inherited_data_->transform_->motion_; |
| 1328 // TODO(ericwilligers): crbug.com/638055 Apply offset-position. | 1329 // TODO(ericwilligers): crbug.com/638055 Apply offset-position. |
| 1329 if (!motion_data.path_) { | 1330 if (!motion_data.path_) { |
| 1330 return; | 1331 return; |
| 1331 } | 1332 } |
| 1332 const LengthPoint& position = OffsetPosition(); | 1333 const LengthPoint& position = OffsetPosition(); |
| 1333 const LengthPoint& anchor = OffsetAnchor(); | 1334 const LengthPoint& anchor = OffsetAnchor(); |
| 1334 if (motion_data.path_->GetType() == BasicShape::kStyleRayType) { | |
| 1335 // TODO(ericwilligers): crbug.com/641245 Support ray paths. | |
| 1336 return; | |
| 1337 } | |
| 1338 const StylePath& motion_path = ToStylePath(*motion_data.path_); | |
| 1339 float path_length = motion_path.length(); | |
| 1340 float distance = FloatValueForLength(motion_data.distance_, path_length); | |
| 1341 float computed_distance; | |
| 1342 if (motion_path.IsClosed() && path_length > 0) { | |
| 1343 computed_distance = fmod(distance, path_length); | |
| 1344 if (computed_distance < 0) | |
| 1345 computed_distance += path_length; | |
| 1346 } else { | |
| 1347 computed_distance = clampTo<float>(distance, 0, path_length); | |
| 1348 } | |
| 1349 | 1335 |
| 1350 FloatPoint point; | 1336 FloatPoint point; |
| 1351 float angle; | 1337 float angle; |
| 1352 motion_path.GetPath().PointAndNormalAtLength(computed_distance, point, angle); | 1338 if (motion_data.path_->GetType() == BasicShape::kStyleRayType) { |
| 1339 // TODO(ericwilligers): crbug.com/641245 Support <size> for ray paths. | |
| 1340 float distance = FloatValueForLength(motion_data.distance_, 0); | |
| 1341 | |
| 1342 angle = ToStyleRay(*motion_data.path_).Angle() - 90; | |
| 1343 point.SetX(distance * cos(deg2rad(angle))); | |
| 1344 point.SetY(distance * sin(deg2rad(angle))); | |
| 1345 } else { | |
| 1346 const StylePath& motion_path = ToStylePath(*motion_data.path_); | |
|
pdr.
2017/05/16 22:51:19
Would it be useful to add the following?
DCHECK(mo
Eric Willigers
2017/05/17 05:47:00
ToStylePath is already a debug checked cast, just
| |
| 1347 float path_length = motion_path.length(); | |
| 1348 float distance = FloatValueForLength(motion_data.distance_, path_length); | |
| 1349 float computed_distance; | |
| 1350 if (motion_path.IsClosed() && path_length > 0) { | |
| 1351 computed_distance = fmod(distance, path_length); | |
| 1352 if (computed_distance < 0) | |
| 1353 computed_distance += path_length; | |
| 1354 } else { | |
| 1355 computed_distance = clampTo<float>(distance, 0, path_length); | |
| 1356 } | |
| 1357 | |
| 1358 motion_path.GetPath().PointAndNormalAtLength(computed_distance, point, | |
| 1359 angle); | |
| 1360 } | |
| 1353 | 1361 |
| 1354 if (motion_data.rotation_.type == kOffsetRotationFixed) | 1362 if (motion_data.rotation_.type == kOffsetRotationFixed) |
| 1355 angle = 0; | 1363 angle = 0; |
| 1356 | 1364 |
| 1357 float origin_shift_x = 0; | 1365 float origin_shift_x = 0; |
| 1358 float origin_shift_y = 0; | 1366 float origin_shift_y = 0; |
| 1359 // If offset-Position and offset-anchor properties are not yet enabled, | 1367 // If offset-Position and offset-anchor properties are not yet enabled, |
| 1360 // they will have the default value, auto. | 1368 // they will have the default value, auto. |
| 1361 if (position.X() != Length(kAuto) || anchor.X() != Length(kAuto)) { | 1369 if (position.X() != Length(kAuto) || anchor.X() != Length(kAuto)) { |
| 1362 // Shift the origin from transform-origin to offset-anchor. | 1370 // Shift the origin from transform-origin to offset-anchor. |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2509 if (value < 0) | 2517 if (value < 0) |
| 2510 fvalue -= 0.5f; | 2518 fvalue -= 0.5f; |
| 2511 else | 2519 else |
| 2512 fvalue += 0.5f; | 2520 fvalue += 0.5f; |
| 2513 } | 2521 } |
| 2514 | 2522 |
| 2515 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2523 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
| 2516 } | 2524 } |
| 2517 | 2525 |
| 2518 } // namespace blink | 2526 } // namespace blink |
| OLD | NEW |