Ignore:
Timestamp:
Dec 30, 2011, 6:43:33 PM (13 years ago)
Author:
[email protected]
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/html/HTMLOptionsCollection.cpp

    r97533 r103855  
    2828namespace WebCore {
    2929
    30 HTMLOptionsCollection::HTMLOptionsCollection(PassRefPtr<HTMLSelectElement> select)
    31     : HTMLCollection(select.get(), SelectOptions, select->collectionInfo())
     30HTMLOptionsCollection::HTMLOptionsCollection(HTMLSelectElement* select)
     31    : HTMLCollection(select, SelectOptions, 0, /* retainBaseNode */ false)
    3232{
    3333}
    3434
    35 PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(PassRefPtr<HTMLSelectElement> select)
     35PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(HTMLSelectElement* select)
    3636{
    3737    return adoptRef(new HTMLOptionsCollection(select));
     
    8888}
    8989
     90void HTMLOptionsCollection::invalidateCache()
     91{
     92    if (info())
     93        info()->reset();
     94}
     95
    9096} //namespace
Note: See TracChangeset for help on using the changeset viewer.