Bug 1847509 - Remove colors with static initializers r=emilio

This fixes a regression where the size of the binaries were increased.

Differential Revision: https://phabricator.services.mozilla.com/D185849
This commit is contained in:
Tiaan Louw 2023-08-10 05:57:17 +00:00
parent e2b2e5ebe7
commit bc45488c4e
4 changed files with 20 additions and 23 deletions

View File

@ -1809,7 +1809,7 @@ void nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
struct nsRecessedBorder : public nsStyleBorder {
explicit nsRecessedBorder(nscoord aBorderWidth) {
for (const auto side : AllPhysicalSides()) {
BorderColorFor(side) = StyleColor::BLACK;
BorderColorFor(side) = StyleColor::Black();
mBorder.Side(side) = aBorderWidth;
// Note: use SetBorderStyle here because we want to affect
// mComputedBorder

View File

@ -43,26 +43,23 @@ inline StyleColor StyleColor::FromColor(nscolor aColor) {
return StyleColor::Absolute(StyleAbsoluteColor::FromColor(aColor));
}
// Workaround for window.h conflict.
template <>
inline StyleColor StyleColor::Transparent() {
#pragma push_macro("TRANSPARENT")
#undef TRANSPARENT
// static
template <>
inline const StyleColor StyleColor::TRANSPARENT =
StyleColor::Absolute(StyleAbsoluteColor::TRANSPARENT);
return StyleColor::Absolute(StyleAbsoluteColor::TRANSPARENT);
#pragma pop_macro("TRANSPARENT")
}
// static
template <>
inline const StyleColor StyleColor::BLACK =
StyleColor::Absolute(StyleAbsoluteColor::BLACK);
inline StyleColor StyleColor::Black() {
return StyleColor::Absolute(StyleAbsoluteColor::BLACK);
}
// static
template <>
inline const StyleColor StyleColor::WHITE =
StyleColor::Absolute(StyleAbsoluteColor::WHITE);
inline StyleColor StyleColor::White() {
return StyleColor::Absolute(StyleAbsoluteColor::WHITE);
}
template <>
StyleAbsoluteColor StyleColor::ResolveColor(const StyleAbsoluteColor&) const;

View File

@ -752,7 +752,7 @@ using SVGPaintFallback = StyleGenericSVGPaintFallback<StyleColor>;
// nsStyleSVG
//
nsStyleSVG::nsStyleSVG()
: mFill{StyleSVGPaintKind::Color(StyleColor::BLACK),
: mFill{StyleSVGPaintKind::Color(StyleColor::Black()),
SVGPaintFallback::Unset()},
mStroke{StyleSVGPaintKind::None(), SVGPaintFallback::Unset()},
mMarkerEnd(StyleUrlOrNone::None()),
@ -899,9 +899,9 @@ nsStyleSVGReset::nsStyleSVGReset()
mR(NonNegativeLengthPercentage::Zero()),
mMask(nsStyleImageLayers::LayerType::Mask),
mClipPath(StyleClipPath::None()),
mStopColor(StyleColor::BLACK),
mFloodColor(StyleColor::BLACK),
mLightingColor(StyleColor::WHITE),
mStopColor(StyleColor::Black()),
mFloodColor(StyleColor::Black()),
mLightingColor(StyleColor::White()),
mStopOpacity(1.0f),
mFloodOpacity(1.0f),
mVectorEffect(StyleVectorEffect::None),
@ -2037,7 +2037,7 @@ nsChangeHint nsStyleImageLayers::Layer::CalcDifference(
nsStyleBackground::nsStyleBackground()
: mImage(nsStyleImageLayers::LayerType::Background),
mBackgroundColor(StyleColor::TRANSPARENT) {
mBackgroundColor(StyleColor::Transparent()) {
MOZ_COUNT_CTOR(nsStyleBackground);
}

View File

@ -549,12 +549,12 @@ renaming_overrides_prefixing = true
"""
"GenericColor" = """
static const StyleGenericColor TRANSPARENT;
static const StyleGenericColor BLACK;
static const StyleGenericColor WHITE;
static inline StyleGenericColor FromColor(nscolor);
static inline StyleGenericColor Transparent();
static inline StyleGenericColor Black();
static inline StyleGenericColor White();
bool MaybeTransparent() const;
/**