--- a/layout/style/GenericSpecifiedValues.h
+++ b/layout/style/GenericSpecifiedValues.h
@@ -11,16 +11,17 @@
*/
#ifndef mozilla_GenericSpecifiedValues_h
#define mozilla_GenericSpecifiedValues_h
#include "mozilla/ServoUtils.h"
#include "nsCSSProps.h"
#include "nsCSSValue.h"
+#include "nsColor.h"
class nsAttrValue;
namespace mozilla {
class ServoSpecifiedValues;
// This provides a common interface for attribute mappers
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -279,17 +279,16 @@ whitelist-types = [
"nsCSSCounterDesc",
"nsCSSFontDesc",
"nsCSSKeyword",
"nsCSSPropertyID",
"nsCSSPropertyIDSet",
"nsCSSProps",
"nsCSSShadowArray",
"nsCSSValue",
- "nsCSSValueFloatColor",
"nsCSSValueList",
"nsCSSValueList_heap",
"nsCSSValuePair_heap",
"nsCSSValuePairList",
"nsCSSValuePairList_heap",
"nsCSSValueTriplet_heap",
"nsCursorImage",
"nsFont",
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -43,21 +43,19 @@ static bool MightHaveRef(const T& aStrin
}
return false;
}
nsCSSValue::nsCSSValue(int32_t aValue, nsCSSUnit aUnit)
: mUnit(aUnit)
{
- MOZ_ASSERT(aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated ||
- aUnit == eCSSUnit_EnumColor,
+ MOZ_ASSERT(aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated,
"not an int value");
- if (aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated ||
- aUnit == eCSSUnit_EnumColor) {
+ if (aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated) {
mValue.mInt = aValue;
}
else {
mUnit = eCSSUnit_Null;
mValue.mInt = 0;
}
}
@@ -133,30 +131,19 @@ nsCSSValue::nsCSSValue(const nsCSSValue&
else if (eCSSUnit_Percent <= mUnit) {
mValue.mFloat = aCopy.mValue.mFloat;
MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat));
}
else if (UnitHasStringValue()) {
mValue.mString = aCopy.mValue.mString;
mValue.mString->AddRef();
}
- else if (eCSSUnit_Integer <= mUnit && mUnit <= eCSSUnit_EnumColor) {
+ else if (eCSSUnit_Integer <= mUnit && mUnit <= eCSSUnit_Enumerated) {
mValue.mInt = aCopy.mValue.mInt;
}
- else if (IsIntegerColorUnit()) {
- mValue.mColor = aCopy.mValue.mColor;
- }
- else if (IsFloatColorUnit()) {
- mValue.mFloatColor = aCopy.mValue.mFloatColor;
- mValue.mFloatColor->AddRef();
- }
- else if (eCSSUnit_ComplexColor == mUnit) {
- mValue.mComplexColor = aCopy.mValue.mComplexColor;
- mValue.mComplexColor->AddRef();
- }
else if (UnitHasArrayValue()) {
mValue.mArray = aCopy.mValue.mArray;
mValue.mArray->AddRef();
}
else if (eCSSUnit_URL == mUnit) {
mValue.mURL = aCopy.mValue.mURL;
mValue.mURL->AddRef();
}
@@ -244,28 +231,19 @@ bool nsCSSValue::operator==(const nsCSSV
if (mUnit == aOther.mUnit) {
if (mUnit <= eCSSUnit_DummyInherit) {
return true;
}
else if (UnitHasStringValue()) {
return (NS_strcmp(GetBufferValue(mValue.mString),
GetBufferValue(aOther.mValue.mString)) == 0);
}
- else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_EnumColor)) {
+ else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_Enumerated)) {
return mValue.mInt == aOther.mValue.mInt;
}
- else if (IsIntegerColorUnit()) {
- return mValue.mColor == aOther.mValue.mColor;
- }
- else if (IsFloatColorUnit()) {
- return *mValue.mFloatColor == *aOther.mValue.mFloatColor;
- }
- else if (eCSSUnit_ComplexColor == mUnit) {
- return *mValue.mComplexColor == *aOther.mValue.mComplexColor;
- }
else if (UnitHasArrayValue()) {
return *mValue.mArray == *aOther.mValue.mArray;
}
else if (eCSSUnit_URL == mUnit) {
return mValue.mURL->Equals(*aOther.mValue.mURL);
}
else if (eCSSUnit_Image == mUnit) {
return mValue.mImage->Equals(*aOther.mValue.mImage);
@@ -387,20 +365,16 @@ nscoord nsCSSValue::GetPixelLength() con
MOZ_ASSERT(!ServoStyleSet::IsCurrentThreadInServoTraversal()); \
mValue.member->Release(); \
}
void nsCSSValue::DoReset()
{
if (UnitHasStringValue()) {
mValue.mString->Release();
- } else if (IsFloatColorUnit()) {
- DO_RELEASE(mFloatColor);
- } else if (eCSSUnit_ComplexColor == mUnit) {
- DO_RELEASE(mComplexColor);
} else if (UnitHasArrayValue()) {
DO_RELEASE(mArray);
} else if (eCSSUnit_URL == mUnit) {
DO_RELEASE(mURL);
} else if (eCSSUnit_Image == mUnit) {
DO_RELEASE(mImage);
} else if (eCSSUnit_Pair == mUnit) {
DO_RELEASE(mPair);
@@ -423,22 +397,20 @@ void nsCSSValue::DoReset()
}
mUnit = eCSSUnit_Null;
}
#undef DO_RELEASE
void nsCSSValue::SetIntValue(int32_t aValue, nsCSSUnit aUnit)
{
- MOZ_ASSERT(aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated ||
- aUnit == eCSSUnit_EnumColor,
+ MOZ_ASSERT(aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated,
"not an int value");
Reset();
- if (aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated ||
- aUnit == eCSSUnit_EnumColor) {
+ if (aUnit == eCSSUnit_Integer || aUnit == eCSSUnit_Enumerated) {
mUnit = aUnit;
mValue.mInt = aValue;
}
}
void nsCSSValue::SetPercentValue(float aValue)
{
Reset();
@@ -473,66 +445,22 @@ void nsCSSValue::SetStringValue(const ns
void
nsCSSValue::SetAtomIdentValue(already_AddRefed<nsAtom> aValue)
{
Reset();
mUnit = eCSSUnit_AtomIdent;
mValue.mAtom = aValue.take();
}
-void nsCSSValue::SetColorValue(nscolor aValue)
-{
- SetIntegerColorValue(aValue, eCSSUnit_RGBAColor);
-}
-
-
-
-void nsCSSValue::SetIntegerColorValue(nscolor aValue, nsCSSUnit aUnit)
-{
- Reset();
- mUnit = aUnit;
- MOZ_ASSERT(IsIntegerColorUnit(), "bad unit");
- mValue.mColor = aValue;
-}
-
void nsCSSValue::SetIntegerCoordValue(nscoord aValue)
{
SetFloatValue(nsPresContext::AppUnitsToFloatCSSPixels(aValue),
eCSSUnit_Pixel);
}
-void nsCSSValue::SetFloatColorValue(float aComponent1,
- float aComponent2,
- float aComponent3,
- float aAlpha,
- nsCSSUnit aUnit)
-{
- Reset();
- mUnit = aUnit;
- MOZ_ASSERT(IsFloatColorUnit(), "bad unit");
- mValue.mFloatColor =
- new nsCSSValueFloatColor(aComponent1, aComponent2, aComponent3, aAlpha);
- mValue.mFloatColor->AddRef();
-}
-
-void
-nsCSSValue::SetRGBAColorValue(const RGBAColorData& aValue)
-{
- SetFloatColorValue(aValue.mR, aValue.mG, aValue.mB,
- aValue.mA, eCSSUnit_PercentageRGBAColor);
-}
-
-void
-nsCSSValue::SetComplexColorValue(already_AddRefed<ComplexColorValue> aValue)
-{
- Reset();
- mUnit = eCSSUnit_ComplexColor;
- mValue.mComplexColor = aValue.take();
-}
-
void nsCSSValue::SetArrayValue(nsCSSValue::Array* aValue, nsCSSUnit aUnit)
{
Reset();
mUnit = aUnit;
MOZ_ASSERT(UnitHasArrayValue(), "bad unit");
mValue.mArray = aValue;
mValue.mArray->AddRef();
}
@@ -852,39 +780,16 @@ void nsCSSValue::StartImageLoad(nsIDocum
mozilla::css::ImageValue::CreateFromURLValue(mValue.mURL,
aDocument,
aCORSMode);
nsCSSValue* writable = const_cast<nsCSSValue*>(this);
writable->SetImageValue(image);
}
-nscolor nsCSSValue::GetColorValue() const
-{
- MOZ_ASSERT(IsNumericColorUnit(), "not a color value");
- if (IsFloatColorUnit()) {
- return mValue.mFloatColor->GetColorValue(mUnit);
- }
- return mValue.mColor;
-}
-
-bool nsCSSValue::IsNonTransparentColor() const
-{
- // We have the value in the form it was specified in at this point, so we
- // have to look for both the keyword 'transparent' and its equivalent in
- // rgba notation.
- nsDependentString buf;
- return
- (IsIntegerColorUnit() && NS_GET_A(GetColorValue()) > 0) ||
- (IsFloatColorUnit() && mValue.mFloatColor->IsNonTransparentColor()) ||
- (mUnit == eCSSUnit_Ident &&
- !nsGkAtoms::transparent->Equals(GetStringValue(buf))) ||
- (mUnit == eCSSUnit_EnumColor);
-}
-
nsCSSValue::Array*
nsCSSValue::InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs)
{
RefPtr<nsCSSValue::Array> func = Array::Create(aNumArgs + 1);
func->Item(0).SetIntValue(aFunctionId, eCSSUnit_Enumerated);
SetArrayValue(func, eCSSUnit_Function);
return func;
}
@@ -1082,39 +987,16 @@ nsCSSValue::SizeOfExcludingThis(mozilla:
// Atom is always shared, and thus should not be counted.
case eCSSUnit_AtomIdent:
break;
// Int: nothing extra to measure.
case eCSSUnit_Integer:
case eCSSUnit_Enumerated:
- case eCSSUnit_EnumColor:
- break;
-
- // Integer Color: nothing extra to measure.
- case eCSSUnit_RGBColor:
- case eCSSUnit_RGBAColor:
- case eCSSUnit_HexColor:
- case eCSSUnit_ShortHexColor:
- case eCSSUnit_HexColorAlpha:
- case eCSSUnit_ShortHexColorAlpha:
- break;
-
- // Float Color
- case eCSSUnit_PercentageRGBColor:
- case eCSSUnit_PercentageRGBAColor:
- case eCSSUnit_HSLColor:
- case eCSSUnit_HSLAColor:
- n += mValue.mFloatColor->SizeOfIncludingThis(aMallocSizeOf);
- break;
-
- // Complex Color
- case eCSSUnit_ComplexColor:
- n += mValue.mComplexColor->SizeOfIncludingThis(aMallocSizeOf);
break;
// Float: nothing extra to measure.
case eCSSUnit_Percent:
case eCSSUnit_Number:
case eCSSUnit_ViewportWidth:
case eCSSUnit_ViewportHeight:
case eCSSUnit_ViewportMin:
@@ -1872,83 +1754,16 @@ size_t
css::ImageValue::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
n += css::URLValueData::SizeOfExcludingThis(aMallocSizeOf);
n += mRequests.ShallowSizeOfExcludingThis(aMallocSizeOf);
return n;
}
-size_t
-css::ComplexColorValue::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
-{
- // Only measure it if it's unshared, to avoid double-counting.
- size_t n = 0;
- if (mRefCnt <= 1) {
- n += aMallocSizeOf(this);
- }
- return n;
-}
-
-// --- nsCSSValueFloatColor -------------
-
-bool
-nsCSSValueFloatColor::operator==(nsCSSValueFloatColor& aOther) const
-{
- return mComponent1 == aOther.mComponent1 &&
- mComponent2 == aOther.mComponent2 &&
- mComponent3 == aOther.mComponent3 &&
- mAlpha == aOther.mAlpha;
-}
-
-nscolor
-nsCSSValueFloatColor::GetColorValue(nsCSSUnit aUnit) const
-{
- MOZ_ASSERT(nsCSSValue::IsFloatColorUnit(aUnit), "unexpected unit");
-
- // We should clamp each component value since eCSSUnit_PercentageRGBColor
- // and eCSSUnit_PercentageRGBAColor may store values greater than 1.0.
- if (aUnit == eCSSUnit_PercentageRGBColor ||
- aUnit == eCSSUnit_PercentageRGBAColor) {
- return NS_RGBA(
- // We need to clamp before multiplying by 255.0f to avoid overflow.
- NSToIntRound(mozilla::clamped(mComponent1, 0.0f, 1.0f) * 255.0f),
- NSToIntRound(mozilla::clamped(mComponent2, 0.0f, 1.0f) * 255.0f),
- NSToIntRound(mozilla::clamped(mComponent3, 0.0f, 1.0f) * 255.0f),
- NSToIntRound(mozilla::clamped(mAlpha, 0.0f, 1.0f) * 255.0f));
- }
-
- // HSL color
- MOZ_ASSERT(aUnit == eCSSUnit_HSLColor ||
- aUnit == eCSSUnit_HSLAColor);
- nscolor hsl = NS_HSL2RGB(mComponent1, mComponent2, mComponent3);
- return NS_RGBA(NS_GET_R(hsl),
- NS_GET_G(hsl),
- NS_GET_B(hsl),
- NSToIntRound(mAlpha * 255.0f));
-}
-
-bool
-nsCSSValueFloatColor::IsNonTransparentColor() const
-{
- return mAlpha > 0.0f;
-}
-
-size_t
-nsCSSValueFloatColor::SizeOfIncludingThis(
- mozilla::MallocSizeOf aMallocSizeOf) const
-{
- // Only measure it if it's unshared, to avoid double-counting.
- size_t n = 0;
- if (mRefCnt <= 1) {
- n += aMallocSizeOf(this);
- }
- return n;
-}
-
// --- nsCSSCornerSizes -----------------
nsCSSCornerSizes::nsCSSCornerSizes(void)
{
MOZ_COUNT_CTOR(nsCSSCornerSizes);
}
nsCSSCornerSizes::nsCSSCornerSizes(const nsCSSCornerSizes& aCopy)
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -9,24 +9,22 @@
#ifndef nsCSSValue_h___
#define nsCSSValue_h___
#include "mozilla/Attributes.h"
#include "mozilla/CORSMode.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ServoTypes.h"
#include "mozilla/SheetType.h"
-#include "mozilla/StyleComplexColor.h"
#include "mozilla/URLExtraData.h"
#include "mozilla/UniquePtr.h"
#include "nsCSSKeywords.h"
#include "nsCSSPropertyID.h"
#include "nsCSSProps.h"
-#include "nsColor.h"
#include "nsCoord.h"
#include "nsProxyRelease.h"
#include "nsRefPtrHashtable.h"
#include "nsString.h"
#include "nsStringBuffer.h"
#include "nsTArray.h"
#include "nsStyleConsts.h"
#include "nsStyleCoord.h"
@@ -345,111 +343,16 @@ private:
{
}
GridTemplateAreasValue(const GridTemplateAreasValue& aOther) = delete;
GridTemplateAreasValue&
operator=(const GridTemplateAreasValue& aOther) = delete;
};
-struct RGBAColorData
-{
- // 1.0 means 100% for all components, but the value may fall outside
- // the range of [0.0, 1.0], so it is necessary to clamp them when
- // converting to nscolor.
- float mR;
- float mG;
- float mB;
- float mA;
-
- RGBAColorData() = default;
- MOZ_IMPLICIT RGBAColorData(nscolor aColor)
- : mR(NS_GET_R(aColor) * (1.0f / 255.0f))
- , mG(NS_GET_G(aColor) * (1.0f / 255.0f))
- , mB(NS_GET_B(aColor) * (1.0f / 255.0f))
- , mA(NS_GET_A(aColor) * (1.0f / 255.0f))
- {}
- RGBAColorData(float aR, float aG, float aB, float aA)
- : mR(aR), mG(aG), mB(aB), mA(aA) {}
-
- bool operator==(const RGBAColorData& aOther) const
- {
- return mR == aOther.mR && mG == aOther.mG &&
- mB == aOther.mB && mA == aOther.mA;
- }
- bool operator!=(const RGBAColorData& aOther) const
- {
- return !(*this == aOther);
- }
-
- nscolor ToColor() const
- {
- return NS_RGBA(ClampColor(mR * 255.0f),
- ClampColor(mG * 255.0f),
- ClampColor(mB * 255.0f),
- ClampColor(mA * 255.0f));
- }
-
- RGBAColorData WithAlpha(float aAlpha) const
- {
- RGBAColorData result = *this;
- result.mA = aAlpha;
- return result;
- }
-};
-
-struct ComplexColorData
-{
- RGBAColorData mColor;
- float mForegroundRatio;
-
- ComplexColorData() = default;
- ComplexColorData(const RGBAColorData& aColor, float aForegroundRatio)
- : mColor(aColor), mForegroundRatio(aForegroundRatio) {}
- ComplexColorData(nscolor aColor, float aForegroundRatio)
- : mColor(aColor), mForegroundRatio(aForegroundRatio) {}
- explicit ComplexColorData(const StyleComplexColor& aColor)
- : mColor(aColor.mColor)
- , mForegroundRatio(aColor.mForegroundRatio * (1.0f / 255.0f)) {}
-
- bool operator==(const ComplexColorData& aOther) const
- {
- return mForegroundRatio == aOther.mForegroundRatio &&
- (IsCurrentColor() || mColor == aOther.mColor);
- }
- bool operator!=(const ComplexColorData& aOther) const
- {
- return !(*this == aOther);
- }
-
- bool IsCurrentColor() const { return mForegroundRatio >= 1.0f; }
- bool IsNumericColor() const { return mForegroundRatio <= 0.0f; }
-
- StyleComplexColor ToComplexColor() const
- {
- return {mColor.ToColor(), ClampColor(mForegroundRatio * 255.0f)};
- }
-};
-
-struct ComplexColorValue final : public ComplexColorData
-{
- // Just redirect any parameter to the data struct.
- template<typename... Args>
- explicit ComplexColorValue(Args&&... aArgs)
- : ComplexColorData(Forward<Args>(aArgs)...) {}
- ComplexColorValue(const ComplexColorValue&) = delete;
-
- NS_INLINE_DECL_REFCOUNTING(ComplexColorValue)
-
- size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
-
-private:
- ~ComplexColorValue() {}
-};
-
} // namespace css
} // namespace mozilla
enum nsCSSUnit {
eCSSUnit_Null = 0, // (n/a) null unit, value is not specified
eCSSUnit_Auto = 1, // (n/a) value is algorithmic
eCSSUnit_Inherit = 2, // (n/a) value is inherited
eCSSUnit_Initial = 3, // (n/a) value is default UA value
@@ -518,35 +421,16 @@ enum nsCSSUnit {
eCSSUnit_FontFamilyList = 58, // (SharedFontList*) value
// Atom units
eCSSUnit_AtomIdent = 60, // (nsAtom*) for its string as an identifier
eCSSUnit_Integer = 70, // (int) simple value
eCSSUnit_Enumerated = 71, // (int) value has enumerated meaning
- eCSSUnit_EnumColor = 80, // (int) enumerated color (kColorKTable)
- eCSSUnit_RGBColor = 81, // (nscolor) an opaque RGBA value specified as rgb()
- eCSSUnit_RGBAColor = 82, // (nscolor) an RGBA value specified as rgba()
- eCSSUnit_HexColor = 83, // (nscolor) an opaque RGBA value specified as #rrggbb
- eCSSUnit_ShortHexColor = 84, // (nscolor) an opaque RGBA value specified as #rgb
- eCSSUnit_HexColorAlpha = 85, // (nscolor) an opaque RGBA value specified as #rrggbbaa
- eCSSUnit_ShortHexColorAlpha = 86, // (nscolor) an opaque RGBA value specified as #rgba
- eCSSUnit_PercentageRGBColor = 87, // (nsCSSValueFloatColor*) an opaque
- // RGBA value specified as rgb() with
- // percentage components. Values over
- // 100% are allowed.
- eCSSUnit_PercentageRGBAColor = 88, // (nsCSSValueFloatColor*) an RGBA value
- // specified as rgba() with percentage
- // components. Values over 100% are
- // allowed.
- eCSSUnit_HSLColor = 89, // (nsCSSValueFloatColor*)
- eCSSUnit_HSLAColor = 90, // (nsCSSValueFloatColor*)
- eCSSUnit_ComplexColor = 91, // (ComplexColorValue*)
-
eCSSUnit_Percent = 100, // (float) 1.0 == 100%) value is percentage of something
eCSSUnit_Number = 101, // (float) value is numeric (usually multiplier, different behavior than percent)
// Length units - relative
// Viewport relative measure
eCSSUnit_ViewportWidth = 700, // (float) 1% of the width of the initial containing block
eCSSUnit_ViewportHeight = 701, // (float) 1% of the height of the initial containing block
eCSSUnit_ViewportMin = 702, // (float) smaller of ViewportWidth and ViewportHeight
@@ -591,17 +475,16 @@ struct nsCSSRect;
struct nsCSSRect_heap;
struct nsCSSValueList;
struct nsCSSValueList_heap;
struct nsCSSValueSharedList;
struct nsCSSValuePairList;
struct nsCSSValuePairList_heap;
struct nsCSSValueTriplet;
struct nsCSSValueTriplet_heap;
-class nsCSSValueFloatColor;
class nsCSSValue {
public:
struct Array;
friend struct Array;
friend struct mozilla::css::URLValueData;
@@ -688,52 +571,20 @@ public:
bool IsCalcUnit() const
{ return eCSSUnit_Calc <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
bool UnitHasStringValue() const
{ return eCSSUnit_String <= mUnit && mUnit <= eCSSUnit_Element; }
bool UnitHasArrayValue() const
{ return eCSSUnit_Array <= mUnit && mUnit <= eCSSUnit_Calc_Divided; }
- // Checks for the nsCSSValue being of a particular type of color unit:
- //
- // - IsIntegerColorUnit returns true for:
- // eCSSUnit_RGBColor -- rgb(int,int,int)
- // eCSSUnit_RGBAColor -- rgba(int,int,int,float)
- // eCSSUnit_HexColor -- #rrggbb
- // eCSSUnit_ShortHexColor -- #rgb
- // eCSSUnit_HexColorAlpha -- #rrggbbaa
- // eCSSUnit_ShortHexColorAlpha -- #rgba
- //
- // - IsFloatColorUnit returns true for:
- // eCSSUnit_PercentageRGBColor -- rgb(%,%,%)
- // eCSSUnit_PercentageRGBAColor -- rgba(%,%,%,float)
- // eCSSUnit_HSLColor -- hsl(float,%,%)
- // eCSSUnit_HSLAColor -- hsla(float,%,%,float)
- //
- // - IsNumericColorUnit returns true for any of the above units.
- //
- // Note that color keywords and system colors are represented by
- // eCSSUnit_EnumColor and eCSSUnit_Ident.
- bool IsIntegerColorUnit() const { return IsIntegerColorUnit(mUnit); }
- bool IsFloatColorUnit() const { return IsFloatColorUnit(mUnit); }
- bool IsNumericColorUnit() const { return IsNumericColorUnit(mUnit); }
- static bool IsIntegerColorUnit(nsCSSUnit aUnit)
- { return eCSSUnit_RGBColor <= aUnit && aUnit <= eCSSUnit_ShortHexColorAlpha; }
- static bool IsFloatColorUnit(nsCSSUnit aUnit)
- { return eCSSUnit_PercentageRGBColor <= aUnit &&
- aUnit <= eCSSUnit_HSLAColor; }
- static bool IsNumericColorUnit(nsCSSUnit aUnit)
- { return IsIntegerColorUnit(aUnit) || IsFloatColorUnit(aUnit); }
-
int32_t GetIntValue() const
{
MOZ_ASSERT(mUnit == eCSSUnit_Integer ||
- mUnit == eCSSUnit_Enumerated ||
- mUnit == eCSSUnit_EnumColor,
+ mUnit == eCSSUnit_Enumerated,
"not an int value");
return mValue.mInt;
}
nsCSSKeyword GetKeywordValue() const
{
MOZ_ASSERT(mUnit == eCSSUnit_Enumerated, "not a keyword value");
return static_cast<nsCSSKeyword>(mValue.mInt);
@@ -775,24 +626,16 @@ public:
}
const char16_t* GetStringBufferValue() const
{
MOZ_ASSERT(UnitHasStringValue(), "not a string value");
return GetBufferValue(mValue.mString);
}
- nscolor GetColorValue() const;
- bool IsNonTransparentColor() const;
- mozilla::StyleComplexColor GetStyleComplexColorValue() const
- {
- MOZ_ASSERT(mUnit == eCSSUnit_ComplexColor);
- return mValue.mComplexColor->ToComplexColor();
- }
-
Array* GetArrayValue() const
{
MOZ_ASSERT(UnitHasArrayValue(), "not an array value");
return mValue.mArray;
}
nsIURI* GetURLValue() const
{
@@ -871,22 +714,16 @@ public:
// Like GetImageValue, but additionally will pass the imgRequestProxy
// through nsContentUtils::GetStaticRequest if aPresContent is static.
already_AddRefed<imgRequestProxy> GetPossiblyStaticImageValue(
nsIDocument* aDocument, nsPresContext* aPresContext) const;
nscoord GetPixelLength() const;
- nsCSSValueFloatColor* GetFloatColorValue() const
- {
- MOZ_ASSERT(IsFloatColorUnit(), "not a float color value");
- return mValue.mFloatColor;
- }
-
nsAtom* GetAtomValue() const {
MOZ_ASSERT(mUnit == eCSSUnit_AtomIdent);
return mValue.mAtom;
}
void Reset() // sets to null
{
if (mUnit != eCSSUnit_Null)
@@ -904,27 +741,18 @@ public:
static_assert(mozilla::EnumTypeFitsWithin<T, int32_t>::value,
"aValue must be an enum that fits within mValue.mInt");
SetIntValue(static_cast<int32_t>(aValue), eCSSUnit_Enumerated);
}
void SetPercentValue(float aValue);
void SetFloatValue(float aValue, nsCSSUnit aUnit);
void SetStringValue(const nsString& aValue, nsCSSUnit aUnit);
void SetAtomIdentValue(already_AddRefed<nsAtom> aValue);
- void SetColorValue(nscolor aValue);
- void SetIntegerColorValue(nscolor aValue, nsCSSUnit aUnit);
// converts the nscoord to pixels
void SetIntegerCoordValue(nscoord aCoord);
- void SetFloatColorValue(float aComponent1,
- float aComponent2,
- float aComponent3,
- float aAlpha, nsCSSUnit aUnit);
- void SetRGBAColorValue(const mozilla::css::RGBAColorData& aValue);
- void SetComplexColorValue(
- already_AddRefed<mozilla::css::ComplexColorValue> aValue);
void SetArrayValue(nsCSSValue::Array* aArray, nsCSSUnit aUnit);
void SetURLValue(mozilla::css::URLValue* aURI);
void SetImageValue(mozilla::css::ImageValue* aImage);
void SetGridTemplateAreas(mozilla::css::GridTemplateAreasValue* aValue);
void SetFontFamilyListValue(already_AddRefed<mozilla::SharedFontList> aFontListValue);
void SetPairValue(const nsCSSValuePair* aPair);
void SetPairValue(const nsCSSValue& xValue, const nsCSSValue& yValue);
void SetSharedListValue(nsCSSValueSharedList* aList);
@@ -987,33 +815,30 @@ private:
protected:
nsCSSUnit mUnit;
union {
int32_t mInt;
float mFloat;
// Note: the capacity of the buffer may exceed the length of the string.
// If we're of a string type, mString is not null.
nsStringBuffer* MOZ_OWNING_REF mString;
- nscolor mColor;
nsAtom* MOZ_OWNING_REF mAtom;
Array* MOZ_OWNING_REF mArray;
mozilla::css::URLValue* MOZ_OWNING_REF mURL;
mozilla::css::ImageValue* MOZ_OWNING_REF mImage;
mozilla::css::GridTemplateAreasValue* MOZ_OWNING_REF mGridTemplateAreas;
nsCSSValuePair_heap* MOZ_OWNING_REF mPair;
nsCSSRect_heap* MOZ_OWNING_REF mRect;
nsCSSValueTriplet_heap* MOZ_OWNING_REF mTriplet;
nsCSSValueList_heap* MOZ_OWNING_REF mList;
nsCSSValueList* mListDependent;
nsCSSValueSharedList* MOZ_OWNING_REF mSharedList;
nsCSSValuePairList_heap* MOZ_OWNING_REF mPairList;
nsCSSValuePairList* mPairListDependent;
- nsCSSValueFloatColor* MOZ_OWNING_REF mFloatColor;
mozilla::SharedFontList* MOZ_OWNING_REF mFontFamilyList;
- mozilla::css::ComplexColorValue* MOZ_OWNING_REF mComplexColor;
} mValue;
};
struct nsCSSValue::Array final {
// return |Array| with reference count of zero
static Array* Create(size_t aItemCount) {
return new (aItemCount) Array(aItemCount);
@@ -1551,75 +1376,16 @@ nsCSSValue::GetPairListValue() const
if (mUnit == eCSSUnit_PairList)
return mValue.mPairList;
else {
MOZ_ASSERT (mUnit == eCSSUnit_PairListDep, "not a pairlist value");
return mValue.mPairListDependent;
}
}
-class nsCSSValueFloatColor final {
-public:
- nsCSSValueFloatColor(float aComponent1, float aComponent2, float aComponent3,
- float aAlpha)
- : mComponent1(aComponent1)
- , mComponent2(aComponent2)
- , mComponent3(aComponent3)
- , mAlpha(aAlpha)
- {
- // We may copy nsCSSValueFloatColor and do some comparisons on them.
- // In order to get the correct result, we have to make sure each component
- // is finite.
- MOZ_ASSERT(mozilla::IsFinite(aComponent1) &&
- mozilla::IsFinite(aComponent2) &&
- mozilla::IsFinite(aComponent3) &&
- mozilla::IsFinite(aAlpha),
- "Caller must ensure color components are finite");
- }
-
-private:
- // Private destructor, to discourage deletion outside of Release():
- ~nsCSSValueFloatColor()
- {}
-
-public:
- bool operator==(nsCSSValueFloatColor& aOther) const;
-
- nscolor GetColorValue(nsCSSUnit aUnit) const;
- float Comp1() const { return mComponent1; }
- float Comp2() const { return mComponent2; }
- float Comp3() const { return mComponent3; }
- float Alpha() const { return mAlpha; }
- bool IsNonTransparentColor() const;
-
- size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
-
- NS_INLINE_DECL_REFCOUNTING(nsCSSValueFloatColor)
-
-private:
- // The range of each component is.
- // [0, 1] for HSLColor and HSLAColor. mComponent1 for hue, mComponent2 for
- // saturation, mComponent3 for lightness.
- // [0, 1] for saturation and lightness
- // represents [0%, 100%].
- // [0, 1] for hue represents
- // [0deg, 360deg].
- //
- // [-float::max(), float::max()] for PercentageRGBColor, PercentageRGBAColor.
- // 1.0 means 100%.
- float mComponent1;
- float mComponent2;
- float mComponent3;
- float mAlpha;
-
- nsCSSValueFloatColor(const nsCSSValueFloatColor& aOther) = delete;
- nsCSSValueFloatColor& operator=(const nsCSSValueFloatColor& aOther)
- = delete;
-};
-
struct nsCSSCornerSizes {
nsCSSCornerSizes(void);
nsCSSCornerSizes(const nsCSSCornerSizes& aCopy);
~nsCSSCornerSizes();
// argument is a "full corner" constant from nsStyleConsts.h
nsCSSValue const & GetCorner(uint32_t aCorner) const {
return this->*corners[aCorner];
--- a/servo/components/style/gecko_bindings/sugar/ns_css_value.rs
+++ b/servo/components/style/gecko_bindings/sugar/ns_css_value.rs
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Little helpers for `nsCSSValue`.
use gecko_bindings::bindings;
use gecko_bindings::structs;
use gecko_bindings::structs::{nsCSSValue, nsCSSUnit};
-use gecko_bindings::structs::{nsCSSValue_Array, nsCSSValueList, nscolor};
+use gecko_bindings::structs::{nsCSSValue_Array, nsCSSValueList};
use gecko_string_cache::Atom;
use std::marker::PhantomData;
use std::mem;
use std::ops::{Index, IndexMut};
use std::slice;
use values::computed::{Angle, Length, LengthOrPercentage, Percentage};
use values::specified::url::SpecifiedUrl;
@@ -28,43 +28,30 @@ impl nsCSSValue {
pub fn is_none(&self) -> bool {
self.mUnit == nsCSSUnit::eCSSUnit_None
}
/// Returns this nsCSSValue value as an integer, unchecked in release
/// builds.
pub fn integer_unchecked(&self) -> i32 {
debug_assert!(self.mUnit == nsCSSUnit::eCSSUnit_Integer ||
- self.mUnit == nsCSSUnit::eCSSUnit_Enumerated ||
- self.mUnit == nsCSSUnit::eCSSUnit_EnumColor);
+ self.mUnit == nsCSSUnit::eCSSUnit_Enumerated);
unsafe { *self.mValue.mInt.as_ref() }
}
/// Checks if it is an integer and returns it if so
pub fn integer(&self) -> Option<i32> {
if self.mUnit == nsCSSUnit::eCSSUnit_Integer ||
- self.mUnit == nsCSSUnit::eCSSUnit_Enumerated ||
- self.mUnit == nsCSSUnit::eCSSUnit_EnumColor {
+ self.mUnit == nsCSSUnit::eCSSUnit_Enumerated {
Some(unsafe { *self.mValue.mInt.as_ref() })
} else {
None
}
}
- /// Checks if it is an RGBA color, returning it if so
- /// Only use it with colors set by SetColorValue(),
- /// which always sets RGBA colors
- pub fn color_value(&self) -> Option<nscolor> {
- if self.mUnit == nsCSSUnit::eCSSUnit_RGBAColor {
- Some(unsafe { *self.mValue.mColor.as_ref() })
- } else {
- None
- }
- }
-
/// Returns this nsCSSValue value as a floating point value, unchecked in
/// release builds.
pub fn float_unchecked(&self) -> f32 {
debug_assert!(nsCSSUnit::eCSSUnit_Number as u32 <= self.mUnit as u32);
unsafe { *self.mValue.mFloat.as_ref() }
}
/// Returns this nsCSSValue as a nsCSSValue::Array, unchecked in release