Changeset 138841 in webkit
- Timestamp:
- Jan 4, 2013, 1:03:20 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r138840 r138841 1 2013-01-04 Adam Klein <adamk@chromium.org> 2 3 [v8] Stop using an IDL to generate V8MutationCallback 4 https://bugs.webkit.org/show_bug.cgi?id=106122 5 6 Reviewed by Adam Barth. 7 8 The only real code in the generated V8MutationCallback.{h,cpp} files 9 were specifically written in CodeGeneratorV8 for its use. By instead 10 Using completely-hand-written versions of these files, the 11 CodeGenerator can be simplified (as can all generated Callbacks). 12 All the actually shared code is still shared via subclassing of 13 ActiveDOMCallback. 14 15 This introduces additional flexibility into the implementation of 16 MutationCallback which will be used when fixing the MutationObserver 17 memory leak (http://webkit.org/b/90661) for JSC. 18 19 No changes to JSC for now, just a FIXME in the IDL file. 20 21 No new tests, refactoringonly. 22 23 * WebCore.gypi: 24 * bindings/scripts/CodeGeneratorV8.pm: 25 (GenerateCallbackHeader): 26 (GenerateCallbackImplementation): 27 * bindings/scripts/test/V8/V8TestCallback.cpp: 28 (WebCore::V8TestCallback::V8TestCallback): 29 * bindings/scripts/test/V8/V8TestCallback.h: 30 (WebCore::V8TestCallback::create): 31 (V8TestCallback): 32 * bindings/v8/V8MutationCallback.cpp: Renamed from Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp. 33 (WebCore::V8MutationCallback::V8MutationCallback): 34 (WebCore::V8MutationCallback::handleEvent): 35 * bindings/v8/V8MutationCallback.h: Added. 36 (V8MutationCallback): 37 (WebCore::V8MutationCallback::create): 38 (WebCore::V8MutationCallback::weakCallback): 39 * dom/MutationCallback.idl: 40 1 41 2013-01-04 Tony Chang <tony@chromium.org> 2 42 -
trunk/Source/WebCore/WebCore.gypi
r138836 r138841 225 225 'dom/MessagePort.idl', 226 226 'dom/MouseEvent.idl', 227 'dom/MutationCallback.idl',228 227 'dom/MutationEvent.idl', 229 228 'dom/MutationObserver.idl', … … 1259 1258 'bindings/v8/V8LazyEventListener.cpp', 1260 1259 'bindings/v8/V8LazyEventListener.h', 1260 'bindings/v8/V8MutationCallback.cpp', 1261 'bindings/v8/V8MutationCallback.h', 1261 1262 'bindings/v8/V8NPObject.cpp', 1262 1263 'bindings/v8/V8NPObject.h', … … 1363 1364 'bindings/v8/custom/V8MessagePortCustom.cpp', 1364 1365 'bindings/v8/custom/V8MicroDataItemValueCustom.cpp', 1365 'bindings/v8/custom/V8MutationCallbackCustom.cpp',1366 1366 'bindings/v8/custom/V8MutationObserverCustom.cpp', 1367 1367 'bindings/v8/custom/V8NamedNodeMapCustom.cpp', -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r138769 r138841 3253 3253 push(@headerContent, <<END); 3254 3254 public: 3255 static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context , v8::Handle<v8::Object> owner = v8::Handle<v8::Object>())3255 static PassRefPtr<${v8InterfaceName}> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context) 3256 3256 { 3257 3257 ASSERT(value->IsObject()); 3258 3258 ASSERT(context); 3259 return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(value), context , owner));3259 return adoptRef(new ${v8InterfaceName}(v8::Handle<v8::Object>::Cast(value), context)); 3260 3260 } 3261 3261 … … 3291 3291 3292 3292 private: 3293 ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>); 3294 3295 static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter) 3296 { 3297 ${v8InterfaceName}* object = static_cast<${v8InterfaceName}*>(parameter); 3298 object->m_callback.clear(); 3299 } 3293 ${v8InterfaceName}(v8::Handle<v8::Object>, ScriptExecutionContext*); 3300 3294 3301 3295 ScopedPersistent<v8::Object> m_callback; … … 3329 3323 push(@implContent, "namespace WebCore {\n\n"); 3330 3324 push(@implContent, <<END); 3331 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context , v8::Handle<v8::Object> owner)3325 ${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context) 3332 3326 : ActiveDOMCallback(context) 3333 3327 , m_callback(callback) 3334 3328 , m_worldContext(UseCurrentWorld) 3335 3329 { 3336 if (owner.IsEmpty())3337 return;3338 owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);3339 m_callback.get().MakeWeak(this, &${v8InterfaceName}::weakCallback);3340 3330 } 3341 3331 -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp
r136822 r138841 40 40 namespace WebCore { 41 41 42 V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context , v8::Handle<v8::Object> owner)42 V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context) 43 43 : ActiveDOMCallback(context) 44 44 , m_callback(callback) 45 45 , m_worldContext(UseCurrentWorld) 46 46 { 47 if (owner.IsEmpty())48 return;49 owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);50 m_callback.get().MakeWeak(this, &V8TestCallback::weakCallback);51 47 } 52 48 -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h
r138769 r138841 37 37 class V8TestCallback : public TestCallback, public ActiveDOMCallback { 38 38 public: 39 static PassRefPtr<V8TestCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context , v8::Handle<v8::Object> owner = v8::Handle<v8::Object>())39 static PassRefPtr<V8TestCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context) 40 40 { 41 41 ASSERT(value->IsObject()); 42 42 ASSERT(context); 43 return adoptRef(new V8TestCallback(v8::Handle<v8::Object>::Cast(value), context , owner));43 return adoptRef(new V8TestCallback(v8::Handle<v8::Object>::Cast(value), context)); 44 44 } 45 45 … … 59 59 60 60 private: 61 V8TestCallback(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>); 62 63 static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter) 64 { 65 V8TestCallback* object = static_cast<V8TestCallback*>(parameter); 66 object->m_callback.clear(); 67 } 61 V8TestCallback(v8::Handle<v8::Object>, ScriptExecutionContext*); 68 62 69 63 ScopedPersistent<v8::Object> m_callback; -
trunk/Source/WebCore/bindings/v8/V8MutationCallback.cpp
r138840 r138841 1 1 /* 2 * Copyright (C) 201 0, 2012Google Inc. All rights reserved.2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 7 12 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 29 24 */ 30 25 31 26 #include "config.h" 32 33 27 #include "V8MutationCallback.h" 34 28 … … 39 33 #include "V8MutationRecord.h" 40 34 #include <wtf/Assertions.h> 41 #include <wtf/GetPtr.h>42 #include <wtf/RefCounted.h>43 #include <wtf/RefPtr.h>44 35 45 36 namespace WebCore { 37 38 V8MutationCallback::V8MutationCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner) 39 : ActiveDOMCallback(context) 40 , m_callback(callback) 41 , m_worldContext(UseCurrentWorld) 42 { 43 owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback); 44 m_callback.get().MakeWeak(this, &V8MutationCallback::weakCallback); 45 } 46 46 47 47 bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObserver* observer) -
trunk/Source/WebCore/dom/MutationCallback.idl
r138811 r138841 29 29 */ 30 30 31 // FIXME: This interface is only used to generate code for JSC. 32 // It should be removed once http://webkit.org/b/93661 is fixed. 31 33 [ 32 34 Callback
Note:
See TracChangeset
for help on using the changeset viewer.