Bug 232706: Remove unneccesary datatypes from nsHTMLValue and cleanup AttributeToString.
r=caillon sr=jst
This commit is contained in:
Родитель
adaca9ddb0
Коммит
65d14b7bf0
|
@ -184,7 +184,6 @@ public:
|
||||||
|
|
||||||
PRUint32 HashValue() const
|
PRUint32 HashValue() const
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// mBits and PRUint32 might have different size. This should silence
|
// mBits and PRUint32 might have different size. This should silence
|
||||||
// any warnings or compile-errors. This is what the implementation of
|
// any warnings or compile-errors. This is what the implementation of
|
||||||
// NS_PTR_TO_INT32 does to take care of the same problem.
|
// NS_PTR_TO_INT32 does to take care of the same problem.
|
||||||
|
|
|
@ -50,26 +50,20 @@
|
||||||
#include "nsICSSStyleRule.h"
|
#include "nsICSSStyleRule.h"
|
||||||
#include "nsCSSDeclaration.h"
|
#include "nsCSSDeclaration.h"
|
||||||
|
|
||||||
nsHTMLValue::nsHTMLValue(nsHTMLUnit aUnit)
|
nsHTMLValue::nsHTMLValue()
|
||||||
: mUnit(aUnit)
|
: mUnit(eHTMLUnit_String)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(GetUnitClass() == HTMLUNIT_NOSTORE, "not a valueless unit");
|
|
||||||
if (GetUnitClass() != HTMLUNIT_NOSTORE) {
|
|
||||||
mUnit = eHTMLUnit_Null;
|
|
||||||
}
|
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsHTMLValue::nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit)
|
nsHTMLValue::nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit)
|
||||||
: mUnit(aUnit)
|
: mUnit(aUnit)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER ||
|
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER, "unit not an integer unit");
|
||||||
GetUnitClass() == HTMLUNIT_PIXEL, "unit not an integer unit");
|
if (GetUnitClass() == HTMLUNIT_INTEGER) {
|
||||||
if (GetUnitClass() == HTMLUNIT_INTEGER ||
|
|
||||||
GetUnitClass() == HTMLUNIT_PIXEL) {
|
|
||||||
mValue.mInt = aValue;
|
mValue.mInt = aValue;
|
||||||
} else {
|
} else {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,9 +124,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
||||||
// Call GetUnitClass() so that we turn StringWithLength into String
|
// Call GetUnitClass() so that we turn StringWithLength into String
|
||||||
PRUint32 unitClass = GetUnitClass();
|
PRUint32 unitClass = GetUnitClass();
|
||||||
switch (unitClass) {
|
switch (unitClass) {
|
||||||
case HTMLUNIT_NOSTORE:
|
|
||||||
return PR_TRUE;
|
|
||||||
|
|
||||||
case HTMLUNIT_STRING:
|
case HTMLUNIT_STRING:
|
||||||
if (mValue.mString && aOther.mValue.mString) {
|
if (mValue.mString && aOther.mValue.mString) {
|
||||||
return GetDependentString().Equals(aOther.GetDependentString());
|
return GetDependentString().Equals(aOther.GetDependentString());
|
||||||
|
@ -141,7 +132,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
||||||
return mValue.mString == aOther.mValue.mString;
|
return mValue.mString == aOther.mValue.mString;
|
||||||
|
|
||||||
case HTMLUNIT_INTEGER:
|
case HTMLUNIT_INTEGER:
|
||||||
case HTMLUNIT_PIXEL:
|
|
||||||
return mValue.mInt == aOther.mValue.mInt;
|
return mValue.mInt == aOther.mValue.mInt;
|
||||||
|
|
||||||
case HTMLUNIT_COLOR:
|
case HTMLUNIT_COLOR:
|
||||||
|
@ -211,7 +201,7 @@ void nsHTMLValue::Reset(void)
|
||||||
else if (mUnit == eHTMLUnit_AtomArray) {
|
else if (mUnit == eHTMLUnit_AtomArray) {
|
||||||
delete mValue.mAtomArray;
|
delete mValue.mAtomArray;
|
||||||
}
|
}
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,17 +214,11 @@ void nsHTMLValue::SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit)
|
||||||
if (GetUnitClass() == HTMLUNIT_INTEGER) {
|
if (GetUnitClass() == HTMLUNIT_INTEGER) {
|
||||||
mValue.mInt = aValue;
|
mValue.mInt = aValue;
|
||||||
} else {
|
} else {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLValue::SetPixelValue(PRInt32 aValue)
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
mUnit = eHTMLUnit_Pixel;
|
|
||||||
mValue.mInt = aValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsHTMLValue::SetPercentValue(float aValue)
|
void nsHTMLValue::SetPercentValue(float aValue)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
@ -254,7 +238,7 @@ void nsHTMLValue::SetStringValueInternal(const nsAString& aValue,
|
||||||
nsCheapStringBufferUtils::CopyToBuffer(mValue.mString, aValue);
|
nsCheapStringBufferUtils::CopyToBuffer(mValue.mString, aValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,21 +266,11 @@ void nsHTMLValue::SetColorValue(nscolor aValue)
|
||||||
mValue.mColor = aValue;
|
mValue.mColor = aValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLValue::SetEmptyValue(void)
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
mUnit = eHTMLUnit_Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
||||||
{
|
{
|
||||||
mUnit = aCopy.mUnit;
|
mUnit = aCopy.mUnit;
|
||||||
switch (GetUnitClass()) {
|
switch (GetUnitClass()) {
|
||||||
case HTMLUNIT_NOSTORE:
|
|
||||||
mValue.mString = nsnull;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HTMLUNIT_STRING:
|
case HTMLUNIT_STRING:
|
||||||
if (aCopy.mValue.mString) {
|
if (aCopy.mValue.mString) {
|
||||||
nsCheapStringBufferUtils::Clone(mValue.mString, aCopy.mValue.mString);
|
nsCheapStringBufferUtils::Clone(mValue.mString, aCopy.mValue.mString);
|
||||||
|
@ -306,7 +280,6 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HTMLUNIT_INTEGER:
|
case HTMLUNIT_INTEGER:
|
||||||
case HTMLUNIT_PIXEL:
|
|
||||||
mValue.mInt = aCopy.mValue.mInt;
|
mValue.mInt = aCopy.mValue.mInt;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -326,7 +299,8 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
||||||
case HTMLUNIT_ATOMARRAY:
|
case HTMLUNIT_ATOMARRAY:
|
||||||
mValue.mAtomArray = new nsCOMArray<nsIAtom>(*aCopy.mValue.mAtomArray);
|
mValue.mAtomArray = new nsCOMArray<nsIAtom>(*aCopy.mValue.mAtomArray);
|
||||||
if (!mValue.mAtomArray) {
|
if (!mValue.mAtomArray) {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -411,11 +385,7 @@ nsHTMLValue::ParseSpecialIntValue(const nsAString& aString,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Straight number is interpreted with the default unit
|
// Straight number is interpreted with the default unit
|
||||||
if (aDefaultUnit == eHTMLUnit_Pixel) {
|
SetIntValue(val, aDefaultUnit);
|
||||||
SetPixelValue(val);
|
|
||||||
} else {
|
|
||||||
SetIntValue(val, aDefaultUnit);
|
|
||||||
}
|
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,11 +418,6 @@ nsHTMLValue::ToString(nsAString& aResult) const
|
||||||
}
|
}
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
|
||||||
case eHTMLUnit_Pixel:
|
|
||||||
intStr.AppendInt(GetPixelValue());
|
|
||||||
aResult.Append(intStr);
|
|
||||||
return PR_TRUE;
|
|
||||||
|
|
||||||
case eHTMLUnit_Percent:
|
case eHTMLUnit_Percent:
|
||||||
{
|
{
|
||||||
float percentVal = GetPercentValue() * 100.0f;
|
float percentVal = GetPercentValue() * 100.0f;
|
||||||
|
@ -463,14 +428,14 @@ nsHTMLValue::ToString(nsAString& aResult) const
|
||||||
}
|
}
|
||||||
case eHTMLUnit_Color:
|
case eHTMLUnit_Color:
|
||||||
{
|
{
|
||||||
nscolor v = GetColorValue();
|
nscolor v;
|
||||||
|
GetColorValue(v);
|
||||||
char buf[10];
|
char buf[10];
|
||||||
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
||||||
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
||||||
AppendASCIItoUTF16(buf, aResult);
|
AppendASCIItoUTF16(buf, aResult);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
case eHTMLUnit_ColorName:
|
|
||||||
case eHTMLUnit_String:
|
case eHTMLUnit_String:
|
||||||
GetStringValue(aResult);
|
GetStringValue(aResult);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
@ -516,11 +481,7 @@ nsHTMLValue::ParseIntWithBounds(const nsAString& aString,
|
||||||
if (NS_SUCCEEDED(ec)) {
|
if (NS_SUCCEEDED(ec)) {
|
||||||
val = PR_MAX(val, aMin);
|
val = PR_MAX(val, aMin);
|
||||||
val = PR_MIN(val, aMax);
|
val = PR_MIN(val, aMax);
|
||||||
if (aDefaultUnit == eHTMLUnit_Pixel) {
|
SetIntValue(val, aDefaultUnit);
|
||||||
SetPixelValue(val);
|
|
||||||
} else {
|
|
||||||
SetIntValue(val, aDefaultUnit);
|
|
||||||
}
|
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +510,7 @@ nsHTMLValue::ParseColor(const nsAString& aString, nsIDocument* aDocument)
|
||||||
// No color names begin with a '#', but numerical colors do so
|
// No color names begin with a '#', but numerical colors do so
|
||||||
// it is a very common first char
|
// it is a very common first char
|
||||||
if ((colorStr.CharAt(0) != '#') && NS_ColorNameToRGB(colorStr, &color)) {
|
if ((colorStr.CharAt(0) != '#') && NS_ColorNameToRGB(colorStr, &color)) {
|
||||||
SetStringValue(colorStr, eHTMLUnit_ColorName);
|
SetStringValue(colorStr, eHTMLUnit_String);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,10 +148,8 @@ public:
|
||||||
// between different things stored as the same type. Doing
|
// between different things stored as the same type. Doing
|
||||||
// mUnit & HTMLUNIT_CLASS_MASK should give you the class of type.
|
// mUnit & HTMLUNIT_CLASS_MASK should give you the class of type.
|
||||||
//
|
//
|
||||||
#define HTMLUNIT_NOSTORE 0x0000
|
|
||||||
#define HTMLUNIT_STRING 0x0100
|
#define HTMLUNIT_STRING 0x0100
|
||||||
#define HTMLUNIT_INTEGER 0x0200
|
#define HTMLUNIT_INTEGER 0x0200
|
||||||
#define HTMLUNIT_PIXEL 0x0400
|
|
||||||
#define HTMLUNIT_COLOR 0x0800
|
#define HTMLUNIT_COLOR 0x0800
|
||||||
#define HTMLUNIT_CSSSTYLERULE 0x1000
|
#define HTMLUNIT_CSSSTYLERULE 0x1000
|
||||||
#define HTMLUNIT_PERCENT 0x2000
|
#define HTMLUNIT_PERCENT 0x2000
|
||||||
|
@ -159,15 +157,8 @@ public:
|
||||||
#define HTMLUNIT_CLASS_MASK 0xff00
|
#define HTMLUNIT_CLASS_MASK 0xff00
|
||||||
|
|
||||||
enum nsHTMLUnit {
|
enum nsHTMLUnit {
|
||||||
// null, value is not specified: 0x0000
|
|
||||||
eHTMLUnit_Null = HTMLUNIT_NOSTORE,
|
|
||||||
// empty, value is not specified: 0x0001
|
|
||||||
eHTMLUnit_Empty = HTMLUNIT_NOSTORE | 1,
|
|
||||||
|
|
||||||
// a string value
|
// a string value
|
||||||
eHTMLUnit_String = HTMLUNIT_STRING,
|
eHTMLUnit_String = HTMLUNIT_STRING,
|
||||||
// a color name value
|
|
||||||
eHTMLUnit_ColorName = HTMLUNIT_STRING | 1,
|
|
||||||
|
|
||||||
// a simple int value
|
// a simple int value
|
||||||
eHTMLUnit_Integer = HTMLUNIT_INTEGER,
|
eHTMLUnit_Integer = HTMLUNIT_INTEGER,
|
||||||
|
@ -176,9 +167,6 @@ enum nsHTMLUnit {
|
||||||
// value is a relative proportion of some whole
|
// value is a relative proportion of some whole
|
||||||
eHTMLUnit_Proportional = HTMLUNIT_INTEGER | 2,
|
eHTMLUnit_Proportional = HTMLUNIT_INTEGER | 2,
|
||||||
|
|
||||||
// screen pixels (screen relative measure)
|
|
||||||
eHTMLUnit_Pixel = HTMLUNIT_PIXEL,
|
|
||||||
|
|
||||||
// an RGBA value
|
// an RGBA value
|
||||||
eHTMLUnit_Color = HTMLUNIT_COLOR,
|
eHTMLUnit_Color = HTMLUNIT_COLOR,
|
||||||
|
|
||||||
|
@ -200,7 +188,7 @@ enum nsHTMLUnit {
|
||||||
*/
|
*/
|
||||||
class nsHTMLValue {
|
class nsHTMLValue {
|
||||||
public:
|
public:
|
||||||
nsHTMLValue(nsHTMLUnit aUnit = eHTMLUnit_Null);
|
nsHTMLValue();
|
||||||
nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
||||||
nsHTMLValue(float aValue);
|
nsHTMLValue(float aValue);
|
||||||
nsHTMLValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
nsHTMLValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
||||||
|
@ -222,24 +210,23 @@ public:
|
||||||
nsHTMLUnit GetUnit(void) const { return (nsHTMLUnit)mUnit; }
|
nsHTMLUnit GetUnit(void) const { return (nsHTMLUnit)mUnit; }
|
||||||
|
|
||||||
PRInt32 GetIntValue(void) const;
|
PRInt32 GetIntValue(void) const;
|
||||||
PRInt32 GetPixelValue(void) const;
|
|
||||||
float GetPercentValue(void) const;
|
float GetPercentValue(void) const;
|
||||||
nsAString& GetStringValue(nsAString& aBuffer) const;
|
nsAString& GetStringValue(nsAString& aBuffer) const;
|
||||||
nsICSSStyleRule* GetCSSStyleRuleValue(void) const;
|
nsICSSStyleRule* GetCSSStyleRuleValue(void) const;
|
||||||
nscolor GetColorValue(void) const;
|
PRBool GetColorValue(nscolor& aColor) const;
|
||||||
nsCOMArray<nsIAtom>* AtomArrayValue() const;
|
nsCOMArray<nsIAtom>* AtomArrayValue() const;
|
||||||
|
|
||||||
|
PRBool IsEmptyString() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the string to null type, freeing things in the process if necessary.
|
* Reset the string to null type, freeing things in the process if necessary.
|
||||||
*/
|
*/
|
||||||
void Reset(void);
|
void Reset(void);
|
||||||
void SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
void SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
||||||
void SetPixelValue(PRInt32 aValue);
|
|
||||||
void SetPercentValue(float aValue);
|
void SetPercentValue(float aValue);
|
||||||
void SetStringValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
void SetStringValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
||||||
void SetCSSStyleRuleValue(nsICSSStyleRule* aValue);
|
void SetCSSStyleRuleValue(nsICSSStyleRule* aValue);
|
||||||
void SetColorValue(nscolor aValue);
|
void SetColorValue(nscolor aValue);
|
||||||
void SetEmptyValue(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get this HTML value as a string (depends on the type)
|
* Get this HTML value as a string (depends on the type)
|
||||||
|
@ -295,10 +282,10 @@ public:
|
||||||
nsAString& aResult) const;
|
nsAString& aResult) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string value into an int or pixel HTMLValue.
|
* Parse a string value into an int HTMLValue.
|
||||||
*
|
*
|
||||||
* @param aString the string to parse
|
* @param aString the string to parse
|
||||||
* @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
|
* @param aDefaultUnit the unit to use
|
||||||
* @return whether the value could be parsed
|
* @return whether the value could be parsed
|
||||||
*/
|
*/
|
||||||
PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit) {
|
PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit) {
|
||||||
|
@ -306,13 +293,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string value into an int or pixel HTMLValue with minimum
|
* Parse a string value into an int HTMLValue with minimum
|
||||||
* value and maximum value (can optionally parse percent (n%) and
|
* value and maximum value (can optionally parse percent (n%) and
|
||||||
* proportional (n%). This method explicitly sets a lower bound of zero on
|
* proportional (n*). This method explicitly sets a lower bound of zero on
|
||||||
* the element, whether it be proportional or percent or raw integer.
|
* the element, whether it be proportional or percent or raw integer.
|
||||||
*
|
*
|
||||||
* @param aString the string to parse
|
* @param aString the string to parse
|
||||||
* @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
|
* @param aDefaultUnit the unit to use
|
||||||
* @param aCanBePercent true if it can be a percent value (%)
|
* @param aCanBePercent true if it can be a percent value (%)
|
||||||
* @param aCanBeProportional true if it can be a proportional value (*)
|
* @param aCanBeProportional true if it can be a proportional value (*)
|
||||||
* @return whether the value could be parsed
|
* @return whether the value could be parsed
|
||||||
|
@ -322,13 +309,13 @@ public:
|
||||||
PRBool aCanBeProportional);
|
PRBool aCanBeProportional);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string value into an int or pixel HTMLValue with minimum
|
* Parse a string value into an int HTMLValue with minimum
|
||||||
* value and maximum value
|
* value and maximum value
|
||||||
*
|
*
|
||||||
* @param aString the string to parse
|
* @param aString the string to parse
|
||||||
* @param aMin the minimum value (if value is less it will be bumped up)
|
* @param aMin the minimum value (if value is less it will be bumped up)
|
||||||
* @param aMax the maximum value (if value is greater it will be chopped down)
|
* @param aMax the maximum value (if value is greater it will be chopped down)
|
||||||
* @param aValueUnit the unit to use (eHTMLUnit_Pixel or Integer)
|
* @param aValueUnit the unit to use
|
||||||
* @return whether the value could be parsed
|
* @return whether the value could be parsed
|
||||||
*/
|
*/
|
||||||
PRBool ParseIntWithBounds(const nsAString& aString, nsHTMLUnit aValueUnit,
|
PRBool ParseIntWithBounds(const nsAString& aString, nsHTMLUnit aValueUnit,
|
||||||
|
@ -432,15 +419,6 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PRInt32 nsHTMLValue::GetPixelValue(void) const
|
|
||||||
{
|
|
||||||
NS_ASSERTION((mUnit == eHTMLUnit_Pixel), "not a pixel value");
|
|
||||||
if (mUnit == eHTMLUnit_Pixel) {
|
|
||||||
return mValue.mInt;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float nsHTMLValue::GetPercentValue(void) const
|
inline float nsHTMLValue::GetPercentValue(void) const
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mUnit == eHTMLUnit_Percent, "not a percent value");
|
NS_ASSERTION(mUnit == eHTMLUnit_Percent, "not a percent value");
|
||||||
|
@ -452,7 +430,7 @@ inline float nsHTMLValue::GetPercentValue(void) const
|
||||||
|
|
||||||
inline nsAString& nsHTMLValue::GetStringValue(nsAString& aBuffer) const
|
inline nsAString& nsHTMLValue::GetStringValue(nsAString& aBuffer) const
|
||||||
{
|
{
|
||||||
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING || mUnit == eHTMLUnit_Null,
|
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING,
|
||||||
"not a string value");
|
"not a string value");
|
||||||
if (GetUnitClass() == HTMLUNIT_STRING && mValue.mString) {
|
if (GetUnitClass() == HTMLUNIT_STRING && mValue.mString) {
|
||||||
aBuffer = GetDependentString();
|
aBuffer = GetDependentString();
|
||||||
|
@ -471,20 +449,19 @@ inline nsICSSStyleRule* nsHTMLValue::GetCSSStyleRuleValue(void) const
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline nscolor nsHTMLValue::GetColorValue(void) const
|
inline PRBool nsHTMLValue::GetColorValue(nscolor& aColor) const
|
||||||
{
|
{
|
||||||
NS_ASSERTION((mUnit == eHTMLUnit_Color) || (mUnit == eHTMLUnit_ColorName),
|
NS_ASSERTION((mUnit == eHTMLUnit_Color) || (mUnit == eHTMLUnit_String),
|
||||||
"not a color value");
|
"not a color value");
|
||||||
if (mUnit == eHTMLUnit_Color) {
|
if (mUnit == eHTMLUnit_Color) {
|
||||||
return mValue.mColor;
|
aColor = mValue.mColor;
|
||||||
|
|
||||||
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
if (mUnit == eHTMLUnit_ColorName) {
|
if (mUnit == eHTMLUnit_String && mValue.mString) {
|
||||||
nscolor color;
|
return NS_ColorNameToRGB(GetDependentString(), &aColor);
|
||||||
if (NS_ColorNameToRGB(GetDependentString(), &color)) {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NS_RGB(0,0,0);
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline nsCOMArray<nsIAtom>*
|
inline nsCOMArray<nsIAtom>*
|
||||||
|
@ -499,5 +476,10 @@ inline PRBool nsHTMLValue::operator!=(const nsHTMLValue& aOther) const
|
||||||
return PRBool(! ((*this) == aOther));
|
return PRBool(! ((*this) == aOther));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline PRBool nsHTMLValue::IsEmptyString() const
|
||||||
|
{
|
||||||
|
return mUnit == eHTMLUnit_String && !mValue.mString;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* nsHTMLValue_h___ */
|
#endif /* nsHTMLValue_h___ */
|
||||||
|
|
||||||
|
|
|
@ -1685,11 +1685,6 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
||||||
rv = ParseClassAttribute(aValue, attrValue);
|
rv = ParseClassAttribute(aValue, attrValue);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
else if (aValue.IsEmpty()) {
|
|
||||||
// This is a bit evil but there's code out there that only looks for
|
|
||||||
// this datatype and not for empty-string.
|
|
||||||
attrValue.SetTo(nsHTMLValue(eHTMLUnit_Empty));
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
attrValue.SetTo(aValue);
|
attrValue.SetTo(aValue);
|
||||||
}
|
}
|
||||||
|
@ -1922,43 +1917,22 @@ nsGenericHTMLElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
return NS_CONTENT_ATTR_NOT_THERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrValue->GetType() != nsAttrValue::eHTMLValue) {
|
// Use subclass to convert enums to string.
|
||||||
attrValue->ToString(aResult);
|
if (attrValue->GetType() == nsAttrValue::eHTMLValue &&
|
||||||
|
attrValue->GetHTMLValue()->GetUnit() == eHTMLUnit_Enumerated) {
|
||||||
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
if (aNameSpaceID != kNameSpaceID_None ||
|
||||||
}
|
AttributeToString(aAttribute, *attrValue->GetHTMLValue(), aResult) !=
|
||||||
|
NS_CONTENT_ATTR_HAS_VALUE) {
|
||||||
|
NS_NOTREACHED("no enum to string conversion found");
|
||||||
|
|
||||||
const nsHTMLValue* value = attrValue->GetHTMLValue();
|
|
||||||
|
|
||||||
// Try subclass conversion routine first
|
|
||||||
if (aNameSpaceID == kNameSpaceID_None &&
|
|
||||||
AttributeToString(aAttribute, *value, aResult) ==
|
|
||||||
NS_CONTENT_ATTR_HAS_VALUE) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise use default conversions
|
|
||||||
switch (value->GetUnit()) {
|
|
||||||
case eHTMLUnit_Null:
|
|
||||||
case eHTMLUnit_Empty:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case eHTMLUnit_String:
|
|
||||||
case eHTMLUnit_ColorName:
|
|
||||||
case eHTMLUnit_Integer:
|
|
||||||
case eHTMLUnit_Pixel:
|
|
||||||
case eHTMLUnit_Color:
|
|
||||||
case eHTMLUnit_Percent:
|
|
||||||
case eHTMLUnit_CSSStyleRule:
|
|
||||||
case eHTMLUnit_AtomArray:
|
|
||||||
value->ToString(aResult);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
NS_NOTREACHED("no value to string conversion found");
|
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
return NS_CONTENT_ATTR_NOT_THERE;
|
||||||
|
}
|
||||||
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attrValue->ToString(aResult);
|
||||||
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2303,11 +2277,8 @@ nsGenericHTMLElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
nsAString& aResult) const
|
nsAString& aResult) const
|
||||||
{
|
{
|
||||||
if (nsHTMLAtoms::dir == aAttribute) {
|
if (nsHTMLAtoms::dir == aAttribute) {
|
||||||
nsHTMLValue value;
|
if (aValue.GetUnit() == eHTMLUnit_Enumerated) {
|
||||||
nsresult result = GetHTMLAttribute(nsHTMLAtoms::dir, value);
|
aValue.EnumValueToString(kDirTable, aResult);
|
||||||
|
|
||||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
|
||||||
value.EnumValueToString(kDirTable, aResult);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -2765,27 +2736,12 @@ nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute,
|
||||||
{
|
{
|
||||||
if ((aAttribute == nsHTMLAtoms::width) ||
|
if ((aAttribute == nsHTMLAtoms::width) ||
|
||||||
(aAttribute == nsHTMLAtoms::height)) {
|
(aAttribute == nsHTMLAtoms::height)) {
|
||||||
return aResult.ParseSpecialIntValue(aString, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE);
|
return aResult.ParseSpecialIntValue(aString, eHTMLUnit_Integer, PR_TRUE, PR_FALSE);
|
||||||
}
|
}
|
||||||
else if ((aAttribute == nsHTMLAtoms::hspace) ||
|
else if ((aAttribute == nsHTMLAtoms::hspace) ||
|
||||||
(aAttribute == nsHTMLAtoms::vspace) ||
|
(aAttribute == nsHTMLAtoms::vspace) ||
|
||||||
(aAttribute == nsHTMLAtoms::border)) {
|
(aAttribute == nsHTMLAtoms::border)) {
|
||||||
return aResult.ParseIntWithBounds(aString, eHTMLUnit_Pixel, 0);
|
return aResult.ParseIntWithBounds(aString, eHTMLUnit_Integer, 0);
|
||||||
}
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
nsGenericHTMLElement::ImageAttributeToString(nsIAtom* aAttribute,
|
|
||||||
const nsHTMLValue& aValue,
|
|
||||||
nsAString& aResult)
|
|
||||||
{
|
|
||||||
if ((aAttribute == nsHTMLAtoms::width) ||
|
|
||||||
(aAttribute == nsHTMLAtoms::height) ||
|
|
||||||
(aAttribute == nsHTMLAtoms::border) ||
|
|
||||||
(aAttribute == nsHTMLAtoms::hspace) ||
|
|
||||||
(aAttribute == nsHTMLAtoms::vspace)) {
|
|
||||||
return aValue.ToString(aResult);
|
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2956,8 +2912,9 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu
|
||||||
eCSSUnit_Enumerated);
|
eCSSUnit_Enumerated);
|
||||||
}
|
}
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::lang, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::lang, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_String) {
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
|
value.GetUnit() == eHTMLUnit_String) {
|
||||||
nsAutoString lang;
|
nsAutoString lang;
|
||||||
value.GetStringValue(lang);
|
value.GetStringValue(lang);
|
||||||
aData->mDisplayData->mLang.SetStringValue(lang,
|
aData->mDisplayData->mLang.SetStringValue(lang,
|
||||||
|
@ -3072,8 +3029,8 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
|
||||||
// hspace: value
|
// hspace: value
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
|
||||||
nsCSSValue hval;
|
nsCSSValue hval;
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
hval.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
hval.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
hval.SetPercentValue(value.GetPercentValue());
|
hval.SetPercentValue(value.GetPercentValue());
|
||||||
|
|
||||||
|
@ -3088,8 +3045,8 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
|
||||||
// vspace: value
|
// vspace: value
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
|
||||||
nsCSSValue vval;
|
nsCSSValue vval;
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
vval.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
vval.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
vval.SetPercentValue(value.GetPercentValue());
|
vval.SetPercentValue(value.GetPercentValue());
|
||||||
|
|
||||||
|
@ -3114,8 +3071,8 @@ nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttr
|
||||||
// width: value
|
// width: value
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
|
@ -3123,8 +3080,8 @@ nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttr
|
||||||
// height: value
|
// height: value
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
|
@ -3140,14 +3097,15 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAtt
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
|
|
||||||
// border: pixels
|
// border: pixels
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::border, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::border, value) ==
|
||||||
if (value.GetUnit() == eHTMLUnit_Null)
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (value.GetUnit() != eHTMLUnit_Pixel) // something other than pixels
|
if (value.GetUnit() != eHTMLUnit_Integer) // something other than Integer
|
||||||
value.SetPixelValue(0);
|
value.SetIntValue(0, eHTMLUnit_Integer);
|
||||||
|
|
||||||
nscoord val = value.GetPixelValue();
|
nscoord val = value.GetIntValue();
|
||||||
|
|
||||||
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
|
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
|
||||||
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -3191,43 +3149,42 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsMappedAttributes* aAtt
|
||||||
// background
|
// background
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::background, value)) {
|
aAttributes->GetAttribute(nsHTMLAtoms::background, value) &&
|
||||||
if (eHTMLUnit_String == value.GetUnit()) {
|
value.GetUnit() == eHTMLUnit_String) {
|
||||||
nsAutoString spec;
|
nsAutoString spec;
|
||||||
value.GetStringValue(spec);
|
value.GetStringValue(spec);
|
||||||
if (!spec.IsEmpty()) {
|
if (!spec.IsEmpty()) {
|
||||||
// Resolve url to an absolute url
|
// Resolve url to an absolute url
|
||||||
// XXX this breaks if the HTML element has an xml:base
|
// XXX this breaks if the HTML element has an xml:base
|
||||||
// attribute (the xml:base will not be taken into account)
|
// attribute (the xml:base will not be taken into account)
|
||||||
// as well as elements with _baseHref set. We need to be able
|
// as well as elements with _baseHref set. We need to be able
|
||||||
// to get to the element somehow, or store the base URI in the
|
// to get to the element somehow, or store the base URI in the
|
||||||
// attributes.
|
// attributes.
|
||||||
nsIPresShell *shell = aData->mPresContext->GetPresShell();
|
nsIPresShell *shell = aData->mPresContext->GetPresShell();
|
||||||
if (shell) {
|
if (shell) {
|
||||||
nsCOMPtr<nsIDocument> doc;
|
nsCOMPtr<nsIDocument> doc;
|
||||||
nsresult rv = shell->GetDocument(getter_AddRefs(doc));
|
nsresult rv = shell->GetDocument(getter_AddRefs(doc));
|
||||||
if (NS_SUCCEEDED(rv) && doc) {
|
if (NS_SUCCEEDED(rv) && doc) {
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
rv = nsContentUtils::NewURIWithDocumentCharset(
|
rv = nsContentUtils::NewURIWithDocumentCharset(
|
||||||
getter_AddRefs(uri), spec, doc, doc->GetBaseURI());
|
getter_AddRefs(uri), spec, doc, doc->GetBaseURI());
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsCSSValue::URL *url = new nsCSSValue::URL(uri, spec.get());
|
nsCSSValue::URL *url = new nsCSSValue::URL(uri, spec.get());
|
||||||
if (url) {
|
if (url) {
|
||||||
if (url->mString)
|
if (url->mString)
|
||||||
aData->mColorData->mBackImage.SetURLValue(url);
|
aData->mColorData->mBackImage.SetURLValue(url);
|
||||||
else
|
else
|
||||||
delete url;
|
delete url;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (aData->mPresContext) {
|
}
|
||||||
|
else if (aData->mPresContext->CompatibilityMode() ==
|
||||||
|
eCompatibility_NavQuirks) {
|
||||||
// in NavQuirks mode, allow the empty string to set the
|
// in NavQuirks mode, allow the empty string to set the
|
||||||
// background to empty
|
// background to empty
|
||||||
if (eCompatibility_NavQuirks == aData->mPresContext->CompatibilityMode() &&
|
aData->mColorData->mBackImage.SetNoneValue();
|
||||||
eHTMLUnit_Empty == value.GetUnit())
|
|
||||||
aData->mColorData->mBackImage.SetNoneValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3235,10 +3192,12 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsMappedAttributes* aAtt
|
||||||
// bgcolor
|
// bgcolor
|
||||||
if (aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null) {
|
if (aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::bgcolor, value);
|
nscolor color;
|
||||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
if (aAttributes->GetAttribute(nsHTMLAtoms::bgcolor, value) !=
|
||||||
(eHTMLUnit_ColorName == value.GetUnit()))
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
aData->mColorData->mBackColor.SetColorValue(value.GetColorValue());
|
value.GetColorValue(color)) {
|
||||||
|
aData->mColorData->mBackColor.SetColorValue(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,7 @@ public:
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
/**
|
/**
|
||||||
* Turn an attribute value into string based on the type of attribute
|
* Turn an attribute value into string based on the type of attribute
|
||||||
* (does not need to do standard types such as string, integer, pixel,
|
* (does not need to do standard types such as string, integer,
|
||||||
* color ...). Called by GetAttr().
|
* color ...). Called by GetAttr().
|
||||||
*
|
*
|
||||||
* @param aAttribute the attribute to convert
|
* @param aAttribute the attribute to convert
|
||||||
|
@ -417,18 +417,6 @@ public:
|
||||||
static PRBool ParseImageAttribute(nsIAtom* aAttribute,
|
static PRBool ParseImageAttribute(nsIAtom* aAttribute,
|
||||||
const nsAString& aString,
|
const nsAString& aString,
|
||||||
nsHTMLValue& aResult);
|
nsHTMLValue& aResult);
|
||||||
/**
|
|
||||||
* Convert an image attribute to string
|
|
||||||
*
|
|
||||||
* @param aAttribute the attribute to parse
|
|
||||||
* @param aValue the value to convert
|
|
||||||
* @param aResult the resulting string
|
|
||||||
* @return whether the value was converted
|
|
||||||
*/
|
|
||||||
static PRBool ImageAttributeToString(nsIAtom* aAttribute,
|
|
||||||
const nsHTMLValue& aValue,
|
|
||||||
nsAString& aResult);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a frameborder string to value (yes/no/1/0)
|
* Convert a frameborder string to value (yes/no/1/0)
|
||||||
*
|
*
|
||||||
|
@ -893,14 +881,12 @@ protected:
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Set##_method(PRBool aValue) \
|
_class::Set##_method(PRBool aValue) \
|
||||||
{ \
|
{ \
|
||||||
nsHTMLValue empty(eHTMLUnit_Empty); \
|
|
||||||
if (aValue) { \
|
if (aValue) { \
|
||||||
return SetHTMLAttribute(nsHTMLAtoms::_atom, empty, PR_TRUE); \
|
return SetHTMLAttribute(nsHTMLAtoms::_atom, nsHTMLValue(), \
|
||||||
} \
|
PR_TRUE); \
|
||||||
else { \
|
|
||||||
UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, PR_TRUE); \
|
|
||||||
return NS_OK; \
|
|
||||||
} \
|
} \
|
||||||
|
UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, PR_TRUE); \
|
||||||
|
return NS_OK; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -937,40 +923,6 @@ protected:
|
||||||
return SetHTMLAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
|
return SetHTMLAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A macro to implement the getter and the setter for a given pixel
|
|
||||||
* valued content property. The method uses the generic GetAttr and
|
|
||||||
* SetAttr methods.
|
|
||||||
*/
|
|
||||||
#define NS_IMPL_PIXEL_ATTR(_class, _method, _atom) \
|
|
||||||
NS_IMPL_PIXEL_ATTR_DEFAULT_VALUE(_class, _method, _atom, -1)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A macro to implement the getter and the setter for a given pixel
|
|
||||||
* valued content property with a default value.
|
|
||||||
* The method uses the generic GetAttr and SetAttr methods.
|
|
||||||
*/
|
|
||||||
#define NS_IMPL_PIXEL_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
|
||||||
NS_IMETHODIMP \
|
|
||||||
_class::Get##_method(PRInt32* aValue) \
|
|
||||||
{ \
|
|
||||||
nsHTMLValue value; \
|
|
||||||
*aValue = _default; \
|
|
||||||
if (NS_CONTENT_ATTR_HAS_VALUE == \
|
|
||||||
GetHTMLAttribute(nsHTMLAtoms::_atom, value)) { \
|
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) { \
|
|
||||||
*aValue = value.GetPixelValue(); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
return NS_OK; \
|
|
||||||
} \
|
|
||||||
NS_IMETHODIMP \
|
|
||||||
_class::Set##_method(PRInt32 aValue) \
|
|
||||||
{ \
|
|
||||||
nsHTMLValue value(aValue, eHTMLUnit_Pixel); \
|
|
||||||
return SetHTMLAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A macro to implement the getter and setter for a given content
|
* A macro to implement the getter and setter for a given content
|
||||||
* property that needs to return a URI in string form. The method
|
* property that needs to return a URI in string form. The method
|
||||||
|
|
|
@ -69,11 +69,6 @@
|
||||||
|
|
||||||
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
||||||
|
|
||||||
// XXX suppress
|
|
||||||
|
|
||||||
// XXX either suppress is handled in the event code below OR we need a
|
|
||||||
// custom frame
|
|
||||||
|
|
||||||
class nsHTMLAnchorElement : public nsGenericHTMLElement,
|
class nsHTMLAnchorElement : public nsGenericHTMLElement,
|
||||||
public nsIDOMHTMLAnchorElement,
|
public nsIDOMHTMLAnchorElement,
|
||||||
public nsIDOMNSHTMLAnchorElement,
|
public nsIDOMNSHTMLAnchorElement,
|
||||||
|
@ -325,17 +320,9 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::suppress) {
|
|
||||||
if (!aValue.Equals(NS_LITERAL_STRING("true"),
|
|
||||||
nsCaseInsensitiveStringComparator())) {
|
|
||||||
aResult.SetEmptyValue(); // XXX? shouldn't just leave "true"
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
return NS_CONTENT_ATTR_NOT_THERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX support suppress in here
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||||
nsEvent* aEvent,
|
nsEvent* aEvent,
|
||||||
|
|
|
@ -169,10 +169,10 @@ NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Archive, archive)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code)
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code)
|
||||||
NS_IMPL_URI_ATTR(nsHTMLAppletElement, CodeBase, codebase)
|
NS_IMPL_URI_ATTR(nsHTMLAppletElement, CodeBase, codebase)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Height, height)
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Height, height)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLAppletElement, Hspace, hspace)
|
NS_IMPL_INT_ATTR(nsHTMLAppletElement, Hspace, hspace)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Name, name)
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Name, name)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Object, object)
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Object, object)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLAppletElement, Vspace, vspace)
|
NS_IMPL_INT_ATTR(nsHTMLAppletElement, Vspace, vspace)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width)
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -203,10 +203,6 @@ nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
|
|
||||||
aValue, aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult);
|
return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,11 +205,7 @@ nsHTMLAreaElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
const nsAString& aValue,
|
const nsAString& aValue,
|
||||||
nsHTMLValue& aResult)
|
nsHTMLValue& aResult)
|
||||||
{
|
{
|
||||||
if (aAttribute == nsHTMLAtoms::nohref) {
|
if (aAttribute == nsHTMLAtoms::tabindex) {
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::tabindex) {
|
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,6 @@ HTML_ATOM(strike, "strike")
|
||||||
HTML_ATOM(strong, "strong")
|
HTML_ATOM(strong, "strong")
|
||||||
HTML_ATOM(style, "style")
|
HTML_ATOM(style, "style")
|
||||||
HTML_ATOM(summary, "summary")
|
HTML_ATOM(summary, "summary")
|
||||||
HTML_ATOM(suppress, "suppress")
|
|
||||||
HTML_ATOM(tabindex, "tabindex")
|
HTML_ATOM(tabindex, "tabindex")
|
||||||
HTML_ATOM(table, "table")
|
HTML_ATOM(table, "table")
|
||||||
HTML_ATOM(tabstop, "tabstop")
|
HTML_ATOM(tabstop, "tabstop")
|
||||||
|
|
|
@ -170,8 +170,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||||
if (mPart->GetAttrCount() > 0) {
|
if (mPart->GetAttrCount() > 0) {
|
||||||
// if marginwidth/marginheight are set, reflect them as 'margin'
|
// if marginwidth/marginheight are set, reflect them as 'margin'
|
||||||
mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
||||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
if (eHTMLUnit_Integer == value.GetUnit()) {
|
||||||
bodyMarginWidth = value.GetPixelValue();
|
bodyMarginWidth = value.GetIntValue();
|
||||||
if (bodyMarginWidth < 0) bodyMarginWidth = 0;
|
if (bodyMarginWidth < 0) bodyMarginWidth = 0;
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -181,8 +181,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||||
}
|
}
|
||||||
|
|
||||||
mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
|
mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
|
||||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
if (eHTMLUnit_Integer == value.GetUnit()) {
|
||||||
bodyMarginHeight = value.GetPixelValue();
|
bodyMarginHeight = value.GetIntValue();
|
||||||
if (bodyMarginHeight < 0) bodyMarginHeight = 0;
|
if (bodyMarginHeight < 0) bodyMarginHeight = 0;
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -194,8 +194,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||||
if (eCompatibility_NavQuirks == mode){
|
if (eCompatibility_NavQuirks == mode){
|
||||||
// topmargin (IE-attribute)
|
// topmargin (IE-attribute)
|
||||||
mPart->GetHTMLAttribute(nsHTMLAtoms::topmargin, value);
|
mPart->GetHTMLAttribute(nsHTMLAtoms::topmargin, value);
|
||||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
if (eHTMLUnit_Integer == value.GetUnit()) {
|
||||||
bodyTopMargin = value.GetPixelValue();
|
bodyTopMargin = value.GetIntValue();
|
||||||
if (bodyTopMargin < 0) bodyTopMargin = 0;
|
if (bodyTopMargin < 0) bodyTopMargin = 0;
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -204,8 +204,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||||
|
|
||||||
// bottommargin (IE-attribute)
|
// bottommargin (IE-attribute)
|
||||||
mPart->GetHTMLAttribute(nsHTMLAtoms::bottommargin, value);
|
mPart->GetHTMLAttribute(nsHTMLAtoms::bottommargin, value);
|
||||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
if (eHTMLUnit_Integer == value.GetUnit()) {
|
||||||
bodyBottomMargin = value.GetPixelValue();
|
bodyBottomMargin = value.GetIntValue();
|
||||||
if (bodyBottomMargin < 0) bodyBottomMargin = 0;
|
if (bodyBottomMargin < 0) bodyBottomMargin = 0;
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -214,8 +214,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||||
|
|
||||||
// leftmargin (IE-attribute)
|
// leftmargin (IE-attribute)
|
||||||
mPart->GetHTMLAttribute(nsHTMLAtoms::leftmargin, value);
|
mPart->GetHTMLAttribute(nsHTMLAtoms::leftmargin, value);
|
||||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
if (eHTMLUnit_Integer == value.GetUnit()) {
|
||||||
bodyLeftMargin = value.GetPixelValue();
|
bodyLeftMargin = value.GetIntValue();
|
||||||
if (bodyLeftMargin < 0) bodyLeftMargin = 0;
|
if (bodyLeftMargin < 0) bodyLeftMargin = 0;
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -224,8 +224,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
||||||
|
|
||||||
// rightmargin (IE-attribute)
|
// rightmargin (IE-attribute)
|
||||||
mPart->GetHTMLAttribute(nsHTMLAtoms::rightmargin, value);
|
mPart->GetHTMLAttribute(nsHTMLAtoms::rightmargin, value);
|
||||||
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
if (eHTMLUnit_Integer == value.GetUnit()) {
|
||||||
bodyRightMargin = value.GetPixelValue();
|
bodyRightMargin = value.GetIntValue();
|
||||||
if (bodyRightMargin < 0) bodyRightMargin = 0;
|
if (bodyRightMargin < 0) bodyRightMargin = 0;
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -484,7 +484,7 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
(aAttribute == nsHTMLAtoms::bottommargin) ||
|
(aAttribute == nsHTMLAtoms::bottommargin) ||
|
||||||
(aAttribute == nsHTMLAtoms::leftmargin) ||
|
(aAttribute == nsHTMLAtoms::leftmargin) ||
|
||||||
(aAttribute == nsHTMLAtoms::rightmargin)) {
|
(aAttribute == nsHTMLAtoms::rightmargin)) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,22 +520,23 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
||||||
if (doc) {
|
if (doc) {
|
||||||
nsIHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
|
nsIHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
|
||||||
if (styleSheet) {
|
if (styleSheet) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::link, value);
|
nscolor color;
|
||||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
if (aAttributes->GetAttribute(nsHTMLAtoms::link, value) !=
|
||||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
styleSheet->SetLinkColor(value.GetColorValue());
|
value.GetColorValue(color)) {
|
||||||
|
styleSheet->SetLinkColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::alink, value) !=
|
||||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
value.GetColorValue(color)) {
|
||||||
styleSheet->SetActiveLinkColor(value.GetColorValue());
|
styleSheet->SetActiveLinkColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::vlink, value) !=
|
||||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
value.GetColorValue(color)) {
|
||||||
styleSheet->SetVisitedLinkColor(value.GetColorValue());
|
styleSheet->SetVisitedLinkColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,10 +547,11 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
||||||
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
||||||
// color: color
|
// color: color
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::text, value);
|
nscolor color;
|
||||||
if (((eHTMLUnit_Color == value.GetUnit())) ||
|
if (aAttributes->GetAttribute(nsHTMLAtoms::text, value) !=
|
||||||
(eHTMLUnit_ColorName == value.GetUnit()))
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
aData->mColorData->mColor.SetColorValue(value.GetColorValue());
|
value.GetColorValue(color))
|
||||||
|
aData->mColorData->mColor.SetColorValue(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,10 +356,6 @@ nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
table++;
|
table++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::disabled) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
return NS_CONTENT_ATTR_NOT_THERE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,10 +176,6 @@ nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::compact) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_NO_VALUE;
|
|
||||||
}
|
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
return NS_CONTENT_ATTR_NOT_THERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,11 +198,13 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
// type: enum
|
// type: enum
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||||
else if (value.GetUnit() != eHTMLUnit_Null)
|
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
else
|
||||||
|
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,12 +176,12 @@ nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::gutter) {
|
else if (aAttribute == nsHTMLAtoms::gutter) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 1)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 1)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
else if (aAttribute == nsHTMLAtoms::width) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,11 +173,11 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
//rickg: fixed flaw where ToInteger error code was not being checked.
|
//rickg: fixed flaw where ToInteger error code was not being checked.
|
||||||
// This caused wrong default value for font size.
|
// This caused wrong default value for font size.
|
||||||
PRInt32 ec, v = tmp.ToInteger(&ec);
|
PRInt32 ec, v = tmp.ToInteger(&ec);
|
||||||
if(NS_SUCCEEDED(ec)){
|
if(NS_SUCCEEDED(ec)) {
|
||||||
tmp.CompressWhitespace(PR_TRUE, PR_FALSE);
|
tmp.CompressWhitespace(PR_TRUE, PR_FALSE);
|
||||||
PRUnichar ch = tmp.IsEmpty() ? 0 : tmp.First();
|
PRUnichar ch = tmp.IsEmpty() ? 0 : tmp.First();
|
||||||
aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ?
|
aResult.SetIntValue(v, (ch == '+' || ch == '-') ?
|
||||||
eHTMLUnit_Integer : eHTMLUnit_Enumerated);
|
eHTMLUnit_Enumerated : eHTMLUnit_Integer);
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,20 +197,16 @@ nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
if ((aAttribute == nsHTMLAtoms::size) ||
|
if ((aAttribute == nsHTMLAtoms::size) ||
|
||||||
(aAttribute == nsHTMLAtoms::pointSize) ||
|
(aAttribute == nsHTMLAtoms::pointSize) ||
|
||||||
(aAttribute == nsHTMLAtoms::fontWeight)) {
|
(aAttribute == nsHTMLAtoms::fontWeight)) {
|
||||||
aResult.Truncate();
|
|
||||||
nsAutoString intVal;
|
|
||||||
if (aValue.GetUnit() == eHTMLUnit_Enumerated) {
|
if (aValue.GetUnit() == eHTMLUnit_Enumerated) {
|
||||||
intVal.AppendInt(aValue.GetIntValue(), 10);
|
nsAutoString intVal;
|
||||||
aResult.Append(intVal);
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aValue.GetUnit() == eHTMLUnit_Integer) {
|
|
||||||
PRInt32 value = aValue.GetIntValue();
|
PRInt32 value = aValue.GetIntValue();
|
||||||
|
intVal.AppendInt(value, 10);
|
||||||
if (value >= 0) {
|
if (value >= 0) {
|
||||||
aResult.Append(NS_LITERAL_STRING("+"));
|
aResult = NS_LITERAL_STRING("+") + intVal;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aResult = intVal;
|
||||||
}
|
}
|
||||||
intVal.AppendInt(value, 10);
|
|
||||||
aResult.Append(intVal);
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,8 +226,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
|
|
||||||
// face: string list
|
// face: string list
|
||||||
if (font.mFamily.GetUnit() == eCSSUnit_Null) {
|
if (font.mFamily.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::face, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::face, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_String) {
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
|
value.GetUnit() == eHTMLUnit_String) {
|
||||||
nsAutoString familyList;
|
nsAutoString familyList;
|
||||||
value.GetStringValue(familyList);
|
value.GetStringValue(familyList);
|
||||||
if (!familyList.IsEmpty()) {
|
if (!familyList.IsEmpty()) {
|
||||||
|
@ -255,8 +252,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
nsHTMLUnit unit = value.GetUnit();
|
nsHTMLUnit unit = value.GetUnit();
|
||||||
if (unit == eHTMLUnit_Integer || unit == eHTMLUnit_Enumerated) {
|
if (unit == eHTMLUnit_Integer || unit == eHTMLUnit_Enumerated) {
|
||||||
PRInt32 size = value.GetIntValue();
|
PRInt32 size = value.GetIntValue();
|
||||||
if (unit == eHTMLUnit_Integer) // int (+/-)
|
if (unit == eHTMLUnit_Enumerated) // int (+/-)
|
||||||
size += 3; // XXX should be BASEFONT, not three
|
size += 3; // XXX should be BASEFONT, not three see bug 3875
|
||||||
|
|
||||||
size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
|
size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
|
||||||
font.mSize.SetIntValue(size, eCSSUnit_Enumerated);
|
font.mSize.SetIntValue(size, eCSSUnit_Enumerated);
|
||||||
|
@ -277,11 +274,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
||||||
// color: color
|
// color: color
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
|
nscolor color;
|
||||||
if (NS_CONTENT_ATTR_NOT_THERE !=
|
if (NS_CONTENT_ATTR_NOT_THERE !=
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::color, value)) {
|
aAttributes->GetAttribute(nsHTMLAtoms::color, value) &&
|
||||||
if (((eHTMLUnit_Color == value.GetUnit())) ||
|
value.GetColorValue(color)) {
|
||||||
(eHTMLUnit_ColorName == value.GetUnit()))
|
aData->mColorData->mColor.SetColorValue(color);
|
||||||
aData->mColorData->mColor.SetColorValue(value.GetColorValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,10 +287,10 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// in quirks mode. The NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL flag only
|
// in quirks mode. The NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL flag only
|
||||||
// affects quirks mode rendering.
|
// affects quirks mode rendering.
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
|
nscolor color;
|
||||||
if (NS_CONTENT_ATTR_NOT_THERE !=
|
if (NS_CONTENT_ATTR_NOT_THERE !=
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::color, value) &&
|
aAttributes->GetAttribute(nsHTMLAtoms::color, value) &&
|
||||||
(eHTMLUnit_Color == value.GetUnit() ||
|
value.GetColorValue(color)) {
|
||||||
eHTMLUnit_ColorName == value.GetUnit())) {
|
|
||||||
nsCSSValue& decoration = aData->mTextData->mDecoration;
|
nsCSSValue& decoration = aData->mTextData->mDecoration;
|
||||||
PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
|
PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
|
||||||
if (decoration.GetUnit() == eCSSUnit_Enumerated) {
|
if (decoration.GetUnit() == eCSSUnit_Enumerated) {
|
||||||
|
|
|
@ -240,19 +240,15 @@ nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::marginwidth) {
|
else if (aAttribute == nsHTMLAtoms::marginwidth) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::marginheight) {
|
else if (aAttribute == nsHTMLAtoms::marginheight) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::noresize) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::scrolling) {
|
else if (aAttribute == nsHTMLAtoms::scrolling) {
|
||||||
if (ParseScrollingValue(aValue, aResult)) {
|
if (ParseScrollingValue(aValue, aResult)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
|
|
|
@ -351,7 +351,7 @@ nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::border) {
|
else if (aAttribute == nsHTMLAtoms::border) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0, 100)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0, 100)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,19 +178,15 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
nsHTMLValue& aResult)
|
nsHTMLValue& aResult)
|
||||||
{
|
{
|
||||||
if (aAttribute == nsHTMLAtoms::width) {
|
if (aAttribute == nsHTMLAtoms::width) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::size) {
|
else if (aAttribute == nsHTMLAtoms::size) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 1, 1000)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 1, 1000)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::noshade) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::align) {
|
else if (aAttribute == nsHTMLAtoms::align) {
|
||||||
if (aResult.ParseEnumValue(aValue, kAlignTable)) {
|
if (aResult.ParseEnumValue(aValue, kAlignTable)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
|
@ -228,19 +224,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
PRBool noshade = PR_FALSE;
|
PRBool noshade = PR_FALSE;
|
||||||
|
|
||||||
nsHTMLValue color;
|
nsHTMLValue colorValue;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::color, color);
|
nscolor color;
|
||||||
|
PRBool colorIsSet = aAttributes->GetAttribute(nsHTMLAtoms::color, colorValue) !=
|
||||||
PRBool colorIsSet = color.GetUnit() == eHTMLUnit_Color ||
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
color.GetUnit() == eHTMLUnit_ColorName;
|
colorValue.GetColorValue(color);
|
||||||
|
|
||||||
if (aData->mSID == eStyleStruct_Position ||
|
if (aData->mSID == eStyleStruct_Position ||
|
||||||
aData->mSID == eStyleStruct_Border) {
|
aData->mSID == eStyleStruct_Border) {
|
||||||
if (colorIsSet) {
|
if (colorIsSet) {
|
||||||
noshade = PR_TRUE;
|
noshade = PR_TRUE;
|
||||||
} else {
|
} else {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::noshade, value);
|
noshade = !!aAttributes->GetAttr(nsHTMLAtoms::noshade);
|
||||||
noshade = value.GetUnit() != eHTMLUnit_Null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,18 +268,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aData->mSID == eStyleStruct_Position) {
|
else if (aData->mSID == eStyleStruct_Position) {
|
||||||
// width: pixel, percent
|
// width: integer, percent
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
// size: pixel
|
// size: integer
|
||||||
if (noshade) {
|
if (noshade) {
|
||||||
// noshade case: size is set using the border
|
// noshade case: size is set using the border
|
||||||
aData->mPositionData->mHeight.SetAutoValue();
|
aData->mPositionData->mHeight.SetAutoValue();
|
||||||
|
@ -294,20 +289,20 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// for size=1, html.css has a special case rule that makes this work by
|
// for size=1, html.css has a special case rule that makes this work by
|
||||||
// removing all but the top border.
|
// removing all but the top border.
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
} // else use default value from html.css
|
} // else use default value from html.css
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aData->mSID == eStyleStruct_Border && noshade) { // if not noshade, border styles are dealt with by html.css
|
else if (aData->mSID == eStyleStruct_Border && noshade) { // if not noshade, border styles are dealt with by html.css
|
||||||
// size: pixel
|
// size: integer
|
||||||
// if a size is set, use half of it per side, otherwise, use 1px per side
|
// if a size is set, use half of it per side, otherwise, use 1px per side
|
||||||
float sizePerSide;
|
float sizePerSide;
|
||||||
PRBool allSides = PR_TRUE;
|
PRBool allSides = PR_TRUE;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
sizePerSide = (float)value.GetPixelValue() / 2.0f;
|
sizePerSide = (float)value.GetIntValue() / 2.0f;
|
||||||
if (sizePerSide < 1.0f) {
|
if (sizePerSide < 1.0f) {
|
||||||
// XXX When the pixel bug is fixed, all the special casing for
|
// XXX When the pixel bug is fixed, all the special casing for
|
||||||
// subpixel borders should be removed.
|
// subpixel borders should be removed.
|
||||||
|
@ -377,7 +372,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// (we got the color attribute earlier)
|
// (we got the color attribute earlier)
|
||||||
if (colorIsSet &&
|
if (colorIsSet &&
|
||||||
aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
||||||
aData->mColorData->mColor.SetColorValue(color.GetColorValue());
|
aData->mColorData->mColor.SetColorValue(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,22 +368,22 @@ nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
nsHTMLValue& aResult)
|
nsHTMLValue& aResult)
|
||||||
{
|
{
|
||||||
if (aAttribute == nsHTMLAtoms::marginwidth) {
|
if (aAttribute == nsHTMLAtoms::marginwidth) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::marginheight) {
|
else if (aAttribute == nsHTMLAtoms::marginheight) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
else if (aAttribute == nsHTMLAtoms::width) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::height) {
|
else if (aAttribute == nsHTMLAtoms::height) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,8 +460,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
|
@ -469,8 +469,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// height: value
|
// height: value
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,13 +261,13 @@ NS_IMPL_STRING_ATTR(nsHTMLImageElement, Name, name)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Align, align)
|
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Align, align)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Alt, alt)
|
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Alt, alt)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Border, border)
|
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Border, border)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLImageElement, Hspace, hspace)
|
NS_IMPL_INT_ATTR(nsHTMLImageElement, Hspace, hspace)
|
||||||
NS_IMPL_BOOL_ATTR(nsHTMLImageElement, IsMap, ismap)
|
NS_IMPL_BOOL_ATTR(nsHTMLImageElement, IsMap, ismap)
|
||||||
NS_IMPL_URI_ATTR(nsHTMLImageElement, LongDesc, longdesc)
|
NS_IMPL_URI_ATTR(nsHTMLImageElement, LongDesc, longdesc)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Lowsrc, lowsrc)
|
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Lowsrc, lowsrc)
|
||||||
NS_IMPL_URI_ATTR_GETTER(nsHTMLImageElement, Src, src)
|
NS_IMPL_URI_ATTR_GETTER(nsHTMLImageElement, Src, src)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
|
NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLImageElement, Vspace, vspace)
|
NS_IMPL_INT_ATTR(nsHTMLImageElement, Vspace, vspace)
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHTMLImageElement::GetImageFrame(nsIImageFrame** aImageFrame)
|
nsHTMLImageElement::GetImageFrame(nsIImageFrame** aImageFrame)
|
||||||
|
@ -423,14 +423,14 @@ nsHTMLImageElement::GetWidthHeight()
|
||||||
|
|
||||||
if (GetHTMLAttribute(nsHTMLAtoms::width,
|
if (GetHTMLAttribute(nsHTMLAtoms::width,
|
||||||
value) == NS_CONTENT_ATTR_HAS_VALUE) {
|
value) == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||||
size.width = value.GetPixelValue();
|
size.width = value.GetIntValue();
|
||||||
} else if (image) {
|
} else if (image) {
|
||||||
image->GetWidth(&size.width);
|
image->GetWidth(&size.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetHTMLAttribute(nsHTMLAtoms::height,
|
if (GetHTMLAttribute(nsHTMLAtoms::height,
|
||||||
value) == NS_CONTENT_ATTR_HAS_VALUE) {
|
value) == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||||
size.height = value.GetPixelValue();
|
size.height = value.GetIntValue();
|
||||||
} else if (image) {
|
} else if (image) {
|
||||||
image->GetHeight(&size.height);
|
image->GetHeight(&size.height);
|
||||||
}
|
}
|
||||||
|
@ -485,10 +485,6 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::ismap) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::src) {
|
else if (aAttribute == nsHTMLAtoms::src) {
|
||||||
static const char* kWhitespace = " \n\r\t\b";
|
static const char* kWhitespace = " \n\r\t\b";
|
||||||
aResult.SetStringValue(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
|
aResult.SetStringValue(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
|
||||||
|
@ -512,9 +508,6 @@ nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult);
|
return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult);
|
||||||
}
|
}
|
||||||
|
@ -655,7 +648,7 @@ nsHTMLImageElement::Initialize(JSContext* aContext, JSObject *aObj,
|
||||||
JSBool ret = JS_ValueToInt32(aContext, argv[0], &width);
|
JSBool ret = JS_ValueToInt32(aContext, argv[0], &width);
|
||||||
NS_ENSURE_TRUE(ret, NS_ERROR_INVALID_ARG);
|
NS_ENSURE_TRUE(ret, NS_ERROR_INVALID_ARG);
|
||||||
|
|
||||||
nsHTMLValue widthVal((PRInt32)width, eHTMLUnit_Pixel);
|
nsHTMLValue widthVal((PRInt32)width, eHTMLUnit_Integer);
|
||||||
|
|
||||||
nsresult rv = SetHTMLAttribute(nsHTMLAtoms::width, widthVal, PR_FALSE);
|
nsresult rv = SetHTMLAttribute(nsHTMLAtoms::width, widthVal, PR_FALSE);
|
||||||
|
|
||||||
|
@ -665,7 +658,7 @@ nsHTMLImageElement::Initialize(JSContext* aContext, JSObject *aObj,
|
||||||
ret = JS_ValueToInt32(aContext, argv[1], &height);
|
ret = JS_ValueToInt32(aContext, argv[1], &height);
|
||||||
NS_ENSURE_TRUE(ret, NS_ERROR_INVALID_ARG);
|
NS_ENSURE_TRUE(ret, NS_ERROR_INVALID_ARG);
|
||||||
|
|
||||||
nsHTMLValue heightVal((PRInt32)height, eHTMLUnit_Pixel);
|
nsHTMLValue heightVal((PRInt32)height, eHTMLUnit_Integer);
|
||||||
|
|
||||||
rv = SetHTMLAttribute(nsHTMLAtoms::height, heightVal, PR_FALSE);
|
rv = SetHTMLAttribute(nsHTMLAtoms::height, heightVal, PR_FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,25 +558,6 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||||
ImageURIChanged(src);
|
ImageURIChanged(src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the type of the input has changed we might need to change the type
|
|
||||||
// of the size attribute.
|
|
||||||
nsHTMLValue value;
|
|
||||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
|
||||||
GetHTMLAttribute(nsHTMLAtoms::size, value)) {
|
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel &&
|
|
||||||
(mType == NS_FORM_INPUT_TEXT ||
|
|
||||||
mType == NS_FORM_INPUT_PASSWORD)) {
|
|
||||||
nsHTMLValue newValue(value.GetPixelValue(), eHTMLUnit_Integer);
|
|
||||||
SetHTMLAttribute(nsHTMLAtoms::size, newValue, PR_FALSE);
|
|
||||||
}
|
|
||||||
else if (value.GetUnit() == eHTMLUnit_Integer &&
|
|
||||||
mType != NS_FORM_INPUT_TEXT &&
|
|
||||||
mType != NS_FORM_INPUT_PASSWORD) {
|
|
||||||
nsHTMLValue newValue(value.GetIntValue(), eHTMLUnit_Pixel);
|
|
||||||
SetHTMLAttribute(nsHTMLAtoms::size, newValue, PR_FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,8 +640,7 @@ nsHTMLInputElement::SetDisabled(PRBool aDisabled)
|
||||||
SET_BOOLBIT(mBitField, BF_DISABLED_CHANGED, PR_TRUE);
|
SET_BOOLBIT(mBitField, BF_DISABLED_CHANGED, PR_TRUE);
|
||||||
|
|
||||||
if (aDisabled) {
|
if (aDisabled) {
|
||||||
nsHTMLValue empty(eHTMLUnit_Empty);
|
return SetHTMLAttribute(nsHTMLAtoms::disabled, nsHTMLValue(), PR_TRUE);
|
||||||
return SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE);
|
UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE);
|
||||||
|
@ -674,13 +654,9 @@ nsHTMLInputElement::GetSize(PRUint32* aValue)
|
||||||
|
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||||
GetHTMLAttribute(nsHTMLAtoms::size, value)) {
|
GetHTMLAttribute(nsHTMLAtoms::size, value) &&
|
||||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
*aValue = value.GetIntValue();
|
*aValue = value.GetIntValue();
|
||||||
}
|
|
||||||
else if (value.GetUnit() == eHTMLUnit_Pixel) {
|
|
||||||
*aValue = value.GetPixelValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -689,14 +665,7 @@ nsHTMLInputElement::GetSize(PRUint32* aValue)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLInputElement::SetSize(PRUint32 aValue)
|
nsHTMLInputElement::SetSize(PRUint32 aValue)
|
||||||
{
|
{
|
||||||
nsHTMLUnit unit = eHTMLUnit_Pixel;
|
nsHTMLValue value(aValue, eHTMLUnit_Integer);
|
||||||
|
|
||||||
if (mType == NS_FORM_INPUT_TEXT ||
|
|
||||||
mType == NS_FORM_INPUT_PASSWORD) {
|
|
||||||
unit = eHTMLUnit_Integer;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsHTMLValue value(aValue, unit);
|
|
||||||
return SetHTMLAttribute(nsHTMLAtoms::size, value, PR_TRUE);
|
return SetHTMLAttribute(nsHTMLAtoms::size, value, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1806,6 +1775,8 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
nsHTMLValue& aResult)
|
nsHTMLValue& aResult)
|
||||||
{
|
{
|
||||||
if (aAttribute == nsHTMLAtoms::type) {
|
if (aAttribute == nsHTMLAtoms::type) {
|
||||||
|
// XXX ARG!! This is major evilness. StringToAttribute
|
||||||
|
// shouldn't set members. Override SetAttr instead
|
||||||
const nsHTMLValue::EnumTable *table = kInputTypeTable;
|
const nsHTMLValue::EnumTable *table = kInputTypeTable;
|
||||||
nsAutoString valueStr(aValue);
|
nsAutoString valueStr(aValue);
|
||||||
while (nsnull != table->tag) {
|
while (nsnull != table->tag) {
|
||||||
|
@ -1825,25 +1796,13 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
// as an HTMLValue.
|
// as an HTMLValue.
|
||||||
mType = NS_FORM_INPUT_TEXT;
|
mType = NS_FORM_INPUT_TEXT;
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::checked) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::disabled) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::readonly) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
else if (aAttribute == nsHTMLAtoms::width) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::height) {
|
else if (aAttribute == nsHTMLAtoms::height) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1853,16 +1812,8 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::size) {
|
else if (aAttribute == nsHTMLAtoms::size) {
|
||||||
if (mType == NS_FORM_INPUT_TEXT ||
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
mType == NS_FORM_INPUT_PASSWORD) {
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::tabindex) {
|
else if (aAttribute == nsHTMLAtoms::tabindex) {
|
||||||
|
@ -1871,7 +1822,7 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::border) {
|
else if (aAttribute == nsHTMLAtoms::border) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1920,13 +1871,6 @@ nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::checked) {
|
|
||||||
aResult.Assign(NS_LITERAL_STRING("checked"));
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
|
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
|
||||||
aResult);
|
aResult);
|
||||||
|
|
|
@ -201,11 +201,13 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
// type: enum
|
// type: enum
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||||
else if (value.GetUnit() != eHTMLUnit_Null)
|
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
else
|
||||||
|
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,11 +237,13 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
// type: enum
|
// type: enum
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||||
else if (value.GetUnit() != eHTMLUnit_Null)
|
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
|
else
|
||||||
|
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,13 +208,13 @@ NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype)
|
||||||
NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data)
|
NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data)
|
||||||
NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
|
NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLObjectElement, Hspace, hspace)
|
NS_IMPL_INT_ATTR(nsHTMLObjectElement, Hspace, hspace)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby)
|
||||||
NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex)
|
NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLObjectElement, Vspace, vspace)
|
NS_IMPL_INT_ATTR(nsHTMLObjectElement, Vspace, vspace)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width)
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,9 +271,6 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
|
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
|
||||||
aResult);
|
aResult);
|
||||||
|
|
|
@ -106,9 +106,6 @@ public:
|
||||||
NS_IMETHOD Initialize(JSContext* aContext, JSObject *aObj,
|
NS_IMETHOD Initialize(JSContext* aContext, JSObject *aObj,
|
||||||
PRUint32 argc, jsval *argv);
|
PRUint32 argc, jsval *argv);
|
||||||
|
|
||||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
|
||||||
const nsAString& aValue,
|
|
||||||
nsHTMLValue& aResult);
|
|
||||||
NS_IMETHOD GetAttributeChangeHint(const nsIAtom* aAttribute,
|
NS_IMETHOD GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||||
PRInt32 aModType,
|
PRInt32 aModType,
|
||||||
nsChangeHint& aHint) const;
|
nsChangeHint& aHint) const;
|
||||||
|
@ -368,17 +365,11 @@ nsHTMLOptionElement::GetDisabled(PRBool* aDisabled)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLOptionElement::SetDisabled(PRBool aDisabled)
|
nsHTMLOptionElement::SetDisabled(PRBool aDisabled)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
|
||||||
nsHTMLValue empty(eHTMLUnit_Empty);
|
|
||||||
|
|
||||||
|
|
||||||
if (aDisabled) {
|
if (aDisabled) {
|
||||||
rv = SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
|
return SetHTMLAttribute(nsHTMLAtoms::disabled, nsHTMLValue(), PR_TRUE);
|
||||||
} else {
|
|
||||||
rv = UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -418,16 +409,11 @@ nsHTMLOptionElement::GetDefaultSelected(PRBool* aDefaultSelected)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLOptionElement::SetDefaultSelected(PRBool aDefaultSelected)
|
nsHTMLOptionElement::SetDefaultSelected(PRBool aDefaultSelected)
|
||||||
{
|
{
|
||||||
nsHTMLValue empty(eHTMLUnit_Empty);
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
|
|
||||||
if (aDefaultSelected) {
|
if (aDefaultSelected) {
|
||||||
rv = SetHTMLAttribute(nsHTMLAtoms::selected, empty, PR_TRUE);
|
return SetHTMLAttribute(nsHTMLAtoms::selected, nsHTMLValue(), PR_TRUE);
|
||||||
} else {
|
|
||||||
rv = UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::selected, PR_TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::selected, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -469,23 +455,6 @@ nsHTMLOptionElement::GetIndex(PRInt32* aIndex)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsHTMLOptionElement::StringToAttribute(nsIAtom* aAttribute,
|
|
||||||
const nsAString& aValue,
|
|
||||||
nsHTMLValue& aResult)
|
|
||||||
{
|
|
||||||
if (aAttribute == nsHTMLAtoms::selected) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::disabled) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLOptionElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
nsHTMLOptionElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||||
PRInt32 aModType,
|
PRInt32 aModType,
|
||||||
|
@ -725,13 +694,8 @@ nsHTMLOptionElement::Initialize(JSContext* aContext,
|
||||||
argv[2],
|
argv[2],
|
||||||
&defaultSelected)) &&
|
&defaultSelected)) &&
|
||||||
(JS_TRUE == defaultSelected)) {
|
(JS_TRUE == defaultSelected)) {
|
||||||
nsHTMLValue empty(eHTMLUnit_Empty);
|
result = SetHTMLAttribute(nsHTMLAtoms::selected, nsHTMLValue(), PR_FALSE);
|
||||||
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
result = SetHTMLAttribute(nsHTMLAtoms::selected, empty, PR_FALSE);
|
|
||||||
|
|
||||||
if (NS_FAILED(result)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX This is *untested* behavior. Should work though.
|
// XXX This is *untested* behavior. Should work though.
|
||||||
|
|
|
@ -197,11 +197,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
nsRuleData* aData)
|
nsRuleData* aData)
|
||||||
{
|
{
|
||||||
if (aData->mSID == eStyleStruct_Font) {
|
if (aData->mSID == eStyleStruct_Font) {
|
||||||
nsHTMLValue value;
|
// variable
|
||||||
|
if (aAttributes->GetAttr(nsHTMLAtoms::variable))
|
||||||
// variable: empty
|
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::variable, value);
|
|
||||||
if (value.GetUnit() == eHTMLUnit_Empty)
|
|
||||||
aData->mFontData->mFamily.SetStringValue(NS_LITERAL_STRING("serif"),
|
aData->mFontData->mFamily.SetStringValue(NS_LITERAL_STRING("serif"),
|
||||||
eCSSUnit_String);
|
eCSSUnit_String);
|
||||||
}
|
}
|
||||||
|
@ -221,13 +218,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
}
|
}
|
||||||
else if (aData->mSID == eStyleStruct_Text) {
|
else if (aData->mSID == eStyleStruct_Text) {
|
||||||
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
|
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
|
||||||
// wrap: empty
|
// wrap: empty
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::wrap, value);
|
if (aAttributes->GetAttr(nsHTMLAtoms::wrap))
|
||||||
if (value.GetUnit() != eHTMLUnit_Null)
|
|
||||||
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated);
|
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated);
|
||||||
|
|
||||||
// cols: int (nav4 attribute)
|
// cols: int (nav4 attribute)
|
||||||
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
// Force wrap property on since we want to wrap at a width
|
// Force wrap property on since we want to wrap at a width
|
||||||
|
|
|
@ -1801,15 +1801,7 @@ nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
const nsAString& aValue,
|
const nsAString& aValue,
|
||||||
nsHTMLValue& aResult)
|
nsHTMLValue& aResult)
|
||||||
{
|
{
|
||||||
if (aAttribute == nsHTMLAtoms::disabled) {
|
if (aAttribute == nsHTMLAtoms::size) {
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::multiple) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::size) {
|
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,10 +262,6 @@ nsHTMLSharedContainerElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 1)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 1)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
} else if (mNodeInfo->Equals(nsHTMLAtoms::dir) &&
|
|
||||||
aAttribute == nsHTMLAtoms::compact) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_NO_VALUE;
|
|
||||||
}
|
}
|
||||||
} else if (mNodeInfo->Equals(nsHTMLAtoms::caption)) {
|
} else if (mNodeInfo->Equals(nsHTMLAtoms::caption)) {
|
||||||
if (aAttribute == nsHTMLAtoms::align) {
|
if (aAttribute == nsHTMLAtoms::align) {
|
||||||
|
@ -353,13 +349,16 @@ MapDirAndMenuAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
// type: enum
|
// type: enum
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
aData->mListData->mType.SetIntValue(value.GetIntValue(),
|
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||||
eCSSUnit_Enumerated);
|
aData->mListData->mType.SetIntValue(value.GetIntValue(),
|
||||||
} else if (value.GetUnit() != eHTMLUnit_Null) {
|
eCSSUnit_Enumerated);
|
||||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC,
|
}
|
||||||
eCSSUnit_Enumerated);
|
else {
|
||||||
|
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC,
|
||||||
|
eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,13 +377,16 @@ MapOlAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
// type: enum
|
// type: enum
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
aData->mListData->mType.SetIntValue(value.GetIntValue(),
|
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||||
eCSSUnit_Enumerated);
|
aData->mListData->mType.SetIntValue(value.GetIntValue(),
|
||||||
} else if (value.GetUnit() != eHTMLUnit_Null) {
|
eCSSUnit_Enumerated);
|
||||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL,
|
}
|
||||||
eCSSUnit_Enumerated);
|
else {
|
||||||
|
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL,
|
||||||
|
eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
||||||
if (aAttribute == nsHTMLAtoms::size) {
|
if (aAttribute == nsHTMLAtoms::size) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
} else if (aAttribute == nsHTMLAtoms::align) {
|
} else if (aAttribute == nsHTMLAtoms::align) {
|
||||||
|
@ -248,7 +248,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
} else if ((aAttribute == nsHTMLAtoms::width) ||
|
} else if ((aAttribute == nsHTMLAtoms::width) ||
|
||||||
(aAttribute == nsHTMLAtoms::height)) {
|
(aAttribute == nsHTMLAtoms::height)) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,8 +268,6 @@ nsHTMLSharedLeafElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
AlignValueToString(aValue, aResult);
|
AlignValueToString(aValue, aResult);
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
} else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
}
|
||||||
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
||||||
if (aAttribute == nsHTMLAtoms::align) {
|
if (aAttribute == nsHTMLAtoms::align) {
|
||||||
|
@ -301,9 +299,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// width: value
|
// width: value
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mWidth.SetPercentValue(value.GetPercentValue());
|
mWidth.SetPercentValue(value.GetPercentValue());
|
||||||
|
@ -313,9 +311,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// height: value
|
// height: value
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mHeight.SetFloatValue((float)value.GetPixelValue(),
|
mHeight.SetFloatValue((float)value.GetIntValue(),
|
||||||
eCSSUnit_Pixel);
|
eCSSUnit_Pixel);
|
||||||
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
|
@ -326,9 +324,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// size: value
|
// size: value
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mWidth.SetFloatValue((float)value.GetPixelValue(),
|
mWidth.SetFloatValue((float)value.GetIntValue(),
|
||||||
eCSSUnit_Pixel);
|
eCSSUnit_Pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,8 +346,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aData->mDisplayData->mDisplay == eCSSUnit_Null) {
|
if (aData->mDisplayData->mDisplay == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (eHTMLUnit_String == value.GetUnit()) {
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
|
eHTMLUnit_String == value.GetUnit()) {
|
||||||
nsAutoString tmp;
|
nsAutoString tmp;
|
||||||
value.GetStringValue(tmp);
|
value.GetStringValue(tmp);
|
||||||
if (tmp.EqualsIgnoreCase("line") ||
|
if (tmp.EqualsIgnoreCase("line") ||
|
||||||
|
|
|
@ -239,7 +239,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
||||||
if (aAttribute == nsHTMLAtoms::size) {
|
if (aAttribute == nsHTMLAtoms::size) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
} else if (aAttribute == nsHTMLAtoms::align) {
|
} else if (aAttribute == nsHTMLAtoms::align) {
|
||||||
|
@ -248,7 +248,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
} else if ((aAttribute == nsHTMLAtoms::width) ||
|
} else if ((aAttribute == nsHTMLAtoms::width) ||
|
||||||
(aAttribute == nsHTMLAtoms::height)) {
|
(aAttribute == nsHTMLAtoms::height)) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,8 +268,6 @@ nsHTMLSharedLeafElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
AlignValueToString(aValue, aResult);
|
AlignValueToString(aValue, aResult);
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
} else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
}
|
||||||
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
|
||||||
if (aAttribute == nsHTMLAtoms::align) {
|
if (aAttribute == nsHTMLAtoms::align) {
|
||||||
|
@ -301,9 +299,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// width: value
|
// width: value
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mWidth.SetPercentValue(value.GetPercentValue());
|
mWidth.SetPercentValue(value.GetPercentValue());
|
||||||
|
@ -313,9 +311,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// height: value
|
// height: value
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mHeight.SetFloatValue((float)value.GetPixelValue(),
|
mHeight.SetFloatValue((float)value.GetIntValue(),
|
||||||
eCSSUnit_Pixel);
|
eCSSUnit_Pixel);
|
||||||
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
|
@ -326,9 +324,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// size: value
|
// size: value
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->
|
aData->mPositionData->
|
||||||
mWidth.SetFloatValue((float)value.GetPixelValue(),
|
mWidth.SetFloatValue((float)value.GetIntValue(),
|
||||||
eCSSUnit_Pixel);
|
eCSSUnit_Pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,8 +346,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aData->mDisplayData->mDisplay == eCSSUnit_Null) {
|
if (aData->mDisplayData->mDisplay == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (eHTMLUnit_String == value.GetUnit()) {
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
|
eHTMLUnit_String == value.GetUnit()) {
|
||||||
nsAutoString tmp;
|
nsAutoString tmp;
|
||||||
value.GetStringValue(tmp);
|
value.GetStringValue(tmp);
|
||||||
if (tmp.EqualsIgnoreCase("line") ||
|
if (tmp.EqualsIgnoreCase("line") ||
|
||||||
|
|
|
@ -208,13 +208,13 @@ NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype)
|
||||||
NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data)
|
NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data)
|
||||||
NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
|
NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLObjectElement, Hspace, hspace)
|
NS_IMPL_INT_ATTR(nsHTMLObjectElement, Hspace, hspace)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby)
|
||||||
NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex)
|
NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap)
|
||||||
NS_IMPL_PIXEL_ATTR(nsHTMLObjectElement, Vspace, vspace)
|
NS_IMPL_INT_ATTR(nsHTMLObjectElement, Vspace, vspace)
|
||||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width)
|
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width)
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,9 +271,6 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
|
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
|
||||||
aResult);
|
aResult);
|
||||||
|
|
|
@ -371,14 +371,14 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
else if (aAttribute == nsHTMLAtoms::height) {
|
else if (aAttribute == nsHTMLAtoms::height) {
|
||||||
/* attributes that resolve to integers or percents */
|
/* attributes that resolve to integers or percents */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
else if (aAttribute == nsHTMLAtoms::width) {
|
||||||
/* attributes that resolve to integers or percents */
|
/* attributes that resolve to integers or percents */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -447,9 +447,9 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
if (value.GetPixelValue() > 0)
|
if (value.GetIntValue() > 0)
|
||||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
// else 0 implies auto for compatibility.
|
// else 0 implies auto for compatibility.
|
||||||
}
|
}
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent) {
|
else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
|
@ -462,9 +462,9 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// height: value
|
// height: value
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
if (value.GetPixelValue() > 0)
|
if (value.GetIntValue() > 0)
|
||||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
// else 0 implies auto for compatibility.
|
// else 0 implies auto for compatibility.
|
||||||
}
|
}
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent) {
|
else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
|
@ -486,12 +486,12 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
|
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
|
||||||
// nowrap: enum
|
// nowrap: enum
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value) !=
|
||||||
if (value.GetUnit() != eHTMLUnit_Null) {
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
// See if our width is not a pixel width.
|
// See if our width is not a integer width.
|
||||||
nsHTMLValue widthValue;
|
nsHTMLValue widthValue;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, widthValue);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, widthValue);
|
||||||
if (widthValue.GetUnit() != eHTMLUnit_Pixel)
|
if (widthValue.GetUnit() != eHTMLUnit_Integer)
|
||||||
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
|
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
else if (aAttribute == nsHTMLAtoms::width) {
|
||||||
/* attributes that resolve to integers or percents or proportions */
|
/* attributes that resolve to integers or percents or proportions */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_TRUE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_TRUE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,11 +234,6 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
|
||||||
if (aValue.ToString(aResult)) {
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult);
|
return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult);
|
||||||
}
|
}
|
||||||
|
@ -250,15 +245,15 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
||||||
aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
// width
|
// width
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::width, value) !=
|
||||||
if (value.GetUnit() != eHTMLUnit_Null) {
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
switch (value.GetUnit()) {
|
switch (value.GetUnit()) {
|
||||||
case eHTMLUnit_Percent: {
|
case eHTMLUnit_Percent: {
|
||||||
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eHTMLUnit_Pixel: {
|
case eHTMLUnit_Integer: {
|
||||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eHTMLUnit_Proportional: {
|
case eHTMLUnit_Proportional: {
|
||||||
|
|
|
@ -947,10 +947,10 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
nsHTMLValue& aResult)
|
nsHTMLValue& aResult)
|
||||||
{
|
{
|
||||||
/* ignore summary, just a string */
|
/* ignore summary, just a string */
|
||||||
/* attributes that resolve to pixels, with min=0 */
|
/* attributes that resolve to integer, with min=0 */
|
||||||
if (aAttribute == nsHTMLAtoms::cellspacing ||
|
if (aAttribute == nsHTMLAtoms::cellspacing ||
|
||||||
aAttribute == nsHTMLAtoms::cellpadding) {
|
aAttribute == nsHTMLAtoms::cellpadding) {
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -962,35 +962,32 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::border) {
|
else if (aAttribute == nsHTMLAtoms::border) {
|
||||||
/* attributes that are either empty, or pixels */
|
/* attributes that are either empty, or integer */
|
||||||
|
|
||||||
PRInt32 min = (aValue.IsEmpty()) ? 1 : 0;
|
PRInt32 min = (aValue.IsEmpty()) ? 1 : 0;
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, min)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, min)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// XXX this should really be NavQuirks only to allow non numeric value
|
// XXX this should really be NavQuirks only to allow non numeric value
|
||||||
aResult.SetPixelValue(1);
|
aResult.SetIntValue(1, eHTMLUnit_Integer);
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::height) {
|
else if (aAttribute == nsHTMLAtoms::height) {
|
||||||
/* attributes that resolve to integers or percents */
|
/* attributes that resolve to integers or percents */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
else if (aAttribute == nsHTMLAtoms::width) {
|
||||||
/* attributes that resolve to integers or percents or proportions */
|
/* attributes that resolve to integers or percents or proportions */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
// treat 0 width as auto
|
// treat 0 width as auto
|
||||||
nsHTMLUnit unit = aResult.GetUnit();
|
nsHTMLUnit unit = aResult.GetUnit();
|
||||||
if ((eHTMLUnit_Pixel == unit) && (0 == aResult.GetPixelValue())) {
|
if ((eHTMLUnit_Integer == unit) && (0 == aResult.GetIntValue())) {
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
|
||||||
}
|
|
||||||
else if ((eHTMLUnit_Integer == unit) && (0 == aResult.GetIntValue())) {
|
|
||||||
return NS_CONTENT_ATTR_NOT_THERE;
|
return NS_CONTENT_ATTR_NOT_THERE;
|
||||||
}
|
}
|
||||||
else if ((eHTMLUnit_Percent == unit) && (0.0f == aResult.GetPercentValue())) {
|
else if ((eHTMLUnit_Percent == unit) && (0.0f == aResult.GetPercentValue())) {
|
||||||
|
@ -1029,7 +1026,7 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::hspace ||
|
else if (aAttribute == nsHTMLAtoms::hspace ||
|
||||||
aAttribute == nsHTMLAtoms::vspace) {
|
aAttribute == nsHTMLAtoms::vspace) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1139,62 +1136,58 @@ MapTableBorderInto(const nsMappedAttributes* aAttributes,
|
||||||
nsRuleData* aData, PRUint8 aBorderStyle)
|
nsRuleData* aData, PRUint8 aBorderStyle)
|
||||||
{
|
{
|
||||||
nsHTMLValue borderValue;
|
nsHTMLValue borderValue;
|
||||||
|
if (aAttributes->GetAttribute(nsHTMLAtoms::border, borderValue) ==
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::border, borderValue);
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
if (borderValue.GetUnit() == eHTMLUnit_Null) {
|
|
||||||
// the absence of "border" with the presence of "frame" implies
|
// the absence of "border" with the presence of "frame" implies
|
||||||
// border = 1 pixel
|
// border = 1 pixel
|
||||||
nsHTMLValue frameValue;
|
if (!aAttributes->GetAttr(nsHTMLAtoms::frame)) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::frame, frameValue);
|
return;
|
||||||
|
}
|
||||||
if (frameValue.GetUnit() != eHTMLUnit_Null)
|
borderValue.SetIntValue(1, eHTMLUnit_Integer);
|
||||||
borderValue.SetPixelValue(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (borderValue.GetUnit() != eHTMLUnit_Null) {
|
if (borderValue.GetUnit() != eHTMLUnit_Integer) {
|
||||||
if (borderValue.GetUnit() != eHTMLUnit_Pixel) {
|
// empty values of border get rules=all and frame=border
|
||||||
// empty values of border get rules=all and frame=border
|
if (aData->mTableData) {
|
||||||
|
aData->mTableData->mRules.SetIntValue(NS_STYLE_TABLE_RULES_ALL, eCSSUnit_Enumerated);
|
||||||
|
aData->mTableData->mFrame.SetIntValue(NS_STYLE_TABLE_FRAME_BORDER, eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
|
borderValue.SetIntValue(1, eHTMLUnit_Integer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PRInt32 borderThickness = borderValue.GetIntValue();
|
||||||
|
|
||||||
|
if (0 != borderThickness) {
|
||||||
|
// border != 0 implies rules=all and frame=border
|
||||||
if (aData->mTableData) {
|
if (aData->mTableData) {
|
||||||
aData->mTableData->mRules.SetIntValue(NS_STYLE_TABLE_RULES_ALL, eCSSUnit_Enumerated);
|
aData->mTableData->mRules.SetIntValue(NS_STYLE_TABLE_RULES_ALL, eCSSUnit_Enumerated);
|
||||||
aData->mTableData->mFrame.SetIntValue(NS_STYLE_TABLE_FRAME_BORDER, eCSSUnit_Enumerated);
|
aData->mTableData->mFrame.SetIntValue(NS_STYLE_TABLE_FRAME_BORDER, eCSSUnit_Enumerated);
|
||||||
}
|
}
|
||||||
borderValue.SetPixelValue(1);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PRInt32 borderThickness = borderValue.GetPixelValue();
|
// border = 0 implies rules=none and frame=void
|
||||||
|
if (aData->mTableData) {
|
||||||
if (0 != borderThickness) {
|
aData->mTableData->mRules.SetIntValue(NS_STYLE_TABLE_RULES_NONE, eCSSUnit_Enumerated);
|
||||||
// border != 0 implies rules=all and frame=border
|
aData->mTableData->mFrame.SetIntValue(NS_STYLE_TABLE_FRAME_NONE, eCSSUnit_Enumerated);
|
||||||
if (aData->mTableData) {
|
|
||||||
aData->mTableData->mRules.SetIntValue(NS_STYLE_TABLE_RULES_ALL, eCSSUnit_Enumerated);
|
|
||||||
aData->mTableData->mFrame.SetIntValue(NS_STYLE_TABLE_FRAME_BORDER, eCSSUnit_Enumerated);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// border = 0 implies rules=none and frame=void
|
|
||||||
if (aData->mTableData) {
|
|
||||||
aData->mTableData->mRules.SetIntValue(NS_STYLE_TABLE_RULES_NONE, eCSSUnit_Enumerated);
|
|
||||||
aData->mTableData->mFrame.SetIntValue(NS_STYLE_TABLE_FRAME_NONE, eCSSUnit_Enumerated);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PRInt32 borderThickness = borderValue.GetPixelValue();
|
PRInt32 borderThickness = borderValue.GetIntValue();
|
||||||
|
|
||||||
if (aData->mMarginData) {
|
if (aData->mMarginData) {
|
||||||
// by default, set all border sides to the specified width
|
// by default, set all border sides to the specified width
|
||||||
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||||
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mMarginData->mBorderWidth.mRight.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
aData->mMarginData->mBorderWidth.mRight.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||||
if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mMarginData->mBorderWidth.mTop .SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
aData->mMarginData->mBorderWidth.mTop .SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||||
if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mMarginData->mBorderWidth.mBottom.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
aData->mMarginData->mBorderWidth.mBottom.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||||
|
|
||||||
// now account for the frame attribute
|
// now account for the frame attribute
|
||||||
MapTableFrameInto(aAttributes, aData, aBorderStyle);
|
MapTableFrameInto(aAttributes, aData, aBorderStyle);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1220,11 +1213,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// cellspacing
|
// cellspacing
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::cellspacing, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::cellspacing, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
if (aData->mTableData->mBorderSpacingX.GetUnit() == eCSSUnit_Null)
|
if (aData->mTableData->mBorderSpacingX.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mTableData->mBorderSpacingX.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mTableData->mBorderSpacingX.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
if (aData->mTableData->mBorderSpacingY.GetUnit() == eCSSUnit_Null)
|
if (aData->mTableData->mBorderSpacingY.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mTableData->mBorderSpacingY.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mTableData->mBorderSpacingY.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
}
|
}
|
||||||
else if ((value.GetUnit() == eHTMLUnit_Percent) && (eCompatibility_NavQuirks == mode)) {
|
else if ((value.GetUnit() == eHTMLUnit_Percent) && (eCompatibility_NavQuirks == mode)) {
|
||||||
// in quirks mode, treat a % cellspacing value a pixel value.
|
// in quirks mode, treat a % cellspacing value a pixel value.
|
||||||
|
@ -1249,8 +1242,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
}
|
}
|
||||||
|
|
||||||
// cols
|
// cols
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::cols, value) !=
|
||||||
if (value.GetUnit() != eHTMLUnit_Null) {
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mTableData->mCols.SetIntValue(value.GetIntValue(), eCSSUnit_Integer);
|
aData->mTableData->mCols.SetIntValue(value.GetIntValue(), eCSSUnit_Integer);
|
||||||
else // COLS had no value, so it refers to all columns
|
else // COLS had no value, so it refers to all columns
|
||||||
|
@ -1289,22 +1282,22 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
if (eCompatibility_NavQuirks == mode) {
|
if (eCompatibility_NavQuirks == mode) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
|
||||||
|
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||||
margin.mLeft.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
margin.mLeft.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||||
margin.mRight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
margin.mRight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
|
||||||
|
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||||
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
||||||
margin.mTop.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
margin.mTop.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
||||||
margin.mBottom.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
margin.mBottom.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1315,12 +1308,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
if (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
|
if (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel || value.GetUnit() == eHTMLUnit_Percent) {
|
if (value.GetUnit() == eHTMLUnit_Integer || value.GetUnit() == eHTMLUnit_Percent) {
|
||||||
// We have cellpadding. This will override our padding values if we don't
|
// We have cellpadding. This will override our padding values if we don't
|
||||||
// have any set.
|
// have any set.
|
||||||
nsCSSValue padVal;
|
nsCSSValue padVal;
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
padVal.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
padVal.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else {
|
else {
|
||||||
// when we support % cellpadding in standard mode, uncomment the following
|
// when we support % cellpadding in standard mode, uncomment the following
|
||||||
float pctVal = value.GetPercentValue();
|
float pctVal = value.GetPercentValue();
|
||||||
|
@ -1351,8 +1344,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// width: value
|
// width: value
|
||||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
|
@ -1360,8 +1353,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// height: value
|
// height: value
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
|
@ -1382,10 +1375,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
// Set the cell's border from the table in the separate border model. If there is a border
|
// Set the cell's border from the table in the separate border model. If there is a border
|
||||||
// on the table, then the mapping to rules=all will take care of borders in the collapsing model.
|
// on the table, then the mapping to rules=all will take care of borders in the collapsing model.
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::border, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::border, value) !=
|
||||||
if (((value.GetUnit() == eHTMLUnit_Pixel) &&
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
(value.GetPixelValue() > 0)) ||
|
((value.GetUnit() == eHTMLUnit_Integer &&
|
||||||
(value.GetUnit() == eHTMLUnit_Empty)) {
|
value.GetIntValue() > 0) ||
|
||||||
|
value.IsEmptyString())) {
|
||||||
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue(1.0f, eCSSUnit_Pixel);
|
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue(1.0f, eCSSUnit_Pixel);
|
||||||
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
|
||||||
|
@ -1424,10 +1418,10 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
NS_STYLE_BORDER_STYLE_OUTSET;
|
NS_STYLE_BORDER_STYLE_OUTSET;
|
||||||
// bordercolor
|
// bordercolor
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::bordercolor, value);
|
nscolor color;
|
||||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
if (aAttributes->GetAttribute(nsHTMLAtoms::bordercolor, value) !=
|
||||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
NS_CONTENT_ATTR_NOT_THERE &&
|
||||||
nscolor color = value.GetColorValue();
|
value.GetColorValue(color)) {
|
||||||
if (aData->mMarginData->mBorderColor.mLeft.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderColor.mLeft.GetUnit() == eCSSUnit_Null)
|
||||||
aData->mMarginData->mBorderColor.mLeft.SetColorValue(color);
|
aData->mMarginData->mBorderColor.mLeft.SetColorValue(color);
|
||||||
if (aData->mMarginData->mBorderColor.mRight.GetUnit() == eCSSUnit_Null)
|
if (aData->mMarginData->mBorderColor.mRight.GetUnit() == eCSSUnit_Null)
|
||||||
|
|
|
@ -526,14 +526,14 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
else if (aAttribute == nsHTMLAtoms::height) {
|
else if (aAttribute == nsHTMLAtoms::height) {
|
||||||
/* attributes that resolve to integers or percents */
|
/* attributes that resolve to integers or percents */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::width) {
|
else if (aAttribute == nsHTMLAtoms::width) {
|
||||||
/* attributes that resolve to integers or percents */
|
/* attributes that resolve to integers or percents */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,8 +591,8 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||||
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
else if (aAttribute == nsHTMLAtoms::height) {
|
else if (aAttribute == nsHTMLAtoms::height) {
|
||||||
/* attributes that resolve to integers or percents */
|
/* attributes that resolve to integers or percents */
|
||||||
|
|
||||||
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
|
if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Integer, PR_TRUE, PR_FALSE)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,8 +357,8 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||||
if (value.GetUnit() == eHTMLUnit_Pixel)
|
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
|
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aData->mSID == eStyleStruct_Text) {
|
else if (aData->mSID == eStyleStruct_Text) {
|
||||||
|
|
|
@ -584,19 +584,11 @@ nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute,
|
||||||
const nsAString& aValue,
|
const nsAString& aValue,
|
||||||
nsHTMLValue& aResult)
|
nsHTMLValue& aResult)
|
||||||
{
|
{
|
||||||
if (aAttribute == nsHTMLAtoms::disabled) {
|
if (aAttribute == nsHTMLAtoms::cols) {
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::cols) {
|
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsHTMLAtoms::readonly) {
|
|
||||||
aResult.SetEmptyValue();
|
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
||||||
}
|
|
||||||
else if (aAttribute == nsHTMLAtoms::rows) {
|
else if (aAttribute == nsHTMLAtoms::rows) {
|
||||||
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
|
||||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||||
|
|
|
@ -218,11 +218,13 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
// type: enum
|
// type: enum
|
||||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
NS_CONTENT_ATTR_NOT_THERE) {
|
||||||
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||||
else if (value.GetUnit() != eHTMLUnit_Null)
|
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
else
|
||||||
|
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2644,7 +2644,9 @@ nsHTMLDocument::SetAlinkColor(const nsAString& aAlinkColor)
|
||||||
} else if (mAttrStyleSheet) {
|
} else if (mAttrStyleSheet) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (value.ParseColor(aAlinkColor, this)) {
|
if (value.ParseColor(aAlinkColor, this)) {
|
||||||
mAttrStyleSheet->SetActiveLinkColor(value.GetColorValue());
|
nscolor color;
|
||||||
|
value.GetColorValue(color);
|
||||||
|
mAttrStyleSheet->SetActiveLinkColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2684,7 +2686,9 @@ nsHTMLDocument::SetLinkColor(const nsAString& aLinkColor)
|
||||||
} else if (mAttrStyleSheet) {
|
} else if (mAttrStyleSheet) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (value.ParseColor(aLinkColor, this)) {
|
if (value.ParseColor(aLinkColor, this)) {
|
||||||
mAttrStyleSheet->SetLinkColor(value.GetColorValue());
|
nscolor color;
|
||||||
|
value.GetColorValue(color);
|
||||||
|
mAttrStyleSheet->SetLinkColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2724,7 +2728,9 @@ nsHTMLDocument::SetVlinkColor(const nsAString& aVlinkColor)
|
||||||
} else if (mAttrStyleSheet) {
|
} else if (mAttrStyleSheet) {
|
||||||
nsHTMLValue value;
|
nsHTMLValue value;
|
||||||
if (value.ParseColor(aVlinkColor, this)) {
|
if (value.ParseColor(aVlinkColor, this)) {
|
||||||
mAttrStyleSheet->SetVisitedLinkColor(value.GetColorValue());
|
nscolor color;
|
||||||
|
value.GetColorValue(color);
|
||||||
|
mAttrStyleSheet->SetVisitedLinkColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ nsPluginDocument::CreateSyntheticPluginDocument()
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove margins from body
|
// remove margins from body
|
||||||
nsHTMLValue zero(0, eHTMLUnit_Pixel);
|
nsHTMLValue zero(0, eHTMLUnit_Integer);
|
||||||
body->SetHTMLAttribute(nsHTMLAtoms::marginwidth, zero, PR_FALSE);
|
body->SetHTMLAttribute(nsHTMLAtoms::marginwidth, zero, PR_FALSE);
|
||||||
body->SetHTMLAttribute(nsHTMLAtoms::marginheight, zero, PR_FALSE);
|
body->SetHTMLAttribute(nsHTMLAtoms::marginheight, zero, PR_FALSE);
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,6 @@ HTML_ATOM(strike, "strike")
|
||||||
HTML_ATOM(strong, "strong")
|
HTML_ATOM(strong, "strong")
|
||||||
HTML_ATOM(style, "style")
|
HTML_ATOM(style, "style")
|
||||||
HTML_ATOM(summary, "summary")
|
HTML_ATOM(summary, "summary")
|
||||||
HTML_ATOM(suppress, "suppress")
|
|
||||||
HTML_ATOM(tabindex, "tabindex")
|
HTML_ATOM(tabindex, "tabindex")
|
||||||
HTML_ATOM(table, "table")
|
HTML_ATOM(table, "table")
|
||||||
HTML_ATOM(tabstop, "tabstop")
|
HTML_ATOM(tabstop, "tabstop")
|
||||||
|
|
|
@ -148,10 +148,8 @@ public:
|
||||||
// between different things stored as the same type. Doing
|
// between different things stored as the same type. Doing
|
||||||
// mUnit & HTMLUNIT_CLASS_MASK should give you the class of type.
|
// mUnit & HTMLUNIT_CLASS_MASK should give you the class of type.
|
||||||
//
|
//
|
||||||
#define HTMLUNIT_NOSTORE 0x0000
|
|
||||||
#define HTMLUNIT_STRING 0x0100
|
#define HTMLUNIT_STRING 0x0100
|
||||||
#define HTMLUNIT_INTEGER 0x0200
|
#define HTMLUNIT_INTEGER 0x0200
|
||||||
#define HTMLUNIT_PIXEL 0x0400
|
|
||||||
#define HTMLUNIT_COLOR 0x0800
|
#define HTMLUNIT_COLOR 0x0800
|
||||||
#define HTMLUNIT_CSSSTYLERULE 0x1000
|
#define HTMLUNIT_CSSSTYLERULE 0x1000
|
||||||
#define HTMLUNIT_PERCENT 0x2000
|
#define HTMLUNIT_PERCENT 0x2000
|
||||||
|
@ -159,15 +157,8 @@ public:
|
||||||
#define HTMLUNIT_CLASS_MASK 0xff00
|
#define HTMLUNIT_CLASS_MASK 0xff00
|
||||||
|
|
||||||
enum nsHTMLUnit {
|
enum nsHTMLUnit {
|
||||||
// null, value is not specified: 0x0000
|
|
||||||
eHTMLUnit_Null = HTMLUNIT_NOSTORE,
|
|
||||||
// empty, value is not specified: 0x0001
|
|
||||||
eHTMLUnit_Empty = HTMLUNIT_NOSTORE | 1,
|
|
||||||
|
|
||||||
// a string value
|
// a string value
|
||||||
eHTMLUnit_String = HTMLUNIT_STRING,
|
eHTMLUnit_String = HTMLUNIT_STRING,
|
||||||
// a color name value
|
|
||||||
eHTMLUnit_ColorName = HTMLUNIT_STRING | 1,
|
|
||||||
|
|
||||||
// a simple int value
|
// a simple int value
|
||||||
eHTMLUnit_Integer = HTMLUNIT_INTEGER,
|
eHTMLUnit_Integer = HTMLUNIT_INTEGER,
|
||||||
|
@ -176,9 +167,6 @@ enum nsHTMLUnit {
|
||||||
// value is a relative proportion of some whole
|
// value is a relative proportion of some whole
|
||||||
eHTMLUnit_Proportional = HTMLUNIT_INTEGER | 2,
|
eHTMLUnit_Proportional = HTMLUNIT_INTEGER | 2,
|
||||||
|
|
||||||
// screen pixels (screen relative measure)
|
|
||||||
eHTMLUnit_Pixel = HTMLUNIT_PIXEL,
|
|
||||||
|
|
||||||
// an RGBA value
|
// an RGBA value
|
||||||
eHTMLUnit_Color = HTMLUNIT_COLOR,
|
eHTMLUnit_Color = HTMLUNIT_COLOR,
|
||||||
|
|
||||||
|
@ -200,7 +188,7 @@ enum nsHTMLUnit {
|
||||||
*/
|
*/
|
||||||
class nsHTMLValue {
|
class nsHTMLValue {
|
||||||
public:
|
public:
|
||||||
nsHTMLValue(nsHTMLUnit aUnit = eHTMLUnit_Null);
|
nsHTMLValue();
|
||||||
nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
||||||
nsHTMLValue(float aValue);
|
nsHTMLValue(float aValue);
|
||||||
nsHTMLValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
nsHTMLValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
||||||
|
@ -222,24 +210,23 @@ public:
|
||||||
nsHTMLUnit GetUnit(void) const { return (nsHTMLUnit)mUnit; }
|
nsHTMLUnit GetUnit(void) const { return (nsHTMLUnit)mUnit; }
|
||||||
|
|
||||||
PRInt32 GetIntValue(void) const;
|
PRInt32 GetIntValue(void) const;
|
||||||
PRInt32 GetPixelValue(void) const;
|
|
||||||
float GetPercentValue(void) const;
|
float GetPercentValue(void) const;
|
||||||
nsAString& GetStringValue(nsAString& aBuffer) const;
|
nsAString& GetStringValue(nsAString& aBuffer) const;
|
||||||
nsICSSStyleRule* GetCSSStyleRuleValue(void) const;
|
nsICSSStyleRule* GetCSSStyleRuleValue(void) const;
|
||||||
nscolor GetColorValue(void) const;
|
PRBool GetColorValue(nscolor& aColor) const;
|
||||||
nsCOMArray<nsIAtom>* AtomArrayValue() const;
|
nsCOMArray<nsIAtom>* AtomArrayValue() const;
|
||||||
|
|
||||||
|
PRBool IsEmptyString() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the string to null type, freeing things in the process if necessary.
|
* Reset the string to null type, freeing things in the process if necessary.
|
||||||
*/
|
*/
|
||||||
void Reset(void);
|
void Reset(void);
|
||||||
void SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
void SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit);
|
||||||
void SetPixelValue(PRInt32 aValue);
|
|
||||||
void SetPercentValue(float aValue);
|
void SetPercentValue(float aValue);
|
||||||
void SetStringValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
void SetStringValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
|
||||||
void SetCSSStyleRuleValue(nsICSSStyleRule* aValue);
|
void SetCSSStyleRuleValue(nsICSSStyleRule* aValue);
|
||||||
void SetColorValue(nscolor aValue);
|
void SetColorValue(nscolor aValue);
|
||||||
void SetEmptyValue(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get this HTML value as a string (depends on the type)
|
* Get this HTML value as a string (depends on the type)
|
||||||
|
@ -295,10 +282,10 @@ public:
|
||||||
nsAString& aResult) const;
|
nsAString& aResult) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string value into an int or pixel HTMLValue.
|
* Parse a string value into an int HTMLValue.
|
||||||
*
|
*
|
||||||
* @param aString the string to parse
|
* @param aString the string to parse
|
||||||
* @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
|
* @param aDefaultUnit the unit to use
|
||||||
* @return whether the value could be parsed
|
* @return whether the value could be parsed
|
||||||
*/
|
*/
|
||||||
PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit) {
|
PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit) {
|
||||||
|
@ -306,13 +293,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string value into an int or pixel HTMLValue with minimum
|
* Parse a string value into an int HTMLValue with minimum
|
||||||
* value and maximum value (can optionally parse percent (n%) and
|
* value and maximum value (can optionally parse percent (n%) and
|
||||||
* proportional (n%). This method explicitly sets a lower bound of zero on
|
* proportional (n*). This method explicitly sets a lower bound of zero on
|
||||||
* the element, whether it be proportional or percent or raw integer.
|
* the element, whether it be proportional or percent or raw integer.
|
||||||
*
|
*
|
||||||
* @param aString the string to parse
|
* @param aString the string to parse
|
||||||
* @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
|
* @param aDefaultUnit the unit to use
|
||||||
* @param aCanBePercent true if it can be a percent value (%)
|
* @param aCanBePercent true if it can be a percent value (%)
|
||||||
* @param aCanBeProportional true if it can be a proportional value (*)
|
* @param aCanBeProportional true if it can be a proportional value (*)
|
||||||
* @return whether the value could be parsed
|
* @return whether the value could be parsed
|
||||||
|
@ -322,13 +309,13 @@ public:
|
||||||
PRBool aCanBeProportional);
|
PRBool aCanBeProportional);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string value into an int or pixel HTMLValue with minimum
|
* Parse a string value into an int HTMLValue with minimum
|
||||||
* value and maximum value
|
* value and maximum value
|
||||||
*
|
*
|
||||||
* @param aString the string to parse
|
* @param aString the string to parse
|
||||||
* @param aMin the minimum value (if value is less it will be bumped up)
|
* @param aMin the minimum value (if value is less it will be bumped up)
|
||||||
* @param aMax the maximum value (if value is greater it will be chopped down)
|
* @param aMax the maximum value (if value is greater it will be chopped down)
|
||||||
* @param aValueUnit the unit to use (eHTMLUnit_Pixel or Integer)
|
* @param aValueUnit the unit to use
|
||||||
* @return whether the value could be parsed
|
* @return whether the value could be parsed
|
||||||
*/
|
*/
|
||||||
PRBool ParseIntWithBounds(const nsAString& aString, nsHTMLUnit aValueUnit,
|
PRBool ParseIntWithBounds(const nsAString& aString, nsHTMLUnit aValueUnit,
|
||||||
|
@ -432,15 +419,6 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PRInt32 nsHTMLValue::GetPixelValue(void) const
|
|
||||||
{
|
|
||||||
NS_ASSERTION((mUnit == eHTMLUnit_Pixel), "not a pixel value");
|
|
||||||
if (mUnit == eHTMLUnit_Pixel) {
|
|
||||||
return mValue.mInt;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float nsHTMLValue::GetPercentValue(void) const
|
inline float nsHTMLValue::GetPercentValue(void) const
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mUnit == eHTMLUnit_Percent, "not a percent value");
|
NS_ASSERTION(mUnit == eHTMLUnit_Percent, "not a percent value");
|
||||||
|
@ -452,7 +430,7 @@ inline float nsHTMLValue::GetPercentValue(void) const
|
||||||
|
|
||||||
inline nsAString& nsHTMLValue::GetStringValue(nsAString& aBuffer) const
|
inline nsAString& nsHTMLValue::GetStringValue(nsAString& aBuffer) const
|
||||||
{
|
{
|
||||||
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING || mUnit == eHTMLUnit_Null,
|
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING,
|
||||||
"not a string value");
|
"not a string value");
|
||||||
if (GetUnitClass() == HTMLUNIT_STRING && mValue.mString) {
|
if (GetUnitClass() == HTMLUNIT_STRING && mValue.mString) {
|
||||||
aBuffer = GetDependentString();
|
aBuffer = GetDependentString();
|
||||||
|
@ -471,20 +449,19 @@ inline nsICSSStyleRule* nsHTMLValue::GetCSSStyleRuleValue(void) const
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline nscolor nsHTMLValue::GetColorValue(void) const
|
inline PRBool nsHTMLValue::GetColorValue(nscolor& aColor) const
|
||||||
{
|
{
|
||||||
NS_ASSERTION((mUnit == eHTMLUnit_Color) || (mUnit == eHTMLUnit_ColorName),
|
NS_ASSERTION((mUnit == eHTMLUnit_Color) || (mUnit == eHTMLUnit_String),
|
||||||
"not a color value");
|
"not a color value");
|
||||||
if (mUnit == eHTMLUnit_Color) {
|
if (mUnit == eHTMLUnit_Color) {
|
||||||
return mValue.mColor;
|
aColor = mValue.mColor;
|
||||||
|
|
||||||
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
if (mUnit == eHTMLUnit_ColorName) {
|
if (mUnit == eHTMLUnit_String && mValue.mString) {
|
||||||
nscolor color;
|
return NS_ColorNameToRGB(GetDependentString(), &aColor);
|
||||||
if (NS_ColorNameToRGB(GetDependentString(), &color)) {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NS_RGB(0,0,0);
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline nsCOMArray<nsIAtom>*
|
inline nsCOMArray<nsIAtom>*
|
||||||
|
@ -499,5 +476,10 @@ inline PRBool nsHTMLValue::operator!=(const nsHTMLValue& aOther) const
|
||||||
return PRBool(! ((*this) == aOther));
|
return PRBool(! ((*this) == aOther));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline PRBool nsHTMLValue::IsEmptyString() const
|
||||||
|
{
|
||||||
|
return mUnit == eHTMLUnit_String && !mValue.mString;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* nsHTMLValue_h___ */
|
#endif /* nsHTMLValue_h___ */
|
||||||
|
|
||||||
|
|
|
@ -50,26 +50,20 @@
|
||||||
#include "nsICSSStyleRule.h"
|
#include "nsICSSStyleRule.h"
|
||||||
#include "nsCSSDeclaration.h"
|
#include "nsCSSDeclaration.h"
|
||||||
|
|
||||||
nsHTMLValue::nsHTMLValue(nsHTMLUnit aUnit)
|
nsHTMLValue::nsHTMLValue()
|
||||||
: mUnit(aUnit)
|
: mUnit(eHTMLUnit_String)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(GetUnitClass() == HTMLUNIT_NOSTORE, "not a valueless unit");
|
|
||||||
if (GetUnitClass() != HTMLUNIT_NOSTORE) {
|
|
||||||
mUnit = eHTMLUnit_Null;
|
|
||||||
}
|
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsHTMLValue::nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit)
|
nsHTMLValue::nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit)
|
||||||
: mUnit(aUnit)
|
: mUnit(aUnit)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER ||
|
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER, "unit not an integer unit");
|
||||||
GetUnitClass() == HTMLUNIT_PIXEL, "unit not an integer unit");
|
if (GetUnitClass() == HTMLUNIT_INTEGER) {
|
||||||
if (GetUnitClass() == HTMLUNIT_INTEGER ||
|
|
||||||
GetUnitClass() == HTMLUNIT_PIXEL) {
|
|
||||||
mValue.mInt = aValue;
|
mValue.mInt = aValue;
|
||||||
} else {
|
} else {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,9 +124,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
||||||
// Call GetUnitClass() so that we turn StringWithLength into String
|
// Call GetUnitClass() so that we turn StringWithLength into String
|
||||||
PRUint32 unitClass = GetUnitClass();
|
PRUint32 unitClass = GetUnitClass();
|
||||||
switch (unitClass) {
|
switch (unitClass) {
|
||||||
case HTMLUNIT_NOSTORE:
|
|
||||||
return PR_TRUE;
|
|
||||||
|
|
||||||
case HTMLUNIT_STRING:
|
case HTMLUNIT_STRING:
|
||||||
if (mValue.mString && aOther.mValue.mString) {
|
if (mValue.mString && aOther.mValue.mString) {
|
||||||
return GetDependentString().Equals(aOther.GetDependentString());
|
return GetDependentString().Equals(aOther.GetDependentString());
|
||||||
|
@ -141,7 +132,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
||||||
return mValue.mString == aOther.mValue.mString;
|
return mValue.mString == aOther.mValue.mString;
|
||||||
|
|
||||||
case HTMLUNIT_INTEGER:
|
case HTMLUNIT_INTEGER:
|
||||||
case HTMLUNIT_PIXEL:
|
|
||||||
return mValue.mInt == aOther.mValue.mInt;
|
return mValue.mInt == aOther.mValue.mInt;
|
||||||
|
|
||||||
case HTMLUNIT_COLOR:
|
case HTMLUNIT_COLOR:
|
||||||
|
@ -211,7 +201,7 @@ void nsHTMLValue::Reset(void)
|
||||||
else if (mUnit == eHTMLUnit_AtomArray) {
|
else if (mUnit == eHTMLUnit_AtomArray) {
|
||||||
delete mValue.mAtomArray;
|
delete mValue.mAtomArray;
|
||||||
}
|
}
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,17 +214,11 @@ void nsHTMLValue::SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit)
|
||||||
if (GetUnitClass() == HTMLUNIT_INTEGER) {
|
if (GetUnitClass() == HTMLUNIT_INTEGER) {
|
||||||
mValue.mInt = aValue;
|
mValue.mInt = aValue;
|
||||||
} else {
|
} else {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLValue::SetPixelValue(PRInt32 aValue)
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
mUnit = eHTMLUnit_Pixel;
|
|
||||||
mValue.mInt = aValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsHTMLValue::SetPercentValue(float aValue)
|
void nsHTMLValue::SetPercentValue(float aValue)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
@ -254,7 +238,7 @@ void nsHTMLValue::SetStringValueInternal(const nsAString& aValue,
|
||||||
nsCheapStringBufferUtils::CopyToBuffer(mValue.mString, aValue);
|
nsCheapStringBufferUtils::CopyToBuffer(mValue.mString, aValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
mValue.mString = nsnull;
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,21 +266,11 @@ void nsHTMLValue::SetColorValue(nscolor aValue)
|
||||||
mValue.mColor = aValue;
|
mValue.mColor = aValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLValue::SetEmptyValue(void)
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
mUnit = eHTMLUnit_Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
||||||
{
|
{
|
||||||
mUnit = aCopy.mUnit;
|
mUnit = aCopy.mUnit;
|
||||||
switch (GetUnitClass()) {
|
switch (GetUnitClass()) {
|
||||||
case HTMLUNIT_NOSTORE:
|
|
||||||
mValue.mString = nsnull;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HTMLUNIT_STRING:
|
case HTMLUNIT_STRING:
|
||||||
if (aCopy.mValue.mString) {
|
if (aCopy.mValue.mString) {
|
||||||
nsCheapStringBufferUtils::Clone(mValue.mString, aCopy.mValue.mString);
|
nsCheapStringBufferUtils::Clone(mValue.mString, aCopy.mValue.mString);
|
||||||
|
@ -306,7 +280,6 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HTMLUNIT_INTEGER:
|
case HTMLUNIT_INTEGER:
|
||||||
case HTMLUNIT_PIXEL:
|
|
||||||
mValue.mInt = aCopy.mValue.mInt;
|
mValue.mInt = aCopy.mValue.mInt;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -326,7 +299,8 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
|
||||||
case HTMLUNIT_ATOMARRAY:
|
case HTMLUNIT_ATOMARRAY:
|
||||||
mValue.mAtomArray = new nsCOMArray<nsIAtom>(*aCopy.mValue.mAtomArray);
|
mValue.mAtomArray = new nsCOMArray<nsIAtom>(*aCopy.mValue.mAtomArray);
|
||||||
if (!mValue.mAtomArray) {
|
if (!mValue.mAtomArray) {
|
||||||
mUnit = eHTMLUnit_Null;
|
mUnit = eHTMLUnit_String;
|
||||||
|
mValue.mString = nsnull;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -411,11 +385,7 @@ nsHTMLValue::ParseSpecialIntValue(const nsAString& aString,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Straight number is interpreted with the default unit
|
// Straight number is interpreted with the default unit
|
||||||
if (aDefaultUnit == eHTMLUnit_Pixel) {
|
SetIntValue(val, aDefaultUnit);
|
||||||
SetPixelValue(val);
|
|
||||||
} else {
|
|
||||||
SetIntValue(val, aDefaultUnit);
|
|
||||||
}
|
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,11 +418,6 @@ nsHTMLValue::ToString(nsAString& aResult) const
|
||||||
}
|
}
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
|
||||||
case eHTMLUnit_Pixel:
|
|
||||||
intStr.AppendInt(GetPixelValue());
|
|
||||||
aResult.Append(intStr);
|
|
||||||
return PR_TRUE;
|
|
||||||
|
|
||||||
case eHTMLUnit_Percent:
|
case eHTMLUnit_Percent:
|
||||||
{
|
{
|
||||||
float percentVal = GetPercentValue() * 100.0f;
|
float percentVal = GetPercentValue() * 100.0f;
|
||||||
|
@ -463,14 +428,14 @@ nsHTMLValue::ToString(nsAString& aResult) const
|
||||||
}
|
}
|
||||||
case eHTMLUnit_Color:
|
case eHTMLUnit_Color:
|
||||||
{
|
{
|
||||||
nscolor v = GetColorValue();
|
nscolor v;
|
||||||
|
GetColorValue(v);
|
||||||
char buf[10];
|
char buf[10];
|
||||||
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
||||||
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
||||||
AppendASCIItoUTF16(buf, aResult);
|
AppendASCIItoUTF16(buf, aResult);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
case eHTMLUnit_ColorName:
|
|
||||||
case eHTMLUnit_String:
|
case eHTMLUnit_String:
|
||||||
GetStringValue(aResult);
|
GetStringValue(aResult);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
@ -516,11 +481,7 @@ nsHTMLValue::ParseIntWithBounds(const nsAString& aString,
|
||||||
if (NS_SUCCEEDED(ec)) {
|
if (NS_SUCCEEDED(ec)) {
|
||||||
val = PR_MAX(val, aMin);
|
val = PR_MAX(val, aMin);
|
||||||
val = PR_MIN(val, aMax);
|
val = PR_MIN(val, aMax);
|
||||||
if (aDefaultUnit == eHTMLUnit_Pixel) {
|
SetIntValue(val, aDefaultUnit);
|
||||||
SetPixelValue(val);
|
|
||||||
} else {
|
|
||||||
SetIntValue(val, aDefaultUnit);
|
|
||||||
}
|
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +510,7 @@ nsHTMLValue::ParseColor(const nsAString& aString, nsIDocument* aDocument)
|
||||||
// No color names begin with a '#', but numerical colors do so
|
// No color names begin with a '#', but numerical colors do so
|
||||||
// it is a very common first char
|
// it is a very common first char
|
||||||
if ((colorStr.CharAt(0) != '#') && NS_ColorNameToRGB(colorStr, &color)) {
|
if ((colorStr.CharAt(0) != '#') && NS_ColorNameToRGB(colorStr, &color)) {
|
||||||
SetStringValue(colorStr, eHTMLUnit_ColorName);
|
SetStringValue(colorStr, eHTMLUnit_String);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче