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

Unified Diff: Source/core/inspector/InspectorDOMAgent.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/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorDOMAgent.cpp
diff --git a/Source/core/inspector/InspectorDOMAgent.cpp b/Source/core/inspector/InspectorDOMAgent.cpp
index 66ec7af93533cf5bf8b07898a4e91b340073ce70..392d08b9b9833495c2f1c0dac79f417d8ee2a424 100644
--- a/Source/core/inspector/InspectorDOMAgent.cpp
+++ b/Source/core/inspector/InspectorDOMAgent.cpp
@@ -754,13 +754,13 @@ void InspectorDOMAgent::setAttributesAsText(ErrorString* errorString, int elemen
String caseAdjustedName = name ? (shouldIgnoreCase ? name->lower() : *name) : String();
- if (!parsedElement->hasAttributes() && name) {
+ AttributeCollection attributes = parsedElement->attributes();
+ if (attributes.isEmpty() && name) {
m_domEditor->removeAttribute(element, caseAdjustedName, errorString);
return;
}
bool foundOriginalAttribute = false;
- AttributeCollection attributes = parsedElement->attributes();
AttributeCollection::const_iterator end = attributes.end();
for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
// Add attribute pair
@@ -1016,9 +1016,6 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim
}
// Go through all attributes and serialize them.
const Element* element = toElement(node);
- if (!element->hasAttributes())
- break;
-
AttributeCollection attributes = element->attributes();
AttributeCollection::const_iterator end = attributes.end();
for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
@@ -1644,8 +1641,6 @@ PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA
{
RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<String>::create();
// Go through all attributes and serialize them.
- if (!element->hasAttributes())
- return attributesValue.release();
AttributeCollection attributes = element->attributes();
AttributeCollection::const_iterator end = attributes.end();
for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698