[webkit-dev] How to get window/view reference with NSAPI on Mac OS X 10.6 [Snow Leopard]?

Doug Hill doughill at grouplogic.com
Fri Jul 17 12:35:40 PDT 2009


Let me rephrase the subject line.

What I mean to ask is this:

In a Netscape plugin, if NPDrawingModelQuickDraw and NPEventModelCarbon are not available   :-)   how does one get a reference to the window or NSView that a plugin is contained in?

With the Carbon event model, the "window" field of the NPWindow passed via SetWindow contains a WindowRef which is sufficient to draw and attach Drag Manager handlers.

However, after reading the docs and looking at the Moz. code, if the event model is NPEventModelCocoa the "window" field is always NULL. This seems to be because that drawing now takes places via the new Cocoa "draw" event which provides the CGContextRef.   However, this seems to ignore the need to access the window for things other than drawing.

After reading and debugging WebKit, it appears that the very reference I need is stuffed into the instance->ndata field that's passed to me at creation time.  Yea!   But, I'm assuming that this isn't a recommended source so I'm asking the plugin gurus - how I can get access to the appropriate Cocoa objects in an approved and supported way.  [Please forgive me if there's an obvious Cocoa way to do this - I'm new to the runtime environment and am still absorbing the many PDFs documenting it...]


Thanks for any help you can provide...

-doug.

Ps.   One thing I have noticed is that few, if any, of the Netscape code samples out there handle the Snow Leopard case where the event and drawing models are forced on you and are different from the status quo.  For example, most still use the Carbon event model.  Are there any Snow Leopard-friendly examples of a Netscape plugin out there?

PPs.  I know that it's trivial to get this information when writing a WebKit-style plugin - it's given to you by the WebKitPluginFactory. My requirement is to avoid shipping and maintaining two plugins at all cost which is why I'm using NS.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090717/fcb561a1/attachment.html>


More information about the webkit-dev mailing list