Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2801243002: More tweaks to <script nonce> hiding. (Closed)
Patch Set: Element. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index a2390f6390500a66411bcdf3d0d29807dc3f0715..4a1b2838b6bfc4688e2acdf84f863f6d0cc4ad7f 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -430,6 +430,14 @@ bool Element::ShouldIgnoreAttributeCase() const {
return IsHTMLElement() && GetDocument().IsHTMLDocument();
}
+const AtomicString& Element::nonce() const {
+ return HasRareData() ? GetElementRareData()->GetNonce() : g_empty_atom;
+}
+
+void Element::setNonce(const AtomicString& nonce) {
+ EnsureElementRareData().SetNonce(nonce);
+}
+
void Element::scrollIntoView(bool align_to_top) {
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
@@ -1657,6 +1665,12 @@ Node::InsertionNotificationRequest Element::InsertedInto(
if (parentElement() && parentElement()->IsInCanvasSubtree())
SetIsInCanvasSubtree(true);
+ if (hasAttribute(nonceAttr) && getAttribute(nonceAttr) != g_empty_atom) {
+ setNonce(getAttribute(nonceAttr));
+ if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled())
+ setAttribute(nonceAttr, g_empty_atom);
+ }
+
return kInsertionDone;
}
@@ -3999,6 +4013,9 @@ void Element::CloneAttributesFromElement(const Element& other) {
AttributeChangedFromParserOrByCloning(
attr.GetName(), attr.Value(), AttributeModificationReason::kByCloning);
}
+
+ if (other.nonce() != g_null_atom)
+ setNonce(other.nonce());
}
void Element::CloneDataFromElement(const Element& other) {

Powered by Google App Engine
This is Rietveld 408576698