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

Unified Diff: third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp

Issue 2881673003: CSS Motion Path: Support parsing of ray(<angle>) paths (Closed)
Patch Set: DCHECK_EQ 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/css/BasicShapeFunctions.cpp
diff --git a/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp b/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp
index e47da16600e0f27c59d39af66c04b9560ff22e60..e17f2aa74d4d7d81bed0f6c1003bf5b6bf5692a1 100644
--- a/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp
+++ b/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp
@@ -32,13 +32,50 @@
#include "core/css/CSSBasicShapeValues.h"
#include "core/css/CSSIdentifierValue.h"
#include "core/css/CSSPrimitiveValueMappings.h"
+#include "core/css/CSSRayValue.h"
#include "core/css/CSSValuePair.h"
#include "core/css/resolver/StyleResolverState.h"
#include "core/style/BasicShapes.h"
#include "core/style/ComputedStyle.h"
+#include "core/style/StyleRay.h"
namespace blink {
+static StyleRay::RaySize KeywordToRaySize(CSSValueID id) {
+ switch (id) {
+ case CSSValueClosestSide:
+ return StyleRay::RaySize::kClosestSide;
+ case CSSValueClosestCorner:
+ return StyleRay::RaySize::kClosestCorner;
+ case CSSValueFarthestSide:
+ return StyleRay::RaySize::kFarthestSide;
+ case CSSValueFarthestCorner:
+ return StyleRay::RaySize::kFarthestCorner;
+ case CSSValueSides:
+ return StyleRay::RaySize::kSides;
+ default:
+ NOTREACHED();
+ return StyleRay::RaySize::kClosestSide;
+ }
+}
+
+static CSSValueID RaySizeToKeyword(StyleRay::RaySize size) {
+ switch (size) {
+ case StyleRay::RaySize::kClosestSide:
+ return CSSValueClosestSide;
+ case StyleRay::RaySize::kClosestCorner:
+ return CSSValueClosestCorner;
+ case StyleRay::RaySize::kFarthestSide:
+ return CSSValueFarthestSide;
+ case StyleRay::RaySize::kFarthestCorner:
+ return CSSValueFarthestCorner;
+ case StyleRay::RaySize::kSides:
+ return CSSValueSides;
+ }
+ NOTREACHED();
+ return CSSValueInvalid;
+}
+
static CSSValue* ValueForCenterCoordinate(
const ComputedStyle& style,
const BasicShapeCenterCoordinate& center,
@@ -81,6 +118,19 @@ static CSSValue* BasicShapeRadiusToCSSValue(const ComputedStyle& style,
CSSValue* ValueForBasicShape(const ComputedStyle& style,
const BasicShape* basic_shape) {
switch (basic_shape->GetType()) {
+ case BasicShape::kStyleRayType: {
+ const StyleRay& ray = ToStyleRay(*basic_shape);
+ return CSSRayValue::Create(
+ *CSSPrimitiveValue::Create(ray.Angle(),
+ CSSPrimitiveValue::UnitType::kDegrees),
+ *CSSIdentifierValue::Create(RaySizeToKeyword(ray.Size())),
+ (ray.Contain() ? CSSIdentifierValue::Create(CSSValueContain)
+ : nullptr));
+ }
+
+ case BasicShape::kStylePathType:
+ return ToStylePath(basic_shape)->ComputedCSSValue();
+
case BasicShape::kBasicShapeCircleType: {
const BasicShapeCircle* circle = ToBasicShapeCircle(basic_shape);
CSSBasicShapeCircleValue* circle_value =
@@ -295,6 +345,12 @@ PassRefPtr<BasicShape> BasicShapeForValue(const StyleResolverState& state,
ConvertToLengthSize(state, rect_value.BottomLeftRadius()));
basic_shape = std::move(rect);
+ } else if (basic_shape_value.IsRayValue()) {
+ const CSSRayValue& ray_value = ToCSSRayValue(basic_shape_value);
+ float angle = ray_value.Angle().ComputeDegrees();
+ StyleRay::RaySize size = KeywordToRaySize(ray_value.Size().GetValueID());
+ bool contain = !!ray_value.Contain();
+ basic_shape = StyleRay::Create(angle, size, contain);
} else {
NOTREACHED();
}

Powered by Google App Engine
This is Rietveld 408576698