Diff
Modified: trunk/Source/WebCore/ChangeLog (138840 => 138841)
--- trunk/Source/WebCore/ChangeLog 2013-01-04 20:51:10 UTC (rev 138840)
+++ trunk/Source/WebCore/ChangeLog 2013-01-04 21:03:20 UTC (rev 138841)
@@ -1,3 +1,43 @@
+2013-01-04 Adam Klein <ad...@chromium.org>
+
+ [v8] Stop using an IDL to generate V8MutationCallback
+ https://bugs.webkit.org/show_bug.cgi?id=106122
+
+ Reviewed by Adam Barth.
+
+ The only real code in the generated V8MutationCallback.{h,cpp} files
+ were specifically written in CodeGeneratorV8 for its use. By instead
+ Using completely-hand-written versions of these files, the
+ CodeGenerator can be simplified (as can all generated Callbacks).
+ All the actually shared code is still shared via subclassing of
+ ActiveDOMCallback.
+
+ This introduces additional flexibility into the implementation of
+ MutationCallback which will be used when fixing the MutationObserver
+ memory leak (http://webkit.org/b/90661) for JSC.
+
+ No changes to JSC for now, just a FIXME in the IDL file.
+
+ No new tests, refactoringonly.
+
+ * WebCore.gypi:
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateCallbackHeader):
+ (GenerateCallbackImplementation):
+ * bindings/scripts/test/V8/V8TestCallback.cpp:
+ (WebCore::V8TestCallback::V8TestCallback):
+ * bindings/scripts/test/V8/V8TestCallback.h:
+ (WebCore::V8TestCallback::create):
+ (V8TestCallback):
+ * bindings/v8/V8MutationCallback.cpp: Renamed from Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp.
+ (WebCore::V8MutationCallback::V8MutationCallback):
+ (WebCore::V8MutationCallback::handleEvent):
+ * bindings/v8/V8MutationCallback.h: Added.
+ (V8MutationCallback):
+ (WebCore::V8MutationCallback::create):
+ (WebCore::V8MutationCallback::weakCallback):
+ * dom/MutationCallback.idl:
+
2013-01-04 Tony Chang <t...@chromium.org>
Remove some autogenerated settings from InternalSettings.idl
Modified: trunk/Source/WebCore/WebCore.gypi (138840 => 138841)
--- trunk/Source/WebCore/WebCore.gypi 2013-01-04 20:51:10 UTC (rev 138840)
+++ trunk/Source/WebCore/WebCore.gypi 2013-01-04 21:03:20 UTC (rev 138841)
@@ -224,7 +224,6 @@
'dom/MessageEvent.idl',
'dom/MessagePort.idl',
'dom/MouseEvent.idl',
- 'dom/MutationCallback.idl',
'dom/MutationEvent.idl',
'dom/MutationObserver.idl',
'dom/MutationRecord.idl',
@@ -1258,6 +1257,8 @@
'bindings/v8/V8Initializer.h',
'bindings/v8/V8LazyEventListener.cpp',
'bindings/v8/V8LazyEventListener.h',
+ 'bindings/v8/V8MutationCallback.cpp',
+ 'bindings/v8/V8MutationCallback.h',
'bindings/v8/V8NPObject.cpp',
'bindings/v8/V8NPObject.h',
'bindings/v8/V8NPUtils.cpp',
@@ -1362,7 +1363,6 @@
'bindings/v8/custom/V8MessageEventCustom.cpp',
'bindings/v8/custom/V8MessagePortCustom.cpp',
'bindings/v8/custom/V8MicroDataItemValueCustom.cpp',
- 'bindings/v8/custom/V8MutationCallbackCustom.cpp',
'bindings/v8/custom/V8MutationObserverCustom.cpp',
'bindings/v8/custom/V8NamedNodeMapCustom.cpp',
'bindings/v8/custom/V8NamedNodesCollection.cpp',
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (138840 => 138841)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2013-01-04 20:51:10 UTC (rev 138840)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2013-01-04 21:03:20 UTC (rev 138841)
@@ -3252,11 +3252,11 @@
push(@headerContent, <<END);
public:
- static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner = v8::Handle<v8::Object>())
+ static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context)
{
ASSERT(value->IsObject());
ASSERT(context);
- return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(value), context, owner));
+ return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(value), context));
}
virtual ~${v8InterfaceName}();
@@ -3290,14 +3290,8 @@
virtual ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
private:
- ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>);
+ ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*);
- static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
- {
- ${v8InterfaceName}* object = static_cast<${v8InterfaceName}*>(parameter);
- object->m_callback.clear();
- }
-
ScopedPersistent<v8::Object> m_callback;
WorldContextHandle m_worldContext;
};
@@ -3328,15 +3322,11 @@
push(@implContent, "#include <wtf/Assertions.h>\n\n");
push(@implContent, "namespace WebCore {\n\n");
push(@implContent, <<END);
-${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
+${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context)
: ActiveDOMCallback(context)
, m_callback(callback)
, m_worldContext(UseCurrentWorld)
{
- if (owner.IsEmpty())
- return;
- owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
- m_callback.get().MakeWeak(this, &${v8InterfaceName}::weakCallback);
}
${v8InterfaceName}::~${v8InterfaceName}()
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp (138840 => 138841)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp 2013-01-04 20:51:10 UTC (rev 138840)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp 2013-01-04 21:03:20 UTC (rev 138841)
@@ -39,15 +39,11 @@
namespace WebCore {
-V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
+V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context)
: ActiveDOMCallback(context)
, m_callback(callback)
, m_worldContext(UseCurrentWorld)
{
- if (owner.IsEmpty())
- return;
- owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
- m_callback.get().MakeWeak(this, &V8TestCallback::weakCallback);
}
V8TestCallback::~V8TestCallback()
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h (138840 => 138841)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h 2013-01-04 20:51:10 UTC (rev 138840)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h 2013-01-04 21:03:20 UTC (rev 138841)
@@ -36,11 +36,11 @@
class V8TestCallback : public TestCallback, public ActiveDOMCallback {
public:
- static PassRefPtr<V8TestCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner = v8::Handle<v8::Object>())
+ static PassRefPtr<V8TestCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context)
{
ASSERT(value->IsObject());
ASSERT(context);
- return adoptRef(new V8TestCallback(v8::Handle<v8::Object>::Cast(value), context, owner));
+ return adoptRef(new V8TestCallback(v8::Handle<v8::Object>::Cast(value), context));
}
virtual ~V8TestCallback();
@@ -58,14 +58,8 @@
virtual ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
private:
- V8TestCallback(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>);
+ V8TestCallback(v8::Handle<v8::Object>, ScriptExecutionContext*);
- static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
- {
- V8TestCallback* object = static_cast<V8TestCallback*>(parameter);
- object->m_callback.clear();
- }
-
ScopedPersistent<v8::Object> m_callback;
WorldContextHandle m_worldContext;
};
Copied: trunk/Source/WebCore/bindings/v8/V8MutationCallback.cpp (from rev 138840, trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp) (0 => 138841)
--- trunk/Source/WebCore/bindings/v8/V8MutationCallback.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/v8/V8MutationCallback.cpp 2013-01-04 21:03:20 UTC (rev 138841)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8MutationCallback.h"
+
+#include "ScriptExecutionContext.h"
+#include "V8Binding.h"
+#include "V8Callback.h"
+#include "V8MutationObserver.h"
+#include "V8MutationRecord.h"
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+V8MutationCallback::V8MutationCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
+ : ActiveDOMCallback(context)
+ , m_callback(callback)
+ , m_worldContext(UseCurrentWorld)
+{
+ owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
+ m_callback.get().MakeWeak(this, &V8MutationCallback::weakCallback);
+}
+
+bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObserver* observer)
+{
+ ASSERT(mutations);
+ if (!mutations)
+ return true;
+
+ if (!canInvokeCallback())
+ return true;
+
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
+ if (v8Context.IsEmpty())
+ return true;
+
+ v8::Context::Scope scope(v8Context);
+
+ v8::Local<v8::Array> mutationsArray = v8::Array::New(mutations->size());
+ for (size_t i = 0; i < mutations->size(); ++i)
+ mutationsArray->Set(deprecatedV8Integer(i), toV8(mutations->at(i).get()));
+
+ v8::Handle<v8::Value> observerHandle = toV8(observer);
+ if (observerHandle.IsEmpty()) {
+ if (!isScriptControllerTerminating())
+ CRASH();
+ return true;
+ }
+
+ if (!observerHandle->IsObject())
+ return true;
+
+ v8::Handle<v8::Value> argv[] = {
+ mutationsArray,
+ observerHandle
+ };
+
+ bool callbackReturnValue = false;
+ return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/bindings/v8/V8MutationCallback.h (0 => 138841)
--- trunk/Source/WebCore/bindings/v8/V8MutationCallback.h (rev 0)
+++ trunk/Source/WebCore/bindings/v8/V8MutationCallback.h 2013-01-04 21:03:20 UTC (rev 138841)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8MutationCallback_h
+#define V8MutationCallback_h
+
+#include "ActiveDOMCallback.h"
+#include "MutationCallback.h"
+#include "ScopedPersistent.h"
+#include "WorldContextHandle.h"
+#include <v8.h>
+
+namespace WebCore {
+
+class ScriptExecutionContext;
+
+class V8MutationCallback : public MutationCallback, public ActiveDOMCallback {
+public:
+ static PassRefPtr<V8MutationCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
+ {
+ ASSERT(value->IsObject());
+ ASSERT(context);
+ return adoptRef(new V8MutationCallback(v8::Handle<v8::Object>::Cast(value), context, owner));
+ }
+
+ virtual bool handleEvent(MutationRecordArray*, MutationObserver*) OVERRIDE;
+ virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ContextDestructionObserver::scriptExecutionContext(); }
+
+private:
+ V8MutationCallback(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>);
+
+ static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
+ {
+ V8MutationCallback* object = static_cast<V8MutationCallback*>(parameter);
+ object->m_callback.clear();
+ }
+
+ ScopedPersistent<v8::Object> m_callback;
+ WorldContextHandle m_worldContext;
+};
+
+}
+
+#endif // V8MutationCallback_h
Deleted: trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp (138840 => 138841)
--- trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp 2013-01-04 20:51:10 UTC (rev 138840)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp 2013-01-04 21:03:20 UTC (rev 138841)
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2010, 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "V8MutationCallback.h"
-
-#include "ScriptExecutionContext.h"
-#include "V8Binding.h"
-#include "V8Callback.h"
-#include "V8MutationObserver.h"
-#include "V8MutationRecord.h"
-#include <wtf/Assertions.h>
-#include <wtf/GetPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObserver* observer)
-{
- ASSERT(mutations);
- if (!mutations)
- return true;
-
- if (!canInvokeCallback())
- return true;
-
- v8::HandleScope handleScope;
-
- v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
- if (v8Context.IsEmpty())
- return true;
-
- v8::Context::Scope scope(v8Context);
-
- v8::Local<v8::Array> mutationsArray = v8::Array::New(mutations->size());
- for (size_t i = 0; i < mutations->size(); ++i)
- mutationsArray->Set(deprecatedV8Integer(i), toV8(mutations->at(i).get()));
-
- v8::Handle<v8::Value> observerHandle = toV8(observer);
- if (observerHandle.IsEmpty()) {
- if (!isScriptControllerTerminating())
- CRASH();
- return true;
- }
-
- if (!observerHandle->IsObject())
- return true;
-
- v8::Handle<v8::Value> argv[] = {
- mutationsArray,
- observerHandle
- };
-
- bool callbackReturnValue = false;
- return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
-}
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/dom/MutationCallback.idl (138840 => 138841)
--- trunk/Source/WebCore/dom/MutationCallback.idl 2013-01-04 20:51:10 UTC (rev 138840)
+++ trunk/Source/WebCore/dom/MutationCallback.idl 2013-01-04 21:03:20 UTC (rev 138841)
@@ -28,6 +28,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+// FIXME: This interface is only used to generate code for JSC.
+// It should be removed once http://webkit.org/b/93661 is fixed.
[
Callback
] interface MutationCallback {