Changeset 63000 in webkit


Ignore:
Timestamp:
Jul 9, 2010 3:07:50 PM (14 years ago)
Author:
andersca@apple.com
Message:

Handle setting of drawing and event models
https://bugs.webkit.org/show_bug.cgi?id=41994

Reviewed by Sam Weinig and Dan Bernstein.

  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:

Handle NPPVpluginDrawingModel and NPPVpluginEventModel.

  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_inNPPNew.

(WebKit::NetscapePlugin::~NetscapePlugin):
Assert that we aren't still running.

(WebKit::NetscapePlugin::fromNPP):
New function that returns a NetscapePlugin object given a NPP pointer.

(WebKit::NetscapePlugin::initialize):

  • WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp:

(WebKit::NetscapePlugin::setDrawingModel):
Set the drawing model.

(WebKit::NetscapePlugin::setEventModel):
Set the event model.

(WebKit::initializeEvent):
(WebKit::NetscapePlugin::platformPaint):
Only send the Cocoa event when using the Cocoa event model.

Location:
trunk/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r62996 r63000  
     12010-07-09  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig and Dan Bernstein.
     4
     5        Handle setting of drawing and event models
     6        https://bugs.webkit.org/show_bug.cgi?id=41994
     7
     8        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     9        Handle NPPVpluginDrawingModel and NPPVpluginEventModel.
     10
     11        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     12        (WebKit::NetscapePlugin::NetscapePlugin):
     13        Initialize m_inNPPNew.
     14
     15        (WebKit::NetscapePlugin::~NetscapePlugin):
     16        Assert that we aren't still running.
     17
     18        (WebKit::NetscapePlugin::fromNPP):
     19        New function that returns a NetscapePlugin object given a NPP pointer.
     20
     21        (WebKit::NetscapePlugin::initialize):
     22        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp:
     23        (WebKit::NetscapePlugin::setDrawingModel):
     24        Set the drawing model.
     25
     26        (WebKit::NetscapePlugin::setEventModel):
     27        Set the event model.
     28
     29        (WebKit::initializeEvent):
     30        (WebKit::NetscapePlugin::platformPaint):
     31        Only send the Cocoa event when using the Cocoa event model.
     32
    1332010-07-09  Sam Weinig  <sam@webkit.org>
    234
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r62964 r63000  
    2626#include "NetscapeBrowserFuncs.h"
    2727
     28#include "NetscapePlugin.h"
    2829#include "NotImplemented.h"
    2930
     
    223224}
    224225
    225 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
    226 {
    227     notImplemented();
    228     return NPERR_GENERIC_ERROR;
     226NPError NPN_SetValue(NPP npp, NPPVariable variable, void *value)
     227{
     228    switch (variable) {
     229#if PLATFORM(MAC)
     230        case NPPVpluginDrawingModel: {
     231            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     232           
     233            NPDrawingModel drawingModel = static_cast<NPDrawingModel>(reinterpret_cast<uintptr_t>(value));
     234            return plugin->setDrawingModel(drawingModel);
     235        }
     236
     237        case NPPVpluginEventModel: {
     238            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     239           
     240            NPEventModel eventModel = static_cast<NPEventModel>(reinterpret_cast<uintptr_t>(value));
     241            return plugin->setEventModel(eventModel);
     242        }
     243#endif
     244
     245        default:
     246            notImplemented();
     247            return NPERR_GENERIC_ERROR;
     248    }
     249   
     250    return NPERR_NO_ERROR;
    229251}
    230252
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r62993 r63000  
    3737    , m_npWindow()
    3838    , m_isStarted(false)
     39    , m_inNPPNew(false)
    3940#if PLATFORM(MAC)
    4041    , m_drawingModel(static_cast<NPDrawingModel>(-1))
     
    4849NetscapePlugin::~NetscapePlugin()
    4950{
     51    ASSERT(!m_isStarted);
     52}
     53
     54PassRefPtr<NetscapePlugin> NetscapePlugin::fromNPP(NPP npp)
     55{
     56    if (npp) {
     57        NetscapePlugin* plugin = static_cast<NetscapePlugin*>(npp->ndata);
     58        ASSERT(npp == &plugin->m_npp);
     59       
     60        return plugin;
     61    }
     62
     63    // FIXME: Return the current NetscapePlugin here.
     64    ASSERT_NOT_REACHED();
     65    return 0;
    5066}
    5167
     
    6884    uint16_t mode = loadManually ? NP_FULL : NP_EMBED;
    6985   
     86    m_inNPPNew = true;
     87
    7088    // FIXME: Pass arguments to NPP_New.
    7189    NPError error = m_pluginModule->pluginFuncs().newp(0, &m_npp, mode, 0, 0, 0, 0);
     90
     91    m_inNPPNew = false;
     92
    7293    if (error != NPERR_NO_ERROR)
    7394        return false;
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r62993 r63000  
    4141    virtual ~NetscapePlugin();
    4242
     43    static PassRefPtr<NetscapePlugin> fromNPP(NPP);
     44
     45#if PLATFORM(MAC)
     46    NPError setDrawingModel(NPDrawingModel);
     47    NPError setEventModel(NPEventModel);
     48#endif
     49
    4350private:
    4451    NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule);
     
    6370   
    6471    bool m_isStarted;
     72    bool m_inNPPNew;
    6573
    6674#if PLATFORM(MAC)
  • trunk/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp

    r62993 r63000  
    3131
    3232namespace WebKit {
     33
     34NPError NetscapePlugin::setDrawingModel(NPDrawingModel drawingModel)
     35{
     36    // The drawing model can only be set from NPP_New.
     37    if (!m_inNPPNew)
     38        return NPERR_GENERIC_ERROR;
     39
     40    switch (drawingModel) {
     41#ifndef NP_NO_QUICKDRAW
     42        case NPDrawingModelQuickDraw:
     43#endif
     44        case NPDrawingModelCoreGraphics:
     45        case NPDrawingModelCoreAnimation:
     46            m_drawingModel = drawingModel;
     47            break;
     48
     49        default:
     50            return NPERR_GENERIC_ERROR;
     51    }
     52
     53    return NPERR_NO_ERROR;
     54}
     55   
     56NPError NetscapePlugin::setEventModel(NPEventModel eventModel)
     57{
     58    // The event model can only be set from NPP_New.
     59    if (!m_inNPPNew)
     60        return NPERR_GENERIC_ERROR;
     61
     62    switch (eventModel) {
     63#ifndef NP_NO_CARBON
     64        case NPEventModelCarbon:
     65#endif
     66        case NPEventModelCocoa:
     67            m_eventModel = eventModel;
     68            break;
     69
     70        default:
     71            return NPERR_GENERIC_ERROR;
     72    }
     73   
     74    return NPERR_NO_ERROR;
     75}
    3376
    3477bool NetscapePlugin::platformPostInitialize()
     
    72115}
    73116
     117static inline NPCocoaEvent initializeEvent(NPCocoaEventType type)
     118{
     119    NPCocoaEvent event;
     120   
     121    event.type = type;
     122    event.version = 0;
     123   
     124    return event;
     125}
     126
    74127void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect)
    75128{
    76     NPCocoaEvent event;
    77     event.type = NPCocoaEventDrawRect;
    78     event.version = 0;
    79     event.data.draw.context = context->platformContext();
    80     event.data.draw.x = dirtyRect.x() - m_frameRect.x();
    81     event.data.draw.y = dirtyRect.y() - m_frameRect.y();
    82     event.data.draw.width = dirtyRect.width();
    83     event.data.draw.height = dirtyRect.height();
     129    switch (m_eventModel) {
     130        case NPEventModelCocoa: {
     131            NPCocoaEvent event = initializeEvent(NPCocoaEventDrawRect);
    84132
    85     m_pluginModule->pluginFuncs().event(&m_npp, &event);
     133            event.data.draw.context = context->platformContext();
     134            event.data.draw.x = dirtyRect.x() - m_frameRect.x();
     135            event.data.draw.y = dirtyRect.y() - m_frameRect.y();
     136            event.data.draw.width = dirtyRect.width();
     137            event.data.draw.height = dirtyRect.height();
     138           
     139            m_pluginModule->pluginFuncs().event(&m_npp, &event);
     140            break;
     141        }
     142       
     143        default:
     144            ASSERT_NOT_REACHED();
     145    }
    86146}
    87147
Note: See TracChangeset for help on using the changeset viewer.