Move the remaining collections to caching on their respective base nodes.
<http://webkit.org/b/75416>

Reviewed by Anders Carlsson.

Source/WebCore: 

Add a (lazily-allocated) array of HTMLCollections to ElementRareData and cache
the various collections on their base node rather than recreating them every time.

Test: fast/dom/collection-idempotence.html
      fast/dom/gc-9.html

* html/CollectionType.h:
* dom/ElementRareData.h:
(WebCore::ElementRareData::hasCachedHTMLCollections):
(WebCore::ElementRareData::cachedHTMLCollection):
(WebCore::ElementRareData::ensureCachedHTMLCollection):
* dom/Element.h:
* dom/Element.cpp:
(WebCore::Element::ensureCachedHTMLCollection):

    Plumbing to cache HTMLCollections on ElementRareData.

(WebCore::Element::~Element):

    Detach any cached collections from an element when it's destroyed.

* html/HTMLCollection.h:
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::HTMLCollection):
(WebCore::HTMLCollection::create):
(WebCore::HTMLCollection::~HTMLCollection):
(WebCore::HTMLCollection::detachFromNode):
* html/HTMLTableRowsCollection.cpp:
(WebCore::HTMLTableRowsCollection::HTMLTableRowsCollection):
* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::HTMLOptionsCollection):
* html/HTMLFormCollection.cpp:
(WebCore::HTMLFormCollection::HTMLFormCollection):
* dom/Document.cpp:
(WebCore::Document::cachedCollection):

    Consolidate the HTMLCollection constructors and get rid of the hacks to
    optionally retain the base node.

* html/HTMLDataListElement.cpp:
(WebCore::HTMLDataListElement::options):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::children):
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::areas):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::tBodies):
* html/HTMLTableRowElement.cpp:
(WebCore::HTMLTableRowElement::cells):
* html/HTMLTableSectionElement.cpp:
(WebCore::HTMLTableSectionElement::rows):

    Cached collections!

LayoutTests: 

- Updated gc-9.html to document the new lifetime behavior of HTMLCollections.
- Merged all the *collection-idempotence.html tests into a big one and added
  tests for the newly changed collections.

* fast/dom/gc-9-expected.txt:
* fast/dom/gc-9.html:
* fast/dom/collection-idempotence-expected.txt: Added.
* fast/dom/collection-idempotence.html: Added.
* fast/dom/document-collection-idempotence-expected.txt: Removed.
* fast/dom/document-collection-idempotence.html: Removed.
* fast/dom/form-elements-collection-idempotence-expected.txt: Removed.
* fast/dom/form-elements-collection-idempotence.html: Removed.
* fast/dom/select-options-collection-idempotence-expected.txt: Removed.
* fast/dom/select-options-collection-idempotence.html: Removed.
* fast/dom/table-rows-collection-idempotence-expected.txt: Removed.
* fast/dom/table-rows-collection-idempotence.html: Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/html/HTMLCollection.cpp b/Source/WebCore/html/HTMLCollection.cpp
index f7aed50..0d3f8f2 100644
--- a/Source/WebCore/html/HTMLCollection.cpp
+++ b/Source/WebCore/html/HTMLCollection.cpp
@@ -37,26 +37,13 @@
 
 using namespace HTMLNames;
 
-HTMLCollection::HTMLCollection(Document* document, CollectionType type)
-    : m_baseIsRetained(false)
-    , m_includeChildren(shouldIncludeChildren(type))
-    , m_ownsInfo(false)
-    , m_type(type)
-    , m_base(document)
-    , m_info(0)
-{
-}
-
-HTMLCollection::HTMLCollection(Node* base, CollectionType type, bool retainBaseNode)
-    : m_baseIsRetained(retainBaseNode)
-    , m_includeChildren(shouldIncludeChildren(type))
+HTMLCollection::HTMLCollection(Node* base, CollectionType type)
+    : m_includeChildren(shouldIncludeChildren(type))
     , m_ownsInfo(false)
     , m_type(type)
     , m_base(base)
     , m_info(0)
 {
-    if (m_baseIsRetained)
-        m_base->ref();
 }
 
 bool HTMLCollection::shouldIncludeChildren(CollectionType type)
@@ -91,28 +78,20 @@
     return false;
 }
 
-PassRefPtr<HTMLCollection> HTMLCollection::createForCachingOnDocument(Document* document, CollectionType type)
+PassRefPtr<HTMLCollection> HTMLCollection::create(Node* base, CollectionType type)
 {
-    return adoptRef(new HTMLCollection(document, type));
-}
-
-PassRefPtr<HTMLCollection> HTMLCollection::create(PassRefPtr<Node> base, CollectionType type)
-{
-    return adoptRef(new HTMLCollection(base.get(), type));
+    return adoptRef(new HTMLCollection(base, type));
 }
 
 HTMLCollection::~HTMLCollection()
 {
     if (m_ownsInfo)
         delete m_info;
-    if (m_baseIsRetained)
-        m_base->deref();
 }
 
 void HTMLCollection::detachFromNode()
 {
     m_base = 0;
-    m_baseIsRetained = false;
 }
 
 void HTMLCollection::resetCollectionInfo() const