Bug 1370802: Clean up copy-pasta in GenericSpecifiedValues code. r?heycam
MozReview-Commit-ID: ABXfuSmLQRU
--- a/layout/style/GenericSpecifiedValuesInlines.h
+++ b/layout/style/GenericSpecifiedValuesInlines.h
@@ -32,32 +32,36 @@ void
GenericSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue)
{
MOZ_STYLO_FORWARD(SetIdentStringValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue)
{
- MOZ_STYLO_FORWARD(SetIdentStringValueIfUnset, (aId, aValue))
-}
-
-void
-GenericSpecifiedValues::SetIdentAtomValueIfUnset(nsCSSPropertyID aId, nsIAtom* aValue)
-{
- MOZ_STYLO_FORWARD(SetIdentAtomValueIfUnset, (aId, aValue))
+ if (!PropertyIsSet(aId)) {
+ SetIdentStringValue(aId, aValue);
+ }
}
void
GenericSpecifiedValues::SetIdentAtomValue(nsCSSPropertyID aId, nsIAtom* aValue)
{
MOZ_STYLO_FORWARD(SetIdentAtomValue, (aId, aValue))
}
void
+GenericSpecifiedValues::SetIdentAtomValueIfUnset(nsCSSPropertyID aId, nsIAtom* aValue)
+{
+ if (!PropertyIsSet(aId)) {
+ SetIdentAtomValue(aId, aValue);
+ }
+}
+
+void
GenericSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
{
// there are some static asserts in MOZ_STYLO_FORWARD which
// won't work with the overloaded SetKeywordValue function,
// so we copy its expansion and use SetIntValue for decltype
// instead
static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::SetIntValue),
decltype(&MOZ_STYLO_GECKO_TYPE::SetKeywordValue)>
@@ -70,31 +74,19 @@ GenericSpecifiedValues::SetKeywordValue(
return AsServo()->SetKeywordValue(aId, aValue);
}
return AsGecko()->SetKeywordValue(aId, aValue);
}
void
GenericSpecifiedValues::SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue)
{
- // there are some static asserts in MOZ_STYLO_FORWARD which
- // won't work with the overloaded SetKeywordValue function,
- // so we copy its expansion and use SetIntValue for decltype
- // instead
- static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::SetIntValue),
- decltype(&MOZ_STYLO_GECKO_TYPE::SetKeywordValueIfUnset)>
- ::value, "Gecko subclass should define its own SetKeywordValueIfUnset");
- static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::SetIntValue),
- decltype(&MOZ_STYLO_SERVO_TYPE::SetKeywordValueIfUnset)>
- ::value, "Servo subclass should define its own SetKeywordValueIfUnset");
-
- if (IsServo()) {
- return AsServo()->SetKeywordValueIfUnset(aId, aValue);
+ if (!PropertyIsSet(aId)) {
+ SetKeywordValue(aId, aValue);
}
- return AsGecko()->SetKeywordValueIfUnset(aId, aValue);
}
void
GenericSpecifiedValues::SetIntValue(nsCSSPropertyID aId, int32_t aValue)
{
MOZ_STYLO_FORWARD(SetIntValue, (aId, aValue))
}
@@ -102,17 +94,19 @@ void
GenericSpecifiedValues::SetPixelValue(nsCSSPropertyID aId, float aValue)
{
MOZ_STYLO_FORWARD(SetPixelValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue)
{
- MOZ_STYLO_FORWARD(SetPixelValueIfUnset, (aId, aValue))
+ if (!PropertyIsSet(aId)) {
+ SetPixelValue(aId, aValue);
+ }
}
void
GenericSpecifiedValues::SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue)
{
MOZ_STYLO_FORWARD(SetLengthValue, (aId, aValue))
}
@@ -126,53 +120,61 @@ void
GenericSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue)
{
MOZ_STYLO_FORWARD(SetPercentValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue)
{
- MOZ_STYLO_FORWARD(SetPercentValueIfUnset, (aId, aValue))
+ if (!PropertyIsSet(aId)) {
+ SetPercentValue(aId, aValue);
+ }
}
void
GenericSpecifiedValues::SetAutoValue(nsCSSPropertyID aId)
{
MOZ_STYLO_FORWARD(SetAutoValue, (aId))
}
void
GenericSpecifiedValues::SetAutoValueIfUnset(nsCSSPropertyID aId)
{
- MOZ_STYLO_FORWARD(SetAutoValueIfUnset, (aId))
+ if (!PropertyIsSet(aId)) {
+ SetAutoValue(aId);
+ }
}
void
GenericSpecifiedValues::SetCurrentColor(nsCSSPropertyID aId)
{
MOZ_STYLO_FORWARD(SetCurrentColor, (aId))
}
void
GenericSpecifiedValues::SetCurrentColorIfUnset(nsCSSPropertyID aId)
{
- MOZ_STYLO_FORWARD(SetCurrentColorIfUnset, (aId))
+ if (!PropertyIsSet(aId)) {
+ SetCurrentColor(aId);
+ }
}
void
GenericSpecifiedValues::SetColorValue(nsCSSPropertyID aId, nscolor aValue)
{
MOZ_STYLO_FORWARD(SetColorValue, (aId, aValue))
}
void
GenericSpecifiedValues::SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue)
{
- MOZ_STYLO_FORWARD(SetColorValueIfUnset, (aId, aValue))
+ if (!PropertyIsSet(aId)) {
+ SetColorValue(aId, aValue);
+ }
}
void
GenericSpecifiedValues::SetFontFamily(const nsString& aValue)
{
MOZ_STYLO_FORWARD(SetFontFamily, (aValue))
}
--- a/layout/style/ServoSpecifiedValues.h
+++ b/layout/style/ServoSpecifiedValues.h
@@ -23,90 +23,36 @@ public:
ServoSpecifiedValues(nsPresContext* aContext, RawServoDeclarationBlock* aDecl);
// GenericSpecifiedValues overrides
bool PropertyIsSet(nsCSSPropertyID aId);
void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue);
- void SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetIdentStringValue(aId, aValue);
- }
- }
-
void SetIdentAtomValue(nsCSSPropertyID aId, nsIAtom* aValue);
- void SetIdentAtomValueIfUnset(nsCSSPropertyID aId, nsIAtom* aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetIdentAtomValue(aId, aValue);
- }
- }
-
void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue);
- void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetKeywordValue(aId, aValue);
- }
- }
-
void SetIntValue(nsCSSPropertyID aId, int32_t aValue);
void SetPixelValue(nsCSSPropertyID aId, float aValue);
- void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetPixelValue(aId, aValue);
- }
- }
-
void SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue);
void SetNumberValue(nsCSSPropertyID aId, float aValue);
void SetPercentValue(nsCSSPropertyID aId, float aValue);
void SetAutoValue(nsCSSPropertyID aId);
- void SetAutoValueIfUnset(nsCSSPropertyID aId) {
- if (!PropertyIsSet(aId)) {
- SetAutoValue(aId);
- }
- }
-
- void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetPercentValue(aId, aValue);
- }
- }
-
void SetCurrentColor(nsCSSPropertyID aId);
- void SetCurrentColorIfUnset(nsCSSPropertyID aId) {
- if (!PropertyIsSet(aId)) {
- SetCurrentColor(aId);
- }
- }
-
void SetColorValue(nsCSSPropertyID aId, nscolor aValue);
- void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetColorValue(aId, aValue);
- }
- }
-
void SetFontFamily(const nsString& aValue);
void SetTextDecorationColorOverride();
void SetBackgroundImage(nsAttrValue& aValue);
private:
RefPtr<RawServoDeclarationBlock> mDecl;
};
--- a/layout/style/nsRuleData.h
+++ b/layout/style/nsRuleData.h
@@ -124,65 +124,37 @@ struct nsRuleData final: mozilla::Generi
return ValueFor(aId)->GetUnit() != eCSSUnit_Null;
}
void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue)
{
ValueFor(aId)->SetStringValue(aValue, eCSSUnit_Ident);
}
- void SetIdentStringValueIfUnset(nsCSSPropertyID aId, const nsString& aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetIdentStringValue(aId, aValue);
- }
- }
-
void SetIdentAtomValue(nsCSSPropertyID aId, nsIAtom* aValue)
{
nsCOMPtr<nsIAtom> atom = aValue;
ValueFor(aId)->SetAtomIdentValue(atom.forget());
}
- void SetIdentAtomValueIfUnset(nsCSSPropertyID aId, nsIAtom* aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetIdentAtomValue(aId, aValue);
- }
- }
-
void SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
{
ValueFor(aId)->SetIntValue(aValue, eCSSUnit_Enumerated);
}
- void SetKeywordValueIfUnset(nsCSSPropertyID aId, int32_t aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetKeywordValue(aId, aValue);
- }
- }
-
void SetIntValue(nsCSSPropertyID aId, int32_t aValue)
{
ValueFor(aId)->SetIntValue(aValue, eCSSUnit_Integer);
}
void SetPixelValue(nsCSSPropertyID aId, float aValue)
{
ValueFor(aId)->SetFloatValue(aValue, eCSSUnit_Pixel);
}
- void SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetPixelValue(aId, aValue);
- }
- }
-
void SetLengthValue(nsCSSPropertyID aId, nsCSSValue aValue)
{
nsCSSValue* val = ValueFor(aId);
*val = aValue;
}
void SetNumberValue(nsCSSPropertyID aId, float aValue)
{
@@ -193,51 +165,25 @@ struct nsRuleData final: mozilla::Generi
{
ValueFor(aId)->SetPercentValue(aValue);
}
void SetAutoValue(nsCSSPropertyID aId) {
ValueFor(aId)->SetAutoValue();
}
- void SetAutoValueIfUnset(nsCSSPropertyID aId) {
- if (!PropertyIsSet(aId)) {
- SetAutoValue(aId);
- }
- }
-
- void SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetPercentValue(aId, aValue);
- }
- }
-
void SetCurrentColor(nsCSSPropertyID aId) {
ValueFor(aId)->SetIntValue(NS_COLOR_CURRENTCOLOR, eCSSUnit_EnumColor);
}
- void SetCurrentColorIfUnset(nsCSSPropertyID aId) {
- if (!PropertyIsSet(aId)) {
- SetCurrentColor(aId);
- }
- }
-
void SetColorValue(nsCSSPropertyID aId, nscolor aValue)
{
ValueFor(aId)->SetColorValue(aValue);
}
- void SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue)
- {
- if (!PropertyIsSet(aId)) {
- SetColorValue(aId, aValue);
- }
- }
-
void SetFontFamily(const nsString& aValue);
void SetTextDecorationColorOverride();
void SetBackgroundImage(nsAttrValue& aValue);
private:
inline size_t GetPoisonOffset();
};