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

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

Issue 2881673003: CSS Motion Path: Support parsing of ray(<angle>) paths (Closed)
Patch Set: size contain? 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/StyleRay.cpp
diff --git a/third_party/WebKit/Source/core/style/StyleRay.cpp b/third_party/WebKit/Source/core/style/StyleRay.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9be76673fbe5655d77a52db169092138948bc7db
--- /dev/null
+++ b/third_party/WebKit/Source/core/style/StyleRay.cpp
@@ -0,0 +1,92 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/style/StyleRay.h"
+
+#include "core/css/CSSIdentifierValue.h"
+#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSRayValue.h"
+#include "core/css/CSSValueList.h"
+
+namespace blink {
+
+namespace {
+
+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;
+ }
+}
+
+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;
+}
+
+} // anonymous namespace
+
+PassRefPtr<StyleRay> StyleRay::Create(const CSSRayValue& value) {
fs 2017/05/15 09:18:14 Could we have this just take the three values, and
Eric Willigers 2017/05/15 10:52:23 Done.
+ return AdoptRef(new StyleRay(value));
+}
+
+StyleRay::StyleRay(const CSSRayValue& value) {
+ angle_ = value.Angle()->ComputeDegrees();
+ size_ = KeywordToRaySize(value.Size()->GetValueID());
+ contain_ = !!value.Contain();
+}
+
+CSSRayValue* StyleRay::ComputedCSSValue() const {
fs 2017/05/15 09:18:14 I think this might as well go in ValueForBasicShap
Eric Willigers 2017/05/15 10:52:23 Done.
+ CSSValueList* arguments = CSSValueList::CreateSpaceSeparated();
+ arguments->Append(*CSSPrimitiveValue::Create(
+ Angle(), CSSPrimitiveValue::UnitType::kDegrees));
+ arguments->Append(*CSSIdentifierValue::Create(RaySizeToKeyword(Size())));
+ if (Contain())
+ arguments->Append(*CSSIdentifierValue::Create(CSSValueContain));
+ return CSSRayValue::Create(arguments);
+}
+
+bool StyleRay::operator==(const BasicShape& o) const {
+ if (!IsSameType(o))
+ return false;
+ const StyleRay& other = ToStyleRay(o);
+ return angle_ == other.angle_;
fs 2017/05/15 09:18:14 Should also check size_ and contain_?
Eric Willigers 2017/05/15 10:52:23 Done.
+}
+
+void StyleRay::GetPath(Path&, const FloatRect&) {
+ // ComputedStyle::ApplyMotionPathTransform cannot call GetPath
+ // for rays as they may have infinite length.
fs 2017/05/15 09:18:14 This is kind of an indication that ray(...) isn't
Eric Willigers 2017/05/15 10:52:23 Acknowledged.
+ NOTREACHED();
+}
+
+PassRefPtr<BasicShape> StyleRay::Blend(const BasicShape*, double) const {
+ // FIXME(ericwilligers): Implement animation for offset-path.
fs 2017/05/15 09:18:14 TODO
Eric Willigers 2017/05/15 10:52:23 Done.
+ NOTREACHED();
+ return nullptr;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698