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

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: Take feedback into consideration 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
« no previous file with comments | « Source/core/dom/ElementData.h ('k') | Source/core/dom/ElementDataCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ElementData.cpp
diff --git a/Source/core/dom/ElementData.cpp b/Source/core/dom/ElementData.cpp
index 82a61d9d139d2287c8acf89cde9f9e7614f1f1d5..9a67194e1e46e5c24475c0021fa5fb215cee1d5e 100644
--- a/Source/core/dom/ElementData.cpp
+++ b/Source/core/dom/ElementData.cpp
@@ -32,7 +32,6 @@
#include "core/dom/ElementData.h"
#include "core/css/StylePropertySet.h"
-#include "core/dom/Attr.h"
#include "core/dom/QualifiedName.h"
#include "wtf/Vector.h"
@@ -70,7 +69,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,58 +106,23 @@ 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.find(it->name());
if (!otherAttr || it->value() != otherAttr->value())
return false;
}
return true;
}
-size_t ElementData::findAttrNodeIndex(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();
- unsigned index = 0;
- for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it, ++index) {
- if (it->name() == attr->qualifiedName())
- return index;
- }
- return kNotFound;
-}
-
-size_t ElementData::findAttributeIndexByNameSlowCase(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();
- unsigned index = 0;
- for (AttributeCollection::const_iterator it = attributes.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()) {
- if (shouldIgnoreAttributeCase && equalIgnoringCase(name, it->localName()))
- return index;
- } else {
- // FIXME: Would be faster to do this comparison without calling toString, which
- // generates a temporary string by concatenation. But this branch is only reached
- // if the attribute name has a prefix, which is rare in HTML.
- if (equalPossiblyIgnoringCase(name, it->name().toString(), shouldIgnoreAttributeCase))
- return index;
- }
- }
- return kNotFound;
-}
-
void ElementData::trace(Visitor* visitor)
{
if (m_isUnique)
@@ -227,7 +191,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]);
« no previous file with comments | « Source/core/dom/ElementData.h ('k') | Source/core/dom/ElementDataCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698