Ignore:
Timestamp:
May 15, 2006, 5:04:57 PM (19 years ago)
Author:
tomernic
Message:

JavaScriptCore:

Reviewed by John Sullivan.

Part of <rdar://problem/4466508> Add 64-bit support to the Netscape Plugin API

Added to the Netscape Plugin API the concept of "plugin drawing models". The drawing model
determines the kind of graphics context created by the browser for the plugin, as well as
the Mac types of various Netscape Plugin API data structures.

There is a drawing model to represent the old QuickDraw-based API. It is used by default
if QuickDraw is available on the system, unless the plugin specifies another drawing model.

The big change is the addition of the CoreGraphics drawing model. A plugin may request this
drawing model to obtain access to a CGContextRef for drawing, instead of a QuickDraw CGrafPtr.

  • bindings/npapi.h: Define NP_NO_QUICKDRAW when compiling 64-bit; there is no 64-bit QuickDraw. Added NPNVpluginDrawingModel, NPNVsupportsQuickDrawBool, and NPNVsupportsCoreGraphicsBool variables. Added NPDrawingModel enumeration. Currently the only drawing models are QuickDraw and CoreGraphics. NPRegion's type now depends on the drawing model specified by the plugin. NP_Port is now only defined when QuickDraw is available. Added NP_CGContext, which is the type of the NPWindow's "window" member in CoreGraphics mode.

WebKit:

Reviewed by John Sullivan.

Part of <rdar://problem/4466508> Add 64-bit support to the Netscape Plugin API

Added to the Netscape Plugin API the concept of "plugin drawing models". The drawing model
determines the kind of graphics context created by the browser for the plugin, as well as
the Mac types of various Netscape Plugin API data structures.

There is a drawing model to represent the old QuickDraw-based API. It is used by default
if QuickDraw is available on the system, unless the plugin specifies another drawing model.

The big change is the addition of the CoreGraphics drawing model. A plugin may request this
drawing model to obtain access to a CGContextRef for drawing, instead of a QuickDraw CGrafPtr.

  • Plugins/WebBaseNetscapePluginView.h: Added PluginPort union, which wraps a NP_Port and a NP_CGContext. This is to make access to the nPort and lastSetPort ivars more convenient now that the port type differs based on the drawing model. Changed types of nPort and lastSetPort to PluginPort so they can be used with any drawing model. Added drawingModel ivar.
  • Plugins/WebBaseNetscapePluginView.m: Renamed PortState to PortState_QD. PortState is now an opaque pointer. PortState_QD cannot be used if QuickDraw is unavailable. (-[WebBaseNetscapePluginView fixWindowPort]): Cannot be used if QuickDraw is unavailable. (-[WebBaseNetscapePluginView saveAndSetNewPortStateForUpdate:]): Only fix window port if drawing model is QuickDraw. Re-ordered some code so I could group QuickDraw-specific stuff into switch and if blocks (that's why the diff here is so terrible). Now returns a malloc()'ed PortState that the caller is responsible for freeing. Renamed to better reflect this behavior. Support for the CoreGraphics drawing model -- fill PortState_CG struct, save CGContext state. (-[WebBaseNetscapePluginView restorePortState:]): Switch based on drawing model. Support for the CoreGraphics drawing model -- restore CGContext state saved earlier. (-[WebBaseNetscapePluginView sendEvent:]): Formatting. Don't set save/set port state or set the window in CoreGraphics mode unless the event being sent is an updateEvt. We can't provide the plugin with a CGContext outside of our view display cycle. Don't restore PortState if it's NULL (didn't used to be a pointer). Free when we're done with it. (-[WebBaseNetscapePluginView isNewWindowEqualToOldWindow]): Formatting. Switch how we compare ports based on the drawing model. (-[WebBaseNetscapePluginView updateAndSetWindow]): Fixed for CoreGraphics by triggering a redisplay instead of sending an update event to the plugin outside of the view display cycle. Don't restore PortState if it's NULL (didn't used to be a pointer). Free when we're done with it. (-[WebBaseNetscapePluginView setWindowIfNecessary]): Assert that the window is only set when updating in CoreGraphics mode. Log differently depending on the drawing model. (-[WebBaseNetscapePluginView start]): Fall back on QuickDraw if the plugin does not specify a drawing model. (-[WebBaseNetscapePluginView tellQuickTimeToChill]): Cannot be used if QuickDraw is unavailable. (-[WebBaseNetscapePluginView viewWillMoveToWindow:]): Only call -tellQuickTimeToChill in QuickDraw mode. (-[WebBaseNetscapePluginView viewHasMoved:]): ditto (-[WebBaseNetscapePluginView invalidateRegion:]): NPRegion is a CGPathRef in CoreGraphics mode. (-[WebBaseNetscapePluginView getVariable:value:]): Added support for retriveing the NPNVpluginDrawingModel, NPNVsupportsQuickDrawBool, and NPNVsupportsCoreGraphicsBool browser variables. (-[WebBaseNetscapePluginView setVariable:value:]): Added support for setting the NPNVpluginDrawingModel variable.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bindings/npapi.h

    r14246 r14397  
    9191#endif
    9292
     93#if defined(XP_MACOSX) && defined(__LP64__)
     94    #define NP_NO_QUICKDRAW
     95#endif
    9396
    9497/*----------------------------------------------------------------------*/
     
    333336    /* Get the NPObject wrapper for the plugins DOM element. */
    334337    NPNVPluginElementNPObject                 /* Not implemented in WebKit */
     338
     339#ifdef XP_MACOSX
     340    , NPNVpluginDrawingModel = 1000 /* The NPDrawingModel specified by the plugin */
     341
     342#ifndef NP_NO_QUICKDRAW
     343    , NPNVsupportsQuickDrawBool = 2000 /* TRUE if the browser supports the QuickDraw drawing model */
     344#endif
     345    , NPNVsupportsCoreGraphicsBool = 2001 /* TRUE if the browser supports the CoreGraphics drawing model */
     346#endif /* XP_MACOSX */
    335347} NPNVariable;
    336348
     
    343355    NPWindowTypeDrawable
    344356} NPWindowType;
     357
     358#ifdef XP_MACOSX
     359
     360/*
     361 * The drawing model for a Mac OS X plugin.  These are the possible values for the NPNVpluginDrawingModel variable.
     362 */
     363 
     364typedef enum {
     365#ifndef NP_NO_QUICKDRAW
     366    NPDrawingModelQuickDraw = 0,
     367#endif
     368    NPDrawingModelCoreGraphics = 1
     369} NPDrawingModel;
     370
     371#endif
    345372
    346373typedef struct _NPWindow
     
    400427#endif /* XP_MAC */
    401428
    402 #if defined(XP_MAC) || defined(XP_MACOSX)
     429#if defined(XP_MAC)
    403430typedef RgnHandle NPRegion;
     431#elif defined(XP_MACOSX)
     432/*
     433 * NPRegion's type depends on the drawing model specified by the plugin (see NPNVpluginDrawingModel).
     434 * NPQDRegion represents a QuickDraw RgnHandle, and NPCGRegion represents a CoreGraphics CGPathRef.
     435 */
     436typedef void *NPRegion;
     437#ifndef NP_NO_QUICKDRAW
     438typedef RgnHandle NPQDRegion;
     439#endif
     440typedef CGPathRef NPCGRegion;
    404441#elif defined(XP_WIN)
    405442typedef HRGN NPRegion;
     
    410447#endif /* XP_MAC */
    411448
     449#ifdef XP_MACOSX
     450
     451/*
     452 * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics
     453 * as its drawing model.
     454 */
     455
     456typedef struct NP_CGContext
     457{
     458    CGContextRef context;
     459    WindowRef window;
     460} NP_CGContext;
     461
     462#endif /* XP_MACOSX */
     463
    412464#if defined(XP_MAC) || defined(XP_MACOSX)
     465
    413466/*
    414467 *  Mac-specific structures and definitions.
    415468 */
    416469
     470#ifndef NP_NO_QUICKDRAW
     471
     472/*
     473 * NP_Port is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelQuickDraw as its
     474 * drawing model, or the plugin does not specify a drawing model.
     475 *
     476 * It is not recommended that new plugins use NPDrawingModelQuickDraw or NP_Port, as QuickDraw has been
     477 * deprecated in Mac OS X 10.5.  CoreGraphics is the preferred drawing API.
     478 *
     479 * NP_Port is not available in 64-bit.
     480 */
     481 
    417482typedef struct NP_Port
    418483{
     
    421486    int32        porty;
    422487} NP_Port;
     488
     489#endif /* NP_NO_QUICKDRAW */
    423490
    424491/*
Note: See TracChangeset for help on using the changeset viewer.