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

Unified Diff: Source/core/dom/ElementData.h

Issue 180723006: Have ElementData::attributeItem() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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/dom/Element.cpp ('k') | Source/core/dom/ElementData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ElementData.h
diff --git a/Source/core/dom/ElementData.h b/Source/core/dom/ElementData.h
index 146ad5320839836270d4585bb483c01a21dbf2bd..e209f7fb1b8d76c4ed606df990128f10ce8e1580 100644
--- a/Source/core/dom/ElementData.h
+++ b/Source/core/dom/ElementData.h
@@ -66,7 +66,7 @@ public:
size_t length() const;
bool isEmpty() const { return !length(); }
- const Attribute* attributeItem(unsigned index) const;
+ const Attribute& attributeItem(unsigned index) const;
const Attribute* getAttributeItem(const QualifiedName&) const;
size_t getAttributeItemIndex(const QualifiedName&, bool shouldIgnoreCase = false) const;
size_t getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
@@ -149,7 +149,7 @@ public:
void addAttribute(const QualifiedName&, const AtomicString&);
void removeAttribute(size_t index);
- Attribute* attributeItem(unsigned index);
+ Attribute& attributeItem(unsigned index);
Attribute* getAttributeItem(const QualifiedName&);
UniqueElementData();
@@ -189,7 +189,7 @@ inline const Attribute* ElementData::getAttributeItem(const AtomicString& name,
{
size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase);
if (index != kNotFound)
- return attributeItem(index);
+ return &attributeItem(index);
return 0;
}
@@ -252,10 +252,11 @@ inline const Attribute* ElementData::getAttributeItem(const QualifiedName& name)
return 0;
}
-inline const Attribute* ElementData::attributeItem(unsigned index) const
+inline const Attribute& ElementData::attributeItem(unsigned index) const
{
RELEASE_ASSERT(index < length());
- return attributeBase() + index;
+ ASSERT(attributeBase() + index);
+ return *(attributeBase() + index);
}
inline void UniqueElementData::addAttribute(const QualifiedName& attributeName, const AtomicString& value)
@@ -268,9 +269,9 @@ inline void UniqueElementData::removeAttribute(size_t index)
m_attributeVector.remove(index);
}
-inline Attribute* UniqueElementData::attributeItem(unsigned index)
+inline Attribute& UniqueElementData::attributeItem(unsigned index)
{
- return &m_attributeVector.at(index);
+ return m_attributeVector.at(index);
}
} // namespace WebCore
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/ElementData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698