diff --git a/extensions/layout-debug/src/nsILayoutRegressionTester.idl b/extensions/layout-debug/src/nsILayoutRegressionTester.idl index d3492e23ca2..f14568d79d9 100644 --- a/extensions/layout-debug/src/nsILayoutRegressionTester.idl +++ b/extensions/layout-debug/src/nsILayoutRegressionTester.idl @@ -42,7 +42,7 @@ interface nsIDOMWindow; interface nsILocalFile; -[scriptable, uuid(1B4CD090-0531-11d6-A876-00105A183419)] +[scriptable, uuid(B249B2C0-EE11-11DA-8AD9-0800200C9A66)] interface nsILayoutRegressionTester : nsISupports { /** @@ -57,6 +57,7 @@ interface nsILayoutRegressionTester : nsISupports */ const short DUMP_FLAGS_MASK_DEFAULT = 0; const short DUMP_FLAGS_MASK_DUMP_STYLE = 1; + const short DUMP_FLAGS_MASK_PRINT_MODE = 2; const long DUMP_RESULT_COMPLETED = 0; // loaded OK const long DUMP_RESULT_LOADING = 1; // still loading diff --git a/extensions/layout-debug/src/nsRegressionTester.cpp b/extensions/layout-debug/src/nsRegressionTester.cpp index 4b5f2172195..c20dca2b9ad 100644 --- a/extensions/layout-debug/src/nsRegressionTester.cpp +++ b/extensions/layout-debug/src/nsRegressionTester.cpp @@ -53,6 +53,8 @@ #include "nsIDOMHTMLDocument.h" #include "nsISimpleEnumerator.h" #include "nsIDocShell.h" +#include "nsIContentViewer.h" +#include "nsIContentViewerFile.h" #include "nsIFrameDebug.h" #include "nsIFrame.h" #include "nsStyleStruct.h" @@ -121,11 +123,21 @@ nsRegressionTester::DumpFrameModel(nsIDOMWindow *aWindowToDump, nsILocalFile *aD rv = aDestFile->OpenANSIFileDesc("w", &fp); if (NS_FAILED(rv)) return rv; } - - fdbg->DumpRegressionData(presShell->GetPresContext(), fp, 0, dumpStyle); + if (aFlagsMask & DUMP_FLAGS_MASK_PRINT_MODE) { + nsCOMPtr viewer; + docShell->GetContentViewer(getter_AddRefs(viewer)); + if (viewer){ + nsCOMPtr viewerFile = do_QueryInterface(viewer); + if (viewerFile) { + viewerFile->Print(PR_TRUE, fp, nsnull); + } + } + } + else { + fdbg->DumpRegressionData(presShell->GetPresContext(), fp, 0, dumpStyle); + } if (fp != stdout) fclose(fp); - *aResult = DUMP_RESULT_COMPLETED; return NS_OK; } diff --git a/extensions/layout-debug/ui/content/layoutdebug.js b/extensions/layout-debug/ui/content/layoutdebug.js index b6f8400b9b6..e1e2136989f 100644 --- a/extensions/layout-debug/ui/content/layoutdebug.js +++ b/extensions/layout-debug/ui/content/layoutdebug.js @@ -343,31 +343,32 @@ const NS_LOCALFILEINPUTSTREAM_CONTRACTID = "@mozilla.org/network/file-input-stream;1"; -function RunRTest(aFilename, aIsBaseline) +function RunRTest(aFilename, aIsBaseline, aIsPrinting) { if (gRTestURLList) { // XXX Does alert work? alert("Already running regression test.\n"); return; } - - dump("Running " + (aIsBaseline?"baseline":"verify") + " test for " + aFilename + ".\n"); + dump("Running " + (aIsBaseline?"baseline":"verify") + + (aIsPrinting?" PrintMode":"") + " test for " + aFilename + ".\n"); var listFile = Components.classes[NS_LOCAL_FILE_CONTRACTID]. createInstance(nsILocalFile); listFile.persistentDescriptor = aFilename; - gRTestURLList = new RTestURLList(listFile, aIsBaseline); + gRTestURLList = new RTestURLList(listFile, aIsBaseline, aIsPrinting); gRTestURLList.startURL(); } -function RTestURLList(aLocalFile, aIsBaseline) { - this.init(aLocalFile, aIsBaseline); +function RTestURLList(aLocalFile, aIsBaseline, aIsPrinting) { + this.init(aLocalFile, aIsBaseline, aIsPrinting); } RTestURLList.prototype = { - init : function(aLocalFile, aIsBaseline) + init : function(aLocalFile, aIsBaseline, aIsPrinting) { this.mIsBaseline = aIsBaseline; + this.mIsPrinting = aIsPrinting; this.mURLs = new Array(); this.readFileList(aLocalFile); this.mRegressionTester = @@ -419,8 +420,16 @@ RTestURLList.prototype = { dump("Writing regression data to " + data.QueryInterface(nsILocalFile).persistentDescriptor + "\n"); - this.mRegressionTester.dumpFrameModel(gBrowser.contentWindow, data, - nsILayoutRegressionTester.DUMP_FLAGS_MASK_DUMP_STYLE); + if (this.mIsPrinting) { + this.mRegressionTester.dumpFrameModel(gBrowser.contentWindow, data, + nsILayoutRegressionTester.DUMP_FLAGS_MASK_PRINT_MODE); + } + else { + this.mRegressionTester.dumpFrameModel(gBrowser.contentWindow, data, + nsILayoutRegressionTester.DUMP_FLAGS_MASK_DUMP_STYLE); + } + + if (!this.mIsBaseline) { var base_data = this.mCurrentURL.dir.clone(); @@ -454,5 +463,6 @@ RTestURLList.prototype = { mURLs : null, mCurrentURL : null, // url (string), dir (nsIFileURL), relurl (string) mIsBaseline : null, - mRegressionTester : null + mRegressionTester : null, + mIsPrinting : null } diff --git a/extensions/layout-debug/ui/content/layoutdebug.xul b/extensions/layout-debug/ui/content/layoutdebug.xul index bc368cba9a9..f84b3ecee1f 100644 --- a/extensions/layout-debug/ui/content/layoutdebug.xul +++ b/extensions/layout-debug/ui/content/layoutdebug.xul @@ -97,13 +97,13 @@ - + - + - + @@ -115,6 +115,7 @@ + + oncommand="RunRTest(this.getAttribute('name'), true, document.getElementById('menu_RTestPrintMode').getAttribute('checked'));" /> @@ -141,7 +142,7 @@ + oncommand="RunRTest(this.getAttribute('name'), false, document.getElementById('menu_RTestPrintMode').getAttribute('checked'));" /> @@ -221,7 +222,7 @@ + homepage="about:blank" /> diff --git a/extensions/layout-debug/ui/locale/en-US/layoutdebug.dtd b/extensions/layout-debug/ui/locale/en-US/layoutdebug.dtd index f7f34200695..a2503a2f9a5 100644 --- a/extensions/layout-debug/ui/locale/en-US/layoutdebug.dtd +++ b/extensions/layout-debug/ui/locale/en-US/layoutdebug.dtd @@ -61,6 +61,8 @@ + +