Changeset 64154 in webkit


Ignore:
Timestamp:
Jul 27, 2010 1:55:29 PM (14 years ago)
Author:
andersca@apple.com
Message:

Expose interface for returning the plug-in script JSObject
https://bugs.webkit.org/show_bug.cgi?id=43074

Reviewed by Sam Weinig.

WebCore:

PluginViewBase::scriptObject should be a virtual function.

  • plugins/PluginViewBase.h:

(WebCore::PluginViewBase::scriptObject):

WebKit2:

  • WebProcess/Plugins/NPRuntimeObjectMap.cpp:

(WebKit::NPRuntimeObjectMap::getOrCreateJSObject):
Add empty stub.

  • WebProcess/Plugins/NPRuntimeObjectMap.h:
  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

(WebKit::NetscapePlugin::pluginScriptableNPObject):
Ask the plug-in for it's scriptable NPObject.

  • WebProcess/Plugins/Netscape/NetscapePlugin.h:
  • WebProcess/Plugins/Plugin.h:

Add pluginScritableNPObject.

  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::PluginView):
Call PluginViewBase constructor.

(WebKit::PluginView::scriptObject):
Ask the plug-in for its scriptable object and wrap it.

  • WebProcess/Plugins/PluginView.h:

PluginView now inherits from PluginViewBase.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64152 r64154  
     12010-07-27  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Expose interface for returning the plug-in script JSObject
     6        https://bugs.webkit.org/show_bug.cgi?id=43074
     7
     8        PluginViewBase::scriptObject should be a virtual function.
     9
     10        * plugins/PluginViewBase.h:
     11        (WebCore::PluginViewBase::scriptObject):
     12
    1132010-07-27  Jian Li  <jianli@chromium.org>
    214
  • trunk/WebCore/plugins/PluginViewBase.h

    r64093 r64154  
    4545#endif
    4646
    47     JSC::JSObject* scriptObject(JSC::ExecState*, JSC::JSGlobalObject*) { return 0; }
     47    virtual JSC::JSObject* scriptObject(JSC::ExecState*, JSC::JSGlobalObject*) { return 0; }
    4848
    4949protected:
  • trunk/WebKit2/ChangeLog

    r64147 r64154  
     12010-07-27  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Expose interface for returning the plug-in script JSObject
     6        https://bugs.webkit.org/show_bug.cgi?id=43074
     7
     8        * WebProcess/Plugins/NPRuntimeObjectMap.cpp:
     9        (WebKit::NPRuntimeObjectMap::getOrCreateJSObject):
     10        Add empty stub.
     11
     12        * WebProcess/Plugins/NPRuntimeObjectMap.h:
     13        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     14        (WebKit::NetscapePlugin::pluginScriptableNPObject):
     15        Ask the plug-in for it's scriptable NPObject.
     16
     17        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     18        * WebProcess/Plugins/Plugin.h:
     19        Add pluginScritableNPObject.
     20
     21        * WebProcess/Plugins/PluginView.cpp:
     22        (WebKit::PluginView::PluginView):
     23        Call PluginViewBase constructor.
     24
     25        (WebKit::PluginView::scriptObject):
     26        Ask the plug-in for its scriptable object and wrap it.
     27
     28        * WebProcess/Plugins/PluginView.h:
     29        PluginView now inherits from PluginViewBase.
     30
    1312010-07-27  Anders Carlsson  <andersca@apple.com>
    232
  • trunk/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp

    r64147 r64154  
    6363}
    6464
     65JSObject* NPRuntimeObjectMap::getOrCreateJSObject(NPObject*, ExecState*, JSGlobalObject*)
     66{
     67    // FIXME: Implement.
     68    return 0;
     69}
     70
    6571void NPRuntimeObjectMap::invalidate()
    6672{
  • trunk/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h

    r64147 r64154  
    3333namespace JSC {
    3434    class ExecState;
     35    class JSGlobalObject;
    3536    class JSObject;
    3637}
     
    4647    explicit NPRuntimeObjectMap(PluginView*);
    4748
    48     // Returns an NPObject that wraps the given JavaScript object. If there is already an NPObject that wraps this JSObject, it will
     49    // Returns an NPObject that wraps the given JSObject object. If there is already an NPObject that wraps this JSObject, it will
    4950    // retain it and return it.
    5051    NPObject* getOrCreateNPObject(JSC::JSObject*);
    5152
    5253    void npJSObjectDestroyed(NPJSObject*);
     54
     55    // Returns a JSObject object that wraps the given NPObject.
     56    JSC::JSObject* getOrCreateJSObject(NPObject*, JSC::ExecState*, JSC::JSGlobalObject*);
     57
    5358
    5459    // Called when the plug-in is destroyed. Will invalidate all the NPObjects.
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r64073 r64154  
    439439}
    440440
     441NPObject* NetscapePlugin::pluginScriptableNPObject()
     442{
     443    NPObject* scriptableNPObject = 0;
     444   
     445    if (NPP_GetValue(NPPVpluginScriptableNPObject, &scriptableNPObject) != NPERR_NO_ERROR)
     446        return 0;
     447   
     448    return scriptableNPObject;
     449}
     450
    441451PluginController* NetscapePlugin::controller()
    442452{
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r64076 r64154  
    117117    virtual bool handleMouseLeaveEvent(const WebMouseEvent&);
    118118    virtual void setFocus(bool);
     119    virtual NPObject* pluginScriptableNPObject();
    119120
    120121    virtual PluginController* controller();
  • trunk/WebKit2/WebProcess/Plugins/Plugin.h

    r64073 r64154  
    3030#include <wtf/RefCounted.h>
    3131#include <wtf/Vector.h>
     32
     33struct NPObject;
    3234
    3335namespace WebCore {
     
    105107    virtual void setFocus(bool) = 0;
    106108
     109    // Get the NPObject that corresponds to the plug-in's scriptable object. Returns a retained object.
     110    virtual NPObject* pluginScriptableNPObject() = 0;
     111
    107112    // Returns the plug-in controller for this plug-in.
    108113    // FIXME: We could just have the controller be a member variable of Plugin.
  • trunk/WebKit2/WebProcess/Plugins/PluginView.cpp

    r64145 r64154  
    2626#include "PluginView.h"
    2727
     28#include "NPRuntimeUtilities.h"
    2829#include "Plugin.h"
    2930#include "WebEvent.h"
     
    210211
    211212PluginView::PluginView(WebCore::HTMLPlugInElement* pluginElement, PassRefPtr<Plugin> plugin, const Plugin::Parameters& parameters)
    212     : m_pluginElement(pluginElement)
     213    : PluginViewBase(0)
     214    , m_pluginElement(pluginElement)
    213215    , m_plugin(plugin)
    214216    , m_parameters(parameters)
     
    280282}
    281283
     284JSObject* PluginView::scriptObject(ExecState* exec, JSGlobalObject* globalObject)
     285{
     286    NPObject* scriptableNPObject = m_plugin->pluginScriptableNPObject();
     287    if (!scriptableNPObject)
     288        return 0;
     289
     290    JSObject* jsObject = m_npRuntimeObjectMap.getOrCreateJSObject(scriptableNPObject, exec, globalObject);
     291    releaseNPObject(scriptableNPObject);
     292
     293    return jsObject;
     294}
     295
    282296void PluginView::setFrameRect(const WebCore::IntRect& rect)
    283297{
  • trunk/WebKit2/WebProcess/Plugins/PluginView.h

    r64145 r64154  
    3434
    3535#include <WebCore/MediaCanStartListener.h>
    36 #include <WebCore/Widget.h>
     36#include <WebCore/PluginViewBase.h>
    3737#include <wtf/Deque.h>
    3838
     
    4646namespace WebKit {
    4747
    48 class PluginView : public WebCore::Widget, WebCore::MediaCanStartListener, PluginController, WebFrame::LoadListener {
     48class PluginView : public WebCore::PluginViewBase, WebCore::MediaCanStartListener, PluginController, WebFrame::LoadListener {
    4949public:
    5050    static PassRefPtr<PluginView> create(WebCore::HTMLPlugInElement* pluginElement, PassRefPtr<Plugin> plugin, const Plugin::Parameters& parameters)
     
    8181    void cancelAllStreams();
    8282
     83    // WebCore::PluginViewBase
     84    virtual JSC::JSObject* scriptObject(JSC::ExecState*, JSC::JSGlobalObject*);
     85   
    8386    // WebCore::Widget
    8487    virtual void setFrameRect(const WebCore::IntRect&);
Note: See TracChangeset for help on using the changeset viewer.