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

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

Issue 27973004: Have ensureAttrNodeListForElement() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nit Created 7 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 94402222e8a03166c57ce2ed1588dde7eee46284..d54973019399ee0c488cfb208986771472a62e31 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -157,16 +157,16 @@ static AttrNodeList* attrNodeListForElement(Element* element)
return attrNodeListMap().get(element);
}
-static AttrNodeList* ensureAttrNodeListForElement(Element* element)
+static AttrNodeList& ensureAttrNodeListForElement(Element* element)
{
if (element->hasSyntheticAttrChildNodes()) {
ASSERT(attrNodeListMap().contains(element));
- return attrNodeListMap().get(element);
+ return *attrNodeListMap().get(element);
}
ASSERT(!attrNodeListMap().contains(element));
element->setHasSyntheticAttrChildNodes(true);
AttrNodeListMap::AddResult result = attrNodeListMap().add(element, adoptPtr(new AttrNodeList));
- return result.iterator->value.get();
+ return *result.iterator->value;
}
static void removeAttrNodeListForElement(Element* element)
@@ -177,11 +177,11 @@ static void removeAttrNodeListForElement(Element* element)
element->setHasSyntheticAttrChildNodes(false);
}
-static Attr* findAttrNodeInList(AttrNodeList* attrNodeList, const QualifiedName& name)
+static Attr* findAttrNodeInList(AttrNodeList& attrNodeList, const QualifiedName& name)
{
- for (unsigned i = 0; i < attrNodeList->size(); ++i) {
- if (attrNodeList->at(i)->qualifiedName() == name)
- return attrNodeList->at(i).get();
+ for (unsigned i = 0; i < attrNodeList.size(); ++i) {
+ if (attrNodeList[i]->qualifiedName() == name)
+ return attrNodeList[i].get();
}
return 0;
}
@@ -1936,7 +1936,7 @@ PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& es)
attrNode->attachToElement(this);
treeScope().adoptIfNeeded(attrNode);
- ensureAttrNodeListForElement(this)->append(attrNode);
+ ensureAttrNodeListForElement(this).append(attrNode);
return oldAttrNode.release();
}
@@ -3056,18 +3056,18 @@ void Element::setSavedLayerScrollOffset(const IntSize& size)
PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name)
{
if (AttrNodeList* attrNodeList = attrNodeListForElement(this))
- return findAttrNodeInList(attrNodeList, name);
+ return findAttrNodeInList(*attrNodeList, name);
return 0;
}
PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name)
{
- AttrNodeList* attrNodeList = ensureAttrNodeListForElement(this);
+ AttrNodeList& attrNodeList = ensureAttrNodeListForElement(this);
RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name);
if (!attrNode) {
attrNode = Attr::create(*this, name);
treeScope().adoptIfNeeded(attrNode.get());
- attrNodeList->append(attrNode);
+ attrNodeList.append(attrNode);
}
return attrNode.release();
}
@@ -3096,7 +3096,7 @@ void Element::detachAllAttrNodesFromElement()
for (unsigned i = 0; i < attributeCount(); ++i) {
const Attribute* attribute = attributeItem(i);
- if (RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, attribute->name()))
+ if (RefPtr<Attr> attrNode = findAttrNodeInList(*attrNodeList, attribute->name()))
attrNode->detachFromElementWithValue(attribute->value());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698