Handle marquee stylistic attributes via attribute mapping. Bug 163505, patch

by Martijn Wargers <martijn.martijn@gmail.com>, r+sr=bzbarsky
This commit is contained in:
bzbarsky%mit.edu 2005-10-23 22:47:58 +00:00
Родитель 04825cfb67
Коммит 38f8530cec
1 изменённых файлов: 43 добавлений и 20 удалений

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

@ -42,9 +42,6 @@
#include "nsPresContext.h"
#include "nsMappedAttributes.h"
// XXX support missing nav attributes? gutter, cols, width
class nsHTMLDivElement : public nsGenericHTMLElement,
public nsIDOMHTMLDivElement
{
@ -111,18 +108,20 @@ nsHTMLDivElement::ParseAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
if (mNodeInfo->Equals(nsHTMLAtoms::marquee)) {
if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height)) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
else if ((aAttribute == nsHTMLAtoms::hspace) ||
(aAttribute == nsHTMLAtoms::vspace)) {
return aResult.ParseIntWithBounds(aValue, 0);
}
}
if (mNodeInfo->Equals(nsHTMLAtoms::div) && aAttribute == nsHTMLAtoms::align) {
return ParseDivAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::gutter) {
return aResult.ParseIntWithBounds(aValue, 1);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
}
@ -134,19 +133,43 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
}
static void
MapMarqueeAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
{
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
}
NS_IMETHODIMP_(PRBool)
nsHTMLDivElement::IsAttributeMapped(const nsIAtom* aAttribute) const
{
static const MappedAttributeEntry* const map[] = {
sDivAlignAttributeMap,
sCommonAttributeMap
};
if (mNodeInfo->Equals(nsHTMLAtoms::div)) {
static const MappedAttributeEntry* const map[] = {
sDivAlignAttributeMap,
sCommonAttributeMap
};
return FindAttributeDependence(aAttribute, map, NS_ARRAY_LENGTH(map));
}
if (mNodeInfo->Equals(nsHTMLAtoms::marquee)) {
static const MappedAttributeEntry* const map[] = {
sImageMarginSizeAttributeMap,
sCommonAttributeMap
};
return FindAttributeDependence(aAttribute, map, NS_ARRAY_LENGTH(map));
}
return FindAttributeDependence(aAttribute, map, NS_ARRAY_LENGTH(map));
return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
}
nsMapRuleToAttributesFunc
nsHTMLDivElement::GetAttributeMappingFunction() const
{
return &MapAttributesIntoRule;
if (mNodeInfo->Equals(nsHTMLAtoms::div)) {
return &MapAttributesIntoRule;
}
if (mNodeInfo->Equals(nsHTMLAtoms::marquee)) {
return &MapMarqueeAttributesIntoRule;
}
return nsGenericHTMLElement::GetAttributeMappingFunction();
}