Commit a5d34d76 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Make InterpolationValue.non_interpolable_value const

This also eliminated the last caller to LengthInterpolationFunctions::
Composite (out of necessity), hence the two ::Composite* functions
were unified.

Bug: 981024
Change-Id: I197ad0fd246d7aabff08b326e1ee3d9e4520ee35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722941
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682684}
parent 03cfb02f
...@@ -14,12 +14,13 @@ namespace blink { ...@@ -14,12 +14,13 @@ namespace blink {
class BasicShapeNonInterpolableValue : public NonInterpolableValue { class BasicShapeNonInterpolableValue : public NonInterpolableValue {
public: public:
static scoped_refptr<NonInterpolableValue> Create( static scoped_refptr<const NonInterpolableValue> Create(
BasicShape::ShapeType type) { BasicShape::ShapeType type) {
return base::AdoptRef(new BasicShapeNonInterpolableValue(type)); return base::AdoptRef(new BasicShapeNonInterpolableValue(type));
} }
static scoped_refptr<NonInterpolableValue> CreatePolygon(WindRule wind_rule, static scoped_refptr<const NonInterpolableValue> CreatePolygon(
wtf_size_t size) { WindRule wind_rule,
wtf_size_t size) {
return base::AdoptRef(new BasicShapeNonInterpolableValue(wind_rule, size)); return base::AdoptRef(new BasicShapeNonInterpolableValue(wind_rule, size));
} }
......
...@@ -47,8 +47,8 @@ const BasicShape* GetBasicShape(const CSSProperty& property, ...@@ -47,8 +47,8 @@ const BasicShape* GetBasicShape(const CSSProperty& property,
class UnderlyingCompatibilityChecker class UnderlyingCompatibilityChecker
: public CSSInterpolationType::CSSConversionChecker { : public CSSInterpolationType::CSSConversionChecker {
public: public:
UnderlyingCompatibilityChecker( UnderlyingCompatibilityChecker(scoped_refptr<const NonInterpolableValue>
scoped_refptr<NonInterpolableValue> underlying_non_interpolable_value) underlying_non_interpolable_value)
: underlying_non_interpolable_value_( : underlying_non_interpolable_value_(
std::move(underlying_non_interpolable_value)) {} std::move(underlying_non_interpolable_value)) {}
...@@ -60,7 +60,7 @@ class UnderlyingCompatibilityChecker ...@@ -60,7 +60,7 @@ class UnderlyingCompatibilityChecker
*underlying.non_interpolable_value); *underlying.non_interpolable_value);
} }
scoped_refptr<NonInterpolableValue> underlying_non_interpolable_value_; scoped_refptr<const NonInterpolableValue> underlying_non_interpolable_value_;
}; };
class InheritedShapeChecker class InheritedShapeChecker
......
...@@ -224,7 +224,7 @@ InterpolationValue ConvertBorderImageAutoSide() { ...@@ -224,7 +224,7 @@ InterpolationValue ConvertBorderImageAutoSide() {
InterpolationValue ConvertBorderImageLengthBox(const BorderImageLengthBox& box, InterpolationValue ConvertBorderImageLengthBox(const BorderImageLengthBox& box,
double zoom) { double zoom) {
auto list = std::make_unique<InterpolableList>(kSideIndexCount); auto list = std::make_unique<InterpolableList>(kSideIndexCount);
Vector<scoped_refptr<NonInterpolableValue>> non_interpolable_values( Vector<scoped_refptr<const NonInterpolableValue>> non_interpolable_values(
kSideIndexCount); kSideIndexCount);
const BorderImageLength* sides[kSideIndexCount] = {}; const BorderImageLength* sides[kSideIndexCount] = {};
sides[kSideTop] = &box.Top(); sides[kSideTop] = &box.Top();
...@@ -254,7 +254,7 @@ void CompositeSide(UnderlyingValue& underlying_value, ...@@ -254,7 +254,7 @@ void CompositeSide(UnderlyingValue& underlying_value,
underlying_fraction, interpolable_value); underlying_fraction, interpolable_value);
break; break;
case SideType::kLength: case SideType::kLength:
LengthInterpolationFunctions::CompositeUnderlying( LengthInterpolationFunctions::Composite(
underlying_value, underlying_fraction, interpolable_value, underlying_value, underlying_fraction, interpolable_value,
non_interpolable_value); non_interpolable_value);
break; break;
...@@ -313,7 +313,7 @@ InterpolationValue CSSBorderImageLengthBoxInterpolationType::MaybeConvertValue( ...@@ -313,7 +313,7 @@ InterpolationValue CSSBorderImageLengthBoxInterpolationType::MaybeConvertValue(
return nullptr; return nullptr;
auto list = std::make_unique<InterpolableList>(kSideIndexCount); auto list = std::make_unique<InterpolableList>(kSideIndexCount);
Vector<scoped_refptr<NonInterpolableValue>> non_interpolable_values( Vector<scoped_refptr<const NonInterpolableValue>> non_interpolable_values(
kSideIndexCount); kSideIndexCount);
const CSSValue* sides[kSideIndexCount] = {}; const CSSValue* sides[kSideIndexCount] = {};
sides[kSideTop] = quad->Top(); sides[kSideTop] = quad->Top();
......
...@@ -53,7 +53,7 @@ class UnderlyingFilterListChecker ...@@ -53,7 +53,7 @@ class UnderlyingFilterListChecker
: public CSSInterpolationType::CSSConversionChecker { : public CSSInterpolationType::CSSConversionChecker {
public: public:
UnderlyingFilterListChecker( UnderlyingFilterListChecker(
scoped_refptr<NonInterpolableList> non_interpolable_list) scoped_refptr<const NonInterpolableList> non_interpolable_list)
: non_interpolable_list_(std::move(non_interpolable_list)) {} : non_interpolable_list_(std::move(non_interpolable_list)) {}
bool IsValid(const StyleResolverState&, bool IsValid(const StyleResolverState&,
...@@ -73,7 +73,7 @@ class UnderlyingFilterListChecker ...@@ -73,7 +73,7 @@ class UnderlyingFilterListChecker
} }
private: private:
scoped_refptr<NonInterpolableList> non_interpolable_list_; scoped_refptr<const NonInterpolableList> non_interpolable_list_;
}; };
class InheritedFilterListChecker class InheritedFilterListChecker
...@@ -101,7 +101,8 @@ InterpolationValue ConvertFilterList(const FilterOperations& filter_operations, ...@@ -101,7 +101,8 @@ InterpolationValue ConvertFilterList(const FilterOperations& filter_operations,
double zoom) { double zoom) {
wtf_size_t length = filter_operations.size(); wtf_size_t length = filter_operations.size();
auto interpolable_list = std::make_unique<InterpolableList>(length); auto interpolable_list = std::make_unique<InterpolableList>(length);
Vector<scoped_refptr<NonInterpolableValue>> non_interpolable_values(length); Vector<scoped_refptr<const NonInterpolableValue>> non_interpolable_values(
length);
for (wtf_size_t i = 0; i < length; i++) { for (wtf_size_t i = 0; i < length; i++) {
InterpolationValue filter_result = InterpolationValue filter_result =
filter_interpolation_functions::MaybeConvertFilter( filter_interpolation_functions::MaybeConvertFilter(
...@@ -164,7 +165,8 @@ InterpolationValue CSSFilterListInterpolationType::MaybeConvertValue( ...@@ -164,7 +165,8 @@ InterpolationValue CSSFilterListInterpolationType::MaybeConvertValue(
const auto& list = To<CSSValueList>(value); const auto& list = To<CSSValueList>(value);
wtf_size_t length = list.length(); wtf_size_t length = list.length();
auto interpolable_list = std::make_unique<InterpolableList>(length); auto interpolable_list = std::make_unique<InterpolableList>(length);
Vector<scoped_refptr<NonInterpolableValue>> non_interpolable_values(length); Vector<scoped_refptr<const NonInterpolableValue>> non_interpolable_values(
length);
for (wtf_size_t i = 0; i < length; i++) { for (wtf_size_t i = 0; i < length; i++) {
InterpolationValue item_result = InterpolationValue item_result =
filter_interpolation_functions::MaybeConvertCSSFilter(list.Item(i)); filter_interpolation_functions::MaybeConvertCSSFilter(list.Item(i));
...@@ -188,9 +190,9 @@ CSSFilterListInterpolationType::MaybeConvertStandardPropertyUnderlyingValue( ...@@ -188,9 +190,9 @@ CSSFilterListInterpolationType::MaybeConvertStandardPropertyUnderlyingValue(
PairwiseInterpolationValue CSSFilterListInterpolationType::MaybeMergeSingles( PairwiseInterpolationValue CSSFilterListInterpolationType::MaybeMergeSingles(
InterpolationValue&& start, InterpolationValue&& start,
InterpolationValue&& end) const { InterpolationValue&& end) const {
NonInterpolableList& start_non_interpolable_list = const NonInterpolableList& start_non_interpolable_list =
ToNonInterpolableList(*start.non_interpolable_value); ToNonInterpolableList(*start.non_interpolable_value);
NonInterpolableList& end_non_interpolable_list = const NonInterpolableList& end_non_interpolable_list =
ToNonInterpolableList(*end.non_interpolable_value); ToNonInterpolableList(*end.non_interpolable_value);
wtf_size_t start_length = start_non_interpolable_list.length(); wtf_size_t start_length = start_non_interpolable_list.length();
wtf_size_t end_length = end_non_interpolable_list.length(); wtf_size_t end_length = end_non_interpolable_list.length();
...@@ -284,9 +286,8 @@ void CSSFilterListInterpolationType::Composite( ...@@ -284,9 +286,8 @@ void CSSFilterListInterpolationType::Composite(
} }
underlying_value_owner.MutableValue().interpolable_value = underlying_value_owner.MutableValue().interpolable_value =
std::move(extended_interpolable_list); std::move(extended_interpolable_list);
// const_cast to take a ref.
underlying_value_owner.MutableValue().non_interpolable_value = underlying_value_owner.MutableValue().non_interpolable_value =
const_cast<NonInterpolableValue*>(value.non_interpolable_value.get()); value.non_interpolable_value;
} }
void CSSFilterListInterpolationType::ApplyStandardPropertyValue( void CSSFilterListInterpolationType::ApplyStandardPropertyValue(
......
...@@ -50,8 +50,8 @@ class CSSImageNonInterpolableValue : public NonInterpolableValue { ...@@ -50,8 +50,8 @@ class CSSImageNonInterpolableValue : public NonInterpolableValue {
} }
static scoped_refptr<CSSImageNonInterpolableValue> Merge( static scoped_refptr<CSSImageNonInterpolableValue> Merge(
scoped_refptr<NonInterpolableValue> start, scoped_refptr<const NonInterpolableValue> start,
scoped_refptr<NonInterpolableValue> end); scoped_refptr<const NonInterpolableValue> end);
CSSValue* Crossfade(double progress) const { CSSValue* Crossfade(double progress) const {
if (is_single_ || progress <= 0) if (is_single_ || progress <= 0)
...@@ -82,8 +82,8 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSImageNonInterpolableValue); ...@@ -82,8 +82,8 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSImageNonInterpolableValue);
DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSImageNonInterpolableValue); DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSImageNonInterpolableValue);
scoped_refptr<CSSImageNonInterpolableValue> CSSImageNonInterpolableValue::Merge( scoped_refptr<CSSImageNonInterpolableValue> CSSImageNonInterpolableValue::Merge(
scoped_refptr<NonInterpolableValue> start, scoped_refptr<const NonInterpolableValue> start,
scoped_refptr<NonInterpolableValue> end) { scoped_refptr<const NonInterpolableValue> end) {
const CSSImageNonInterpolableValue& start_image_pair = const CSSImageNonInterpolableValue& start_image_pair =
ToCSSImageNonInterpolableValue(*start); ToCSSImageNonInterpolableValue(*start);
const CSSImageNonInterpolableValue& end_image_pair = const CSSImageNonInterpolableValue& end_image_pair =
......
...@@ -119,7 +119,8 @@ InterpolationValue CSSImageListInterpolationType::MaybeConvertValue( ...@@ -119,7 +119,8 @@ InterpolationValue CSSImageListInterpolationType::MaybeConvertValue(
const wtf_size_t length = value_list.length(); const wtf_size_t length = value_list.length();
auto interpolable_list = std::make_unique<InterpolableList>(length); auto interpolable_list = std::make_unique<InterpolableList>(length);
Vector<scoped_refptr<NonInterpolableValue>> non_interpolable_values(length); Vector<scoped_refptr<const NonInterpolableValue>> non_interpolable_values(
length);
for (wtf_size_t i = 0; i < length; i++) { for (wtf_size_t i = 0; i < length; i++) {
InterpolationValue component = InterpolationValue component =
CSSImageInterpolationType::MaybeConvertCSSValue(value_list.Item(i), CSSImageInterpolationType::MaybeConvertCSSValue(value_list.Item(i),
......
...@@ -133,10 +133,8 @@ void CSSLengthInterpolationType::Composite( ...@@ -133,10 +133,8 @@ void CSSLengthInterpolationType::Composite(
double underlying_fraction, double underlying_fraction,
const InterpolationValue& value, const InterpolationValue& value,
double interpolation_fraction) const { double interpolation_fraction) const {
InterpolationValue& underlying = underlying_value_owner.MutableValue();
LengthInterpolationFunctions::Composite( LengthInterpolationFunctions::Composite(
underlying.interpolable_value, underlying.non_interpolable_value, underlying_value_owner, underlying_fraction, *value.interpolable_value,
underlying_fraction, *value.interpolable_value,
value.non_interpolable_value.get()); value.non_interpolable_value.get());
} }
......
...@@ -145,7 +145,7 @@ void CSSLengthListInterpolationType::Composite( ...@@ -145,7 +145,7 @@ void CSSLengthListInterpolationType::Composite(
ListInterpolationFunctions::LengthMatchingStrategy::kLowestCommonMultiple, ListInterpolationFunctions::LengthMatchingStrategy::kLowestCommonMultiple,
WTF::BindRepeating( WTF::BindRepeating(
LengthInterpolationFunctions::NonInterpolableValuesAreCompatible), LengthInterpolationFunctions::NonInterpolableValuesAreCompatible),
WTF::BindRepeating(LengthInterpolationFunctions::CompositeUnderlying)); WTF::BindRepeating(LengthInterpolationFunctions::Composite));
} }
void CSSLengthListInterpolationType::ApplyStandardPropertyValue( void CSSLengthListInterpolationType::ApplyStandardPropertyValue(
......
...@@ -78,7 +78,7 @@ class CSSRotateNonInterpolableValue : public NonInterpolableValue { ...@@ -78,7 +78,7 @@ class CSSRotateNonInterpolableValue : public NonInterpolableValue {
scoped_refptr<CSSRotateNonInterpolableValue> Composite( scoped_refptr<CSSRotateNonInterpolableValue> Composite(
const CSSRotateNonInterpolableValue& other, const CSSRotateNonInterpolableValue& other,
double other_progress) { double other_progress) const {
DCHECK(is_single_ && !is_start_additive_); DCHECK(is_single_ && !is_start_additive_);
if (other.is_single_) { if (other.is_single_) {
DCHECK_EQ(other_progress, 0); DCHECK_EQ(other_progress, 0);
...@@ -241,7 +241,7 @@ void CSSRotateInterpolationType::Composite( ...@@ -241,7 +241,7 @@ void CSSRotateInterpolationType::Composite(
double underlying_fraction, double underlying_fraction,
const InterpolationValue& value, const InterpolationValue& value,
double interpolation_fraction) const { double interpolation_fraction) const {
CSSRotateNonInterpolableValue& underlying_non_interpolable_value = const CSSRotateNonInterpolableValue& underlying_non_interpolable_value =
ToCSSRotateNonInterpolableValue( ToCSSRotateNonInterpolableValue(
*underlying_value_owner.Value().non_interpolable_value); *underlying_value_owner.Value().non_interpolable_value);
const CSSRotateNonInterpolableValue& non_interpolable_value = const CSSRotateNonInterpolableValue& non_interpolable_value =
......
...@@ -39,7 +39,7 @@ struct IndentMode { ...@@ -39,7 +39,7 @@ struct IndentMode {
class CSSTextIndentNonInterpolableValue : public NonInterpolableValue { class CSSTextIndentNonInterpolableValue : public NonInterpolableValue {
public: public:
static scoped_refptr<CSSTextIndentNonInterpolableValue> Create( static scoped_refptr<CSSTextIndentNonInterpolableValue> Create(
scoped_refptr<NonInterpolableValue> length_non_interpolable_value, scoped_refptr<const NonInterpolableValue> length_non_interpolable_value,
const IndentMode& mode) { const IndentMode& mode) {
return base::AdoptRef(new CSSTextIndentNonInterpolableValue( return base::AdoptRef(new CSSTextIndentNonInterpolableValue(
std::move(length_non_interpolable_value), mode)); std::move(length_non_interpolable_value), mode));
...@@ -48,28 +48,64 @@ class CSSTextIndentNonInterpolableValue : public NonInterpolableValue { ...@@ -48,28 +48,64 @@ class CSSTextIndentNonInterpolableValue : public NonInterpolableValue {
const NonInterpolableValue* LengthNonInterpolableValue() const { const NonInterpolableValue* LengthNonInterpolableValue() const {
return length_non_interpolable_value_.get(); return length_non_interpolable_value_.get();
} }
scoped_refptr<NonInterpolableValue>& LengthNonInterpolableValue() {
return length_non_interpolable_value_;
}
const IndentMode& Mode() const { return mode_; } const IndentMode& Mode() const { return mode_; }
DECLARE_NON_INTERPOLABLE_VALUE_TYPE(); DECLARE_NON_INTERPOLABLE_VALUE_TYPE();
private: private:
CSSTextIndentNonInterpolableValue( CSSTextIndentNonInterpolableValue(
scoped_refptr<NonInterpolableValue> length_non_interpolable_value, scoped_refptr<const NonInterpolableValue> length_non_interpolable_value,
const IndentMode& mode) const IndentMode& mode)
: length_non_interpolable_value_( : length_non_interpolable_value_(
std::move(length_non_interpolable_value)), std::move(length_non_interpolable_value)),
mode_(mode) {} mode_(mode) {}
scoped_refptr<NonInterpolableValue> length_non_interpolable_value_; scoped_refptr<const NonInterpolableValue> length_non_interpolable_value_;
const IndentMode mode_; const IndentMode mode_;
}; };
DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSTextIndentNonInterpolableValue); DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSTextIndentNonInterpolableValue);
DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSTextIndentNonInterpolableValue); DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSTextIndentNonInterpolableValue);
// A wrapper for the UnderlyingValue passed to
// CSSTextIndentInterpolationType::Composite which can be forwarded to
// LengthInterpolationFunctions::Composite.
//
// If LengthInterpolationFunctions::Composite calls SetNonInterpolableValue with
// a new NonInterpolableValue, this class wraps it in a new
// CSSTextIndentNonInterpolableValue before being set on the inner
// UnderlyingValue.
class UnderlyingTextIndentAsLengthValue : public UnderlyingValue {
STACK_ALLOCATED();
public:
UnderlyingTextIndentAsLengthValue(UnderlyingValue& inner_underlying_value,
IndentMode mode)
: inner_underlying_value_(inner_underlying_value), mode_(mode) {}
InterpolableValue& MutableInterpolableValue() final {
return inner_underlying_value_.MutableInterpolableValue();
}
const NonInterpolableValue* GetNonInterpolableValue() const final {
const auto& text_indent_non_interpolable_value =
ToCSSTextIndentNonInterpolableValue(
*inner_underlying_value_.GetNonInterpolableValue());
return text_indent_non_interpolable_value.LengthNonInterpolableValue();
}
void SetNonInterpolableValue(
scoped_refptr<const NonInterpolableValue> non_interpolable_value) final {
inner_underlying_value_.SetNonInterpolableValue(
CSSTextIndentNonInterpolableValue::Create(
std::move(non_interpolable_value), mode_));
}
private:
UnderlyingValue& inner_underlying_value_;
const IndentMode mode_;
};
namespace { namespace {
class UnderlyingIndentModeChecker class UnderlyingIndentModeChecker
...@@ -186,9 +222,9 @@ CSSTextIndentInterpolationType::MaybeConvertStandardPropertyUnderlyingValue( ...@@ -186,9 +222,9 @@ CSSTextIndentInterpolationType::MaybeConvertStandardPropertyUnderlyingValue(
PairwiseInterpolationValue CSSTextIndentInterpolationType::MaybeMergeSingles( PairwiseInterpolationValue CSSTextIndentInterpolationType::MaybeMergeSingles(
InterpolationValue&& start, InterpolationValue&& start,
InterpolationValue&& end) const { InterpolationValue&& end) const {
CSSTextIndentNonInterpolableValue& start_non_interpolable_value = const CSSTextIndentNonInterpolableValue& start_non_interpolable_value =
ToCSSTextIndentNonInterpolableValue(*start.non_interpolable_value); ToCSSTextIndentNonInterpolableValue(*start.non_interpolable_value);
CSSTextIndentNonInterpolableValue& end_non_interpolable_value = const CSSTextIndentNonInterpolableValue& end_non_interpolable_value =
ToCSSTextIndentNonInterpolableValue(*end.non_interpolable_value); ToCSSTextIndentNonInterpolableValue(*end.non_interpolable_value);
if (start_non_interpolable_value.Mode() != end_non_interpolable_value.Mode()) if (start_non_interpolable_value.Mode() != end_non_interpolable_value.Mode())
...@@ -226,12 +262,12 @@ void CSSTextIndentInterpolationType::Composite( ...@@ -226,12 +262,12 @@ void CSSTextIndentInterpolationType::Composite(
return; return;
} }
UnderlyingTextIndentAsLengthValue underlying_text_indent_as_length(
underlying_value_owner, mode);
LengthInterpolationFunctions::Composite( LengthInterpolationFunctions::Composite(
underlying_value_owner.MutableValue().interpolable_value, underlying_text_indent_as_length, underlying_fraction,
ToCSSTextIndentNonInterpolableValue( *value.interpolable_value,
*underlying_value_owner.MutableValue().non_interpolable_value)
.LengthNonInterpolableValue(),
underlying_fraction, *value.interpolable_value,
non_interpolable_value.LengthNonInterpolableValue()); non_interpolable_value.LengthNonInterpolableValue());
} }
......
...@@ -39,9 +39,9 @@ class CSSTransformNonInterpolableValue : public NonInterpolableValue { ...@@ -39,9 +39,9 @@ class CSSTransformNonInterpolableValue : public NonInterpolableValue {
} }
static scoped_refptr<CSSTransformNonInterpolableValue> Create( static scoped_refptr<CSSTransformNonInterpolableValue> Create(
CSSTransformNonInterpolableValue&& start, const CSSTransformNonInterpolableValue& start,
double start_fraction, double start_fraction,
CSSTransformNonInterpolableValue&& end, const CSSTransformNonInterpolableValue& end,
double end_fraction) { double end_fraction) {
return base::AdoptRef(new CSSTransformNonInterpolableValue( return base::AdoptRef(new CSSTransformNonInterpolableValue(
false, start.GetInterpolatedTransform(start_fraction), false, start.GetInterpolatedTransform(start_fraction),
...@@ -51,7 +51,7 @@ class CSSTransformNonInterpolableValue : public NonInterpolableValue { ...@@ -51,7 +51,7 @@ class CSSTransformNonInterpolableValue : public NonInterpolableValue {
scoped_refptr<CSSTransformNonInterpolableValue> Composite( scoped_refptr<CSSTransformNonInterpolableValue> Composite(
const CSSTransformNonInterpolableValue& other, const CSSTransformNonInterpolableValue& other,
double other_progress) { double other_progress) const {
DCHECK(!IsAdditive()); DCHECK(!IsAdditive());
if (other.is_single_) { if (other.is_single_) {
DCHECK_EQ(other_progress, 0); DCHECK_EQ(other_progress, 0);
...@@ -107,7 +107,7 @@ class CSSTransformNonInterpolableValue : public NonInterpolableValue { ...@@ -107,7 +107,7 @@ class CSSTransformNonInterpolableValue : public NonInterpolableValue {
Vector<scoped_refptr<TransformOperation>> Concat( Vector<scoped_refptr<TransformOperation>> Concat(
const TransformOperations& a, const TransformOperations& a,
const TransformOperations& b) { const TransformOperations& b) const {
Vector<scoped_refptr<TransformOperation>> result; Vector<scoped_refptr<TransformOperation>> result;
result.ReserveCapacity(a.size() + b.size()); result.ReserveCapacity(a.size() + b.size());
result.AppendVector(a.Operations()); result.AppendVector(a.Operations());
...@@ -247,7 +247,7 @@ void CSSTransformInterpolationType::Composite( ...@@ -247,7 +247,7 @@ void CSSTransformInterpolationType::Composite(
double underlying_fraction, double underlying_fraction,
const InterpolationValue& value, const InterpolationValue& value,
double interpolation_fraction) const { double interpolation_fraction) const {
CSSTransformNonInterpolableValue& underlying_non_interpolable_value = const CSSTransformNonInterpolableValue& underlying_non_interpolable_value =
ToCSSTransformNonInterpolableValue( ToCSSTransformNonInterpolableValue(
*underlying_value_owner.Value().non_interpolable_value); *underlying_value_owner.Value().non_interpolable_value);
const CSSTransformNonInterpolableValue& non_interpolable_value = const CSSTransformNonInterpolableValue& non_interpolable_value =
......
...@@ -20,7 +20,7 @@ class FilterNonInterpolableValue : public NonInterpolableValue { ...@@ -20,7 +20,7 @@ class FilterNonInterpolableValue : public NonInterpolableValue {
public: public:
static scoped_refptr<FilterNonInterpolableValue> Create( static scoped_refptr<FilterNonInterpolableValue> Create(
FilterOperation::OperationType type, FilterOperation::OperationType type,
scoped_refptr<NonInterpolableValue> type_non_interpolable_value) { scoped_refptr<const NonInterpolableValue> type_non_interpolable_value) {
return base::AdoptRef(new FilterNonInterpolableValue( return base::AdoptRef(new FilterNonInterpolableValue(
type, std::move(type_non_interpolable_value))); type, std::move(type_non_interpolable_value)));
} }
...@@ -35,12 +35,12 @@ class FilterNonInterpolableValue : public NonInterpolableValue { ...@@ -35,12 +35,12 @@ class FilterNonInterpolableValue : public NonInterpolableValue {
private: private:
FilterNonInterpolableValue( FilterNonInterpolableValue(
FilterOperation::OperationType type, FilterOperation::OperationType type,
scoped_refptr<NonInterpolableValue> type_non_interpolable_value) scoped_refptr<const NonInterpolableValue> type_non_interpolable_value)
: type_(type), : type_(type),
type_non_interpolable_value_(std::move(type_non_interpolable_value)) {} type_non_interpolable_value_(std::move(type_non_interpolable_value)) {}
const FilterOperation::OperationType type_; const FilterOperation::OperationType type_;
scoped_refptr<NonInterpolableValue> type_non_interpolable_value_; scoped_refptr<const NonInterpolableValue> type_non_interpolable_value_;
}; };
DEFINE_NON_INTERPOLABLE_VALUE_TYPE(FilterNonInterpolableValue); DEFINE_NON_INTERPOLABLE_VALUE_TYPE(FilterNonInterpolableValue);
......
...@@ -20,7 +20,8 @@ struct InterpolationValue { ...@@ -20,7 +20,8 @@ struct InterpolationValue {
explicit InterpolationValue( explicit InterpolationValue(
std::unique_ptr<InterpolableValue> interpolable_value, std::unique_ptr<InterpolableValue> interpolable_value,
scoped_refptr<NonInterpolableValue> non_interpolable_value = nullptr) scoped_refptr<const NonInterpolableValue> non_interpolable_value =
nullptr)
: interpolable_value(std::move(interpolable_value)), : interpolable_value(std::move(interpolable_value)),
non_interpolable_value(std::move(non_interpolable_value)) {} non_interpolable_value(std::move(non_interpolable_value)) {}
...@@ -49,7 +50,7 @@ struct InterpolationValue { ...@@ -49,7 +50,7 @@ struct InterpolationValue {
} }
std::unique_ptr<InterpolableValue> interpolable_value; std::unique_ptr<InterpolableValue> interpolable_value;
scoped_refptr<NonInterpolableValue> non_interpolable_value; scoped_refptr<const NonInterpolableValue> non_interpolable_value;
}; };
} // namespace blink } // namespace blink
......
...@@ -143,18 +143,6 @@ bool LengthInterpolationFunctions::HasPercentage( ...@@ -143,18 +143,6 @@ bool LengthInterpolationFunctions::HasPercentage(
} }
void LengthInterpolationFunctions::Composite( void LengthInterpolationFunctions::Composite(
std::unique_ptr<InterpolableValue>& underlying_interpolable_value,
scoped_refptr<NonInterpolableValue>& underlying_non_interpolable_value,
double underlying_fraction,
const InterpolableValue& interpolable_value,
const NonInterpolableValue* non_interpolable_value) {
underlying_interpolable_value->ScaleAndAdd(underlying_fraction,
interpolable_value);
underlying_non_interpolable_value = CSSLengthNonInterpolableValue::Merge(
underlying_non_interpolable_value.get(), non_interpolable_value);
}
void LengthInterpolationFunctions::CompositeUnderlying(
UnderlyingValue& underlying_value, UnderlyingValue& underlying_value,
double underlying_fraction, double underlying_fraction,
const InterpolableValue& interpolable_value, const InterpolableValue& interpolable_value,
......
...@@ -32,16 +32,10 @@ class LengthInterpolationFunctions { ...@@ -32,16 +32,10 @@ class LengthInterpolationFunctions {
static bool NonInterpolableValuesAreCompatible(const NonInterpolableValue*, static bool NonInterpolableValuesAreCompatible(const NonInterpolableValue*,
const NonInterpolableValue*); const NonInterpolableValue*);
static bool HasPercentage(const NonInterpolableValue*); static bool HasPercentage(const NonInterpolableValue*);
// TODO(andruud): Unify these Composite* functions. static void Composite(UnderlyingValue&,
static void Composite(std::unique_ptr<InterpolableValue>&,
scoped_refptr<NonInterpolableValue>&,
double underlying_fraction, double underlying_fraction,
const InterpolableValue&, const InterpolableValue&,
const NonInterpolableValue*); const NonInterpolableValue*);
static void CompositeUnderlying(UnderlyingValue&,
double underlying_fraction,
const InterpolableValue&,
const NonInterpolableValue*);
static Length CreateLength(const InterpolableValue&, static Length CreateLength(const InterpolableValue&,
const NonInterpolableValue*, const NonInterpolableValue*,
const CSSToLengthConversionData&, const CSSToLengthConversionData&,
......
...@@ -40,7 +40,7 @@ class UnderlyingItemValue : public UnderlyingValue { ...@@ -40,7 +40,7 @@ class UnderlyingItemValue : public UnderlyingValue {
.Get(index_); .Get(index_);
} }
void SetNonInterpolableValue( void SetNonInterpolableValue(
scoped_refptr<NonInterpolableValue> non_interpolable_value) final { scoped_refptr<const NonInterpolableValue> non_interpolable_value) final {
builder_.Set(index_, std::move(non_interpolable_value)); builder_.Set(index_, std::move(non_interpolable_value));
} }
...@@ -156,16 +156,16 @@ PairwiseInterpolationValue ListInterpolationFunctions::MaybeMergeSingles( ...@@ -156,16 +156,16 @@ PairwiseInterpolationValue ListInterpolationFunctions::MaybeMergeSingles(
std::make_unique<InterpolableList>(final_length); std::make_unique<InterpolableList>(final_length);
auto result_end_interpolable_list = auto result_end_interpolable_list =
std::make_unique<InterpolableList>(final_length); std::make_unique<InterpolableList>(final_length);
Vector<scoped_refptr<NonInterpolableValue>> result_non_interpolable_values( Vector<scoped_refptr<const NonInterpolableValue>>
final_length); result_non_interpolable_values(final_length);
InterpolableList& start_interpolable_list = InterpolableList& start_interpolable_list =
ToInterpolableList(*start.interpolable_value); ToInterpolableList(*start.interpolable_value);
InterpolableList& end_interpolable_list = InterpolableList& end_interpolable_list =
ToInterpolableList(*end.interpolable_value); ToInterpolableList(*end.interpolable_value);
NonInterpolableList& start_non_interpolable_list = const NonInterpolableList& start_non_interpolable_list =
ToNonInterpolableList(*start.non_interpolable_value); ToNonInterpolableList(*start.non_interpolable_value);
NonInterpolableList& end_non_interpolable_list = const NonInterpolableList& end_non_interpolable_list =
ToNonInterpolableList(*end.non_interpolable_value); ToNonInterpolableList(*end.non_interpolable_value);
for (wtf_size_t i = 0; i < final_length; i++) { for (wtf_size_t i = 0; i < final_length; i++) {
...@@ -217,7 +217,7 @@ PairwiseInterpolationValue ListInterpolationFunctions::MaybeMergeSingles( ...@@ -217,7 +217,7 @@ PairwiseInterpolationValue ListInterpolationFunctions::MaybeMergeSingles(
static void RepeatToLength(InterpolationValue& value, wtf_size_t length) { static void RepeatToLength(InterpolationValue& value, wtf_size_t length) {
InterpolableList& interpolable_list = InterpolableList& interpolable_list =
ToInterpolableList(*value.interpolable_value); ToInterpolableList(*value.interpolable_value);
NonInterpolableList& non_interpolable_list = const NonInterpolableList& non_interpolable_list =
ToNonInterpolableList(*value.non_interpolable_value); ToNonInterpolableList(*value.non_interpolable_value);
wtf_size_t current_length = interpolable_list.length(); wtf_size_t current_length = interpolable_list.length();
DCHECK_GT(current_length, 0U); DCHECK_GT(current_length, 0U);
...@@ -225,7 +225,7 @@ static void RepeatToLength(InterpolationValue& value, wtf_size_t length) { ...@@ -225,7 +225,7 @@ static void RepeatToLength(InterpolationValue& value, wtf_size_t length) {
return; return;
DCHECK_LT(current_length, length); DCHECK_LT(current_length, length);
auto new_interpolable_list = std::make_unique<InterpolableList>(length); auto new_interpolable_list = std::make_unique<InterpolableList>(length);
Vector<scoped_refptr<NonInterpolableValue>> new_non_interpolable_values( Vector<scoped_refptr<const NonInterpolableValue>> new_non_interpolable_values(
length); length);
for (wtf_size_t i = length; i-- > 0;) { for (wtf_size_t i = length; i-- > 0;) {
new_interpolable_list->Set( new_interpolable_list->Set(
...@@ -246,18 +246,18 @@ static void PadToSameLength(InterpolationValue& value, ...@@ -246,18 +246,18 @@ static void PadToSameLength(InterpolationValue& value,
const InterpolationValue& length_value) { const InterpolationValue& length_value) {
InterpolableList& interpolable_list = InterpolableList& interpolable_list =
ToInterpolableList(*value.interpolable_value); ToInterpolableList(*value.interpolable_value);
NonInterpolableList& non_interpolable_list = const NonInterpolableList& non_interpolable_list =
ToNonInterpolableList(*value.non_interpolable_value); ToNonInterpolableList(*value.non_interpolable_value);
const wtf_size_t current_length = interpolable_list.length(); const wtf_size_t current_length = interpolable_list.length();
InterpolableList& target_interpolable_list = InterpolableList& target_interpolable_list =
ToInterpolableList(*length_value.interpolable_value); ToInterpolableList(*length_value.interpolable_value);
NonInterpolableList& target_non_interpolable_list = const NonInterpolableList& target_non_interpolable_list =
ToNonInterpolableList(*length_value.non_interpolable_value); ToNonInterpolableList(*length_value.non_interpolable_value);
const wtf_size_t target_length = target_interpolable_list.length(); const wtf_size_t target_length = target_interpolable_list.length();
DCHECK_LT(current_length, target_length); DCHECK_LT(current_length, target_length);
auto new_interpolable_list = auto new_interpolable_list =
std::make_unique<InterpolableList>(target_length); std::make_unique<InterpolableList>(target_length);
Vector<scoped_refptr<NonInterpolableValue>> new_non_interpolable_values( Vector<scoped_refptr<const NonInterpolableValue>> new_non_interpolable_values(
target_length); target_length);
wtf_size_t index = 0; wtf_size_t index = 0;
for (; index < current_length; index++) { for (; index < current_length; index++) {
...@@ -353,11 +353,7 @@ void ListInterpolationFunctions::Composite( ...@@ -353,11 +353,7 @@ void ListInterpolationFunctions::Composite(
if (underlying_length < final_length) { if (underlying_length < final_length) {
RepeatToLength(underlying_value, final_length); RepeatToLength(underlying_value, final_length);
} }
NonInterpolableList& underlying_non_interpolable_list = NonInterpolableList::AutoBuilder builder(underlying_value_owner);
ToNonInterpolableList(*underlying_value.non_interpolable_value);
NonInterpolableList::AutoBuilder builder(underlying_value_owner,
underlying_non_interpolable_list);
for (wtf_size_t i = 0; i < final_length; i++) { for (wtf_size_t i = 0; i < final_length; i++) {
UnderlyingItemValue underlying_item(underlying_value_owner, builder, i); UnderlyingItemValue underlying_item(underlying_value_owner, builder, i);
...@@ -376,11 +372,8 @@ void ListInterpolationFunctions::Composite( ...@@ -376,11 +372,8 @@ void ListInterpolationFunctions::Composite(
} }
InterpolableList& underlying_interpolable_list = InterpolableList& underlying_interpolable_list =
ToInterpolableList(*underlying_value.interpolable_value); ToInterpolableList(*underlying_value.interpolable_value);
NonInterpolableList& underlying_non_interpolable_list =
ToNonInterpolableList(*underlying_value.non_interpolable_value);
NonInterpolableList::AutoBuilder builder(underlying_value_owner, NonInterpolableList::AutoBuilder builder(underlying_value_owner);
underlying_non_interpolable_list);
for (wtf_size_t i = 0; i < value_length; i++) { for (wtf_size_t i = 0; i < value_length; i++) {
UnderlyingItemValue underlying_item(underlying_value_owner, builder, i); UnderlyingItemValue underlying_item(underlying_value_owner, builder, i);
...@@ -394,11 +387,8 @@ void ListInterpolationFunctions::Composite( ...@@ -394,11 +387,8 @@ void ListInterpolationFunctions::Composite(
} }
} }
NonInterpolableList::AutoBuilder::AutoBuilder( NonInterpolableList::AutoBuilder::AutoBuilder(UnderlyingValue& underlying_value)
UnderlyingValue& underlying_value, : underlying_value_(underlying_value) {
NonInterpolableList& underlying_non_interpolable_list)
: underlying_value_(underlying_value),
underlying_non_interpolable_list_(underlying_non_interpolable_list) {
DCHECK(underlying_value.GetNonInterpolableValue()); DCHECK(underlying_value.GetNonInterpolableValue());
DCHECK(IsNonInterpolableList(underlying_value_.GetNonInterpolableValue())); DCHECK(IsNonInterpolableList(underlying_value_.GetNonInterpolableValue()));
} }
...@@ -417,12 +407,14 @@ NonInterpolableList::AutoBuilder::~AutoBuilder() { ...@@ -417,12 +407,14 @@ NonInterpolableList::AutoBuilder::~AutoBuilder() {
void NonInterpolableList::AutoBuilder::Set( void NonInterpolableList::AutoBuilder::Set(
wtf_size_t index, wtf_size_t index,
scoped_refptr<NonInterpolableValue> non_interpolable_value) { scoped_refptr<const NonInterpolableValue> non_interpolable_value) {
// Copy list on first call to Set. // Copy list on first call to Set.
if (!list_.size()) { if (!list_.size()) {
wtf_size_t underlying_length = underlying_non_interpolable_list_.length(); const auto& non_interpolable_list =
ToNonInterpolableList(*underlying_value_.GetNonInterpolableValue());
wtf_size_t underlying_length = non_interpolable_list.length();
for (wtf_size_t i = 0; i < underlying_length; ++i) for (wtf_size_t i = 0; i < underlying_length; ++i)
list_.push_back(underlying_non_interpolable_list_.Get(i)); list_.push_back(non_interpolable_list.Get(i));
} }
DCHECK_LT(index, list_.size()); DCHECK_LT(index, list_.size());
......
...@@ -74,7 +74,7 @@ class CORE_EXPORT NonInterpolableList : public NonInterpolableValue { ...@@ -74,7 +74,7 @@ class CORE_EXPORT NonInterpolableList : public NonInterpolableValue {
return base::AdoptRef(new NonInterpolableList()); return base::AdoptRef(new NonInterpolableList());
} }
static scoped_refptr<NonInterpolableList> Create( static scoped_refptr<NonInterpolableList> Create(
Vector<scoped_refptr<NonInterpolableValue>>&& list) { Vector<scoped_refptr<const NonInterpolableValue>>&& list) {
return base::AdoptRef(new NonInterpolableList(std::move(list))); return base::AdoptRef(new NonInterpolableList(std::move(list)));
} }
...@@ -82,7 +82,6 @@ class CORE_EXPORT NonInterpolableList : public NonInterpolableValue { ...@@ -82,7 +82,6 @@ class CORE_EXPORT NonInterpolableList : public NonInterpolableValue {
const NonInterpolableValue* Get(wtf_size_t index) const { const NonInterpolableValue* Get(wtf_size_t index) const {
return list_[index].get(); return list_[index].get();
} }
NonInterpolableValue* Get(wtf_size_t index) { return list_[index].get(); }
// This class can update the NonInterpolableList of an UnderlyingValue with // This class can update the NonInterpolableList of an UnderlyingValue with
// a series of mutations. The actual update of the list is delayed until the // a series of mutations. The actual update of the list is delayed until the
...@@ -94,27 +93,24 @@ class CORE_EXPORT NonInterpolableList : public NonInterpolableValue { ...@@ -94,27 +93,24 @@ class CORE_EXPORT NonInterpolableList : public NonInterpolableValue {
public: public:
// The UnderlyingValue provided here is assumed to contain a // The UnderlyingValue provided here is assumed to contain a
// non-nullptr NonInterpolableList. // non-nullptr NonInterpolableList.
// AutoBuilder(UnderlyingValue&);
// TODO(andruud): Remove NonInterpolableList& param.
AutoBuilder(UnderlyingValue&, NonInterpolableList&);
~AutoBuilder(); ~AutoBuilder();
void Set(wtf_size_t index, scoped_refptr<NonInterpolableValue>); void Set(wtf_size_t index, scoped_refptr<const NonInterpolableValue>);
private: private:
UnderlyingValue& underlying_value_; UnderlyingValue& underlying_value_;
NonInterpolableList& underlying_non_interpolable_list_; Vector<scoped_refptr<const NonInterpolableValue>> list_;
Vector<scoped_refptr<NonInterpolableValue>> list_;
}; };
DECLARE_NON_INTERPOLABLE_VALUE_TYPE(); DECLARE_NON_INTERPOLABLE_VALUE_TYPE();
private: private:
NonInterpolableList() = default; NonInterpolableList() = default;
NonInterpolableList(Vector<scoped_refptr<NonInterpolableValue>>&& list) NonInterpolableList(Vector<scoped_refptr<const NonInterpolableValue>>&& list)
: list_(list) {} : list_(list) {}
Vector<scoped_refptr<NonInterpolableValue>> list_; Vector<scoped_refptr<const NonInterpolableValue>> list_;
}; };
DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(NonInterpolableList); DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(NonInterpolableList);
...@@ -126,7 +122,8 @@ InterpolationValue ListInterpolationFunctions::CreateList( ...@@ -126,7 +122,8 @@ InterpolationValue ListInterpolationFunctions::CreateList(
if (length == 0) if (length == 0)
return CreateEmptyList(); return CreateEmptyList();
auto interpolable_list = std::make_unique<InterpolableList>(length); auto interpolable_list = std::make_unique<InterpolableList>(length);
Vector<scoped_refptr<NonInterpolableValue>> non_interpolable_values(length); Vector<scoped_refptr<const NonInterpolableValue>> non_interpolable_values(
length);
for (wtf_size_t i = 0; i < length; i++) { for (wtf_size_t i = 0; i < length; i++) {
InterpolationValue item = create_item(i); InterpolationValue item = create_item(i);
if (!item) if (!item)
......
...@@ -60,7 +60,7 @@ class TestUnderlyingValue : public UnderlyingValue { ...@@ -60,7 +60,7 @@ class TestUnderlyingValue : public UnderlyingValue {
} }
void SetNonInterpolableValue( void SetNonInterpolableValue(
scoped_refptr<NonInterpolableValue> non_interpolable_value) final { scoped_refptr<const NonInterpolableValue> non_interpolable_value) final {
interpolation_value_.non_interpolable_value = non_interpolable_value; interpolation_value_.non_interpolable_value = non_interpolable_value;
} }
...@@ -254,7 +254,7 @@ TEST(ListInterpolationFunctionsTest, BuilderNoModify) { ...@@ -254,7 +254,7 @@ TEST(ListInterpolationFunctionsTest, BuilderNoModify) {
{ {
TestUnderlyingValue underlying_value(list); TestUnderlyingValue underlying_value(list);
NonInterpolableList::AutoBuilder builder(underlying_value, before); NonInterpolableList::AutoBuilder builder(underlying_value);
} }
auto& after = ToNonInterpolableList(*list.non_interpolable_value); auto& after = ToNonInterpolableList(*list.non_interpolable_value);
...@@ -272,7 +272,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyFirst) { ...@@ -272,7 +272,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyFirst) {
{ {
TestUnderlyingValue underlying_value(list); TestUnderlyingValue underlying_value(list);
NonInterpolableList::AutoBuilder builder(underlying_value, before); NonInterpolableList::AutoBuilder builder(underlying_value);
builder.Set(0, TestNonInterpolableValue::Create(4)); builder.Set(0, TestNonInterpolableValue::Create(4));
} }
...@@ -291,7 +291,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyMiddle) { ...@@ -291,7 +291,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyMiddle) {
{ {
TestUnderlyingValue underlying_value(list); TestUnderlyingValue underlying_value(list);
NonInterpolableList::AutoBuilder builder(underlying_value, before); NonInterpolableList::AutoBuilder builder(underlying_value);
builder.Set(1, TestNonInterpolableValue::Create(4)); builder.Set(1, TestNonInterpolableValue::Create(4));
} }
...@@ -310,7 +310,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyLast) { ...@@ -310,7 +310,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyLast) {
{ {
TestUnderlyingValue underlying_value(list); TestUnderlyingValue underlying_value(list);
NonInterpolableList::AutoBuilder builder(underlying_value, before); NonInterpolableList::AutoBuilder builder(underlying_value);
builder.Set(2, TestNonInterpolableValue::Create(4)); builder.Set(2, TestNonInterpolableValue::Create(4));
} }
...@@ -329,7 +329,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyAll) { ...@@ -329,7 +329,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyAll) {
{ {
TestUnderlyingValue underlying_value(list); TestUnderlyingValue underlying_value(list);
NonInterpolableList::AutoBuilder builder(underlying_value, before); NonInterpolableList::AutoBuilder builder(underlying_value);
builder.Set(0, TestNonInterpolableValue::Create(4)); builder.Set(0, TestNonInterpolableValue::Create(4));
builder.Set(1, TestNonInterpolableValue::Create(5)); builder.Set(1, TestNonInterpolableValue::Create(5));
builder.Set(2, TestNonInterpolableValue::Create(6)); builder.Set(2, TestNonInterpolableValue::Create(6));
...@@ -350,7 +350,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyReverse) { ...@@ -350,7 +350,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyReverse) {
{ {
TestUnderlyingValue underlying_value(list); TestUnderlyingValue underlying_value(list);
NonInterpolableList::AutoBuilder builder(underlying_value, before); NonInterpolableList::AutoBuilder builder(underlying_value);
builder.Set(3, TestNonInterpolableValue::Create(6)); builder.Set(3, TestNonInterpolableValue::Create(6));
builder.Set(1, TestNonInterpolableValue::Create(7)); builder.Set(1, TestNonInterpolableValue::Create(7));
} }
...@@ -372,7 +372,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyListWithOneItem) { ...@@ -372,7 +372,7 @@ TEST(ListInterpolationFunctionsTest, BuilderModifyListWithOneItem) {
{ {
TestUnderlyingValue underlying_value(list); TestUnderlyingValue underlying_value(list);
NonInterpolableList::AutoBuilder builder(underlying_value, before); NonInterpolableList::AutoBuilder builder(underlying_value);
builder.Set(0, TestNonInterpolableValue::Create(4)); builder.Set(0, TestNonInterpolableValue::Create(4));
} }
......
...@@ -20,7 +20,8 @@ struct PairwiseInterpolationValue { ...@@ -20,7 +20,8 @@ struct PairwiseInterpolationValue {
PairwiseInterpolationValue( PairwiseInterpolationValue(
std::unique_ptr<InterpolableValue> start_interpolable_value, std::unique_ptr<InterpolableValue> start_interpolable_value,
std::unique_ptr<InterpolableValue> end_interpolable_value, std::unique_ptr<InterpolableValue> end_interpolable_value,
scoped_refptr<NonInterpolableValue> non_interpolable_value = nullptr) scoped_refptr<const NonInterpolableValue> non_interpolable_value =
nullptr)
: start_interpolable_value(std::move(start_interpolable_value)), : start_interpolable_value(std::move(start_interpolable_value)),
end_interpolable_value(std::move(end_interpolable_value)), end_interpolable_value(std::move(end_interpolable_value)),
non_interpolable_value(std::move(non_interpolable_value)) {} non_interpolable_value(std::move(non_interpolable_value)) {}
...@@ -36,7 +37,7 @@ struct PairwiseInterpolationValue { ...@@ -36,7 +37,7 @@ struct PairwiseInterpolationValue {
std::unique_ptr<InterpolableValue> start_interpolable_value; std::unique_ptr<InterpolableValue> start_interpolable_value;
std::unique_ptr<InterpolableValue> end_interpolable_value; std::unique_ptr<InterpolableValue> end_interpolable_value;
scoped_refptr<NonInterpolableValue> non_interpolable_value; scoped_refptr<const NonInterpolableValue> non_interpolable_value;
}; };
} // namespace blink } // namespace blink
......
...@@ -48,7 +48,7 @@ class PairwisePrimitiveInterpolation : public PrimitiveInterpolation { ...@@ -48,7 +48,7 @@ class PairwisePrimitiveInterpolation : public PrimitiveInterpolation {
const InterpolationType& type, const InterpolationType& type,
std::unique_ptr<InterpolableValue> start, std::unique_ptr<InterpolableValue> start,
std::unique_ptr<InterpolableValue> end, std::unique_ptr<InterpolableValue> end,
scoped_refptr<NonInterpolableValue> non_interpolable_value) scoped_refptr<const NonInterpolableValue> non_interpolable_value)
: type_(type), : type_(type),
start_(std::move(start)), start_(std::move(start)),
end_(std::move(end)), end_(std::move(end)),
...@@ -86,7 +86,7 @@ class PairwisePrimitiveInterpolation : public PrimitiveInterpolation { ...@@ -86,7 +86,7 @@ class PairwisePrimitiveInterpolation : public PrimitiveInterpolation {
const InterpolationType& type_; const InterpolationType& type_;
std::unique_ptr<InterpolableValue> start_; std::unique_ptr<InterpolableValue> start_;
std::unique_ptr<InterpolableValue> end_; std::unique_ptr<InterpolableValue> end_;
scoped_refptr<NonInterpolableValue> non_interpolable_value_; scoped_refptr<const NonInterpolableValue> non_interpolable_value_;
}; };
// Represents a pair of incompatible keyframes that fall back to 50% flip // Represents a pair of incompatible keyframes that fall back to 50% flip
......
...@@ -19,7 +19,7 @@ class CSSSizeNonInterpolableValue : public NonInterpolableValue { ...@@ -19,7 +19,7 @@ class CSSSizeNonInterpolableValue : public NonInterpolableValue {
} }
static scoped_refptr<CSSSizeNonInterpolableValue> Create( static scoped_refptr<CSSSizeNonInterpolableValue> Create(
scoped_refptr<NonInterpolableValue> length_non_interpolable_value) { scoped_refptr<const NonInterpolableValue> length_non_interpolable_value) {
return base::AdoptRef(new CSSSizeNonInterpolableValue( return base::AdoptRef(new CSSSizeNonInterpolableValue(
std::move(length_non_interpolable_value))); std::move(length_non_interpolable_value)));
} }
...@@ -44,13 +44,13 @@ class CSSSizeNonInterpolableValue : public NonInterpolableValue { ...@@ -44,13 +44,13 @@ class CSSSizeNonInterpolableValue : public NonInterpolableValue {
} }
CSSSizeNonInterpolableValue( CSSSizeNonInterpolableValue(
scoped_refptr<NonInterpolableValue> length_non_interpolable_value) scoped_refptr<const NonInterpolableValue> length_non_interpolable_value)
: keyword_(CSSValueID::kInvalid), : keyword_(CSSValueID::kInvalid),
length_non_interpolable_value_( length_non_interpolable_value_(
std::move(length_non_interpolable_value)) {} std::move(length_non_interpolable_value)) {}
CSSValueID keyword_; CSSValueID keyword_;
scoped_refptr<NonInterpolableValue> length_non_interpolable_value_; scoped_refptr<const NonInterpolableValue> length_non_interpolable_value_;
}; };
DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSSizeNonInterpolableValue); DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSSizeNonInterpolableValue);
...@@ -58,12 +58,11 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSSizeNonInterpolableValue); ...@@ -58,12 +58,11 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSSizeNonInterpolableValue);
// A wrapper for the UnderlyingValue passed to // A wrapper for the UnderlyingValue passed to
// SizeInterpolationFunctions::Composite which can be forwarded to // SizeInterpolationFunctions::Composite which can be forwarded to
// LengthInterpolationFunctions::CompositeUnderlying. // LengthInterpolationFunctions::Composite.
// //
// If LengthInterpolationFunctions::CompositeUnderlying calls // If LengthInterpolationFunctions::Composite calls SetNonInterpolableValue with
// SetNonInterpolableValue with a new NonInterpolableValue, this class // a new NonInterpolableValue, this class wraps it in a new
// wraps it in a new CSSSizeNonInterpolableValue before being set on the inner // CSSSizeNonInterpolableValue before being set on the inner UnderlyingValue.
// UnderlyingValue.
class UnderlyingSizeAsLengthValue : public UnderlyingValue { class UnderlyingSizeAsLengthValue : public UnderlyingValue {
STACK_ALLOCATED(); STACK_ALLOCATED();
...@@ -82,7 +81,7 @@ class UnderlyingSizeAsLengthValue : public UnderlyingValue { ...@@ -82,7 +81,7 @@ class UnderlyingSizeAsLengthValue : public UnderlyingValue {
} }
void SetNonInterpolableValue( void SetNonInterpolableValue(
scoped_refptr<NonInterpolableValue> non_interpolable_value) final { scoped_refptr<const NonInterpolableValue> non_interpolable_value) final {
inner_underlying_value_.SetNonInterpolableValue( inner_underlying_value_.SetNonInterpolableValue(
CSSSizeNonInterpolableValue::Create(std::move(non_interpolable_value))); CSSSizeNonInterpolableValue::Create(std::move(non_interpolable_value)));
} }
...@@ -197,7 +196,7 @@ void SizeInterpolationFunctions::Composite( ...@@ -197,7 +196,7 @@ void SizeInterpolationFunctions::Composite(
if (size_non_interpolable_value.IsKeyword()) if (size_non_interpolable_value.IsKeyword())
return; return;
UnderlyingSizeAsLengthValue underlying_size_as_length(underlying_value); UnderlyingSizeAsLengthValue underlying_size_as_length(underlying_value);
LengthInterpolationFunctions::CompositeUnderlying( LengthInterpolationFunctions::Composite(
underlying_size_as_length, underlying_fraction, interpolable_value, underlying_size_as_length, underlying_fraction, interpolable_value,
size_non_interpolable_value.LengthNonInterpolableValue()); size_non_interpolable_value.LengthNonInterpolableValue());
} }
......
...@@ -34,8 +34,8 @@ const InterpolableValue& TransitionInterpolation::CurrentInterpolableValue() ...@@ -34,8 +34,8 @@ const InterpolableValue& TransitionInterpolation::CurrentInterpolableValue()
return *cached_interpolable_value_; return *cached_interpolable_value_;
} }
NonInterpolableValue* TransitionInterpolation::CurrentNonInterpolableValue() const NonInterpolableValue*
const { TransitionInterpolation::CurrentNonInterpolableValue() const {
if (cached_fraction_ == 0) { if (cached_fraction_ == 0) {
return start_.non_interpolable_value.get(); return start_.non_interpolable_value.get();
} }
......
...@@ -95,7 +95,7 @@ class CORE_EXPORT TransitionInterpolation : public Interpolation { ...@@ -95,7 +95,7 @@ class CORE_EXPORT TransitionInterpolation : public Interpolation {
private: private:
const InterpolableValue& CurrentInterpolableValue() const; const InterpolableValue& CurrentInterpolableValue() const;
NonInterpolableValue* CurrentNonInterpolableValue() const; const NonInterpolableValue* CurrentNonInterpolableValue() const;
const PropertyHandle property_; const PropertyHandle property_;
const InterpolationType& type_; const InterpolationType& type_;
......
...@@ -22,10 +22,10 @@ class TypedInterpolationValue { ...@@ -22,10 +22,10 @@ class TypedInterpolationValue {
USING_FAST_MALLOC(TypedInterpolationValue); USING_FAST_MALLOC(TypedInterpolationValue);
public: public:
TypedInterpolationValue( TypedInterpolationValue(const InterpolationType& type,
const InterpolationType& type, std::unique_ptr<InterpolableValue> interpolable_value,
std::unique_ptr<InterpolableValue> interpolable_value, scoped_refptr<const NonInterpolableValue>
scoped_refptr<NonInterpolableValue> non_interpolable_value = nullptr) non_interpolable_value = nullptr)
: type_(type), : type_(type),
value_(std::move(interpolable_value), value_(std::move(interpolable_value),
std::move(non_interpolable_value)) { std::move(non_interpolable_value)) {
......
...@@ -29,7 +29,8 @@ class CORE_EXPORT UnderlyingValue { ...@@ -29,7 +29,8 @@ class CORE_EXPORT UnderlyingValue {
// The NonInterpolableValue part of the underlying value may not be mutated, // The NonInterpolableValue part of the underlying value may not be mutated,
// hence there is no MutableNonInterpolableValue function. However, the // hence there is no MutableNonInterpolableValue function. However, the
// NonInterpolableValue part may be replaced entirely with this function. // NonInterpolableValue part may be replaced entirely with this function.
virtual void SetNonInterpolableValue(scoped_refptr<NonInterpolableValue>) = 0; virtual void SetNonInterpolableValue(
scoped_refptr<const NonInterpolableValue>) = 0;
}; };
} // namespace blink } // namespace blink
......
...@@ -24,7 +24,7 @@ const NonInterpolableValue* UnderlyingValueOwner::GetNonInterpolableValue() ...@@ -24,7 +24,7 @@ const NonInterpolableValue* UnderlyingValueOwner::GetNonInterpolableValue()
} }
void UnderlyingValueOwner::SetNonInterpolableValue( void UnderlyingValueOwner::SetNonInterpolableValue(
scoped_refptr<NonInterpolableValue> non_interpolable_value) { scoped_refptr<const NonInterpolableValue> non_interpolable_value) {
MutableValue().non_interpolable_value = non_interpolable_value; MutableValue().non_interpolable_value = non_interpolable_value;
} }
......
...@@ -34,7 +34,7 @@ class CORE_EXPORT UnderlyingValueOwner : public UnderlyingValue { ...@@ -34,7 +34,7 @@ class CORE_EXPORT UnderlyingValueOwner : public UnderlyingValue {
// UnderlyingValue // UnderlyingValue
InterpolableValue& MutableInterpolableValue() final; InterpolableValue& MutableInterpolableValue() final;
const NonInterpolableValue* GetNonInterpolableValue() const final; const NonInterpolableValue* GetNonInterpolableValue() const final;
void SetNonInterpolableValue(scoped_refptr<NonInterpolableValue>) final; void SetNonInterpolableValue(scoped_refptr<const NonInterpolableValue>) final;
const InterpolationType& GetType() const { const InterpolationType& GetType() const {
DCHECK(type_); DCHECK(type_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment