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.h

    r34432 r103855  
    3636class HTMLOptionsCollection : public HTMLCollection {
    3737public:
    38     static PassRefPtr<HTMLOptionsCollection> create(PassRefPtr<HTMLSelectElement>);
     38    static PassRefPtr<HTMLOptionsCollection> create(HTMLSelectElement*);
    3939
    4040    void add(PassRefPtr<HTMLOptionElement>, ExceptionCode&);
     
    4747    void setLength(unsigned, ExceptionCode&);
    4848
     49    void invalidateCache();
     50
    4951private:
    50     HTMLOptionsCollection(PassRefPtr<HTMLSelectElement>);
     52    HTMLOptionsCollection(HTMLSelectElement*);
    5153};
    5254
Note: See TracChangeset for help on using the changeset viewer.