Changeset 103855 in webkit
- Timestamp:
- Dec 30, 2011, 6:43:33 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r103853 r103855 1 2011-12-30 Andreas Kling <[email protected]> 2 3 Cache and reuse the HTMLSelectElement.options collection. 4 <http://webkit.org/b/75399> 5 6 Reviewed by Anders Carlsson. 7 8 - Update gc-9.html to document the new lifetime characteristics of HTMLSelectElement.options. 9 - Add a test to verify that HTMLSelectElement.options returns the same object when called repeatedly. 10 11 * fast/dom/gc-9-expected.txt: 12 * fast/dom/gc-9.html: 13 * fast/dom/select-options-collection-idempotence-expected.txt: Added. 14 * fast/dom/select-options-collection-idempotence.html: Added. 15 1 16 2011-12-30 Robert Hogan <[email protected]> 2 17 -
trunk/LayoutTests/fast/dom/gc-9-expected.txt
r103848 r103855 14 14 PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0).myCustomProperty should be undefined and is. 15 15 PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat').myCustomProperty should be undefined and is. 16 PASS: document.getElementsByTagName('select')[0].options.myCustomProperty should be undefinedand is.16 PASS: document.getElementsByTagName('select')[0].options.myCustomProperty should be 1 and is. 17 17 PASS: document.body.childNodes.myCustomProperty should be undefined and is. 18 18 PASS: document.all.myCustomProperty should be 1 and is. … … 50 50 PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0).myCustomProperty should be undefined and is. 51 51 PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat').myCustomProperty should be undefined and is. 52 PASS: document.getElementsByTagName('select')[0].options.myCustomProperty should be undefinedand is.52 PASS: document.getElementsByTagName('select')[0].options.myCustomProperty should be 1 and is. 53 53 PASS: document.body.childNodes.myCustomProperty should be undefined and is. 54 54 PASS: document.all.myCustomProperty should be 1 and is. -
trunk/LayoutTests/fast/dom/gc-9.html
r103848 r103855 123 123 [ "document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0)" ], // CanvasGradient 124 124 [ "document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat')" ], // CanvasPattern 125 [ "document.getElementsByTagName('select')[0].options" ],125 [ "document.getElementsByTagName('select')[0].options", "allow custom" ], 126 126 [ "document.body.childNodes" ], 127 127 -
trunk/Source/WebCore/ChangeLog
r103854 r103855 1 2011-12-30 Andreas Kling <[email protected]> 2 3 Cache and reuse the HTMLSelectElement.options collection. 4 <http://webkit.org/b/75399> 5 6 Reviewed by Anders Carlsson. 7 8 Let HTMLSelectElement::options() cache the returned collection and tie it to the 9 lifetime of the form. This shrinks HTMLSelectElement by sizeof(CollectionCache) 10 minus one pointer. 11 12 Test: fast/dom/select-options-collection-idempotence.html 13 fast/gc-9.html 14 15 * html/HTMLSelectElement.h: 16 * html/HTMLSelectElement.cpp: 17 (WebCore::HTMLSelectElement::options): 18 19 Cache the HTMLOptionsCollection returned by options() on the HTMLSelectElement. 20 Remove the per-select CollectionCache and let the collection manage that. 21 22 * html/HTMLOptionsCollection.h: 23 * html/HTMLOptionsCollection.cpp: 24 (WebCore::HTMLOptionsCollection::create): 25 (WebCore::HTMLOptionsCollection::HTMLOptionsCollection): 26 27 Tell the base class constructor to not retain the back-pointer to the element. 28 29 * html/HTMLSelectElement.cpp: 30 (WebCore::HTMLSelectElement::setRecalcListItems): 31 * html/HTMLOptionsCollection.cpp: 32 (WebCore::HTMLOptionsCollection::invalidateCache): 33 34 Added so HTMLSelectElement can invalidate the collection without triggering 35 unnecessary instantiation of a CollectionCache. 36 1 37 2011-12-30 Kentaro Hara <[email protected]> 2 38 -
trunk/Source/WebCore/html/HTMLOptionsCollection.cpp
r97533 r103855 28 28 namespace WebCore { 29 29 30 HTMLOptionsCollection::HTMLOptionsCollection( PassRefPtr<HTMLSelectElement>select)31 : HTMLCollection(select .get(), SelectOptions, select->collectionInfo())30 HTMLOptionsCollection::HTMLOptionsCollection(HTMLSelectElement* select) 31 : HTMLCollection(select, SelectOptions, 0, /* retainBaseNode */ false) 32 32 { 33 33 } 34 34 35 PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create( PassRefPtr<HTMLSelectElement>select)35 PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(HTMLSelectElement* select) 36 36 { 37 37 return adoptRef(new HTMLOptionsCollection(select)); … … 88 88 } 89 89 90 void HTMLOptionsCollection::invalidateCache() 91 { 92 if (info()) 93 info()->reset(); 94 } 95 90 96 } //namespace -
trunk/Source/WebCore/html/HTMLOptionsCollection.h
r34432 r103855 36 36 class HTMLOptionsCollection : public HTMLCollection { 37 37 public: 38 static PassRefPtr<HTMLOptionsCollection> create( PassRefPtr<HTMLSelectElement>);38 static PassRefPtr<HTMLOptionsCollection> create(HTMLSelectElement*); 39 39 40 40 void add(PassRefPtr<HTMLOptionElement>, ExceptionCode&); … … 47 47 void setLength(unsigned, ExceptionCode&); 48 48 49 void invalidateCache(); 50 49 51 private: 50 HTMLOptionsCollection( PassRefPtr<HTMLSelectElement>);52 HTMLOptionsCollection(HTMLSelectElement*); 51 53 }; 52 54 -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r103497 r103855 328 328 PassRefPtr<HTMLOptionsCollection> HTMLSelectElement::options() 329 329 { 330 return HTMLOptionsCollection::create(this); 330 if (!m_optionsCollection) 331 m_optionsCollection = HTMLOptionsCollection::create(this); 332 return m_optionsCollection; 331 333 } 332 334 … … 681 683 setOptionsChangedOnRenderer(); 682 684 setNeedsStyleRecalc(); 683 if (!inDocument() )684 m_ collectionInfo.reset();685 if (!inDocument() && m_optionsCollection) 686 m_optionsCollection->invalidateCache(); 685 687 } 686 688 -
trunk/Source/WebCore/html/HTMLSelectElement.h
r102419 r103855 27 27 #define HTMLSelectElement_h 28 28 29 #include "CollectionCache.h"30 29 #include "Event.h" 31 30 #include "HTMLFormControlElement.h" 31 #include "HTMLOptionsCollection.h" 32 32 #include <wtf/Vector.h> 33 33 … … 84 84 Node* namedItem(const AtomicString& name); 85 85 Node* item(unsigned index); 86 87 CollectionCache* collectionInfo() { m_collectionInfo.checkConsistency(); return &m_collectionInfo; }88 86 89 87 void scrollToSelection(); … … 177 175 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 178 176 179 CollectionCache m_collectionInfo; 177 RefPtr<HTMLOptionsCollection> m_optionsCollection; 178 180 179 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHRElement objects. 181 180 mutable Vector<HTMLElement*> m_listItems;
Note:
See TracChangeset
for help on using the changeset viewer.