Make spacer attribute mapping code not depend on data in the style context (which attribute mapping code should not do). (Bug 449435) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2008-09-04 13:02:08 -07:00
parent ff14b5b6ad
commit 2cf88dfb3f

View File

@ -47,7 +47,6 @@
#include "nsPresContext.h"
#include "nsRuleData.h"
#include "nsMappedAttributes.h"
#include "nsStyleContext.h"
// XXX nav4 has type= start= (same as OL/UL)
extern nsAttrValue::EnumTable kListTypeTable[];
@ -239,11 +238,23 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
if (aData->mSIDs & (NS_STYLE_INHERIT_BIT(Position) |
NS_STYLE_INHERIT_BIT(Display))) {
PRBool typeIsBlock = PR_FALSE;
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value && value->Type() == nsAttrValue::eString) {
const nsString& tmp(value->GetStringValue());
if (tmp.LowerCaseEqualsLiteral("line") ||
tmp.LowerCaseEqualsLiteral("vert") ||
tmp.LowerCaseEqualsLiteral("vertical") ||
tmp.LowerCaseEqualsLiteral("block")) {
// This is not strictly 100% compatible: if the spacer is given
// a width of zero then it is basically ignored.
typeIsBlock = PR_TRUE;
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
const nsStyleDisplay* display = aData->mStyleContext->GetStyleDisplay();
PRBool typeIsBlock = (display->mDisplay == NS_STYLE_DISPLAY_BLOCK);
if (typeIsBlock) {
// width: value
if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
@ -281,6 +292,7 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
@ -295,21 +307,15 @@ SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
}
if (typeIsBlock) {
if (aData->mDisplayData->mDisplay.GetUnit() == eCSSUnit_Null) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value && value->Type() == nsAttrValue::eString) {
nsAutoString tmp(value->GetStringValue());
if (tmp.LowerCaseEqualsLiteral("line") ||
tmp.LowerCaseEqualsLiteral("vert") ||
tmp.LowerCaseEqualsLiteral("vertical") ||
tmp.LowerCaseEqualsLiteral("block")) {
// This is not strictly 100% compatible: if the spacer is given
// a width of zero then it is basically ignored.
aData->mDisplayData->mDisplay.SetIntValue(NS_STYLE_DISPLAY_BLOCK,
eCSSUnit_Enumerated);
}
}
}
// Any new structs that don't need typeIsBlock should go outside
// the code that calculates it.
}
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);