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

    r102419 r103855  
    2727#define HTMLSelectElement_h
    2828
    29 #include "CollectionCache.h"
    3029#include "Event.h"
    3130#include "HTMLFormControlElement.h"
     31#include "HTMLOptionsCollection.h"
    3232#include <wtf/Vector.h>
    3333
     
    8484    Node* namedItem(const AtomicString& name);
    8585    Node* item(unsigned index);
    86 
    87     CollectionCache* collectionInfo() { m_collectionInfo.checkConsistency(); return &m_collectionInfo; }
    8886
    8987    void scrollToSelection();
     
    177175    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
    178176
    179     CollectionCache m_collectionInfo;
     177    RefPtr<HTMLOptionsCollection> m_optionsCollection;
     178
    180179    // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHRElement objects.
    181180    mutable Vector<HTMLElement*> m_listItems;
Note: See TracChangeset for help on using the changeset viewer.