summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/node-childNodes-idempotence.html
diff options
context:
space:
mode:
authorkling@webkit.org <kling@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2012-01-19 02:55:03 +0000
committerkling@webkit.org <kling@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2012-01-19 02:55:03 +0000
commit1c9f333f79e38a865e50f8f1ec33a50e5be2375f (patch)
treed596919d50d18e5603bf5891294703501132e594 /third_party/WebKit/LayoutTests/fast/dom/node-childNodes-idempotence.html
parentc11068bd4edc2054f27a4ed2e5e55d3b69601fd0 (diff)
downloadchromium_src-1c9f333f79e38a865e50f8f1ec33a50e5be2375f.zip
chromium_src-1c9f333f79e38a865e50f8f1ec33a50e5be2375f.tar.gz
chromium_src-1c9f333f79e38a865e50f8f1ec33a50e5be2375f.tar.bz2
Cache and reuse the NodeList returned by Node::childNodes().
<http://webkit.org/b/76591> Reviewed by Ryosuke Niwa. Source/WebCore: Instead of only caching the DynamicNodeList::Caches for .childNodes on NodeRareData, cache the full ChildNodeList object. Lifetime management is left to wrappers who invalidate the cached (raw) pointer via Node::removeCachedChildNodeList(), called from ~ChildNodeList(). This is a slight behavior change, in that Node.childNodes === Node.childNodes will now be true. This matches the behavior of both Firefox and Opera. This reduces memory consumption by 192 kB (on 32-bit) when viewing the full HTML5 spec at <http://whatwg.org/c> Test: fast/dom/gc-9.html fast/dom/node-childNodes-idempotence.html * dom/Node.cpp: (WebCore::Node::childNodes): * dom/NodeRareData.h: (WebCore::NodeRareData::NodeRareData): (WebCore::NodeRareData::childNodeList): (WebCore::NodeRareData::setChildNodeList): Only construct one ChildNodeList per Node and store it on NodeRareData for retrieval across childNodes() calls. * dom/ChildNodeList.h: (WebCore::ChildNodeList::create): * dom/ChildNodeList.cpp: (WebCore::ChildNodeList::ChildNodeList): Construct the Caches at creation instead of passing it to the constructor. (WebCore::ChildNodeList::reset): Added, resets the internal cache. (WebCore::ChildNodeList::~ChildNodeList): Call Node::removeCachedChildNodeList(). * dom/DynamicNodeList.cpp: * dom/DynamicNodeList.h: Have DynamicNodeList (and subclasses) respond "true" to isDynamicNodeList(). Previously only DynamicSubtreeNodeList (and subclasses) were doing this. Without it, JSC may GC our ChildNodeLists prematurely (due to NodeList's isReachableFromOpaqueRoots() implementation checking isDynamicNodeList().) * dom/Node.h: * dom/Node.cpp: (WebCore::Node::removeCachedChildNodeList): Added for ~ChildNodeList() to remove the pointer to itself from the Node. (WebCore::NodeRareData::clearChildNodeListCache): Call ChildNodeList::reset(). LayoutTests: Updated gc-9.html to document the new lifetime characteristics of a .childNodes with custom properties. Also added a test to verify that .childNodes === .childNodes. * fast/dom/gc-9-expected.txt: * fast/dom/gc-9.html: * fast/dom/node-childNodes-idempotence-expected.txt: Added. * fast/dom/node-childNodes-idempotence.html: Added. git-svn-id: svn://svn.chromium.org/blink/trunk@105372 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/dom/node-childNodes-idempotence.html')
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/node-childNodes-idempotence.html18
1 files changed, 18 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/dom/node-childNodes-idempotence.html b/third_party/WebKit/LayoutTests/fast/dom/node-childNodes-idempotence.html
new file mode 100644
index 0000000..fdb90d3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/node-childNodes-idempotence.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description("This test verifies that Node.childNodes returns the same NodeList when called repeatedly.");
+
+shouldBe("document.documentElement.childNodes", "document.documentElement.childNodes");
+shouldBeTrue("document.documentElement.childNodes === document.documentElement.childNodes");
+
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>