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
: public CSSInterpolationType::CSSConversionChecker {
public:
InheritedShapeChecker(const CSSProperty& property,
scoped_refptr<BasicShape> inherited_shape)
scoped_refptr<const BasicShape> inherited_shape)
: property_(property), inherited_shape_(std::move(inherited_shape)) {}
private:
......@@ -79,7 +79,7 @@ class InheritedShapeChecker
}
const CSSProperty& property_;
scoped_refptr<BasicShape> inherited_shape_;
scoped_refptr<const BasicShape> inherited_shape_;
};
} // namespace
......@@ -110,9 +110,8 @@ InterpolationValue CSSBasicShapeInterpolationType::MaybeConvertInherit(
const StyleResolverState& state,
ConversionCheckers& conversion_checkers) const {
const BasicShape* shape = GetBasicShape(CssProperty(), *state.ParentStyle());
// const_cast to take a ref.
conversion_checkers.push_back(std::make_unique<InheritedShapeChecker>(
CssProperty(), const_cast<BasicShape*>(shape)));
conversion_checkers.push_back(
std::make_unique<InheritedShapeChecker>(CssProperty(), shape));
return basic_shape_interpolation_functions::MaybeConvertBasicShape(
shape, state.ParentStyle()->EffectiveZoom());
}
......
......@@ -19,7 +19,8 @@ namespace {
// Returns the property's path() value.
// 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()) {
case CSSPropertyID::kD:
return style.SvgStyle().D();
......@@ -95,7 +96,7 @@ InterpolationValue CSSPathInterpolationType::MaybeConvertInitial(
class InheritedPathChecker : public CSSInterpolationType::CSSConversionChecker {
public:
InheritedPathChecker(const CSSProperty& property,
scoped_refptr<StylePath> style_path)
scoped_refptr<const StylePath> style_path)
: property_(property), style_path_(std::move(style_path)) {}
private:
......@@ -105,7 +106,7 @@ class InheritedPathChecker : public CSSInterpolationType::CSSConversionChecker {
}
const CSSProperty& property_;
const scoped_refptr<StylePath> style_path_;
const scoped_refptr<const StylePath> style_path_;
};
InterpolationValue CSSPathInterpolationType::MaybeConvertInherit(
......
......@@ -69,7 +69,7 @@ class InheritedShadowListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
InheritedShadowListChecker(const CSSProperty& property,
scoped_refptr<ShadowList> shadow_list)
scoped_refptr<const ShadowList> shadow_list)
: property_(property), shadow_list_(std::move(shadow_list)) {}
private:
......@@ -85,7 +85,7 @@ class InheritedShadowListChecker
}
const CSSProperty& property_;
scoped_refptr<ShadowList> shadow_list_;
scoped_refptr<const ShadowList> shadow_list_;
};
InterpolationValue CSSShadowListInterpolationType::MaybeConvertInherit(
......@@ -96,8 +96,7 @@ InterpolationValue CSSShadowListInterpolationType::MaybeConvertInherit(
const ShadowList* inherited_shadow_list =
GetShadowList(CssProperty(), *state.ParentStyle());
conversion_checkers.push_back(std::make_unique<InheritedShadowListChecker>(
CssProperty(),
const_cast<ShadowList*>(inherited_shadow_list))); // Take ref.
CssProperty(), inherited_shadow_list)); // Take ref.
return ConvertShadowList(inherited_shadow_list,
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