Commit a8ddef71 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Use scoped_refptr<const Type> in a few CSS*InterpolationTypes

These instances of StylePath/BasicShape/ShadowList are supposed to be
immutable, so add const qualifications and drop some then unnecessary
const_cast<>s.

Change-Id: I1a6ca8ec9c45dac757a45882129f91f745745023
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2460894Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#815210}
parent a12b550d
...@@ -68,7 +68,7 @@ class InheritedShapeChecker ...@@ -68,7 +68,7 @@ class InheritedShapeChecker
: public CSSInterpolationType::CSSConversionChecker { : public CSSInterpolationType::CSSConversionChecker {
public: public:
InheritedShapeChecker(const CSSProperty& property, InheritedShapeChecker(const CSSProperty& property,
scoped_refptr<BasicShape> inherited_shape) scoped_refptr<const BasicShape> inherited_shape)
: property_(property), inherited_shape_(std::move(inherited_shape)) {} : property_(property), inherited_shape_(std::move(inherited_shape)) {}
private: private:
...@@ -79,7 +79,7 @@ class InheritedShapeChecker ...@@ -79,7 +79,7 @@ class InheritedShapeChecker
} }
const CSSProperty& property_; const CSSProperty& property_;
scoped_refptr<BasicShape> inherited_shape_; scoped_refptr<const BasicShape> inherited_shape_;
}; };
} // namespace } // namespace
...@@ -110,9 +110,8 @@ InterpolationValue CSSBasicShapeInterpolationType::MaybeConvertInherit( ...@@ -110,9 +110,8 @@ InterpolationValue CSSBasicShapeInterpolationType::MaybeConvertInherit(
const StyleResolverState& state, const StyleResolverState& state,
ConversionCheckers& conversion_checkers) const { ConversionCheckers& conversion_checkers) const {
const BasicShape* shape = GetBasicShape(CssProperty(), *state.ParentStyle()); const BasicShape* shape = GetBasicShape(CssProperty(), *state.ParentStyle());
// const_cast to take a ref. conversion_checkers.push_back(
conversion_checkers.push_back(std::make_unique<InheritedShapeChecker>( std::make_unique<InheritedShapeChecker>(CssProperty(), shape));
CssProperty(), const_cast<BasicShape*>(shape)));
return basic_shape_interpolation_functions::MaybeConvertBasicShape( return basic_shape_interpolation_functions::MaybeConvertBasicShape(
shape, state.ParentStyle()->EffectiveZoom()); shape, state.ParentStyle()->EffectiveZoom());
} }
......
...@@ -19,7 +19,8 @@ namespace { ...@@ -19,7 +19,8 @@ namespace {
// Returns the property's path() value. // Returns the property's path() value.
// If the property's value is not a path(), returns nullptr. // If the property's value is not a path(), returns nullptr.
StylePath* GetPath(const CSSProperty& property, const ComputedStyle& style) { const StylePath* GetPath(const CSSProperty& property,
const ComputedStyle& style) {
switch (property.PropertyID()) { switch (property.PropertyID()) {
case CSSPropertyID::kD: case CSSPropertyID::kD:
return style.SvgStyle().D(); return style.SvgStyle().D();
...@@ -95,7 +96,7 @@ InterpolationValue CSSPathInterpolationType::MaybeConvertInitial( ...@@ -95,7 +96,7 @@ InterpolationValue CSSPathInterpolationType::MaybeConvertInitial(
class InheritedPathChecker : public CSSInterpolationType::CSSConversionChecker { class InheritedPathChecker : public CSSInterpolationType::CSSConversionChecker {
public: public:
InheritedPathChecker(const CSSProperty& property, InheritedPathChecker(const CSSProperty& property,
scoped_refptr<StylePath> style_path) scoped_refptr<const StylePath> style_path)
: property_(property), style_path_(std::move(style_path)) {} : property_(property), style_path_(std::move(style_path)) {}
private: private:
...@@ -105,7 +106,7 @@ class InheritedPathChecker : public CSSInterpolationType::CSSConversionChecker { ...@@ -105,7 +106,7 @@ class InheritedPathChecker : public CSSInterpolationType::CSSConversionChecker {
} }
const CSSProperty& property_; const CSSProperty& property_;
const scoped_refptr<StylePath> style_path_; const scoped_refptr<const StylePath> style_path_;
}; };
InterpolationValue CSSPathInterpolationType::MaybeConvertInherit( InterpolationValue CSSPathInterpolationType::MaybeConvertInherit(
......
...@@ -69,7 +69,7 @@ class InheritedShadowListChecker ...@@ -69,7 +69,7 @@ class InheritedShadowListChecker
: public CSSInterpolationType::CSSConversionChecker { : public CSSInterpolationType::CSSConversionChecker {
public: public:
InheritedShadowListChecker(const CSSProperty& property, InheritedShadowListChecker(const CSSProperty& property,
scoped_refptr<ShadowList> shadow_list) scoped_refptr<const ShadowList> shadow_list)
: property_(property), shadow_list_(std::move(shadow_list)) {} : property_(property), shadow_list_(std::move(shadow_list)) {}
private: private:
...@@ -85,7 +85,7 @@ class InheritedShadowListChecker ...@@ -85,7 +85,7 @@ class InheritedShadowListChecker
} }
const CSSProperty& property_; const CSSProperty& property_;
scoped_refptr<ShadowList> shadow_list_; scoped_refptr<const ShadowList> shadow_list_;
}; };
InterpolationValue CSSShadowListInterpolationType::MaybeConvertInherit( InterpolationValue CSSShadowListInterpolationType::MaybeConvertInherit(
...@@ -96,8 +96,7 @@ InterpolationValue CSSShadowListInterpolationType::MaybeConvertInherit( ...@@ -96,8 +96,7 @@ InterpolationValue CSSShadowListInterpolationType::MaybeConvertInherit(
const ShadowList* inherited_shadow_list = const ShadowList* inherited_shadow_list =
GetShadowList(CssProperty(), *state.ParentStyle()); GetShadowList(CssProperty(), *state.ParentStyle());
conversion_checkers.push_back(std::make_unique<InheritedShadowListChecker>( conversion_checkers.push_back(std::make_unique<InheritedShadowListChecker>(
CssProperty(), CssProperty(), inherited_shadow_list)); // Take ref.
const_cast<ShadowList*>(inherited_shadow_list))); // Take ref.
return ConvertShadowList(inherited_shadow_list, return ConvertShadowList(inherited_shadow_list,
state.ParentStyle()->EffectiveZoom()); state.ParentStyle()->EffectiveZoom());
} }
......
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