JSHTMLFormElement::canGetItemsForName needlessly allocates a Vector
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 06:05:05 +0000 (06:05 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Aug 2013 06:05:05 +0000 (06:05 +0000)
commitc8d63b01de3f575b41fde4cc0e438469308e2704
tree286cde238ce9ffe3828bf538312cfd4a01a07ca1
parent2e90a3c026bb3ca658e47f430b5dd54ec4d990f7
JSHTMLFormElement::canGetItemsForName needlessly allocates a Vector
https://bugs.webkit.org/show_bug.cgi?id=120277

Reviewed by Sam Weinig.

Added HTMLFormElement::hasNamedElement and used it in JSHTMLFormElement::canGetItemsForName.

This required fixing a bug in HTMLFormElement::getNamedElements that the first call to getNamedElements
after replacing an element A with another element B of the same name caused it to erroneously append A
to namedItems via the aliases mapping. Because getNamedElements used to be always called in pairs, this
wrong behavior was never visible to the Web. Fixed the bug by not adding the old element to namedItem
when namedItem's size is 1.

Also renamed m_elementAliases to m_pastNamesMap along with related member functions.

No new tests are added since there should be no Web exposed behavioral change.

* bindings/js/JSHTMLFormElementCustom.cpp:
(WebCore::JSHTMLFormElement::canGetItemsForName):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::elementFromPastNamesMap):
(WebCore::HTMLFormElement::addElementToPastNamesMap):
(WebCore::HTMLFormElement::hasNamedElement):
(WebCore::HTMLFormElement::getNamedElements):
* html/HTMLFormElement.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154586 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLFormElement.h