Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: Source/WebCore/bindings/v8/V8LazyEventListener.cpp

Issue 10007027: Merge 113086 - [v8] Fix memory leak in V8LazyEventListener (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/bindings/v8/V8LazyEventListener.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/bindings/v8/V8LazyEventListener.cpp
===================================================================
--- Source/WebCore/bindings/v8/V8LazyEventListener.cpp (revision 113392)
+++ Source/WebCore/bindings/v8/V8LazyEventListener.cpp (working copy)
@@ -50,18 +50,15 @@
namespace WebCore {
-V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, PassRefPtr<Node> node, const WorldContextHandle& worldContext)
+V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, Node* node, const WorldContextHandle& worldContext)
: V8AbstractEventListener(true, worldContext)
, m_functionName(functionName)
, m_eventParameterName(eventParameterName)
, m_code(code)
, m_sourceURL(sourceURL)
, m_node(node)
- , m_formElement(0)
, m_position(position)
{
- if (m_node && m_node->isHTMLElement())
- m_formElement = static_cast<HTMLElement*>(m_node.get())->form();
}
template<typename T>
@@ -165,13 +162,14 @@
ASSERT(value->IsFunction());
v8::Local<v8::Function> intermediateFunction = value.As<v8::Function>();
- v8::Handle<v8::Object> nodeWrapper = toObjectWrapper<Node>(m_node.get());
- v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(m_formElement.get());
+ HTMLFormElement* formElement = 0;
+ if (m_node && m_node->isHTMLElement())
+ formElement = static_cast<HTMLElement*>(m_node)->form();
+
+ v8::Handle<v8::Object> nodeWrapper = toObjectWrapper<Node>(m_node);
+ v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(formElement);
v8::Handle<v8::Object> documentWrapper = toObjectWrapper<Document>(m_node ? m_node->ownerDocument() : 0);
- m_node.clear();
- m_formElement.clear();
-
v8::Handle<v8::Value> parameters[3] = { nodeWrapper, formWrapper, documentWrapper };
// Use Call directly to avoid an erroneous call to V8RecursionScope::didLeaveScriptContext().
@@ -212,6 +210,12 @@
wrappedFunction->SetName(v8::String::New(fromWebCoreString(m_functionName), m_functionName.length()));
+ // Since we only parse once, there's no need to keep data used for parsing around anymore.
+ m_functionName = String();
+ m_code = String();
+ m_eventParameterName = String();
+ m_sourceURL = String();
+
setListenerObject(wrappedFunction);
}
« no previous file with comments | « Source/WebCore/bindings/v8/V8LazyEventListener.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698