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

Side by Side Diff: third_party/WebKit/Source/core/animation/ShadowInterpolationFunctions.cpp

Issue 1977763002: Remove OwnPtr::release() calls in core/ (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove static_pointer_cast<>s. Created 4 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 unified diff | Download patch
OLDNEW
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 "core/animation/ShadowInterpolationFunctions.h" 5 #include "core/animation/ShadowInterpolationFunctions.h"
6 6
7 #include "core/animation/CSSColorInterpolationType.h" 7 #include "core/animation/CSSColorInterpolationType.h"
8 #include "core/animation/CSSLengthInterpolationType.h" 8 #include "core/animation/CSSLengthInterpolationType.h"
9 #include "core/animation/InterpolationValue.h" 9 #include "core/animation/InterpolationValue.h"
10 #include "core/animation/NonInterpolableValue.h" 10 #include "core/animation/NonInterpolableValue.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 bool ShadowInterpolationFunctions::nonInterpolableValuesAreCompatible(const NonI nterpolableValue* a, const NonInterpolableValue* b) 51 bool ShadowInterpolationFunctions::nonInterpolableValuesAreCompatible(const NonI nterpolableValue* a, const NonInterpolableValue* b)
52 { 52 {
53 return toShadowNonInterpolableValue(*a).style() == toShadowNonInterpolableVa lue(*b).style(); 53 return toShadowNonInterpolableValue(*a).style() == toShadowNonInterpolableVa lue(*b).style();
54 } 54 }
55 55
56 PairwiseInterpolationValue ShadowInterpolationFunctions::maybeMergeSingles(Inter polationValue&& start, InterpolationValue&& end) 56 PairwiseInterpolationValue ShadowInterpolationFunctions::maybeMergeSingles(Inter polationValue&& start, InterpolationValue&& end)
57 { 57 {
58 if (!nonInterpolableValuesAreCompatible(start.nonInterpolableValue.get(), en d.nonInterpolableValue.get())) 58 if (!nonInterpolableValuesAreCompatible(start.nonInterpolableValue.get(), en d.nonInterpolableValue.get()))
59 return nullptr; 59 return nullptr;
60 return PairwiseInterpolationValue(start.interpolableValue.release(), end.int erpolableValue.release(), start.nonInterpolableValue.release()); 60 return PairwiseInterpolationValue(std::move(start.interpolableValue), std::m ove(end.interpolableValue), start.nonInterpolableValue.release());
61 } 61 }
62 62
63 InterpolationValue ShadowInterpolationFunctions::convertShadowData(const ShadowD ata& shadowData, double zoom) 63 InterpolationValue ShadowInterpolationFunctions::convertShadowData(const ShadowD ata& shadowData, double zoom)
64 { 64 {
65 OwnPtr<InterpolableList> interpolableList = InterpolableList::create(ShadowC omponentIndexCount); 65 OwnPtr<InterpolableList> interpolableList = InterpolableList::create(ShadowC omponentIndexCount);
66 interpolableList->set(ShadowX, CSSLengthInterpolationType::createInterpolabl ePixels(shadowData.x() / zoom)); 66 interpolableList->set(ShadowX, CSSLengthInterpolationType::createInterpolabl ePixels(shadowData.x() / zoom));
67 interpolableList->set(ShadowY, CSSLengthInterpolationType::createInterpolabl ePixels(shadowData.y() / zoom)); 67 interpolableList->set(ShadowY, CSSLengthInterpolationType::createInterpolabl ePixels(shadowData.y() / zoom));
68 interpolableList->set(ShadowBlur, CSSLengthInterpolationType::createInterpol ablePixels(shadowData.blur() / zoom)); 68 interpolableList->set(ShadowBlur, CSSLengthInterpolationType::createInterpol ablePixels(shadowData.blur() / zoom));
69 interpolableList->set(ShadowSpread, CSSLengthInterpolationType::createInterp olablePixels(shadowData.spread() / zoom)); 69 interpolableList->set(ShadowSpread, CSSLengthInterpolationType::createInterp olablePixels(shadowData.spread() / zoom));
70 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInterpol ableColor(shadowData.color())); 70 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInterpol ableColor(shadowData.color()));
71 return InterpolationValue(interpolableList.release(), ShadowNonInterpolableV alue::create(shadowData.style())); 71 return InterpolationValue(std::move(interpolableList), ShadowNonInterpolable Value::create(shadowData.style()));
72 } 72 }
73 73
74 InterpolationValue ShadowInterpolationFunctions::maybeConvertCSSValue(const CSSV alue& value) 74 InterpolationValue ShadowInterpolationFunctions::maybeConvertCSSValue(const CSSV alue& value)
75 { 75 {
76 if (!value.isShadowValue()) 76 if (!value.isShadowValue())
77 return nullptr; 77 return nullptr;
78 const CSSShadowValue& shadow = toCSSShadowValue(value); 78 const CSSShadowValue& shadow = toCSSShadowValue(value);
79 79
80 ShadowStyle style = Normal; 80 ShadowStyle style = Normal;
81 if (shadow.style) { 81 if (shadow.style) {
(...skipping 13 matching lines...) Expand all
95 shadow.y.get(), 95 shadow.y.get(),
96 shadow.blur.get(), 96 shadow.blur.get(),
97 shadow.spread.get(), 97 shadow.spread.get(),
98 }; 98 };
99 for (size_t i = 0; i < WTF_ARRAY_LENGTH(lengths); i++) { 99 for (size_t i = 0; i < WTF_ARRAY_LENGTH(lengths); i++) {
100 if (lengths[i]) { 100 if (lengths[i]) {
101 InterpolationValue lengthField = CSSLengthInterpolationType::maybeCo nvertCSSValue(*lengths[i]); 101 InterpolationValue lengthField = CSSLengthInterpolationType::maybeCo nvertCSSValue(*lengths[i]);
102 if (!lengthField) 102 if (!lengthField)
103 return nullptr; 103 return nullptr;
104 ASSERT(!lengthField.nonInterpolableValue); 104 ASSERT(!lengthField.nonInterpolableValue);
105 interpolableList->set(i, lengthField.interpolableValue.release()); 105 interpolableList->set(i, std::move(lengthField.interpolableValue));
106 } else { 106 } else {
107 interpolableList->set(i, CSSLengthInterpolationType::createInterpola blePixels(0)); 107 interpolableList->set(i, CSSLengthInterpolationType::createInterpola blePixels(0));
108 } 108 }
109 } 109 }
110 110
111 if (shadow.color) { 111 if (shadow.color) {
112 OwnPtr<InterpolableValue> interpolableColor = CSSColorInterpolationType: :maybeCreateInterpolableColor(*shadow.color); 112 OwnPtr<InterpolableValue> interpolableColor = CSSColorInterpolationType: :maybeCreateInterpolableColor(*shadow.color);
113 if (!interpolableColor) 113 if (!interpolableColor)
114 return nullptr; 114 return nullptr;
115 interpolableList->set(ShadowColor, interpolableColor.release()); 115 interpolableList->set(ShadowColor, std::move(interpolableColor));
116 } else { 116 } else {
117 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInte rpolableColor(StyleColor::currentColor())); 117 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInte rpolableColor(StyleColor::currentColor()));
118 } 118 }
119 119
120 return InterpolationValue(interpolableList.release(), ShadowNonInterpolableV alue::create(style)); 120 return InterpolationValue(std::move(interpolableList), ShadowNonInterpolable Value::create(style));
121 } 121 }
122 122
123 PassOwnPtr<InterpolableValue> ShadowInterpolationFunctions::createNeutralInterpo lableValue() 123 PassOwnPtr<InterpolableValue> ShadowInterpolationFunctions::createNeutralInterpo lableValue()
124 { 124 {
125 return convertShadowData(ShadowData(FloatPoint(0, 0), 0, 0, Normal, StyleCol or(Color::transparent)), 1).interpolableValue.release(); 125 return convertShadowData(ShadowData(FloatPoint(0, 0), 0, 0, Normal, StyleCol or(Color::transparent)), 1).interpolableValue;
126 } 126 }
127 127
128 void ShadowInterpolationFunctions::composite(OwnPtr<InterpolableValue>& underlyi ngInterpolableValue, RefPtr<NonInterpolableValue>& underlyingNonInterpolableValu e, double underlyingFraction, const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue) 128 void ShadowInterpolationFunctions::composite(OwnPtr<InterpolableValue>& underlyi ngInterpolableValue, RefPtr<NonInterpolableValue>& underlyingNonInterpolableValu e, double underlyingFraction, const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue)
129 { 129 {
130 ASSERT(nonInterpolableValuesAreCompatible(underlyingNonInterpolableValue.get (), nonInterpolableValue)); 130 ASSERT(nonInterpolableValuesAreCompatible(underlyingNonInterpolableValue.get (), nonInterpolableValue));
131 InterpolableList& underlyingInterpolableList = toInterpolableList(*underlyin gInterpolableValue); 131 InterpolableList& underlyingInterpolableList = toInterpolableList(*underlyin gInterpolableValue);
132 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue); 132 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue);
133 underlyingInterpolableList.scaleAndAdd(underlyingFraction, interpolableList) ; 133 underlyingInterpolableList.scaleAndAdd(underlyingFraction, interpolableList) ;
134 } 134 }
135 135
136 ShadowData ShadowInterpolationFunctions::createShadowData(const InterpolableValu e& interpolableValue, const NonInterpolableValue* nonInterpolableValue, const St yleResolverState& state) 136 ShadowData ShadowInterpolationFunctions::createShadowData(const InterpolableValu e& interpolableValue, const NonInterpolableValue* nonInterpolableValue, const St yleResolverState& state)
137 { 137 {
138 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue); 138 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue);
139 const ShadowNonInterpolableValue& shadowNonInterpolableValue = toShadowNonIn terpolableValue(*nonInterpolableValue); 139 const ShadowNonInterpolableValue& shadowNonInterpolableValue = toShadowNonIn terpolableValue(*nonInterpolableValue);
140 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio nData(); 140 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio nData();
141 Length shadowX = CSSLengthInterpolationType::resolveInterpolableLength(*inte rpolableList.get(ShadowX), nullptr, conversionData); 141 Length shadowX = CSSLengthInterpolationType::resolveInterpolableLength(*inte rpolableList.get(ShadowX), nullptr, conversionData);
142 Length shadowY = CSSLengthInterpolationType::resolveInterpolableLength(*inte rpolableList.get(ShadowY), nullptr, conversionData); 142 Length shadowY = CSSLengthInterpolationType::resolveInterpolableLength(*inte rpolableList.get(ShadowY), nullptr, conversionData);
143 Length shadowBlur = CSSLengthInterpolationType::resolveInterpolableLength(*i nterpolableList.get(ShadowBlur), nullptr, conversionData, ValueRangeNonNegative) ; 143 Length shadowBlur = CSSLengthInterpolationType::resolveInterpolableLength(*i nterpolableList.get(ShadowBlur), nullptr, conversionData, ValueRangeNonNegative) ;
144 Length shadowSpread = CSSLengthInterpolationType::resolveInterpolableLength( *interpolableList.get(ShadowSpread), nullptr, conversionData); 144 Length shadowSpread = CSSLengthInterpolationType::resolveInterpolableLength( *interpolableList.get(ShadowSpread), nullptr, conversionData);
145 ASSERT(shadowX.isFixed() && shadowY.isFixed() && shadowBlur.isFixed() && sha dowSpread.isFixed()); 145 ASSERT(shadowX.isFixed() && shadowY.isFixed() && shadowBlur.isFixed() && sha dowSpread.isFixed());
146 return ShadowData( 146 return ShadowData(
147 FloatPoint(shadowX.value(), shadowY.value()), shadowBlur.value(), shadow Spread.value(), shadowNonInterpolableValue.style(), 147 FloatPoint(shadowX.value(), shadowY.value()), shadowBlur.value(), shadow Spread.value(), shadowNonInterpolableValue.style(),
148 CSSColorInterpolationType::resolveInterpolableColor(*interpolableList.ge t(ShadowColor), state)); 148 CSSColorInterpolationType::resolveInterpolableColor(*interpolableList.ge t(ShadowColor), state));
149 } 149 }
150 150
151 } // namespace blink 151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698