[Webkit-unassigned] [Bug 123895] Move array position caching out from HTMLCollection

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Nov 6 09:34:53 PST 2013


Darin Adler <darin at apple.com> changed:

           What    |Removed                     |Added
 Attachment #216180|review?                     |review+
               Flag|                            |

--- Comment #2 from Darin Adler <darin at apple.com>  2013-11-06 09:33:40 PST ---
(From update of attachment 216180)
View in context: https://bugs.webkit.org/attachment.cgi?id=216180&action=review

> Source/WebCore/html/HTMLCollection.cpp:134
> +HTMLCollection::HTMLCollection(ContainerNode& ownerNode, CollectionType type, ElementTraversalType traversalType)

I think that the enum is great for the argument.

> Source/WebCore/html/HTMLCollection.cpp:144
> +    , m_elementTraversalType(traversalType)

But for the local, I might suggest we use a boolean named m_requiresCustomForwardTraversal or something like that.

In other words, I liked the readability of the old pattern where the data member was a boolean.

> Source/WebCore/html/HTMLCollection.h:76
> +    Element* traverseFirstElement(ContainerNode* root) const;

Nothing new, but I am not a big fan of the name “traverse first element”. The meaning of traverse here is unclear.

> Source/WebCore/html/HTMLCollection.h:143
> +    virtual Element* virtualElementAfter(Element*) const { ASSERT_NOT_REACHED(); return nullptr; }

So we can’t use pure virtual because we only need this for classes that are CustomForwardOnlyTraversal. Ugly.

> Source/WebCore/html/HTMLFormControlsCollection.cpp:77
> +    unsigned i = 0;
> +    for (; i < elementVector.size(); ++i) {
> +        auto& associatedElement = *elementVector[i];
> +        if (associatedElement.isEnumeratable() && &associatedElement.asHTMLElement() == &element)
> +            break;
> +    }
> +    return i;

I would put the return inside the loop, and use a normal for loop without an “outside the loop” i variable. I think that would also make it slightly clearer what the function returns when nothing is found. But maybe this is more elegant.

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the webkit-unassigned mailing list