[webkit-dev] Attaching property to external (Obj-c) synthetic event

2009-06-17 Thread Ross Lillie
Greetings,

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
current Javascript context.

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.

However, at this point (before dispatch) I would like to attach a JavaScript
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
JSObject] method returns NULL. Has the corresponding Javascript Object been
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
appreciated.

Thanks in advance, and regards
Ross

--
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!!

// Intent was to use the JavaScriptCore APIs to add a custom property to the
// DOMEvent object created above

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Attaching property to external (Obj-c) synthetic event

2009-06-17 Thread Ross Lillie
Greetings again,

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,
Ross


On 6/17/09 4:29 PM, Ross Lillie ross.lil...@motorola.com wrote:

 Greetings,
 
 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
 current Javascript context.
 
 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.
 
 However, at this point (before dispatch) I would like to attach a JavaScript
 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
 JSObject] method returns NULL. Has the corresponding Javascript Object been
 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
 appreciated.
 
 Thanks in advance, and regards
 Ross
 
 --
 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!!
 
 // Intent was to use the JavaScriptCore APIs to add a custom property to the
 // DOMEvent object created above
 
 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Add custom event into Webkit

2009-04-09 Thread Ross Lillie
Hi Darin,

Thanks for the reply.  Yes, this is starting to make sense, please excuse,
but my Javascript/DOM knowledge is pretty rusty - but it's coming back.

I'd figured out that I can create arbitrarily named events via the DOMEvent
class (in my external code), however, as you mentioned, the problem is that
I need to attach special data.

In a nutshell, I want to expose an external device model (C or C++) to
Javascript.  No problem, as there are numerous places to grab a reference to
the JSContext allowing me to expose my external code internally as a
Javascript object.

The next piece of the puzzle, however, is dispatching events generated by my
external code into the Javascript/DOM environment.  These events ideally
require special data to be attached.  From my admittedly limited
understanding of WebKit internals, it would appear that I can't do this
without bypassing the public interfaces.

Finally, if I want my custom event targets to be an attribute on a DOM node,
I would think that I would also need to create a custom attribute node that
implements the EventTarget interface, and register this node in some manner
within WebKit's core - but I haven't dug into this far enough yet.  While
this isn't strictly necessary, it provide nice syntactic sugar when
developing an interface that works with your external device model.

Obviously, I'd like to avoid bypassing public webkit interfaces.  I just
don't know if I can cleanly do what I need to with the current APIs for my
embedded application.

I hope I'm not complete out in the weeds in my current understanding.  Your
comments have been helpful.  Hopefully, this explanation makes more sense.

Thanks loads for the feedback.

Regards,
/ross

On 4/9/09 10:45 AM, Darin Adler da...@apple.com wrote:

 On Apr 9, 2009, at 2:40 AM, Tony Louaze wrote:
 
 I want to add a custom event into Webkit without modify and compile
 Webkit.
 
 It all depends what you mean by a custom event. If you want to send an
 event with a special name but no special data attached, you can do
 this easily with standard DOM API.
 
 In JavaScript it would be something like this:
 
  var event = document.createEvent(Events);
  event.initEvent(specialName, false, false);
  target.dispatchEvent(event);
 
 On which object should I make the addEventListener : a custom JS
 object or an existing DOM object (which one ?) ?
 
 You can send an event to any event target object, which can be any DOM
 node or other type of object, and the listener would need to be
 attached to that object, the one you send the event to. Your question
 isn¹t specific enough.
 
 For now, I'm just interracting with JS context by using the
 Webkit.dll API.
 
 WebKit DOM bindings for JavaScript and for Objective-C on Mac OS X are
 mostly complete; the ones done with COM on Windows are enough for
 Safari but are incomplete, and are likely missing some things you¹d
 need to deal with custom events.
 
  -- Darin
 
 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] FW: Creating custom DOM events

2009-04-08 Thread Ross Lillie
Thanks for the reply.

To clarify, it¹s the external process generating an event representing the
process¹ completion status that I want to dispatch into a DOM target.  I
understand that I can simply add and event listener to a DOM element,
however if I want my custom event handler to be an attribute of a DOM
element, then I¹m assuming that I need to a) create a custom DOM attribute
that b) implements the EventTarget interface.  My external code then
dispatches it¹s custom event to my custom attribute/eventTarget.  This would
then allow my HTML markup to be of the form:

div onMyExternalProcessComplete=function()

I¹m not saying that this is necessarily the best way to accomplish this, but
am just trying to understand how everything is connected within the webkit
framework. However, if my understanding is correct, then what is the best
way to add a custom attribute/eventTarget into the DOM?

thanks again for the insights,
Ross


On 4/8/09 4:10 AM, ZHOU Xiao-bo zhxb.u...@gmail.com wrote:

  external code to be able to dispatch custom events 
 you mean that your c++ code can be triggered by a custom event or your code
 can
 generate a custom envent?
 
 if former, I think you should implement your own onxxx attribute, and add some
 eventlisteners;
 if latter, maybe you can add your own eventlistener to some node and create an
 event and call 
 handlelocalevent 
 
 2009/4/8 Ross Lillie ross.lil...@motorola.com
 I have external C++ code that I'm exposing to the JavaScript runtime.  I'd
 also like my external code to be able to dispatch custom events via the DOM
 event mechanism.  For example
 
     element onMyCustomEvent=function() {}
 
 Now, if I'm beginning to understand Webkit (which is doubtful) it seems that
 I need to somehow create a new attribute node that's wired to my external
 code and serves as the EventTarget for event dispatches.  I.e. somewhat
 similar to how this is described for Mozilla/Gecko
 
 The public interfaces in WebKit don't appear to provide the functionality I
 need.  The private interfaces in WebCore appear that they might.  Am I on
 the right track?
 
 If so, how are new elements added to the DOM?  Is this the function of the
 NamedNodeMap, or am I completely lost in my understanding?  Also, I'm
 assuming any custom event must also be registered somewhere.
 
 Thanks in advance for any insight or pointers to more information.
 Ross
 
 
 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
 
 

-- End of Forwarded Message

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Creating custom DOM events

2009-04-07 Thread Ross Lillie
I have external C++ code that I'm exposing to the JavaScript runtime.  I'd
also like my external code to be able to dispatch custom events via the DOM
event mechanism.  For example

element onMyCustomEvent=function() {}

Now, if I'm beginning to understand Webkit (which is doubtful) it seems that
I need to somehow create a new attribute node that's wired to my external
code and serves as the EventTarget for event dispatches.  I.e. somewhat
similar to how this is described for Mozilla/Gecko

The public interfaces in WebKit don't appear to provide the functionality I
need.  The private interfaces in WebCore appear that they might.  Am I on
the right track?

If so, how are new elements added to the DOM?  Is this the function of the
NamedNodeMap, or am I completely lost in my understanding?  Also, I'm
assuming any custom event must also be registered somewhere.

Thanks in advance for any insight or pointers to more information.
Ross


___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Extending JS context for all WebFrames

2009-03-12 Thread Ross Lillie
I've been digging into extending the Javascript context associated with a
Webview, however I'm not sure that that public JS core APIs accomplish what
I want to achieve.

Ideally, I would like to extend the JS global object with my external (C++)
library routines so that any time a new WebView is allocated/init'd, its
underlying JS GlobalObject contains my external objects and properties.

While I can grab the JSGlobalContext reference from a WebView's mainFrame,
and subsequently use the public JS APIs to extend the underlying JS global
object, I believe that subsequent WebView allocations will cause the
underlying JSGlobalObject to be reinitialized forcing me to 're-extend' the
object using the public APIs.

First, is my understanding of the relation between a WebFrame and its
underlying JSGlobalContext (and hence the associated global object) correct?
An, if so, I'm assuming that I'll some how need to manipulate the
JSGlobalObject directly.

My understanding of the overall webkit organization is still pretty
rudimentary, so I've likely missed something.

Thoughts?

Regards,
--
Ross Lillie

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Extending JS context for all WebFrames

2009-03-12 Thread Ross Lillie
Thanks Geoff,

But I think I¹m still faced with the same problem.  If I want ALL pages
associated with all possible WebViews to have access to my external
objects/properties, does this still not require me to reinitialize the
global object (via the context reference) at each page load?  What I¹m
trying to accomplish is to have my extended global object be the default
object for all webview/page lists.

It¹s 6pm and my brain hurts.  Thanks for any help/insight you can provide.

Confused in Schaumburg,
Ross Lillie


On 3/12/09 5:37 PM, Geoffrey Garen gga...@apple.com wrote:

 Hi Ross.
 
 While I can grab the JSGlobalContext reference from a WebView's mainFrame,
 and subsequently use the public JS APIs to extend the underlying JS global
 object, I believe that subsequent WebView allocations will cause the
 underlying JSGlobalObject to be reinitialized forcing me to 're-extend' the
 object using the public APIs.
 
 It's a page load, not a WebView allocation, that clears the data in a
 JSGlobalContext.
 
 Here is the delegate callback you need: ­
 webView:didClearWindowObject:forFrame:
 http://developer.apple.com/documentation/Cocoa/Reference/WebKit/Protocols/Web
 FrameLoadDelegate_Protocol/Reference/Reference.html%23//apple_ref/occ/instm/NS
 Object/webView:didClearWindowObject:forFrame:
 
 Cheers,
 Geoff
 

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Build error when source tree on alternate volume

2009-01-07 Thread Ross Lillie
I'm getting build errors when building WebKit on OS X (10.5.6, Xcode 3.1.1)
when the source tree is located on an alternate volume.  In my
configuration, the source tree is located on a secondary volume
(/Volumes/Project HD/webkit).  Examining the terminal log you see the
following errors:

setenv XCODE_VERSION_ACTUAL 0310
setenv XCODE_VERSION_MAJOR 0300
setenv YACC /Developer/usr/bin/yacc
/bin/sh -c \/Volumes/Project
HD/webkit/WebKitBuild/WebCore.build/Debug/Derived
Sources.build/Script-DD041FBD09D9DDBE0010AF2A.sh\
i686-apple-darwin9-gcc-4.0.1: HD/webkit/WebKitBuild/Debug: No such file or
directory
WebCore/ForwardingHeaders/wtf/Platform.h:1:37: error:
JavaScriptCore/Platform.h: No such file or directory
i686-apple-darwin9-gcc-4.0.1: HD/webkit/WebKitBuild/Debug: No such file or
directory
WebCore/ForwardingHeaders/wtf/Platform.h:1:37: error:
JavaScriptCore/Platform.h: No such file or directory
i686-apple-darwin9-gcc-4.0.1: HD/webkit/WebKitBuild/Debug: No such file or
directory
WebCore/ForwardingHeaders/wtf/Platform.h:1:37: error:
JavaScriptCore/Platform.h: No such file or directory

The build later halts with the following message:

_SVG_AS_IMAGE ENABLE_SVG_FONTS ENABLE_SVG_FOREIGN_OBJECT ENABLE_SVG_USE
ENABLE_VIDEO ENABLE_WORKERS ENABLE_XPATH ENABLE_XSLT LANGUAGE_JAVASCRIPT
--generator JS WebCore/xml/XSLTProcessor.idl
make: *** No rule to make target `JSDOMWindowBase.lut.h', needed by `all'.
Stop.
make: *** Waiting for unfinished jobs
** BUILD FAILED **

The following build commands failed:
Derived Sources:
PhaseScriptExecution /Volumes/Project
HD/webkit/WebKitBuild/WebCore.build/Debug/Derived
Sources.build/Script-DD041FBD09D9DDBE0010AF2A.sh
(1 failure)

If the source tree is rooted in my Mac home directory (e.g.
/Users/xx/projects/webkit), everything builds fine.

This error results in numerous generated files not being created (e.g.
HTMLNames.h, etc.)  As I¹m fairly new to Xcode as well as the webkit build
process I¹m floundering to trace down the exact error.  Any suggestions
would be helpful.

thanks
/ross

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Build error when source tree on alternate volume

2009-01-07 Thread Ross Lillie
Thanks Dan!

/ross


On 1/7/09 3:20 PM, Dan Bernstein m...@apple.com wrote:

 Unfortunately, WebKit cannot be built when there are spaces in the path to the
 source tree. See https://bugs.webkit.org/show_bug.cgi?id=10758.
 
 On Jan 7, 2009, at 1:14 PM, Ross Lillie wrote:
 
 I'm getting build errors when building WebKit on OS X (10.5.6, Xcode 3.1.1)
 when the source tree is located on an alternate volume.  In my configuration,
 the source tree is located on a secondary volume (/Volumes/Project
 HD/webkit).  Examining the terminal log you see the following errors:
 
 setenv XCODE_VERSION_ACTUAL 0310
 setenv XCODE_VERSION_MAJOR 0300
 setenv YACC /Developer/usr/bin/yacc
 /bin/sh -c \/Volumes/Project
 HD/webkit/WebKitBuild/WebCore.build/Debug/Derived
 Sources.build/Script-DD041FBD09D9DDBE0010AF2A.sh\
 i686-apple-darwin9-gcc-4.0.1: HD/webkit/WebKitBuild/Debug: No such file or
 directory
 WebCore/ForwardingHeaders/wtf/Platform.h:1:37: error:
 JavaScriptCore/Platform.h: No such file or directory
 i686-apple-darwin9-gcc-4.0.1: HD/webkit/WebKitBuild/Debug: No such file or
 directory
 WebCore/ForwardingHeaders/wtf/Platform.h:1:37: error:
 JavaScriptCore/Platform.h: No such file or directory
 i686-apple-darwin9-gcc-4.0.1: HD/webkit/WebKitBuild/Debug: No such file or
 directory
 WebCore/ForwardingHeaders/wtf/Platform.h:1:37: error:
 JavaScriptCore/Platform.h: No such file or directory
 
 The build later halts with the following message:
 
 _SVG_AS_IMAGE ENABLE_SVG_FONTS ENABLE_SVG_FOREIGN_OBJECT ENABLE_SVG_USE
 ENABLE_VIDEO ENABLE_WORKERS ENABLE_XPATH ENABLE_XSLT LANGUAGE_JAVASCRIPT
 --generator JS WebCore/xml/XSLTProcessor.idl
 make: *** No rule to make target `JSDOMWindowBase.lut.h', needed by `all'.
 Stop.
 make: *** Waiting for unfinished jobs
 ** BUILD FAILED **
 
 The following build commands failed:
 Derived Sources:
 PhaseScriptExecution /Volumes/Project
 HD/webkit/WebKitBuild/WebCore.build/Debug/Derived
 Sources.build/Script-DD041FBD09D9DDBE0010AF2A.sh
 (1 failure)
 
 If the source tree is rooted in my Mac home directory (e.g.
 /Users/xx/projects/webkit), everything builds fine.
 
 This error results in numerous generated files not being created (e.g.
 HTMLNames.h, etc.)  As I¹m fairly new to Xcode as well as the webkit build
 process I¹m floundering to trace down the exact error.  Any suggestions would
 be helpful.
 
 thanks
 /ross
 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
 
 

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev