Commit 1cc8b439 authored by philipj's avatar philipj Committed by Commit bot

Remove AttributeCollection's findIndex(Attr*) by using QualifiedName

The internal Attribute and AttributeCollection need not know anything
about the web-exposed Attr.

Since Attr::qualifiedName() is not just a trivial getter, calling that
outside of the loop is probably a good idea anyway.

Review URL: https://codereview.chromium.org/1467143004

Cr-Commit-Position: refs/heads/master@{#361221}
parent d1e660b8
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#ifndef AttributeCollection_h #ifndef AttributeCollection_h
#define AttributeCollection_h #define AttributeCollection_h
#include "core/dom/Attr.h"
#include "core/dom/Attribute.h" #include "core/dom/Attribute.h"
#include "wtf/Allocator.h" #include "wtf/Allocator.h"
#include "wtf/Vector.h" #include "wtf/Vector.h"
...@@ -68,7 +67,6 @@ public: ...@@ -68,7 +67,6 @@ public:
iterator find(const AtomicString& name, bool shouldIgnoreCase) const; iterator find(const AtomicString& name, bool shouldIgnoreCase) const;
size_t findIndex(const QualifiedName&, bool shouldIgnoreCase = false) const; size_t findIndex(const QualifiedName&, bool shouldIgnoreCase = false) const;
size_t findIndex(const AtomicString& name, bool shouldIgnoreCase) const; size_t findIndex(const AtomicString& name, bool shouldIgnoreCase) const;
size_t findIndex(Attr*) const;
protected: protected:
size_t findSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const; size_t findSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
...@@ -183,19 +181,6 @@ inline typename AttributeCollectionGeneric<Container, ContainerMemberType>::iter ...@@ -183,19 +181,6 @@ inline typename AttributeCollectionGeneric<Container, ContainerMemberType>::iter
return nullptr; return nullptr;
} }
template <typename Container, typename ContainerMemberType>
size_t AttributeCollectionGeneric<Container, ContainerMemberType>::findIndex(Attr* attr) const
{
// This relies on the fact that Attr's QualifiedName == the Attribute's name.
iterator end = this->end();
unsigned index = 0;
for (iterator it = begin(); it != end; ++it, ++index) {
if (it->name() == attr->qualifiedName())
return index;
}
return kNotFound;
}
template <typename Container, typename ContainerMemberType> template <typename Container, typename ContainerMemberType>
size_t AttributeCollectionGeneric<Container, ContainerMemberType>::findSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const size_t AttributeCollectionGeneric<Container, ContainerMemberType>::findSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
{ {
......
...@@ -2201,7 +2201,7 @@ PassRefPtrWillBeRawPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionS ...@@ -2201,7 +2201,7 @@ PassRefPtrWillBeRawPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionS
synchronizeAttribute(attr->qualifiedName()); synchronizeAttribute(attr->qualifiedName());
size_t index = elementData()->attributes().findIndex(attr); size_t index = elementData()->attributes().findIndex(attr->qualifiedName());
if (index == kNotFound) { if (index == kNotFound) {
exceptionState.throwDOMException(NotFoundError, "The attribute was not found on this element."); exceptionState.throwDOMException(NotFoundError, "The attribute was not found on this element.");
return nullptr; return nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment