[webkit-dev] Question about JSGlobalObject and RootObject use in the objc bridge

Rémy Saissy remy.saissy at gmail.com
Mon Oct 31 02:33:18 PDT 2011


Very sort, I forgot the [webkit-dev] in my subject. 
It is fixed now.
Regards,


Envoyé de mon iPad

Le 30 oct. 2011 à 15:49, Rémy Saissy <remy.saissy at gmail.com> a écrit :

> Hi,
> I've just wrote a small patch to webkit in order to have javascript string parameters being bridged to NSString.
> 
> It works fine but I think it can be improved, but to do it, I first need some explanations from you guys :).
> 
> What I've found out is that in WebCore::objc_utility.mm, when the method
> 
> ObjcValue convertValueToObjcValue(ExecState* exec, JSValue value, ObjcValueType type)
> 
> Receives an ObjcObjectType it tries to retrieve both the originRootObject and the rootObject. In the case of a non object parameter, both are be the same.
> The issue is that:
> 
> JSGlobalObject *originGlobalObject = exec->dynamicGlobalObject();
> 
> RootObject* originRootObject = findRootObject(originGlobalObject);
> 
> 
> Returns the originGlobalObject but findRootObject() returns nil.
> 
> My patch adds an if else statement at the end of this case block but I think that the correct way to fix the issue is to let the conversion to
> [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:originRootObject rootObject:rootObject]
> 
> and to figure out why there is no originRootObject return (and thus no rootObject). From my current understanding, it is because the following method in runtime_root.cpp
> PassRefPtr<RootObject> RootObject::create(const void* nativeHandle, JSGlobalObject* globalObject)
> 
> 
> is not called everytime it should be.  For example, I think it should be called in WebScriptObject.mm:- (void)setValue:(id)value forKey:(NSString *)key so the root object at this time will be in in the rootObjectSet of runtime_root.cpp. But since I am not sure to correctly understand what is the difference between a RootObject and a JSGlobalObject and how they interact with each other and with the ExecState, I prefer to ask ;).
> 
> It would be nice if somebody could explain me or at least point me to some useful resources.
> Thanks!
> 
> -- 
> Rémy Saissy
> Picassa: http://picasaweb.google.com/remy.saissy
> Blog: http://blog.remysaissy.com
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111031/ba838ba9/attachment.html>


More information about the webkit-dev mailing list