RESOLVED FIXED 127266
Add a nicer way to iterate over all the attributes of an element
https://bugs.webkit.org/show_bug.cgi?id=127266
Summary Add a nicer way to iterate over all the attributes of an element
Benjamin Poulain
Reported 2014-01-19 23:24:09 PST
Add a nicer way to iterate over all the attributes of an element
Attachments
Patch (29.78 KB, patch)
2014-01-19 23:33 PST, Benjamin Poulain
ggaren: review+
Benjamin Poulain
Comment 1 2014-01-19 23:33:29 PST
Anders Carlsson
Comment 2 2014-01-20 09:13:41 PST
Comment on attachment 221620 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=221620&action=review > Source/WebCore/dom/ElementData.h:73 > +class AttributeIteratorAccessor { > +public: > + AttributeIteratorAccessor(const Attribute* array, unsigned size) > + : m_array(array) > + , m_size(size) > + { > + } > + > + AttributeConstIterator begin() const { return AttributeConstIterator(m_array, 0); } > + AttributeConstIterator end() const { return AttributeConstIterator(m_array, m_size); } > +private: > + const Attribute* m_array; > + unsigned m_size; > +}; I think you can use WTF::IteratorRange here instead.
Geoffrey Garen
Comment 3 2014-01-20 09:30:44 PST
Comment on attachment 221620 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=221620&action=review r=me Please consider Anders's suggestion. > Source/WebCore/dom/ElementData.cpp:182 > + unsigned count = length(); In cases like this, I prefer "unsigned length = this->length()" or "unsigned length = ElementData::length()". It's bad when one thing becomes two. Taking "length" and renaming it to "count" makes it seem like you've changed it somehow, which can be confusing.
Benjamin Poulain
Comment 4 2014-01-20 17:07:09 PST
(In reply to comment #2) > I think you can use WTF::IteratorRange here instead. My first idea was to just use the Attribute* as the iterator. But for some reason clang really sucks iterating with pointers :(
Benjamin Poulain
Comment 5 2014-01-20 17:27:38 PST
Note You need to log in before you can comment on or make changes to this bug.