From 3f8064e4a9afda3a731559933460aa3c085c4257 Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Thu, 16 May 2002 21:04:27 +0000 Subject: [PATCH] Update to the debug plugin. This is not part of the build. --- .../layout-debug/idl/nsIDebugObject.idl | 7 + .../layout-debug/plugin/nsIDebugPlugin.h | 18 +- .../layout-debug/plugin/nsIDebugPlugin.idl | 1 + .../layout-debug/plugin/nsScriptablePeer.cpp | 17 +- extensions/layout-debug/plugin/plugin.cpp | 18 ++ extensions/layout-debug/plugin/plugin.h | 2 + extensions/layout-debug/plugin/test.html | 247 ++++++++++++++++-- extensions/layout-debug/src/nsDebugObject.cpp | 57 +++- .../layout-debug/src/nsRegressionTester.cpp | 57 +++- 9 files changed, 397 insertions(+), 27 deletions(-) diff --git a/extensions/layout-debug/idl/nsIDebugObject.idl b/extensions/layout-debug/idl/nsIDebugObject.idl index 1144b6dd83f..52b563b0c2a 100644 --- a/extensions/layout-debug/idl/nsIDebugObject.idl +++ b/extensions/layout-debug/idl/nsIDebugObject.idl @@ -50,6 +50,13 @@ interface nsIDebugObject : nsISupports */ void DumpContent(in nsISupports aUrlToDump,in wstring aFilePath,in wstring aFileName); + /** + * Compares the contents of frame model files + * @param + * @param + */ + void CompareFrameModels(in wstring aBasePath,in wstring aVerPath,in wstring aBaseFile,in wstring aVerFile, in unsigned long aFlags); + }; diff --git a/extensions/layout-debug/plugin/nsIDebugPlugin.h b/extensions/layout-debug/plugin/nsIDebugPlugin.h index 1ff084c96d7..27218567566 100644 --- a/extensions/layout-debug/plugin/nsIDebugPlugin.h +++ b/extensions/layout-debug/plugin/nsIDebugPlugin.h @@ -39,6 +39,9 @@ class NS_NO_VTABLE nsIDebugPlugin : public nsISupports { /* void GetNextFileInDirectory ([retval] out string aFileName); */ NS_IMETHOD GetNextFileInDirectory(char **aFileName) = 0; + /* void CompareLayoutFiles (in wstring aBasePath, in wstring aVerPath, in wstring aBaseFile, in wstring aVerFile, in unsigned long aFlags, [retval] out long aResult); */ + NS_IMETHOD CompareLayoutFiles(const PRUnichar *aBasePath, const PRUnichar *aVerPath, const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, PRInt32 *aResult) = 0; + }; /* Use this macro when declaring classes that implement this interface. */ @@ -46,21 +49,24 @@ class NS_NO_VTABLE nsIDebugPlugin : public nsISupports { NS_IMETHOD GetVersion(char * *aVersion); \ NS_IMETHOD DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult); \ NS_IMETHOD StartDirectorySearch(const char *aFilePath); \ - NS_IMETHOD GetNextFileInDirectory(char **aFileName); + NS_IMETHOD GetNextFileInDirectory(char **aFileName); \ + NS_IMETHOD CompareLayoutFiles(const PRUnichar *aBasePath, const PRUnichar *aVerPath, const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, PRInt32 *aResult); /* 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, 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); } + NS_IMETHOD GetNextFileInDirectory(char **aFileName) { return _to GetNextFileInDirectory(aFileName); } \ + NS_IMETHOD CompareLayoutFiles(const PRUnichar *aBasePath, const PRUnichar *aVerPath, const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, PRInt32 *aResult) { return _to CompareLayoutFiles(aBasePath, aVerPath, aBaseFile, aVerFile, aFlags, aResult); } /* 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, 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); } + NS_IMETHOD GetNextFileInDirectory(char **aFileName) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetNextFileInDirectory(aFileName); } \ + NS_IMETHOD CompareLayoutFiles(const PRUnichar *aBasePath, const PRUnichar *aVerPath, const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, PRInt32 *aResult) { return !_to ? NS_ERROR_NULL_POINTER : _to->CompareLayoutFiles(aBasePath, aVerPath, aBaseFile, aVerFile, aFlags, aResult); } #if 0 /* Use the code below as a template for the implementation class for this interface. */ @@ -115,6 +121,12 @@ NS_IMETHODIMP nsDebugPlugin::GetNextFileInDirectory(char **aFileName) return NS_ERROR_NOT_IMPLEMENTED; } +/* void CompareLayoutFiles (in wstring aBasePath, in wstring aVerPath, in wstring aBaseFile, in wstring aVerFile, in unsigned long aFlags, [retval] out long aResult); */ +NS_IMETHODIMP nsDebugPlugin::CompareLayoutFiles(const PRUnichar *aBasePath, const PRUnichar *aVerPath, const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, PRInt32 *aResult) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + /* End of implementation class template. */ #endif diff --git a/extensions/layout-debug/plugin/nsIDebugPlugin.idl b/extensions/layout-debug/plugin/nsIDebugPlugin.idl index 5e20c5c3b2d..03dbb6e59d1 100644 --- a/extensions/layout-debug/plugin/nsIDebugPlugin.idl +++ b/extensions/layout-debug/plugin/nsIDebugPlugin.idl @@ -28,5 +28,6 @@ interface nsIDebugPlugin : nsISupports { 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); + void CompareLayoutFiles(in wstring aBasePath,in wstring aVerPath,in wstring aBaseFile,in wstring aVerFile,in unsigned long aFlags,[retval] out long aResult); }; diff --git a/extensions/layout-debug/plugin/nsScriptablePeer.cpp b/extensions/layout-debug/plugin/nsScriptablePeer.cpp index 7dd36224b8f..89f0e071f4b 100644 --- a/extensions/layout-debug/plugin/nsScriptablePeer.cpp +++ b/extensions/layout-debug/plugin/nsScriptablePeer.cpp @@ -117,7 +117,6 @@ NS_IMETHODIMP nsScriptablePeer::GetVersion(char * *aVersion) return NS_OK; } - NS_IMETHODIMP nsScriptablePeer::DumpLayout(nsISupports *aWindow, const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aResult) { nsresult rv = NS_OK; @@ -134,6 +133,22 @@ PRBool retVal; return rv; } +NS_IMETHODIMP nsScriptablePeer::CompareLayoutFiles(const PRUnichar *aBasePath, const PRUnichar *aVerPath, + const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, PRInt32 *aResult) +{ +nsresult rv = NS_OK; +PRBool retVal; + + if (mPlugin){ + mPlugin->CompareLayoutFrames(aBasePath,aVerPath,aBaseFile,aVerFile,aFlags, &retVal); + if (retVal == NS_OK) { + *aResult= 0; + } else { + *aResult = 1; + } + } + return rv; +} // // the following method will be callable from JavaScript diff --git a/extensions/layout-debug/plugin/plugin.cpp b/extensions/layout-debug/plugin/plugin.cpp index d7e7ba03285..2d500023bb3 100644 --- a/extensions/layout-debug/plugin/plugin.cpp +++ b/extensions/layout-debug/plugin/plugin.cpp @@ -190,6 +190,24 @@ void nsPluginInstance::OutPutLayoutFrames(nsISupports *aWindow, const PRUnichar } } +//----------------------------------------------------- + +void nsPluginInstance::CompareLayoutFrames(const PRUnichar *aBasePath, const PRUnichar *aVerPath, + const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, 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){ + *aRetVal = theDebugObject->CompareFrameModels(aBasePath,aVerPath,aBaseFile,aVerFile,aFlags); + } + } +} + //----------------------------------------------------- void diff --git a/extensions/layout-debug/plugin/plugin.h b/extensions/layout-debug/plugin/plugin.h index 2f27636f1a5..575372855b5 100644 --- a/extensions/layout-debug/plugin/plugin.h +++ b/extensions/layout-debug/plugin/plugin.h @@ -62,6 +62,8 @@ public: // locals void getVersion(char* *aVersion); void OutPutLayoutFrames(nsISupports *aWindow,const PRUnichar *aFilePath, const PRUnichar *aFileName, PRInt32 *aRetVal); + void CompareLayoutFrames(const PRUnichar *aBasePath, const PRUnichar *aVerPath, + const PRUnichar *aBaseFile, const PRUnichar *aVerFile, PRUint32 aFlags, PRInt32 *aRetVal); void StartDirectorySearch(const char *aFilePath); void GetNextFileInDirectory(char **aFilePath); nsIDebugPlugin* getScriptablePeer(); diff --git a/extensions/layout-debug/plugin/test.html b/extensions/layout-debug/plugin/test.html index 0ace64e4e0f..739be1882e8 100644 --- a/extensions/layout-debug/plugin/test.html +++ b/extensions/layout-debug/plugin/test.html @@ -2,34 +2,156 @@ Debug Plug-in Test + + +
-

XPConnect Scriptable Debug Plug-in

+

Example XPConnect Scriptable Debug Plug-in Regression Page

- -

- -
-
+
+

OUTPUT IDLE

+
+

-
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Regression Directory + + +
+ BaseLine Extension + + + + Verify Extension + + +
+ BaseLine Output Directory + + + + Verify Output Directory + + +
+ Run Baseline + + +
+ Run Verify + + + + Compare Now + + + + + + +
+ +
+ + diff --git a/extensions/layout-debug/src/nsDebugObject.cpp b/extensions/layout-debug/src/nsDebugObject.cpp index 422564f0f21..33e711eea61 100644 --- a/extensions/layout-debug/src/nsDebugObject.cpp +++ b/extensions/layout-debug/src/nsDebugObject.cpp @@ -58,9 +58,12 @@ #include "nsIFrameDebug.h" #include "nsIFrame.h" #include "nsStyleStruct.h" +#include "nsIFrameUtil.h" +#include "nsLayoutCID.h" NS_IMPL_ISUPPORTS1(nsDebugObject, nsIDebugObject) - +static NS_DEFINE_IID(kFrameUtilCID, NS_FRAME_UTIL_CID); +static NS_DEFINE_IID(kIFrameUtilIID, NS_IFRAME_UTIL_IID); /** --------------------------------------------------- * See documentation in nsDebugObject.h @@ -113,10 +116,18 @@ PRBool stillLoading; presShell->GetRootFrame(&root); if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) { - FILE* fp = fopen("s:/testdump.txt", "wt"); + // create the string for the output + nsCAutoString outputPath; + outputPath.AssignWithConversion(aFilePath); + outputPath.AppendWithConversion(aFileName); + char* filePath = ToNewCString(outputPath); + + FILE* fp = fopen(filePath, "wt"); + presShell->GetPresContext(&thePC); fdbg->DumpRegressionData(thePC, fp, 0, PR_TRUE); fclose(fp); + delete filePath; result = NS_OK; // the document is now loaded, and the frames are dumped. } } @@ -126,5 +137,47 @@ PRBool stillLoading; return result; } +/** --------------------------------------------------- + * See documentation in nsDebugObject.h + * @update 6/21/00 dwc + */ +NS_IMETHODIMP +nsDebugObject::CompareFrameModels(const PRUnichar *aBasePath, const PRUnichar *aVerifyPath, + const PRUnichar *aBaseLineFileName, const PRUnichar *aVerifyFileName, PRUint32 aFlags) +{ +nsresult result = NS_ERROR_FAILURE; +nsCAutoString tempString; +nsCAutoString verifyFile; +char* baselineFilePath; +char* verifyFilePath; +FILE *bp,*vp; + tempString.AssignWithConversion(aBasePath); + tempString.AppendWithConversion(aBaseLineFileName); + baselineFilePath = ToNewCString(tempString); + + tempString.AssignWithConversion(aVerifyPath); + tempString.AppendWithConversion(aVerifyFileName); + verifyFilePath = ToNewCString(tempString); + + bp = fopen(baselineFilePath, "rt"); + if (bp) { + vp = fopen(verifyFilePath, "rt"); + if (vp) { + nsIFrameUtil* fu; + nsresult rv = nsComponentManager::CreateInstance(kFrameUtilCID, nsnull, + kIFrameUtilIID, (void **)&fu); + if (NS_SUCCEEDED(rv)) { + result = fu->CompareRegressionData(bp,vp,1); + } + fclose(vp); + } + fclose(bp); + } + delete baselineFilePath; + delete verifyFilePath; + + return result; +} + diff --git a/extensions/layout-debug/src/nsRegressionTester.cpp b/extensions/layout-debug/src/nsRegressionTester.cpp index 422564f0f21..33e711eea61 100644 --- a/extensions/layout-debug/src/nsRegressionTester.cpp +++ b/extensions/layout-debug/src/nsRegressionTester.cpp @@ -58,9 +58,12 @@ #include "nsIFrameDebug.h" #include "nsIFrame.h" #include "nsStyleStruct.h" +#include "nsIFrameUtil.h" +#include "nsLayoutCID.h" NS_IMPL_ISUPPORTS1(nsDebugObject, nsIDebugObject) - +static NS_DEFINE_IID(kFrameUtilCID, NS_FRAME_UTIL_CID); +static NS_DEFINE_IID(kIFrameUtilIID, NS_IFRAME_UTIL_IID); /** --------------------------------------------------- * See documentation in nsDebugObject.h @@ -113,10 +116,18 @@ PRBool stillLoading; presShell->GetRootFrame(&root); if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) { - FILE* fp = fopen("s:/testdump.txt", "wt"); + // create the string for the output + nsCAutoString outputPath; + outputPath.AssignWithConversion(aFilePath); + outputPath.AppendWithConversion(aFileName); + char* filePath = ToNewCString(outputPath); + + FILE* fp = fopen(filePath, "wt"); + presShell->GetPresContext(&thePC); fdbg->DumpRegressionData(thePC, fp, 0, PR_TRUE); fclose(fp); + delete filePath; result = NS_OK; // the document is now loaded, and the frames are dumped. } } @@ -126,5 +137,47 @@ PRBool stillLoading; return result; } +/** --------------------------------------------------- + * See documentation in nsDebugObject.h + * @update 6/21/00 dwc + */ +NS_IMETHODIMP +nsDebugObject::CompareFrameModels(const PRUnichar *aBasePath, const PRUnichar *aVerifyPath, + const PRUnichar *aBaseLineFileName, const PRUnichar *aVerifyFileName, PRUint32 aFlags) +{ +nsresult result = NS_ERROR_FAILURE; +nsCAutoString tempString; +nsCAutoString verifyFile; +char* baselineFilePath; +char* verifyFilePath; +FILE *bp,*vp; + tempString.AssignWithConversion(aBasePath); + tempString.AppendWithConversion(aBaseLineFileName); + baselineFilePath = ToNewCString(tempString); + + tempString.AssignWithConversion(aVerifyPath); + tempString.AppendWithConversion(aVerifyFileName); + verifyFilePath = ToNewCString(tempString); + + bp = fopen(baselineFilePath, "rt"); + if (bp) { + vp = fopen(verifyFilePath, "rt"); + if (vp) { + nsIFrameUtil* fu; + nsresult rv = nsComponentManager::CreateInstance(kFrameUtilCID, nsnull, + kIFrameUtilIID, (void **)&fu); + if (NS_SUCCEEDED(rv)) { + result = fu->CompareRegressionData(bp,vp,1); + } + fclose(vp); + } + fclose(bp); + } + delete baselineFilePath; + delete verifyFilePath; + + return result; +} +