Skip to content
Permalink
Browse files
Implement more NPRuntime related NPN_ functions
https://bugs.webkit.org/show_bug.cgi?id=42520

Reviewed by Sam Weinig.

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/Plugins/NPRuntimeUtilities.cpp: Added.
* WebProcess/Plugins/NPRuntimeUtilities.h: Added.
Add new file with NPRuntime related utility functions.

* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_CreateObject):
(WebKit::NPN_RetainObject):
(WebKit::NPN_ReleaseObject):
Call the corresponding NPRuntimeUtilities functions.

Canonical link: https://commits.webkit.org/54470@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Jul 18, 2010
1 parent 823d843 commit 3e581a6b1055d2f659a973d7de11991c6706e04e
@@ -1,3 +1,21 @@
2010-07-18 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

Implement more NPRuntime related NPN_ functions
https://bugs.webkit.org/show_bug.cgi?id=42520

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/Plugins/NPRuntimeUtilities.cpp: Added.
* WebProcess/Plugins/NPRuntimeUtilities.h: Added.
Add new file with NPRuntime related utility functions.

* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_CreateObject):
(WebKit::NPN_RetainObject):
(WebKit::NPN_ReleaseObject):
Call the corresponding NPRuntimeUtilities functions.

2010-07-18 Anders Carlsson <andersca@apple.com>

Reviewed by Dan Bernstein.
@@ -32,6 +32,8 @@
0F52667411DD4A490006D33C /* WebProcessProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F52667311DD4A490006D33C /* WebProcessProxyMac.mm */; };
1A10475A110A5AD500A43ECD /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */; };
1A1C4EC810D06099005E67E7 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */; };
1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */; };
1A30066E1110F4F70031937C /* ResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A30066C1110F4F70031937C /* ResponsivenessTimer.h */; };
1A30EAC6115D7DA30053E937 /* ConnectionMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A30EAC5115D7DA30053E937 /* ConnectionMac.cpp */; };
1A3E736111CC2659007BD539 /* WebPlatformStrategies.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3E735F11CC2659007BD539 /* WebPlatformStrategies.h */; };
@@ -297,6 +299,8 @@
0F5265BB11DD37860006D33C /* LayerBackedDrawingAreaProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LayerBackedDrawingAreaProxyMac.mm; sourceTree = "<group>"; };
0F52667311DD4A490006D33C /* WebProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessProxyMac.mm; sourceTree = "<group>"; };
1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeUtilities.cpp; sourceTree = "<group>"; };
1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRuntimeUtilities.h; sourceTree = "<group>"; };
1A30066C1110F4F70031937C /* ResponsivenessTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResponsivenessTimer.h; sourceTree = "<group>"; };
1A30EAC5115D7DA30053E937 /* ConnectionMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConnectionMac.cpp; sourceTree = "<group>"; };
1A3E735F11CC2659007BD539 /* WebPlatformStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlatformStrategies.h; sourceTree = "<group>"; };
@@ -648,6 +652,8 @@
1A6FB90811E66FB100DB1371 /* Netscape */,
1A6FB7E511E6530500DB1371 /* DummyPlugin.cpp */,
1A6FB7E411E6530500DB1371 /* DummyPlugin.h */,
1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */,
1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */,
1A6FB7D011E651E200DB1371 /* Plugin.cpp */,
1A6FB7D111E651E200DB1371 /* Plugin.h */,
1AA56F2811E92BC80061B882 /* PluginController.h */,
@@ -1234,6 +1240,7 @@
BC8699B7116AADAA002A925B /* WKViewInternal.h in Headers */,
BC2E6E8C1141971500A63B1E /* WorkItem.h in Headers */,
BC2E6E8E1141971500A63B1E /* WorkQueue.h in Headers */,
1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1424,6 +1431,7 @@
BC8699B6116AADAA002A925B /* WKView.mm in Sources */,
BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */,
BC0092F8115837A300E0AE2A /* WorkQueueMac.cpp in Sources */,
1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,85 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "NPRuntimeUtilities.h"

namespace WebKit {

NPObject* createNPObject(NPP npp, NPClass* npClass)
{
ASSERT(npClass);

NPObject* npObject;
if (npClass->allocate)
npObject = npClass->allocate(npp, npClass);
else {
// This should really call NPN_MemAlloc, but we know that it uses malloc
// under the hood so it's fine.
npObject = static_cast<NPObject*>(malloc(sizeof(NPObject)));
}

npObject->_class = npClass;
npObject->referenceCount = 1;

return npObject;
}

void deallocateNPObject(NPObject* npObject)
{
ASSERT(npObject);
if (!npObject)
return;

if (npObject->_class->deallocate)
npObject->_class->deallocate(npObject);
else {
// This should really call NPN_MemFree, but we know that it uses free
// under the hood so it's fine.
free(npObject);
}
}

void retainNPObject(NPObject* npObject)
{
ASSERT(npObject);
if (!npObject)
return;

npObject->referenceCount++;
}

void releaseNPObject(NPObject* npObject)
{
ASSERT(npObject);
if (!npObject)
return;

ASSERT(npObject->referenceCount >= 1);
npObject->referenceCount--;
if (!npObject->referenceCount)
deallocateNPObject(npObject);
}

} // namespace WebKit
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef NPRuntimeUtilities_h
#define NPRuntimeUtilities_h

#include <WebCore/npruntime.h>

struct NPClass;
struct NPObject;

namespace WebKit {

NPObject* createNPObject(NPP, NPClass*);
void deallocateNPObject(NPObject*);

void retainNPObject(NPObject*);
void releaseNPObject(NPObject*);

}

#endif // NPRuntimeUtilities_h
@@ -25,6 +25,7 @@

#include "NetscapeBrowserFuncs.h"

#include "NPRuntimeUtilities.h"
#include "NetscapePlugin.h"
#include "NotImplemented.h"
#include <WebCore/IdentifierRep.h>
@@ -277,29 +278,18 @@ static int32_t NPN_IntFromIdentifier(NPIdentifier identifier)

static NPObject* NPN_CreateObject(NPP npp, NPClass *npClass)
{
ASSERT(npClass);

NPObject* object;
if (npClass->allocate)
object = npClass->allocate(npp, npClass);
else
object = static_cast<NPObject*>(NPN_MemAlloc(sizeof(NPObject)));

object->_class = npClass;
object->referenceCount = 1;

return object;
return createNPObject(npp, npClass);
}

static NPObject *NPN_RetainObject(NPObject *npobj)
static NPObject *NPN_RetainObject(NPObject *npObject)
{
notImplemented();
return 0;
retainNPObject(npObject);
return npObject;
}

static void NPN_ReleaseObject(NPObject *npobj)
static void NPN_ReleaseObject(NPObject *npObject)
{
notImplemented();
releaseNPObject(npObject);
}

static bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result)

0 comments on commit 3e581a6

Please sign in to comment.