diff --git a/content/html/style/src/nsCSSValue.cpp b/content/html/style/src/nsCSSValue.cpp index e09481fc88d..7fd298c03c7 100644 --- a/content/html/style/src/nsCSSValue.cpp +++ b/content/html/style/src/nsCSSValue.cpp @@ -123,6 +123,11 @@ nsCSSValue::nsCSSValue(const nsCSSValue& aCopy) } } +nsCSSValue::~nsCSSValue() +{ + Reset(); +} + nsCSSValue& nsCSSValue::operator=(const nsCSSValue& aCopy) { Reset(); @@ -177,6 +182,44 @@ PRBool nsCSSValue::operator==(const nsCSSValue& aOther) const return PR_FALSE; } +nscoord nsCSSValue::GetLengthTwips() const +{ + NS_ASSERTION(IsFixedLengthUnit(), "not a fixed length unit"); + + if (IsFixedLengthUnit()) { + switch (mUnit) { + case eCSSUnit_Inch: + return NS_INCHES_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Foot: + return NS_FEET_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Mile: + return NS_MILES_TO_TWIPS(mValue.mFloat); + + case eCSSUnit_Millimeter: + return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Centimeter: + return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Meter: + return NS_METERS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Kilometer: + return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); + + case eCSSUnit_Point: + return NSFloatPointsToTwips(mValue.mFloat); + case eCSSUnit_Pica: + return NS_PICAS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Didot: + return NS_DIDOTS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Cicero: + return NS_CICEROS_TO_TWIPS(mValue.mFloat); + default: + NS_ERROR("should never get here"); + break; + } + } + return 0; +} + void nsCSSValue::SetIntValue(PRInt32 aValue, nsCSSUnit aUnit) { NS_ASSERTION((eCSSUnit_Integer == aUnit) || @@ -189,6 +232,23 @@ void nsCSSValue::SetIntValue(PRInt32 aValue, nsCSSUnit aUnit) } } +void nsCSSValue::SetPercentValue(float aValue) +{ + Reset(); + mUnit = eCSSUnit_Percent; + mValue.mFloat = aValue; +} + +void nsCSSValue::SetFloatValue(float aValue, nsCSSUnit aUnit) +{ + NS_ASSERTION(eCSSUnit_Number <= aUnit, "not a float value"); + Reset(); + if (eCSSUnit_Number <= aUnit) { + mUnit = aUnit; + mValue.mFloat = aValue; + } +} + void nsCSSValue::SetStringValue(const nsAString& aValue, nsCSSUnit aUnit) { @@ -215,31 +275,31 @@ void nsCSSValue::SetURLValue(nsCSSValue::URL* aValue) mValue.mURL->AddRef(); } -void nsCSSValue::SetAutoValue(void) +void nsCSSValue::SetAutoValue() { Reset(); mUnit = eCSSUnit_Auto; } -void nsCSSValue::SetInheritValue(void) +void nsCSSValue::SetInheritValue() { Reset(); mUnit = eCSSUnit_Inherit; } -void nsCSSValue::SetInitialValue(void) +void nsCSSValue::SetInitialValue() { Reset(); mUnit = eCSSUnit_Initial; } -void nsCSSValue::SetNoneValue(void) +void nsCSSValue::SetNoneValue() { Reset(); mUnit = eCSSUnit_None; } -void nsCSSValue::SetNormalValue(void) +void nsCSSValue::SetNormalValue() { Reset(); mUnit = eCSSUnit_Normal; diff --git a/content/html/style/src/nsCSSValue.h b/content/html/style/src/nsCSSValue.h index 84500bc5846..2e50701bd81 100644 --- a/content/html/style/src/nsCSSValue.h +++ b/content/html/style/src/nsCSSValue.h @@ -135,11 +135,7 @@ public: nsCSSValue(nscolor aValue); nsCSSValue(URL* aValue); nsCSSValue(const nsCSSValue& aCopy); - ~nsCSSValue(void) - { - Reset(); - } - + ~nsCSSValue(); nsCSSValue& operator=(const nsCSSValue& aCopy); PRBool operator==(const nsCSSValue& aOther) const; @@ -149,34 +145,34 @@ public: return !(*this == aOther); } - nsCSSUnit GetUnit(void) const { return mUnit; }; - PRBool IsLengthUnit(void) const + nsCSSUnit GetUnit() const { return mUnit; }; + PRBool IsLengthUnit() const { return PRBool((eCSSUnit_Inch <= mUnit) && (mUnit <= eCSSUnit_Proportional)); } - PRBool IsFixedLengthUnit(void) const + PRBool IsFixedLengthUnit() const { return PRBool((eCSSUnit_Inch <= mUnit) && (mUnit <= eCSSUnit_Cicero)); } - PRBool IsRelativeLengthUnit(void) const + PRBool IsRelativeLengthUnit() const { return PRBool((eCSSUnit_EM <= mUnit) && (mUnit <= eCSSUnit_Proportional)); } - PRBool IsAngularUnit(void) const + PRBool IsAngularUnit() const { return PRBool((eCSSUnit_Degree <= mUnit) && (mUnit <= eCSSUnit_Radian)); } - PRBool IsFrequencyUnit(void) const + PRBool IsFrequencyUnit() const { return PRBool((eCSSUnit_Hertz <= mUnit) && (mUnit <= eCSSUnit_Kilohertz)); } - PRBool IsTimeUnit(void) const + PRBool IsTimeUnit() const { return PRBool((eCSSUnit_Seconds <= mUnit) && (mUnit <= eCSSUnit_Milliseconds)); } - PRInt32 GetIntValue(void) const + PRInt32 GetIntValue() const { NS_ASSERTION(mUnit == eCSSUnit_Integer || mUnit == eCSSUnit_Enumerated, "not an int value"); return mValue.mInt; } - float GetPercentValue(void) const + float GetPercentValue() const { NS_ASSERTION(mUnit == eCSSUnit_Percent, "not a percent value"); return mValue.mFloat; } - float GetFloatValue(void) const + float GetFloatValue() const { NS_ASSERTION(eCSSUnit_Number <= mUnit, "not a float value"); return mValue.mFloat; @@ -200,64 +196,27 @@ public: return mValue.mString; } - nscolor GetColorValue(void) const + nscolor GetColorValue() const { NS_ASSERTION((mUnit == eCSSUnit_Color), "not a color value"); return mValue.mColor; } - nsIURI* GetURLValue(void) const + nsIURI* GetURLValue() const { NS_ASSERTION(mUnit == eCSSUnit_URL, "not a URL value"); return mValue.mURL->mURI; } - const PRUnichar* GetOriginalURLValue(void) const + const PRUnichar* GetOriginalURLValue() const { NS_ASSERTION(mUnit == eCSSUnit_URL, "not a URL value"); return mValue.mURL->mString; } + nscoord GetLengthTwips() const; - nscoord GetLengthTwips(void) const - { - NS_ASSERTION(IsFixedLengthUnit(), "not a fixed length unit"); - - if (IsFixedLengthUnit()) { - switch (mUnit) { - case eCSSUnit_Inch: - return NS_INCHES_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Foot: - return NS_FEET_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Mile: - return NS_MILES_TO_TWIPS(mValue.mFloat); - - case eCSSUnit_Millimeter: - return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Centimeter: - return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Meter: - return NS_METERS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Kilometer: - return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); - - case eCSSUnit_Point: - return NSFloatPointsToTwips(mValue.mFloat); - case eCSSUnit_Pica: - return NS_PICAS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Didot: - return NS_DIDOTS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Cicero: - return NS_CICEROS_TO_TWIPS(mValue.mFloat); - default: - NS_ERROR("should never get here"); - break; - } - } - return 0; - } - - void Reset(void) // sets to null + void Reset() // sets to null { if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) && (nsnull != mValue.mString)) { @@ -270,31 +229,16 @@ public: } void SetIntValue(PRInt32 aValue, nsCSSUnit aUnit); - void SetPercentValue(float aValue) - { - Reset(); - mUnit = eCSSUnit_Percent; - mValue.mFloat = aValue; - } - - void SetFloatValue(float aValue, nsCSSUnit aUnit) - { - NS_ASSERTION(eCSSUnit_Number <= aUnit, "not a float value"); - Reset(); - if (eCSSUnit_Number <= aUnit) { - mUnit = aUnit; - mValue.mFloat = aValue; - } - } - + void SetPercentValue(float aValue); + void SetFloatValue(float aValue, nsCSSUnit aUnit); void SetStringValue(const nsAString& aValue, nsCSSUnit aUnit); void SetColorValue(nscolor aValue); void SetURLValue(nsCSSValue::URL* aURI); - void SetAutoValue(void); - void SetInheritValue(void); - void SetInitialValue(void); - void SetNoneValue(void); - void SetNormalValue(void); + void SetAutoValue(); + void SetInheritValue(); + void SetInitialValue(); + void SetNoneValue(); + void SetNormalValue(); // debugging methods only // XXXldb Not anymore! diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index e09481fc88d..7fd298c03c7 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -123,6 +123,11 @@ nsCSSValue::nsCSSValue(const nsCSSValue& aCopy) } } +nsCSSValue::~nsCSSValue() +{ + Reset(); +} + nsCSSValue& nsCSSValue::operator=(const nsCSSValue& aCopy) { Reset(); @@ -177,6 +182,44 @@ PRBool nsCSSValue::operator==(const nsCSSValue& aOther) const return PR_FALSE; } +nscoord nsCSSValue::GetLengthTwips() const +{ + NS_ASSERTION(IsFixedLengthUnit(), "not a fixed length unit"); + + if (IsFixedLengthUnit()) { + switch (mUnit) { + case eCSSUnit_Inch: + return NS_INCHES_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Foot: + return NS_FEET_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Mile: + return NS_MILES_TO_TWIPS(mValue.mFloat); + + case eCSSUnit_Millimeter: + return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Centimeter: + return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Meter: + return NS_METERS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Kilometer: + return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); + + case eCSSUnit_Point: + return NSFloatPointsToTwips(mValue.mFloat); + case eCSSUnit_Pica: + return NS_PICAS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Didot: + return NS_DIDOTS_TO_TWIPS(mValue.mFloat); + case eCSSUnit_Cicero: + return NS_CICEROS_TO_TWIPS(mValue.mFloat); + default: + NS_ERROR("should never get here"); + break; + } + } + return 0; +} + void nsCSSValue::SetIntValue(PRInt32 aValue, nsCSSUnit aUnit) { NS_ASSERTION((eCSSUnit_Integer == aUnit) || @@ -189,6 +232,23 @@ void nsCSSValue::SetIntValue(PRInt32 aValue, nsCSSUnit aUnit) } } +void nsCSSValue::SetPercentValue(float aValue) +{ + Reset(); + mUnit = eCSSUnit_Percent; + mValue.mFloat = aValue; +} + +void nsCSSValue::SetFloatValue(float aValue, nsCSSUnit aUnit) +{ + NS_ASSERTION(eCSSUnit_Number <= aUnit, "not a float value"); + Reset(); + if (eCSSUnit_Number <= aUnit) { + mUnit = aUnit; + mValue.mFloat = aValue; + } +} + void nsCSSValue::SetStringValue(const nsAString& aValue, nsCSSUnit aUnit) { @@ -215,31 +275,31 @@ void nsCSSValue::SetURLValue(nsCSSValue::URL* aValue) mValue.mURL->AddRef(); } -void nsCSSValue::SetAutoValue(void) +void nsCSSValue::SetAutoValue() { Reset(); mUnit = eCSSUnit_Auto; } -void nsCSSValue::SetInheritValue(void) +void nsCSSValue::SetInheritValue() { Reset(); mUnit = eCSSUnit_Inherit; } -void nsCSSValue::SetInitialValue(void) +void nsCSSValue::SetInitialValue() { Reset(); mUnit = eCSSUnit_Initial; } -void nsCSSValue::SetNoneValue(void) +void nsCSSValue::SetNoneValue() { Reset(); mUnit = eCSSUnit_None; } -void nsCSSValue::SetNormalValue(void) +void nsCSSValue::SetNormalValue() { Reset(); mUnit = eCSSUnit_Normal; diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index 84500bc5846..2e50701bd81 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -135,11 +135,7 @@ public: nsCSSValue(nscolor aValue); nsCSSValue(URL* aValue); nsCSSValue(const nsCSSValue& aCopy); - ~nsCSSValue(void) - { - Reset(); - } - + ~nsCSSValue(); nsCSSValue& operator=(const nsCSSValue& aCopy); PRBool operator==(const nsCSSValue& aOther) const; @@ -149,34 +145,34 @@ public: return !(*this == aOther); } - nsCSSUnit GetUnit(void) const { return mUnit; }; - PRBool IsLengthUnit(void) const + nsCSSUnit GetUnit() const { return mUnit; }; + PRBool IsLengthUnit() const { return PRBool((eCSSUnit_Inch <= mUnit) && (mUnit <= eCSSUnit_Proportional)); } - PRBool IsFixedLengthUnit(void) const + PRBool IsFixedLengthUnit() const { return PRBool((eCSSUnit_Inch <= mUnit) && (mUnit <= eCSSUnit_Cicero)); } - PRBool IsRelativeLengthUnit(void) const + PRBool IsRelativeLengthUnit() const { return PRBool((eCSSUnit_EM <= mUnit) && (mUnit <= eCSSUnit_Proportional)); } - PRBool IsAngularUnit(void) const + PRBool IsAngularUnit() const { return PRBool((eCSSUnit_Degree <= mUnit) && (mUnit <= eCSSUnit_Radian)); } - PRBool IsFrequencyUnit(void) const + PRBool IsFrequencyUnit() const { return PRBool((eCSSUnit_Hertz <= mUnit) && (mUnit <= eCSSUnit_Kilohertz)); } - PRBool IsTimeUnit(void) const + PRBool IsTimeUnit() const { return PRBool((eCSSUnit_Seconds <= mUnit) && (mUnit <= eCSSUnit_Milliseconds)); } - PRInt32 GetIntValue(void) const + PRInt32 GetIntValue() const { NS_ASSERTION(mUnit == eCSSUnit_Integer || mUnit == eCSSUnit_Enumerated, "not an int value"); return mValue.mInt; } - float GetPercentValue(void) const + float GetPercentValue() const { NS_ASSERTION(mUnit == eCSSUnit_Percent, "not a percent value"); return mValue.mFloat; } - float GetFloatValue(void) const + float GetFloatValue() const { NS_ASSERTION(eCSSUnit_Number <= mUnit, "not a float value"); return mValue.mFloat; @@ -200,64 +196,27 @@ public: return mValue.mString; } - nscolor GetColorValue(void) const + nscolor GetColorValue() const { NS_ASSERTION((mUnit == eCSSUnit_Color), "not a color value"); return mValue.mColor; } - nsIURI* GetURLValue(void) const + nsIURI* GetURLValue() const { NS_ASSERTION(mUnit == eCSSUnit_URL, "not a URL value"); return mValue.mURL->mURI; } - const PRUnichar* GetOriginalURLValue(void) const + const PRUnichar* GetOriginalURLValue() const { NS_ASSERTION(mUnit == eCSSUnit_URL, "not a URL value"); return mValue.mURL->mString; } + nscoord GetLengthTwips() const; - nscoord GetLengthTwips(void) const - { - NS_ASSERTION(IsFixedLengthUnit(), "not a fixed length unit"); - - if (IsFixedLengthUnit()) { - switch (mUnit) { - case eCSSUnit_Inch: - return NS_INCHES_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Foot: - return NS_FEET_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Mile: - return NS_MILES_TO_TWIPS(mValue.mFloat); - - case eCSSUnit_Millimeter: - return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Centimeter: - return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Meter: - return NS_METERS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Kilometer: - return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); - - case eCSSUnit_Point: - return NSFloatPointsToTwips(mValue.mFloat); - case eCSSUnit_Pica: - return NS_PICAS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Didot: - return NS_DIDOTS_TO_TWIPS(mValue.mFloat); - case eCSSUnit_Cicero: - return NS_CICEROS_TO_TWIPS(mValue.mFloat); - default: - NS_ERROR("should never get here"); - break; - } - } - return 0; - } - - void Reset(void) // sets to null + void Reset() // sets to null { if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) && (nsnull != mValue.mString)) { @@ -270,31 +229,16 @@ public: } void SetIntValue(PRInt32 aValue, nsCSSUnit aUnit); - void SetPercentValue(float aValue) - { - Reset(); - mUnit = eCSSUnit_Percent; - mValue.mFloat = aValue; - } - - void SetFloatValue(float aValue, nsCSSUnit aUnit) - { - NS_ASSERTION(eCSSUnit_Number <= aUnit, "not a float value"); - Reset(); - if (eCSSUnit_Number <= aUnit) { - mUnit = aUnit; - mValue.mFloat = aValue; - } - } - + void SetPercentValue(float aValue); + void SetFloatValue(float aValue, nsCSSUnit aUnit); void SetStringValue(const nsAString& aValue, nsCSSUnit aUnit); void SetColorValue(nscolor aValue); void SetURLValue(nsCSSValue::URL* aURI); - void SetAutoValue(void); - void SetInheritValue(void); - void SetInitialValue(void); - void SetNoneValue(void); - void SetNormalValue(void); + void SetAutoValue(); + void SetInheritValue(); + void SetInitialValue(); + void SetNoneValue(); + void SetNormalValue(); // debugging methods only // XXXldb Not anymore!