Bug 480647 part 3 - Clean up nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle; r=ehsan

This commit is contained in:
Aryeh Gregor 2012-04-24 13:57:23 +03:00
Родитель 8a0ad5f175
Коммит fffaab3b93
1 изменённых файлов: 50 добавлений и 63 удалений

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

@ -853,78 +853,65 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(dom::Element* aElement,
{ {
MOZ_ASSERT(aElement); MOZ_ASSERT(aElement);
nsIAtom* tagName = aElement->Tag(); nsIAtom* tagName = aElement->Tag();
const nsHTMLCSSUtils::CSSEquivTable* equivTable = nsnull;
if (nsEditProperty::b == aHTMLProperty) { if (nsEditProperty::b == aHTMLProperty) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, boldEquivTable, aValue, aGetOrRemoveRequest); equivTable = boldEquivTable;
} } else if (nsEditProperty::i == aHTMLProperty) {
else if (nsEditProperty::i == aHTMLProperty) { equivTable = italicEquivTable;
BuildCSSDeclarations(cssPropertyArray, cssValueArray, italicEquivTable, aValue, aGetOrRemoveRequest); } else if (nsEditProperty::u == aHTMLProperty) {
} equivTable = underlineEquivTable;
else if (nsEditProperty::u == aHTMLProperty) { } else if (nsEditProperty::strike == aHTMLProperty) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, underlineEquivTable, aValue, aGetOrRemoveRequest); equivTable = strikeEquivTable;
} } else if (nsEditProperty::tt == aHTMLProperty) {
else if (nsEditProperty::strike == aHTMLProperty) { equivTable = ttEquivTable;
BuildCSSDeclarations(cssPropertyArray, cssValueArray, strikeEquivTable, aValue, aGetOrRemoveRequest); } else if (aAttribute) {
}
else if (nsEditProperty::tt == aHTMLProperty) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, ttEquivTable, aValue, aGetOrRemoveRequest);
}
else if (aAttribute) {
if (nsEditProperty::font == aHTMLProperty && if (nsEditProperty::font == aHTMLProperty &&
aAttribute->EqualsLiteral("color")) { aAttribute->EqualsLiteral("color")) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, fontColorEquivTable, aValue, aGetOrRemoveRequest); equivTable = fontColorEquivTable;
} } else if (nsEditProperty::font == aHTMLProperty &&
else if (nsEditProperty::font == aHTMLProperty &&
aAttribute->EqualsLiteral("face")) { aAttribute->EqualsLiteral("face")) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, fontFaceEquivTable, aValue, aGetOrRemoveRequest); equivTable = fontFaceEquivTable;
} } else if (aAttribute->EqualsLiteral("bgcolor")) {
else if (aAttribute->EqualsLiteral("bgcolor")) { equivTable = bgcolorEquivTable;
BuildCSSDeclarations(cssPropertyArray, cssValueArray, bgcolorEquivTable, aValue, aGetOrRemoveRequest); } else if (aAttribute->EqualsLiteral("background")) {
} equivTable = backgroundImageEquivTable;
else if (aAttribute->EqualsLiteral("background")) { } else if (aAttribute->EqualsLiteral("text")) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, backgroundImageEquivTable, aValue, aGetOrRemoveRequest); equivTable = textColorEquivTable;
} } else if (aAttribute->EqualsLiteral("border")) {
else if (aAttribute->EqualsLiteral("text")) { equivTable = borderEquivTable;
BuildCSSDeclarations(cssPropertyArray, cssValueArray, textColorEquivTable, aValue, aGetOrRemoveRequest); } else if (aAttribute->EqualsLiteral("align")) {
}
else if (aAttribute->EqualsLiteral("border")) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, borderEquivTable, aValue, aGetOrRemoveRequest);
}
else if (aAttribute->EqualsLiteral("align")) {
if (nsEditProperty::table == tagName) { if (nsEditProperty::table == tagName) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, tableAlignEquivTable, aValue, aGetOrRemoveRequest); equivTable = tableAlignEquivTable;
} } else if (nsEditProperty::hr == tagName) {
else if (nsEditProperty::hr == tagName) { equivTable = hrAlignEquivTable;
BuildCSSDeclarations(cssPropertyArray, cssValueArray, hrAlignEquivTable, aValue, aGetOrRemoveRequest); } else if (nsEditProperty::legend == tagName ||
}
else if (nsEditProperty::legend == tagName ||
nsEditProperty::caption == tagName) { nsEditProperty::caption == tagName) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, captionAlignEquivTable, aValue, aGetOrRemoveRequest); equivTable = captionAlignEquivTable;
} else {
equivTable = textAlignEquivTable;
} }
else { } else if (aAttribute->EqualsLiteral("valign")) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, textAlignEquivTable, aValue, aGetOrRemoveRequest); equivTable = verticalAlignEquivTable;
} } else if (aAttribute->EqualsLiteral("nowrap")) {
} equivTable = nowrapEquivTable;
else if (aAttribute->EqualsLiteral("valign")) { } else if (aAttribute->EqualsLiteral("width")) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, verticalAlignEquivTable, aValue, aGetOrRemoveRequest); equivTable = widthEquivTable;
} } else if (aAttribute->EqualsLiteral("height") ||
else if (aAttribute->EqualsLiteral("nowrap")) { (nsEditProperty::hr == tagName &&
BuildCSSDeclarations(cssPropertyArray, cssValueArray, nowrapEquivTable, aValue, aGetOrRemoveRequest); aAttribute->EqualsLiteral("size"))) {
} equivTable = heightEquivTable;
else if (aAttribute->EqualsLiteral("width")) { } else if (aAttribute->EqualsLiteral("type") &&
BuildCSSDeclarations(cssPropertyArray, cssValueArray, widthEquivTable, aValue, aGetOrRemoveRequest);
}
else if (aAttribute->EqualsLiteral("height") ||
(nsEditProperty::hr == tagName && aAttribute->EqualsLiteral("size"))) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, heightEquivTable, aValue, aGetOrRemoveRequest);
}
else if (aAttribute->EqualsLiteral("type") &&
(nsEditProperty::ol == tagName (nsEditProperty::ol == tagName
|| nsEditProperty::ul == tagName || nsEditProperty::ul == tagName
|| nsEditProperty::li == tagName)) { || nsEditProperty::li == tagName)) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, listStyleTypeEquivTable, aValue, aGetOrRemoveRequest); equivTable = listStyleTypeEquivTable;
} }
} }
if (equivTable) {
BuildCSSDeclarations(cssPropertyArray, cssValueArray, equivTable,
aValue, aGetOrRemoveRequest);
}
} }
// Add to aNode the CSS inline style equivalent to HTMLProperty/aAttribute/aValue for the node, // Add to aNode the CSS inline style equivalent to HTMLProperty/aAttribute/aValue for the node,