From 4e58d20e24273eb27d580348ff23ccbbe73d2cbd Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Fri, 24 Feb 2012 13:41:02 +0000 Subject: [PATCH] [v8] when a named item on document goes out of scope, actually remove it https://bugs.webkit.org/show_bug.cgi?id=79409 Reviewed by Adam Barth. Source/WebCore: The original change already included the code, but it led to some problems, so it was reverted in http://trac.webkit.org/changeset/63845. However, not removing the items leaks a considerable amount of memory, so I'm adding the code back. The bug that led to the revert was that the accessor was removed unconditionally. I'm now only removing it, when the last item with that name is removed. Test: fast/dom/HTMLDocument/named-item.html * bindings/v8/V8DOMWindowShell.cpp: (WebCore::V8DOMWindowShell::namedItemRemoved): LayoutTests: * fast/dom/HTMLDocument/named-item-expected.txt: Added. * fast/dom/HTMLDocument/named-item.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108780 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 ++++++++ .../fast/dom/HTMLDocument/named-item-expected.txt | 3 +++ LayoutTests/fast/dom/HTMLDocument/named-item.html | 28 ++++++++++++++++++++++ Source/WebCore/ChangeLog | 19 +++++++++++++++ Source/WebCore/bindings/v8/V8DOMWindowShell.cpp | 12 ++++++++++ 5 files changed, 72 insertions(+) create mode 100644 LayoutTests/fast/dom/HTMLDocument/named-item-expected.txt create mode 100644 LayoutTests/fast/dom/HTMLDocument/named-item.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 159342c..3f17201 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2012-02-24 Jochen Eisinger + + [v8] when a named item on document goes out of scope, actually remove it + https://bugs.webkit.org/show_bug.cgi?id=79409 + + Reviewed by Adam Barth. + + * fast/dom/HTMLDocument/named-item-expected.txt: Added. + * fast/dom/HTMLDocument/named-item.html: Added. + 2012-02-24 Flex Mobile Convert some fast/regions pixel tests to reftests diff --git a/LayoutTests/fast/dom/HTMLDocument/named-item-expected.txt b/LayoutTests/fast/dom/HTMLDocument/named-item-expected.txt new file mode 100644 index 0000000..9eb935d --- /dev/null +++ b/LayoutTests/fast/dom/HTMLDocument/named-item-expected.txt @@ -0,0 +1,3 @@ +Tests that the named item created for an image with an ID is correctly removed. The test passes, if you see a "PASS" message in the div below. + +PASS diff --git a/LayoutTests/fast/dom/HTMLDocument/named-item.html b/LayoutTests/fast/dom/HTMLDocument/named-item.html new file mode 100644 index 0000000..25818f5 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLDocument/named-item.html @@ -0,0 +1,28 @@ + + + + + +

+Tests that the named item created for an image with an ID is correctly removed. +The test passes, if you see a "PASS" message in the div below. +

+
+ + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index fa50305..56710c5 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,22 @@ +2012-02-24 Jochen Eisinger + + [v8] when a named item on document goes out of scope, actually remove it + https://bugs.webkit.org/show_bug.cgi?id=79409 + + Reviewed by Adam Barth. + + The original change already included the code, but it led to some + problems, so it was reverted in http://trac.webkit.org/changeset/63845. + However, not removing the items leaks a considerable amount of memory, + so I'm adding the code back. The bug that led to the revert was that + the accessor was removed unconditionally. I'm now only removing it, + when the last item with that name is removed. + + Test: fast/dom/HTMLDocument/named-item.html + + * bindings/v8/V8DOMWindowShell.cpp: + (WebCore::V8DOMWindowShell::namedItemRemoved): + 2012-02-24 Kentaro Hara Move Worker-related APIs from DOMWindow.idl to DOMWindowWorker.idl diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp index a2fceb0..8d16a10 100644 --- a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp +++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp @@ -577,6 +577,18 @@ void V8DOMWindowShell::namedItemAdded(HTMLDocument* doc, const AtomicString& nam void V8DOMWindowShell::namedItemRemoved(HTMLDocument* doc, const AtomicString& name) { + if (doc->hasNamedItem(name.impl()) || doc->hasExtraNamedItem(name.impl())) + return; + + if (!initContextIfNeeded()) + return; + + v8::HandleScope handleScope; + v8::Context::Scope contextScope(m_context); + + ASSERT(!m_document.IsEmpty()); + checkDocumentWrapper(m_document, doc); + m_document->Delete(v8String(name)); } void V8DOMWindowShell::updateSecurityOrigin() -- 2.7.4