Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Unified Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2884943002: CSS Motion Path: calculate transform for simple ray() paths (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/style/ComputedStyle.cpp
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.cpp b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
index dcaaded2cb2bb7fc24beab8c511e0551c0a2adf1..75b54b579df1e88c6ba276a8010f454e11e2f951 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -45,6 +45,7 @@
#include "core/style/StyleInheritedData.h"
#include "core/style/StyleInheritedVariables.h"
#include "core/style/StyleNonInheritedVariables.h"
+#include "core/style/StyleRay.h"
#include "platform/LengthFunctions.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/fonts/Font.h"
@@ -1331,25 +1332,32 @@ void ComputedStyle::ApplyMotionPathTransform(
}
const LengthPoint& position = OffsetPosition();
const LengthPoint& anchor = OffsetAnchor();
- if (motion_data.path_->GetType() == BasicShape::kStyleRayType) {
- // TODO(ericwilligers): crbug.com/641245 Support ray paths.
- return;
- }
- const StylePath& motion_path = ToStylePath(*motion_data.path_);
- float path_length = motion_path.length();
- float distance = FloatValueForLength(motion_data.distance_, path_length);
- float computed_distance;
- if (motion_path.IsClosed() && path_length > 0) {
- computed_distance = fmod(distance, path_length);
- if (computed_distance < 0)
- computed_distance += path_length;
- } else {
- computed_distance = clampTo<float>(distance, 0, path_length);
- }
FloatPoint point;
float angle;
- motion_path.GetPath().PointAndNormalAtLength(computed_distance, point, angle);
+ if (motion_data.path_->GetType() == BasicShape::kStyleRayType) {
+ // TODO(ericwilligers): crbug.com/641245 Support <size> for ray paths.
+ float distance = FloatValueForLength(motion_data.distance_, 0);
+
+ angle = ToStyleRay(*motion_data.path_).Angle() - 90;
+ point.SetX(distance * cos(deg2rad(angle)));
+ point.SetY(distance * sin(deg2rad(angle)));
+ } else {
+ 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
+ float path_length = motion_path.length();
+ float distance = FloatValueForLength(motion_data.distance_, path_length);
+ float computed_distance;
+ if (motion_path.IsClosed() && path_length > 0) {
+ computed_distance = fmod(distance, path_length);
+ if (computed_distance < 0)
+ computed_distance += path_length;
+ } else {
+ computed_distance = clampTo<float>(distance, 0, path_length);
+ }
+
+ motion_path.GetPath().PointAndNormalAtLength(computed_distance, point,
+ angle);
+ }
if (motion_data.rotation_.type == kOffsetRotationFixed)
angle = 0;

Powered by Google App Engine
This is Rietveld 408576698