Reviewed by Sam.
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Mar 2008 01:39:21 +0000 (01:39 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Mar 2008 01:39:21 +0000 (01:39 +0000)
        * WebCore.xcodeproj/project.pbxproj:
        Change jni_jsobject.cpp to be Obj-C++ for now. The plan is to merge
        this with jni_objc.mm and create jni_jsobject.mm.

        * bridge/jni/jni_jsobject.cpp:
        (createRootObject):
        Move createRootObject here from WebCoreFrameBridge.

        (JavaJSObject::createNative):
        Call the newly added createRootObject function.

        * bridge/runtime_root.cpp:
        (KJS::Bindings::RootObject::initializeJNIThreading):
        * bridge/runtime_root.h:
        setCreateRootObject no longer takes a root object, rename it to initializeJNIThreading.

        * page/mac/FrameMac.mm:
        (WebCore::Frame::createScriptInstanceForWidget):
        Just call Frame::createRootObject here.

        * page/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge init]):
        Call initializeJNIThreading.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30814 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/jni/jni_jsobject.cpp
WebCore/bridge/runtime_root.cpp
WebCore/bridge/runtime_root.h
WebCore/page/mac/FrameMac.mm
WebCore/page/mac/WebCoreFrameBridge.mm

index acd4410ec22cead88d0cb43edc2aa9463e1952d7..cd10e95996cae682a6b65924b571e01202bc05ad 100644 (file)
@@ -1,3 +1,31 @@
+2008-03-05  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Change jni_jsobject.cpp to be Obj-C++ for now. The plan is to merge 
+        this with jni_objc.mm and create jni_jsobject.mm.
+        
+        * bridge/jni/jni_jsobject.cpp:
+        (createRootObject):
+        Move createRootObject here from WebCoreFrameBridge.
+        
+        (JavaJSObject::createNative):
+        Call the newly added createRootObject function.
+        
+        * bridge/runtime_root.cpp:
+        (KJS::Bindings::RootObject::initializeJNIThreading):
+        * bridge/runtime_root.h:
+        setCreateRootObject no longer takes a root object, rename it to initializeJNIThreading.
+
+        * page/mac/FrameMac.mm:
+        (WebCore::Frame::createScriptInstanceForWidget):
+        Just call Frame::createRootObject here.
+        
+        * page/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge init]):
+        Call initializeJNIThreading.
+
 2008-03-05  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam.
index 27c27df82f2cba3b8dd239132aae857340314109..7c65511fc4e08155b2d95bde972dfaf65f04391f 100644 (file)
                1A569CD00D7E2B82007C3983 /* jni_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_class.h; sourceTree = "<group>"; };
                1A569CD10D7E2B82007C3983 /* jni_instance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_instance.cpp; sourceTree = "<group>"; };
                1A569CD20D7E2B82007C3983 /* jni_instance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_instance.h; sourceTree = "<group>"; };
-               1A569CD30D7E2B82007C3983 /* jni_jsobject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_jsobject.cpp; sourceTree = "<group>"; };
+               1A569CD30D7E2B82007C3983 /* jni_jsobject.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = jni_jsobject.cpp; sourceTree = "<group>"; };
                1A569CD40D7E2B82007C3983 /* jni_jsobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_jsobject.h; sourceTree = "<group>"; };
                1A569CD50D7E2B82007C3983 /* jni_objc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = jni_objc.mm; sourceTree = "<group>"; };
                1A569CD60D7E2B82007C3983 /* jni_runtime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_runtime.cpp; sourceTree = "<group>"; };
index 602aca7ef8d2e25ab2f1fe29b2f5acb40042e024..28d89487653b2cf368107962ace925d9966bbb1d 100644 (file)
 #include "config.h"
 #include "jni_jsobject.h"
 
+#include "Frame.h"
+#include "kjs_proxy.h"
+#include "WebCoreFrameBridge.h"
+#include "WebCoreViewFactory.h"
 #include "jni_runtime.h"
 #include "jni_utility.h"
 #include "runtime_object.h"
 #include <kjs/ExecState.h>
 #include <kjs/JSGlobalObject.h>
 #include <kjs/interpreter.h>
-
 #include <wtf/Assertions.h>
 
+using WebCore::Frame;
+
 using namespace KJS::Bindings;
 using namespace KJS;
 
@@ -316,6 +321,17 @@ void JavaJSObject::finalize() const
         rootObject->gcUnprotect(_imp);
 }
 
+static PassRefPtr<RootObject> createRootObject(void* nativeHandle)
+{
+    NSView *view = (NSView *)nativeHandle;
+    WebCoreFrameBridge *bridge = [[WebCoreViewFactory sharedFactory] bridgeForView:view];
+    if (!bridge)
+        return 0;
+    
+    Frame* frame = [bridge _frame];
+    return frame->createRootObject(nativeHandle, frame->scriptProxy()->globalObject());
+}
+
 // We're either creating a 'Root' object (via a call to JavaJSObject.getWindow()), or
 // another JavaJSObject.
 jlong JavaJSObject::createNative(jlong nativeHandle)
@@ -328,10 +344,6 @@ jlong JavaJSObject::createNative(jlong nativeHandle)
     if (findProtectingRootObject(jlong_to_impptr(nativeHandle)))
         return nativeHandle;
 
-    CreateRootObjectFunction createRootObject = RootObject::createRootObject();
-    if (!createRootObject)
-        return ptr_to_jlong(0);
-
     RefPtr<RootObject> rootObject = createRootObject(jlong_to_ptr(nativeHandle));
 
     // If rootObject is !NULL We must have been called via netscape.javascript.JavaJSObject.getWindow(),
index 1804e25cb4b784134050dde83313c38bbd6d1478..78b0242b833bc774ecbdc9d5d23edfffa4282a7a 100644 (file)
@@ -171,28 +171,19 @@ static void performJavaScriptAccess(void*)
         CFRunLoopWakeUp(originatingLoop);
 }
 
-static CreateRootObjectFunction _createRootObject;
-    
-CreateRootObjectFunction RootObject::createRootObject()
-{
-    return _createRootObject;
-}
-
 CFRunLoopRef RootObject::runLoop()
 {
     return _runLoop;
 }        
 
 // Must be called from the thread that will be used to access JavaScript.
-void RootObject::setCreateRootObject(CreateRootObjectFunction createRootObject) {
+void RootObject::initializeJNIThreading() {
     // Should only be called once.
-    ASSERT(!_createRootObject);
+    ASSERT(!_runLoop);
 
-    _createRootObject = createRootObject;
-    
     // Assume that we can retain this run loop forever.  It'll most 
     // likely (always?) be the main loop.
-    _runLoop = (CFRunLoopRef)CFRetain (CFRunLoopGetCurrent ());
+    _runLoop = (CFRunLoopRef)CFRetain (CFRunLoopGetCurrent());
 
     // Setup a source the other threads can use to signal the _runLoop
     // thread that a JavaScript call needs to be invoked.
index ce176f6491fc6696d83b6dafc65137d3c0d07606..57ab7c86c66f7c30fae5db48eb871e8acec17c69 100644 (file)
@@ -45,7 +45,6 @@ namespace Bindings {
 
 class RootObject;
 
-typedef PassRefPtr<RootObject> (*CreateRootObjectFunction)(void* nativeHandle);
 typedef HashCountedSet<JSObject*> ProtectCountSet;
 
 extern RootObject* findProtectingRootObject(JSObject*);
@@ -71,8 +70,7 @@ public:
 
 #if PLATFORM(MAC)
     // Must be called from the thread that will be used to access JavaScript.
-    static void setCreateRootObject(CreateRootObjectFunction);
-    static CreateRootObjectFunction createRootObject();
+    static void initializeJNIThreading();
     
     static CFRunLoopRef runLoop();
     static void dispatchToJavaScriptThread(JSObjectCallContext *context);
index cef8d1c88ec7beea8c4fce6f3e57fd950dec2d00..f97fea1caceadb79429f40455e9689562d6509a6 100644 (file)
@@ -586,8 +586,7 @@ KJS::Bindings::Instance* Frame::createScriptInstanceForWidget(WebCore::Widget* w
         return 0;
 
     void* nativeHandle = aView;
-    CreateRootObjectFunction createRootObject = RootObject::createRootObject();
-    RefPtr<RootObject> rootObject = createRootObject(nativeHandle);
+    RefPtr<RootObject> rootObject = createRootObject(nativeHandle, scriptProxy()->globalObject());
 
     if ([aView respondsToSelector:@selector(objectForWebScript)]) {
         id objectForWebScript = [aView objectForWebScript];
index 6741c4fc0480af9d1f5fe6f335f5855e9b22a03b..bd793cdfdb7a85319b5b54ea8eeed52c10aecc18 100644 (file)
@@ -121,17 +121,6 @@ using KJS::UnspecifiedType;
 
 using KJS::Bindings::RootObject;
 
-static PassRefPtr<RootObject> createRootObject(void* nativeHandle)
-{
-    NSView *view = (NSView *)nativeHandle;
-    WebCoreFrameBridge *bridge = [[WebCoreViewFactory sharedFactory] bridgeForView:view];
-    if (!bridge)
-        return 0;
-
-    Frame* frame = [bridge _frame];
-    return frame->createRootObject(nativeHandle, frame->scriptProxy()->globalObject());
-}
-
 static pthread_t mainThread = 0;
 
 static void updateRenderingForBindings(ExecState* exec, JSObject* rootObject)
@@ -252,7 +241,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
         initializedKJS = true;
 
         mainThread = pthread_self();
-        RootObject::setCreateRootObject(createRootObject);
+        RootObject::initializeJNIThreading();
         KJS::Bindings::Instance::setDidExecuteFunction(updateRenderingForBindings);
     }