Bug 232706: Remove unneccesary datatypes from nsHTMLValue and cleanup AttributeToString.

r=caillon sr=jst
This commit is contained in:
sicking%bigfoot.com 2004-02-11 00:09:59 +00:00
Родитель adaca9ddb0
Коммит 65d14b7bf0
42 изменённых файлов: 451 добавлений и 818 удалений

Просмотреть файл

@ -184,7 +184,6 @@ public:
PRUint32 HashValue() const
{
//
// mBits and PRUint32 might have different size. This should silence
// any warnings or compile-errors. This is what the implementation of
// NS_PTR_TO_INT32 does to take care of the same problem.

Просмотреть файл

@ -50,26 +50,20 @@
#include "nsICSSStyleRule.h"
#include "nsCSSDeclaration.h"
nsHTMLValue::nsHTMLValue(nsHTMLUnit aUnit)
: mUnit(aUnit)
nsHTMLValue::nsHTMLValue()
: mUnit(eHTMLUnit_String)
{
NS_ASSERTION(GetUnitClass() == HTMLUNIT_NOSTORE, "not a valueless unit");
if (GetUnitClass() != HTMLUNIT_NOSTORE) {
mUnit = eHTMLUnit_Null;
}
mValue.mString = nsnull;
}
nsHTMLValue::nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit)
: mUnit(aUnit)
{
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER ||
GetUnitClass() == HTMLUNIT_PIXEL, "unit not an integer unit");
if (GetUnitClass() == HTMLUNIT_INTEGER ||
GetUnitClass() == HTMLUNIT_PIXEL) {
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER, "unit not an integer unit");
if (GetUnitClass() == HTMLUNIT_INTEGER) {
mValue.mInt = aValue;
} else {
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
}
@ -130,9 +124,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
// Call GetUnitClass() so that we turn StringWithLength into String
PRUint32 unitClass = GetUnitClass();
switch (unitClass) {
case HTMLUNIT_NOSTORE:
return PR_TRUE;
case HTMLUNIT_STRING:
if (mValue.mString && aOther.mValue.mString) {
return GetDependentString().Equals(aOther.GetDependentString());
@ -141,7 +132,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
return mValue.mString == aOther.mValue.mString;
case HTMLUNIT_INTEGER:
case HTMLUNIT_PIXEL:
return mValue.mInt == aOther.mValue.mInt;
case HTMLUNIT_COLOR:
@ -211,7 +201,7 @@ void nsHTMLValue::Reset(void)
else if (mUnit == eHTMLUnit_AtomArray) {
delete mValue.mAtomArray;
}
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
@ -224,17 +214,11 @@ void nsHTMLValue::SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit)
if (GetUnitClass() == HTMLUNIT_INTEGER) {
mValue.mInt = aValue;
} 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)
{
Reset();
@ -254,7 +238,7 @@ void nsHTMLValue::SetStringValueInternal(const nsAString& aValue,
nsCheapStringBufferUtils::CopyToBuffer(mValue.mString, aValue);
}
} else {
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
}
@ -282,21 +266,11 @@ void nsHTMLValue::SetColorValue(nscolor aValue)
mValue.mColor = aValue;
}
void nsHTMLValue::SetEmptyValue(void)
{
Reset();
mUnit = eHTMLUnit_Empty;
}
void
nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
{
mUnit = aCopy.mUnit;
switch (GetUnitClass()) {
case HTMLUNIT_NOSTORE:
mValue.mString = nsnull;
break;
case HTMLUNIT_STRING:
if (aCopy.mValue.mString) {
nsCheapStringBufferUtils::Clone(mValue.mString, aCopy.mValue.mString);
@ -306,7 +280,6 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
break;
case HTMLUNIT_INTEGER:
case HTMLUNIT_PIXEL:
mValue.mInt = aCopy.mValue.mInt;
break;
@ -326,7 +299,8 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
case HTMLUNIT_ATOMARRAY:
mValue.mAtomArray = new nsCOMArray<nsIAtom>(*aCopy.mValue.mAtomArray);
if (!mValue.mAtomArray) {
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
break;
@ -411,11 +385,7 @@ nsHTMLValue::ParseSpecialIntValue(const nsAString& aString,
}
// Straight number is interpreted with the default unit
if (aDefaultUnit == eHTMLUnit_Pixel) {
SetPixelValue(val);
} else {
SetIntValue(val, aDefaultUnit);
}
SetIntValue(val, aDefaultUnit);
return PR_TRUE;
}
@ -448,11 +418,6 @@ nsHTMLValue::ToString(nsAString& aResult) const
}
return PR_TRUE;
case eHTMLUnit_Pixel:
intStr.AppendInt(GetPixelValue());
aResult.Append(intStr);
return PR_TRUE;
case eHTMLUnit_Percent:
{
float percentVal = GetPercentValue() * 100.0f;
@ -463,14 +428,14 @@ nsHTMLValue::ToString(nsAString& aResult) const
}
case eHTMLUnit_Color:
{
nscolor v = GetColorValue();
nscolor v;
GetColorValue(v);
char buf[10];
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
AppendASCIItoUTF16(buf, aResult);
return PR_TRUE;
}
case eHTMLUnit_ColorName:
case eHTMLUnit_String:
GetStringValue(aResult);
return PR_TRUE;
@ -516,11 +481,7 @@ nsHTMLValue::ParseIntWithBounds(const nsAString& aString,
if (NS_SUCCEEDED(ec)) {
val = PR_MAX(val, aMin);
val = PR_MIN(val, aMax);
if (aDefaultUnit == eHTMLUnit_Pixel) {
SetPixelValue(val);
} else {
SetIntValue(val, aDefaultUnit);
}
SetIntValue(val, aDefaultUnit);
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
// it is a very common first char
if ((colorStr.CharAt(0) != '#') && NS_ColorNameToRGB(colorStr, &color)) {
SetStringValue(colorStr, eHTMLUnit_ColorName);
SetStringValue(colorStr, eHTMLUnit_String);
return PR_TRUE;
}

Просмотреть файл

@ -148,10 +148,8 @@ public:
// between different things stored as the same type. Doing
// mUnit & HTMLUNIT_CLASS_MASK should give you the class of type.
//
#define HTMLUNIT_NOSTORE 0x0000
#define HTMLUNIT_STRING 0x0100
#define HTMLUNIT_INTEGER 0x0200
#define HTMLUNIT_PIXEL 0x0400
#define HTMLUNIT_COLOR 0x0800
#define HTMLUNIT_CSSSTYLERULE 0x1000
#define HTMLUNIT_PERCENT 0x2000
@ -159,15 +157,8 @@ public:
#define HTMLUNIT_CLASS_MASK 0xff00
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
eHTMLUnit_String = HTMLUNIT_STRING,
// a color name value
eHTMLUnit_ColorName = HTMLUNIT_STRING | 1,
// a simple int value
eHTMLUnit_Integer = HTMLUNIT_INTEGER,
@ -176,9 +167,6 @@ enum nsHTMLUnit {
// value is a relative proportion of some whole
eHTMLUnit_Proportional = HTMLUNIT_INTEGER | 2,
// screen pixels (screen relative measure)
eHTMLUnit_Pixel = HTMLUNIT_PIXEL,
// an RGBA value
eHTMLUnit_Color = HTMLUNIT_COLOR,
@ -200,7 +188,7 @@ enum nsHTMLUnit {
*/
class nsHTMLValue {
public:
nsHTMLValue(nsHTMLUnit aUnit = eHTMLUnit_Null);
nsHTMLValue();
nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit);
nsHTMLValue(float aValue);
nsHTMLValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
@ -222,24 +210,23 @@ public:
nsHTMLUnit GetUnit(void) const { return (nsHTMLUnit)mUnit; }
PRInt32 GetIntValue(void) const;
PRInt32 GetPixelValue(void) const;
float GetPercentValue(void) const;
nsAString& GetStringValue(nsAString& aBuffer) const;
nsICSSStyleRule* GetCSSStyleRuleValue(void) const;
nscolor GetColorValue(void) const;
PRBool GetColorValue(nscolor& aColor) const;
nsCOMArray<nsIAtom>* AtomArrayValue() const;
PRBool IsEmptyString() const;
/**
* Reset the string to null type, freeing things in the process if necessary.
*/
void Reset(void);
void SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit);
void SetPixelValue(PRInt32 aValue);
void SetPercentValue(float aValue);
void SetStringValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
void SetCSSStyleRuleValue(nsICSSStyleRule* aValue);
void SetColorValue(nscolor aValue);
void SetEmptyValue(void);
/**
* Get this HTML value as a string (depends on the type)
@ -295,10 +282,10 @@ public:
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 aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
* @param aDefaultUnit the unit to use
* @return whether the value could be parsed
*/
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
* 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.
*
* @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 aCanBeProportional true if it can be a proportional value (*)
* @return whether the value could be parsed
@ -322,13 +309,13 @@ public:
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
*
* @param aString the string to parse
* @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 aValueUnit the unit to use (eHTMLUnit_Pixel or Integer)
* @param aValueUnit the unit to use
* @return whether the value could be parsed
*/
PRBool ParseIntWithBounds(const nsAString& aString, nsHTMLUnit aValueUnit,
@ -432,15 +419,6 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
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
{
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
{
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING || mUnit == eHTMLUnit_Null,
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING,
"not a string value");
if (GetUnitClass() == HTMLUNIT_STRING && mValue.mString) {
aBuffer = GetDependentString();
@ -471,20 +449,19 @@ inline nsICSSStyleRule* nsHTMLValue::GetCSSStyleRuleValue(void) const
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");
if (mUnit == eHTMLUnit_Color) {
return mValue.mColor;
aColor = mValue.mColor;
return PR_TRUE;
}
if (mUnit == eHTMLUnit_ColorName) {
nscolor color;
if (NS_ColorNameToRGB(GetDependentString(), &color)) {
return color;
}
if (mUnit == eHTMLUnit_String && mValue.mString) {
return NS_ColorNameToRGB(GetDependentString(), &aColor);
}
return NS_RGB(0,0,0);
return PR_FALSE;
}
inline nsCOMArray<nsIAtom>*
@ -499,5 +476,10 @@ inline PRBool nsHTMLValue::operator!=(const nsHTMLValue& aOther) const
return PRBool(! ((*this) == aOther));
}
inline PRBool nsHTMLValue::IsEmptyString() const
{
return mUnit == eHTMLUnit_String && !mValue.mString;
}
#endif /* nsHTMLValue_h___ */

Просмотреть файл

@ -1685,11 +1685,6 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aAttribute,
rv = ParseClassAttribute(aValue, attrValue);
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 {
attrValue.SetTo(aValue);
}
@ -1922,43 +1917,22 @@ nsGenericHTMLElement::GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
return NS_CONTENT_ATTR_NOT_THERE;
}
if (attrValue->GetType() != nsAttrValue::eHTMLValue) {
attrValue->ToString(aResult);
// Use subclass to convert enums to string.
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_HAS_VALUE;
}
attrValue->ToString(aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
@ -2303,11 +2277,8 @@ nsGenericHTMLElement::AttributeToString(nsIAtom* aAttribute,
nsAString& aResult) const
{
if (nsHTMLAtoms::dir == aAttribute) {
nsHTMLValue value;
nsresult result = GetHTMLAttribute(nsHTMLAtoms::dir, value);
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
value.EnumValueToString(kDirTable, aResult);
if (aValue.GetUnit() == eHTMLUnit_Enumerated) {
aValue.EnumValueToString(kDirTable, aResult);
return NS_OK;
}
@ -2765,27 +2736,12 @@ nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute,
{
if ((aAttribute == nsHTMLAtoms::width) ||
(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) ||
(aAttribute == nsHTMLAtoms::vspace) ||
(aAttribute == nsHTMLAtoms::border)) {
return aResult.ParseIntWithBounds(aString, eHTMLUnit_Pixel, 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 aResult.ParseIntWithBounds(aString, eHTMLUnit_Integer, 0);
}
return PR_FALSE;
}
@ -2956,8 +2912,9 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu
eCSSUnit_Enumerated);
}
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::lang, value);
if (value.GetUnit() == eHTMLUnit_String) {
if (aAttributes->GetAttribute(nsHTMLAtoms::lang, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
value.GetUnit() == eHTMLUnit_String) {
nsAutoString lang;
value.GetStringValue(lang);
aData->mDisplayData->mLang.SetStringValue(lang,
@ -3072,8 +3029,8 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
// hspace: value
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
nsCSSValue hval;
if (value.GetUnit() == eHTMLUnit_Pixel)
hval.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
hval.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
hval.SetPercentValue(value.GetPercentValue());
@ -3088,8 +3045,8 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
// vspace: value
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
nsCSSValue vval;
if (value.GetUnit() == eHTMLUnit_Pixel)
vval.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
vval.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
vval.SetPercentValue(value.GetPercentValue());
@ -3114,8 +3071,8 @@ nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttr
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
}
@ -3123,8 +3080,8 @@ nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttr
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
}
@ -3140,14 +3097,15 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAtt
nsHTMLValue value;
// border: pixels
aAttributes->GetAttribute(nsHTMLAtoms::border, value);
if (value.GetUnit() == eHTMLUnit_Null)
if (aAttributes->GetAttribute(nsHTMLAtoms::border, value) ==
NS_CONTENT_ATTR_NOT_THERE) {
return;
}
if (value.GetUnit() != eHTMLUnit_Pixel) // something other than pixels
value.SetPixelValue(0);
if (value.GetUnit() != eHTMLUnit_Integer) // something other than Integer
value.SetIntValue(0, eHTMLUnit_Integer);
nscoord val = value.GetPixelValue();
nscoord val = value.GetIntValue();
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null)
@ -3191,43 +3149,42 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsMappedAttributes* aAtt
// background
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
aAttributes->GetAttribute(nsHTMLAtoms::background, value)) {
if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString spec;
value.GetStringValue(spec);
if (!spec.IsEmpty()) {
// Resolve url to an absolute url
// XXX this breaks if the HTML element has an xml:base
// attribute (the xml:base will not be taken into account)
// 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
// attributes.
nsIPresShell *shell = aData->mPresContext->GetPresShell();
if (shell) {
nsCOMPtr<nsIDocument> doc;
nsresult rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(rv) && doc) {
nsCOMPtr<nsIURI> uri;
rv = nsContentUtils::NewURIWithDocumentCharset(
getter_AddRefs(uri), spec, doc, doc->GetBaseURI());
if (NS_SUCCEEDED(rv)) {
nsCSSValue::URL *url = new nsCSSValue::URL(uri, spec.get());
if (url) {
if (url->mString)
aData->mColorData->mBackImage.SetURLValue(url);
else
delete url;
}
aAttributes->GetAttribute(nsHTMLAtoms::background, value) &&
value.GetUnit() == eHTMLUnit_String) {
nsAutoString spec;
value.GetStringValue(spec);
if (!spec.IsEmpty()) {
// Resolve url to an absolute url
// XXX this breaks if the HTML element has an xml:base
// attribute (the xml:base will not be taken into account)
// 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
// attributes.
nsIPresShell *shell = aData->mPresContext->GetPresShell();
if (shell) {
nsCOMPtr<nsIDocument> doc;
nsresult rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(rv) && doc) {
nsCOMPtr<nsIURI> uri;
rv = nsContentUtils::NewURIWithDocumentCharset(
getter_AddRefs(uri), spec, doc, doc->GetBaseURI());
if (NS_SUCCEEDED(rv)) {
nsCSSValue::URL *url = new nsCSSValue::URL(uri, spec.get());
if (url) {
if (url->mString)
aData->mColorData->mBackImage.SetURLValue(url);
else
delete url;
}
}
}
}
} else if (aData->mPresContext) {
}
else if (aData->mPresContext->CompatibilityMode() ==
eCompatibility_NavQuirks) {
// in NavQuirks mode, allow the empty string to set the
// background to empty
if (eCompatibility_NavQuirks == aData->mPresContext->CompatibilityMode() &&
eHTMLUnit_Empty == value.GetUnit())
aData->mColorData->mBackImage.SetNoneValue();
aData->mColorData->mBackImage.SetNoneValue();
}
}
}
@ -3235,10 +3192,12 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsMappedAttributes* aAtt
// bgcolor
if (aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null) {
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::bgcolor, value);
if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit()))
aData->mColorData->mBackColor.SetColorValue(value.GetColorValue());
nscolor color;
if (aAttributes->GetAttribute(nsHTMLAtoms::bgcolor, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
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
* (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().
*
* @param aAttribute the attribute to convert
@ -417,18 +417,6 @@ public:
static PRBool ParseImageAttribute(nsIAtom* aAttribute,
const nsAString& aString,
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)
*
@ -893,14 +881,12 @@ protected:
NS_IMETHODIMP \
_class::Set##_method(PRBool aValue) \
{ \
nsHTMLValue empty(eHTMLUnit_Empty); \
if (aValue) { \
return SetHTMLAttribute(nsHTMLAtoms::_atom, empty, PR_TRUE); \
} \
else { \
UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, PR_TRUE); \
return NS_OK; \
return SetHTMLAttribute(nsHTMLAtoms::_atom, nsHTMLValue(), \
PR_TRUE); \
} \
UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, PR_TRUE); \
return NS_OK; \
}
/**
@ -937,40 +923,6 @@ protected:
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
* property that needs to return a URI in string form. The method

Просмотреть файл

@ -69,11 +69,6 @@
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,
public nsIDOMHTMLAnchorElement,
public nsIDOMNSHTMLAnchorElement,
@ -325,17 +320,9 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute,
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;
}
// XXX support suppress in here
nsresult
nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext* aPresContext,
nsEvent* aEvent,

Просмотреть файл

@ -169,10 +169,10 @@ NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Archive, archive)
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code)
NS_IMPL_URI_ATTR(nsHTMLAppletElement, CodeBase, codebase)
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, Object, object)
NS_IMPL_PIXEL_ATTR(nsHTMLAppletElement, Vspace, vspace)
NS_IMPL_INT_ATTR(nsHTMLAppletElement, Vspace, vspace)
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width)
NS_IMETHODIMP
@ -203,10 +203,6 @@ nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
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);
}

Просмотреть файл

@ -205,11 +205,7 @@ nsHTMLAreaElement::StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::nohref) {
aResult.SetEmptyValue();
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::tabindex) {
if (aAttribute == nsHTMLAtoms::tabindex) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}

Просмотреть файл

@ -253,7 +253,6 @@ HTML_ATOM(strike, "strike")
HTML_ATOM(strong, "strong")
HTML_ATOM(style, "style")
HTML_ATOM(summary, "summary")
HTML_ATOM(suppress, "suppress")
HTML_ATOM(tabindex, "tabindex")
HTML_ATOM(table, "table")
HTML_ATOM(tabstop, "tabstop")

Просмотреть файл

@ -170,8 +170,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (mPart->GetAttrCount() > 0) {
// if marginwidth/marginheight are set, reflect them as 'margin'
mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyMarginWidth = value.GetPixelValue();
if (eHTMLUnit_Integer == value.GetUnit()) {
bodyMarginWidth = value.GetIntValue();
if (bodyMarginWidth < 0) bodyMarginWidth = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
@ -181,8 +181,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
}
mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyMarginHeight = value.GetPixelValue();
if (eHTMLUnit_Integer == value.GetUnit()) {
bodyMarginHeight = value.GetIntValue();
if (bodyMarginHeight < 0) bodyMarginHeight = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mTop.GetUnit() == eCSSUnit_Null)
@ -194,8 +194,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
if (eCompatibility_NavQuirks == mode){
// topmargin (IE-attribute)
mPart->GetHTMLAttribute(nsHTMLAtoms::topmargin, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyTopMargin = value.GetPixelValue();
if (eHTMLUnit_Integer == value.GetUnit()) {
bodyTopMargin = value.GetIntValue();
if (bodyTopMargin < 0) bodyTopMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mTop.GetUnit() == eCSSUnit_Null)
@ -204,8 +204,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
// bottommargin (IE-attribute)
mPart->GetHTMLAttribute(nsHTMLAtoms::bottommargin, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyBottomMargin = value.GetPixelValue();
if (eHTMLUnit_Integer == value.GetUnit()) {
bodyBottomMargin = value.GetIntValue();
if (bodyBottomMargin < 0) bodyBottomMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
@ -214,8 +214,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
// leftmargin (IE-attribute)
mPart->GetHTMLAttribute(nsHTMLAtoms::leftmargin, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyLeftMargin = value.GetPixelValue();
if (eHTMLUnit_Integer == value.GetUnit()) {
bodyLeftMargin = value.GetIntValue();
if (bodyLeftMargin < 0) bodyLeftMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
@ -224,8 +224,8 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
// rightmargin (IE-attribute)
mPart->GetHTMLAttribute(nsHTMLAtoms::rightmargin, value);
if (eHTMLUnit_Pixel == value.GetUnit()) {
bodyRightMargin = value.GetPixelValue();
if (eHTMLUnit_Integer == value.GetUnit()) {
bodyRightMargin = value.GetIntValue();
if (bodyRightMargin < 0) bodyRightMargin = 0;
nsCSSRect& margin = aData->mMarginData->mMargin;
if (margin.mRight.GetUnit() == eCSSUnit_Null)
@ -484,7 +484,7 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute,
(aAttribute == nsHTMLAtoms::bottommargin) ||
(aAttribute == nsHTMLAtoms::leftmargin) ||
(aAttribute == nsHTMLAtoms::rightmargin)) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@ -520,22 +520,23 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
if (doc) {
nsIHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
if (styleSheet) {
aAttributes->GetAttribute(nsHTMLAtoms::link, value);
if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit())) {
styleSheet->SetLinkColor(value.GetColorValue());
nscolor color;
if (aAttributes->GetAttribute(nsHTMLAtoms::link, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
value.GetColorValue(color)) {
styleSheet->SetLinkColor(color);
}
aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit())) {
styleSheet->SetActiveLinkColor(value.GetColorValue());
if (aAttributes->GetAttribute(nsHTMLAtoms::alink, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
value.GetColorValue(color)) {
styleSheet->SetActiveLinkColor(color);
}
aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit())) {
styleSheet->SetVisitedLinkColor(value.GetColorValue());
if (aAttributes->GetAttribute(nsHTMLAtoms::vlink, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
value.GetColorValue(color)) {
styleSheet->SetVisitedLinkColor(color);
}
}
}
@ -546,10 +547,11 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
// color: color
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::text, value);
if (((eHTMLUnit_Color == value.GetUnit())) ||
(eHTMLUnit_ColorName == value.GetUnit()))
aData->mColorData->mColor.SetColorValue(value.GetColorValue());
nscolor color;
if (aAttributes->GetAttribute(nsHTMLAtoms::text, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
value.GetColorValue(color))
aData->mColorData->mColor.SetColorValue(color);
}
}

Просмотреть файл

@ -356,10 +356,6 @@ nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute,
table++;
}
}
else if (aAttribute == nsHTMLAtoms::disabled) {
aResult.SetEmptyValue();
return NS_CONTENT_ATTR_HAS_VALUE;
}
return NS_CONTENT_ATTR_NOT_THERE;
}

Просмотреть файл

@ -176,10 +176,6 @@ nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute,
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;
}
@ -202,11 +198,13 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
nsHTMLValue value;
// type: enum
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
else if (value.GetUnit() != eHTMLUnit_Null)
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), 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) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 1)) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 1)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
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;
}
}

Просмотреть файл

@ -173,11 +173,11 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute,
//rickg: fixed flaw where ToInteger error code was not being checked.
// This caused wrong default value for font size.
PRInt32 ec, v = tmp.ToInteger(&ec);
if(NS_SUCCEEDED(ec)){
if(NS_SUCCEEDED(ec)) {
tmp.CompressWhitespace(PR_TRUE, PR_FALSE);
PRUnichar ch = tmp.IsEmpty() ? 0 : tmp.First();
aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ?
eHTMLUnit_Integer : eHTMLUnit_Enumerated);
aResult.SetIntValue(v, (ch == '+' || ch == '-') ?
eHTMLUnit_Enumerated : eHTMLUnit_Integer);
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@ -197,20 +197,16 @@ nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute,
if ((aAttribute == nsHTMLAtoms::size) ||
(aAttribute == nsHTMLAtoms::pointSize) ||
(aAttribute == nsHTMLAtoms::fontWeight)) {
aResult.Truncate();
nsAutoString intVal;
if (aValue.GetUnit() == eHTMLUnit_Enumerated) {
intVal.AppendInt(aValue.GetIntValue(), 10);
aResult.Append(intVal);
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aValue.GetUnit() == eHTMLUnit_Integer) {
nsAutoString intVal;
PRInt32 value = aValue.GetIntValue();
intVal.AppendInt(value, 10);
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;
}
@ -230,8 +226,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// face: string list
if (font.mFamily.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::face, value);
if (value.GetUnit() == eHTMLUnit_String) {
if (aAttributes->GetAttribute(nsHTMLAtoms::face, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
value.GetUnit() == eHTMLUnit_String) {
nsAutoString familyList;
value.GetStringValue(familyList);
if (!familyList.IsEmpty()) {
@ -255,8 +252,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsHTMLUnit unit = value.GetUnit();
if (unit == eHTMLUnit_Integer || unit == eHTMLUnit_Enumerated) {
PRInt32 size = value.GetIntValue();
if (unit == eHTMLUnit_Integer) // int (+/-)
size += 3; // XXX should be BASEFONT, not three
if (unit == eHTMLUnit_Enumerated) // int (+/-)
size += 3; // XXX should be BASEFONT, not three see bug 3875
size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
font.mSize.SetIntValue(size, eCSSUnit_Enumerated);
@ -277,11 +274,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
// color: color
nsHTMLValue value;
nscolor color;
if (NS_CONTENT_ATTR_NOT_THERE !=
aAttributes->GetAttribute(nsHTMLAtoms::color, value)) {
if (((eHTMLUnit_Color == value.GetUnit())) ||
(eHTMLUnit_ColorName == value.GetUnit()))
aData->mColorData->mColor.SetColorValue(value.GetColorValue());
aAttributes->GetAttribute(nsHTMLAtoms::color, value) &&
value.GetColorValue(color)) {
aData->mColorData->mColor.SetColorValue(color);
}
}
}
@ -290,10 +287,10 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// in quirks mode. The NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL flag only
// affects quirks mode rendering.
nsHTMLValue value;
nscolor color;
if (NS_CONTENT_ATTR_NOT_THERE !=
aAttributes->GetAttribute(nsHTMLAtoms::color, value) &&
(eHTMLUnit_Color == value.GetUnit() ||
eHTMLUnit_ColorName == value.GetUnit())) {
value.GetColorValue(color)) {
nsCSSValue& decoration = aData->mTextData->mDecoration;
PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
if (decoration.GetUnit() == eCSSUnit_Enumerated) {

Просмотреть файл

@ -240,19 +240,15 @@ nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute,
}
}
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;
}
}
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;
}
}
else if (aAttribute == nsHTMLAtoms::noresize) {
aResult.SetEmptyValue();
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::scrolling) {
if (ParseScrollingValue(aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;

Просмотреть файл

@ -351,7 +351,7 @@ nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute,
}
}
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;
}
}

Просмотреть файл

@ -178,19 +178,15 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
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;
}
}
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;
}
}
else if (aAttribute == nsHTMLAtoms::noshade) {
aResult.SetEmptyValue();
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::align) {
if (aResult.ParseEnumValue(aValue, kAlignTable)) {
return NS_CONTENT_ATTR_HAS_VALUE;
@ -228,19 +224,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsHTMLValue value;
PRBool noshade = PR_FALSE;
nsHTMLValue color;
aAttributes->GetAttribute(nsHTMLAtoms::color, color);
PRBool colorIsSet = color.GetUnit() == eHTMLUnit_Color ||
color.GetUnit() == eHTMLUnit_ColorName;
nsHTMLValue colorValue;
nscolor color;
PRBool colorIsSet = aAttributes->GetAttribute(nsHTMLAtoms::color, colorValue) !=
NS_CONTENT_ATTR_NOT_THERE &&
colorValue.GetColorValue(color);
if (aData->mSID == eStyleStruct_Position ||
aData->mSID == eStyleStruct_Border) {
if (colorIsSet) {
noshade = PR_TRUE;
} else {
aAttributes->GetAttribute(nsHTMLAtoms::noshade, value);
noshade = value.GetUnit() != eHTMLUnit_Null;
noshade = !!aAttributes->GetAttr(nsHTMLAtoms::noshade);
}
}
@ -273,18 +268,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
}
else if (aData->mSID == eStyleStruct_Position) {
// width: pixel, percent
// width: integer, percent
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer) {
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
} else if (value.GetUnit() == eHTMLUnit_Percent) {
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
}
}
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
// size: pixel
// size: integer
if (noshade) {
// noshade case: size is set using the border
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
// removing all but the top border.
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer) {
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
} // 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
// size: pixel
// size: integer
// if a size is set, use half of it per side, otherwise, use 1px per side
float sizePerSide;
PRBool allSides = PR_TRUE;
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
sizePerSide = (float)value.GetPixelValue() / 2.0f;
if (value.GetUnit() == eHTMLUnit_Integer) {
sizePerSide = (float)value.GetIntValue() / 2.0f;
if (sizePerSide < 1.0f) {
// XXX When the pixel bug is fixed, all the special casing for
// subpixel borders should be removed.
@ -377,7 +372,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// (we got the color attribute earlier)
if (colorIsSet &&
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)
{
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;
}
}
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;
}
}
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;
}
}
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;
}
}
@ -460,8 +460,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsHTMLValue value;
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
}
@ -469,8 +469,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
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, Alt, alt)
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_URI_ATTR(nsHTMLImageElement, LongDesc, longdesc)
NS_IMPL_STRING_ATTR(nsHTMLImageElement, Lowsrc, lowsrc)
NS_IMPL_URI_ATTR_GETTER(nsHTMLImageElement, Src, src)
NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
NS_IMPL_PIXEL_ATTR(nsHTMLImageElement, Vspace, vspace)
NS_IMPL_INT_ATTR(nsHTMLImageElement, Vspace, vspace)
void
nsHTMLImageElement::GetImageFrame(nsIImageFrame** aImageFrame)
@ -423,14 +423,14 @@ nsHTMLImageElement::GetWidthHeight()
if (GetHTMLAttribute(nsHTMLAtoms::width,
value) == NS_CONTENT_ATTR_HAS_VALUE) {
size.width = value.GetPixelValue();
size.width = value.GetIntValue();
} else if (image) {
image->GetWidth(&size.width);
}
if (GetHTMLAttribute(nsHTMLAtoms::height,
value) == NS_CONTENT_ATTR_HAS_VALUE) {
size.height = value.GetPixelValue();
size.height = value.GetIntValue();
} else if (image) {
image->GetHeight(&size.height);
}
@ -485,10 +485,6 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::ismap) {
aResult.SetEmptyValue();
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::src) {
static const char* kWhitespace = " \n\r\t\b";
aResult.SetStringValue(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
@ -512,9 +508,6 @@ nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
return nsGenericHTMLElement::AttributeToString(aAttribute, aValue, aResult);
}
@ -655,7 +648,7 @@ nsHTMLImageElement::Initialize(JSContext* aContext, JSObject *aObj,
JSBool ret = JS_ValueToInt32(aContext, argv[0], &width);
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);
@ -665,7 +658,7 @@ nsHTMLImageElement::Initialize(JSContext* aContext, JSObject *aObj,
ret = JS_ValueToInt32(aContext, argv[1], &height);
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);
}

Просмотреть файл

@ -558,25 +558,6 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
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);
if (aDisabled) {
nsHTMLValue empty(eHTMLUnit_Empty);
return SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
return SetHTMLAttribute(nsHTMLAtoms::disabled, nsHTMLValue(), PR_TRUE);
}
UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE);
@ -674,13 +654,9 @@ nsHTMLInputElement::GetSize(PRUint32* aValue)
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE ==
GetHTMLAttribute(nsHTMLAtoms::size, value)) {
if (value.GetUnit() == eHTMLUnit_Integer) {
*aValue = value.GetIntValue();
}
else if (value.GetUnit() == eHTMLUnit_Pixel) {
*aValue = value.GetPixelValue();
}
GetHTMLAttribute(nsHTMLAtoms::size, value) &&
value.GetUnit() == eHTMLUnit_Integer) {
*aValue = value.GetIntValue();
}
return NS_OK;
@ -689,14 +665,7 @@ nsHTMLInputElement::GetSize(PRUint32* aValue)
NS_IMETHODIMP
nsHTMLInputElement::SetSize(PRUint32 aValue)
{
nsHTMLUnit unit = eHTMLUnit_Pixel;
if (mType == NS_FORM_INPUT_TEXT ||
mType == NS_FORM_INPUT_PASSWORD) {
unit = eHTMLUnit_Integer;
}
nsHTMLValue value(aValue, unit);
nsHTMLValue value(aValue, eHTMLUnit_Integer);
return SetHTMLAttribute(nsHTMLAtoms::size, value, PR_TRUE);
}
@ -1806,6 +1775,8 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::type) {
// XXX ARG!! This is major evilness. StringToAttribute
// shouldn't set members. Override SetAttr instead
const nsHTMLValue::EnumTable *table = kInputTypeTable;
nsAutoString valueStr(aValue);
while (nsnull != table->tag) {
@ -1825,25 +1796,13 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
// as an HTMLValue.
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) {
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;
}
}
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;
}
}
@ -1853,16 +1812,8 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if (aAttribute == nsHTMLAtoms::size) {
if (mType == NS_FORM_INPUT_TEXT ||
mType == NS_FORM_INPUT_PASSWORD) {
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;
}
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::tabindex) {
@ -1871,7 +1822,7 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
}
}
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;
}
}
@ -1920,13 +1871,6 @@ nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
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,
aResult);

Просмотреть файл

@ -201,11 +201,13 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
nsHTMLValue value;
// type: enum
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
else if (value.GetUnit() != eHTMLUnit_Null)
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), 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) {
nsHTMLValue value;
// type: enum
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
else if (value.GetUnit() != eHTMLUnit_Null)
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), 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_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
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, Standby, standby)
NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex)
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
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)
@ -271,9 +271,6 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
aResult);

Просмотреть файл

@ -106,9 +106,6 @@ public:
NS_IMETHOD Initialize(JSContext* aContext, JSObject *aObj,
PRUint32 argc, jsval *argv);
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsHTMLValue& aResult);
NS_IMETHOD GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType,
nsChangeHint& aHint) const;
@ -368,17 +365,11 @@ nsHTMLOptionElement::GetDisabled(PRBool* aDisabled)
NS_IMETHODIMP
nsHTMLOptionElement::SetDisabled(PRBool aDisabled)
{
nsresult rv = NS_OK;
nsHTMLValue empty(eHTMLUnit_Empty);
if (aDisabled) {
rv = SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
} else {
rv = UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE);
return SetHTMLAttribute(nsHTMLAtoms::disabled, nsHTMLValue(), PR_TRUE);
}
return NS_OK;
return UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE);
}
NS_IMETHODIMP
@ -418,16 +409,11 @@ nsHTMLOptionElement::GetDefaultSelected(PRBool* aDefaultSelected)
NS_IMETHODIMP
nsHTMLOptionElement::SetDefaultSelected(PRBool aDefaultSelected)
{
nsHTMLValue empty(eHTMLUnit_Empty);
nsresult rv = NS_OK;
if (aDefaultSelected) {
rv = SetHTMLAttribute(nsHTMLAtoms::selected, empty, PR_TRUE);
} else {
rv = UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::selected, PR_TRUE);
return SetHTMLAttribute(nsHTMLAtoms::selected, nsHTMLValue(), PR_TRUE);
}
return rv;
return UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::selected, PR_TRUE);
}
NS_IMETHODIMP
@ -469,23 +455,6 @@ nsHTMLOptionElement::GetIndex(PRInt32* aIndex)
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
nsHTMLOptionElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType,
@ -725,13 +694,8 @@ nsHTMLOptionElement::Initialize(JSContext* aContext,
argv[2],
&defaultSelected)) &&
(JS_TRUE == defaultSelected)) {
nsHTMLValue empty(eHTMLUnit_Empty);
result = SetHTMLAttribute(nsHTMLAtoms::selected, empty, PR_FALSE);
if (NS_FAILED(result)) {
return result;
}
result = SetHTMLAttribute(nsHTMLAtoms::selected, nsHTMLValue(), PR_FALSE);
NS_ENSURE_SUCCESS(result, result);
}
// XXX This is *untested* behavior. Should work though.

Просмотреть файл

@ -197,11 +197,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsRuleData* aData)
{
if (aData->mSID == eStyleStruct_Font) {
nsHTMLValue value;
// variable: empty
aAttributes->GetAttribute(nsHTMLAtoms::variable, value);
if (value.GetUnit() == eHTMLUnit_Empty)
// variable
if (aAttributes->GetAttr(nsHTMLAtoms::variable))
aData->mFontData->mFamily.SetStringValue(NS_LITERAL_STRING("serif"),
eCSSUnit_String);
}
@ -221,13 +218,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
else if (aData->mSID == eStyleStruct_Text) {
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
nsHTMLValue value;
// wrap: empty
aAttributes->GetAttribute(nsHTMLAtoms::wrap, value);
if (value.GetUnit() != eHTMLUnit_Null)
if (aAttributes->GetAttr(nsHTMLAtoms::wrap))
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated);
// cols: int (nav4 attribute)
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
if (value.GetUnit() == eHTMLUnit_Integer)
// Force wrap property on since we want to wrap at a width

Просмотреть файл

@ -1801,15 +1801,7 @@ nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::disabled) {
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 (aAttribute == nsHTMLAtoms::size) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}

Просмотреть файл

@ -262,10 +262,6 @@ nsHTMLSharedContainerElement::StringToAttribute(nsIAtom* aAttribute,
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 1)) {
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)) {
if (aAttribute == nsHTMLAtoms::align) {
@ -353,13 +349,16 @@ MapDirAndMenuAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
nsHTMLValue value;
// type: enum
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
aData->mListData->mType.SetIntValue(value.GetIntValue(),
eCSSUnit_Enumerated);
} else if (value.GetUnit() != eHTMLUnit_Null) {
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC,
eCSSUnit_Enumerated);
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
if (value.GetUnit() == eHTMLUnit_Enumerated) {
aData->mListData->mType.SetIntValue(value.GetIntValue(),
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) {
nsHTMLValue value;
// type: enum
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated) {
aData->mListData->mType.SetIntValue(value.GetIntValue(),
eCSSUnit_Enumerated);
} else if (value.GetUnit() != eHTMLUnit_Null) {
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL,
eCSSUnit_Enumerated);
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
if (value.GetUnit() == eHTMLUnit_Enumerated) {
aData->mListData->mType.SetIntValue(value.GetIntValue(),
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)) {
if (aAttribute == nsHTMLAtoms::size) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
} else if (aAttribute == nsHTMLAtoms::align) {
@ -248,7 +248,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
}
} else if ((aAttribute == nsHTMLAtoms::width) ||
(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;
}
}
@ -268,8 +268,6 @@ nsHTMLSharedLeafElement::AttributeToString(nsIAtom* aAttribute,
AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
} else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
if (aAttribute == nsHTMLAtoms::align) {
@ -301,9 +299,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetUnit() == eHTMLUnit_Integer) {
aData->mPositionData->
mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
} else if (value.GetUnit() == eHTMLUnit_Percent) {
aData->mPositionData->
mWidth.SetPercentValue(value.GetPercentValue());
@ -313,9 +311,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetUnit() == eHTMLUnit_Integer) {
aData->mPositionData->
mHeight.SetFloatValue((float)value.GetPixelValue(),
mHeight.SetFloatValue((float)value.GetIntValue(),
eCSSUnit_Pixel);
} else if (value.GetUnit() == eHTMLUnit_Percent) {
aData->mPositionData->
@ -326,9 +324,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// size: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->
mWidth.SetFloatValue((float)value.GetPixelValue(),
mWidth.SetFloatValue((float)value.GetIntValue(),
eCSSUnit_Pixel);
}
}
@ -348,8 +346,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
if (aData->mDisplayData->mDisplay == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (eHTMLUnit_String == value.GetUnit()) {
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
eHTMLUnit_String == value.GetUnit()) {
nsAutoString tmp;
value.GetStringValue(tmp);
if (tmp.EqualsIgnoreCase("line") ||

Просмотреть файл

@ -239,7 +239,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
}
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
if (aAttribute == nsHTMLAtoms::size) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
} else if (aAttribute == nsHTMLAtoms::align) {
@ -248,7 +248,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
}
} else if ((aAttribute == nsHTMLAtoms::width) ||
(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;
}
}
@ -268,8 +268,6 @@ nsHTMLSharedLeafElement::AttributeToString(nsIAtom* aAttribute,
AlignValueToString(aValue, aResult);
return NS_CONTENT_ATTR_HAS_VALUE;
}
} else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
} else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
if (aAttribute == nsHTMLAtoms::align) {
@ -301,9 +299,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetUnit() == eHTMLUnit_Integer) {
aData->mPositionData->
mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
} else if (value.GetUnit() == eHTMLUnit_Percent) {
aData->mPositionData->
mWidth.SetPercentValue(value.GetPercentValue());
@ -313,9 +311,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetUnit() == eHTMLUnit_Integer) {
aData->mPositionData->
mHeight.SetFloatValue((float)value.GetPixelValue(),
mHeight.SetFloatValue((float)value.GetIntValue(),
eCSSUnit_Pixel);
} else if (value.GetUnit() == eHTMLUnit_Percent) {
aData->mPositionData->
@ -326,9 +324,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// size: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->
mWidth.SetFloatValue((float)value.GetPixelValue(),
mWidth.SetFloatValue((float)value.GetIntValue(),
eCSSUnit_Pixel);
}
}
@ -348,8 +346,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
if (aData->mDisplayData->mDisplay == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (eHTMLUnit_String == value.GetUnit()) {
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
eHTMLUnit_String == value.GetUnit()) {
nsAutoString tmp;
value.GetStringValue(tmp);
if (tmp.EqualsIgnoreCase("line") ||

Просмотреть файл

@ -208,13 +208,13 @@ NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype)
NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data)
NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
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, Standby, standby)
NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex)
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
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)
@ -271,9 +271,6 @@ nsHTMLObjectElement::AttributeToString(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (ImageAttributeToString(aAttribute, aValue, aResult)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
return nsGenericHTMLFormElement::AttributeToString(aAttribute, aValue,
aResult);

Просмотреть файл

@ -371,14 +371,14 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::height) {
/* 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;
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* 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;
}
}
@ -447,9 +447,9 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsHTMLValue value;
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetPixelValue() > 0)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer) {
if (value.GetIntValue() > 0)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
// else 0 implies auto for compatibility.
}
else if (value.GetUnit() == eHTMLUnit_Percent) {
@ -462,9 +462,9 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetPixelValue() > 0)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer) {
if (value.GetIntValue() > 0)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
// else 0 implies auto for compatibility.
}
else if (value.GetUnit() == eHTMLUnit_Percent) {
@ -486,12 +486,12 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
// nowrap: enum
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value);
if (value.GetUnit() != eHTMLUnit_Null) {
// See if our width is not a pixel width.
if (aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
// See if our width is not a integer width.
nsHTMLValue 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);
}
}

Просмотреть файл

@ -193,7 +193,7 @@ nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::width) {
/* 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;
}
}
@ -234,11 +234,6 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
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);
}
@ -250,15 +245,15 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
// width
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() != eHTMLUnit_Null) {
if (aAttributes->GetAttribute(nsHTMLAtoms::width, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
switch (value.GetUnit()) {
case eHTMLUnit_Percent: {
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
break;
}
case eHTMLUnit_Pixel: {
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
case eHTMLUnit_Integer: {
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
break;
}
case eHTMLUnit_Proportional: {

Просмотреть файл

@ -947,10 +947,10 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
/* 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 ||
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;
}
}
@ -962,35 +962,32 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
}
}
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;
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, min)) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, min)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
else {
// 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;
}
}
else if (aAttribute == nsHTMLAtoms::height) {
/* 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;
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* 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
nsHTMLUnit unit = aResult.GetUnit();
if ((eHTMLUnit_Pixel == unit) && (0 == aResult.GetPixelValue())) {
return NS_CONTENT_ATTR_NOT_THERE;
}
else if ((eHTMLUnit_Integer == unit) && (0 == aResult.GetIntValue())) {
if ((eHTMLUnit_Integer == unit) && (0 == aResult.GetIntValue())) {
return NS_CONTENT_ATTR_NOT_THERE;
}
else if ((eHTMLUnit_Percent == unit) && (0.0f == aResult.GetPercentValue())) {
@ -1029,7 +1026,7 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
}
else if (aAttribute == nsHTMLAtoms::hspace ||
aAttribute == nsHTMLAtoms::vspace) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Pixel, 0)) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@ -1139,62 +1136,58 @@ MapTableBorderInto(const nsMappedAttributes* aAttributes,
nsRuleData* aData, PRUint8 aBorderStyle)
{
nsHTMLValue borderValue;
aAttributes->GetAttribute(nsHTMLAtoms::border, borderValue);
if (borderValue.GetUnit() == eHTMLUnit_Null) {
if (aAttributes->GetAttribute(nsHTMLAtoms::border, borderValue) ==
NS_CONTENT_ATTR_NOT_THERE) {
// the absence of "border" with the presence of "frame" implies
// border = 1 pixel
nsHTMLValue frameValue;
aAttributes->GetAttribute(nsHTMLAtoms::frame, frameValue);
if (frameValue.GetUnit() != eHTMLUnit_Null)
borderValue.SetPixelValue(1);
if (!aAttributes->GetAttr(nsHTMLAtoms::frame)) {
return;
}
borderValue.SetIntValue(1, eHTMLUnit_Integer);
}
if (borderValue.GetUnit() != eHTMLUnit_Null) {
if (borderValue.GetUnit() != eHTMLUnit_Pixel) {
// empty values of border get rules=all and frame=border
if (borderValue.GetUnit() != eHTMLUnit_Integer) {
// 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) {
aData->mTableData->mRules.SetIntValue(NS_STYLE_TABLE_RULES_ALL, eCSSUnit_Enumerated);
aData->mTableData->mFrame.SetIntValue(NS_STYLE_TABLE_FRAME_BORDER, eCSSUnit_Enumerated);
}
borderValue.SetPixelValue(1);
}
else {
PRInt32 borderThickness = borderValue.GetPixelValue();
if (0 != borderThickness) {
// border != 0 implies 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);
}
}
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);
}
// 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) {
// by default, set all border sides to the specified width
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mRight.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mTop .SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mBottom.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData) {
// by default, set all border sides to the specified width
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mRight.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mTop .SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mBottom.SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
// now account for the frame attribute
MapTableFrameInto(aAttributes, aData, aBorderStyle);
}
// now account for the frame attribute
MapTableFrameInto(aAttributes, aData, aBorderStyle);
}
}
@ -1220,11 +1213,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// cellspacing
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::cellspacing, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetUnit() == eHTMLUnit_Integer) {
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)
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)) {
// in quirks mode, treat a % cellspacing value a pixel value.
@ -1249,8 +1242,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
// cols
aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
if (value.GetUnit() != eHTMLUnit_Null) {
if (aAttributes->GetAttribute(nsHTMLAtoms::cols, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mTableData->mCols.SetIntValue(value.GetIntValue(), eCSSUnit_Integer);
else // COLS had no value, so it refers to all columns
@ -1289,22 +1282,22 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (eCompatibility_NavQuirks == mode) {
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetUnit() == eHTMLUnit_Integer) {
nsCSSRect& margin = aData->mMarginData->mMargin;
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)
margin.mRight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
margin.mRight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
}
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
if (value.GetUnit() == eHTMLUnit_Pixel) {
if (value.GetUnit() == eHTMLUnit_Integer) {
nsCSSRect& margin = aData->mMarginData->mMargin;
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)
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) {
nsHTMLValue 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
// have any set.
nsCSSValue padVal;
if (value.GetUnit() == eHTMLUnit_Pixel)
padVal.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
padVal.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else {
// when we support % cellpadding in standard mode, uncomment the following
float pctVal = value.GetPercentValue();
@ -1351,8 +1344,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
}
@ -1360,8 +1353,8 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
// height: value
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
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
// on the table, then the mapping to rules=all will take care of borders in the collapsing model.
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::border, value);
if (((value.GetUnit() == eHTMLUnit_Pixel) &&
(value.GetPixelValue() > 0)) ||
(value.GetUnit() == eHTMLUnit_Empty)) {
if (aAttributes->GetAttribute(nsHTMLAtoms::border, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
((value.GetUnit() == eHTMLUnit_Integer &&
value.GetIntValue() > 0) ||
value.IsEmptyString())) {
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue(1.0f, eCSSUnit_Pixel);
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
@ -1424,10 +1418,10 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
NS_STYLE_BORDER_STYLE_OUTSET;
// bordercolor
nsHTMLValue value;
aAttributes->GetAttribute(nsHTMLAtoms::bordercolor, value);
if ((eHTMLUnit_Color == value.GetUnit()) ||
(eHTMLUnit_ColorName == value.GetUnit())) {
nscolor color = value.GetColorValue();
nscolor color;
if (aAttributes->GetAttribute(nsHTMLAtoms::bordercolor, value) !=
NS_CONTENT_ATTR_NOT_THERE &&
value.GetColorValue(color)) {
if (aData->mMarginData->mBorderColor.mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderColor.mLeft.SetColorValue(color);
if (aData->mMarginData->mBorderColor.mRight.GetUnit() == eCSSUnit_Null)

Просмотреть файл

@ -526,14 +526,14 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::height) {
/* 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;
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* 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;
}
}
@ -591,8 +591,8 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
nsHTMLValue value;
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
else if (value.GetUnit() == eHTMLUnit_Percent)
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
}

Просмотреть файл

@ -299,7 +299,7 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::height) {
/* 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;
}
}
@ -357,8 +357,8 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
nsHTMLValue value;
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
if (value.GetUnit() == eHTMLUnit_Pixel)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetPixelValue(), eCSSUnit_Pixel);
if (value.GetUnit() == eHTMLUnit_Integer)
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
}
}
else if (aData->mSID == eStyleStruct_Text) {

Просмотреть файл

@ -584,19 +584,11 @@ nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::disabled) {
aResult.SetEmptyValue();
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::cols) {
if (aAttribute == nsHTMLAtoms::cols) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::readonly) {
aResult.SetEmptyValue();
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::rows) {
if (aResult.ParseIntWithBounds(aValue, eHTMLUnit_Integer, 0)) {
return NS_CONTENT_ATTR_HAS_VALUE;

Просмотреть файл

@ -218,11 +218,13 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
nsHTMLValue value;
// type: enum
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
else if (value.GetUnit() != eHTMLUnit_Null)
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
NS_CONTENT_ATTR_NOT_THERE) {
if (value.GetUnit() == eHTMLUnit_Enumerated)
aData->mListData->mType.SetIntValue(value.GetIntValue(), 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) {
nsHTMLValue value;
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) {
nsHTMLValue value;
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) {
nsHTMLValue value;
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
nsHTMLValue zero(0, eHTMLUnit_Pixel);
nsHTMLValue zero(0, eHTMLUnit_Integer);
body->SetHTMLAttribute(nsHTMLAtoms::marginwidth, zero, PR_FALSE);
body->SetHTMLAttribute(nsHTMLAtoms::marginheight, zero, PR_FALSE);

Просмотреть файл

@ -253,7 +253,6 @@ HTML_ATOM(strike, "strike")
HTML_ATOM(strong, "strong")
HTML_ATOM(style, "style")
HTML_ATOM(summary, "summary")
HTML_ATOM(suppress, "suppress")
HTML_ATOM(tabindex, "tabindex")
HTML_ATOM(table, "table")
HTML_ATOM(tabstop, "tabstop")

Просмотреть файл

@ -148,10 +148,8 @@ public:
// between different things stored as the same type. Doing
// mUnit & HTMLUNIT_CLASS_MASK should give you the class of type.
//
#define HTMLUNIT_NOSTORE 0x0000
#define HTMLUNIT_STRING 0x0100
#define HTMLUNIT_INTEGER 0x0200
#define HTMLUNIT_PIXEL 0x0400
#define HTMLUNIT_COLOR 0x0800
#define HTMLUNIT_CSSSTYLERULE 0x1000
#define HTMLUNIT_PERCENT 0x2000
@ -159,15 +157,8 @@ public:
#define HTMLUNIT_CLASS_MASK 0xff00
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
eHTMLUnit_String = HTMLUNIT_STRING,
// a color name value
eHTMLUnit_ColorName = HTMLUNIT_STRING | 1,
// a simple int value
eHTMLUnit_Integer = HTMLUNIT_INTEGER,
@ -176,9 +167,6 @@ enum nsHTMLUnit {
// value is a relative proportion of some whole
eHTMLUnit_Proportional = HTMLUNIT_INTEGER | 2,
// screen pixels (screen relative measure)
eHTMLUnit_Pixel = HTMLUNIT_PIXEL,
// an RGBA value
eHTMLUnit_Color = HTMLUNIT_COLOR,
@ -200,7 +188,7 @@ enum nsHTMLUnit {
*/
class nsHTMLValue {
public:
nsHTMLValue(nsHTMLUnit aUnit = eHTMLUnit_Null);
nsHTMLValue();
nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit);
nsHTMLValue(float aValue);
nsHTMLValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
@ -222,24 +210,23 @@ public:
nsHTMLUnit GetUnit(void) const { return (nsHTMLUnit)mUnit; }
PRInt32 GetIntValue(void) const;
PRInt32 GetPixelValue(void) const;
float GetPercentValue(void) const;
nsAString& GetStringValue(nsAString& aBuffer) const;
nsICSSStyleRule* GetCSSStyleRuleValue(void) const;
nscolor GetColorValue(void) const;
PRBool GetColorValue(nscolor& aColor) const;
nsCOMArray<nsIAtom>* AtomArrayValue() const;
PRBool IsEmptyString() const;
/**
* Reset the string to null type, freeing things in the process if necessary.
*/
void Reset(void);
void SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit);
void SetPixelValue(PRInt32 aValue);
void SetPercentValue(float aValue);
void SetStringValue(const nsAString& aValue, nsHTMLUnit aUnit = eHTMLUnit_String);
void SetCSSStyleRuleValue(nsICSSStyleRule* aValue);
void SetColorValue(nscolor aValue);
void SetEmptyValue(void);
/**
* Get this HTML value as a string (depends on the type)
@ -295,10 +282,10 @@ public:
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 aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
* @param aDefaultUnit the unit to use
* @return whether the value could be parsed
*/
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
* 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.
*
* @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 aCanBeProportional true if it can be a proportional value (*)
* @return whether the value could be parsed
@ -322,13 +309,13 @@ public:
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
*
* @param aString the string to parse
* @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 aValueUnit the unit to use (eHTMLUnit_Pixel or Integer)
* @param aValueUnit the unit to use
* @return whether the value could be parsed
*/
PRBool ParseIntWithBounds(const nsAString& aString, nsHTMLUnit aValueUnit,
@ -432,15 +419,6 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
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
{
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
{
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING || mUnit == eHTMLUnit_Null,
NS_ASSERTION(GetUnitClass() == HTMLUNIT_STRING,
"not a string value");
if (GetUnitClass() == HTMLUNIT_STRING && mValue.mString) {
aBuffer = GetDependentString();
@ -471,20 +449,19 @@ inline nsICSSStyleRule* nsHTMLValue::GetCSSStyleRuleValue(void) const
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");
if (mUnit == eHTMLUnit_Color) {
return mValue.mColor;
aColor = mValue.mColor;
return PR_TRUE;
}
if (mUnit == eHTMLUnit_ColorName) {
nscolor color;
if (NS_ColorNameToRGB(GetDependentString(), &color)) {
return color;
}
if (mUnit == eHTMLUnit_String && mValue.mString) {
return NS_ColorNameToRGB(GetDependentString(), &aColor);
}
return NS_RGB(0,0,0);
return PR_FALSE;
}
inline nsCOMArray<nsIAtom>*
@ -499,5 +476,10 @@ inline PRBool nsHTMLValue::operator!=(const nsHTMLValue& aOther) const
return PRBool(! ((*this) == aOther));
}
inline PRBool nsHTMLValue::IsEmptyString() const
{
return mUnit == eHTMLUnit_String && !mValue.mString;
}
#endif /* nsHTMLValue_h___ */

Просмотреть файл

@ -50,26 +50,20 @@
#include "nsICSSStyleRule.h"
#include "nsCSSDeclaration.h"
nsHTMLValue::nsHTMLValue(nsHTMLUnit aUnit)
: mUnit(aUnit)
nsHTMLValue::nsHTMLValue()
: mUnit(eHTMLUnit_String)
{
NS_ASSERTION(GetUnitClass() == HTMLUNIT_NOSTORE, "not a valueless unit");
if (GetUnitClass() != HTMLUNIT_NOSTORE) {
mUnit = eHTMLUnit_Null;
}
mValue.mString = nsnull;
}
nsHTMLValue::nsHTMLValue(PRInt32 aValue, nsHTMLUnit aUnit)
: mUnit(aUnit)
{
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER ||
GetUnitClass() == HTMLUNIT_PIXEL, "unit not an integer unit");
if (GetUnitClass() == HTMLUNIT_INTEGER ||
GetUnitClass() == HTMLUNIT_PIXEL) {
NS_ASSERTION(GetUnitClass() == HTMLUNIT_INTEGER, "unit not an integer unit");
if (GetUnitClass() == HTMLUNIT_INTEGER) {
mValue.mInt = aValue;
} else {
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
}
@ -130,9 +124,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
// Call GetUnitClass() so that we turn StringWithLength into String
PRUint32 unitClass = GetUnitClass();
switch (unitClass) {
case HTMLUNIT_NOSTORE:
return PR_TRUE;
case HTMLUNIT_STRING:
if (mValue.mString && aOther.mValue.mString) {
return GetDependentString().Equals(aOther.GetDependentString());
@ -141,7 +132,6 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
return mValue.mString == aOther.mValue.mString;
case HTMLUNIT_INTEGER:
case HTMLUNIT_PIXEL:
return mValue.mInt == aOther.mValue.mInt;
case HTMLUNIT_COLOR:
@ -211,7 +201,7 @@ void nsHTMLValue::Reset(void)
else if (mUnit == eHTMLUnit_AtomArray) {
delete mValue.mAtomArray;
}
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
@ -224,17 +214,11 @@ void nsHTMLValue::SetIntValue(PRInt32 aValue, nsHTMLUnit aUnit)
if (GetUnitClass() == HTMLUNIT_INTEGER) {
mValue.mInt = aValue;
} 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)
{
Reset();
@ -254,7 +238,7 @@ void nsHTMLValue::SetStringValueInternal(const nsAString& aValue,
nsCheapStringBufferUtils::CopyToBuffer(mValue.mString, aValue);
}
} else {
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
}
@ -282,21 +266,11 @@ void nsHTMLValue::SetColorValue(nscolor aValue)
mValue.mColor = aValue;
}
void nsHTMLValue::SetEmptyValue(void)
{
Reset();
mUnit = eHTMLUnit_Empty;
}
void
nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
{
mUnit = aCopy.mUnit;
switch (GetUnitClass()) {
case HTMLUNIT_NOSTORE:
mValue.mString = nsnull;
break;
case HTMLUNIT_STRING:
if (aCopy.mValue.mString) {
nsCheapStringBufferUtils::Clone(mValue.mString, aCopy.mValue.mString);
@ -306,7 +280,6 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
break;
case HTMLUNIT_INTEGER:
case HTMLUNIT_PIXEL:
mValue.mInt = aCopy.mValue.mInt;
break;
@ -326,7 +299,8 @@ nsHTMLValue::InitializeFrom(const nsHTMLValue& aCopy)
case HTMLUNIT_ATOMARRAY:
mValue.mAtomArray = new nsCOMArray<nsIAtom>(*aCopy.mValue.mAtomArray);
if (!mValue.mAtomArray) {
mUnit = eHTMLUnit_Null;
mUnit = eHTMLUnit_String;
mValue.mString = nsnull;
}
break;
@ -411,11 +385,7 @@ nsHTMLValue::ParseSpecialIntValue(const nsAString& aString,
}
// Straight number is interpreted with the default unit
if (aDefaultUnit == eHTMLUnit_Pixel) {
SetPixelValue(val);
} else {
SetIntValue(val, aDefaultUnit);
}
SetIntValue(val, aDefaultUnit);
return PR_TRUE;
}
@ -448,11 +418,6 @@ nsHTMLValue::ToString(nsAString& aResult) const
}
return PR_TRUE;
case eHTMLUnit_Pixel:
intStr.AppendInt(GetPixelValue());
aResult.Append(intStr);
return PR_TRUE;
case eHTMLUnit_Percent:
{
float percentVal = GetPercentValue() * 100.0f;
@ -463,14 +428,14 @@ nsHTMLValue::ToString(nsAString& aResult) const
}
case eHTMLUnit_Color:
{
nscolor v = GetColorValue();
nscolor v;
GetColorValue(v);
char buf[10];
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
AppendASCIItoUTF16(buf, aResult);
return PR_TRUE;
}
case eHTMLUnit_ColorName:
case eHTMLUnit_String:
GetStringValue(aResult);
return PR_TRUE;
@ -516,11 +481,7 @@ nsHTMLValue::ParseIntWithBounds(const nsAString& aString,
if (NS_SUCCEEDED(ec)) {
val = PR_MAX(val, aMin);
val = PR_MIN(val, aMax);
if (aDefaultUnit == eHTMLUnit_Pixel) {
SetPixelValue(val);
} else {
SetIntValue(val, aDefaultUnit);
}
SetIntValue(val, aDefaultUnit);
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
// it is a very common first char
if ((colorStr.CharAt(0) != '#') && NS_ColorNameToRGB(colorStr, &color)) {
SetStringValue(colorStr, eHTMLUnit_ColorName);
SetStringValue(colorStr, eHTMLUnit_String);
return PR_TRUE;
}