From a8ea1db99e4000124f2ff77aefc42694bcf74f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 16 Jun 2017 03:56:45 +0200 Subject: [PATCH] Bug 1370802: Clean up copy-pasta in GenericSpecifiedValues code. r=heycam MozReview-Commit-ID: ABXfuSmLQRU --HG-- extra : rebase_source : 58b5b0aea23e362469a87e9592f8ebf9a8db5456 --- layout/style/GenericSpecifiedValuesInlines.h | 54 ++++++++++---------- layout/style/ServoSpecifiedValues.h | 54 -------------------- layout/style/nsRuleData.h | 54 -------------------- 3 files changed, 28 insertions(+), 134 deletions(-) diff --git a/layout/style/GenericSpecifiedValuesInlines.h b/layout/style/GenericSpecifiedValuesInlines.h index b7c921984a31..22e8087e272e 100644 --- a/layout/style/GenericSpecifiedValuesInlines.h +++ b/layout/style/GenericSpecifiedValuesInlines.h @@ -37,13 +37,9 @@ GenericSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId, const nsString& 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 @@ -52,6 +48,14 @@ 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) { @@ -75,21 +79,9 @@ GenericSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t 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 - ::value, "Gecko subclass should define its own SetKeywordValueIfUnset"); - static_assert(!mozilla::IsSame - ::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 @@ -107,7 +99,9 @@ GenericSpecifiedValues::SetPixelValue(nsCSSPropertyID aId, float aValue) void GenericSpecifiedValues::SetPixelValueIfUnset(nsCSSPropertyID aId, float aValue) { - MOZ_STYLO_FORWARD(SetPixelValueIfUnset, (aId, aValue)) + if (!PropertyIsSet(aId)) { + SetPixelValue(aId, aValue); + } } void @@ -131,7 +125,9 @@ GenericSpecifiedValues::SetPercentValue(nsCSSPropertyID aId, float aValue) void GenericSpecifiedValues::SetPercentValueIfUnset(nsCSSPropertyID aId, float aValue) { - MOZ_STYLO_FORWARD(SetPercentValueIfUnset, (aId, aValue)) + if (!PropertyIsSet(aId)) { + SetPercentValue(aId, aValue); + } } void @@ -143,7 +139,9 @@ GenericSpecifiedValues::SetAutoValue(nsCSSPropertyID aId) void GenericSpecifiedValues::SetAutoValueIfUnset(nsCSSPropertyID aId) { - MOZ_STYLO_FORWARD(SetAutoValueIfUnset, (aId)) + if (!PropertyIsSet(aId)) { + SetAutoValue(aId); + } } void @@ -155,7 +153,9 @@ GenericSpecifiedValues::SetCurrentColor(nsCSSPropertyID aId) void GenericSpecifiedValues::SetCurrentColorIfUnset(nsCSSPropertyID aId) { - MOZ_STYLO_FORWARD(SetCurrentColorIfUnset, (aId)) + if (!PropertyIsSet(aId)) { + SetCurrentColor(aId); + } } void @@ -167,7 +167,9 @@ GenericSpecifiedValues::SetColorValue(nsCSSPropertyID aId, nscolor aValue) void GenericSpecifiedValues::SetColorValueIfUnset(nsCSSPropertyID aId, nscolor aValue) { - MOZ_STYLO_FORWARD(SetColorValueIfUnset, (aId, aValue)) + if (!PropertyIsSet(aId)) { + SetColorValue(aId, aValue); + } } void diff --git a/layout/style/ServoSpecifiedValues.h b/layout/style/ServoSpecifiedValues.h index 57229db84c92..a7754d27d559 100644 --- a/layout/style/ServoSpecifiedValues.h +++ b/layout/style/ServoSpecifiedValues.h @@ -28,42 +28,14 @@ public: 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); @@ -72,36 +44,10 @@ public: 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); diff --git a/layout/style/nsRuleData.h b/layout/style/nsRuleData.h index 1ba6f57d7e3b..0a68360f5bce 100644 --- a/layout/style/nsRuleData.h +++ b/layout/style/nsRuleData.h @@ -129,38 +129,17 @@ struct nsRuleData final: mozilla::GenericSpecifiedValues 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 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); @@ -171,13 +150,6 @@ struct nsRuleData final: mozilla::GenericSpecifiedValues 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); @@ -198,41 +170,15 @@ struct nsRuleData final: mozilla::GenericSpecifiedValues 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);