From 2c17ab70cd9854b81b8984e5c1f7c122cd71a7f5 Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Mon, 13 May 2002 02:32:35 +0000 Subject: [PATCH] Updated files for the Debug plugin. Not part of the build. git-svn-id: svn://10.0.0.236/trunk@121361 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout-debug/plugin/nsIDebugPlugin.h | 14 ++--- .../layout-debug/plugin/nsIDebugPlugin.idl | 2 +- .../layout-debug/plugin/nsScriptablePeer.cpp | 18 ++++--- .../extensions/layout-debug/plugin/plugin.cpp | 10 ++-- .../extensions/layout-debug/plugin/plugin.h | 10 ++-- .../extensions/layout-debug/plugin/test.html | 51 ++++++++++++------- .../layout-debug/src/nsDebugObject.cpp | 31 +++++++---- .../layout-debug/src/nsRegressionTester.cpp | 31 +++++++---- 8 files changed, 108 insertions(+), 59 deletions(-) diff --git a/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.h b/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.h index 01c7dbac824..1ff084c96d7 100644 --- a/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.h +++ b/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.h @@ -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; } diff --git a/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.idl b/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.idl index 9895d78d551..5e20c5c3b2d 100644 --- a/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.idl +++ b/mozilla/extensions/layout-debug/plugin/nsIDebugPlugin.idl @@ -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); diff --git a/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp b/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp index 34e80b729ab..7dd36224b8f 100644 --- a/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp +++ b/mozilla/extensions/layout-debug/plugin/nsScriptablePeer.cpp @@ -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; } diff --git a/mozilla/extensions/layout-debug/plugin/plugin.cpp b/mozilla/extensions/layout-debug/plugin/plugin.cpp index d8e5dcf56af..d7e7ba03285 100644 --- a/mozilla/extensions/layout-debug/plugin/plugin.cpp +++ b/mozilla/extensions/layout-debug/plugin/plugin.cpp @@ -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); } } } diff --git a/mozilla/extensions/layout-debug/plugin/plugin.h b/mozilla/extensions/layout-debug/plugin/plugin.h index 592f43a07bc..2f27636f1a5 100644 --- a/mozilla/extensions/layout-debug/plugin/plugin.h +++ b/mozilla/extensions/layout-debug/plugin/plugin.h @@ -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 mIter; diff --git a/mozilla/extensions/layout-debug/plugin/test.html b/mozilla/extensions/layout-debug/plugin/test.html index b4ea6eadfb8..0ace64e4e0f 100644 --- a/mozilla/extensions/layout-debug/plugin/test.html +++ b/mozilla/extensions/layout-debug/plugin/test.html @@ -8,12 +8,6 @@

XPConnect Scriptable Debug Plug-in

-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.

@@ -23,29 +17,52 @@ in the alert box.
- +
diff --git a/mozilla/extensions/layout-debug/src/nsDebugObject.cpp b/mozilla/extensions/layout-debug/src/nsDebugObject.cpp index 1ab24351f78..422564f0f21 100644 --- a/mozilla/extensions/layout-debug/src/nsDebugObject.cpp +++ b/mozilla/extensions/layout-debug/src/nsDebugObject.cpp @@ -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 theInternWindow(do_QueryInterface(aWindow)); if (theInternWindow) { @@ -101,17 +103,28 @@ nsresult found; nsCOMPtr scriptObj(do_QueryInterface(theInternWindow)); nsCOMPtr 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; } + + diff --git a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp index 1ab24351f78..422564f0f21 100644 --- a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp +++ b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp @@ -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 theInternWindow(do_QueryInterface(aWindow)); if (theInternWindow) { @@ -101,17 +103,28 @@ nsresult found; nsCOMPtr scriptObj(do_QueryInterface(theInternWindow)); nsCOMPtr 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; } + +