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

Unified Diff: Source/core/inspector/DOMPatchSupport.cpp

Issue 436603003: Make Element::attributes() less error-prone and simplify call sites (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take feedback into consideration Created 6 years, 4 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
« no previous file with comments | « Source/core/html/parser/HTMLConstructionSite.cpp ('k') | Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/DOMPatchSupport.cpp
diff --git a/Source/core/inspector/DOMPatchSupport.cpp b/Source/core/inspector/DOMPatchSupport.cpp
index 0878ab0ea640dbe66db08f24bd18c68e4f37b686..b9b2230028b4c4bf814412e45eb9caec59a41de2 100644
--- a/Source/core/inspector/DOMPatchSupport.cpp
+++ b/Source/core/inspector/DOMPatchSupport.cpp
@@ -188,22 +188,18 @@ bool DOMPatchSupport::innerPatchNode(Digest* oldDigest, Digest* newDigest, Excep
Element* newElement = toElement(newNode);
if (oldDigest->m_attrsSHA1 != newDigest->m_attrsSHA1) {
// FIXME: Create a function in Element for removing all properties. Take in account whether did/willModifyAttribute are important.
- if (oldElement->hasAttributesWithoutUpdate()) {
- while (oldElement->attributes().size()) {
- const Attribute& attribute = oldElement->attributes().at(0);
- if (!m_domEditor->removeAttribute(oldElement, attribute.localName(), exceptionState))
- return false;
- }
+ while (oldElement->attributesWithoutUpdate().size()) {
+ const Attribute& attribute = oldElement->attributesWithoutUpdate().at(0);
+ if (!m_domEditor->removeAttribute(oldElement, attribute.localName(), exceptionState))
+ return false;
}
// FIXME: Create a function in Element for copying properties. cloneDataFromElement() is close but not enough for this case.
- if (newElement->hasAttributesWithoutUpdate()) {
- AttributeCollection attributes = newElement->attributes();
- AttributeCollection::const_iterator end = attributes.end();
- for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
- if (!m_domEditor->setAttribute(oldElement, it->name().localName(), it->value(), exceptionState))
- return false;
- }
+ AttributeCollection attributes = newElement->attributesWithoutUpdate();
+ AttributeCollection::const_iterator end = attributes.end();
+ for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
+ if (!m_domEditor->setAttribute(oldElement, it->name().localName(), it->value(), exceptionState))
+ return false;
}
}
@@ -429,9 +425,9 @@ PassOwnPtr<DOMPatchSupport::Digest> DOMPatchSupport::createDigest(Node* node, Un
digest->m_children.append(childInfo.release());
}
- if (element.hasAttributesWithoutUpdate()) {
+ AttributeCollection attributes = element.attributesWithoutUpdate();
+ if (!attributes.isEmpty()) {
OwnPtr<blink::WebCryptoDigestor> attrsDigestor = createDigestor(HashAlgorithmSha1);
- AttributeCollection attributes = element.attributes();
AttributeCollection::const_iterator end = attributes.end();
for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
addStringToDigestor(attrsDigestor.get(), it->name().toString());
« no previous file with comments | « Source/core/html/parser/HTMLConstructionSite.cpp ('k') | Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698