зеркало из https://github.com/mozilla/gecko-dev.git
Bug 236479: Kill nsMappedAttributes::GetAttribute.
Patch by Wladimir Palant (trev@gtchat.de) r=sicking sr=jst
This commit is contained in:
Родитель
de25e0d37a
Коммит
03f96fc967
|
@ -111,6 +111,7 @@ public:
|
|||
|
||||
// Methods to get value. These methods do not convert so only use them
|
||||
// to retrieve the datatype that this nsAttrValue has.
|
||||
inline PRBool IsEmptyString() const;
|
||||
const nsDependentSubstring GetStringValue() const;
|
||||
inline nsIAtom* GetAtomValue() const;
|
||||
inline PRInt32 GetIntegerValue() const;
|
||||
|
@ -360,4 +361,10 @@ nsAttrValue::GetIntInternal() const
|
|||
NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER;
|
||||
}
|
||||
|
||||
inline PRBool
|
||||
nsAttrValue::IsEmptyString() const
|
||||
{
|
||||
return !mBits;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -133,25 +133,6 @@ nsMappedAttributes::SetAndTakeAttr(nsIAtom* aAttrName, nsAttrValue& aValue)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMappedAttributes::GetAttribute(nsIAtom* aAttrName,
|
||||
nsHTMLValue& aValue) const
|
||||
{
|
||||
NS_PRECONDITION(aAttrName, "null name");
|
||||
|
||||
const nsAttrValue* val = GetAttr(aAttrName);
|
||||
|
||||
if (!val) {
|
||||
aValue.Reset();
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
val->ToHTMLValue(aValue);
|
||||
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
|
||||
}
|
||||
|
||||
const nsAttrValue*
|
||||
nsMappedAttributes::GetAttr(nsIAtom* aAttrName) const
|
||||
{
|
||||
|
|
|
@ -60,7 +60,6 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsresult SetAndTakeAttr(nsIAtom* aAttrName, nsAttrValue& aValue);
|
||||
nsresult GetAttribute(nsIAtom* aAttrName, nsHTMLValue& aValue) const;
|
||||
const nsAttrValue* GetAttr(nsIAtom* aAttrName) const;
|
||||
|
||||
PRUint32 Count() const
|
||||
|
|
|
@ -2670,27 +2670,21 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_TextReset) {
|
||||
if (aData->mTextData->mUnicodeBidi.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::dir, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::dir);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mUnicodeBidi.SetIntValue(
|
||||
NS_STYLE_UNICODE_BIDI_EMBED, eCSSUnit_Enumerated);
|
||||
}
|
||||
} else if (aData->mSID == eStyleStruct_Visibility) {
|
||||
if (aData->mDisplayData->mDirection.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::dir, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mDisplayData->mDirection.SetIntValue(value.GetIntValue(),
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::dir);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mDisplayData->mDirection.SetIntValue(value->GetEnumValue(),
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
nsHTMLValue value;
|
||||
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,
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::lang);
|
||||
if (value && value->Type() == nsAttrValue::eString) {
|
||||
aData->mDisplayData->mLang.SetStringValue(value->GetStringValue(),
|
||||
eCSSUnit_String);
|
||||
}
|
||||
}
|
||||
|
@ -2750,10 +2744,9 @@ nsGenericHTMLElement::MapImageAlignAttributeInto(const nsMappedAttributes* aAttr
|
|||
nsRuleData* aRuleData)
|
||||
{
|
||||
if (aRuleData->mSID == eStyleStruct_Display || aRuleData->mSID == eStyleStruct_TextReset) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||
PRUint8 align = (PRUint8)(value.GetIntValue());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
PRInt32 align = value->GetEnumValue();
|
||||
if (aRuleData->mSID == eStyleStruct_Display && aRuleData->mDisplayData->mFloat.GetUnit() == eCSSUnit_Null) {
|
||||
if (align == NS_STYLE_TEXT_ALIGN_LEFT)
|
||||
aRuleData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
|
||||
|
@ -2781,10 +2774,9 @@ nsGenericHTMLElement::MapDivAlignAttributeInto(const nsMappedAttributes* aAttrib
|
|||
if (aRuleData->mSID == eStyleStruct_Text) {
|
||||
if (aRuleData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aRuleData->mTextData->mTextAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aRuleData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2797,38 +2789,42 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
|
|||
if (aData->mSID != eStyleStruct_Margin)
|
||||
return;
|
||||
|
||||
nsHTMLValue value;
|
||||
const nsAttrValue* value;
|
||||
|
||||
// hspace: value
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
|
||||
nsCSSValue hval;
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
hval.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||
hval.SetPercentValue(value.GetPercentValue());
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::hspace);
|
||||
if (value) {
|
||||
nsCSSValue hval;
|
||||
if (value->Type() == nsAttrValue::eInteger)
|
||||
hval.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value->Type() == nsAttrValue::ePercent)
|
||||
hval.SetPercentValue(value->GetPercentValue());
|
||||
|
||||
if (hval.GetUnit() != eCSSUnit_Null) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft = hval;
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight = hval;
|
||||
if (hval.GetUnit() != eCSSUnit_Null) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft = hval;
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight = hval;
|
||||
}
|
||||
}
|
||||
|
||||
// vspace: value
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
|
||||
nsCSSValue vval;
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
vval.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
else if (value.GetUnit() == eHTMLUnit_Percent)
|
||||
vval.SetPercentValue(value.GetPercentValue());
|
||||
|
||||
if (vval.GetUnit() != eCSSUnit_Null) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
||||
margin.mTop = vval;
|
||||
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
margin.mBottom = vval;
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::vspace);
|
||||
if (value) {
|
||||
nsCSSValue vval;
|
||||
if (value->Type() == nsAttrValue::eInteger)
|
||||
vval.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value->Type() == nsAttrValue::ePercent)
|
||||
vval.SetPercentValue(value->GetPercentValue());
|
||||
|
||||
if (vval.GetUnit() != eCSSUnit_Null) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
||||
margin.mTop = vval;
|
||||
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
margin.mBottom = vval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2839,24 +2835,22 @@ nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttr
|
|||
if (aData->mSID != eStyleStruct_Position)
|
||||
return;
|
||||
|
||||
nsHTMLValue value;
|
||||
|
||||
// width: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2867,18 +2861,14 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAtt
|
|||
if (aData->mSID != eStyleStruct_Border)
|
||||
return;
|
||||
|
||||
nsHTMLValue value;
|
||||
|
||||
// border: pixels
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::border, value) ==
|
||||
NS_CONTENT_ATTR_NOT_THERE) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::border);
|
||||
if (!value)
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.GetUnit() != eHTMLUnit_Integer) // something other than Integer
|
||||
value.SetIntValue(0, eHTMLUnit_Integer);
|
||||
|
||||
nscoord val = value.GetIntValue();
|
||||
nscoord val = 0;
|
||||
if (value->Type() == nsAttrValue::eInteger)
|
||||
val = value->GetIntegerValue();
|
||||
|
||||
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
|
||||
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
|
@ -2920,12 +2910,9 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsMappedAttributes* aAtt
|
|||
|
||||
if (aData->mColorData->mBackImage.GetUnit() == eCSSUnit_Null) {
|
||||
// background
|
||||
nsHTMLValue value;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::background, value) &&
|
||||
value.GetUnit() == eHTMLUnit_String) {
|
||||
nsAutoString spec;
|
||||
value.GetStringValue(spec);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::background);
|
||||
if (value && value->Type() == nsAttrValue::eString) {
|
||||
nsAutoString spec(value->GetStringValue());
|
||||
if (!spec.IsEmpty()) {
|
||||
// Resolve url to an absolute url
|
||||
// XXX this breaks if the HTML element has an xml:base
|
||||
|
@ -2959,11 +2946,9 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsMappedAttributes* aAtt
|
|||
|
||||
// bgcolor
|
||||
if (aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::bgcolor);
|
||||
nscolor color;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::bgcolor, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
value.GetColorValue(color)) {
|
||||
if (value && value->GetColorValue(color)) {
|
||||
aData->mColorData->mBackColor.SetColorValue(color);
|
||||
}
|
||||
}
|
||||
|
@ -2978,11 +2963,10 @@ nsGenericHTMLElement::MapScrollingAttributeInto(const nsMappedAttributes* aAttri
|
|||
|
||||
// scrolling
|
||||
if (aData->mDisplayData->mOverflow.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::scrolling, value);
|
||||
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::scrolling);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
PRInt32 mappedValue;
|
||||
switch (value.GetIntValue()) {
|
||||
switch (value->GetEnumValue()) {
|
||||
case NS_STYLE_FRAME_ON:
|
||||
case NS_STYLE_FRAME_SCROLL:
|
||||
case NS_STYLE_FRAME_YES:
|
||||
|
|
|
@ -194,10 +194,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_Display) {
|
||||
if (aData->mDisplayData->mClear.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::clear, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mDisplayData->mClear.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::clear);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mDisplayData->mClear.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -505,8 +505,6 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_Display) {
|
||||
// When display if first asked for, go ahead and get our colors set up.
|
||||
nsHTMLValue value;
|
||||
|
||||
nsIPresShell *presShell = aData->mPresContext->GetPresShell();
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
|
@ -514,22 +512,20 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
if (doc) {
|
||||
nsHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
|
||||
if (styleSheet) {
|
||||
const nsAttrValue* value;
|
||||
nscolor color;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::link, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
value.GetColorValue(color)) {
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::link);
|
||||
if (value && value->GetColorValue(color)) {
|
||||
styleSheet->SetLinkColor(color);
|
||||
}
|
||||
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::alink, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
value.GetColorValue(color)) {
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::alink);
|
||||
if (value && value->GetColorValue(color)) {
|
||||
styleSheet->SetActiveLinkColor(color);
|
||||
}
|
||||
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::vlink, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
value.GetColorValue(color)) {
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::vlink);
|
||||
if (value && value->GetColorValue(color)) {
|
||||
styleSheet->SetVisitedLinkColor(color);
|
||||
}
|
||||
}
|
||||
|
@ -540,11 +536,9 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
if (aData->mSID == eStyleStruct_Color) {
|
||||
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
||||
// color: color
|
||||
nsHTMLValue value;
|
||||
nscolor color;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::text, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
value.GetColorValue(color))
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::text);
|
||||
if (value && value->GetColorValue(color))
|
||||
aData->mColorData->mColor.SetColorValue(color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,62 +222,54 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_Font) {
|
||||
nsRuleDataFont& font = *(aData->mFontData);
|
||||
nsHTMLValue value;
|
||||
|
||||
// face: string list
|
||||
if (font.mFamily.GetUnit() == eCSSUnit_Null) {
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::face, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
value.GetUnit() == eHTMLUnit_String) {
|
||||
nsAutoString familyList;
|
||||
value.GetStringValue(familyList);
|
||||
if (!familyList.IsEmpty()) {
|
||||
font.mFamily.SetStringValue(familyList, eCSSUnit_String);
|
||||
font.mFamilyFromHTML = PR_TRUE;
|
||||
}
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::face);
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
!value->IsEmptyString()) {
|
||||
font.mFamily.SetStringValue(value->GetStringValue(), eCSSUnit_String);
|
||||
font.mFamilyFromHTML = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// pointSize: int, enum
|
||||
// pointSize: int
|
||||
if (font.mSize.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::pointSize, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer ||
|
||||
value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||
PRInt32 val = value.GetIntValue();
|
||||
font.mSize.SetFloatValue((float)val, eCSSUnit_Point);
|
||||
}
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::pointSize);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
font.mSize.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Point);
|
||||
else {
|
||||
// size: int, enum ,
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
||||
nsHTMLUnit unit = value.GetUnit();
|
||||
if (unit == eHTMLUnit_Integer || unit == eHTMLUnit_Enumerated) {
|
||||
PRInt32 size = value.GetIntValue();
|
||||
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);
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::size);
|
||||
if (value) {
|
||||
nsAttrValue::ValueType unit = value->Type();
|
||||
if (unit == nsAttrValue::eInteger || unit == nsAttrValue::eEnum) {
|
||||
PRInt32 size;
|
||||
if (unit == nsAttrValue::eEnum) // int (+/-)
|
||||
size = value->GetEnumValue() + 3; // XXX should be BASEFONT, not three see bug 3875
|
||||
else
|
||||
size = value->GetIntegerValue();
|
||||
|
||||
size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
|
||||
font.mSize.SetIntValue(size, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fontWeight: int, enum
|
||||
// fontWeight: int
|
||||
if (font.mWeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::fontWeight, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) // +/-
|
||||
font.mWeight.SetIntValue(value.GetIntValue(), eCSSUnit_Integer);
|
||||
else if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
font.mWeight.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::fontWeight);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) // +/-
|
||||
font.mWeight.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_Color) {
|
||||
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
||||
// color: color
|
||||
nsHTMLValue value;
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::color);
|
||||
nscolor color;
|
||||
if (NS_CONTENT_ATTR_NOT_THERE !=
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::color, value) &&
|
||||
value.GetColorValue(color)) {
|
||||
if (value && value->GetColorValue(color)) {
|
||||
aData->mColorData->mColor.SetColorValue(color);
|
||||
}
|
||||
}
|
||||
|
@ -286,11 +278,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// Make <a><font color="red">text</font></a> give the text a red underline
|
||||
// in quirks mode. The NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL flag only
|
||||
// affects quirks mode rendering.
|
||||
nsHTMLValue value;
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::color);
|
||||
nscolor color;
|
||||
if (NS_CONTENT_ATTR_NOT_THERE !=
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::color, value) &&
|
||||
value.GetColorValue(color)) {
|
||||
if (value && value->GetColorValue(color)) {
|
||||
nsCSSValue& decoration = aData->mTextData->mDecoration;
|
||||
PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
|
||||
if (decoration.GetUnit() == eCSSUnit_Enumerated) {
|
||||
|
|
|
@ -212,14 +212,11 @@ static void
|
|||
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||
nsRuleData* aData)
|
||||
{
|
||||
nsHTMLValue value;
|
||||
PRBool noshade = PR_FALSE;
|
||||
|
||||
nsHTMLValue colorValue;
|
||||
const nsAttrValue* colorValue = aAttributes->GetAttr(nsHTMLAtoms::color);
|
||||
nscolor color;
|
||||
PRBool colorIsSet = aAttributes->GetAttribute(nsHTMLAtoms::color, colorValue) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
colorValue.GetColorValue(color);
|
||||
PRBool colorIsSet = colorValue && colorValue->GetColorValue(color);
|
||||
|
||||
if (aData->mSID == eStyleStruct_Position ||
|
||||
aData->mSID == eStyleStruct_Border) {
|
||||
|
@ -232,11 +229,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
|
||||
if (aData->mSID == eStyleStruct_Margin) {
|
||||
// align: enum
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
// Map align attribute into auto side margins
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
switch (value.GetIntValue()) {
|
||||
switch (value->GetEnumValue()) {
|
||||
case NS_STYLE_TEXT_ALIGN_LEFT:
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft.SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
|
@ -261,11 +258,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
else if (aData->mSID == eStyleStruct_Position) {
|
||||
// width: integer, percent
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
} else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,9 +276,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// the height includes the top and bottom borders that are initially 1px.
|
||||
// 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_Integer) {
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::size);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
} // else use default value from html.css
|
||||
}
|
||||
}
|
||||
|
@ -291,9 +288,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// 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_Integer) {
|
||||
sizePerSide = (float)value.GetIntValue() / 2.0f;
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::size);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
sizePerSide = (float)value->GetIntegerValue() / 2.0f;
|
||||
if (sizePerSide < 1.0f) {
|
||||
// XXX When the pixel bug is fixed, all the special casing for
|
||||
// subpixel borders should be removed.
|
||||
|
|
|
@ -233,10 +233,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// frameborder: 0 | 1 (| NO | YES in quirks mode)
|
||||
// If frameborder is 0 or No, set border to 0
|
||||
// else leave it as the value set in html.css
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::frameborder, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||
PRInt32 frameborder = value.GetIntValue();
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::frameborder);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
PRInt32 frameborder = value->GetEnumValue();
|
||||
if (NS_STYLE_FRAME_0 == frameborder ||
|
||||
NS_STYLE_FRAME_NO == frameborder ||
|
||||
NS_STYLE_FRAME_OFF == frameborder) {
|
||||
|
@ -253,22 +252,21 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
}
|
||||
else if (aData->mSID == eStyleStruct_Position) {
|
||||
// width: value
|
||||
nsHTMLValue value;
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1783,10 +1783,9 @@ static void
|
|||
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||
nsRuleData* aData)
|
||||
{
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::type, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated &&
|
||||
value.GetIntValue() == NS_FORM_INPUT_IMAGE) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::type);
|
||||
if (value && value->Type() == nsAttrValue::eEnum &&
|
||||
value->GetEnumValue() == NS_FORM_INPUT_IMAGE) {
|
||||
nsGenericHTMLFormElement::MapImageBorderAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLFormElement::MapImageMarginAttributeInto(aAttributes, aData);
|
||||
nsGenericHTMLFormElement::MapImageSizeAttributesInto(aAttributes, aData);
|
||||
|
|
|
@ -212,12 +212,10 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_List) {
|
||||
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);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::type);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -249,12 +249,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_List) {
|
||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
// type: enum
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE) {
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::type);
|
||||
if (value) {
|
||||
if (value->Type() == nsAttrValue::eEnum)
|
||||
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
else
|
||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
|
||||
}
|
||||
|
|
|
@ -184,17 +184,16 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
eCSSUnit_String);
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_Position) {
|
||||
// cols: int (nav4 attribute)
|
||||
nsHTMLValue value;
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::cols, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Char);
|
||||
|
||||
// width: int (html4 attribute == nav4 cols)
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Char);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (!value || value->Type() != nsAttrValue::eInteger) {
|
||||
// cols: int (nav4 attribute)
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::cols);
|
||||
}
|
||||
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_Text) {
|
||||
|
@ -202,21 +201,19 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// wrap: empty
|
||||
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
|
||||
// boundary not just a newline.
|
||||
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated);
|
||||
|
||||
|
||||
// width: int (html4 attribute == nav4 cols)
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (!value || value->Type() != nsAttrValue::eInteger) {
|
||||
// cols: int (nav4 attribute)
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::cols);
|
||||
}
|
||||
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
// Force wrap property on since we want to wrap at a width
|
||||
// boundary not just a newline.
|
||||
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -349,8 +349,6 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
|
||||
|
||||
if (aData->mSID == eStyleStruct_Position) {
|
||||
nsHTMLValue value;
|
||||
|
||||
const nsStyleDisplay* display = aData->mStyleContext->GetStyleDisplay();
|
||||
|
||||
PRBool typeIsBlock = (display->mDisplay == NS_STYLE_DISPLAY_BLOCK);
|
||||
|
@ -358,43 +356,43 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (typeIsBlock) {
|
||||
// width: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
aData->mPositionData->
|
||||
mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||
mWidth.SetFloatValue((float)value->GetIntegerValue(),
|
||||
eCSSUnit_Pixel);
|
||||
} else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
aData->mPositionData->
|
||||
mWidth.SetPercentValue(value.GetPercentValue());
|
||||
mWidth.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
aData->mPositionData->
|
||||
mHeight.SetFloatValue((float)value.GetIntValue(),
|
||||
mHeight.SetFloatValue((float)value->GetIntegerValue(),
|
||||
eCSSUnit_Pixel);
|
||||
} else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||
} else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
aData->mPositionData->
|
||||
mHeight.SetPercentValue(value.GetPercentValue());
|
||||
mHeight.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// size: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::size, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::size);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->
|
||||
mWidth.SetFloatValue((float)value.GetIntValue(),
|
||||
mWidth.SetFloatValue((float)value->GetIntegerValue(),
|
||||
eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
} else if (aData->mSID == eStyleStruct_Display) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||
PRUint8 align = (PRUint8)(value.GetIntValue());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
PRInt32 align = value->GetEnumValue();
|
||||
if (aData->mDisplayData->mFloat.GetUnit() == eCSSUnit_Null) {
|
||||
if (align == NS_STYLE_TEXT_ALIGN_LEFT)
|
||||
aData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_LEFT,
|
||||
|
@ -406,11 +404,9 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
}
|
||||
|
||||
if (aData->mDisplayData->mDisplay == eCSSUnit_Null) {
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
eHTMLUnit_String == value.GetUnit()) {
|
||||
nsAutoString tmp;
|
||||
value.GetStringValue(tmp);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::type);
|
||||
if (value && value->Type() == nsAttrValue::eString) {
|
||||
nsAutoString tmp(value->GetStringValue());
|
||||
if (tmp.EqualsIgnoreCase("line") ||
|
||||
tmp.EqualsIgnoreCase("vert") ||
|
||||
tmp.EqualsIgnoreCase("vertical") ||
|
||||
|
@ -443,12 +439,11 @@ DirectoryMenuMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_List) {
|
||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
// type: enum
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::type, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE) {
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mListData->mType.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::type);
|
||||
if (value) {
|
||||
if (value->Type() == nsAttrValue::eEnum)
|
||||
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
else
|
||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
||||
}
|
||||
|
|
|
@ -198,10 +198,9 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_TableBorder) {
|
||||
if (aData->mTableData->mCaptionSide.GetUnit() == eCSSUnit_Null) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTableData->mCaptionSide.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTableData->mCaptionSide.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -418,32 +418,31 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_Position) {
|
||||
// width: value
|
||||
nsHTMLValue value;
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||
if (value.GetIntValue() > 0)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
if (value->GetIntegerValue() > 0)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
// else 0 implies auto for compatibility.
|
||||
}
|
||||
else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||
if (value.GetPercentValue() > 0.0f)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
||||
else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
if (value->GetPercentValue() > 0.0f)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
// else 0 implies auto for compatibility
|
||||
}
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||
if (value.GetIntValue() > 0)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
if (value->GetIntegerValue() > 0)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
// else 0 implies auto for compatibility.
|
||||
}
|
||||
else if (value.GetUnit() == eHTMLUnit_Percent) {
|
||||
if (value.GetPercentValue() > 0.0f)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value.GetPercentValue());
|
||||
else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
if (value->GetPercentValue() > 0.0f)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
// else 0 implies auto for compatibility
|
||||
}
|
||||
}
|
||||
|
@ -451,21 +450,17 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
else if (aData->mSID == eStyleStruct_Text) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
|
||||
// nowrap: enum
|
||||
nsHTMLValue value;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE) {
|
||||
if (aAttributes->GetAttr(nsHTMLAtoms::nowrap)) {
|
||||
// See if our width is not a integer width.
|
||||
nsHTMLValue widthValue;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, widthValue);
|
||||
if (widthValue.GetUnit() != eHTMLUnit_Integer)
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (!value || value->Type() != nsAttrValue::eInteger)
|
||||
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
@ -473,10 +468,9 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
else if (aData->mSID == eStyleStruct_TextReset) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,20 +229,19 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
if (aData->mSID == eStyleStruct_Position &&
|
||||
aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
// width
|
||||
nsHTMLValue value;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::width, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE) {
|
||||
switch (value.GetUnit()) {
|
||||
case eHTMLUnit_Percent: {
|
||||
aData->mPositionData->mWidth.SetPercentValue(value.GetPercentValue());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (value) {
|
||||
switch (value->Type()) {
|
||||
case nsAttrValue::ePercent: {
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
break;
|
||||
}
|
||||
case eHTMLUnit_Integer: {
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
case nsAttrValue::eInteger: {
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
break;
|
||||
}
|
||||
case eHTMLUnit_Proportional: {
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Proportional);
|
||||
case nsAttrValue::eProportional: {
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetProportionalValue(), eCSSUnit_Proportional);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -253,19 +252,17 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
else if (aData->mSID == eStyleStruct_Text) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_TextReset) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,10 +276,9 @@ void ColMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (aData->mSID == eStyleStruct_Table &&
|
||||
aData->mTableData->mSpan.GetUnit() == eCSSUnit_Null) {
|
||||
// span: int
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::span, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
aData->mTableData->mSpan.SetIntValue(value.GetIntValue(),
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::span);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mTableData->mSpan.SetIntValue(value->GetIntegerValue(),
|
||||
eCSSUnit_Integer);
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ TableRowsCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
|||
if ((count+rows) > aIndex) {
|
||||
body.Item(aIndex-count, aReturn);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
count += rows;
|
||||
|
@ -1049,13 +1049,12 @@ MapTableFrameInto(const nsMappedAttributes* aAttributes,
|
|||
if (aData->mMarginData->mBorderStyle.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mBorderStyle.mBottom.SetIntValue(aBorderStyle, eCSSUnit_Enumerated);
|
||||
|
||||
nsHTMLValue frameValue;
|
||||
// 0 out the sides that we want to hide based on the frame attribute
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::frame, frameValue);
|
||||
const nsAttrValue* frameValue = aAttributes->GetAttr(nsHTMLAtoms::frame);
|
||||
|
||||
if (frameValue.GetUnit() == eHTMLUnit_Enumerated) {
|
||||
if (frameValue && frameValue->Type() == nsAttrValue::eEnum) {
|
||||
// adjust the border style based on the value of frame
|
||||
switch (frameValue.GetIntValue())
|
||||
switch (frameValue->GetEnumValue())
|
||||
{
|
||||
case NS_STYLE_TABLE_FRAME_NONE:
|
||||
aData->mMarginData->mBorderStyle.mLeft.SetIntValue(NS_STYLE_BORDER_STYLE_NONE, eCSSUnit_Enumerated);
|
||||
|
@ -1101,46 +1100,30 @@ static void
|
|||
MapTableBorderInto(const nsMappedAttributes* aAttributes,
|
||||
nsRuleData* aData, PRUint8 aBorderStyle)
|
||||
{
|
||||
nsHTMLValue borderValue;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::border, borderValue) ==
|
||||
NS_CONTENT_ATTR_NOT_THERE) {
|
||||
// the absence of "border" with the presence of "frame" implies
|
||||
// border = 1 pixel
|
||||
if (!aAttributes->GetAttr(nsHTMLAtoms::frame)) {
|
||||
return;
|
||||
}
|
||||
borderValue.SetIntValue(1, eHTMLUnit_Integer);
|
||||
}
|
||||
const nsAttrValue* borderValue = aAttributes->GetAttr(nsHTMLAtoms::border);
|
||||
if (!borderValue && !aAttributes->GetAttr(nsHTMLAtoms::frame))
|
||||
return;
|
||||
|
||||
if (borderValue.GetUnit() != eHTMLUnit_Integer) {
|
||||
// empty values of border get rules=all and frame=border
|
||||
if (aData->mTableData) {
|
||||
// the absence of "border" with the presence of "frame" implies
|
||||
// border = 1 pixel
|
||||
PRInt32 borderThickness = 1;
|
||||
|
||||
if (borderValue && borderValue->Type() == nsAttrValue::eInteger)
|
||||
borderThickness = borderValue->GetIntegerValue();
|
||||
|
||||
if (aData->mTableData) {
|
||||
if (0 != borderThickness) {
|
||||
// border != 0 implies rules=all and frame=border
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
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.GetIntValue();
|
||||
|
||||
if (aData->mMarginData) {
|
||||
// by default, set all border sides to the specified width
|
||||
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
|
@ -1177,20 +1160,19 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
|
||||
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
// cellspacing
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::cellspacing, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::cellspacing);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
if (aData->mTableData->mBorderSpacingX.GetUnit() == eCSSUnit_Null)
|
||||
aData->mTableData->mBorderSpacingX.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
aData->mTableData->mBorderSpacingX.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
if (aData->mTableData->mBorderSpacingY.GetUnit() == eCSSUnit_Null)
|
||||
aData->mTableData->mBorderSpacingY.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
aData->mTableData->mBorderSpacingY.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
else if ((value.GetUnit() == eHTMLUnit_Percent) && (eCompatibility_NavQuirks == mode)) {
|
||||
else if (value && value->Type() == nsAttrValue::ePercent && eCompatibility_NavQuirks == mode) {
|
||||
// in quirks mode, treat a % cellspacing value a pixel value.
|
||||
if (aData->mTableData->mBorderSpacingX.GetUnit() == eCSSUnit_Null)
|
||||
aData->mTableData->mBorderSpacingX.SetFloatValue(100.0f * value.GetPercentValue(), eCSSUnit_Pixel);
|
||||
aData->mTableData->mBorderSpacingX.SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel);
|
||||
if (aData->mTableData->mBorderSpacingY.GetUnit() == eCSSUnit_Null)
|
||||
aData->mTableData->mBorderSpacingY.SetFloatValue(100.0f * value.GetPercentValue(), eCSSUnit_Pixel);
|
||||
aData->mTableData->mBorderSpacingY.SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1199,27 +1181,27 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
MapTableBorderInto(aAttributes, aData, 0);
|
||||
|
||||
nsHTMLValue value;
|
||||
const nsAttrValue* value;
|
||||
// layout
|
||||
if (aData->mTableData->mLayout.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::layout, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTableData->mLayout.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::layout);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTableData->mLayout.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
// cols
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::cols, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE) {
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
aData->mTableData->mCols.SetIntValue(value.GetIntValue(), eCSSUnit_Integer);
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::cols);
|
||||
if (value) {
|
||||
if (value->Type() == nsAttrValue::eInteger)
|
||||
aData->mTableData->mCols.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
|
||||
else // COLS had no value, so it refers to all columns
|
||||
aData->mTableData->mCols.SetIntValue(NS_STYLE_TABLE_COLS_ALL, eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
// rules
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::rules, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTableData->mRules.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::rules);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTableData->mRules.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_Margin) {
|
||||
|
@ -1228,12 +1210,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
// align; Check for enumerated type (it may be another type if
|
||||
// illegal)
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated) {
|
||||
if ((NS_STYLE_TEXT_ALIGN_CENTER == value.GetIntValue()) ||
|
||||
(NS_STYLE_TEXT_ALIGN_MOZ_CENTER == value.GetIntValue())) {
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
if (value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_CENTER ||
|
||||
value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft.SetAutoValue();
|
||||
|
@ -1246,24 +1227,24 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// vspace is mapped into top and bottom margins
|
||||
// - *** Quirks Mode only ***
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::hspace, value);
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::hspace);
|
||||
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
margin.mLeft.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
margin.mRight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::vspace, value);
|
||||
value = aAttributes->GetAttr(nsHTMLAtoms::vspace);
|
||||
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) {
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
||||
margin.mTop.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
margin.mTop.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
margin.mBottom.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
margin.mBottom.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1272,33 +1253,35 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
|
||||
|
||||
if (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value);
|
||||
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_Integer)
|
||||
padVal.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
else {
|
||||
// when we support % cellpadding in standard mode, uncomment the following
|
||||
float pctVal = value.GetPercentValue();
|
||||
//if (eCompatibility_NavQuirks == mode) {
|
||||
// in quirks mode treat a pct cellpadding value as a pixel value
|
||||
padVal.SetFloatValue(100.0f * pctVal, eCSSUnit_Pixel);
|
||||
//}
|
||||
//else {
|
||||
// padVal.SetPercentValue(pctVal);
|
||||
//}
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::cellpadding);
|
||||
if (value) {
|
||||
nsAttrValue::ValueType valueType = value->Type();
|
||||
if (valueType == nsAttrValue::eInteger || valueType == nsAttrValue::ePercent) {
|
||||
// We have cellpadding. This will override our padding values if we don't
|
||||
// have any set.
|
||||
nsCSSValue padVal;
|
||||
if (valueType == nsAttrValue::eInteger)
|
||||
padVal.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else {
|
||||
// when we support % cellpadding in standard mode, uncomment the following
|
||||
float pctVal = value->GetPercentValue();
|
||||
//if (eCompatibility_NavQuirks == mode) {
|
||||
// in quirks mode treat a pct cellpadding value as a pixel value
|
||||
padVal.SetFloatValue(100.0f * pctVal, eCSSUnit_Pixel);
|
||||
//}
|
||||
//else {
|
||||
// padVal.SetPercentValue(pctVal);
|
||||
//}
|
||||
}
|
||||
if (aData->mMarginData->mPadding.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mLeft = padVal;
|
||||
if (aData->mMarginData->mPadding.mRight.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mRight = padVal;
|
||||
if (aData->mMarginData->mPadding.mTop.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mTop = padVal;
|
||||
if (aData->mMarginData->mPadding.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mBottom = padVal;
|
||||
}
|
||||
if (aData->mMarginData->mPadding.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mLeft = padVal;
|
||||
if (aData->mMarginData->mPadding.mRight.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mRight = padVal;
|
||||
if (aData->mMarginData->mPadding.mTop.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mTop = padVal;
|
||||
if (aData->mMarginData->mPadding.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mPadding.mBottom = padVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1306,23 +1289,22 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
|
||||
|
||||
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
nsHTMLValue value;
|
||||
// width: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::width, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1340,12 +1322,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (NS_STYLE_BORDER_SEPARATE == tableStyle->mBorderCollapse) {
|
||||
// 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;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::border, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
((value.GetUnit() == eHTMLUnit_Integer &&
|
||||
value.GetIntValue() > 0) ||
|
||||
value.IsEmptyString())) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::border);
|
||||
if (value &&
|
||||
((value->Type() == nsAttrValue::eInteger &&
|
||||
value->GetIntegerValue() > 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)
|
||||
|
@ -1383,11 +1364,9 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
? NS_STYLE_BORDER_STYLE_BG_OUTSET :
|
||||
NS_STYLE_BORDER_STYLE_OUTSET;
|
||||
// bordercolor
|
||||
nsHTMLValue value;
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::bordercolor);
|
||||
nscolor color;
|
||||
if (aAttributes->GetAttribute(nsHTMLAtoms::bordercolor, value) !=
|
||||
NS_CONTENT_ATTR_NOT_THERE &&
|
||||
value.GetColorValue(color)) {
|
||||
if (value && 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)
|
||||
|
|
|
@ -569,31 +569,28 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_Position) {
|
||||
// height: value
|
||||
nsHTMLValue value;
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||
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());
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_Text) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_TextReset) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -339,29 +339,26 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
{
|
||||
if (aData->mSID == eStyleStruct_Position) {
|
||||
// height: value
|
||||
nsHTMLValue value;
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::height, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Integer)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value.GetIntValue(), eCSSUnit_Pixel);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_Text) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
else if (aData->mSID == eStyleStruct_TextReset) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
nsHTMLValue value;
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::valign, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value.GetIntValue(), eCSSUnit_Enumerated);
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче