Bug 959150 part 5 - Avoid reallocating the attribute holder when parsing with nsHtml5StringParser. r=smaug.

This commit is contained in:
Henri Sivonen
2014-03-05 21:38:50 +02:00
parent d07d56d994
commit 775e097398
8 changed files with 61 additions and 50 deletions

View File

@@ -81,7 +81,8 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
aAttributes,
mozilla::dom::FROM_PARSER_FRAGMENT,
mBuilder);
if (aAttributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
if (MOZ_UNLIKELY(aAttributes != tokenizer->GetAttributes() &&
aAttributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES)) {
delete aAttributes;
}
return elem;
@@ -511,6 +512,8 @@ nsHtml5TreeBuilder::addAttributesToElement(nsIContentHandle* aElement, nsHtml5Ht
}
if (mBuilder) {
MOZ_ASSERT(aAttributes == tokenizer->GetAttributes(),
"Using attribute other than the tokenizer's to add to body or html.");
nsresult rv = nsHtml5TreeOperation::AddAttributes(
static_cast<nsIContent*>(aElement),
aAttributes,