зеркало из https://github.com/mozilla/gecko-dev.git
pulling changes. The checkin went to the wrong place.
This commit is contained in:
Родитель
303ce25eb2
Коммит
c637ecd828
|
@ -19,39 +19,22 @@
|
|||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE = npdebug
|
||||
REQUIRES= xpcom \
|
||||
dom \
|
||||
necko\
|
||||
string \
|
||||
widget \
|
||||
locale \
|
||||
view \
|
||||
pref \
|
||||
gfx2 \
|
||||
imglib2 \
|
||||
unicharutil \
|
||||
java \
|
||||
debug \
|
||||
$(NULL)
|
||||
|
||||
DEPTH=..\..\..\..\..\..
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
|
||||
|
||||
MODULE = npsimple
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIDebugPlugin.idl \
|
||||
.\nsISimplePlugin.idl \
|
||||
$(NULL)
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = npdebug
|
||||
RESFILE = npdebug.res
|
||||
DEFFILE = npdebug.def
|
||||
DLLNAME = npsimple
|
||||
RESFILE = npsimple.res
|
||||
DEFFILE = npsimple.def
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
CFLAGS = $(CFLAGS) -I.\include
|
||||
CFLAGS = $(CFLAGS) -I..\include -I..\..\include
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\plugin.obj \
|
||||
|
@ -59,8 +42,7 @@ OBJS = \
|
|||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
.\common\$(OBJDIR)\plugingate.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
..\common\$(OBJDIR)\plugingate.lib \
|
||||
$(NULL)
|
||||
|
||||
WIN_LIBS = version.lib
|
||||
|
@ -69,15 +51,13 @@ include <$(DEPTH)\config\rules.mak>
|
|||
|
||||
# don't forget to remove files exported by default
|
||||
libs:: $(DLL)
|
||||
$(RM) $(XPDIST)\idl\nsIDebugPlugin.idl
|
||||
$(RM) $(XPDIST)\include\nsIDebugPlugin.h
|
||||
# $(RM) $(DIST)\bin\components\$(DLLNAME).xpt
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins
|
||||
|
||||
$(RM) $(XPDIST)\idl\nsISimplePlugin.idl
|
||||
$(RM) $(XPDIST)\include\nsISimplePlugin.h
|
||||
$(RM) $(DIST)\bin\components\$(DLLNAME).xpt
|
||||
|
||||
clobber::
|
||||
$(RM) *.sbr
|
||||
$(RM) $(XPDIST)\idl\nsIDebugPlugin.idl
|
||||
$(RM) $(XPDIST)\include\nsIDebugPlugin.h
|
||||
$(RM) $(XPDIST)\idl\nsISimplePlugin.idl
|
||||
$(RM) $(XPDIST)\include\nsISimplePlugin.h
|
||||
$(RM) $(DIST)\bin\components\$(DLLNAME).xpt
|
||||
$(RM) $(DIST)\bin\plugins\$(DLLNAME).dll
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
//
|
||||
#include "plugin.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDebugPluginIID, NS_IDEBUGPLUGIN_IID);
|
||||
static NS_DEFINE_IID(kISimplePluginIID, NS_ISIMPLEPLUGIN_IID);
|
||||
static NS_DEFINE_IID(kIClassInfoIID, NS_ICLASSINFO_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
|
@ -86,8 +86,8 @@ NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstan
|
|||
if(!aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if(aIID.Equals(kIDebugPluginIID)) {
|
||||
*aInstancePtr = static_cast<nsIDebugPlugin*>(this);
|
||||
if(aIID.Equals(kISimplePluginIID)) {
|
||||
*aInstancePtr = static_cast<nsISimplePlugin*>(this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstan
|
|||
}
|
||||
|
||||
if(aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = static_cast<nsISupports*>(static_cast<nsIDebugPlugin*>(this));
|
||||
*aInstancePtr = static_cast<nsISupports*>(static_cast<nsISimplePlugin*>(this));
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -116,38 +116,3 @@ NS_IMETHODIMP nsScriptablePeer::GetVersion(char * *aVersion)
|
|||
mPlugin->getVersion(aVersion);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsScriptablePeer::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName)
|
||||
{
|
||||
|
||||
if (mPlugin)
|
||||
mPlugin->DumpLayout(aWindow,aFilePath,aFileName);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// the following method will be callable from JavaScript
|
||||
//
|
||||
NS_IMETHODIMP nsScriptablePeer::StartDirectorySearch(const char *aFilePath)
|
||||
{
|
||||
|
||||
if (mPlugin)
|
||||
mPlugin->StartDirectorySearch(aFilePath);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsScriptablePeer::GetNextFileInDirectory(char **aFilePath)
|
||||
{
|
||||
|
||||
if (mPlugin)
|
||||
mPlugin->GetNextFileInDirectory(aFilePath);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#ifndef __nsScriptablePeer_h__
|
||||
#define __nsScriptablePeer_h__
|
||||
|
||||
#include "nsIDebugPlugin.h"
|
||||
#include "nsISimplePlugin.h"
|
||||
#include "nsIClassInfo.h"
|
||||
|
||||
class nsPluginInstance;
|
||||
|
@ -78,7 +78,7 @@ class nsClassInfoMixin : public nsIClassInfo
|
|||
{return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
};
|
||||
|
||||
class nsScriptablePeer : public nsIDebugPlugin,
|
||||
class nsScriptablePeer : public nsISimplePlugin,
|
||||
public nsClassInfoMixin
|
||||
{
|
||||
public:
|
||||
|
@ -96,7 +96,7 @@ protected:
|
|||
|
||||
public:
|
||||
// native methods callable from JavaScript
|
||||
NS_DECL_NSIDEBUGPLUGIN
|
||||
NS_DECL_NSISIMPLEPLUGIN
|
||||
|
||||
protected:
|
||||
nsPluginInstance* mPlugin;
|
||||
|
|
|
@ -38,13 +38,6 @@
|
|||
#include "plugin.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIMemory.h"
|
||||
#include "nsIDebugObject.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
// service manager which will give the access to all public browser services
|
||||
// we will use memory service as an illustration
|
||||
|
@ -54,9 +47,9 @@ nsIServiceManager * gServiceManager = NULL;
|
|||
|
||||
// Unix needs this
|
||||
#ifdef XP_UNIX
|
||||
#define MIME_TYPES_HANDLED "application/debug-plugin"
|
||||
#define PLUGIN_NAME "Debug Plugin"
|
||||
#define PLUGIN_DESCRIPTION "Debug Plugin"
|
||||
#define MIME_TYPES_HANDLED "application/simple-plugin"
|
||||
#define PLUGIN_NAME "Simple Plugin Example for Mozilla"
|
||||
#define PLUGIN_DESCRIPTION "Simple Plugin Example for Mozilla"
|
||||
|
||||
char* NPP_GetMIMEDescription(void)
|
||||
{
|
||||
|
@ -172,89 +165,6 @@ void nsPluginInstance::getVersion(char* *aVersion)
|
|||
NS_IF_RELEASE(nsMemoryService);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
void
|
||||
nsPluginInstance::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName)
|
||||
{
|
||||
|
||||
nsIDebugObject *theDebugObject=NULL;
|
||||
|
||||
if (gServiceManager) {
|
||||
// get service using its contract id and use it to allocate the memory
|
||||
gServiceManager->GetServiceByContractID("@mozilla.org/debug/debugobject;1", NS_GET_IID(nsIDebugObject), (void **)&theDebugObject);
|
||||
if(theDebugObject){
|
||||
theDebugObject->DumpContent(aWindow,aFilePath,aFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
void
|
||||
nsPluginInstance::StartDirectorySearch(const char *aFilePath)
|
||||
{
|
||||
nsXPIDLCString dirPath;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> theDir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
rv = NS_InitFileFromURLSpec(theDir, aFilePath);
|
||||
|
||||
if (NS_FAILED(rv)){
|
||||
mIter = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
rv = theDir->GetDirectoryEntries(getter_AddRefs(mIter));
|
||||
if (NS_FAILED(rv)){
|
||||
mIter = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
void
|
||||
nsPluginInstance::GetNextFileInDirectory(char **aDirName)
|
||||
{
|
||||
PRBool hasMore;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
char* URLName;
|
||||
|
||||
*aDirName = 0;
|
||||
if ( 0 ==mIter ){
|
||||
return;
|
||||
}
|
||||
|
||||
while ( NS_SUCCEEDED(mIter->HasMoreElements(&hasMore)) ){
|
||||
rv = mIter->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
nsCOMPtr<nsIFile> dirEntry(do_QueryInterface(supports, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
nsXPIDLCString filePath;
|
||||
char* afilepath;
|
||||
rv = dirEntry->GetPath(&afilepath);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
if( strstr(afilepath,".html") != 0 ) {
|
||||
*aDirName = afilepath;
|
||||
NS_GetURLSpecFromFile(dirEntry,&URLName);
|
||||
*aDirName = URLName;
|
||||
break;
|
||||
} else {
|
||||
nsMemory::Free(afilepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
|
||||
// ==============================
|
||||
// ! Scriptability related code !
|
||||
// ==============================
|
||||
|
@ -271,7 +181,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
|||
switch (aVariable) {
|
||||
case NPPVpluginScriptableInstance: {
|
||||
// addref happens in getter, so we don't addref here
|
||||
nsIDebugPlugin * scriptablePeer = getScriptablePeer();
|
||||
nsISimplePlugin * scriptablePeer = getScriptablePeer();
|
||||
if (scriptablePeer) {
|
||||
*(nsISupports **)aValue = scriptablePeer;
|
||||
} else
|
||||
|
@ -280,7 +190,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
|||
break;
|
||||
|
||||
case NPPVpluginScriptableIID: {
|
||||
static nsIID scriptableIID = NS_IDEBUGPLUGIN_IID;
|
||||
static nsIID scriptableIID = NS_ISIMPLEPLUGIN_IID;
|
||||
nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
|
||||
if (ptr) {
|
||||
*ptr = scriptableIID;
|
||||
|
@ -312,7 +222,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
|||
// ==============================
|
||||
//
|
||||
// this method will return the scriptable object (and create it if necessary)
|
||||
nsIDebugPlugin* nsPluginInstance::getScriptablePeer()
|
||||
nsISimplePlugin* nsPluginInstance::getScriptablePeer()
|
||||
{
|
||||
if (!mScriptablePeer) {
|
||||
mScriptablePeer = new nsScriptablePeer(this);
|
||||
|
|
|
@ -40,9 +40,6 @@
|
|||
|
||||
#include "pluginbase.h"
|
||||
#include "nsScriptablePeer.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
|
||||
class nsPluginInstance : public nsPluginInstanceBase
|
||||
{
|
||||
|
@ -61,17 +58,13 @@ public:
|
|||
|
||||
// locals
|
||||
void getVersion(char* *aVersion);
|
||||
void DumpLayout(nsISupports *aWindow,const PRUnichar *aFilePath, const PRUnichar *aFileName);
|
||||
void StartDirectorySearch(const char *aFilePath);
|
||||
void GetNextFileInDirectory(char **aFilePath);
|
||||
nsIDebugPlugin* getScriptablePeer();
|
||||
|
||||
nsISimplePlugin* getScriptablePeer();
|
||||
|
||||
private:
|
||||
NPP mInstance;
|
||||
NPBool mInitialized;
|
||||
nsIDebugPlugin * mScriptablePeer;
|
||||
nsCOMPtr<nsISimpleEnumerator> mIter;
|
||||
|
||||
NPP mInstance;
|
||||
NPBool mInitialized;
|
||||
nsISimplePlugin * mScriptablePeer;
|
||||
|
||||
public:
|
||||
char mString[128];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by npDebug.rc
|
||||
// Used by simple.rc
|
||||
//
|
||||
#define IDD_MAIN 101
|
||||
#define IDC_BUTTON_GO 1002
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Debug Plug-in Test</TITLE>
|
||||
<TITLE>Simple Plug-in Test</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
<center>
|
||||
<h1> XPConnect Scriptable Debug Plug-in </h1>
|
||||
<h1> XPConnect Scriptable Sample Plug-in </h1>
|
||||
</center>
|
||||
|
||||
This page contains a testcase which demonstrates the work of scriptable
|
||||
|
@ -19,33 +19,20 @@ in the alert box.
|
|||
|
||||
<center>
|
||||
|
||||
<embed type="application/debug-plugin" width=1 height=1 hidden="true"><br>
|
||||
<embed type="application/simple-plugin" width=1 height=1 hidden="true"><br>
|
||||
|
||||
<script>
|
||||
var embed = document.embeds[0];
|
||||
|
||||
function DumpFrames()
|
||||
function ShowVersion()
|
||||
{
|
||||
|
||||
var filedirectory = "file:///S|/mozilla/layout/html/tests/block";
|
||||
embed.StartDirectorySearch(filedirectory);
|
||||
do {
|
||||
filename=embed.GetNextFileInDirectory();
|
||||
alert(filename);
|
||||
outputfilename = filename.replace (".html",".tst");
|
||||
alert(outputfilename);
|
||||
|
||||
|
||||
//var thewindow = window.open(filetopen);
|
||||
//embed.DumpLayout(thewindow,"s:/tests","filename");
|
||||
} while (filename!=null)
|
||||
|
||||
alert(embed.version);
|
||||
}
|
||||
</script>
|
||||
|
||||
<br>
|
||||
<form name="formname">
|
||||
<input type=button value="DumpFrames" onclick='DumpFrames()'>
|
||||
<input type=button value="Show Version" onclick='ShowVersion()'>
|
||||
</form>
|
||||
|
||||
</center>
|
||||
|
|
Загрузка…
Ссылка в новой задаче