mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-06 16:51:46 +00:00
Updated files for the Debug plugin. Not part of the build.
This commit is contained in:
parent
8bdf996e1c
commit
967322a13a
@ -30,8 +30,8 @@ class NS_NO_VTABLE nsIDebugPlugin : public nsISupports {
|
||||
/* readonly attribute string version; */
|
||||
NS_IMETHOD GetVersion(char * *aVersion) = 0;
|
||||
|
||||
/* void DumpLayout (in nsISupports aWindow, in wstring aFilePath, in wstring aFileName); */
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName) = 0;
|
||||
/* void DumpLayout (in nsISupports aWindow, in wstring aFilePath, in wstring aFileName, [retval] out long aResult); */
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult) = 0;
|
||||
|
||||
/* void StartDirectorySearch (in string aFilePath); */
|
||||
NS_IMETHOD StartDirectorySearch(const char *aFilePath) = 0;
|
||||
@ -44,21 +44,21 @@ class NS_NO_VTABLE nsIDebugPlugin : public nsISupports {
|
||||
/* Use this macro when declaring classes that implement this interface. */
|
||||
#define NS_DECL_NSIDEBUGPLUGIN \
|
||||
NS_IMETHOD GetVersion(char * *aVersion); \
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName); \
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult); \
|
||||
NS_IMETHOD StartDirectorySearch(const char *aFilePath); \
|
||||
NS_IMETHOD GetNextFileInDirectory(char **aFileName);
|
||||
|
||||
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
|
||||
#define NS_FORWARD_NSIDEBUGPLUGIN(_to) \
|
||||
NS_IMETHOD GetVersion(char * *aVersion) { return _to GetVersion(aVersion); } \
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName) { return _to DumpLayout(aWindow, aFilePath, aFileName); } \
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult) { return _to DumpLayout(aWindow, aFilePath, aFileName, aResult); } \
|
||||
NS_IMETHOD StartDirectorySearch(const char *aFilePath) { return _to StartDirectorySearch(aFilePath); } \
|
||||
NS_IMETHOD GetNextFileInDirectory(char **aFileName) { return _to GetNextFileInDirectory(aFileName); }
|
||||
|
||||
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
|
||||
#define NS_FORWARD_SAFE_NSIDEBUGPLUGIN(_to) \
|
||||
NS_IMETHOD GetVersion(char * *aVersion) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetVersion(aVersion); } \
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName) { return !_to ? NS_ERROR_NULL_POINTER : _to->DumpLayout(aWindow, aFilePath, aFileName); } \
|
||||
NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult) { return !_to ? NS_ERROR_NULL_POINTER : _to->DumpLayout(aWindow, aFilePath, aFileName, aResult); } \
|
||||
NS_IMETHOD StartDirectorySearch(const char *aFilePath) { return !_to ? NS_ERROR_NULL_POINTER : _to->StartDirectorySearch(aFilePath); } \
|
||||
NS_IMETHOD GetNextFileInDirectory(char **aFileName) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetNextFileInDirectory(aFileName); }
|
||||
|
||||
@ -97,8 +97,8 @@ NS_IMETHODIMP nsDebugPlugin::GetVersion(char * *aVersion)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void DumpLayout (in nsISupports aWindow, in wstring aFilePath, in wstring aFileName); */
|
||||
NS_IMETHODIMP nsDebugPlugin::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName)
|
||||
/* void DumpLayout (in nsISupports aWindow, in wstring aFilePath, in wstring aFileName, [retval] out long aResult); */
|
||||
NS_IMETHODIMP nsDebugPlugin::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
[scriptable, uuid(482e1890-1fe5-11d5-9cf8-0060b0fbd8ac)]
|
||||
interface nsIDebugPlugin : nsISupports {
|
||||
readonly attribute string version;
|
||||
void DumpLayout(in nsISupports aWindow,in wstring aFilePath,in wstring aFileName);
|
||||
void DumpLayout(in nsISupports aWindow,in wstring aFilePath,in wstring aFileName,[retval] out long aResult );
|
||||
void StartDirectorySearch(in string aFilePath);
|
||||
void GetNextFileInDirectory([retval] out string aFileName);
|
||||
|
||||
|
@ -118,14 +118,20 @@ NS_IMETHODIMP nsScriptablePeer::GetVersion(char * *aVersion)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsScriptablePeer::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName)
|
||||
NS_IMETHODIMP nsScriptablePeer::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool retVal;
|
||||
|
||||
if (mPlugin)
|
||||
mPlugin->DumpLayout(aWindow,aFilePath,aFileName);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
if (mPlugin){
|
||||
mPlugin->OutPutLayoutFrames(aWindow,aFilePath,aFileName,&retVal);
|
||||
if (retVal == NS_OK) {
|
||||
*aResult= 0;
|
||||
} else {
|
||||
*aResult = 1;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,18 +174,18 @@ void nsPluginInstance::getVersion(char* *aVersion)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
void
|
||||
nsPluginInstance::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName)
|
||||
|
||||
void nsPluginInstance::OutPutLayoutFrames(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aRetVal)
|
||||
{
|
||||
|
||||
nsIDebugObject *theDebugObject=NULL;
|
||||
|
||||
*aRetVal = NS_ERROR_FAILURE;
|
||||
|
||||
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);
|
||||
*aRetVal = theDebugObject->DumpContent(aWindow,aFilePath,aFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,16 +60,16 @@ public:
|
||||
NPError GetValue(NPPVariable variable, void *value);
|
||||
|
||||
// locals
|
||||
void getVersion(char* *aVersion);
|
||||
void DumpLayout(nsISupports *aWindow,const PRUnichar *aFilePath, const PRUnichar *aFileName);
|
||||
void StartDirectorySearch(const char *aFilePath);
|
||||
void GetNextFileInDirectory(char **aFilePath);
|
||||
void getVersion(char* *aVersion);
|
||||
void OutPutLayoutFrames(nsISupports *aWindow,const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aRetVal);
|
||||
void StartDirectorySearch(const char *aFilePath);
|
||||
void GetNextFileInDirectory(char **aFilePath);
|
||||
nsIDebugPlugin* getScriptablePeer();
|
||||
|
||||
private:
|
||||
NPP mInstance;
|
||||
NPBool mInitialized;
|
||||
nsIDebugPlugin * mScriptablePeer;
|
||||
nsIDebugPlugin * mScriptablePeer;
|
||||
nsCOMPtr<nsISimpleEnumerator> mIter;
|
||||
|
||||
|
||||
|
@ -8,12 +8,6 @@
|
||||
<h1> XPConnect Scriptable Debug Plug-in </h1>
|
||||
</center>
|
||||
|
||||
This page contains a testcase which demonstrates the work of scriptable
|
||||
plug-in with Mozilla. This example plug-in has no native GUI and does not
|
||||
draw anything in the plugin window. Clicking on the button will result in calling
|
||||
native plugin method from JavaScript. Show Version will instruct the plug-in
|
||||
to retrieve the Mozilla user agent string and return it to JavaScript to show
|
||||
in the alert box.
|
||||
|
||||
<br><br>
|
||||
|
||||
@ -23,29 +17,52 @@ in the alert box.
|
||||
|
||||
<script>
|
||||
var embed = document.embeds[0];
|
||||
var started = false;
|
||||
var theWindow;
|
||||
|
||||
function DumpFrames()
|
||||
function DumpFrames(firstTime,lastFile)
|
||||
{
|
||||
var loadingFlag;
|
||||
|
||||
var filedirectory = "file:///S|/mozilla/layout/html/tests/block";
|
||||
embed.StartDirectorySearch(filedirectory);
|
||||
do {
|
||||
if (firstTime == true) {
|
||||
var filedirectory = "file:///S|/mozilla/layout/html/tests/block";
|
||||
embed.StartDirectorySearch(filedirectory);
|
||||
filename=embed.GetNextFileInDirectory();
|
||||
if( filename != null) {
|
||||
theWindow = window.open(filename);
|
||||
}
|
||||
started = true;
|
||||
} else {
|
||||
filename = lastFile;
|
||||
}
|
||||
|
||||
while ( filename != null) {
|
||||
alert(filename);
|
||||
outputfilename = filename.replace (".html",".tst");
|
||||
alert(outputfilename);
|
||||
|
||||
|
||||
var thewindow = window.open(filetopen);
|
||||
embed.DumpLayout(thewindow,"s:/tests","filename");
|
||||
} while (filename!=null)
|
||||
|
||||
loading = embed.DumpLayout(theWindow,"s:/tests","outputfilename");
|
||||
|
||||
alert (loading);
|
||||
if (loading != 0) {
|
||||
setTimeout("DumpFrames(false,filename)",1000);
|
||||
alert("Waiting");
|
||||
break;
|
||||
} else {
|
||||
theWindow.close();
|
||||
filename=embed.GetNextFileInDirectory();
|
||||
alert("successful");
|
||||
if( filename != null) {
|
||||
theWindow = window.open(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<br>
|
||||
<form name="formname">
|
||||
<input type=button value="DumpFrames" onclick='DumpFrames()'>
|
||||
<input type=button value="DumpFrames" onclick='DumpFrames(true,0)'>
|
||||
</form>
|
||||
|
||||
</center>
|
||||
|
@ -87,7 +87,9 @@ nsDebugObject::~nsDebugObject()
|
||||
NS_IMETHODIMP
|
||||
nsDebugObject::DumpContent(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName)
|
||||
{
|
||||
nsresult found;
|
||||
nsresult result = NS_ERROR_NOT_AVAILABLE;
|
||||
PRUint32 busyFlags;
|
||||
PRBool stillLoading;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> theInternWindow(do_QueryInterface(aWindow));
|
||||
if (theInternWindow) {
|
||||
@ -101,17 +103,28 @@ nsresult found;
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptObj(do_QueryInterface(theInternWindow));
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
scriptObj->GetDocShell(getter_AddRefs(docShell));
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
presShell->GetRootFrame(&root);
|
||||
if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) {
|
||||
FILE* fp = fopen("s:/testdump.txt", "wt");
|
||||
presShell->GetPresContext(&thePC);
|
||||
fdbg->DumpRegressionData(thePC, fp, 0, PR_TRUE);
|
||||
fclose(fp);
|
||||
|
||||
// find out if the document is loaded
|
||||
docShell->GetBusyFlags(&busyFlags);
|
||||
stillLoading = busyFlags && (nsIDocShell::BUSY_FLAGS_BUSY | nsIDocShell::BUSY_FLAGS_PAGE_LOADING);
|
||||
|
||||
if ( !stillLoading ) {
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
presShell->GetRootFrame(&root);
|
||||
if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) {
|
||||
|
||||
FILE* fp = fopen("s:/testdump.txt", "wt");
|
||||
presShell->GetPresContext(&thePC);
|
||||
fdbg->DumpRegressionData(thePC, fp, 0, PR_TRUE);
|
||||
fclose(fp);
|
||||
result = NS_OK; // the document is now loaded, and the frames are dumped.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -87,7 +87,9 @@ nsDebugObject::~nsDebugObject()
|
||||
NS_IMETHODIMP
|
||||
nsDebugObject::DumpContent(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName)
|
||||
{
|
||||
nsresult found;
|
||||
nsresult result = NS_ERROR_NOT_AVAILABLE;
|
||||
PRUint32 busyFlags;
|
||||
PRBool stillLoading;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> theInternWindow(do_QueryInterface(aWindow));
|
||||
if (theInternWindow) {
|
||||
@ -101,17 +103,28 @@ nsresult found;
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptObj(do_QueryInterface(theInternWindow));
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
scriptObj->GetDocShell(getter_AddRefs(docShell));
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
presShell->GetRootFrame(&root);
|
||||
if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) {
|
||||
FILE* fp = fopen("s:/testdump.txt", "wt");
|
||||
presShell->GetPresContext(&thePC);
|
||||
fdbg->DumpRegressionData(thePC, fp, 0, PR_TRUE);
|
||||
fclose(fp);
|
||||
|
||||
// find out if the document is loaded
|
||||
docShell->GetBusyFlags(&busyFlags);
|
||||
stillLoading = busyFlags && (nsIDocShell::BUSY_FLAGS_BUSY | nsIDocShell::BUSY_FLAGS_PAGE_LOADING);
|
||||
|
||||
if ( !stillLoading ) {
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
presShell->GetRootFrame(&root);
|
||||
if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) {
|
||||
|
||||
FILE* fp = fopen("s:/testdump.txt", "wt");
|
||||
presShell->GetPresContext(&thePC);
|
||||
fdbg->DumpRegressionData(thePC, fp, 0, PR_TRUE);
|
||||
fclose(fp);
|
||||
result = NS_OK; // the document is now loaded, and the frames are dumped.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user