Changeset 143637 in webkit


Ignore:
Timestamp:
Feb 21, 2013 12:00:33 PM (11 years ago)
Author:
mhahnenberg@apple.com
Message:

Objective-C API: Need a way to use the Objective-C JavaScript API with WebKit
https://bugs.webkit.org/show_bug.cgi?id=106059

Source/JavaScriptCore:

Reviewed by Geoffrey Garen.

  • API/JSBase.h: Renamed enable flag for API.
  • API/JSBlockAdaptor.h: Using new flag.
  • API/JSBlockAdaptor.mm: Ditto.
  • API/JSContext.h: Add convenience C API conversion function for JSGlobalContextRef.
  • API/JSContext.mm:

(-[JSContext JSGlobalContextRef]): Implementation of C API convenience function.
(-[JSContext initWithVirtualMachine:]): We don't use the m_apiData field any more.
(-[JSContext initWithGlobalContextRef:]): init method for allocating new JSContexts given a JSGlobalContextRef.
(-[JSContext dealloc]): No more m_apiData.
(-[JSContext wrapperForObjCObject:]): Renamed wrapperForObject.
(-[JSContext wrapperForJSObject:]): Fetches or allocates the JSValue for the specified JSValueRef in this JSContext.
(+[JSContext contextWithGlobalContextRef:]): Helper function to grab the lightweight JSContext wrapper for a given
JSGlobalContextRef from the global wrapper cache or allocate a new one if there isn't already one.

  • API/JSContextInternal.h: New flag, new method declaration for initWithGlobalContextRef.
  • API/JSExport.h: New flag.
  • API/JSValue.h: New flag and new C API convenience method.
  • API/JSValue.mm:

(-[JSValue JSValueRef]): Implementation of the C API convenience method.
(objectToValueWithoutCopy):
(+[JSValue valueWithValue:inContext:]): We now ask the JSContext for an Objective-C JSValue wrapper, which it can cache
in its internal JSWrapperMap.

  • API/JSValueInternal.h:
  • API/JSVirtualMachine.h:
  • API/JSVirtualMachine.mm: Added global cache that maps JSContextGroupRef -> JSVirtualMachine lightweight wrappers.

(wrapperCacheLock):
(initWrapperCache):
(+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]):
(+[JSVMWrapperCache wrapperForJSContextGroupRef:]):
(-[JSVirtualMachine init]):
(-[JSVirtualMachine initWithContextGroupRef:]):
(-[JSVirtualMachine dealloc]):
(+[JSVirtualMachine virtualMachineWithContextGroupRef:]):
(-[JSVirtualMachine contextForGlobalContextRef:]):
(-[JSVirtualMachine addContext:forGlobalContextRef:]):

  • API/JSVirtualMachineInternal.h:
  • API/JSWrapperMap.h:
  • API/JSWrapperMap.mm:

(-[JSObjCClassInfo allocateConstructorAndPrototypeWithSuperClassInfo:]): We use the JSObjectSetPrototype C API call because
setting the proto property causes all sorts of bad things to happen behind the scenes, which can cause crashes based on
when it gets called.
(-[JSWrapperMap initWithContext:]):
(-[JSWrapperMap jsWrapperForObject:]):
(-[JSWrapperMap objcWrapperForJSValueRef:]):

  • API/JavaScriptCore.h:
  • API/ObjCCallbackFunction.h:
  • API/ObjCCallbackFunction.mm:

(ObjCCallbackFunction::ObjCCallbackFunction): We never actually should have retained the target in the case that we had a
block as a callback. Blocks are initially allocated on the stack and are only moved to the heap if we call their copy method.
Retaining the block on the stack was a bad idea because if that stack frame ever went away and we called the block later,
we'd crash and burn.
(ObjCCallbackFunction::setContext): We need a new setter for when the weak reference to a JSContext inside an ObjCCallbackFunction
disappears, we can allocate a new one in its place.
(ObjCCallbackFunction):
(objCCallbackFunctionCallAsFunction): Reset the callback's context if it's ever destroyed.
(objCCallbackFunctionForInvocation): Again, don't set the proto property because it uses black magic that can cause us to crash
depending on when this is called.
(objCCallbackFunctionForBlock): Here is where we copy the block to the heap when we're first creating the callback object for it.

  • API/tests/testapi.c:

(main):

  • API/tests/testapi.mm: We're going to get rid of the automatic block conversion, since that is causing leaks. I changed it

here in this test just so that it wouldn't mask any other potential leaks. Also modified some of the tests since JSContexts are
just lightweight wrappers now, we're not guaranteed to get the same pointer back from the call to [JSValue context] as the one
that the value was created in.
(-[TestObject callback:]):

(JSC::JSGlobalData::JSGlobalData): No more m_apiData.

  • runtime/JSGlobalData.h: Ditto.
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::JSGlobalObject): Ditto.

  • runtime/JSGlobalObject.h:

Source/WebCore:

Reviewed by Geoffrey Garen.

  • WebCore.exp.in:
  • bindings/js/JSDOMWindowShell.cpp:

(WebCore::JSDOMWindowShell::setWindow): Since we're basically abandoning a JSDOMWindow here, we call
garbageCollectSoon().

  • bindings/js/JSDOMWindowShell.h:
  • bindings/js/ScriptController.h: New function to get the JSContext for the global object of the current main world.
  • bindings/js/ScriptControllerMac.mm:

(WebCore::ScriptController::javaScriptContext): Ditto.

  • bindings/objc/WebScriptObject.h: Added ifdef guards. Also new convenience conversion function for the JSC Obj-C API.
  • bindings/objc/WebScriptObject.mm: JSC::JSValue and JSValue conflict with one another, so we have to be more specific.

(-[WebScriptObject _globalContextRef]): Useful helper function for getting the JSGlobalContextRef of a particular WebScriptObject.
(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject evaluateWebScript:]):
(-[WebScriptObject valueForKey:]):
(-[WebScriptObject webScriptValueAtIndex:]):
(+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
(-[WebScriptObject JSValue]): Implementation of convenience WebScriptObject conversion function to new Objective-C API.

  • bindings/objc/WebScriptObjectPrivate.h:

Source/WebKit/mac:

Reviewed by Geoffrey Garen.

Addition of appropriate delegate callbacks and support to the WebKit API.

  • WebCoreSupport/WebFrameLoaderClient.mm:
  • WebView/WebDelegateImplementationCaching.h:

(WebFrameLoadDelegateImplementationCache):

  • WebView/WebFrame.h:
  • WebView/WebFrame.mm:

(-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
(-[WebFrame _javaScriptContextForScriptWorld:]):
(-[WebFrame javaScriptContext]):

  • WebView/WebFrameLoadDelegate.h:
  • WebView/WebFramePrivate.h:
  • WebView/WebScriptDebugDelegate.mm:

(-[WebScriptCallFrame _convertValueToObjcValue:JSC::]):
(-[WebScriptCallFrame exception]):
(-[WebScriptCallFrame evaluateWebScript:]):

  • WebView/WebScriptWorld.h:
  • WebView/WebScriptWorld.mm:

(+[WebScriptWorld scriptWorldForJavaScriptContext:]):

  • WebView/WebView.mm:

(-[WebView _cacheFrameLoadDelegateImplementations]):
(aeDescFromJSValue):
(-[WebView aeDescByEvaluatingJavaScriptFromString:]):
(-[WebView _computedStyleIncludingVisitedInfo:forElement:]):

Source/WTF:

Reviewed by Geoffrey Garen.

  • wtf/FeatureDefines.h: Added enable flag for JSC Objective-C API so it can be used in

export files.

Tools:

Reviewed by Geoffrey Garen.

Added new tests for the WebKit API portion of the JSC Objective-C API.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/mac/JSContextBackForwardCache1.html: Added.
  • TestWebKitAPI/Tests/mac/JSContextBackForwardCache2.html: Added.
  • TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm: Added.

(-[MyConsole log:]):
(-[MyConsole printHelloWorld]):
(-[MyConsole add:to:]):
(-[DidCreateJavaScriptContextFrameLoadDelegate webView:didFinishLoadForFrame:]):
(-[DidCreateJavaScriptContextFrameLoadDelegate webView:didCreateJavaScriptContext:forFrame:]):
(TestWebKitAPI):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
3 added
50 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSBase.h

    r139004 r143637  
    141141
    142142/* Enable the Objective-C API for platforms with a modern runtime. */
    143 #undef JS_OBJC_API_ENABLED
    144 #define JS_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 && !defined(__i386__))
     143#if !defined(JSC_OBJC_API_ENABLED)
     144#define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 && !defined(__i386__))
     145#endif
    145146
    146147#endif /* JSBase_h */
  • trunk/Source/JavaScriptCore/API/JSBlockAdaptor.h

    r142319 r143637  
    2626#import <JavaScriptCore/JavaScriptCore.h>
    2727
    28 #if JS_OBJC_API_ENABLED
     28#if JSC_OBJC_API_ENABLED
    2929
    3030@interface JSBlockAdaptor : NSObject
  • trunk/Source/JavaScriptCore/API/JSBlockAdaptor.mm

    r142319 r143637  
    2727#import "JavaScriptCore.h"
    2828
    29 #if JS_OBJC_API_ENABLED
     29#if JSC_OBJC_API_ENABLED
    3030
    3131#import "APICast.h"
  • trunk/Source/JavaScriptCore/API/JSContext.h

    r142319 r143637  
    2424 */
    2525
     26#ifndef JSContext_h
     27#define JSContext_h
     28
    2629#include <JavaScriptCore/JavaScript.h>
    2730
    28 #if JS_OBJC_API_ENABLED
     31#if JSC_OBJC_API_ENABLED
    2932
    3033@class JSVirtualMachine, JSValue;
     
    4952// Evaluate a string of JavaScript code.
    5053- (JSValue *)evaluateScript:(NSString *)script;
     54
     55// Return the C API version of this context. This function is for convenience
     56// at the boundaries when converting code from the C API to the Objective-C API.
     57- (JSGlobalContextRef)globalContextRef;
    5158
    5259// This method retrieves the global object of the JavaScript execution context.
     
    115122
    116123#endif
     124
     125#endif // JSContext_h
  • trunk/Source/JavaScriptCore/API/JSContext.mm

    r141490 r143637  
    3838#import <wtf/HashSet.h>
    3939
    40 #if JS_OBJC_API_ENABLED
     40#if JSC_OBJC_API_ENABLED
    4141
    4242@implementation JSContext {
     
    4949@synthesize exceptionHandler;
    5050
     51- (JSGlobalContextRef)globalContextRef
     52{
     53    return m_context;
     54}
     55
    5156- (id)init
    5257{
     
    6873    };
    6974
    70     toJS(m_context)->lexicalGlobalObject()->m_apiData = self;
    7175    return self;
    7276}
     
    168172@implementation JSContext(Internal)
    169173
     174- (id)initWithGlobalContextRef:(JSGlobalContextRef)context
     175{
     176    self = [super init];
     177    if (!self)
     178        return nil;
     179
     180    JSC::JSGlobalObject* globalObject = toJS(context)->lexicalGlobalObject();
     181    m_virtualMachine = [[JSVirtualMachine virtualMachineWithContextGroupRef:toRef(&globalObject->globalData())] retain];
     182    ASSERT(m_virtualMachine);
     183    m_context = JSGlobalContextRetain(context);
     184    m_wrapperMap = [[JSWrapperMap alloc] initWithContext:self];
     185
     186    self.exceptionHandler = ^(JSContext *context, JSValue *exceptionValue) {
     187        context.exception = exceptionValue;
     188    };
     189
     190    return self;
     191}
     192
    170193JSGlobalContextRef contextInternalContext(JSContext *context)
    171194{
     
    175198- (void)dealloc
    176199{
    177     toJS(m_context)->lexicalGlobalObject()->m_apiData = 0;
    178200    [m_wrapperMap release];
    179201    JSGlobalContextRelease(m_context);
     
    221243}
    222244
    223 - (JSValue *)wrapperForObject:(id)object
     245- (JSValue *)wrapperForObjCObject:(id)object
    224246{
    225247    // Lock access to m_wrapperMap
    226248    JSC::JSLockHolder lock(toJS(m_context));
    227     return [m_wrapperMap wrapperForObject:object];
     249    return [m_wrapperMap jsWrapperForObject:object];
     250}
     251
     252- (JSValue *)wrapperForJSObject:(JSValueRef)value
     253{
     254    JSC::JSLockHolder lock(toJS(m_context));
     255    return [m_wrapperMap objcWrapperForJSValueRef:value];
     256}
     257
     258+ (JSContext *)contextWithGlobalContextRef:(JSGlobalContextRef)globalContext
     259{
     260    JSVirtualMachine *virtualMachine = [JSVirtualMachine virtualMachineWithContextGroupRef:toRef(&toJS(globalContext)->globalData())];
     261    JSContext *context = [virtualMachine contextForGlobalContextRef:globalContext];
     262    if (!context) {
     263        context = [[[JSContext alloc] initWithGlobalContextRef:globalContext] autorelease];
     264        [virtualMachine addContext:context forGlobalContextRef:globalContext];
     265    }
     266    return context;
    228267}
    229268
  • trunk/Source/JavaScriptCore/API/JSContextInternal.h

    r141176 r143637  
    2424 */
    2525
     26#ifndef JSContextInternal_h
     27#define JSContextInternal_h
     28
    2629#import <JavaScriptCore/JavaScriptCore.h>
    2730
    28 #if JS_OBJC_API_ENABLED
     31#if JSC_OBJC_API_ENABLED
    2932
    30 #import "JSContext.h"
     33#import <JavaScriptCore/JSContext.h>
    3134
    3235struct CallbackData {
     
    5760@interface JSContext(Internal)
    5861
    59 JSGlobalContextRef contextInternalContext(JSContext *);
     62- (id)initWithGlobalContextRef:(JSGlobalContextRef)context;
     63
     64JS_EXPORT_PRIVATE JSGlobalContextRef contextInternalContext(JSContext *);
    6065
    6166- (void)notifyException:(JSValueRef)exception;
     
    6671- (void)endCallbackWithData:(CallbackData *)callbackData;
    6772
    68 - (JSValue *)wrapperForObject:(id)object;
     73- (JSValue *)wrapperForObjCObject:(id)object;
     74- (JSValue *)wrapperForJSObject:(JSValueRef)value;
     75
     76+ (JSContext *)contextWithGlobalContextRef:(JSGlobalContextRef)globalContext;
    6977
    7078@property (readonly, retain) JSWrapperMap *wrapperMap;
     
    7381
    7482#endif
     83
     84#endif // JSContextInternal_h
  • trunk/Source/JavaScriptCore/API/JSExport.h

    r142319 r143637  
    2626#import <JavaScriptCore/JavaScriptCore.h>
    2727
    28 #if JS_OBJC_API_ENABLED
     28#if JSC_OBJC_API_ENABLED
    2929
    3030// When a JavaScript value is created from an instance of an Objective-C class
  • trunk/Source/JavaScriptCore/API/JSValue.h

    r142319 r143637  
    2424 */
    2525
    26 #if JS_OBJC_API_ENABLED
     26#ifndef JSValue_h
     27#define JSValue_h
     28
     29#if JSC_OBJC_API_ENABLED
    2730
    2831@class JSContext;
     
    102105+ (JSValue *)valueWithNullInContext:(JSContext *)context;
    103106+ (JSValue *)valueWithUndefinedInContext:(JSContext *)context;
     107
     108// Return the C API version of this value. This function is for convenience
     109// at the boundaries when converting code from the C API to the Objective-C API.
     110- (JSValueRef)JSValueRef;
    104111
    105112// Convert this value to a corresponding Objective-C object, according to the
     
    293300#endif
    294301
     302#endif // JSValue_h
  • trunk/Source/JavaScriptCore/API/JSValue.mm

    r142319 r143637  
    2525
    2626#include "config.h"
    27 //#import "JSValue.h"
    2827
    2928#import "APICast.h"
     
    4645#import <wtf/text/StringHash.h>
    4746
    48 #if JS_OBJC_API_ENABLED
     47#if JSC_OBJC_API_ENABLED
    4948
    5049NSString * const JSPropertyDescriptorWritableKey = @"writable";
     
    5756@implementation JSValue {
    5857    JSValueRef m_value;
     58}
     59
     60- (JSValueRef)JSValueRef
     61{
     62    return m_value;
    5963}
    6064
     
    891895    }
    892896
    893     return (ObjcContainerConvertor::Task){ object, valueInternalValue([context wrapperForObject:object]), ContainerNone };
     897    return (ObjcContainerConvertor::Task){ object, valueInternalValue([context wrapperForObjCObject:object]), ContainerNone };
    894898}
    895899
     
    942946+ (JSValue *)valueWithValue:(JSValueRef)value inContext:(JSContext *)context
    943947{
    944     return [[[JSValue alloc] initWithValue:value inContext:context] autorelease];
     948    return [context wrapperForJSObject:value];
    945949}
    946950
  • trunk/Source/JavaScriptCore/API/JSValueInternal.h

    r140718 r143637  
    2424 */
    2525
     26#ifndef JSValueInternal_h
     27#define JSValueInternal_h
     28
    2629#import <JavaScriptCore/JavaScriptCore.h>
    27 #import "JSValue.h"
     30#import <JavaScriptCore/JSValue.h>
    2831
    29 #if JS_OBJC_API_ENABLED
     32#if JSC_OBJC_API_ENABLED
    3033
    3134@interface JSValue(Internal)
     
    5356
    5457#endif
     58
     59#endif // JSValueInternal_h
  • trunk/Source/JavaScriptCore/API/JSVirtualMachine.h

    r138664 r143637  
    2626#import <JavaScriptCore/JavaScriptCore.h>
    2727
    28 #if JS_OBJC_API_ENABLED
     28#if JSC_OBJC_API_ENABLED
    2929
    3030// An instance of JSVirtualMachine represents a single JavaScript "object space"
  • trunk/Source/JavaScriptCore/API/JSVirtualMachine.mm

    r138664 r143637  
    2828#import "JavaScriptCore.h"
    2929
    30 #if JS_OBJC_API_ENABLED
     30#if JSC_OBJC_API_ENABLED
    3131
    3232#import "APICast.h"
    3333#import "JSVirtualMachineInternal.h"
    3434
     35static NSMapTable *globalWrapperCache = 0;
     36
     37static Mutex& wrapperCacheLock()
     38{
     39    DEFINE_STATIC_LOCAL(Mutex, mutex, ());
     40    return mutex;
     41}
     42
     43static void initWrapperCache()
     44{
     45    ASSERT(!globalWrapperCache);
     46    NSPointerFunctionsOptions keyOptions = NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality;
     47    NSPointerFunctionsOptions valueOptions = NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality;
     48    globalWrapperCache = [[NSMapTable alloc] initWithKeyOptions:keyOptions valueOptions:valueOptions capacity:0];
     49}
     50
     51static NSMapTable *wrapperCache()
     52{
     53    if (!globalWrapperCache)
     54        initWrapperCache();
     55    return globalWrapperCache;
     56}
     57
     58@interface JSVMWrapperCache : NSObject
     59+ (void)addWrapper:(JSVirtualMachine *)wrapper forJSContextGroupRef:(JSContextGroupRef)group;
     60+ (JSVirtualMachine *)wrapperForJSContextGroupRef:(JSContextGroupRef)group;
     61@end
     62
     63@implementation JSVMWrapperCache
     64
     65+ (void)addWrapper:(JSVirtualMachine *)wrapper forJSContextGroupRef:(JSContextGroupRef)group
     66{
     67    MutexLocker locker(wrapperCacheLock());
     68    NSMapInsert(wrapperCache(), group, wrapper);
     69}
     70
     71+ (JSVirtualMachine *)wrapperForJSContextGroupRef:(JSContextGroupRef)group
     72{
     73    MutexLocker locker(wrapperCacheLock());
     74    return static_cast<JSVirtualMachine *>(NSMapGet(wrapperCache(), group));
     75}
     76
     77@end
     78
    3579@implementation JSVirtualMachine {
    3680    JSContextGroupRef m_group;
     81    NSMapTable *m_contextCache;
    3782}
    3883
    3984- (id)init
    4085{
     86    JSContextGroupRef group = JSContextGroupCreate();
     87    self = [self initWithContextGroupRef:group];
     88    // The extra JSContextGroupRetain is balanced here.
     89    JSContextGroupRelease(group);
     90    return self;
     91}
     92
     93- (id)initWithContextGroupRef:(JSContextGroupRef)group
     94{
    4195    self = [super init];
    4296    if (!self)
    4397        return nil;
    44 
    45     m_group = JSContextGroupCreate();
    46     toJS(m_group)->m_apiData = self;
     98   
     99    m_group = JSContextGroupRetain(group);
     100   
     101    NSPointerFunctionsOptions keyOptions = NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality;
     102    NSPointerFunctionsOptions valueOptions = NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality;
     103    m_contextCache = [[NSMapTable alloc] initWithKeyOptions:keyOptions valueOptions:valueOptions capacity:0];
     104   
    47105    return self;
    48106}
     
    54112- (void)dealloc
    55113{
    56     toJS(m_group)->m_apiData = 0;
    57114    JSContextGroupRelease(m_group);
    58115    [super dealloc];
     
    64121}
    65122
     123+ (JSVirtualMachine *)virtualMachineWithContextGroupRef:(JSContextGroupRef)group
     124{
     125    JSVirtualMachine *virtualMachine = [JSVMWrapperCache wrapperForJSContextGroupRef:group];
     126    if (!virtualMachine) {
     127        virtualMachine = [[[JSVirtualMachine alloc] initWithContextGroupRef:group] autorelease];
     128        [JSVMWrapperCache addWrapper:virtualMachine forJSContextGroupRef:group];
     129    }
     130    return virtualMachine;
     131}
     132
     133- (JSContext *)contextForGlobalContextRef:(JSGlobalContextRef)globalContext
     134{
     135    return static_cast<JSContext *>(NSMapGet(m_contextCache, globalContext));
     136}
     137
     138- (void)addContext:(JSContext *)wrapper forGlobalContextRef:(JSGlobalContextRef)globalContext
     139{
     140    NSMapInsert(m_contextCache, globalContext, wrapper);
     141}
     142
    66143@end
     144
    67145
    68146#endif
  • trunk/Source/JavaScriptCore/API/JSVirtualMachineInternal.h

    r138689 r143637  
    2424 */
    2525
    26 #import "JSVirtualMachine.h"
     26#ifndef JSVirtualMachineInternal_h
     27#define JSVirtualMachineInternal_h
     28
     29#import <JavaScriptCore/JSVirtualMachine.h>
    2730#import <JavaScriptCore/JavaScriptCore.h>
    2831
    29 #if JS_OBJC_API_ENABLED
     32#if JSC_OBJC_API_ENABLED
    3033
    3134@interface JSVirtualMachine(Internal)
     
    3336JSContextGroupRef getGroupFromVirtualMachine(JSVirtualMachine *);
    3437
     38+ (JSVirtualMachine *)virtualMachineWithContextGroupRef:(JSContextGroupRef)group;
     39
     40- (JSContext *)contextForGlobalContextRef:(JSGlobalContextRef)globalContext;
     41- (void)addContext:(JSContext *)wrapper forGlobalContextRef:(JSGlobalContextRef)globalContext;
     42
    3543@end
    3644
    3745#endif
     46
     47#endif // JSVirtualMachineInternal_h
  • trunk/Source/JavaScriptCore/API/JSWrapperMap.h

    r138689 r143637  
    2828#import <objc/objc-runtime.h>
    2929
    30 #if JS_OBJC_API_ENABLED
     30#if JSC_OBJC_API_ENABLED
    3131
    3232@interface JSWrapperMap : NSObject
     
    3434- (id)initWithContext:(JSContext *)context;
    3535
    36 - (JSValue *)wrapperForObject:(id)object;
     36- (JSValue *)jsWrapperForObject:(id)object;
     37
     38- (JSValue *)objcWrapperForJSValueRef:(JSValueRef)value;
    3739
    3840@end
  • trunk/Source/JavaScriptCore/API/JSWrapperMap.mm

    r142319 r143637  
    2727#import "JavaScriptCore.h"
    2828
    29 #if JS_OBJC_API_ENABLED
     29#if JSC_OBJC_API_ENABLED
    3030
    3131#import "APICast.h"
     
    383383
    384384        // Set [Prototype].
    385         prototype[@"__proto__"] = [JSValue valueWithValue:toRef(superClassInfo->m_prototype.get()) inContext:m_context];
     385        JSObjectSetPrototype(contextInternalContext(m_context), toRef(m_prototype.get()), toRef(superClassInfo->m_prototype.get()));
    386386
    387387        [constructor release];
     
    426426    JSContext *m_context;
    427427    NSMutableDictionary *m_classMap;
    428     JSC::WeakGCMap<id, JSC::JSObject> m_cachedWrappers;
     428    JSC::WeakGCMap<id, JSC::JSObject> m_cachedJSWrappers;
     429    NSMapTable *m_cachedObjCWrappers;
    429430}
    430431
     
    435436        return nil;
    436437
     438    NSPointerFunctionsOptions keyOptions = NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality;
     439    NSPointerFunctionsOptions valueOptions = NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality;
     440    m_cachedObjCWrappers = [[NSMapTable alloc] initWithKeyOptions:keyOptions valueOptions:valueOptions capacity:0];
     441   
    437442    m_context = context;
    438443    m_classMap = [[NSMutableDictionary alloc] init];
     
    462467}
    463468
    464 - (JSValue *)wrapperForObject:(id)object
    465 {
    466     JSC::JSObject* jsWrapper = m_cachedWrappers.get(object);
     469- (JSValue *)jsWrapperForObject:(id)object
     470{
     471    JSC::JSObject* jsWrapper = m_cachedJSWrappers.get(object);
    467472    if (jsWrapper)
    468473        return [JSValue valueWithValue:toRef(jsWrapper) inContext:m_context];
     
    483488    JSC::ExecState* exec = toJS(contextInternalContext(m_context));
    484489    jsWrapper = toJS(exec, valueInternalValue(wrapper)).toObject(exec);
    485     m_cachedWrappers.set(object, jsWrapper);
     490    m_cachedJSWrappers.set(object, jsWrapper);
     491    return wrapper;
     492}
     493
     494- (JSValue *)objcWrapperForJSValueRef:(JSValueRef)value
     495{
     496    JSValue *wrapper = static_cast<JSValue *>(NSMapGet(m_cachedObjCWrappers, value));
     497    if (!wrapper) {
     498        wrapper = [[[JSValue alloc] initWithValue:value inContext:m_context] autorelease];
     499        NSMapInsert(m_cachedObjCWrappers, value, wrapper);
     500    }
    486501    return wrapper;
    487502}
  • trunk/Source/JavaScriptCore/API/JavaScriptCore.h

    r140718 r143637  
    3030#include <JavaScriptCore/JSStringRefCF.h>
    3131
    32 #if defined(__OBJC__) && JS_OBJC_API_ENABLED
     32#if defined(__OBJC__) && JSC_OBJC_API_ENABLED
    3333
    3434#import "JSContext.h"
  • trunk/Source/JavaScriptCore/API/ObjCCallbackFunction.h

    r138689 r143637  
    2626#import <JavaScriptCore/JavaScriptCore.h>
    2727
    28 #if JS_OBJC_API_ENABLED
     28#if JSC_OBJC_API_ENABLED
    2929
    3030JSObjectRef objCCallbackFunctionForMethod(JSContext *, Class, Protocol *, BOOL isInstanceMethod, SEL, const char* types);
  • trunk/Source/JavaScriptCore/API/ObjCCallbackFunction.mm

    r141805 r143637  
    2727#import "JavaScriptCore.h"
    2828
    29 #if JS_OBJC_API_ENABLED
     29#if JSC_OBJC_API_ENABLED
    3030
    3131#import "APICast.h"
     
    3333#import "Error.h"
    3434#import "JSBlockAdaptor.h"
     35#import "JSCJSValueInlines.h"
     36#import "JSCell.h"
     37#import "JSCellInlines.h"
    3538#import "JSContextInternal.h"
    3639#import "JSWrapperMap.h"
     
    427430    {
    428431        ASSERT(type != CallbackInstanceMethod || instanceClass);
    429         if (m_type != CallbackInstanceMethod)
    430             [[m_invocation.get() target] retain];
    431432    }
    432433
     
    443444    {
    444445        return m_context.get();
     446    }
     447
     448    void setContext(JSContext *context)
     449    {
     450        ASSERT(!m_context.get());
     451        m_context.set(context);
    445452    }
    446453
     
    475482    JSContext *context = callback->context();
    476483    if (!context) {
    477         // FIXME: https://bugs.webkit.org/show_bug.cgi?id=105894
    478         // Rather than requiring that the context be retained, it would probably be more
    479         // appropriate to use a new JSContext instance (creating one if necessary).
    480         *exception = toRef(JSC::createTypeError(toJS(callerContext), "Objective-C callback function context released"));
    481         return JSValueMakeUndefined(callerContext);
     484        context = [JSContext contextWithGlobalContextRef:toGlobalRef(toJS(callerContext)->lexicalGlobalObject()->globalExec())];
     485        callback->setContext(context);
    482486    }
    483487
     
    611615    JSValue *value = [JSValue valueWithValue:functionObject inContext:context];
    612616    value[@"length"] = @(argumentCount);
    613     value[@"__proto__"] = context[@"Function"][@"prototype"];
     617    JSObjectSetPrototype(contextInternalContext(context), functionObject, valueInternalValue(context[@"Function"][@"prototype"]));
    614618    value[@"toString"] = [context evaluateScript:@"(function(){ return '"
    615619        "function <Objective-C>() {" "\\n"
     
    635639    const char* signature = _Block_signature(target);
    636640    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[NSMethodSignature signatureWithObjCTypes:signature]];
    637     [invocation setTarget:target];
     641    [invocation setTarget:[target copy]];
    638642    return objCCallbackFunctionForInvocation(context, invocation, CallbackBlock, nil, signature);
    639643}
  • trunk/Source/JavaScriptCore/API/tests/testapi.c

    r142838 r143637  
    5252#endif
    5353
    54 #if JS_OBJC_API_ENABLED
     54#if JSC_OBJC_API_ENABLED
    5555void testObjectiveCAPI(void);
    5656#endif
     
    10481048#endif
    10491049
    1050 #if JS_OBJC_API_ENABLED
     1050#if JSC_OBJC_API_ENABLED
    10511051    testObjectiveCAPI();
    10521052#endif
  • trunk/Source/JavaScriptCore/API/tests/testapi.mm

    r141914 r143637  
    3232extern "C" void testObjectiveCAPI(void);
    3333
    34 #if JS_OBJC_API_ENABLED
     34#if JSC_OBJC_API_ENABLED
    3535
    3636@protocol ParentObject <JSExport>
     
    5858- (NSString *)testArgumentTypesWithInt:(int)i double:(double)d boolean:(BOOL)b string:(NSString *)s number:(NSNumber *)n array:(NSArray *)a dictionary:(NSDictionary *)o
    5959);
    60 - (void)callback:(void(^)(int))block;
     60- (void)callback:(JSValue *)function;
    6161@end
    6262
     
    8686    return [NSString stringWithFormat:@"%d,%g,%d,%@,%d,%@,%@", i, d, b==YES?true:false,s,[n intValue],a[1],o[@"x"]];
    8787}
    88 - (void)callback:(void(^)(int))block
    89 {
    90     block(42);
     88- (void)callback:(JSValue *)function
     89{
     90    [function callWithArguments:[NSArray arrayWithObject:[NSNumber numberWithInt:42]]];
    9191}
    9292@end
     
    483483        JSContext *context2 = [[JSContext alloc] initWithVirtualMachine:context1.virtualMachine];
    484484        JSValue *value = [JSValue valueWithDouble:42 inContext:context2];
    485         checkResult(@"value.context == context2", value.context == context2);
    486485        context1[@"passValueBetweenContexts"] = value;
    487486        JSValue *result = [context1 evaluateScript:@"passValueBetweenContexts"];
    488         checkResult(@"result.context == context1", result.context == context1);
    489487        checkResult(@"[value isEqualToObject:result]", [value isEqualToObject:result]);
    490488    }
  • trunk/Source/JavaScriptCore/ChangeLog

    r143562 r143637  
     12013-02-20  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Objective-C API: Need a way to use the Objective-C JavaScript API with WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=106059
     5
     6        Reviewed by Geoffrey Garen.
     7       
     8        * API/JSBase.h: Renamed enable flag for API.
     9        * API/JSBlockAdaptor.h: Using new flag.
     10        * API/JSBlockAdaptor.mm: Ditto.
     11        * API/JSContext.h: Add convenience C API conversion function for JSGlobalContextRef.
     12        * API/JSContext.mm:
     13        (-[JSContext JSGlobalContextRef]): Implementation of C API convenience function.
     14        (-[JSContext initWithVirtualMachine:]): We don't use the m_apiData field any more.
     15        (-[JSContext initWithGlobalContextRef:]): init method for allocating new JSContexts given a JSGlobalContextRef.
     16        (-[JSContext dealloc]): No more m_apiData.
     17        (-[JSContext wrapperForObjCObject:]): Renamed wrapperForObject.
     18        (-[JSContext wrapperForJSObject:]): Fetches or allocates the JSValue for the specified JSValueRef in this JSContext.
     19        (+[JSContext contextWithGlobalContextRef:]): Helper function to grab the lightweight JSContext wrapper for a given
     20        JSGlobalContextRef from the global wrapper cache or allocate a new one if there isn't already one.
     21        * API/JSContextInternal.h: New flag, new method declaration for initWithGlobalContextRef.
     22        * API/JSExport.h: New flag.
     23        * API/JSValue.h: New flag and new C API convenience method.
     24        * API/JSValue.mm:
     25        (-[JSValue JSValueRef]): Implementation of the C API convenience method.
     26        (objectToValueWithoutCopy):
     27        (+[JSValue valueWithValue:inContext:]): We now ask the JSContext for an Objective-C JSValue wrapper, which it can cache
     28        in its internal JSWrapperMap.
     29        * API/JSValueInternal.h:
     30        * API/JSVirtualMachine.h:
     31        * API/JSVirtualMachine.mm: Added global cache that maps JSContextGroupRef -> JSVirtualMachine lightweight wrappers.
     32        (wrapperCacheLock):
     33        (initWrapperCache):
     34        (+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]):
     35        (+[JSVMWrapperCache wrapperForJSContextGroupRef:]):
     36        (-[JSVirtualMachine init]):
     37        (-[JSVirtualMachine initWithContextGroupRef:]):
     38        (-[JSVirtualMachine dealloc]):
     39        (+[JSVirtualMachine virtualMachineWithContextGroupRef:]):
     40        (-[JSVirtualMachine contextForGlobalContextRef:]):
     41        (-[JSVirtualMachine addContext:forGlobalContextRef:]):
     42        * API/JSVirtualMachineInternal.h:
     43        * API/JSWrapperMap.h:
     44        * API/JSWrapperMap.mm:
     45        (-[JSObjCClassInfo allocateConstructorAndPrototypeWithSuperClassInfo:]): We use the JSObjectSetPrototype C API call because
     46        setting the __proto__ property causes all sorts of bad things to happen behind the scenes, which can cause crashes based on
     47        when it gets called.
     48        (-[JSWrapperMap initWithContext:]):
     49        (-[JSWrapperMap jsWrapperForObject:]):
     50        (-[JSWrapperMap objcWrapperForJSValueRef:]):
     51        * API/JavaScriptCore.h:
     52        * API/ObjCCallbackFunction.h:
     53        * API/ObjCCallbackFunction.mm:
     54        (ObjCCallbackFunction::ObjCCallbackFunction): We never actually should have retained the target in the case that we had a
     55        block as a callback. Blocks are initially allocated on the stack and are only moved to the heap if we call their copy method.
     56        Retaining the block on the stack was a bad idea because if that stack frame ever went away and we called the block later,
     57        we'd crash and burn.
     58        (ObjCCallbackFunction::setContext): We need a new setter for when the weak reference to a JSContext inside an ObjCCallbackFunction
     59        disappears, we can allocate a new one in its place.
     60        (ObjCCallbackFunction):
     61        (objCCallbackFunctionCallAsFunction): Reset the callback's context if it's ever destroyed.
     62        (objCCallbackFunctionForInvocation): Again, don't set the __proto__ property because it uses black magic that can cause us to crash
     63        depending on when this is called.
     64        (objCCallbackFunctionForBlock): Here is where we copy the block to the heap when we're first creating the callback object for it.
     65        * API/tests/testapi.c:
     66        (main):
     67        * API/tests/testapi.mm: We're going to get rid of the automatic block conversion, since that is causing leaks. I changed it
     68        here in this test just so that it wouldn't mask any other potential leaks. Also modified some of the tests since JSContexts are
     69        just lightweight wrappers now, we're not guaranteed to get the same pointer back from the call to [JSValue context] as the one
     70        that the value was created in.
     71        (-[TestObject callback:]):
     72        * JavaScriptCore.xcodeproj/project.pbxproj:
     73        * runtime/JSGlobalData.cpp:
     74        (JSC::JSGlobalData::JSGlobalData): No more m_apiData.
     75        * runtime/JSGlobalData.h: Ditto.
     76        * runtime/JSGlobalObject.cpp:
     77        (JSC::JSGlobalObject::JSGlobalObject): Ditto.
     78        * runtime/JSGlobalObject.h:
     79
    1802013-02-19  Filip Pizlo  <fpizlo@apple.com>
    281
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r143392 r143637  
    589589                86E3C615167BABD7006D760A /* JSVirtualMachine.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C60F167BAB87006D760A /* JSVirtualMachine.h */; settings = {ATTRIBUTES = (Public, ); }; };
    590590                86E3C616167BABEE006D760A /* JSContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86E3C608167BAB87006D760A /* JSContext.mm */; };
    591                 86E3C617167BABEE006D760A /* JSContextInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C609167BAB87006D760A /* JSContextInternal.h */; };
     591                86E3C617167BABEE006D760A /* JSContextInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C609167BAB87006D760A /* JSContextInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
    592592                86E3C618167BABEE006D760A /* JSWrapperMap.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86E3C60B167BAB87006D760A /* JSWrapperMap.mm */; };
    593593                86E3C619167BABEE006D760A /* JSWrapperMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C60C167BAB87006D760A /* JSWrapperMap.h */; };
    594594                86E3C61A167BABEE006D760A /* JSValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86E3C60D167BAB87006D760A /* JSValue.mm */; };
    595                 86E3C61B167BABEE006D760A /* JSValueInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C60E167BAB87006D760A /* JSValueInternal.h */; };
     595                86E3C61B167BABEE006D760A /* JSValueInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C60E167BAB87006D760A /* JSValueInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
    596596                86E3C61C167BABEE006D760A /* JSVirtualMachine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86E3C610167BAB87006D760A /* JSVirtualMachine.mm */; };
    597                 86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C611167BAB87006D760A /* JSVirtualMachineInternal.h */; };
     597                86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C611167BAB87006D760A /* JSVirtualMachineInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
    598598                86E85539111B9968001AF51E /* JSStringBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E85538111B9968001AF51E /* JSStringBuilder.h */; };
    599599                86EBF2FF1560F06A008E9222 /* NameConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EBF2F91560F036008E9222 /* NameConstructor.cpp */; };
     
    29292929                                0F63945515D07057006A597C /* ArrayProfile.h in Headers */,
    29302930                                BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */,
     2931                                86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */,
    29312932                                BC18C5240E16FC8A00B34460 /* ArrayPrototype.lut.h in Headers */,
     2933                                86E3C617167BABEE006D760A /* JSContextInternal.h in Headers */,
     2934                                86E3C61B167BABEE006D760A /* JSValueInternal.h in Headers */,
    29322935                                0FB7F39615ED8E4600F167B2 /* ArrayStorage.h in Headers */,
    29332936                                9688CB150ED12B4E001D649F /* AssemblerBuffer.h in Headers */,
     
    31263129                                BC18C41D0E16F5CD00B34460 /* JSClassRef.h in Headers */,
    31273130                                86E3C613167BABD7006D760A /* JSContext.h in Headers */,
    3128                                 86E3C617167BABEE006D760A /* JSContextInternal.h in Headers */,
    31293131                                BC18C41E0E16F5CD00B34460 /* JSContextRef.h in Headers */,
    31303132                                148CD1D8108CF902008163C6 /* JSContextRefPrivate.h in Headers */,
     
    31613163                                6507D29E0E871E5E00D7D896 /* JSTypeInfo.h in Headers */,
    31623164                                86E3C612167BABD7006D760A /* JSValue.h in Headers */,
    3163                                 86E3C61B167BABEE006D760A /* JSValueInternal.h in Headers */,
    31643165                                BC18C42C0E16F5CD00B34460 /* JSValueRef.h in Headers */,
    31653166                                BC18C42D0E16F5CD00B34460 /* JSVariableObject.h in Headers */,
    31663167                                86E3C615167BABD7006D760A /* JSVirtualMachine.h in Headers */,
    3167                                 86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */,
    31683168                                A7482E93116A7CAD003B0712 /* JSWeakObjectMapRefInternal.h in Headers */,
    31693169                                A7482B9311671147003B0712 /* JSWeakObjectMapRefPrivate.h in Headers */,
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r143279 r143637  
    188188#endif
    189189    , m_newStringsSinceLastHashConst(0)
    190     , m_apiData(0)
    191190#if ENABLE(ASSEMBLER)
    192191    , m_canUseAssembler(enableAssembler(executableAllocator))
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r143279 r143637  
    480480        JS_EXPORT_PRIVATE void discardAllCode();
    481481
    482         void *m_apiData;
    483 
    484482    private:
    485483        friend class LLIntOffsetsExtractor;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r143147 r143637  
    117117    , m_evalEnabled(true)
    118118    , m_globalObjectMethodTable(globalObjectMethodTable ? globalObjectMethodTable : &s_globalObjectMethodTable)
    119     , m_apiData(0)
    120119{
    121120}
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r143171 r143637  
    197197    bool hasProfiler() const { return globalObjectMethodTable()->supportsProfiling(this); }
    198198
    199     void* m_apiData;
    200 
    201199protected:
    202200    JS_EXPORT_PRIVATE explicit JSGlobalObject(JSGlobalData&, Structure*, const GlobalObjectMethodTable* = 0);
  • trunk/Source/WTF/ChangeLog

    r143618 r143637  
     12013-02-19  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Objective-C API: Need a way to use the Objective-C JavaScript API with WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=106059
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * wtf/FeatureDefines.h: Added enable flag for JSC Objective-C API so it can be used in
     9        export files.
     10
    1112013-02-21  Martin Robinson  <mrobinson@igalia.com>
    212
  • trunk/Source/WTF/wtf/FeatureDefines.h

    r143505 r143637  
    567567#endif
    568568
     569#if !defined(JSC_OBJC_API_ENABLED)
     570#define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 && !defined(__i386__))
     571#endif
     572
    569573#if !defined(ENABLE_LEGACY_CSS_VENDOR_PREFIXES)
    570574#define ENABLE_LEGACY_CSS_VENDOR_PREFIXES 0
  • trunk/Source/WebCore/ChangeLog

    r143636 r143637  
     12013-02-19  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Objective-C API: Need a way to use the Objective-C JavaScript API with WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=106059
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * WebCore.exp.in:
     9        * bindings/js/JSDOMWindowShell.cpp:
     10        (WebCore::JSDOMWindowShell::setWindow): Since we're basically abandoning a JSDOMWindow here, we call
     11        garbageCollectSoon().
     12        * bindings/js/JSDOMWindowShell.h:
     13        * bindings/js/ScriptController.h: New function to get the JSContext for the global object of the current main world.
     14        * bindings/js/ScriptControllerMac.mm:
     15        (WebCore::ScriptController::javaScriptContext): Ditto.
     16        * bindings/objc/WebScriptObject.h: Added ifdef guards. Also new convenience conversion function for the JSC Obj-C API.
     17        * bindings/objc/WebScriptObject.mm: JSC::JSValue and JSValue conflict with one another, so we have to be more specific.
     18        (-[WebScriptObject _globalContextRef]): Useful helper function for getting the JSGlobalContextRef of a particular WebScriptObject.
     19        (-[WebScriptObject callWebScriptMethod:withArguments:]):
     20        (-[WebScriptObject evaluateWebScript:]):
     21        (-[WebScriptObject valueForKey:]):
     22        (-[WebScriptObject webScriptValueAtIndex:]):
     23        (+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
     24        (-[WebScriptObject JSValue]): Implementation of convenience WebScriptObject conversion function to new Objective-C API.
     25        * bindings/objc/WebScriptObjectPrivate.h:
     26
    1272013-02-21  Kentaro Hara  <haraken@chromium.org>
    228
  • trunk/Source/WebCore/WebCore.exp.in

    r143428 r143637  
    502502__ZN7WebCore16ScriptController13executeScriptERKN3WTF6StringEb
    503503__ZN7WebCore16ScriptController17canExecuteScriptsENS_33ReasonForCallingCanExecuteScriptsE
     504#if JSC_OBJC_API_ENABLED
     505__ZN7WebCore16ScriptController17javaScriptContextEv
     506#endif
    504507__ZN7WebCore16ScriptController18windowScriptObjectEv
    505508__ZN7WebCore16ScriptController20executeScriptInWorldEPNS_15DOMWrapperWorldERKN3WTF6StringEb
  • trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp

    r131088 r143637  
    3131
    3232#include "Frame.h"
     33#include "GCController.h"
    3334#include "JSDOMWindow.h"
    3435#include "DOMWindow.h"
     
    5960{
    6061    static_cast<JSDOMWindowShell*>(cell)->JSDOMWindowShell::~JSDOMWindowShell();
     62}
     63
     64void JSDOMWindowShell::setWindow(JSC::JSGlobalData& globalData, JSDOMWindow* window)
     65{
     66    ASSERT_ARG(window, window);
     67    setTarget(globalData, window);
     68    structure()->setGlobalObject(*JSDOMWindow::commonJSGlobalData(), window);
     69    gcController().garbageCollectSoon();
    6170}
    6271
  • trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h

    r129685 r143637  
    4545
    4646        JSDOMWindow* window() const { return JSC::jsCast<JSDOMWindow*>(target()); }
    47         void setWindow(JSC::JSGlobalData& globalData, JSDOMWindow* window)
    48         {
    49             ASSERT_ARG(window, window);
    50             setTarget(globalData, window);
    51             structure()->setGlobalObject(*JSDOMWindow::commonJSGlobalData(), window);
    52         }
     47        void setWindow(JSC::JSGlobalData&, JSDOMWindow*);
    5348        void setWindow(PassRefPtr<DOMWindow>);
    5449
  • trunk/Source/WebCore/bindings/js/ScriptController.h

    r133006 r143637  
    2727#include "ScriptControllerBase.h"
    2828#include "ScriptInstance.h"
     29#include <JavaScriptCore/JSBase.h>
    2930#include <heap/Strong.h>
    3031#include <wtf/Forward.h>
     
    3536#include <wtf/RetainPtr.h>
    3637OBJC_CLASS WebScriptObject;
     38OBJC_CLASS JSContext;
    3739#endif
    3840
     
    152154#if PLATFORM(MAC)
    153155    WebScriptObject* windowScriptObject();
     156#if JSC_OBJC_API_ENABLED
     157    JSContext *javaScriptContext();
     158#endif
    154159#endif
    155160
  • trunk/Source/WebCore/bindings/js/ScriptControllerMac.mm

    r129964 r143637  
    4242#import "runtime_root.h"
    4343#import <JavaScriptCore/APICast.h>
     44#import <JavaScriptCore/JSContextInternal.h>
    4445#import <runtime/JSLock.h>
    4546
     
    110111}
    111112
     113#if JSC_OBJC_API_ENABLED
     114JSContext *ScriptController::javaScriptContext()
     115{
     116    if (!canExecuteScripts(NotAboutToExecuteScript))
     117        return 0;
     118    JSContext *context = [JSContext contextWithGlobalContextRef:toGlobalRef(bindingRootObject()->globalObject()->globalExec())];
     119    return context;
     120}
     121#endif
     122
    112123void ScriptController::updatePlatformScriptObjects()
    113124{
  • trunk/Source/WebCore/bindings/objc/WebScriptObject.h

    r37476 r143637  
    2424 */
    2525
     26#ifndef WebScriptObject_h
     27#define WebScriptObject_h
     28
    2629#import <Foundation/Foundation.h>
    2730#import <JavaScriptCore/JSBase.h>
     
    190193// WebScriptObject --------------------------------------------------
    191194
     195@class JSValue;
    192196@class WebScriptObjectPrivate;
    193197@class WebFrame;
     
    298302- (void)setException:(NSString *)description;
    299303
     304
     305#if JSC_OBJC_API_ENABLED
     306/*!
     307    @method JSValue
     308    @result The equivalent Objective-C JSValue for this WebScriptObject.
     309    @discussion Use this method to bridge between the WebScriptObject and
     310    JavaScriptCore Objective-C APIs.
     311*/
     312- (JSValue *)JSValue;
     313#endif
     314
    300315@end
    301316
     
    317332
    318333#endif
     334
     335#endif // WebScriptObject_h
  • trunk/Source/WebCore/bindings/objc/WebScriptObject.mm

    r142163 r143637  
    4444#import "runtime_root.h"
    4545#import <JavaScriptCore/APICast.h>
     46#import <JavaScriptCore/JSContextInternal.h>
     47#import <JavaScriptCore/JSValueInternal.h>
    4648#import <interpreter/CallFrame.h>
    4749#import <runtime/InitializeThreading.h>
     
    5456#include <wtf/text/WTFString.h>
    5557
    56 using namespace JSC;
    5758using namespace JSC::Bindings;
    5859using namespace WebCore;
     60
     61using JSC::CallData;
     62using JSC::CallType;
     63using JSC::CallTypeNone;
     64using JSC::ExecState;
     65using JSC::Identifier;
     66using JSC::JSLockHolder;
     67using JSC::JSObject;
     68using JSC::MarkedArgumentBuffer;
     69using JSC::PutPropertySlot;
     70using JSC::jsCast;
     71using JSC::jsUndefined;
     72using JSC::makeSource;
    5973
    6074namespace WebCore {
     
    237251}
    238252
     253- (JSGlobalContextRef)_globalContextRef
     254{
     255    if (![self _isSafeScript])
     256        return nil;
     257    return toGlobalRef([self _rootObject]->globalObject()->globalExec());
     258}
     259
    239260- (oneway void)release
    240261{
     
    305326    ASSERT(!exec->hadException());
    306327
    307     JSValue function = [self _imp]->get(exec, Identifier(exec, String(name)));
     328    JSC::JSValue function = [self _imp]->get(exec, Identifier(exec, String(name)));
    308329    CallData callData;
    309330    CallType callType = getCallData(function, callData);
     
    318339
    319340    [self _rootObject]->globalObject()->globalData().timeoutChecker.start();
    320     JSValue result = JSMainThreadExecState::call(exec, function, callType, callData, [self _imp], argList);
     341    JSC::JSValue result = JSMainThreadExecState::call(exec, function, callType, callData, [self _imp], argList);
    321342    [self _rootObject]->globalObject()->globalData().timeoutChecker.stop();
    322343
     
    344365   
    345366    [self _rootObject]->globalObject()->globalData().timeoutChecker.start();
    346     JSValue returnValue = JSMainThreadExecState::evaluate(exec, makeSource(String(script)), JSC::JSValue(), 0);
     367    JSC::JSValue returnValue = JSMainThreadExecState::evaluate(exec, makeSource(String(script)), JSC::JSValue(), 0);
    347368    [self _rootObject]->globalObject()->globalData().timeoutChecker.stop();
    348369
     
    386407        JSLockHolder lock(exec);
    387408       
    388         JSValue result = [self _imp]->get(exec, Identifier(exec, String(key)));
     409        JSC::JSValue result = [self _imp]->get(exec, Identifier(exec, String(key)));
    389410       
    390411        if (exec->hadException()) {
     
    465486
    466487    JSLockHolder lock(exec);
    467     JSValue result = [self _imp]->get(exec, index);
     488    JSC::JSValue result = [self _imp]->get(exec, index);
    468489
    469490    if (exec->hadException()) {
     
    512533}
    513534
    514 + (id)_convertValueToObjcValue:(JSValue)value originRootObject:(RootObject*)originRootObject rootObject:(RootObject*)rootObject
     535+ (id)_convertValueToObjcValue:(JSC::JSValue)value originRootObject:(RootObject*)originRootObject rootObject:(RootObject*)rootObject
    515536{
    516537    if (value.isObject()) {
     
    556577}
    557578
     579
     580#if JSC_OBJC_API_ENABLED
     581- (JSValue *)JSValue
     582{
     583    if (![self _isSafeScript])
     584        return 0;
     585   
     586    return [JSValue valueWithValue:[self JSObject]
     587                    inContext:[JSContext contextWithGlobalContextRef:[self _globalContextRef]]];
     588}
     589#endif
     590
    558591@end
    559592
  • trunk/Source/WebCore/bindings/objc/WebScriptObjectPrivate.h

    r140718 r143637  
    5858- (JSC::Bindings::RootObject*)_rootObject;
    5959- (JSC::Bindings::RootObject*)_originRootObject;
     60- (JSGlobalContextRef)_globalContextRef;
    6061@end
    6162
  • trunk/Source/WebKit/mac/ChangeLog

    r143505 r143637  
     12013-02-19  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Objective-C API: Need a way to use the Objective-C JavaScript API with WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=106059
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Addition of appropriate delegate callbacks and support to the WebKit API.
     9
     10        * WebCoreSupport/WebFrameLoaderClient.mm:
     11        * WebView/WebDelegateImplementationCaching.h:
     12        (WebFrameLoadDelegateImplementationCache):
     13        * WebView/WebFrame.h:
     14        * WebView/WebFrame.mm:
     15        (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
     16        (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
     17        (-[WebFrame _javaScriptContextForScriptWorld:]):
     18        (-[WebFrame javaScriptContext]):
     19        * WebView/WebFrameLoadDelegate.h:
     20        * WebView/WebFramePrivate.h:
     21        * WebView/WebScriptDebugDelegate.mm:
     22        (-[WebScriptCallFrame _convertValueToObjcValue:JSC::]):
     23        (-[WebScriptCallFrame exception]):
     24        (-[WebScriptCallFrame evaluateWebScript:]):
     25        * WebView/WebScriptWorld.h:
     26        * WebView/WebScriptWorld.mm:
     27        (+[WebScriptWorld scriptWorldForJavaScriptContext:]):
     28        * WebView/WebView.mm:
     29        (-[WebView _cacheFrameLoadDelegateImplementations]):
     30        (aeDescFromJSValue):
     31        (-[WebView aeDescByEvaluatingJavaScriptFromString:]):
     32        (-[WebView _computedStyleIncludingVisitedInfo:forElement:]):
     33
    1342013-02-20  Dirk Schulze  <krit@webkit.org>
    235
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r142977 r143637  
    7575#import "WebUIDelegatePrivate.h"
    7676#import "WebViewInternal.h"
     77#import <JavaScriptCore/JSContextInternal.h>
    7778#import <WebCore/AuthenticationCF.h>
    7879#import <WebCore/AuthenticationMac.h>
     
    118119#import <WebCore/SharedBuffer.h>
    119120#import <WebCore/WebCoreObjCExtras.h>
     121#import <WebCore/WebScriptObjectPrivate.h>
    120122#import <WebCore/Widget.h>
    121123#import <WebKit/DOMElement.h>
     
    19511953    ScriptController *script = frame->script();
    19521954
     1955#if JSC_OBJC_API_ENABLED
     1956    if (implementations->didCreateJavaScriptContextForFrameFunc) {
     1957        CallFrameLoadDelegate(implementations->didCreateJavaScriptContextForFrameFunc, webView, @selector(webView:didCreateJavaScriptContext:forFrame:),
     1958            script->javaScriptContext(), m_webFrame.get());
     1959    } else if (implementations->didClearWindowObjectForFrameFunc) {
     1960#else
    19531961    if (implementations->didClearWindowObjectForFrameFunc) {
     1962#endif
    19541963        CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameFunc, webView, @selector(webView:didClearWindowObject:forFrame:),
    19551964            script->windowScriptObject(), m_webFrame.get());
  • trunk/Source/WebKit/mac/WebView/WebDelegateImplementationCaching.h

    r139000 r143637  
    5353
    5454struct WebFrameLoadDelegateImplementationCache {
     55#if JSC_OBJC_API_ENABLED
     56    IMP didCreateJavaScriptContextForFrameFunc;
     57#endif
    5558    IMP didClearWindowObjectForFrameFunc;
    5659    IMP didClearWindowObjectForFrameInScriptWorldFunc;
  • trunk/Source/WebKit/mac/WebView/WebFrame.h

    r55349 r143637  
    3232@class DOMDocument;
    3333@class DOMHTMLElement;
     34@class JSContext;
    3435@class NSURLRequest;
    3536@class WebArchive;
     
    214215*/
    215216- (JSGlobalContextRef)globalContext;
     217
     218#if JSC_OBJC_API_ENABLED
     219/*!
     220    @method javaScriptContext
     221    @result The frame's global JavaScript execution context. Use this method to
     222    bridge between the WebKit and Objective-C JavaScriptCore API.
     223*/
     224- (JSContext *)javaScriptContext;
     225#endif // JSC_OBJC_API_ENABLED
     226
    216227@end
  • trunk/Source/WebKit/mac/WebView/WebFrame.mm

    r142977 r143637  
    5454#import "WebViewInternal.h"
    5555#import <JavaScriptCore/APICast.h>
     56#import <JavaScriptCore/JSContextInternal.h>
    5657#import <WebCore/AXObjectCache.h>
    5758#import <WebCore/AccessibilityObject.h>
     
    107108using JSC::JSGlobalObject;
    108109using JSC::JSLock;
    109 using JSC::JSValue;
    110110
    111111/*
     
    581581    RetainPtr<WebFrame> protect(self); // Executing arbitrary JavaScript can destroy the frame.
    582582   
    583     JSValue result = _private->coreFrame->script()->executeScript(string, forceUserGesture).jsValue();
     583    JSC::JSValue result = _private->coreFrame->script()->executeScript(string, forceUserGesture).jsValue();
    584584
    585585    if (!_private->coreFrame) // In case the script removed our frame from the page.
     
    10601060    RetainPtr<WebFrame> webFrame(kit(frame)); // Running arbitrary JavaScript can destroy the frame.
    10611061
    1062     JSValue result = frame->script()->executeScriptInWorld(core(world), string, true).jsValue();
     1062    JSC::JSValue result = frame->script()->executeScriptInWorld(core(world), string, true).jsValue();
    10631063
    10641064    if (!webFrame->_private->coreFrame) // In case the script removed our frame from the page.
     
    10861086    return toGlobalRef(coreFrame->script()->globalObject(coreWorld)->globalExec());
    10871087}
     1088
     1089#if JSC_OBJC_API_ENABLED
     1090- (JSContext *)_javaScriptContextForScriptWorld:(WebScriptWorld *)world
     1091{
     1092    JSGlobalContextRef globalContextRef = [self _globalContextForScriptWorld:world];
     1093    if (!globalContextRef)
     1094        return 0;
     1095    return [JSContext contextWithGlobalContextRef:globalContextRef];
     1096}
     1097#endif
    10881098
    10891099- (void)setAllowsScrollersToOverlapContent:(BOOL)flag
     
    14721482}
    14731483
     1484#if JSC_OBJC_API_ENABLED
     1485- (JSContext *)javaScriptContext
     1486{
     1487    Frame* coreFrame = _private->coreFrame;
     1488    if (!coreFrame)
     1489        return 0;
     1490    return coreFrame->script()->javaScriptContext();
     1491}
     1492#endif
     1493
    14741494@end
  • trunk/Source/WebKit/mac/WebView/WebFrameLoadDelegate.h

    r37474 r143637  
    195195- (void)webView:(WebView *)webView windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0);
    196196
     197#if JSC_OBJC_API_ENABLED
     198/*!
     199    @method webView:didCreateJavaScriptContext:contextForFrame:
     200    @abstract Notifies the delegate that a new JavaScript context has been created created.
     201    @param webView The WebView sending the message.
     202    @param context The JSContext representing the frame's JavaScript window object.
     203    @param frame The WebFrame to which the context belongs.
     204    @discussion If a delegate implements webView:didCreateJavaScriptContext:forFrame: along with either
     205    webView:didClearWindowObject:forFrame: or webView:windowScriptObjectAvailable:, only
     206    webView:didCreateJavaScriptContext:forFrame will be invoked. This enables a delegate to implement
     207    multiple versions to maintain backwards compatibility with older versions of WebKit.
     208*/
     209- (void)webView:(WebView *)webView didCreateJavaScriptContext:(JSContext *)context forFrame:(WebFrame *)frame;
     210#endif
     211
    197212@end
  • trunk/Source/WebKit/mac/WebView/WebFramePrivate.h

    r142171 r143637  
    9696- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world;
    9797
     98#if JSC_OBJC_API_ENABLED
     99- (JSContext *)_javaScriptContextForScriptWorld:(WebScriptWorld *)world;
     100#endif
     101
    98102- (void)_replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle;
    99103- (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace;
  • trunk/Source/WebKit/mac/WebView/WebScriptDebugDelegate.mm

    r128267 r143637  
    5656@interface WebScriptCallFrame (WebScriptDebugDelegateInternal)
    5757
    58 - (id)_convertValueToObjcValue:(JSValue)value;
     58- (id)_convertValueToObjcValue:(JSC::JSValue)value;
    5959
    6060@end
     
    114114}
    115115
    116 - (id)_convertValueToObjcValue:(JSValue)value
     116- (id)_convertValueToObjcValue:(JSC::JSValue)value
    117117{
    118118    if (!value)
     
    215215        return nil;
    216216
    217     JSValue exception = _private->debuggerCallFrame->exception();
     217    JSC::JSValue exception = _private->debuggerCallFrame->exception();
    218218    return exception ? [self _convertValueToObjcValue:exception] : nil;
    219219}
     
    242242        DynamicGlobalObjectScope globalObjectScope(globalObject->globalData(), globalObject);
    243243
    244         JSValue exception;
    245         JSValue result = evaluateInGlobalCallFrame(script, exception, globalObject);
     244        JSC::JSValue exception;
     245        JSC::JSValue result = evaluateInGlobalCallFrame(script, exception, globalObject);
    246246        if (exception)
    247247            return [self _convertValueToObjcValue:exception];
     
    249249    }
    250250
    251     JSValue exception;
    252     JSValue result = _private->debuggerCallFrame->evaluate(script, exception);
     251    JSC::JSValue exception;
     252    JSC::JSValue result = _private->debuggerCallFrame->evaluate(script, exception);
    253253    if (exception)
    254254        return [self _convertValueToObjcValue:exception];
  • trunk/Source/WebKit/mac/WebView/WebScriptWorld.h

    r95901 r143637  
    2323 */
    2424
    25 typedef struct OpaqueJSContext* JSGlobalContextRef;
     25#include <JavaScriptCore/JSBase.h>
    2626
     27@class JSContext;
    2728@class WebScriptWorldPrivate;
    2829
     
    3637
    3738+ (WebScriptWorld *)scriptWorldForGlobalContext:(JSGlobalContextRef)globalContext;
     39#if JSC_OBJC_API_ENABLED
     40+ (WebScriptWorld *)scriptWorldForJavaScriptContext:(JSContext *)context;
     41#endif
    3842
    3943- (void)unregisterWorld;
  • trunk/Source/WebKit/mac/WebView/WebScriptWorld.mm

    r95901 r143637  
    2929#import <WebCore/ScriptController.h>
    3030#import <JavaScriptCore/APICast.h>
     31#import <JavaScriptCore/JSContextInternal.h>
    3132
    3233#import <wtf/RefPtr.h>
     
    107108}
    108109
     110#if JSC_OBJC_API_ENABLED
     111+ (WebScriptWorld *)scriptWorldForJavaScriptContext:(JSContext *)context
     112{
     113    return [self scriptWorldForGlobalContext:contextInternalContext(context)];
     114}
     115#endif
     116
    109117@end
    110118
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r143428 r143637  
    16601660    cache->didReplaceStateWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didReplaceStateWithinPageForFrame:));
    16611661    cache->didPopStateWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didPopStateWithinPageForFrame:));
     1662#if JSC_OBJC_API_ENABLED
     1663    cache->didCreateJavaScriptContextForFrameFunc = getMethod(delegate, @selector(webView:didCreateJavaScriptContext:forFrame:));
     1664#endif
    16621665    cache->didClearWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearWindowObject:forFrame:));
    16631666    cache->didClearWindowObjectForFrameInScriptWorldFunc = getMethod(delegate, @selector(webView:didClearWindowObjectForFrame:inScriptWorld:));
     
    49174920}
    49184921
    4919 static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValue)
     4922static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue jsValue)
    49204923{
    49214924    NSAppleEventDescriptor* aeDesc = 0;
     
    49584961            }
    49594962        }
    4960         JSValue primitive = object->toPrimitive(exec);
     4963        JSC::JSValue primitive = object->toPrimitive(exec);
    49614964        if (exec->hadException()) {
    49624965            exec->clearException();
     
    49784981    if (!coreFrame->document())
    49794982        return nil;
    4980     JSValue result = coreFrame->script()->executeScript(script, true).jsValue();
     4983    JSC::JSValue result = coreFrame->script()->executeScript(script, true).jsValue();
    49814984    if (!result) // FIXME: pass errors
    49824985        return 0;
     
    67006703    if (!value)
    67016704        return JSValueMakeUndefined(context);
    6702     JSValue jsValue = toJS(exec, value);
     6705    JSC::JSValue jsValue = toJS(exec, value);
    67036706    if (!jsValue.inherits(&JSElement::s_info))
    67046707        return JSValueMakeUndefined(context);
  • trunk/Tools/ChangeLog

    r143635 r143637  
     12013-02-19  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Objective-C API: Need a way to use the Objective-C JavaScript API with WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=106059
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Added new tests for the WebKit API portion of the JSC Objective-C API.
     9
     10        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     11        * TestWebKitAPI/Tests/mac/JSContextBackForwardCache1.html: Added.
     12        * TestWebKitAPI/Tests/mac/JSContextBackForwardCache2.html: Added.
     13        * TestWebKitAPI/Tests/mac/WebViewDidCreateJavaScriptContext.mm: Added.
     14        (-[MyConsole log:]):
     15        (-[MyConsole printHelloWorld]):
     16        (-[MyConsole add:to:]):
     17        (-[DidCreateJavaScriptContextFrameLoadDelegate webView:didFinishLoadForFrame:]):
     18        (-[DidCreateJavaScriptContextFrameLoadDelegate webView:didCreateJavaScriptContext:forFrame:]):
     19        (TestWebKitAPI):
     20        (TestWebKitAPI::TEST):
     21
    1222013-02-21  Stephen Chenney  <schenney@chromium.org>
    223
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r143067 r143637  
    178178                C0C5D3BE14598B6F00A802A6 /* GetBackingScaleFactor.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */; };
    179179                C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; };
     180                C2CF975A16CEC7140054E99D /* JSContextBackForwardCache2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */; };
     181                C2CF975B16CEC71B0054E99D /* JSContextBackForwardCache1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */; };
     182                C2EB2DD316CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */; };
    180183                C507E8A714C6545B005D6B3B /* InspectorBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = C507E8A614C6545B005D6B3B /* InspectorBar.mm */; };
    181184                C51AFB99169F49FF009CCF66 /* FindMatches.mm in Sources */ = {isa = PBXBuildFile; fileRef = C51AFB98169F49FF009CCF66 /* FindMatches.mm */; };
     
    227230                        dstSubfolderSpec = 7;
    228231                        files = (
     232                                C2CF975B16CEC71B0054E99D /* JSContextBackForwardCache1.html in Copy Resources */,
     233                                C2CF975A16CEC7140054E99D /* JSContextBackForwardCache2.html in Copy Resources */,
    229234                                1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
    230235                                379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
     
    457462                C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; };
    458463                C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; };
     464                C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = JSContextBackForwardCache1.html; sourceTree = "<group>"; };
     465                C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = JSContextBackForwardCache2.html; sourceTree = "<group>"; };
     466                C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewDidCreateJavaScriptContext.mm; sourceTree = "<group>"; };
    459467                C507E8A614C6545B005D6B3B /* InspectorBar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorBar.mm; sourceTree = "<group>"; };
    460468                C51AFB98169F49FF009CCF66 /* FindMatches.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindMatches.mm; sourceTree = "<group>"; };
     
    818826                                37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */,
    819827                                A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
     828                                C2EB2DD116CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm */,
    820829                        );
    821830                        path = mac;
     
    825834                        isa = PBXGroup;
    826835                        children = (
     836                                C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */,
     837                                C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */,
    827838                                379028B814FABE49007E6B43 /* acceptsFirstMouse.html */,
    828839                                B55F11B9151916E600915916 /* Ahem.ttf */,
     
    934945                08FB7793FE84155DC02AAC07 /* Project object */ = {
    935946                        isa = PBXProject;
     947                        attributes = {
     948                        };
    936949                        buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "TestWebKitAPI" */;
    937950                        compatibilityVersion = "Xcode 3.1";
     
    10091022                                9B4F8FA4159D52B1002D9F94 /* HTMLCollectionNamedItem.mm in Sources */,
    10101023                                9B26FC6C159D061000CC3765 /* HTMLFormCollectionNamedItem.mm in Sources */,
     1024                                C2EB2DD316CAC7AC009B52EE /* WebViewDidCreateJavaScriptContext.mm in Sources */,
    10111025                                BC575AAD126E83B9006F0F12 /* InjectedBundleBasic.cpp in Sources */,
    10121026                                378E64731632646D00B6C676 /* InjectedBundleFrameHitTest.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.