зеркало из https://github.com/mozilla/pjs.git
Convert attribute mapping functions to property getters instead of accessing struct members. (Bug 636039, patch 7) r=bzbarsky
This commit is contained in:
Родитель
fb2a048576
Коммит
b82b8c28d3
|
@ -1648,19 +1648,19 @@ nsGenericHTMLElement::MapCommonAttributesExceptHiddenInto(const nsMappedAttribut
|
|||
nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(UserInterface)) {
|
||||
nsRuleDataUserInterface *ui = aData->mUserInterfaceData;
|
||||
if (ui->mUserModify.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* userModify = aData->ValueForUserModify();
|
||||
if (userModify->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value =
|
||||
aAttributes->GetAttr(nsGkAtoms::contenteditable);
|
||||
if (value) {
|
||||
if (value->Equals(nsGkAtoms::_empty, eCaseMatters) ||
|
||||
value->Equals(nsGkAtoms::_true, eIgnoreCase)) {
|
||||
ui->mUserModify.SetIntValue(NS_STYLE_USER_MODIFY_READ_WRITE,
|
||||
eCSSUnit_Enumerated);
|
||||
userModify->SetIntValue(NS_STYLE_USER_MODIFY_READ_WRITE,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
else if (value->Equals(nsGkAtoms::_false, eIgnoreCase)) {
|
||||
ui->mUserModify.SetIntValue(NS_STYLE_USER_MODIFY_READ_ONLY,
|
||||
eCSSUnit_Enumerated);
|
||||
userModify->SetIntValue(NS_STYLE_USER_MODIFY_READ_ONLY,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1669,8 +1669,8 @@ nsGenericHTMLElement::MapCommonAttributesExceptHiddenInto(const nsMappedAttribut
|
|||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Visibility)) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::lang);
|
||||
if (value && value->Type() == nsAttrValue::eString) {
|
||||
aData->mDisplayData->mLang.SetStringValue(value->GetStringValue(),
|
||||
eCSSUnit_Ident);
|
||||
aData->ValueForLang()->SetStringValue(value->GetStringValue(),
|
||||
eCSSUnit_Ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1682,10 +1682,10 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu
|
|||
nsGenericHTMLElement::MapCommonAttributesExceptHiddenInto(aAttributes, aData);
|
||||
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
|
||||
nsRuleDataDisplay* disp = aData->mDisplayData;
|
||||
if (disp->mDisplay.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* display = aData->ValueForDisplay();
|
||||
if (display->GetUnit() == eCSSUnit_Null) {
|
||||
if (aAttributes->IndexOfAttr(nsGkAtoms::hidden, kNameSpaceID_None) >= 0) {
|
||||
disp->mDisplay.SetIntValue(NS_STYLE_DISPLAY_NONE, eCSSUnit_Enumerated);
|
||||
display->SetIntValue(NS_STYLE_DISPLAY_NONE, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1787,22 +1787,27 @@ nsGenericHTMLElement::MapImageAlignAttributeInto(const nsMappedAttributes* aAttr
|
|||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
PRInt32 align = value->GetEnumValue();
|
||||
if ((aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) &&
|
||||
aRuleData->mDisplayData->mFloat.GetUnit() == eCSSUnit_Null) {
|
||||
if (align == NS_STYLE_TEXT_ALIGN_LEFT)
|
||||
aRuleData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
|
||||
else if (align == NS_STYLE_TEXT_ALIGN_RIGHT)
|
||||
aRuleData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_RIGHT, eCSSUnit_Enumerated);
|
||||
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
|
||||
nsCSSValue* cssFloat = aRuleData->ValueForCssFloat();
|
||||
if (cssFloat->GetUnit() == eCSSUnit_Null) {
|
||||
if (align == NS_STYLE_TEXT_ALIGN_LEFT) {
|
||||
cssFloat->SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
|
||||
} else if (align == NS_STYLE_TEXT_ALIGN_RIGHT) {
|
||||
cssFloat->SetIntValue(NS_STYLE_FLOAT_RIGHT, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) &&
|
||||
aRuleData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
switch (align) {
|
||||
case NS_STYLE_TEXT_ALIGN_LEFT:
|
||||
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
||||
break;
|
||||
default:
|
||||
aRuleData->mTextData->mVerticalAlign.SetIntValue(align, eCSSUnit_Enumerated);
|
||||
break;
|
||||
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
|
||||
nsCSSValue* verticalAlign = aRuleData->ValueForVerticalAlign();
|
||||
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
|
||||
switch (align) {
|
||||
case NS_STYLE_TEXT_ALIGN_LEFT:
|
||||
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
||||
break;
|
||||
default:
|
||||
verticalAlign->SetIntValue(align, eCSSUnit_Enumerated);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1814,11 +1819,12 @@ nsGenericHTMLElement::MapDivAlignAttributeInto(const nsMappedAttributes* aAttrib
|
|||
nsRuleData* aRuleData)
|
||||
{
|
||||
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
|
||||
if (aRuleData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* textAlign = aRuleData->ValueForTextAlign();
|
||||
if (textAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aRuleData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1843,11 +1849,12 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
|
|||
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;
|
||||
nsCSSValue* left = aData->ValueForMarginLeftValue();
|
||||
if (left->GetUnit() == eCSSUnit_Null)
|
||||
*left = hval;
|
||||
nsCSSValue* right = aData->ValueForMarginRightValue();
|
||||
if (right->GetUnit() == eCSSUnit_Null)
|
||||
*right = hval;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1861,11 +1868,12 @@ nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAtt
|
|||
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;
|
||||
nsCSSValue* top = aData->ValueForMarginTop();
|
||||
if (top->GetUnit() == eCSSUnit_Null)
|
||||
*top = vval;
|
||||
nsCSSValue* bottom = aData->ValueForMarginBottom();
|
||||
if (bottom->GetUnit() == eCSSUnit_Null)
|
||||
*bottom = vval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1878,21 +1886,23 @@ nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttr
|
|||
return;
|
||||
|
||||
// width: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* width = aData->ValueForWidth();
|
||||
if (width->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
width->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* height = aData->ValueForHeight();
|
||||
if (height->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
height->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1912,35 +1922,44 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAtt
|
|||
if (value->Type() == nsAttrValue::eInteger)
|
||||
val = value->GetIntegerValue();
|
||||
|
||||
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
|
||||
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
borderWidth.mLeft.SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
if (borderWidth.mTop.GetUnit() == eCSSUnit_Null)
|
||||
borderWidth.mTop.SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
if (borderWidth.mRight.GetUnit() == eCSSUnit_Null)
|
||||
borderWidth.mRight.SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
if (borderWidth.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
borderWidth.mBottom.SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
|
||||
if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderLeftWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
|
||||
if (borderTopWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderTopWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
|
||||
if (borderRightWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderRightWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
|
||||
if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderBottomWidth->SetFloatValue((float)val, eCSSUnit_Pixel);
|
||||
|
||||
nsCSSRect& borderStyle = aData->mMarginData->mBorderStyle;
|
||||
if (borderStyle.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
borderStyle.mLeft.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
if (borderStyle.mTop.GetUnit() == eCSSUnit_Null)
|
||||
borderStyle.mTop.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
if (borderStyle.mRight.GetUnit() == eCSSUnit_Null)
|
||||
borderStyle.mRight.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
if (borderStyle.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
borderStyle.mBottom.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderLeftStyle = aData->ValueForBorderLeftStyleValue();
|
||||
if (borderLeftStyle->GetUnit() == eCSSUnit_Null)
|
||||
borderLeftStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderTopStyle = aData->ValueForBorderTopStyle();
|
||||
if (borderTopStyle->GetUnit() == eCSSUnit_Null)
|
||||
borderTopStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderRightStyle = aData->ValueForBorderRightStyleValue();
|
||||
if (borderRightStyle->GetUnit() == eCSSUnit_Null)
|
||||
borderRightStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderBottomStyle = aData->ValueForBorderBottomStyle();
|
||||
if (borderBottomStyle->GetUnit() == eCSSUnit_Null)
|
||||
borderBottomStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID, eCSSUnit_Enumerated);
|
||||
|
||||
nsCSSRect& borderColor = aData->mMarginData->mBorderColor;
|
||||
if (borderColor.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
borderColor.mLeft.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
if (borderColor.mTop.GetUnit() == eCSSUnit_Null)
|
||||
borderColor.mTop.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
if (borderColor.mRight.GetUnit() == eCSSUnit_Null)
|
||||
borderColor.mRight.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
if (borderColor.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
borderColor.mBottom.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderLeftColor = aData->ValueForBorderLeftColorValue();
|
||||
if (borderLeftColor->GetUnit() == eCSSUnit_Null)
|
||||
borderLeftColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderTopColor = aData->ValueForBorderTopColor();
|
||||
if (borderTopColor->GetUnit() == eCSSUnit_Null)
|
||||
borderTopColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderRightColor = aData->ValueForBorderRightColorValue();
|
||||
if (borderRightColor->GetUnit() == eCSSUnit_Null)
|
||||
borderRightColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderBottomColor = aData->ValueForBorderBottomColor();
|
||||
if (borderBottomColor->GetUnit() == eCSSUnit_Null)
|
||||
borderBottomColor->SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1951,7 +1970,8 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
|
|||
return;
|
||||
|
||||
nsPresContext* presContext = aData->mPresContext;
|
||||
if (aData->mColorData->mBackImage.GetUnit() == eCSSUnit_Null &&
|
||||
nsCSSValue* backImage = aData->ValueForBackgroundImage();
|
||||
if (backImage->GetUnit() == eCSSUnit_Null &&
|
||||
presContext->UseDocumentColors()) {
|
||||
// background
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::background);
|
||||
|
@ -1981,8 +2001,7 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
|
|||
new nsCSSValue::Image(uri, buffer, doc->GetDocumentURI(),
|
||||
doc->NodePrincipal(), doc);
|
||||
if (NS_LIKELY(img)) {
|
||||
nsCSSValueList* list =
|
||||
aData->mColorData->mBackImage.SetListValue();
|
||||
nsCSSValueList* list = backImage->SetListValue();
|
||||
list->mValue.SetImageValue(img);
|
||||
}
|
||||
}
|
||||
|
@ -1991,7 +2010,7 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
|
|||
else if (presContext->CompatibilityMode() == eCompatibility_NavQuirks) {
|
||||
// in NavQuirks mode, allow the empty string to set the
|
||||
// background to empty
|
||||
nsCSSValueList* list = aData->mColorData->mBackImage.SetListValue();
|
||||
nsCSSValueList* list = backImage->SetListValue();
|
||||
list->mValue.SetNoneValue();
|
||||
}
|
||||
}
|
||||
|
@ -2005,12 +2024,13 @@ nsGenericHTMLElement::MapBGColorInto(const nsMappedAttributes* aAttributes,
|
|||
if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Background)))
|
||||
return;
|
||||
|
||||
if (aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null &&
|
||||
nsCSSValue* backColor = aData->ValueForBackgroundColor();
|
||||
if (backColor->GetUnit() == eCSSUnit_Null &&
|
||||
aData->mPresContext->UseDocumentColors()) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::bgcolor);
|
||||
nscolor color;
|
||||
if (value && value->GetColorValue(color)) {
|
||||
aData->mColorData->mBackColor.SetColorValue(color);
|
||||
backColor->SetColorValue(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2032,8 +2052,8 @@ nsGenericHTMLElement::MapScrollingAttributeInto(const nsMappedAttributes* aAttri
|
|||
|
||||
// scrolling
|
||||
nsCSSValue* overflowValues[2] = {
|
||||
&aData->mDisplayData->mOverflowX,
|
||||
&aData->mDisplayData->mOverflowY,
|
||||
aData->ValueForOverflowX(),
|
||||
aData->ValueForOverflowY(),
|
||||
};
|
||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(overflowValues); ++i) {
|
||||
if (overflowValues[i]->GetUnit() == eCSSUnit_Null) {
|
||||
|
|
|
@ -133,10 +133,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
|
||||
if (aData->mDisplayData->mClear.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* clear = aData->ValueForClear();
|
||||
if (clear->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::clear);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mDisplayData->mClear.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
clear->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -389,13 +389,14 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
}
|
||||
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
|
||||
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null &&
|
||||
nsCSSValue *colorValue = aData->ValueForColor();
|
||||
if (colorValue->GetUnit() == eCSSUnit_Null &&
|
||||
aData->mPresContext->UseDocumentColors()) {
|
||||
// color: color
|
||||
nscolor color;
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::text);
|
||||
if (value && value->GetColorValue(color))
|
||||
aData->mColorData->mColor.SetColorValue(color);
|
||||
colorValue->SetColorValue(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,22 +186,22 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
|
||||
nsRuleDataFont& font = *(aData->mFontData);
|
||||
|
||||
// face: string list
|
||||
if (font.mFamily.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* family = aData->ValueForFontFamily();
|
||||
if (family->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
!value->IsEmptyString()) {
|
||||
font.mFamily.SetStringValue(value->GetStringValue(), eCSSUnit_Families);
|
||||
family->SetStringValue(value->GetStringValue(), eCSSUnit_Families);
|
||||
}
|
||||
}
|
||||
|
||||
// pointSize: int
|
||||
if (font.mSize.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* fontSize = aData->ValueForFontSize();
|
||||
if (fontSize->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::pointSize);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
font.mSize.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Point);
|
||||
fontSize->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Point);
|
||||
else {
|
||||
// size: int, enum ,
|
||||
value = aAttributes->GetAttr(nsGkAtoms::size);
|
||||
|
@ -215,27 +215,29 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
size = value->GetIntegerValue();
|
||||
|
||||
size = ((0 < size) ? ((size < 8) ? size : 7) : 1);
|
||||
font.mSize.SetIntValue(size, eCSSUnit_Enumerated);
|
||||
fontSize->SetIntValue(size, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fontWeight: int
|
||||
if (font.mWeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* fontWeight = aData->ValueForFontWeight();
|
||||
if (fontWeight->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::fontWeight);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) // +/-
|
||||
font.mWeight.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
|
||||
fontWeight->SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
|
||||
if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null &&
|
||||
nsCSSValue* colorValue = aData->ValueForColor();
|
||||
if (colorValue->GetUnit() == eCSSUnit_Null &&
|
||||
aData->mPresContext->UseDocumentColors()) {
|
||||
// color: color
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
||||
nscolor color;
|
||||
if (value && value->GetColorValue(color)) {
|
||||
aData->mColorData->mColor.SetColorValue(color);
|
||||
colorValue->SetColorValue(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,12 +248,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
||||
nscolor color;
|
||||
if (value && value->GetColorValue(color)) {
|
||||
nsCSSValue& decoration = aData->mTextData->mDecoration;
|
||||
nsCSSValue* decoration = aData->ValueForTextDecoration();
|
||||
PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
|
||||
if (decoration.GetUnit() == eCSSUnit_Enumerated) {
|
||||
newValue |= decoration.GetIntValue();
|
||||
if (decoration->GetUnit() == eCSSUnit_Enumerated) {
|
||||
newValue |= decoration->GetIntValue();
|
||||
}
|
||||
decoration.SetIntValue(newValue, eCSSUnit_Enumerated);
|
||||
decoration->SetIntValue(newValue, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsPresContext.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
#include "nsRuleData.h"
|
||||
#include "nsCSSProps.h"
|
||||
|
||||
class nsHTMLHRElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLHRElement,
|
||||
|
@ -175,45 +176,48 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum) {
|
||||
// Map align attribute into auto side margins
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
|
||||
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
|
||||
switch (value->GetEnumValue()) {
|
||||
case NS_STYLE_TEXT_ALIGN_LEFT:
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft.SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight.SetAutoValue();
|
||||
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
||||
marginLeft->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
if (marginRight->GetUnit() == eCSSUnit_Null)
|
||||
marginRight->SetAutoValue();
|
||||
break;
|
||||
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft.SetAutoValue();
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight.SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
||||
marginLeft->SetAutoValue();
|
||||
if (marginRight->GetUnit() == eCSSUnit_Null)
|
||||
marginRight->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
break;
|
||||
case NS_STYLE_TEXT_ALIGN_CENTER:
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft.SetAutoValue();
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight.SetAutoValue();
|
||||
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
||||
marginLeft->SetAutoValue();
|
||||
if (marginRight->GetUnit() == eCSSUnit_Null)
|
||||
marginRight->SetAutoValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
||||
// width: integer, percent
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* width = aData->ValueForWidth();
|
||||
if (width->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
} else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
width->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* height = aData->ValueForHeight();
|
||||
if (height->GetUnit() == eCSSUnit_Null) {
|
||||
// size: integer
|
||||
if (noshade) {
|
||||
// noshade case: size is set using the border
|
||||
aData->mPositionData->mHeight.SetAutoValue();
|
||||
height->SetAutoValue();
|
||||
} else {
|
||||
// normal case
|
||||
// the height includes the top and bottom borders that are initially 1px.
|
||||
|
@ -221,7 +225,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// removing all but the top border.
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
} // else use default value from html.css
|
||||
}
|
||||
}
|
||||
|
@ -244,51 +248,57 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
} else {
|
||||
sizePerSide = 1.0f; // default to a 2px high line
|
||||
}
|
||||
nsCSSRect& borderWidth = aData->mMarginData->mBorderWidth;
|
||||
if (borderWidth.mTop.GetUnit() == eCSSUnit_Null) {
|
||||
borderWidth.mTop.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
|
||||
if (borderTopWidth->GetUnit() == eCSSUnit_Null) {
|
||||
borderTopWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
}
|
||||
if (allSides) {
|
||||
if (borderWidth.mRight.GetUnit() == eCSSUnit_Null) {
|
||||
borderWidth.mRight.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
|
||||
if (borderRightWidth->GetUnit() == eCSSUnit_Null) {
|
||||
borderRightWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
}
|
||||
if (borderWidth.mBottom.GetUnit() == eCSSUnit_Null) {
|
||||
borderWidth.mBottom.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
|
||||
if (borderBottomWidth->GetUnit() == eCSSUnit_Null) {
|
||||
borderBottomWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
}
|
||||
if (borderWidth.mLeft.GetUnit() == eCSSUnit_Null) {
|
||||
borderWidth.mLeft.SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
|
||||
if (borderLeftWidth->GetUnit() == eCSSUnit_Null) {
|
||||
borderLeftWidth->SetFloatValue(sizePerSide, eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
|
||||
nsCSSRect& borderStyle = aData->mMarginData->mBorderStyle;
|
||||
if (borderStyle.mTop.GetUnit() == eCSSUnit_Null) {
|
||||
borderStyle.mTop.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderTopStyle = aData->ValueForBorderTopStyle();
|
||||
if (borderTopStyle->GetUnit() == eCSSUnit_Null) {
|
||||
borderTopStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
if (allSides) {
|
||||
if (borderStyle.mRight.GetUnit() == eCSSUnit_Null) {
|
||||
borderStyle.mRight.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
nsCSSValue* borderRightStyle = aData->ValueForBorderRightStyleValue();
|
||||
if (borderRightStyle->GetUnit() == eCSSUnit_Null) {
|
||||
borderRightStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
nsCSSValue* borderBottomStyle = aData->ValueForBorderBottomStyle();
|
||||
if (borderBottomStyle->GetUnit() == eCSSUnit_Null) {
|
||||
borderBottomStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
if (borderStyle.mBottom.GetUnit() == eCSSUnit_Null) {
|
||||
borderStyle.mBottom.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
if (borderStyle.mLeft.GetUnit() == eCSSUnit_Null) {
|
||||
borderStyle.mLeft.SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
eCSSUnit_Enumerated);
|
||||
nsCSSValue* borderLeftStyle = aData->ValueForBorderLeftStyleValue();
|
||||
if (borderLeftStyle->GetUnit() == eCSSUnit_Null) {
|
||||
borderLeftStyle->SetIntValue(NS_STYLE_BORDER_STYLE_SOLID,
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
// If it would be noticeable, set the border radius to
|
||||
// 10000px on all corners; this triggers the clamping to make
|
||||
// circular ends. This assumes the <hr> isn't larger than
|
||||
// that in *both* dimensions.
|
||||
nsCSSCornerSizes& corners = aData->mMarginData->mBorderRadius;
|
||||
|
||||
NS_FOR_CSS_FULL_CORNERS(c) {
|
||||
nsCSSValue& dimen = corners.GetCorner(c);
|
||||
if (dimen.GetUnit() == eCSSUnit_Null) {
|
||||
dimen.SetFloatValue(10000.0f, eCSSUnit_Pixel);
|
||||
for (const nsCSSProperty* props =
|
||||
nsCSSProps::SubpropertyEntryFor(eCSSProperty_border_radius);
|
||||
*props != eCSSProperty_UNKNOWN; ++props) {
|
||||
nsCSSValue* dimen = aData->ValueFor(*props);
|
||||
if (dimen->GetUnit() == eCSSUnit_Null) {
|
||||
dimen->SetFloatValue(10000.0f, eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -296,10 +306,11 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
|
||||
// color: a color
|
||||
// (we got the color attribute earlier)
|
||||
nsCSSValue* colorValue = aData->ValueForColor();
|
||||
if (colorIsSet &&
|
||||
aData->mColorData->mColor.GetUnit() == eCSSUnit_Null &&
|
||||
colorValue->GetUnit() == eCSSUnit_Null &&
|
||||
aData->mPresContext->UseDocumentColors()) {
|
||||
aData->mColorData->mColor.SetColorValue(color);
|
||||
colorValue->SetColorValue(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,34 +202,40 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (NS_STYLE_FRAME_0 == frameborder ||
|
||||
NS_STYLE_FRAME_NO == frameborder ||
|
||||
NS_STYLE_FRAME_OFF == frameborder) {
|
||||
if (aData->mMarginData->mBorderWidth.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mBorderWidth.mLeft.SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
if (aData->mMarginData->mBorderWidth.mRight.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mBorderWidth.mRight.SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mBorderWidth.mTop.SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mBorderWidth.mBottom.SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
|
||||
if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderLeftWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
|
||||
if (borderRightWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderRightWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
|
||||
if (borderTopWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderTopWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
|
||||
if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderBottomWidth->SetFloatValue(0.0f, eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
||||
// width: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* width = aData->ValueForWidth();
|
||||
if (width->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
width->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* height = aData->ValueForHeight();
|
||||
if (height->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
height->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,11 +152,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
|
||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* listStyleType = aData->ValueForListStyleType();
|
||||
if (listStyleType->GetUnit() == eCSSUnit_Null) {
|
||||
// type: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,14 +199,15 @@ static void
|
|||
MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
|
||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* listStyleType = aData->ValueForListStyleType();
|
||||
if (listStyleType->GetUnit() == eCSSUnit_Null) {
|
||||
// type: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
||||
if (value) {
|
||||
if (value->Type() == nsAttrValue::eEnum)
|
||||
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
else
|
||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
|
||||
listStyleType->SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,14 +140,15 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
|
||||
// variable
|
||||
nsCSSValue* family = aData->ValueForFontFamily();
|
||||
if (aAttributes->GetAttr(nsGkAtoms::variable) &&
|
||||
aData->mFontData->mFamily.GetUnit() == eCSSUnit_Null) {
|
||||
aData->mFontData->mFamily.SetStringValue(NS_LITERAL_STRING("serif"),
|
||||
eCSSUnit_Families);
|
||||
family->GetUnit() == eCSSUnit_Null) {
|
||||
family->SetStringValue(NS_LITERAL_STRING("serif"), eCSSUnit_Families);
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* width = aData->ValueForWidth();
|
||||
if (width->GetUnit() == eCSSUnit_Null) {
|
||||
// width: int (html4 attribute == nav4 cols)
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (!value || value->Type() != nsAttrValue::eInteger) {
|
||||
|
@ -156,14 +157,15 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
}
|
||||
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
|
||||
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
|
||||
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* whiteSpace = aData->ValueForWhiteSpace();
|
||||
if (whiteSpace->GetUnit() == eCSSUnit_Null) {
|
||||
// wrap: empty
|
||||
if (aAttributes->GetAttr(nsGkAtoms::wrap))
|
||||
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
|
||||
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
|
||||
|
||||
// width: int (html4 attribute == nav4 cols)
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
|
@ -175,7 +177,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
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_PRE_WRAP, eCSSUnit_Enumerated);
|
||||
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,14 +340,15 @@ DirectoryMenuMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
|
||||
if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* listStyleType = aData->ValueForListStyleType();
|
||||
if (listStyleType->GetUnit() == eCSSUnit_Null) {
|
||||
// type: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
||||
if (value) {
|
||||
if (value->Type() == nsAttrValue::eEnum) {
|
||||
aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
} else {
|
||||
aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
||||
listStyleType->SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,10 +137,11 @@ static
|
|||
void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TableBorder)) {
|
||||
if (aData->mTableData->mCaptionSide.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* captionSide = aData->ValueForCaptionSide();
|
||||
if (captionSide->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTableData->mCaptionSide.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
captionSide->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -334,44 +334,48 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
||||
// width: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* width = aData->ValueForWidth();
|
||||
if (width->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
if (value->GetIntegerValue() > 0)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
// else 0 implies auto for compatibility.
|
||||
}
|
||||
else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
if (value->GetPercentValue() > 0.0f)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
width->SetPercentValue(value->GetPercentValue());
|
||||
// else 0 implies auto for compatibility
|
||||
}
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* height = aData->ValueForHeight();
|
||||
if (height->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
if (value->GetIntegerValue() > 0)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
// else 0 implies auto for compatibility.
|
||||
}
|
||||
else if (value && value->Type() == nsAttrValue::ePercent) {
|
||||
if (value->GetPercentValue() > 0.0f)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
height->SetPercentValue(value->GetPercentValue());
|
||||
// else 0 implies auto for compatibility
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* textAlign = aData->ValueForTextAlign();
|
||||
if (textAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* whiteSpace = aData->ValueForWhiteSpace();
|
||||
if (whiteSpace->GetUnit() == eCSSUnit_Null) {
|
||||
// nowrap: enum
|
||||
if (aAttributes->GetAttr(nsGkAtoms::nowrap)) {
|
||||
// See if our width is not a nonzero integer width.
|
||||
|
@ -380,18 +384,18 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (!value || value->Type() != nsAttrValue::eInteger ||
|
||||
value->GetIntegerValue() == 0 ||
|
||||
eCompatibility_NavQuirks != mode) {
|
||||
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
|
||||
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
|
||||
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,54 +152,59 @@ nsHTMLTableColElement::ParseAttribute(PRInt32 aNamespaceID,
|
|||
static
|
||||
void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table) &&
|
||||
aData->mTableData->mSpan.GetUnit() == eCSSUnit_Null) {
|
||||
// span: int
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
PRInt32 val = value->GetIntegerValue();
|
||||
// Note: Do NOT use this code for table cells! The value "0"
|
||||
// means something special for colspan and rowspan, but for <col
|
||||
// span> and <colgroup span> it's just disallowed.
|
||||
if (val > 0) {
|
||||
aData->mTableData->mSpan.SetIntValue(value->GetIntegerValue(),
|
||||
eCSSUnit_Integer);
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table)) {
|
||||
nsCSSValue *span = aData->ValueForSpan();
|
||||
if (span->GetUnit() == eCSSUnit_Null) {
|
||||
// span: int
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
PRInt32 val = value->GetIntegerValue();
|
||||
// Note: Do NOT use this code for table cells! The value "0"
|
||||
// means something special for colspan and rowspan, but for <col
|
||||
// span> and <colgroup span> it's just disallowed.
|
||||
if (val > 0) {
|
||||
span->SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) &&
|
||||
aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
// width
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (value) {
|
||||
switch (value->Type()) {
|
||||
case nsAttrValue::ePercent: {
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
break;
|
||||
}
|
||||
case nsAttrValue::eInteger: {
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
||||
nsCSSValue* width = aData->ValueForWidth();
|
||||
if (width->GetUnit() == eCSSUnit_Null) {
|
||||
// width
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (value) {
|
||||
switch (value->Type()) {
|
||||
case nsAttrValue::ePercent: {
|
||||
width->SetPercentValue(value->GetPercentValue());
|
||||
break;
|
||||
}
|
||||
case nsAttrValue::eInteger: {
|
||||
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* textAlign = aData->ValueForTextAlign();
|
||||
if (textAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
|
||||
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1063,16 +1063,17 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
// cellspacing
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellspacing);
|
||||
nsCSSValue* borderSpacing = aData->ValueForBorderSpacing();
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
if (aData->mTableData->mBorderSpacing.GetUnit() == eCSSUnit_Null)
|
||||
aData->mTableData->mBorderSpacing.
|
||||
if (borderSpacing->GetUnit() == eCSSUnit_Null)
|
||||
borderSpacing->
|
||||
SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
else if (value && value->Type() == nsAttrValue::ePercent &&
|
||||
eCompatibility_NavQuirks == mode) {
|
||||
// in quirks mode, treat a % cellspacing value a pixel value.
|
||||
if (aData->mTableData->mBorderSpacing.GetUnit() == eCSSUnit_Null)
|
||||
aData->mTableData->mBorderSpacing.
|
||||
if (borderSpacing->GetUnit() == eCSSUnit_Null)
|
||||
borderSpacing->
|
||||
SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
|
@ -1082,19 +1083,21 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
const nsAttrValue* value;
|
||||
// layout
|
||||
if (aData->mTableData->mLayout.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* tableLayout = aData->ValueForTableLayout();
|
||||
if (tableLayout->GetUnit() == eCSSUnit_Null) {
|
||||
value = aAttributes->GetAttr(nsGkAtoms::layout);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTableData->mLayout.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
tableLayout->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
|
||||
// cols
|
||||
value = aAttributes->GetAttr(nsGkAtoms::cols);
|
||||
if (value) {
|
||||
nsCSSValue* cols = aData->ValueForCols();
|
||||
if (value->Type() == nsAttrValue::eInteger)
|
||||
aData->mTableData->mCols.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
|
||||
cols->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);
|
||||
cols->SetIntValue(NS_STYLE_TABLE_COLS_ALL, eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1109,11 +1112,12 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
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();
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight.SetAutoValue();
|
||||
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
|
||||
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
||||
marginLeft->SetAutoValue();
|
||||
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
|
||||
if (marginRight->GetUnit() == eCSSUnit_Null)
|
||||
marginRight->SetAutoValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1124,21 +1128,23 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
value = aAttributes->GetAttr(nsGkAtoms::hspace);
|
||||
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mLeft.GetUnit() == eCSSUnit_Null)
|
||||
margin.mLeft.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
if (margin.mRight.GetUnit() == eCSSUnit_Null)
|
||||
margin.mRight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
|
||||
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
||||
marginLeft->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
|
||||
if (marginRight->GetUnit() == eCSSUnit_Null)
|
||||
marginRight->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
|
||||
value = aAttributes->GetAttr(nsGkAtoms::vspace);
|
||||
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
nsCSSRect& margin = aData->mMarginData->mMargin;
|
||||
if (margin.mTop.GetUnit() == eCSSUnit_Null)
|
||||
margin.mTop.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
if (margin.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
margin.mBottom.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
nsCSSValue* marginTop = aData->ValueForMarginTop();
|
||||
if (marginTop->GetUnit() == eCSSUnit_Null)
|
||||
marginTop->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
|
||||
if (marginBottom->GetUnit() == eCSSUnit_Null)
|
||||
marginBottom->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1166,14 +1172,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
// 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;
|
||||
nsCSSValue* paddingLeft = aData->ValueForPaddingLeftValue();
|
||||
if (paddingLeft->GetUnit() == eCSSUnit_Null)
|
||||
*paddingLeft = padVal;
|
||||
nsCSSValue* paddingRight = aData->ValueForPaddingRightValue();
|
||||
if (paddingRight->GetUnit() == eCSSUnit_Null)
|
||||
*paddingRight = padVal;
|
||||
nsCSSValue* paddingTop = aData->ValueForPaddingTop();
|
||||
if (paddingTop->GetUnit() == eCSSUnit_Null)
|
||||
*paddingTop = padVal;
|
||||
nsCSSValue* paddingBottom = aData->ValueForPaddingBottom();
|
||||
if (paddingBottom->GetUnit() == eCSSUnit_Null)
|
||||
*paddingBottom = padVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1183,21 +1193,23 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
|
||||
if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
|
||||
// width: value
|
||||
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* width = aData->ValueForWidth();
|
||||
if (width->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
|
||||
width->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* height = aData->ValueForHeight();
|
||||
if (height->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
height->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1215,14 +1227,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
nscolor color;
|
||||
if (value && presContext->UseDocumentColors() &&
|
||||
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)
|
||||
aData->mMarginData->mBorderColor.mRight.SetColorValue(color);
|
||||
if (aData->mMarginData->mBorderColor.mTop.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mBorderColor.mTop.SetColorValue(color);
|
||||
if (aData->mMarginData->mBorderColor.mBottom.GetUnit() == eCSSUnit_Null)
|
||||
aData->mMarginData->mBorderColor.mBottom.SetColorValue(color);
|
||||
nsCSSValue* borderLeftColor = aData->ValueForBorderLeftColorValue();
|
||||
if (borderLeftColor->GetUnit() == eCSSUnit_Null)
|
||||
borderLeftColor->SetColorValue(color);
|
||||
nsCSSValue* borderRightColor = aData->ValueForBorderRightColorValue();
|
||||
if (borderRightColor->GetUnit() == eCSSUnit_Null)
|
||||
borderRightColor->SetColorValue(color);
|
||||
nsCSSValue* borderTopColor = aData->ValueForBorderTopColor();
|
||||
if (borderTopColor->GetUnit() == eCSSUnit_Null)
|
||||
borderTopColor->SetColorValue(color);
|
||||
nsCSSValue* borderBottomColor = aData->ValueForBorderBottomColor();
|
||||
if (borderBottomColor->GetUnit() == eCSSUnit_Null)
|
||||
borderBottomColor->SetColorValue(color);
|
||||
}
|
||||
|
||||
// border
|
||||
|
@ -1235,14 +1251,18 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
borderThickness = borderValue->GetIntegerValue();
|
||||
|
||||
// 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);
|
||||
nsCSSValue* borderLeftWidth = aData->ValueForBorderLeftWidthValue();
|
||||
if (borderLeftWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderLeftWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderRightWidth = aData->ValueForBorderRightWidthValue();
|
||||
if (borderRightWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderRightWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderTopWidth = aData->ValueForBorderTopWidth();
|
||||
if (borderTopWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderTopWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||
nsCSSValue* borderBottomWidth = aData->ValueForBorderBottomWidth();
|
||||
if (borderBottomWidth->GetUnit() == eCSSUnit_Null)
|
||||
borderBottomWidth->SetFloatValue((float)borderThickness, eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,28 +408,31 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* height = aData->ValueForHeight();
|
||||
if (height->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
else if (value && value->Type() == nsAttrValue::ePercent)
|
||||
aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
|
||||
height->SetPercentValue(value->GetPercentValue());
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* textAlign = aData->ValueForTextAlign();
|
||||
if (textAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
|
||||
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,26 +274,29 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
||||
// height: value
|
||||
if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* height = aData->ValueForHeight();
|
||||
if (height->GetUnit() == eCSSUnit_Null) {
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
|
||||
if (value && value->Type() == nsAttrValue::eInteger)
|
||||
aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
|
||||
if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* textAlign = aData->ValueForTextAlign();
|
||||
if (textAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// align: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
|
||||
if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
|
||||
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
|
||||
// valign: enum
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
|
||||
if (value && value->Type() == nsAttrValue::eEnum)
|
||||
aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,8 +326,10 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
|
||||
const nsAttrValue* value =
|
||||
aAttributes->GetAttr(nsGkAtoms::scriptsizemultiplier_);
|
||||
nsCSSValue* scriptSizeMultiplier =
|
||||
aData->ValueForScriptSizeMultiplier();
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
aData->mFontData->mScriptSizeMultiplier.GetUnit() == eCSSUnit_Null) {
|
||||
scriptSizeMultiplier->GetUnit() == eCSSUnit_Null) {
|
||||
nsAutoString str(value->GetStringValue());
|
||||
str.CompressWhitespace();
|
||||
// MathML numbers can't have leading '+'
|
||||
|
@ -336,22 +338,22 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
float floatValue = str.ToFloat(&errorCode);
|
||||
// Negative scriptsizemultipliers are not parsed
|
||||
if (NS_SUCCEEDED(errorCode) && floatValue >= 0.0f) {
|
||||
aData->mFontData->mScriptSizeMultiplier.
|
||||
SetFloatValue(floatValue, eCSSUnit_Number);
|
||||
scriptSizeMultiplier->SetFloatValue(floatValue, eCSSUnit_Number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = aAttributes->GetAttr(nsGkAtoms::scriptminsize_);
|
||||
nsCSSValue* scriptMinSize = aData->ValueForScriptMinSize();
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
aData->mFontData->mScriptMinSize.GetUnit() == eCSSUnit_Null) {
|
||||
ParseNumericValue(value->GetStringValue(),
|
||||
aData->mFontData->mScriptMinSize, 0);
|
||||
scriptMinSize->GetUnit() == eCSSUnit_Null) {
|
||||
ParseNumericValue(value->GetStringValue(), *scriptMinSize, 0);
|
||||
}
|
||||
|
||||
value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
|
||||
nsCSSValue* scriptLevel = aData->ValueForScriptLevel();
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
aData->mFontData->mScriptLevel.GetUnit() == eCSSUnit_Null) {
|
||||
scriptLevel->GetUnit() == eCSSUnit_Null) {
|
||||
nsAutoString str(value->GetStringValue());
|
||||
str.CompressWhitespace();
|
||||
if (str.Length() > 0) {
|
||||
|
@ -364,9 +366,9 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
// to indicate that the scriptlevel is absolute.
|
||||
PRUnichar ch = str.CharAt(0);
|
||||
if (ch == '+' || ch == '-') {
|
||||
aData->mFontData->mScriptLevel.SetIntValue(intValue, eCSSUnit_Integer);
|
||||
scriptLevel->SetIntValue(intValue, eCSSUnit_Integer);
|
||||
} else {
|
||||
aData->mFontData->mScriptLevel.SetFloatValue(intValue, eCSSUnit_Number);
|
||||
scriptLevel->SetFloatValue(intValue, eCSSUnit_Number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,10 +380,11 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
parseSizeKeywords = PR_FALSE;
|
||||
value = aAttributes->GetAttr(nsGkAtoms::fontsize_);
|
||||
}
|
||||
nsCSSValue* fontSize = aData->ValueForFontSize();
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
aData->mFontData->mSize.GetUnit() == eCSSUnit_Null) {
|
||||
fontSize->GetUnit() == eCSSUnit_Null) {
|
||||
nsAutoString str(value->GetStringValue());
|
||||
if (!ParseNumericValue(str, aData->mFontData->mSize, 0) &&
|
||||
if (!ParseNumericValue(str, *fontSize, 0) &&
|
||||
parseSizeKeywords) {
|
||||
static const char sizes[3][7] = { "small", "normal", "big" };
|
||||
static const PRInt32 values[NS_ARRAY_LENGTH(sizes)] = {
|
||||
|
@ -391,7 +394,7 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
str.CompressWhitespace();
|
||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sizes); ++i) {
|
||||
if (str.EqualsASCII(sizes[i])) {
|
||||
aData->mFontData->mSize.SetIntValue(values[i], eCSSUnit_Enumerated);
|
||||
fontSize->SetIntValue(values[i], eCSSUnit_Enumerated);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -399,10 +402,10 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
}
|
||||
|
||||
value = aAttributes->GetAttr(nsGkAtoms::fontfamily_);
|
||||
nsCSSValue* fontFamily = aData->ValueForFontFamily();
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
aData->mFontData->mFamily.GetUnit() == eCSSUnit_Null) {
|
||||
aData->mFontData->mFamily.SetStringValue(value->GetStringValue(),
|
||||
eCSSUnit_Families);
|
||||
fontFamily->GetUnit() == eCSSUnit_Null) {
|
||||
fontFamily->SetStringValue(value->GetStringValue(), eCSSUnit_Families);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,10 +415,11 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
if (!value) {
|
||||
value = aAttributes->GetAttr(nsGkAtoms::background);
|
||||
}
|
||||
if (value && aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null) {
|
||||
nsCSSValue* backgroundColor = aData->ValueForBackgroundColor();
|
||||
if (value && backgroundColor->GetUnit() == eCSSUnit_Null) {
|
||||
nscolor color;
|
||||
if (value->GetColorValue(color)) {
|
||||
aData->mColorData->mBackColor.SetColorValue(color);
|
||||
backgroundColor->SetColorValue(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -426,9 +430,10 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
value = aAttributes->GetAttr(nsGkAtoms::color);
|
||||
}
|
||||
nscolor color;
|
||||
nsCSSValue* colorValue = aData->ValueForColor();
|
||||
if (value && value->GetColorValue(color) &&
|
||||
aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
|
||||
aData->mColorData->mColor.SetColorValue(color);
|
||||
colorValue->GetUnit() == eCSSUnit_Null) {
|
||||
colorValue->SetColorValue(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче