Changeset 63631 in webkit


Ignore:
Timestamp:
Jul 18, 2010 2:33:58 PM (14 years ago)
Author:
andersca@apple.com
Message:

Add NPJSObjectMap class
https://bugs.webkit.org/show_bug.cgi?id=42524

Reviewed by Sam Weinig.

WebCore:

Export ScriptController functions.

  • WebCore.exp.in:

WebKit2:

  • WebKit2.xcodeproj/project.pbxproj:

Add files.

  • WebProcess/Plugins/NPJSObjectMap.cpp: Added.
  • WebProcess/Plugins/NPJSObjectMap.h: Added.

Add NPJSObjectMap, a map which contains NPObjects that wrap JavaScript objects.

  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::PluginView):
Initialize the map.

(WebKit::PluginView::~PluginView):
Invalidate the map.

(WebKit::PluginView::frame):
Add frame getter.

(WebKit::PluginView::windowScriptNPObject):
Wrap the window object.

(WebKit::PluginView::pluginElementNPObject):
Wrap the plug-in element object.

  • WebProcess/Plugins/PluginView.h:
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r63628 r63631  
     12010-07-18  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Add NPJSObjectMap class
     6        https://bugs.webkit.org/show_bug.cgi?id=42524
     7
     8        Export ScriptController functions.
     9
     10        * WebCore.exp.in:
     11
    1122010-07-18  Anders Carlsson  <andersca@apple.com>
    213
  • trunk/WebCore/WebCore.exp.in

    r63628 r63631  
    381381__ZN7WebCore16ScriptController11createWorldEv
    382382__ZN7WebCore16ScriptController13executeScriptERKNS_6StringEbNS_14ShouldAllowXSSE
     383__ZN7WebCore16ScriptController17canExecuteScriptsENS_33ReasonForCallingCanExecuteScriptsE
    383384__ZN7WebCore16ScriptController18windowScriptObjectEv
    384385__ZN7WebCore16ScriptController20executeScriptInWorldEPNS_15DOMWrapperWorldERKNS_6StringEbNS_14ShouldAllowXSSE
     386__ZN7WebCore16ScriptController24jsObjectForPluginElementEPNS_17HTMLPlugInElementE
    385387__ZN7WebCore16ThreadGlobalData10staticDataE
    386388__ZN7WebCore16ThreadGlobalDataC1Ev
     
    12231225__ZN3JSC8Bindings8InstanceC2EN3WTF10PassRefPtrINS0_10RootObjectEEE
    12241226__ZN3JSC8Bindings8InstanceD2Ev
    1225 __ZN7WebCore13IdentifierRep3getEPKc
    1226 __ZN7WebCore13IdentifierRep3getEi
    12271227__ZN7WebCore13IdentifierRep7isValidEPS0_
    12281228__ZN7WebCore16ScriptController16createRootObjectEPv
    1229 __ZN7WebCore16ScriptController17canExecuteScriptsENS_33ReasonForCallingCanExecuteScriptsE
    1230 __ZN7WebCore16ScriptController24jsObjectForPluginElementEPNS_17HTMLPlugInElementE
    12311229__ZNK3JSC8Bindings13RuntimeObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
    12321230__ZTVN3JSC13RuntimeMethodE
  • trunk/WebKit2/ChangeLog

    r63630 r63631  
     12010-07-18  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Add NPJSObjectMap class
     6        https://bugs.webkit.org/show_bug.cgi?id=42524
     7
     8        * WebKit2.xcodeproj/project.pbxproj:
     9        Add files.
     10
     11        * WebProcess/Plugins/NPJSObjectMap.cpp: Added.
     12        * WebProcess/Plugins/NPJSObjectMap.h: Added.
     13        Add NPJSObjectMap, a map which contains NPObjects that wrap JavaScript objects.
     14
     15        * WebProcess/Plugins/PluginView.cpp:
     16        (WebKit::PluginView::PluginView):
     17        Initialize the map.
     18
     19        (WebKit::PluginView::~PluginView):
     20        Invalidate the map.
     21
     22        (WebKit::PluginView::frame):
     23        Add frame getter.
     24
     25        (WebKit::PluginView::windowScriptNPObject):
     26        Wrap the window object.
     27
     28        (WebKit::PluginView::pluginElementNPObject):
     29        Wrap the plug-in element object.
     30
     31        * WebProcess/Plugins/PluginView.h:
     32
    1332010-07-18  Anders Carlsson  <andersca@apple.com>
    234
  • trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r63630 r63631  
    3333                1A10475A110A5AD500A43ECD /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */; };
    3434                1A1C4EC810D06099005E67E7 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
     35                1A2161B011F37664008AD0F5 /* NPJSObjectMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2161AE11F37664008AD0F5 /* NPJSObjectMap.h */; };
     36                1A2161B111F37664008AD0F5 /* NPJSObjectMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2161AF11F37664008AD0F5 /* NPJSObjectMap.cpp */; };
    3537                1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */; };
    3638                1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */; };
     
    300302                0F52667311DD4A490006D33C /* WebProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessProxyMac.mm; sourceTree = "<group>"; };
    301303                1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
     304                1A2161AE11F37664008AD0F5 /* NPJSObjectMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPJSObjectMap.h; sourceTree = "<group>"; };
     305                1A2161AF11F37664008AD0F5 /* NPJSObjectMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPJSObjectMap.cpp; sourceTree = "<group>"; };
    302306                1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeUtilities.cpp; sourceTree = "<group>"; };
    303307                1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRuntimeUtilities.h; sourceTree = "<group>"; };
     
    653657                                1A6FB7E511E6530500DB1371 /* DummyPlugin.cpp */,
    654658                                1A6FB7E411E6530500DB1371 /* DummyPlugin.h */,
     659                                1A2161AF11F37664008AD0F5 /* NPJSObjectMap.cpp */,
     660                                1A2161AE11F37664008AD0F5 /* NPJSObjectMap.h */,
    655661                                1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */,
    656662                                1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */,
     
    12411247                                BC2E6E8C1141971500A63B1E /* WorkItem.h in Headers */,
    12421248                                BC2E6E8E1141971500A63B1E /* WorkQueue.h in Headers */,
     1249                                1A2161B011F37664008AD0F5 /* NPJSObjectMap.h in Headers */,
    12431250                                1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */,
    12441251                        );
     
    14321439                                BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */,
    14331440                                BC0092F8115837A300E0AE2A /* WorkQueueMac.cpp in Sources */,
     1441                                1A2161B111F37664008AD0F5 /* NPJSObjectMap.cpp in Sources */,
    14341442                                1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */,
    14351443                        );
  • trunk/WebKit2/WebProcess/Plugins/PluginView.cpp

    r63629 r63631  
    3838#include <WebCore/ScrollView.h>
    3939
     40using namespace JSC;
    4041using namespace WebCore;
    4142
     
    211212    , m_isWaitingUntilMediaCanStart(false)
    212213    , m_pendingURLRequestsTimer(RunLoop::main(), this, &PluginView::pendingURLRequestsTimerFired)
     214    , m_npJSObjectMap(this)
    213215{
    214216}
     
    227229        m_plugin->destroy();
    228230
     231    // Invalidate the NPObject map.
     232    m_npJSObjectMap.invalidate();
     233
    229234    // Cancel all streams.
    230235    cancelAllStreams();
     236}
     237
     238Frame* PluginView::frame()
     239{
     240    return m_pluginElement->document()->frame();
    231241}
    232242
     
    534544NPObject* PluginView::windowScriptNPObject()
    535545{
    536     // FIXME: Implement.
    537     return 0;
     546    if (!frame())
     547        return 0;
     548
     549    // FIXME: Handle JavaScript being disabled.
     550    ASSERT(frame()->script()->canExecuteScripts(NotAboutToExecuteScript));
     551
     552    return m_npJSObjectMap.getOrCreateObject(frame()->script()->windowShell(pluginWorld())->window());
    538553}
    539554
    540555NPObject* PluginView::pluginElementNPObject()
    541556{
    542     // FIXME: Implement.
    543     return 0;
     557    if (!frame())
     558        return 0;
     559
     560    // FIXME: Handle JavaScript being disabled.
     561    JSObject* object = frame()->script()->jsObjectForPluginElement(m_pluginElement);
     562    ASSERT(object);
     563
     564    return m_npJSObjectMap.getOrCreateObject(object);
    544565}
    545566
  • trunk/WebKit2/WebProcess/Plugins/PluginView.h

    r63629 r63631  
    2727#define PluginView_h
    2828
     29#include "NPJSObjectMap.h"
    2930#include "Plugin.h"
    3031#include "PluginController.h"
     
    3940
    4041namespace WebCore {
     42    class Frame;
    4143    class HTMLPlugInElement;
    4244}
     
    5052        return adoptRef(new PluginView(pluginElement, plugin, parameters));
    5153    }
     54
     55    WebCore::Frame* frame();
    5256
    5357private:
     
    115119    // Streams that the plug-in has requested to load.
    116120    HashMap<uint64_t, RefPtr<Stream> > m_streams;
     121
     122    // NPObjects wrapping JavaScript objects.
     123    NPJSObjectMap m_npJSObjectMap;
    117124};
    118125
Note: See TracChangeset for help on using the changeset viewer.