Parse OL/UL type=A|a|I|i properly
This commit is contained in:
Родитель
37a0848e7a
Коммит
15c9e8aff7
|
@ -2015,6 +2015,21 @@ nsGenericHTMLElement::ParseEnumValue(const nsString& aValue,
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ParseCaseSensitiveEnumValue(const nsString& aValue,
|
||||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
while (nsnull != aTable->tag) {
|
||||
if (aValue.Equals(aTable->tag)) {
|
||||
aResult.SetIntValue(aTable->value, eHTMLUnit_Enumerated);
|
||||
return PR_TRUE;
|
||||
}
|
||||
aTable++;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::EnumValueToString(const nsHTMLValue& aValue,
|
||||
EnumTable* aTable,
|
||||
|
|
|
@ -205,6 +205,10 @@ public:
|
|||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ParseCaseSensitiveEnumValue(const nsString& aValue,
|
||||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool EnumValueToString(const nsHTMLValue& aValue,
|
||||
EnumTable* aTable,
|
||||
nsString& aResult);
|
||||
|
|
|
@ -142,6 +142,10 @@ nsGenericHTMLElement::EnumTable kListTypeTable[] = {
|
|||
{ "upper-roman", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
|
||||
{ "lower-alpha", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
|
||||
{ "upper-alpha", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
nsGenericHTMLElement::EnumTable kOtherListTypeTable[] = {
|
||||
{ "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
|
||||
{ "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
|
||||
{ "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
|
||||
|
@ -157,7 +161,10 @@ nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
|
||||
aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated);
|
||||
if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue,
|
||||
kOtherListTypeTable, aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIHTMLAttributes.h"
|
||||
|
||||
extern nsGenericHTMLElement::EnumTable kListTypeTable[];
|
||||
extern nsGenericHTMLElement::EnumTable kOtherListTypeTable[];
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLUListElementIID, NS_IDOMHTMLULISTELEMENT_IID);
|
||||
|
||||
|
@ -138,7 +139,10 @@ nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
|
||||
aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
|
||||
if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue,
|
||||
kOtherListTypeTable, aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsISizeOfHandler.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "prprf.h"
|
||||
|
||||
// XXX share all id's in this dir
|
||||
|
||||
|
@ -468,8 +469,9 @@ nsGenericDOMDataNode::ToCString(nsString& aBuf, PRInt32 aOffset,
|
|||
} else if (ch == '\t') {
|
||||
aBuf.Append("\\t");
|
||||
} else if ((ch < ' ') || (ch >= 127)) {
|
||||
aBuf.Append("\\0");
|
||||
aBuf.Append((PRInt32)ch, 8);
|
||||
char buf[10];
|
||||
PR_snprintf(buf, sizeof(buf), "\\u%04x", ch);
|
||||
aBuf.Append(buf);
|
||||
} else {
|
||||
aBuf.Append(ch);
|
||||
}
|
||||
|
|
|
@ -2015,6 +2015,21 @@ nsGenericHTMLElement::ParseEnumValue(const nsString& aValue,
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ParseCaseSensitiveEnumValue(const nsString& aValue,
|
||||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
while (nsnull != aTable->tag) {
|
||||
if (aValue.Equals(aTable->tag)) {
|
||||
aResult.SetIntValue(aTable->value, eHTMLUnit_Enumerated);
|
||||
return PR_TRUE;
|
||||
}
|
||||
aTable++;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::EnumValueToString(const nsHTMLValue& aValue,
|
||||
EnumTable* aTable,
|
||||
|
|
|
@ -205,6 +205,10 @@ public:
|
|||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ParseCaseSensitiveEnumValue(const nsString& aValue,
|
||||
EnumTable* aTable,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool EnumValueToString(const nsHTMLValue& aValue,
|
||||
EnumTable* aTable,
|
||||
nsString& aResult);
|
||||
|
|
|
@ -142,6 +142,10 @@ nsGenericHTMLElement::EnumTable kListTypeTable[] = {
|
|||
{ "upper-roman", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
|
||||
{ "lower-alpha", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
|
||||
{ "upper-alpha", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
nsGenericHTMLElement::EnumTable kOtherListTypeTable[] = {
|
||||
{ "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
|
||||
{ "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
|
||||
{ "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
|
||||
|
@ -157,7 +161,10 @@ nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
|
||||
aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated);
|
||||
if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue,
|
||||
kOtherListTypeTable, aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIHTMLAttributes.h"
|
||||
|
||||
extern nsGenericHTMLElement::EnumTable kListTypeTable[];
|
||||
extern nsGenericHTMLElement::EnumTable kOtherListTypeTable[];
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLUListElementIID, NS_IDOMHTMLULISTELEMENT_IID);
|
||||
|
||||
|
@ -138,7 +139,10 @@ nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable,
|
||||
aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
|
||||
if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue,
|
||||
kOtherListTypeTable, aResult)) {
|
||||
aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче