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/HTMLSelectElement.cpp

    r103497 r103855  
    328328PassRefPtr<HTMLOptionsCollection> HTMLSelectElement::options()
    329329{
    330     return HTMLOptionsCollection::create(this);
     330    if (!m_optionsCollection)
     331        m_optionsCollection = HTMLOptionsCollection::create(this);
     332    return m_optionsCollection;
    331333}
    332334
     
    681683    setOptionsChangedOnRenderer();
    682684    setNeedsStyleRecalc();
    683     if (!inDocument())
    684         m_collectionInfo.reset();
     685    if (!inDocument() && m_optionsCollection)
     686        m_optionsCollection->invalidateCache();
    685687}
    686688
Note: See TracChangeset for help on using the changeset viewer.