Cache and reuse the HTMLAllCollection returned by document.all.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Dec 2011 03:57:51 +0000 (03:57 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Dec 2011 03:57:51 +0000 (03:57 +0000)
commit9219ee470e50cc6eeeb507ef7aedadf5843309ad
tree74177ef90423b270237ffa0944f49290eef0348e
parente31e7425bfcdcb80257d964f30a80dfe1772fbc7
Cache and reuse the HTMLAllCollection returned by document.all.
<http://webkit.org/b/74768>

Reviewed by Antti Koivisto.

Source/WebCore:

Let Document cache the document.all collection, just like we do for
the other collections (.links, .images, etc.)
This is primarily a memory optimization, as repeated calls to
document.all will no longer cause collection objects to stack up.

Tests: fast/dom/document-collection-idempotence.html
       fast/dom/gc-9.html

* dom/Document.h:
* dom/Document.cpp:
(WebCore::Document::all):

    Cache the HTMLAllCollection and reuse it across calls instead of
    creating a new one each time.

* html/HTMLAllCollection.h:
* html/HTMLAllCollection.cpp:
(WebCore::HTMLAllCollection::create):
(WebCore::HTMLAllCollection::HTMLAllCollection):

    Make the HTMLAllCollection constructor take a Document* to enforce
    the fact that it's the only way it should ever be created.

* html/HTMLAllCollection.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):

    Custom reachability code for JSC, same as HTMLCollection.

LayoutTests:

Update tests to document the new behavior of document.all.

* fast/dom/document-collection-idempotence-expected.txt:
* fast/dom/document-collection-idempotence.html:
* fast/dom/gc-9-expected.txt:
* fast/dom/gc-9.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103166 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/document-collection-idempotence-expected.txt
LayoutTests/fast/dom/document-collection-idempotence.html
LayoutTests/fast/dom/gc-9-expected.txt
LayoutTests/fast/dom/gc-9.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLAllCollection.cpp
Source/WebCore/html/HTMLAllCollection.h
Source/WebCore/html/HTMLAllCollection.idl