Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/style/StyleRay.h" | |
| 6 | |
| 7 #include "core/css/CSSIdentifierValue.h" | |
| 8 #include "core/css/CSSPrimitiveValue.h" | |
| 9 #include "core/css/CSSRayValue.h" | |
| 10 #include "core/css/CSSValueList.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 StyleRay::RaySize KeywordToRaySize(CSSValueID id) { | |
| 17 switch (id) { | |
| 18 case CSSValueClosestSide: | |
| 19 return StyleRay::RaySize::kClosestSide; | |
| 20 case CSSValueClosestCorner: | |
| 21 return StyleRay::RaySize::kClosestCorner; | |
| 22 case CSSValueFarthestSide: | |
| 23 return StyleRay::RaySize::kFarthestSide; | |
| 24 case CSSValueFarthestCorner: | |
| 25 return StyleRay::RaySize::kFarthestCorner; | |
| 26 case CSSValueSides: | |
| 27 return StyleRay::RaySize::kSides; | |
| 28 default: | |
| 29 NOTREACHED(); | |
| 30 return StyleRay::RaySize::kClosestSide; | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 CSSValueID RaySizeToKeyword(StyleRay::RaySize size) { | |
| 35 switch (size) { | |
| 36 case StyleRay::RaySize::kClosestSide: | |
| 37 return CSSValueClosestSide; | |
| 38 case StyleRay::RaySize::kClosestCorner: | |
| 39 return CSSValueClosestCorner; | |
| 40 case StyleRay::RaySize::kFarthestSide: | |
| 41 return CSSValueFarthestSide; | |
| 42 case StyleRay::RaySize::kFarthestCorner: | |
| 43 return CSSValueFarthestCorner; | |
| 44 case StyleRay::RaySize::kSides: | |
| 45 return CSSValueSides; | |
| 46 } | |
| 47 NOTREACHED(); | |
| 48 return CSSValueInvalid; | |
| 49 } | |
| 50 | |
| 51 } // anonymous namespace | |
| 52 | |
| 53 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.
| |
| 54 return AdoptRef(new StyleRay(value)); | |
| 55 } | |
| 56 | |
| 57 StyleRay::StyleRay(const CSSRayValue& value) { | |
| 58 angle_ = value.Angle()->ComputeDegrees(); | |
| 59 size_ = KeywordToRaySize(value.Size()->GetValueID()); | |
| 60 contain_ = !!value.Contain(); | |
| 61 } | |
| 62 | |
| 63 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.
| |
| 64 CSSValueList* arguments = CSSValueList::CreateSpaceSeparated(); | |
| 65 arguments->Append(*CSSPrimitiveValue::Create( | |
| 66 Angle(), CSSPrimitiveValue::UnitType::kDegrees)); | |
| 67 arguments->Append(*CSSIdentifierValue::Create(RaySizeToKeyword(Size()))); | |
| 68 if (Contain()) | |
| 69 arguments->Append(*CSSIdentifierValue::Create(CSSValueContain)); | |
| 70 return CSSRayValue::Create(arguments); | |
| 71 } | |
| 72 | |
| 73 bool StyleRay::operator==(const BasicShape& o) const { | |
| 74 if (!IsSameType(o)) | |
| 75 return false; | |
| 76 const StyleRay& other = ToStyleRay(o); | |
| 77 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.
| |
| 78 } | |
| 79 | |
| 80 void StyleRay::GetPath(Path&, const FloatRect&) { | |
| 81 // ComputedStyle::ApplyMotionPathTransform cannot call GetPath | |
| 82 // 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.
| |
| 83 NOTREACHED(); | |
| 84 } | |
| 85 | |
| 86 PassRefPtr<BasicShape> StyleRay::Blend(const BasicShape*, double) const { | |
| 87 // FIXME(ericwilligers): Implement animation for offset-path. | |
|
fs
2017/05/15 09:18:14
TODO
Eric Willigers
2017/05/15 10:52:23
Done.
| |
| 88 NOTREACHED(); | |
| 89 return nullptr; | |
| 90 } | |
| 91 | |
| 92 } // namespace blink | |
| OLD | NEW |