Commit feb42804 authored by alancutter's avatar alancutter Committed by Commit bot

Add CSSInterpolationType specific ConversionChecker

This change refactors the CSS ConversionCheckers to inherit from a common
CSSConversionChecker class that removes some of the boiler plate code in
using the InterpolationEnvironment.

This patch introduces no changes in behaviour.

BUG=671904

Review-Url: https://codereview.chromium.org/2812213002
Cr-Commit-Position: refs/heads/master@{#474948}
parent da11b4dc
......@@ -18,7 +18,7 @@ namespace blink {
namespace {
class UnderlyingCompatibilityChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<UnderlyingCompatibilityChecker> Create(
PassRefPtr<NonInterpolableValue> underlying_non_interpolable_value) {
......@@ -32,7 +32,7 @@ class UnderlyingCompatibilityChecker
: underlying_non_interpolable_value_(
std::move(underlying_non_interpolable_value)) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
return BasicShapeInterpolationFunctions::ShapesAreCompatible(
*underlying_non_interpolable_value_,
......@@ -42,7 +42,8 @@ class UnderlyingCompatibilityChecker
RefPtr<NonInterpolableValue> underlying_non_interpolable_value_;
};
class InheritedShapeChecker : public InterpolationType::ConversionChecker {
class InheritedShapeChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedShapeChecker> Create(
CSSPropertyID property,
......@@ -56,12 +57,11 @@ class InheritedShapeChecker : public InterpolationType::ConversionChecker {
PassRefPtr<BasicShape> inherited_shape)
: property_(property), inherited_shape_(std::move(inherited_shape)) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return DataEquivalent(
inherited_shape_.Get(),
BasicShapePropertyFunctions::GetBasicShape(
property_, *environment.GetState().ParentStyle()));
return DataEquivalent(inherited_shape_.Get(),
BasicShapePropertyFunctions::GetBasicShape(
property_, *state.ParentStyle()));
}
const CSSPropertyID property_;
......
......@@ -119,7 +119,8 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(
namespace {
class UnderlyingSideTypesChecker : public InterpolationType::ConversionChecker {
class UnderlyingSideTypesChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<UnderlyingSideTypesChecker> Create(
const SideTypes& underlying_side_types) {
......@@ -138,7 +139,7 @@ class UnderlyingSideTypesChecker : public InterpolationType::ConversionChecker {
UnderlyingSideTypesChecker(const SideTypes& underlying_side_types)
: underlying_side_types_(underlying_side_types) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
return underlying_side_types_ == GetUnderlyingSideTypes(underlying);
}
......@@ -146,7 +147,8 @@ class UnderlyingSideTypesChecker : public InterpolationType::ConversionChecker {
const SideTypes underlying_side_types_;
};
class InheritedSideTypesChecker : public InterpolationType::ConversionChecker {
class InheritedSideTypesChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedSideTypesChecker> Create(
CSSPropertyID property,
......@@ -160,12 +162,12 @@ class InheritedSideTypesChecker : public InterpolationType::ConversionChecker {
const SideTypes& inherited_side_types)
: property_(property), inherited_side_types_(inherited_side_types) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return inherited_side_types_ ==
SideTypes(
BorderImageLengthBoxPropertyFunctions::GetBorderImageLengthBox(
property_, *environment.GetState().ParentStyle()));
property_, *state.ParentStyle()));
}
const CSSPropertyID property_;
......
......@@ -58,7 +58,8 @@ static ClipAutos GetClipAutos(const ComputedStyle& style) {
style.ClipBottom().IsAuto(), style.ClipLeft().IsAuto());
}
class InheritedAutosChecker : public InterpolationType::ConversionChecker {
class InheritedAutosChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedAutosChecker> Create(
const ClipAutos& inherited_autos) {
......@@ -69,10 +70,9 @@ class InheritedAutosChecker : public InterpolationType::ConversionChecker {
InheritedAutosChecker(const ClipAutos& inherited_autos)
: inherited_autos_(inherited_autos) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return inherited_autos_ ==
GetClipAutos(*environment.GetState().ParentStyle());
return inherited_autos_ == GetClipAutos(*state.ParentStyle());
}
const ClipAutos inherited_autos_;
......@@ -103,7 +103,8 @@ class CSSClipNonInterpolableValue : public NonInterpolableValue {
DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSClipNonInterpolableValue);
DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSClipNonInterpolableValue);
class UnderlyingAutosChecker : public InterpolationType::ConversionChecker {
class UnderlyingAutosChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~UnderlyingAutosChecker() final {}
......@@ -123,7 +124,7 @@ class UnderlyingAutosChecker : public InterpolationType::ConversionChecker {
UnderlyingAutosChecker(const ClipAutos& underlying_autos)
: underlying_autos_(underlying_autos) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
return underlying_autos_ == GetUnderlyingAutos(underlying);
}
......
......@@ -158,7 +158,8 @@ Color CSSColorInterpolationType::ResolveInterpolableColor(
round(alpha));
}
class InheritedColorChecker : public InterpolationType::ConversionChecker {
class InheritedColorChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedColorChecker> Create(
CSSPropertyID property,
......@@ -170,10 +171,10 @@ class InheritedColorChecker : public InterpolationType::ConversionChecker {
InheritedColorChecker(CSSPropertyID property, const OptionalStyleColor& color)
: property_(property), color_(color) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return color_ == ColorPropertyFunctions::GetUnvisitedColor(
property_, *environment.GetState().ParentStyle());
property_, *state.ParentStyle());
}
const CSSPropertyID property_;
......
......@@ -18,7 +18,7 @@ namespace blink {
namespace {
class UnderlyingFilterListChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<UnderlyingFilterListChecker> Create(
PassRefPtr<NonInterpolableList> non_interpolable_list) {
......@@ -26,7 +26,7 @@ class UnderlyingFilterListChecker
new UnderlyingFilterListChecker(std::move(non_interpolable_list)));
}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
const NonInterpolableList& underlying_non_interpolable_list =
ToNonInterpolableList(*underlying.non_interpolable_value);
......@@ -50,7 +50,8 @@ class UnderlyingFilterListChecker
RefPtr<NonInterpolableList> non_interpolable_list_;
};
class InheritedFilterListChecker : public InterpolationType::ConversionChecker {
class InheritedFilterListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedFilterListChecker> Create(
CSSPropertyID property,
......@@ -59,13 +60,12 @@ class InheritedFilterListChecker : public InterpolationType::ConversionChecker {
new InheritedFilterListChecker(property, filter_operations));
}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
const FilterOperations& filter_operations =
filter_operations_wrapper_->Operations();
return filter_operations ==
FilterListPropertyFunctions::GetFilterList(
property_, *environment.GetState().ParentStyle());
return filter_operations == FilterListPropertyFunctions::GetFilterList(
property_, *state.ParentStyle());
}
private:
......
......@@ -16,7 +16,7 @@ namespace blink {
namespace {
class IsMonospaceChecker : public InterpolationType::ConversionChecker {
class IsMonospaceChecker : public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<IsMonospaceChecker> Create(bool is_monospace) {
return WTF::WrapUnique(new IsMonospaceChecker(is_monospace));
......@@ -25,16 +25,16 @@ class IsMonospaceChecker : public InterpolationType::ConversionChecker {
private:
IsMonospaceChecker(bool is_monospace) : is_monospace_(is_monospace) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return is_monospace_ ==
environment.GetState().Style()->GetFontDescription().IsMonospace();
return is_monospace_ == state.Style()->GetFontDescription().IsMonospace();
}
const bool is_monospace_;
};
class InheritedFontSizeChecker : public InterpolationType::ConversionChecker {
class InheritedFontSizeChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedFontSizeChecker> Create(
const FontDescription::Size& inherited_font_size) {
......@@ -45,10 +45,10 @@ class InheritedFontSizeChecker : public InterpolationType::ConversionChecker {
InheritedFontSizeChecker(const FontDescription::Size& inherited_font_size)
: inherited_font_size_(inherited_font_size.value) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return inherited_font_size_ ==
environment.GetState().ParentFontDescription().GetSize().value;
state.ParentFontDescription().GetSize().value;
}
const float inherited_font_size_;
......
......@@ -70,7 +70,7 @@ class UnderlyingTagsChecker : public InterpolationType::ConversionChecker {
};
class InheritedFontVariationSettingsChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
~InheritedFontVariationSettingsChecker() final {}
......@@ -83,12 +83,11 @@ class InheritedFontVariationSettingsChecker
InheritedFontVariationSettingsChecker(const FontVariationSettings* settings)
: settings_(settings) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return DataEquivalent(settings_.Get(), environment.GetState()
.ParentStyle()
->GetFontDescription()
.VariationSettings());
return DataEquivalent(
settings_.Get(),
state.ParentStyle()->GetFontDescription().VariationSettings());
}
RefPtr<const FontVariationSettings> settings_;
......
......@@ -12,7 +12,8 @@
namespace blink {
class InheritedFontWeightChecker : public InterpolationType::ConversionChecker {
class InheritedFontWeightChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedFontWeightChecker> Create(
FontWeight font_weight) {
......@@ -23,10 +24,9 @@ class InheritedFontWeightChecker : public InterpolationType::ConversionChecker {
InheritedFontWeightChecker(FontWeight font_weight)
: font_weight_(font_weight) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return font_weight_ ==
environment.GetState().ParentStyle()->GetFontWeight();
return font_weight_ == state.ParentStyle()->GetFontWeight();
}
const double font_weight_;
......
......@@ -129,7 +129,8 @@ bool CSSImageInterpolationType::EqualNonInterpolableValues(
ToCSSImageNonInterpolableValue(*b));
}
class UnderlyingImageChecker : public InterpolationType::ConversionChecker {
class UnderlyingImageChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~UnderlyingImageChecker() final {}
......@@ -142,7 +143,7 @@ class UnderlyingImageChecker : public InterpolationType::ConversionChecker {
UnderlyingImageChecker(const InterpolationValue& underlying)
: underlying_(underlying.Clone()) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
if (!underlying && !underlying_)
return true;
......@@ -172,7 +173,8 @@ InterpolationValue CSSImageInterpolationType::MaybeConvertInitial(
ImagePropertyFunctions::GetInitialStyleImage(CssProperty()), true);
}
class InheritedImageChecker : public InterpolationType::ConversionChecker {
class InheritedImageChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~InheritedImageChecker() final {}
......@@ -187,10 +189,10 @@ class InheritedImageChecker : public InterpolationType::ConversionChecker {
InheritedImageChecker(CSSPropertyID property, StyleImage* inherited_image)
: property_(property), inherited_image_(inherited_image) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
const StyleImage* inherited_image = ImagePropertyFunctions::GetStyleImage(
property_, *environment.GetState().ParentStyle());
const StyleImage* inherited_image =
ImagePropertyFunctions::GetStyleImage(property_, *state.ParentStyle());
if (!inherited_image_ && !inherited_image)
return true;
if (!inherited_image_ || !inherited_image)
......
......@@ -15,7 +15,8 @@
namespace blink {
class UnderlyingImageListChecker : public InterpolationType::ConversionChecker {
class UnderlyingImageListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~UnderlyingImageListChecker() final {}
......@@ -28,7 +29,7 @@ class UnderlyingImageListChecker : public InterpolationType::ConversionChecker {
UnderlyingImageListChecker(const InterpolationValue& underlying)
: underlying_(underlying.Clone()) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
return ListInterpolationFunctions::EqualValues(
underlying_, underlying,
......@@ -66,7 +67,8 @@ InterpolationValue CSSImageListInterpolationType::MaybeConvertStyleImageList(
});
}
class InheritedImageListChecker : public InterpolationType::ConversionChecker {
class InheritedImageListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~InheritedImageListChecker() final {}
......@@ -82,11 +84,11 @@ class InheritedImageListChecker : public InterpolationType::ConversionChecker {
const StyleImageList& inherited_image_list)
: property_(property), inherited_image_list_(inherited_image_list) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
StyleImageList inherited_image_list;
ImageListPropertyFunctions::GetImageList(
property_, *environment.GetState().ParentStyle(), inherited_image_list);
ImageListPropertyFunctions::GetImageList(property_, *state.ParentStyle(),
inherited_image_list);
return inherited_image_list_ == inherited_image_list;
}
......
......@@ -78,7 +78,7 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSImageSliceNonInterpolableValue);
namespace {
class UnderlyingSliceTypesChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<UnderlyingSliceTypesChecker> Create(
const SliceTypes& underlying_types) {
......@@ -96,7 +96,7 @@ class UnderlyingSliceTypesChecker
UnderlyingSliceTypesChecker(const SliceTypes& underlying_types)
: underlying_types_(underlying_types) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
return underlying_types_ == GetUnderlyingSliceTypes(underlying);
}
......@@ -104,7 +104,8 @@ class UnderlyingSliceTypesChecker
const SliceTypes underlying_types_;
};
class InheritedSliceTypesChecker : public InterpolationType::ConversionChecker {
class InheritedSliceTypesChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedSliceTypesChecker> Create(
CSSPropertyID property,
......@@ -118,11 +119,11 @@ class InheritedSliceTypesChecker : public InterpolationType::ConversionChecker {
const SliceTypes& inherited_types)
: property_(property), inherited_types_(inherited_types) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return inherited_types_ ==
SliceTypes(ImageSlicePropertyFunctions::GetImageSlice(
property_, *environment.GetState().ParentStyle()));
property_, *state.ParentStyle()));
}
const CSSPropertyID property_;
......
......@@ -22,7 +22,8 @@
namespace blink {
class ResolvedVariableChecker : public InterpolationType::ConversionChecker {
class ResolvedVariableChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<ResolvedVariableChecker> Create(
CSSPropertyID property,
......@@ -40,15 +41,14 @@ class ResolvedVariableChecker : public InterpolationType::ConversionChecker {
variable_reference_(variable_reference),
resolved_value_(resolved_value) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
// TODO(alancutter): Just check the variables referenced instead of doing a
// full CSSValue resolve.
bool omit_animation_tainted = false;
const CSSValue* resolved_value =
CSSVariableResolver::ResolveVariableReferences(
environment.GetState(), property_, *variable_reference_,
omit_animation_tainted);
state, property_, *variable_reference_, omit_animation_tainted);
return DataEquivalent(resolved_value_.Get(), resolved_value);
}
......@@ -58,7 +58,7 @@ class ResolvedVariableChecker : public InterpolationType::ConversionChecker {
};
class InheritedCustomPropertyChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedCustomPropertyChecker> Create(
const AtomicString& property,
......@@ -79,11 +79,11 @@ class InheritedCustomPropertyChecker
inherited_value_(inherited_value),
initial_value_(initial_value) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
const CSSValue* inherited_value =
environment.GetState().ParentStyle()->GetRegisteredVariable(
name_, is_inherited_property_);
state.ParentStyle()->GetRegisteredVariable(name_,
is_inherited_property_);
if (!inherited_value) {
inherited_value = initial_value_.Get();
}
......
......@@ -17,6 +17,18 @@ class CSSInterpolationType : public InterpolationType {
public:
void SetCustomPropertyRegistration(const PropertyRegistration&);
class CSSConversionChecker : public ConversionChecker {
public:
bool IsValid(const InterpolationEnvironment& environment,
const InterpolationValue& underlying) const final {
return IsValid(environment.GetState(), underlying);
}
protected:
virtual bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const = 0;
};
protected:
CSSInterpolationType(PropertyHandle);
......
......@@ -28,7 +28,8 @@ float CSSLengthInterpolationType::EffectiveZoom(
: 1;
}
class InheritedLengthChecker : public InterpolationType::ConversionChecker {
class InheritedLengthChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedLengthChecker> Create(CSSPropertyID property,
const Length& length) {
......@@ -39,11 +40,11 @@ class InheritedLengthChecker : public InterpolationType::ConversionChecker {
InheritedLengthChecker(CSSPropertyID property, const Length& length)
: property_(property), length_(length) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
Length parent_length;
if (!LengthPropertyFunctions::GetLength(
property_, *environment.GetState().ParentStyle(), parent_length))
if (!LengthPropertyFunctions::GetLength(property_, *state.ParentStyle(),
parent_length))
return false;
return parent_length == length_;
}
......
......@@ -61,7 +61,8 @@ InterpolationValue CSSLengthListInterpolationType::MaybeConvertInitial(
return MaybeConvertLengthList(initial_length_list, 1);
}
class InheritedLengthListChecker : public InterpolationType::ConversionChecker {
class InheritedLengthListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~InheritedLengthListChecker() final {}
......@@ -77,12 +78,11 @@ class InheritedLengthListChecker : public InterpolationType::ConversionChecker {
const Vector<Length>& inherited_length_list)
: property_(property), inherited_length_list_(inherited_length_list) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
Vector<Length> inherited_length_list;
LengthListPropertyFunctions::GetLengthList(
property_, *environment.GetState().ParentStyle(),
inherited_length_list);
LengthListPropertyFunctions::GetLengthList(property_, *state.ParentStyle(),
inherited_length_list);
return inherited_length_list_ == inherited_length_list;
}
......
......@@ -12,7 +12,8 @@
namespace blink {
class InheritedNumberChecker : public InterpolationType::ConversionChecker {
class InheritedNumberChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedNumberChecker> Create(CSSPropertyID property,
double number) {
......@@ -23,11 +24,11 @@ class InheritedNumberChecker : public InterpolationType::ConversionChecker {
InheritedNumberChecker(CSSPropertyID property, double number)
: property_(property), number_(number) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
double parent_number;
if (!NumberPropertyFunctions::GetNumber(
property_, *environment.GetState().ParentStyle(), parent_number))
if (!NumberPropertyFunctions::GetNumber(property_, *state.ParentStyle(),
parent_number))
return false;
return parent_number == number_;
}
......
......@@ -37,7 +37,7 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSOffsetRotationNonInterpolableValue);
namespace {
class UnderlyingRotationTypeChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<UnderlyingRotationTypeChecker> Create(
OffsetRotationType underlying_rotation_type) {
......@@ -45,7 +45,7 @@ class UnderlyingRotationTypeChecker
new UnderlyingRotationTypeChecker(underlying_rotation_type));
}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
return underlying_rotation_type_ == ToCSSOffsetRotationNonInterpolableValue(
*underlying.non_interpolable_value)
......@@ -60,7 +60,7 @@ class UnderlyingRotationTypeChecker
};
class InheritedRotationTypeChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedRotationTypeChecker> Create(
OffsetRotationType inherited_rotation_type) {
......@@ -68,10 +68,9 @@ class InheritedRotationTypeChecker
new InheritedRotationTypeChecker(inherited_rotation_type));
}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return inherited_rotation_type_ ==
environment.GetState().ParentStyle()->OffsetRotate().type;
return inherited_rotation_type_ == state.ParentStyle()->OffsetRotate().type;
}
private:
......
......@@ -29,7 +29,8 @@ InterpolationValue CSSPaintInterpolationType::MaybeConvertInitial(
CSSColorInterpolationType::CreateInterpolableColor(initial_color));
}
class InheritedPaintChecker : public InterpolationType::ConversionChecker {
class InheritedPaintChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedPaintChecker> Create(
CSSPropertyID property,
......@@ -46,11 +47,11 @@ class InheritedPaintChecker : public InterpolationType::ConversionChecker {
InheritedPaintChecker(CSSPropertyID property, const StyleColor& color)
: property_(property), valid_color_(true), color_(color) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
StyleColor parent_color;
if (!PaintPropertyFunctions::GetColor(
property_, *environment.GetState().ParentStyle(), parent_color))
if (!PaintPropertyFunctions::GetColor(property_, *state.ParentStyle(),
parent_color))
return !valid_color_;
return valid_color_ && parent_color == color_;
}
......
......@@ -50,7 +50,7 @@ InterpolationValue CSSPathInterpolationType::MaybeConvertInitial(
return PathInterpolationFunctions::ConvertValue(nullptr);
}
class InheritedPathChecker : public InterpolationType::ConversionChecker {
class InheritedPathChecker : public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedPathChecker> Create(
PassRefPtr<StylePath> style_path) {
......@@ -61,10 +61,9 @@ class InheritedPathChecker : public InterpolationType::ConversionChecker {
InheritedPathChecker(PassRefPtr<StylePath> style_path)
: style_path_(std::move(style_path)) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return environment.GetState().ParentStyle()->SvgStyle().D() ==
style_path_.Get();
return state.ParentStyle()->SvgStyle().D() == style_path_.Get();
}
const RefPtr<StylePath> style_path_;
......
......@@ -150,17 +150,17 @@ InterpolationValue ConvertRotation(const OptionalRotation& rotation) {
CSSRotateNonInterpolableValue::Create(rotation));
}
class InheritedRotationChecker : public InterpolationType::ConversionChecker {
class InheritedRotationChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedRotationChecker> Create(
const OptionalRotation& inherited_rotation) {
return WTF::WrapUnique(new InheritedRotationChecker(inherited_rotation));
}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
OptionalRotation inherited_rotation =
GetRotation(*environment.GetState().ParentStyle());
OptionalRotation inherited_rotation = GetRotation(*state.ParentStyle());
if (inherited_rotation_.IsNone() || inherited_rotation.IsNone())
return inherited_rotation.IsNone() == inherited_rotation.IsNone();
return inherited_rotation_.GetRotation().axis ==
......
......@@ -62,7 +62,8 @@ std::unique_ptr<InterpolableValue> CreateScaleIdentity() {
return std::move(list);
}
class InheritedScaleChecker : public InterpolationType::ConversionChecker {
class InheritedScaleChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedScaleChecker> Create(const Scale& scale) {
return WTF::WrapUnique(new InheritedScaleChecker(scale));
......@@ -71,9 +72,9 @@ class InheritedScaleChecker : public InterpolationType::ConversionChecker {
private:
InheritedScaleChecker(const Scale& scale) : scale_(scale) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return scale_ == Scale(environment.GetState().ParentStyle()->Scale());
return scale_ == Scale(state.ParentStyle()->Scale());
}
const Scale scale_;
......
......@@ -47,7 +47,8 @@ InterpolationValue CSSShadowListInterpolationType::MaybeConvertInitial(
ShadowListPropertyFunctions::GetInitialShadowList(CssProperty()), 1);
}
class InheritedShadowListChecker : public InterpolationType::ConversionChecker {
class InheritedShadowListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedShadowListChecker> Create(
CSSPropertyID property,
......@@ -61,11 +62,11 @@ class InheritedShadowListChecker : public InterpolationType::ConversionChecker {
PassRefPtr<ShadowList> shadow_list)
: property_(property), shadow_list_(std::move(shadow_list)) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
const ShadowList* inherited_shadow_list =
ShadowListPropertyFunctions::GetShadowList(
property_, *environment.GetState().ParentStyle());
ShadowListPropertyFunctions::GetShadowList(property_,
*state.ParentStyle());
if (!inherited_shadow_list && !shadow_list_)
return true;
if (!inherited_shadow_list || !shadow_list_)
......
......@@ -12,7 +12,8 @@
namespace blink {
class UnderlyingSizeListChecker : public InterpolationType::ConversionChecker {
class UnderlyingSizeListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~UnderlyingSizeListChecker() final {}
......@@ -25,7 +26,7 @@ class UnderlyingSizeListChecker : public InterpolationType::ConversionChecker {
UnderlyingSizeListChecker(const NonInterpolableList& underlying_list)
: underlying_list_(&underlying_list) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
const auto& underlying_list =
ToNonInterpolableList(*underlying.non_interpolable_value);
......@@ -45,7 +46,8 @@ class UnderlyingSizeListChecker : public InterpolationType::ConversionChecker {
RefPtr<const NonInterpolableList> underlying_list_;
};
class InheritedSizeListChecker : public InterpolationType::ConversionChecker {
class InheritedSizeListChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~InheritedSizeListChecker() final {}
......@@ -61,11 +63,10 @@ class InheritedSizeListChecker : public InterpolationType::ConversionChecker {
const SizeList& inherited_size_list)
: property_(property), inherited_size_list_(inherited_size_list) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return inherited_size_list_ ==
SizeListPropertyFunctions::GetSizeList(
property_, *environment.GetState().ParentStyle());
return inherited_size_list_ == SizeListPropertyFunctions::GetSizeList(
property_, *state.ParentStyle());
}
CSSPropertyID property_;
......
......@@ -71,14 +71,14 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSTextIndentNonInterpolableValue);
namespace {
class UnderlyingIndentModeChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<UnderlyingIndentModeChecker> Create(
const IndentMode& mode) {
return WTF::WrapUnique(new UnderlyingIndentModeChecker(mode));
}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
return mode_ == ToCSSTextIndentNonInterpolableValue(
*underlying.non_interpolable_value)
......@@ -91,16 +91,17 @@ class UnderlyingIndentModeChecker
const IndentMode mode_;
};
class InheritedIndentModeChecker : public InterpolationType::ConversionChecker {
class InheritedIndentModeChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedIndentModeChecker> Create(
const IndentMode& mode) {
return WTF::WrapUnique(new InheritedIndentModeChecker(mode));
}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
return mode_ == IndentMode(*environment.GetState().ParentStyle());
return mode_ == IndentMode(*state.ParentStyle());
}
private:
......
......@@ -129,17 +129,17 @@ InterpolationValue ConvertTransform(const TransformOperations& transform) {
return ConvertTransform(TransformOperations(transform));
}
class InheritedTransformChecker : public InterpolationType::ConversionChecker {
class InheritedTransformChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedTransformChecker> Create(
const TransformOperations& inherited_transform) {
return WTF::WrapUnique(new InheritedTransformChecker(inherited_transform));
}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return inherited_transform_ ==
environment.GetState().ParentStyle()->Transform();
return inherited_transform_ == state.ParentStyle()->Transform();
}
private:
......
......@@ -23,7 +23,8 @@ bool IsNoneValue(const InterpolationValue& value) {
return ToInterpolableList(*value.interpolable_value).length() == 0;
}
class InheritedTranslateChecker : public InterpolationType::ConversionChecker {
class InheritedTranslateChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
~InheritedTranslateChecker() {}
......@@ -33,10 +34,10 @@ class InheritedTranslateChecker : public InterpolationType::ConversionChecker {
new InheritedTranslateChecker(std::move(inherited_translate)));
}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
const TransformOperation* inherited_translate =
environment.GetState().ParentStyle()->Translate();
state.ParentStyle()->Translate();
if (inherited_translate_ == inherited_translate)
return true;
if (!inherited_translate_ || !inherited_translate)
......
......@@ -49,7 +49,7 @@ DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSVisibilityNonInterpolableValue);
DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSVisibilityNonInterpolableValue);
class UnderlyingVisibilityChecker
: public InterpolationType::ConversionChecker {
: public CSSInterpolationType::CSSConversionChecker {
public:
~UnderlyingVisibilityChecker() final {}
......@@ -62,7 +62,7 @@ class UnderlyingVisibilityChecker
UnderlyingVisibilityChecker(EVisibility visibility)
: visibility_(visibility) {}
bool IsValid(const InterpolationEnvironment&,
bool IsValid(const StyleResolverState&,
const InterpolationValue& underlying) const final {
double underlying_fraction =
ToInterpolableNumber(*underlying.interpolable_value).Value();
......@@ -75,7 +75,8 @@ class UnderlyingVisibilityChecker
const EVisibility visibility_;
};
class InheritedVisibilityChecker : public InterpolationType::ConversionChecker {
class InheritedVisibilityChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<InheritedVisibilityChecker> Create(
EVisibility visibility) {
......@@ -86,9 +87,9 @@ class InheritedVisibilityChecker : public InterpolationType::ConversionChecker {
InheritedVisibilityChecker(EVisibility visibility)
: visibility_(visibility) {}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
return visibility_ == environment.GetState().ParentStyle()->Visibility();
return visibility_ == state.ParentStyle()->Visibility();
}
const EVisibility visibility_;
......
......@@ -6,14 +6,14 @@
#define LengthUnitsChecker_h
#include <memory>
#include "core/animation/InterpolationType.h"
#include "core/animation/CSSInterpolationType.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/resolver/StyleResolverState.h"
#include "platform/wtf/PtrUtil.h"
namespace blink {
class LengthUnitsChecker : public InterpolationType::ConversionChecker {
class LengthUnitsChecker : public CSSInterpolationType::CSSConversionChecker {
public:
static std::unique_ptr<LengthUnitsChecker> MaybeCreate(
CSSLengthArray&& length_array,
......@@ -34,14 +34,14 @@ class LengthUnitsChecker : public InterpolationType::ConversionChecker {
new LengthUnitsChecker(std::move(length_array), last_index));
}
bool IsValid(const InterpolationEnvironment& environment,
bool IsValid(const StyleResolverState& state,
const InterpolationValue& underlying) const final {
for (size_t i = 0; i <= last_index_; i++) {
if (i == CSSPrimitiveValue::kUnitTypePercentage ||
!length_array_.type_flags.Get(i))
continue;
if (length_array_.values[i] !=
LengthUnit(i, environment.GetState().CssToLengthConversionData()))
LengthUnit(i, state.CssToLengthConversionData()))
return false;
}
return true;
......
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