If Node X is reachable from JavaScript, all Nodes in the same tree should be kept...
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Oct 2012 18:27:56 +0000 (18:27 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Oct 2012 18:27:56 +0000 (18:27 +0000)
commit11822d3dfcc1c7010b65bd1d6b8ba55764e21aa7
tree225663559725efa1f741470803c07c066a987c07
parent7ca053dcecb7a0a736d677fcfbe4a8be93fa80d3
If Node X is reachable from JavaScript, all Nodes in the same tree should be kept alive
https://bugs.webkit.org/show_bug.cgi?id=88834

Reviewed by Gavin Barraclough.

Source/WebCore:

* bindings/js/JSNodeCustom.cpp:
(WebCore::isObservable): Clarified this comment, since it seems to have
misled some folks.

* bindings/js/JSNodeCustom.h:
(WebCore::willCreatePossiblyOrphanedTreeByRemoval): New helper function
to ensure that a disconnected tree is visible to JavaScript.

* bindings/js/ScriptState.cpp:
(WebCore::mainWorldScriptState): Need to check for null because a document's
frame can be null.

* dom/ContainerNode.cpp:
(WebCore::dispatchChildRemovalEvents): When we remove a subtree from the
document, we sever the reference that JavaScript previously held by
referencing its root. So, we give JavaScript an opportunity to establish
a reference to the new root.

LayoutTests:

* fast/dom/gc-12-expected.txt: Added.
* fast/dom/gc-12.html: Added. Test case matches an example cited by
Kentaro Hara <haraken@chromium.org> in bugzilla.

* fast/dom/gc-3-expected.txt:
* fast/dom/gc-3.html:
* fast/dom/gc-5-expected.txt:
* fast/dom/gc-5.html: Updated these tests to reflect new expected behavior.
We've decided that disconnected trees should persist in memory. This risks
a programmer accidentally retaining more memory than expected, but it
also makes the API more obvious.

* fast/dom/gc-dom-tree-lifetime-expected.txt: Added.
* fast/dom/gc-dom-tree-lifetime.html: Added. Test case written by
Kentaro Hara <haraken@chromium.org>.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/gc-12-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/gc-12.html [new file with mode: 0644]
LayoutTests/fast/dom/gc-3-expected.txt
LayoutTests/fast/dom/gc-3.html
LayoutTests/fast/dom/gc-5-expected.txt
LayoutTests/fast/dom/gc-5.html
LayoutTests/fast/dom/gc-dom-tree-lifetime-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/gc-dom-tree-lifetime.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSNodeCustom.cpp
Source/WebCore/bindings/js/JSNodeCustom.h
Source/WebCore/bindings/js/ScriptState.cpp
Source/WebCore/dom/ContainerNode.cpp