[Webkit-unassigned] [Bug 64572] Initial implementation of calling WebScriptObject::callWebScriptMethod() via COM

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 16 12:38:12 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=64572





--- Comment #18 from Adam Roben (:aroben) <aroben at apple.com>  2011-08-16 12:38:13 PST ---
Thanks for the detailed explanation. I think we can make the JSC API work for you. Responses below.

(In reply to comment #17)
> For the JavaScriptCore API I wasn't able to find anything that allowed me to get the JSObject that is associated with the DOM element in an html document.

That's right. This is the main limitation of the JSC API as compared to WebScriptObject.

> I think once I have that, I could use the JavaScriptCore API; I just don't see how to tap into the DOM/JSObject binding. Perhaps it might work if the javascript methods are global, but how to get global javascript in an html document using the JavaScript Core API? The other issue is, I don't know exactly how to get access to the JavaScriptCore API via the COM API, as I don't see interfaces that bridge the gap.

The main entry point for the JSC API for a WebKit app is IWebFrameLoadDelegate::didClearWindowObject. That function gets called once per frame load. It is passed the frame's JSGlobalContextRef (though the function signature only calls it a JSContextRef) and the frame's window object's JSObjectRef.

To get to global JavaScript functions and variables, you can use JSObjectGetProperty(globalContext, windowObject, propertyName, &exception).

One technique we have found useful when writing WebKit-based apps that use the JSC API is to put as much logic in actual JavaScript code as possible. By putting logic into JavaScript itself, you get to use the succinct JS-based DOM APIs rather than having to use the verbose JSC API for everything. You can use the JSC API to inject some hooks into the page to allow your JavaScript code to call back up into your C/C++ code as needed.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list