NPAPI:Models: Difference between revisions

Jump to navigation Jump to search
1,340 bytes added ,  22 April 2010
(Created page with '= Status = Accepted. = Problem Summary = In order to allow revised event and drawing APIs, NPAPI now includes the concept of event and drawing models. Plugins can negotiate wi…')
 
Line 20: Line 20:
* Core Graphics drawing model: NPNVsupportsCoreGraphicsBool
* Core Graphics drawing model: NPNVsupportsCoreGraphicsBool


There will be platform-specific default event and drawing models, which may not have a named designation for legacy reasons. When there is no designation, plugins can assume support for the default model exists. Major current defaults are:
There will be platform-specific default event and drawing models, which may not have a named designation for legacy reasons. When there is no designation, plugins can assume support for the default model exists.
 
Plugins may select their drawing and event models from those that the browser supports on a per-instance basis during NPP_New. Changing models outside of NPP_New is not allowed. Event and drawing models are selected by calling NPN_SetValue and setting the NPPVpluginEventModel and NPPVpluginDrawingModel variables to the desired values.
 
An example of drawing model negotiation, in which the plugin requires the Core Graphics drawing model:
 
static NPError NPP_New(NPMIMEType pluginType, NPP instance,
                        uint16 mode, int16 argc, char* argn[],
                        char* argv[], NPSavedData* saved)
{
    // Check if the browser supports the CoreGraphics drawing model
    NPBool supportsCoreGraphics = FALSE;
    NPError err = browser->getvalue(instance,
                                    NPNVsupportsCoreGraphicsBool,
                                    &supportsCoreGraphics);
    if (err != NPERR_NO_ERROR || !supportsCoreGraphics)
        return NPERR_INCOMPATIBLE_VERSION_ERROR;<br>
    // Set the drawing model
    err = browser->setvalue(instance,
                            NPNVpluginDrawingModel,
                            (void*)NPDrawingModelCoreGraphics);
    if (err != NPERR_NO_ERROR)
        return NPERR_INCOMPATIBLE_VERSION_ERROR;<br>
    return NPERR_NO_ERROR;
}
 
==== Per-platform Default Models ====


* Windows (all versions)
* Windows (all versions)
Confirmed users, Bureaucrats and Sysops emeriti
1,680

edits

Navigation menu