Title: [89035] trunk
Revision
89035
Author
[email protected]
Date
2011-06-16 09:50:19 -0700 (Thu, 16 Jun 2011)

Log Message

2011-06-16  Julien Chaffraix  <[email protected]>

        Reviewed by Darin Adler.

        HTMLTable should cache its 'rows' collection results
        https://bugs.webkit.org/show_bug.cgi?id=62800

        * perf/table-rows-length-caching-expected.txt: Added.
        * perf/table-rows-length-caching.html: Added.
        This test checks that the call to table.rows is CONSTANT once it has
        been populated once (and the DOM is not mutated).
2011-06-16  Julien Chaffraix  <[email protected]>

        Reviewed by Darin Adler.

        HTMLTable should cache its 'rows' collection results
        https://bugs.webkit.org/show_bug.cgi?id=62800

        Test: perf/table-rows-length-caching.html

        Currently all our HTMLCollection's are recreated on call. This means that
        we don't cache the information about the collection between calls to, for
        example, table.rows.

        This change adds a CollectionCache to HTMLTableElement. It is similar to what
        is done for HTMLFormElement.

        * html/HTMLTableElement.cpp:
        (WebCore::HTMLTableElement::collectionCache): This method does
        lazy initialization of the table's collectionCache.
        * html/HTMLTableElement.h: Added a new member and the previous
        method.

        * html/HTMLTableRowsCollection.cpp:
        (WebCore::HTMLTableRowsCollection::HTMLTableRowsCollection): Pass
        the HTMLTableElement's CollectionCache so that we reuse the cached
        results.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (89034 => 89035)


--- trunk/LayoutTests/ChangeLog	2011-06-16 16:39:27 UTC (rev 89034)
+++ trunk/LayoutTests/ChangeLog	2011-06-16 16:50:19 UTC (rev 89035)
@@ -1,3 +1,15 @@
+2011-06-16  Julien Chaffraix  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        HTMLTable should cache its 'rows' collection results
+        https://bugs.webkit.org/show_bug.cgi?id=62800
+
+        * perf/table-rows-length-caching-expected.txt: Added.
+        * perf/table-rows-length-caching.html: Added.
+        This test checks that the call to table.rows is CONSTANT once it has
+        been populated once (and the DOM is not mutated).
+
 2011-06-16  Vitaly Repeshko  <[email protected]>
 
         Unreviewed.

Added: trunk/LayoutTests/perf/table-rows-length-caching-expected.txt (0 => 89035)


--- trunk/LayoutTests/perf/table-rows-length-caching-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/perf/table-rows-length-caching-expected.txt	2011-06-16 16:50:19 UTC (rev 89035)
@@ -0,0 +1,3 @@
+Tests that check that table.row.length is properly cached
+PASS
+

Added: trunk/LayoutTests/perf/table-rows-length-caching.html (0 => 89035)


--- trunk/LayoutTests/perf/table-rows-length-caching.html	                        (rev 0)
+++ trunk/LayoutTests/perf/table-rows-length-caching.html	2011-06-16 16:50:19 UTC (rev 89035)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id='sandbox'></div>
+<div id="console"></div>
+<script src=""
+<script>
+
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var table;
+var sandbox = document.getElementById('sandbox');
+
+// Check that table.rows.length is properly cached.
+
+function setupTableRows(magnitude)
+{
+    if (sandbox.firstChild)
+        sandbox.removeChild(sandbox.firstChild);
+    table = document.createElement('table');
+
+    for (var i = 0; i < magnitude; ++i) {
+        var tr = document.createElement('tr');
+        table.appendChild(tr);
+    }
+    sandbox.appendChild(table);
+
+    // Make sure we have cached the length before testing!
+    table.rows.length;
+}
+
+function testTableRows(magnitude)
+{
+    table.rows.length;
+}
+
+Magnitude.description('Tests that check that table.row.length is properly cached');
+Magnitude.run(setupTableRows, testTableRows, Magnitude.CONSTANT);
+sandbox.removeChild(sandbox.firstChild);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (89034 => 89035)


--- trunk/Source/WebCore/ChangeLog	2011-06-16 16:39:27 UTC (rev 89034)
+++ trunk/Source/WebCore/ChangeLog	2011-06-16 16:50:19 UTC (rev 89035)
@@ -1,3 +1,30 @@
+2011-06-16  Julien Chaffraix  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        HTMLTable should cache its 'rows' collection results
+        https://bugs.webkit.org/show_bug.cgi?id=62800
+
+        Test: perf/table-rows-length-caching.html
+
+        Currently all our HTMLCollection's are recreated on call. This means that
+        we don't cache the information about the collection between calls to, for
+        example, table.rows.
+
+        This change adds a CollectionCache to HTMLTableElement. It is similar to what
+        is done for HTMLFormElement.
+
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::collectionCache): This method does
+        lazy initialization of the table's collectionCache.
+        * html/HTMLTableElement.h: Added a new member and the previous
+        method.
+
+        * html/HTMLTableRowsCollection.cpp:
+        (WebCore::HTMLTableRowsCollection::HTMLTableRowsCollection): Pass
+        the HTMLTableElement's CollectionCache so that we reuse the cached
+        results.
+
 2011-06-16  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r89025.

Modified: trunk/Source/WebCore/html/HTMLTableElement.cpp (89034 => 89035)


--- trunk/Source/WebCore/html/HTMLTableElement.cpp	2011-06-16 16:39:27 UTC (rev 89034)
+++ trunk/Source/WebCore/html/HTMLTableElement.cpp	2011-06-16 16:50:19 UTC (rev 89035)
@@ -624,6 +624,14 @@
     results.append(decl);
 }
 
+CollectionCache* HTMLTableElement::collectionCache() const
+{
+    if (!m_collectionCache)
+        m_collectionCache = adoptPtr(new CollectionCache());
+
+    return m_collectionCache.get();
+}
+
 void HTMLTableElement::attach()
 {
     ASSERT(!attached());

Modified: trunk/Source/WebCore/html/HTMLTableElement.h (89034 => 89035)


--- trunk/Source/WebCore/html/HTMLTableElement.h	2011-06-16 16:39:27 UTC (rev 89034)
+++ trunk/Source/WebCore/html/HTMLTableElement.h	2011-06-16 16:50:19 UTC (rev 89035)
@@ -68,6 +68,8 @@
     void addSharedCellDecls(Vector<CSSMutableStyleDeclaration*>&);
     void addSharedGroupDecls(bool rows, Vector<CSSMutableStyleDeclaration*>&);
 
+    CollectionCache* collectionCache() const;
+
 private:
     HTMLTableElement(const QualifiedName&, Document*);
 
@@ -100,6 +102,7 @@
 
     unsigned short m_padding;
     RefPtr<CSSMappedAttributeDeclaration> m_paddingDecl;
+    mutable OwnPtr<CollectionCache> m_collectionCache;
 };
 
 } //namespace

Modified: trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp (89034 => 89035)


--- trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp	2011-06-16 16:39:27 UTC (rev 89034)
+++ trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp	2011-06-16 16:50:19 UTC (rev 89035)
@@ -149,7 +149,7 @@
 }
 
 HTMLTableRowsCollection::HTMLTableRowsCollection(PassRefPtr<HTMLTableElement> table)
-    : HTMLCollection(table, OtherCollection, 0)
+    : HTMLCollection(table, OtherCollection, table->collectionCache())
 {
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to