Cache and reuse the HTMLSelectElement.options collection.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Dec 2011 02:43:33 +0000 (02:43 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Dec 2011 02:43:33 +0000 (02:43 +0000)
commit8fdc8911ef39a0fc198932cdc176a38a7bd34d74
treecaacd4bf6ab83c270c4126bc950a77757ebd930e
parent5320cdc8ce6664f91eed8ea51835b80de9d744bc
Cache and reuse the HTMLSelectElement.options collection.
<http://webkit.org/b/75399>

Reviewed by Anders Carlsson.

Source/WebCore:

Let HTMLSelectElement::options() cache the returned collection and tie it to the
lifetime of the form. This shrinks HTMLSelectElement by sizeof(CollectionCache)
minus one pointer.

Test: fast/dom/select-options-collection-idempotence.html
      fast/gc-9.html

* html/HTMLSelectElement.h:
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::options):

    Cache the HTMLOptionsCollection returned by options() on the HTMLSelectElement.
    Remove the per-select CollectionCache and let the collection manage that.

* html/HTMLOptionsCollection.h:
* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::create):
(WebCore::HTMLOptionsCollection::HTMLOptionsCollection):

    Tell the base class constructor to not retain the back-pointer to the element.

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::setRecalcListItems):
* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::invalidateCache):

    Added so HTMLSelectElement can invalidate the collection without triggering
    unnecessary instantiation of a CollectionCache.

LayoutTests:

- Update gc-9.html to document the new lifetime characteristics of HTMLSelectElement.options.
- Add a test to verify that HTMLSelectElement.options returns the same object when called repeatedly.

* fast/dom/gc-9-expected.txt:
* fast/dom/gc-9.html:
* fast/dom/select-options-collection-idempotence-expected.txt: Added.
* fast/dom/select-options-collection-idempotence.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103855 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/gc-9-expected.txt
LayoutTests/fast/dom/gc-9.html
LayoutTests/fast/dom/select-options-collection-idempotence-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/select-options-collection-idempotence.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLOptionsCollection.cpp
Source/WebCore/html/HTMLOptionsCollection.h
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/HTMLSelectElement.h