summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5Tokenizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'parser/html/nsHtml5Tokenizer.cpp')
-rw-r--r--parser/html/nsHtml5Tokenizer.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp
index bb8d950d5..aadbca899 100644
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -95,6 +95,7 @@ nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewin
charRefBuf(jArray<char16_t,int32_t>::newJArray(32)),
bmpChar(jArray<char16_t,int32_t>::newJArray(1)),
astralChar(jArray<char16_t,int32_t>::newJArray(2)),
+ containsHyphen(false),
tagName(nullptr),
nonInternedTagName(new nsHtml5ElementName()),
attributeName(nullptr),
@@ -279,11 +280,22 @@ nsHtml5Tokenizer::flushChars(char16_t* buf, int32_t pos)
void
nsHtml5Tokenizer::strBufToElementNameString()
{
- tagName = nsHtml5ElementName::elementNameByBuffer(strBuf, 0, strBufLen, interner);
- if (!tagName) {
- nonInternedTagName->setNameForNonInterned(nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner));
- tagName = nonInternedTagName;
+ if (containsHyphen) {
+ nsIAtom* annotationName = nsHtml5ElementName::ELT_ANNOTATION_XML->getName();
+ if (nsHtml5Portability::localEqualsBuffer(annotationName, strBuf, 0, strBufLen)) {
+ tagName = nsHtml5ElementName::ELT_ANNOTATION_XML;
+ } else {
+ nonInternedTagName->setNameForNonInterned(nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner));
+ tagName = nonInternedTagName;
+ }
+ } else {
+ tagName = nsHtml5ElementName::elementNameByBuffer(strBuf, 0, strBufLen, interner);
+ if (!tagName) {
+ nonInternedTagName->setNameForNonInterned(nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner));
+ tagName = nonInternedTagName;
+ }
}
+ containsHyphen = false;
clearStrBufAfterUse();
}
@@ -484,12 +496,14 @@ nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* bu
endTag = false;
clearStrBufBeforeUse();
appendStrBuf((char16_t) (c + 0x20));
+ containsHyphen = false;
state = P::transition(mViewSource, nsHtml5Tokenizer::TAG_NAME, reconsume, pos);
NS_HTML5_BREAK(tagopenloop);
} else if (c >= 'a' && c <= 'z') {
endTag = false;
clearStrBufBeforeUse();
appendStrBuf(c);
+ containsHyphen = false;
state = P::transition(mViewSource, nsHtml5Tokenizer::TAG_NAME, reconsume, pos);
NS_HTML5_BREAK(tagopenloop);
}
@@ -580,8 +594,11 @@ nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* bu
default: {
if (c >= 'A' && c <= 'Z') {
c += 0x20;
+ } else if (c == '-') {
+ containsHyphen = true;
}
appendStrBuf(c);
+ containsHyphen = false;
continue;
}
}
@@ -3985,6 +4002,7 @@ nsHtml5Tokenizer::resetToDataState()
endTag = false;
shouldSuspend = false;
initDoctypeFields();
+ containsHyphen = false;
tagName = nullptr;
attributeName = nullptr;
if (newAttributesEachTime) {
@@ -4040,6 +4058,7 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
} else {
publicIdentifier = nsHtml5Portability::newStringFromString(other->publicIdentifier);
}
+ containsHyphen = other->containsHyphen;
if (!other->tagName) {
tagName = nullptr;
} else if (other->tagName->isInterned()) {