|
@@ -0,0 +1,46 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Tom Schuster <tschuster@mozilla.com>
|
|
|
+# Date 1707915342 0
|
|
|
+# Node ID 12e5815ccf55470884c97422356d765c37aaeb2c
|
|
|
+# Parent bdeb1b5088193969288d344b7491287e4cc5c5e4
|
|
|
+Bug 1871112 - Specialize AddAttributes for <html>/<body>. r=hsivonen
|
|
|
+
|
|
|
+Differential Revision: https://phabricator.services.mozilla.com/D201562
|
|
|
+
|
|
|
+diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp
|
|
|
+--- a/parser/html/nsHtml5TreeOperation.cpp
|
|
|
++++ b/parser/html/nsHtml5TreeOperation.cpp
|
|
|
+@@ -298,29 +298,32 @@ nsHtml5TreeOperation::FosterParent(nsICo
|
|
|
+ return Append(aNode, aParent, aBuilder);
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ nsHtml5TreeOperation::AddAttributes(nsIContent* aNode,
|
|
|
+ nsHtml5HtmlAttributes* aAttributes,
|
|
|
+ nsHtml5DocumentBuilder* aBuilder)
|
|
|
+ {
|
|
|
++ MOZ_ASSERT(aNode->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::html));
|
|
|
++
|
|
|
+ dom::Element* node = aNode->AsElement();
|
|
|
+ nsHtml5OtherDocUpdate update(node->OwnerDoc(),
|
|
|
+ aBuilder->GetDocument());
|
|
|
+
|
|
|
+ int32_t len = aAttributes->getLength();
|
|
|
+ for (int32_t i = len; i > 0;) {
|
|
|
+ --i;
|
|
|
+ // prefix doesn't need regetting. it is always null or a static atom
|
|
|
+ // local name is never null
|
|
|
+ nsCOMPtr<nsIAtom> localName =
|
|
|
+ Reget(aAttributes->getLocalNameNoBoundsCheck(i));
|
|
|
+ int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
|
|
|
+- if (!node->HasAttr(nsuri, localName)) {
|
|
|
++ if (!node->HasAttr(nsuri, localName) &&
|
|
|
++ !(nsuri == kNameSpaceID_None && localName == nsGkAtoms::nonce)) {
|
|
|
+ // prefix doesn't need regetting. it is always null or a static atom
|
|
|
+ // local name is never null
|
|
|
+ nsString value; // Not Auto, because using it to hold nsStringBuffer*
|
|
|
+ aAttributes->getValueNoBoundsCheck(i).ToString(value);
|
|
|
+ node->SetAttr(
|
|
|
+ nsuri, localName, aAttributes->getPrefixNoBoundsCheck(i), value, true);
|
|
|
+ // XXX what to do with nsresult?
|
|
|
+ }
|