[webkit-dev] Attaching property to external (Obj-c) synthetic event
ross.lillie at motorola.com
Wed Jun 17 15:53:22 PDT 2009
Never mind. If I understand things correctly, calling into the DOMDocument
from native code, to create a new Event instance, does not create the
corresponding JSObject in the window's global context. Dispatching the
event to a target appears to be when the corresponding JSObject is created.
Any insight (such as the way scope chains are set up, etc, just guessing
here...) on why it works like this would be appreciated.
Again thanks in advance and regards,
On 6/17/09 4:29 PM, "Ross Lillie" <ross.lillie at motorola.com> wrote:
> I need to generate a synthetic event (DOM Level 2) from external (native)
> code and inject into the current DOM structure. Furthermore, this event
> needs to have a custom property attached, to pass external data into the
> Generating and dispatching the event from external code is straightforward.
>> From the delegate method (didFinishLoadForFrame) of the WebFrame, I can
> access the DOMDocument as well as the JSGlobalContextRef. Using the
> DOMDocument reference I create a new Event instance via the createEvent()
> method and initialize to the desired type. This event can then be
> dispatched to a specified target in the DOM without any problems.
> property to the corresponding JSObject of the DOMEvent. I assumed that this
> could be accomplished by retrieving the JSObject reference from the
> DOMEvent, but this appears not to work, as calling the [(DOMEvent)ev
> created yet, or is it created when dispatched to the desired target?
> What am I missing? It appears that my understanding of the
> WindowScriptObject interface is not what it should be. Any insight would be
> Thanks in advance, and regards
> Example (abbreviated) code snippet:
>> From the window didFinishLoadForFrame method:
> JSGlobalContextRef ctx = [frame globalContext];
> DOMDocument *doc = [frame DOMDocument];
> DOMEvent *ev = [doc createEvent:@"Events"];
> [ev initEvent:@"eventType" canBubbleArg:YES cancelableArg:NO];
> // At this point I can select the event target via the DOMDocument
> // getElementByID method and dispatch my custom event without problems.
> // However, I'm trying to attach a custom property to the event as
> // follows:
> JSObjectRef evObj = [ev JSObject]; // THIS RETURNS NULL!!
> // DOMEvent object created above
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
More information about the webkit-dev