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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * (C) 2007 Eric Seidel (eric@webkit.org) 9 * (C) 2007 Eric Seidel (eric@webkit.org)
10 * 10 *
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 SynchronizeAttribute(name); 423 SynchronizeAttribute(name);
424 if (const Attribute* attribute = GetElementData()->Attributes().Find(name)) 424 if (const Attribute* attribute = GetElementData()->Attributes().Find(name))
425 return attribute->Value(); 425 return attribute->Value();
426 return g_null_atom; 426 return g_null_atom;
427 } 427 }
428 428
429 bool Element::ShouldIgnoreAttributeCase() const { 429 bool Element::ShouldIgnoreAttributeCase() const {
430 return IsHTMLElement() && GetDocument().IsHTMLDocument(); 430 return IsHTMLElement() && GetDocument().IsHTMLDocument();
431 } 431 }
432 432
433 const AtomicString& Element::nonce() const {
434 return HasRareData() ? GetElementRareData()->GetNonce() : g_empty_atom;
435 }
436
437 void Element::setNonce(const AtomicString& nonce) {
438 EnsureElementRareData().SetNonce(nonce);
439 }
440
433 void Element::scrollIntoView(bool align_to_top) { 441 void Element::scrollIntoView(bool align_to_top) {
434 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 442 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
435 443
436 if (!GetLayoutObject()) 444 if (!GetLayoutObject())
437 return; 445 return;
438 446
439 bool make_visible_in_visual_viewport = 447 bool make_visible_in_visual_viewport =
440 !GetDocument().GetPage()->GetSettings().GetInertVisualViewport(); 448 !GetDocument().GetPage()->GetSettings().GetInertVisualViewport();
441 449
442 LayoutRect bounds = BoundingBox(); 450 LayoutRect bounds = BoundingBox();
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 if (!id_value.IsNull()) 1658 if (!id_value.IsNull())
1651 UpdateId(scope, g_null_atom, id_value); 1659 UpdateId(scope, g_null_atom, id_value);
1652 1660
1653 const AtomicString& name_value = GetNameAttribute(); 1661 const AtomicString& name_value = GetNameAttribute();
1654 if (!name_value.IsNull()) 1662 if (!name_value.IsNull())
1655 UpdateName(g_null_atom, name_value); 1663 UpdateName(g_null_atom, name_value);
1656 1664
1657 if (parentElement() && parentElement()->IsInCanvasSubtree()) 1665 if (parentElement() && parentElement()->IsInCanvasSubtree())
1658 SetIsInCanvasSubtree(true); 1666 SetIsInCanvasSubtree(true);
1659 1667
1668 if (hasAttribute(nonceAttr) && getAttribute(nonceAttr) != g_empty_atom) {
1669 setNonce(getAttribute(nonceAttr));
1670 if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled())
1671 setAttribute(nonceAttr, g_empty_atom);
1672 }
1673
1660 return kInsertionDone; 1674 return kInsertionDone;
1661 } 1675 }
1662 1676
1663 void Element::RemovedFrom(ContainerNode* insertion_point) { 1677 void Element::RemovedFrom(ContainerNode* insertion_point) {
1664 bool was_in_document = insertion_point->isConnected(); 1678 bool was_in_document = insertion_point->isConnected();
1665 1679
1666 DCHECK(!HasRareData() || !GetElementRareData()->HasPseudoElements()); 1680 DCHECK(!HasRareData() || !GetElementRareData()->HasPseudoElements());
1667 1681
1668 if (Fullscreen::IsCurrentFullScreenElement(*this)) { 1682 if (Fullscreen::IsCurrentFullScreenElement(*this)) {
1669 SetContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); 1683 SetContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 GetDocument())) 4006 GetDocument()))
3993 element_data_ = other.element_data_; 4007 element_data_ = other.element_data_;
3994 else 4008 else
3995 element_data_ = other.element_data_->MakeUniqueCopy(); 4009 element_data_ = other.element_data_->MakeUniqueCopy();
3996 4010
3997 AttributeCollection attributes = element_data_->Attributes(); 4011 AttributeCollection attributes = element_data_->Attributes();
3998 for (const Attribute& attr : attributes) { 4012 for (const Attribute& attr : attributes) {
3999 AttributeChangedFromParserOrByCloning( 4013 AttributeChangedFromParserOrByCloning(
4000 attr.GetName(), attr.Value(), AttributeModificationReason::kByCloning); 4014 attr.GetName(), attr.Value(), AttributeModificationReason::kByCloning);
4001 } 4015 }
4016
4017 if (other.nonce() != g_null_atom)
4018 setNonce(other.nonce());
4002 } 4019 }
4003 4020
4004 void Element::CloneDataFromElement(const Element& other) { 4021 void Element::CloneDataFromElement(const Element& other) {
4005 CloneAttributesFromElement(other); 4022 CloneAttributesFromElement(other);
4006 CopyNonAttributePropertiesFromElement(other); 4023 CopyNonAttributePropertiesFromElement(other);
4007 } 4024 }
4008 4025
4009 void Element::CreateUniqueElementData() { 4026 void Element::CreateUniqueElementData() {
4010 if (!element_data_) { 4027 if (!element_data_) {
4011 element_data_ = UniqueElementData::Create(); 4028 element_data_ = UniqueElementData::Create();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 } 4360 }
4344 4361
4345 DEFINE_TRACE_WRAPPERS(Element) { 4362 DEFINE_TRACE_WRAPPERS(Element) {
4346 if (HasRareData()) { 4363 if (HasRareData()) {
4347 visitor->TraceWrappers(GetElementRareData()); 4364 visitor->TraceWrappers(GetElementRareData());
4348 } 4365 }
4349 ContainerNode::TraceWrappers(visitor); 4366 ContainerNode::TraceWrappers(visitor);
4350 } 4367 }
4351 4368
4352 } // namespace blink 4369 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698