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

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

Issue 354023008: Move attributes-related methods from ElementData to AttributeCollection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 6 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
Index: Source/core/dom/ElementData.cpp
diff --git a/Source/core/dom/ElementData.cpp b/Source/core/dom/ElementData.cpp
index 82a61d9d139d2287c8acf89cde9f9e7614f1f1d5..2e6c7c902592b996cb0d0f3b420eee45f6c28d9d 100644
--- a/Source/core/dom/ElementData.cpp
+++ b/Source/core/dom/ElementData.cpp
@@ -70,7 +70,7 @@ ElementData::ElementData(unsigned arraySize)
ElementData::ElementData(const ElementData& other, bool isUnique)
: m_isUnique(isUnique)
- , m_arraySize(isUnique ? 0 : other.attributeCount())
+ , m_arraySize(isUnique ? 0 : other.attributes().size())
, m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDirty)
, m_styleAttributeIsDirty(other.m_styleAttributeIsDirty)
, m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty)
@@ -107,42 +107,41 @@ PassRefPtrWillBeRawPtr<UniqueElementData> ElementData::makeUniqueCopy() const
bool ElementData::isEquivalent(const ElementData* other) const
{
+ AttributeCollection attributes = this->attributes();
if (!other)
- return !hasAttributes();
+ return attributes.isEmpty();
- AttributeCollection attributes = this->attributes();
- if (attributes.size() != other->attributeCount())
+ AttributeCollection otherAttributes = other->attributes();
+ if (attributes.size() != otherAttributes.size())
return false;
AttributeCollection::const_iterator end = attributes.end();
for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
- const Attribute* otherAttr = other->findAttributeByName(it->name());
+ const Attribute* otherAttr = otherAttributes.get(it->name());
if (!otherAttr || it->value() != otherAttr->value())
return false;
}
return true;
}
-size_t ElementData::findAttrNodeIndex(Attr* attr) const
+size_t AttributeCollection::find(Attr* attr) const
{
// This relies on the fact that Attr's QualifiedName == the Attribute's name.
- AttributeCollection attributes = this->attributes();
- AttributeCollection::const_iterator end = attributes.end();
+ const_iterator end = this->end();
unsigned index = 0;
- for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it, ++index) {
+ for (const_iterator it = begin(); it != end; ++it, ++index) {
if (it->name() == attr->qualifiedName())
return index;
}
return kNotFound;
}
-size_t ElementData::findAttributeIndexByNameSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
+size_t AttributeCollection::findSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
{
// Continue to checking case-insensitively and/or full namespaced names if necessary:
- AttributeCollection attributes = this->attributes();
- AttributeCollection::const_iterator end = attributes.end();
+ const_iterator end = this->end();
unsigned index = 0;
- for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it, ++index) {
+ for (const_iterator it = begin(); it != end; ++it, ++index) {
// FIXME: Why check the prefix? Namespace is all that should matter
// and all HTML/SVG attributes have a null namespace!
if (!it->name().hasPrefix()) {
@@ -227,7 +226,7 @@ UniqueElementData::UniqueElementData(const ShareableElementData& other)
ASSERT(!other.m_inlineStyle || !other.m_inlineStyle->isMutable());
m_inlineStyle = other.m_inlineStyle;
- unsigned length = other.attributeCount();
+ unsigned length = other.attributes().size();
m_attributeVector.reserveCapacity(length);
for (unsigned i = 0; i < length; ++i)
m_attributeVector.uncheckedAppend(other.m_attributeArray[i]);

Powered by Google App Engine
This is Rietveld 408576698