OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/SVGStrokeDasharrayStyleInterpolation.h" | 6 #include "core/animation/SVGStrokeDasharrayStyleInterpolation.h" |
7 | 7 |
8 #include "core/animation/LengthStyleInterpolation.h" | 8 #include "core/animation/LengthStyleInterpolation.h" |
9 #include "core/css/CSSValueList.h" | 9 #include "core/css/CSSValueList.h" |
10 #include "core/css/resolver/StyleBuilder.h" | 10 #include "core/css/resolver/StyleBuilder.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return isNone(value); | 41 return isNone(value); |
42 const CSSValueList& valueList = toCSSValueList(value); | 42 const CSSValueList& valueList = toCSSValueList(value); |
43 | 43 |
44 for (size_t index = 0; index < valueList.length(); ++index) { | 44 for (size_t index = 0; index < valueList.length(); ++index) { |
45 if (!LengthStyleInterpolation::canCreateFrom(*valueList.item(index))) | 45 if (!LengthStyleInterpolation::canCreateFrom(*valueList.item(index))) |
46 return false; | 46 return false; |
47 } | 47 } |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 PassRefPtrWillBeRawPtr<SVGStrokeDasharrayStyleInterpolation> SVGStrokeDasharrayS
tyleInterpolation::maybeCreate(const CSSValue& start, const CSSValue& end, CSSPr
opertyID id) | 51 PassRefPtr<SVGStrokeDasharrayStyleInterpolation> SVGStrokeDasharrayStyleInterpol
ation::maybeCreate(const CSSValue& start, const CSSValue& end, CSSPropertyID id) |
52 { | 52 { |
53 if (!canCreateFrom(start) || !canCreateFrom(end)) | 53 if (!canCreateFrom(start) || !canCreateFrom(end)) |
54 return nullptr; | 54 return nullptr; |
55 | 55 |
56 RefPtrWillBeRawPtr<CSSValueList> singleZero = CSSValueList::createCommaSepar
ated(); | 56 RefPtrWillBeRawPtr<CSSValueList> singleZero = CSSValueList::createCommaSepar
ated(); |
57 singleZero->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType:
:Pixels)); | 57 singleZero->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType:
:Pixels)); |
58 | 58 |
59 const CSSValueList& valueListStart = start.isValueList() ? toCSSValueList(st
art) : *singleZero; | 59 const CSSValueList& valueListStart = start.isValueList() ? toCSSValueList(st
art) : *singleZero; |
60 const CSSValueList& valueListEnd = end.isValueList() ? toCSSValueList(end) :
*singleZero; | 60 const CSSValueList& valueListEnd = end.isValueList() ? toCSSValueList(end) :
*singleZero; |
61 size_t size = lowestCommonMultiple(valueListStart.length(), valueListEnd.len
gth()); | 61 size_t size = lowestCommonMultiple(valueListStart.length(), valueListEnd.len
gth()); |
62 ASSERT(size > 0); | 62 ASSERT(size > 0); |
63 | 63 |
64 OwnPtrWillBeRawPtr<InterpolableList> interpolableStart = InterpolableList::c
reate(size); | 64 OwnPtr<InterpolableList> interpolableStart = InterpolableList::create(size); |
65 OwnPtrWillBeRawPtr<InterpolableList> interpolableEnd = InterpolableList::cre
ate(size); | 65 OwnPtr<InterpolableList> interpolableEnd = InterpolableList::create(size); |
66 | 66 |
67 for (size_t i = 0; i < size; ++i) { | 67 for (size_t i = 0; i < size; ++i) { |
68 const CSSPrimitiveValue& from = *toCSSPrimitiveValue(valueListStart.item
(i % valueListStart.length())); | 68 const CSSPrimitiveValue& from = *toCSSPrimitiveValue(valueListStart.item
(i % valueListStart.length())); |
69 const CSSPrimitiveValue& to = *toCSSPrimitiveValue(valueListEnd.item(i %
valueListEnd.length())); | 69 const CSSPrimitiveValue& to = *toCSSPrimitiveValue(valueListEnd.item(i %
valueListEnd.length())); |
70 | 70 |
71 interpolableStart->set(i, LengthStyleInterpolation::toInterpolableValue(
from)); | 71 interpolableStart->set(i, LengthStyleInterpolation::toInterpolableValue(
from)); |
72 interpolableEnd->set(i, LengthStyleInterpolation::toInterpolableValue(to
)); | 72 interpolableEnd->set(i, LengthStyleInterpolation::toInterpolableValue(to
)); |
73 } | 73 } |
74 return adoptRefWillBeNoop(new SVGStrokeDasharrayStyleInterpolation(interpola
bleStart.release(), interpolableEnd.release(), id)); | 74 return adoptRef(new SVGStrokeDasharrayStyleInterpolation(interpolableStart.r
elease(), interpolableEnd.release(), id)); |
75 } | 75 } |
76 | 76 |
77 void SVGStrokeDasharrayStyleInterpolation::apply(StyleResolverState& state) cons
t | 77 void SVGStrokeDasharrayStyleInterpolation::apply(StyleResolverState& state) cons
t |
78 { | 78 { |
79 StyleBuilder::applyProperty(m_id, state, interpolableValueToStrokeDasharray(
*m_cachedValue).get()); | 79 StyleBuilder::applyProperty(m_id, state, interpolableValueToStrokeDasharray(
*m_cachedValue).get()); |
80 } | 80 } |
81 | 81 |
82 } | 82 } |
OLD | NEW |