From 97c3a1435e9dcee61e6c1d39994f160a1f4f219f Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Tue, 8 Jul 2003 21:08:23 +0000 Subject: [PATCH] Add UI code, intended to replace viewer, into extensions/layout-debug/. Separate UI-related features out of existing regression testing interface. b=137331 r+sr=bryner git-svn-id: svn://10.0.0.236/trunk@144585 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/layout-debug/Makefile.in | 2 +- .../extensions/layout-debug/src/Makefile.in | 18 +- .../layout-debug/src/nsDebugFactory.cpp | 22 +- .../src/nsILayoutDebuggingTools.idl | 84 +++ .../src/nsILayoutRegressionTester.idl | 33 - .../layout-debug/src/nsLayoutDebugCIID.h | 6 + .../layout-debug/src/nsLayoutDebugCLH.cpp | 62 ++ .../layout-debug/src/nsLayoutDebugCLH.h | 60 ++ .../src/nsLayoutDebuggingTools.cpp | 617 ++++++++++++++++++ .../layout-debug/src/nsLayoutDebuggingTools.h | 72 ++ .../layout-debug/src/nsRegressionTester.cpp | 492 -------------- .../layout-debug/src/nsRegressionTester.h | 16 - .../extensions/layout-debug/ui/Makefile.in | 29 + .../layout-debug/ui/content/contents.rdf | 63 ++ .../ui/content/layoutdebug-overlay.xul | 62 ++ .../layout-debug/ui/content/layoutdebug.js | 406 ++++++++++++ .../layout-debug/ui/content/layoutdebug.xul | 225 +++++++ mozilla/extensions/layout-debug/ui/jar.mn | 8 + .../layout-debug/ui/locale/en-US/contents.rdf | 60 ++ .../ui/locale/en-US/layoutdebug-overlay.dtd | 38 ++ .../ui/locale/en-US/layoutdebug.dtd | 101 +++ .../layout/tools/tests/content_dumping.html | 58 +- mozilla/layout/tools/tests/debug_utils.html | 37 +- .../layout/tools/tests/regression_tests.js | 4 +- 24 files changed, 1969 insertions(+), 606 deletions(-) create mode 100644 mozilla/extensions/layout-debug/src/nsILayoutDebuggingTools.idl create mode 100644 mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.cpp create mode 100644 mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.h create mode 100644 mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp create mode 100644 mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.h create mode 100644 mozilla/extensions/layout-debug/ui/Makefile.in create mode 100644 mozilla/extensions/layout-debug/ui/content/contents.rdf create mode 100644 mozilla/extensions/layout-debug/ui/content/layoutdebug-overlay.xul create mode 100644 mozilla/extensions/layout-debug/ui/content/layoutdebug.js create mode 100644 mozilla/extensions/layout-debug/ui/content/layoutdebug.xul create mode 100644 mozilla/extensions/layout-debug/ui/jar.mn create mode 100644 mozilla/extensions/layout-debug/ui/locale/en-US/contents.rdf create mode 100644 mozilla/extensions/layout-debug/ui/locale/en-US/layoutdebug-overlay.dtd create mode 100644 mozilla/extensions/layout-debug/ui/locale/en-US/layoutdebug.dtd diff --git a/mozilla/extensions/layout-debug/Makefile.in b/mozilla/extensions/layout-debug/Makefile.in index 2ad69d246ea..531be2c2e2c 100644 --- a/mozilla/extensions/layout-debug/Makefile.in +++ b/mozilla/extensions/layout-debug/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = src +DIRS = src ui include $(topsrcdir)/config/rules.mk diff --git a/mozilla/extensions/layout-debug/src/Makefile.in b/mozilla/extensions/layout-debug/src/Makefile.in index ec9b622e850..54187c25b22 100644 --- a/mozilla/extensions/layout-debug/src/Makefile.in +++ b/mozilla/extensions/layout-debug/src/Makefile.in @@ -34,24 +34,26 @@ MODULE_NAME = nsLayoutDebugModule REQUIRES= xpcom \ string \ - windowwatcher\ - docshell\ + windowwatcher \ + docshell \ string \ - dom\ - gfx\ - content\ - necko\ - layout\ + dom \ + gfx \ + content \ + necko \ + layout \ widget \ locale \ view \ pref \ imglib2 \ unicharutil \ + appshell \ $(NULL) XPIDLSRCS = \ nsILayoutRegressionTester.idl \ + nsILayoutDebuggingTools.idl \ $(NULL) EXPORTS = \ @@ -60,6 +62,8 @@ EXPORTS = \ CPPSRCS = \ nsDebugFactory.cpp \ + nsLayoutDebugCLH.cpp \ + nsLayoutDebuggingTools.cpp \ nsRegressionTester.cpp \ $(NULL) diff --git a/mozilla/extensions/layout-debug/src/nsDebugFactory.cpp b/mozilla/extensions/layout-debug/src/nsDebugFactory.cpp index 0dfa2e01bca..51b6de59798 100644 --- a/mozilla/extensions/layout-debug/src/nsDebugFactory.cpp +++ b/mozilla/extensions/layout-debug/src/nsDebugFactory.cpp @@ -41,20 +41,32 @@ #include "nsIFactory.h" #include "nsISupports.h" #include "nsRegressionTester.h" +#include "nsLayoutDebuggingTools.h" +#include "nsLayoutDebugCLH.h" #include "nsIGenericFactory.h" - - NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegressionTester) - - +NS_GENERIC_FACTORY_CONSTRUCTOR(nsLayoutDebuggingTools) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsLayoutDebugCLH) static const nsModuleComponentInfo components[] = { { "nsRegressionTester", NS_REGRESSION_TESTER_CID, - "@mozilla.org/layout_debug/regressiontester;1", + "@mozilla.org/layout-debug/regressiontester;1", nsRegressionTesterConstructor + }, + { "nsLayoutDebuggingTools", + NS_LAYOUT_DEBUGGINGTOOLS_CID, + NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID, + nsLayoutDebuggingToolsConstructor + }, + { "LayoutDebug Startup Handler", + NS_LAYOUTDEBUGCLH_CID, + "@mozilla.org/commandlinehandler/general-startup;1?type=layoutdebug", + nsLayoutDebugCLHConstructor, + nsLayoutDebugCLH::RegisterProc, + nsLayoutDebugCLH::UnregisterProc } }; diff --git a/mozilla/extensions/layout-debug/src/nsILayoutDebuggingTools.idl b/mozilla/extensions/layout-debug/src/nsILayoutDebuggingTools.idl new file mode 100644 index 00000000000..1f987f99282 --- /dev/null +++ b/mozilla/extensions/layout-debug/src/nsILayoutDebuggingTools.idl @@ -0,0 +1,84 @@ +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +// vim:cindent:tabstop=4:expandtab:shiftwidth=4: +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is layout debugging code. + * + * The Initial Developer of the Original Code is L. David Baron. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * L. David Baron (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIDOMWindow; + +/** + * A series of hooks into non-IDL-ized layout code to allow all the + * layout debugging functions to be used from chrome. + */ + +[scriptable, uuid(4b968d4b-9c08-4635-a7e0-55084843f0fd)] +interface nsILayoutDebuggingTools : nsISupports +{ + + /* + * Initialize debugger object to act on a docshell. + */ + void init(in nsIDOMWindow win); + + /* + * Notify the debugger that the docshell has been told to load a new + * URI. + */ + void newURILoaded(); + + /* Toggle various debugging states */ + attribute boolean visualDebugging; + attribute boolean visualEventDebugging; + attribute boolean paintFlashing; + attribute boolean paintDumping; + attribute boolean invalidateDumping; + attribute boolean eventDumping; + attribute boolean motionEventDumping; + attribute boolean crossingEventDumping; + attribute boolean reflowCounts; + + /* Run various tests. */ + void dumpWebShells(); + void dumpContent(); + void dumpFrames(); + void dumpViews(); + + void dumpStyleSheets(); + void dumpStyleContexts(); + + void dumpReflowStats(); +}; diff --git a/mozilla/extensions/layout-debug/src/nsILayoutRegressionTester.idl b/mozilla/extensions/layout-debug/src/nsILayoutRegressionTester.idl index 881a9ef4954..ecadf72d562 100644 --- a/mozilla/extensions/layout-debug/src/nsILayoutRegressionTester.idl +++ b/mozilla/extensions/layout-debug/src/nsILayoutRegressionTester.idl @@ -46,15 +46,6 @@ interface nsILocalFile; [scriptable, uuid(1B4CD090-0531-11d6-A876-00105A183419)] interface nsILayoutRegressionTester : nsISupports { - - /** - * Output the given string to a file, optionally truncating the file first. - * @param aFile the file to output to - * @param aTruncateFile whether to trunate the file first - * @param aOutputString the string to write out - */ - void outputTextToFile(in nsILocalFile aFile, in boolean aTruncateFile, in string aOutputString); - /** * Dumps the content of a window * @param aWindowToDump the window to dump (may be an iframe etc) @@ -84,29 +75,5 @@ interface nsILayoutRegressionTester : nsISupports const short COMPARE_FLAGS_VERBOSE = 0; const short COMPARE_FLAGS_BRIEF = 1; long compareFrameModels(in nsILocalFile aBaseFile, in nsILocalFile aVerFile, in unsigned long aFlags); - - /** - * Methods to dump various types of data. In all casese, if aDestFile is nil, - * data is written to stdout. - */ - - void dumpContent(in nsIDOMWindow aWindow, in nsILocalFile aDestFile); - - void dumpFrames(in nsIDOMWindow aWindow, in nsILocalFile aDestFile); - void dumpViews(in nsIDOMWindow aWindow, in nsILocalFile aDestFile); - void dumpWebShells(in nsIDOMWindow aWindow, in nsILocalFile aDestFile); - void dumpStyleSheets(in nsIDOMWindow aWindow, in nsILocalFile aDestFile); - void dumpStyleContexts(in nsIDOMWindow aWindow, in nsILocalFile aDestFile); - void dumpReflowStats(in nsIDOMWindow aWindow, in nsILocalFile aDestFile); - - /** - * Turn reflow stats on or off for the given window. Requires that - * you built with MOZ_REFLOW_PERF=1 - */ - void setShowReflowStats(in nsIDOMWindow aWindow, in boolean inShow); - - attribute boolean showFrameBorders; // whether to show frame borders - attribute boolean showEventTargetFrameBorder; // whether to show event target frame borders - }; diff --git a/mozilla/extensions/layout-debug/src/nsLayoutDebugCIID.h b/mozilla/extensions/layout-debug/src/nsLayoutDebugCIID.h index 37f64b1cd83..71cccfa1e26 100644 --- a/mozilla/extensions/layout-debug/src/nsLayoutDebugCIID.h +++ b/mozilla/extensions/layout-debug/src/nsLayoutDebugCIID.h @@ -47,5 +47,11 @@ { 0x698c54f4, 0x4ea9, 0x11d7, \ { 0x85, 0x9f, 0x00, 0x03, 0x93, 0x63, 0x65, 0x92 } } +#define NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID \ + "@mozilla.org/layout-debug/layout-debuggingtools;1" +// 3f4c3b63-e640-4712-abbf-fff1301ceb60 +#define NS_LAYOUT_DEBUGGINGTOOLS_CID { 0x3f4c3b68, 0xe640, 0x4712, \ + { 0xab, 0xbf, 0xff, 0xf1, 0x30, 0x1c, 0xeb, 0x60}} + #endif // nsFrameDebugCIID_h__ diff --git a/mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.cpp b/mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.cpp new file mode 100644 index 00000000000..5704cff2cc8 --- /dev/null +++ b/mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.cpp @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +// vim:cindent:tabstop=4:expandtab:shiftwidth=4: +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is layout debugging code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * L. David Baron (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsLayoutDebugCLH.h" +#include "nsString.h" +#include "plstr.h" + +nsLayoutDebugCLH::nsLayoutDebugCLH() +{ +} + +nsLayoutDebugCLH::~nsLayoutDebugCLH() +{ +} + +NS_IMPL_ISUPPORTS1(nsLayoutDebugCLH, nsICmdLineHandler) + +CMDLINEHANDLER_IMPL(nsLayoutDebugCLH, "-layoutdebug", + "general.startup.layoutdebug", + "chrome://layoutdebug/content/", + "Start with Layout Debugger", + "@mozilla.org/commandlinehandler/general-startup;1?type=layoutdebug", + "LayoutDebug Startup Handler", + PR_TRUE, + "", + PR_TRUE) diff --git a/mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.h b/mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.h new file mode 100644 index 00000000000..f76d6e6d8b2 --- /dev/null +++ b/mozilla/extensions/layout-debug/src/nsLayoutDebugCLH.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +// vim:cindent:tabstop=4:expandtab:shiftwidth=4: +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is layout debugging code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * L. David Baron (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsLayoutDebugCLH_h_ +#define nsLayoutDebugCLH_h_ + +#include "nsICmdLineHandler.h" + +#define NS_LAYOUTDEBUGCLH_CID \ + { 0xa8f52633, 0x5ecf, 0x424a, \ + { 0xa1, 0x47, 0x47, 0xc3, 0x22, 0xf7, 0xbc, 0xe2 }} + +class nsLayoutDebugCLH : public nsICmdLineHandler +{ +public: + nsLayoutDebugCLH(); + virtual ~nsLayoutDebugCLH(); + + NS_DECL_ISUPPORTS + NS_DECL_NSICMDLINEHANDLER + CMDLINEHANDLER_REGISTERPROC_DECLS +}; + +#endif /* !defined(nsLayoutDebugCLH_h_) */ diff --git a/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp b/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp new file mode 100644 index 00000000000..3acc37e1368 --- /dev/null +++ b/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -0,0 +1,617 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +// vim:cindent:tabstop=4:expandtab:shiftwidth=4: +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is layout debugging code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * L. David Baron (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsLayoutDebuggingTools.h" + +#include "nsIDocShell.h" +#include "nsIDocShellTreeNode.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDOMWindow.h" +#include "nsIScriptGlobalObject.h" +#include "nsIDocumentViewer.h" + +#include "nsIServiceManager.h" +#include "nsIAtom.h" +#include "nsQuickSort.h" +#include "nsIPref.h" + +#include "nsIContent.h" +#include "nsIDocument.h" +#include "nsIDOMDocument.h" + +#include "nsIPresShell.h" +#include "nsIViewManager.h" +#include "nsIStyleSet.h" +#include "nsIFrame.h" +#include "nsIFrameDebug.h" + +#include "nsILayoutDebugger.h" +#include "nsLayoutCID.h" +static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID); + +#include "nsISelectionController.h" + +static already_AddRefed +doc_viewer(nsIDocShell *aDocShell) +{ + if (!aDocShell) + return nsnull; + nsIContentViewer *result = nsnull; + aDocShell->GetContentViewer(&result); + return result; +} + +static already_AddRefed +pres_shell(nsIDocShell *aDocShell) +{ + nsCOMPtr dv = + do_QueryInterface(nsCOMPtr(doc_viewer(aDocShell))); + if (!dv) + return nsnull; + nsIPresShell *result = nsnull; + dv->GetPresShell(&result); + return result; +} + +#if 0 // not currently needed +static already_AddRefed +pres_context(nsIDocShell *aDocShell) +{ + nsCOMPtr dv = + do_QueryInterface(nsCOMPtr(doc_viewer(aDocShell))); + if (!dv) + return nsnull; + nsIPresContext *result = nsnull; + dv->GetPresContext(result); + return result; +} +#endif + +static already_AddRefed +view_manager(nsIDocShell *aDocShell) +{ + nsCOMPtr shell(pres_shell(aDocShell)); + if (!shell) + return nsnull; + nsIViewManager *result = nsnull; + shell->GetViewManager(&result); + return result; +} + +static already_AddRefed +document(nsIDocShell *aDocShell) +{ + nsCOMPtr cv(doc_viewer(aDocShell)); + if (!cv) + return nsnull; + nsCOMPtr domDoc; + cv->GetDOMDocument(getter_AddRefs(domDoc)); + if (!domDoc) + return nsnull; + nsIDocument *result = nsnull; + CallQueryInterface(domDoc, &result); + return result; +} + +static already_AddRefed +style_set(nsIDocShell *aDocShell) +{ + nsCOMPtr shell(pres_shell(aDocShell)); + if (!shell) + return nsnull; + nsIStyleSet *result = nsnull; + shell->GetStyleSet(&result); + return result; +} + + +nsLayoutDebuggingTools::nsLayoutDebuggingTools() + : mPaintFlashing(PR_FALSE), + mPaintDumping(PR_FALSE), + mInvalidateDumping(PR_FALSE), + mEventDumping(PR_FALSE), + mMotionEventDumping(PR_FALSE), + mCrossingEventDumping(PR_FALSE), + mReflowCounts(PR_FALSE) +{ + NS_INIT_ISUPPORTS(); + + NewURILoaded(); +} + +nsLayoutDebuggingTools::~nsLayoutDebuggingTools() +{ +} + +NS_IMPL_ISUPPORTS1(nsLayoutDebuggingTools, nsILayoutDebuggingTools) + +NS_IMETHODIMP +nsLayoutDebuggingTools::Init(nsIDOMWindow *aWin) +{ + { + nsCOMPtr global = do_QueryInterface(aWin); + if (!global) + return NS_ERROR_UNEXPECTED; + global->GetDocShell(getter_AddRefs(mDocShell)); + } + + mPrefs = do_GetService(NS_PREF_CONTRACTID); + + GetBoolPref("nglayout.debug.paint_flashing", &mPaintFlashing); + GetBoolPref("nglayout.debug.paint_dumping", &mPaintDumping); + GetBoolPref("nglayout.debug.invalidate_dumping", &mInvalidateDumping); + GetBoolPref("nglayout.debug.event_dumping", &mEventDumping); + GetBoolPref("nglayout.debug.motion_event_dumping", &mMotionEventDumping); + GetBoolPref("nglayout.debug.crossing_event_dumping", &mCrossingEventDumping); + GetBoolPref("layout.reflow.showframecounts", &mReflowCounts); + + { + nsCOMPtr ld = do_GetService(kLayoutDebuggerCID); + if (ld) { + ld->GetShowFrameBorders(&mVisualDebugging); + ld->GetShowEventTargetFrameBorder(&mVisualEventDebugging); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::NewURILoaded() +{ + // Reset all the state that should be reset between pages. + + // XXX Some of these should instead be transferred between pages! + mEditorMode = PR_FALSE; + mVisualDebugging = PR_FALSE; + mVisualEventDebugging = PR_FALSE; + + mReflowCounts = PR_FALSE; + + ForceRefresh(); + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetVisualDebugging(PRBool *aVisualDebugging) +{ + *aVisualDebugging = mVisualDebugging; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetVisualDebugging(PRBool aVisualDebugging) +{ + nsCOMPtr ld = do_GetService(kLayoutDebuggerCID); + if (!ld) + return NS_ERROR_UNEXPECTED; + mVisualDebugging = aVisualDebugging; + ld->SetShowFrameBorders(aVisualDebugging); + ForceRefresh(); + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetVisualEventDebugging(PRBool *aVisualEventDebugging) +{ + *aVisualEventDebugging = mVisualEventDebugging; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetVisualEventDebugging(PRBool aVisualEventDebugging) +{ + nsCOMPtr ld = do_GetService(kLayoutDebuggerCID); + if (!ld) + return NS_ERROR_UNEXPECTED; + mVisualEventDebugging = aVisualEventDebugging; + ld->SetShowEventTargetFrameBorder(aVisualEventDebugging); + ForceRefresh(); + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetPaintFlashing(PRBool *aPaintFlashing) +{ + *aPaintFlashing = mPaintFlashing; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetPaintFlashing(PRBool aPaintFlashing) +{ + mPaintFlashing = aPaintFlashing; + return SetBoolPrefAndRefresh("nglayout.debug.paint_flashing", mPaintFlashing); +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetPaintDumping(PRBool *aPaintDumping) +{ + *aPaintDumping = mPaintDumping; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetPaintDumping(PRBool aPaintDumping) +{ + mPaintDumping = aPaintDumping; + return SetBoolPrefAndRefresh("nglayout.debug.paint_dumping", mPaintDumping); +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetInvalidateDumping(PRBool *aInvalidateDumping) +{ + *aInvalidateDumping = mInvalidateDumping; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetInvalidateDumping(PRBool aInvalidateDumping) +{ + mInvalidateDumping = aInvalidateDumping; + return SetBoolPrefAndRefresh("nglayout.debug.invalidate_dumping", mInvalidateDumping); +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetEventDumping(PRBool *aEventDumping) +{ + *aEventDumping = mEventDumping; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetEventDumping(PRBool aEventDumping) +{ + mEventDumping = aEventDumping; + return SetBoolPrefAndRefresh("nglayout.debug.event_dumping", mEventDumping); +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetMotionEventDumping(PRBool *aMotionEventDumping) +{ + *aMotionEventDumping = mMotionEventDumping; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetMotionEventDumping(PRBool aMotionEventDumping) +{ + mMotionEventDumping = aMotionEventDumping; + return SetBoolPrefAndRefresh("nglayout.debug.motion_event_dumping", mMotionEventDumping); +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetCrossingEventDumping(PRBool *aCrossingEventDumping) +{ + *aCrossingEventDumping = mCrossingEventDumping; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetCrossingEventDumping(PRBool aCrossingEventDumping) +{ + mCrossingEventDumping = aCrossingEventDumping; + return SetBoolPrefAndRefresh("nglayout.debug.crossing_event_dumping", mCrossingEventDumping); +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::GetReflowCounts(PRBool* aShow) +{ + *aShow = mReflowCounts; + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::SetReflowCounts(PRBool aShow) +{ + nsCOMPtr shell(pres_shell(mDocShell)); + if (shell) { +#ifdef MOZ_REFLOW_PERF + shell->SetPaintFrameCount(aShow); + SetBoolPrefAndRefresh("layout.reflow.showframecounts", aShow); + mReflowCounts = aShow; +#else + printf("************************************************\n"); + printf("Sorry, you have not built with MOZ_REFLOW_PERF=1\n"); + printf("************************************************\n"); +#endif + } + return NS_OK; +} + +static void DumpAWebShell(nsIDocShellTreeItem* aShellItem, FILE* out, PRInt32 aIndent) +{ + nsXPIDLString name; + nsCOMPtr parent; + PRInt32 i, n; + + for (i = aIndent; --i >= 0; ) + fprintf(out, " "); + + fprintf(out, "%p '", NS_STATIC_CAST(void*, aShellItem)); + aShellItem->GetName(getter_Copies(name)); + aShellItem->GetSameTypeParent(getter_AddRefs(parent)); + fputs(NS_LossyConvertUCS2toASCII(name).get(), out); + fprintf(out, "' parent=%p <\n", NS_STATIC_CAST(void*, parent)); + + ++aIndent; + nsCOMPtr shellAsNode(do_QueryInterface(aShellItem)); + shellAsNode->GetChildCount(&n); + for (i = 0; i < n; ++i) { + nsCOMPtr child; + shellAsNode->GetChildAt(i, getter_AddRefs(child)); + if (child) { + DumpAWebShell(child, out, aIndent); + } + } + --aIndent; + for (i = aIndent; --i >= 0; ) + fprintf(out, " "); + fputs(">\n", out); +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::DumpWebShells() +{ + nsCOMPtr shellAsItem(do_QueryInterface(mDocShell)); + DumpAWebShell(shellAsItem, stdout, 0); + return NS_OK; +} + +static +void +DumpContentRecur(nsIDocShell* aDocShell, FILE* out) +{ +#ifdef DEBUG + if (nsnull != aDocShell) { + fprintf(out, "docshell=%p \n", NS_STATIC_CAST(void*, aDocShell)); + nsCOMPtr doc(document(aDocShell)); + if (doc) { + nsCOMPtr root; + doc->GetRootContent(getter_AddRefs(root)); + if (root) { + root->List(out); + } + } + else { + fputs("no document\n", out); + } + // dump the frames of the sub documents + PRInt32 i, n; + nsCOMPtr docShellAsNode(do_QueryInterface(aDocShell)); + docShellAsNode->GetChildCount(&n); + for (i = 0; i < n; ++i) { + nsCOMPtr child; + docShellAsNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + if (child) { + DumpContentRecur(childAsShell, out); + } + } + } +#endif +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::DumpContent() +{ + DumpContentRecur(mDocShell, stdout); + return NS_OK; +} + +static void +DumpFramesRecur(nsIDocShell* aDocShell, FILE* out) +{ + if (nsnull != aDocShell) { + fprintf(out, "webshell=%p \n", NS_STATIC_CAST(void*, aDocShell)); + nsCOMPtr shell(pres_shell(aDocShell)); + if (shell) { + nsIFrame* root; + shell->GetRootFrame(&root); + if (root) { + nsCOMPtr presContext; + shell->GetPresContext(getter_AddRefs(presContext)); + + nsIFrameDebug* fdbg; + if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) { + fdbg->List(presContext, out, 0); + } + } + } + else { + fputs("null pres shell\n", out); + } + + // dump the frames of the sub documents + PRInt32 i, n; + nsCOMPtr docShellAsNode(do_QueryInterface(aDocShell)); + docShellAsNode->GetChildCount(&n); + for (i = 0; i < n; ++i) { + nsCOMPtr child; + docShellAsNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + if (childAsShell) { + DumpFramesRecur(childAsShell, out); + } + } + } +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::DumpFrames() +{ + DumpFramesRecur(mDocShell, stdout); + return NS_OK; +} + +static +void +DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) +{ + if (aDocShell) { + fprintf(out, "docshell=%p \n", NS_STATIC_CAST(void*, aDocShell)); + nsCOMPtr vm(view_manager(aDocShell)); + if (vm) { + nsIView* root; + vm->GetRootView(root); + if (nsnull != root) { + root->List(out); + } + } + else { + fputs("null view manager\n", out); + } + + // dump the views of the sub documents + PRInt32 i, n; + nsCOMPtr docShellAsNode(do_QueryInterface(aDocShell)); + docShellAsNode->GetChildCount(&n); + for (i = 0; i < n; i++) { + nsCOMPtr child; + docShellAsNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + if (childAsShell) { + DumpViewsRecur(childAsShell, out); + } + } + } +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::DumpViews() +{ + DumpViewsRecur(mDocShell, stdout); + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::DumpStyleSheets() +{ +#ifdef DEBUG + FILE *out = stdout; + nsCOMPtr styleSet(style_set(mDocShell)); + if (styleSet) + styleSet->List(out); + else + fputs("null style set\n", out); +#endif + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::DumpStyleContexts() +{ +#ifdef DEBUG + FILE *out = stdout; + nsCOMPtr shell(pres_shell(mDocShell)); + if (shell) { + nsCOMPtr styleSet; + shell->GetStyleSet(getter_AddRefs(styleSet)); + if (!styleSet) { + fputs("null style set\n", out); + } else { + nsIFrame* root; + shell->GetRootFrame(&root); + if (!root) { + fputs("null root frame\n", out); + } else { + styleSet->ListContexts(root, out); + } + } + } else { + fputs("null pres shell\n", out); + } +#endif + return NS_OK; +} + +NS_IMETHODIMP +nsLayoutDebuggingTools::DumpReflowStats() +{ +#ifdef DEBUG + nsCOMPtr shell(pres_shell(mDocShell)); + if (shell) { +#ifdef MOZ_REFLOW_PERF + shell->DumpReflows(); +#else + printf("************************************************\n"); + printf("Sorry, you have not built with MOZ_REFLOW_PERF=1\n"); + printf("************************************************\n"); +#endif + } +#endif + return NS_OK; +} + +void nsLayoutDebuggingTools::ForceRefresh() +{ + nsCOMPtr vm(view_manager(mDocShell)); + if (!vm) + return; + nsIView* root = nsnull; + vm->GetRootView(root); + if (root) { + vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE); + } +} + +nsresult +nsLayoutDebuggingTools::SetBoolPrefAndRefresh(const char * aPrefName, + PRBool aNewVal) +{ + NS_ENSURE_TRUE(mPrefs && aPrefName, NS_OK); + + mPrefs->SetBoolPref(aPrefName, aNewVal); + mPrefs->SavePrefFile(nsnull); + + ForceRefresh(); + + return NS_OK; +} + +nsresult +nsLayoutDebuggingTools::GetBoolPref(const char * aPrefName, + PRBool *aValue) +{ + NS_ENSURE_TRUE(mPrefs && aPrefName, NS_OK); + + mPrefs->GetBoolPref(aPrefName, aValue); + + return NS_OK; +} diff --git a/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.h b/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.h new file mode 100644 index 00000000000..848b4500709 --- /dev/null +++ b/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.h @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +// vim:cindent:tabstop=4:expandtab:shiftwidth=4: +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is layout debugging code. + * + * The Initial Developer of the Original Code is L. David Baron. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * L. David Baron (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsILayoutDebuggingTools.h" +#include "nsIDocShell.h" +#include "nsCOMPtr.h" +#include "nsIPref.h" + +class nsLayoutDebuggingTools : public nsILayoutDebuggingTools { + +public: + nsLayoutDebuggingTools(); + virtual ~nsLayoutDebuggingTools(); + + NS_DECL_ISUPPORTS + + NS_DECL_NSILAYOUTDEBUGGINGTOOLS + +protected: + void ForceRefresh(); + nsresult GetBoolPref(const char * aPrefName, PRBool *aValue); + nsresult SetBoolPrefAndRefresh(const char * aPrefName, PRBool aNewValue); + + nsCOMPtr mDocShell; + nsCOMPtr mPrefs; + + PRBool mEditorMode; + PRBool mVisualDebugging; + PRBool mVisualEventDebugging; + PRBool mPaintFlashing; + PRBool mPaintDumping; + PRBool mInvalidateDumping; + PRBool mEventDumping; + PRBool mMotionEventDumping; + PRBool mCrossingEventDumping; + PRBool mReflowCounts; +}; diff --git a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp index b540e31d9a4..82ea3e1c25f 100644 --- a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp +++ b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp @@ -84,27 +84,6 @@ nsRegressionTester::~nsRegressionTester() NS_IMPL_ISUPPORTS1(nsRegressionTester, nsILayoutRegressionTester) -NS_IMETHODIMP -nsRegressionTester::OutputTextToFile(nsILocalFile *aFile, PRBool aTruncateFile, const char *aOutputString) -{ - NS_ENSURE_ARG(aOutputString); - - FILE* fp = stdout; - if (aFile) - { - const char* options = (aTruncateFile) ? "wt" : "at"; - nsresult rv = aFile->OpenANSIFileDesc(options, &fp); - if (NS_FAILED(rv)) return rv; - } - - fprintf(fp, aOutputString); - fprintf(fp, "\n"); - if (fp != stdout) - fclose(fp); - return NS_OK; -} - - NS_IMETHODIMP nsRegressionTester::DumpFrameModel(nsIDOMWindow *aWindowToDump, nsILocalFile *aDestFile, PRUint32 aFlagsMask, PRInt32 *aResult) { @@ -160,189 +139,6 @@ nsRegressionTester::DumpFrameModel(nsIDOMWindow *aWindowToDump, nsILocalFile *aD return NS_OK; } -/* void dumpContent (in nsIDOMWindow aWindow, in nsILocalFile aDestFile); */ -NS_IMETHODIMP -nsRegressionTester::DumpContent(nsIDOMWindow *aWindow, nsILocalFile *aDestFile) -{ - NS_ENSURE_ARG(aWindow); - - nsCOMPtr docShell; - nsresult rv = GetDocShellFromWindow(aWindow, getter_AddRefs(docShell)); - if (NS_FAILED(rv)) return rv; - - FILE* fp = stdout; - if (aDestFile) - { - rv = aDestFile->OpenANSIFileDesc("w", &fp); - if (NS_FAILED(rv)) return rv; - } - - DumpContentRecurse(docShell, fp); - DumpMultipleWebShells(aWindow, fp); - - if (fp != stdout) - fclose(fp); - return NS_OK; -} - -/* void dumpFrames (in nsIDOMWindow aWindow, in nsILocalFile aDestFile); */ -NS_IMETHODIMP -nsRegressionTester::DumpFrames(nsIDOMWindow *aWindow, nsILocalFile *aDestFile) -{ - NS_ENSURE_ARG(aWindow); - - nsCOMPtr docShell; - nsresult rv = GetDocShellFromWindow(aWindow, getter_AddRefs(docShell)); - if (NS_FAILED(rv)) return rv; - - FILE* fp = stdout; - if (aDestFile) - { - rv = aDestFile->OpenANSIFileDesc("w", &fp); - if (NS_FAILED(rv)) return rv; - } - - DumpFramesRecurse(docShell, fp); - DumpMultipleWebShells(aWindow, fp); - - if (fp != stdout) - fclose(fp); - return NS_OK; -} - -NS_IMETHODIMP -nsRegressionTester::DumpViews(nsIDOMWindow *aWindow, nsILocalFile *aDestFile) -{ - NS_ENSURE_ARG(aWindow); - - nsCOMPtr docShell; - nsresult rv = GetDocShellFromWindow(aWindow, getter_AddRefs(docShell)); - if (NS_FAILED(rv)) return rv; - - FILE* fp = stdout; - if (aDestFile) - { - rv = aDestFile->OpenANSIFileDesc("w", &fp); - if (NS_FAILED(rv)) return rv; - } - - DumpViewsRecurse(docShell, fp); - DumpMultipleWebShells(aWindow, fp); - - if (fp != stdout) - fclose(fp); - return NS_OK; -} - -/* void dumpWebShells (in nsIDOMWindow aWindow, in nsILocalFile aDestFile); */ -NS_IMETHODIMP -nsRegressionTester::DumpWebShells(nsIDOMWindow *aWindow, nsILocalFile *aDestFile) -{ - NS_ENSURE_ARG(aWindow); - - nsCOMPtr docShell; - nsresult rv = GetDocShellFromWindow(aWindow, getter_AddRefs(docShell)); - nsCOMPtr shellAsItem(do_QueryInterface(docShell)); - if (!shellAsItem) return NS_ERROR_FAILURE; - - FILE* outFile = stdout; - if (aDestFile) - { - rv = aDestFile->OpenANSIFileDesc("w", &outFile); - if (NS_FAILED(rv)) return rv; - } - - DumpAWebShell(shellAsItem, outFile); - if (outFile != stdout) - fclose(outFile); - - return NS_OK; -} - -NS_IMETHODIMP -nsRegressionTester::DumpStyleSheets(nsIDOMWindow *aWindow, nsILocalFile *aDestFile) -{ - NS_ENSURE_ARG(aWindow); - - nsCOMPtr presShell; - nsresult rv = GetPresShellFromWindow(aWindow, getter_AddRefs(presShell)); - if (NS_FAILED(rv)) return rv; - - FILE* outFile = stdout; - if (aDestFile) - { - rv = aDestFile->OpenANSIFileDesc("w", &outFile); - if (NS_FAILED(rv)) return rv; - } - - nsCOMPtr styleSet; - presShell->GetStyleSet(getter_AddRefs(styleSet)); - if (styleSet) - styleSet->List(outFile); - else - fputs("null style set\n", outFile); - - if (outFile != stdout) - fclose(outFile); - return NS_OK; -} - -NS_IMETHODIMP -nsRegressionTester::DumpStyleContexts(nsIDOMWindow *aWindow, nsILocalFile *aDestFile) -{ - NS_ENSURE_ARG(aWindow); - - nsCOMPtr presShell; - nsresult rv = GetPresShellFromWindow(aWindow, getter_AddRefs(presShell)); - if (NS_FAILED(rv)) return rv; - - FILE* outFile = stdout; - if (aDestFile) - { - rv = aDestFile->OpenANSIFileDesc("w", &outFile); - if (NS_FAILED(rv)) return rv; - } - - nsCOMPtr styleSet; - presShell->GetStyleSet(getter_AddRefs(styleSet)); - if (styleSet) - { - nsIFrame* root; - presShell->GetRootFrame(&root); - if (root) - fputs("null root frame\n", outFile); - else - styleSet->ListContexts(root, outFile); - } - else - fputs("null style set\n", outFile); - - if (outFile != stdout) - fclose(outFile); - return NS_OK; -} - -/* void dumpReflowStats (in nsIDOMWindow aWindow, in nsILocalFile aDestFile); */ -NS_IMETHODIMP -nsRegressionTester::DumpReflowStats(nsIDOMWindow *aWindow, nsILocalFile* /* aDestFile */) -{ - NS_ENSURE_ARG(aWindow); - - nsCOMPtr presShell; - nsresult rv = GetPresShellFromWindow(aWindow, getter_AddRefs(presShell)); - if (NS_FAILED(rv)) return rv; - -#ifdef MOZ_REFLOW_PERF - presShell->DumpReflows(); -#else - fprintf(stdout, "***********************************\n"); - fprintf(stdout, "Sorry, you haven't built with MOZ_REFLOW_PERF=1\n"); - fprintf(stdout, "***********************************\n"); -#endif - - return NS_OK; -} - NS_IMETHODIMP nsRegressionTester::CompareFrameModels(nsILocalFile *aBaseFile, nsILocalFile *aVerFile, PRUint32 aFlags, PRInt32 *aResult) { @@ -377,92 +173,6 @@ nsRegressionTester::CompareFrameModels(nsILocalFile *aBaseFile, nsILocalFile *aV return NS_OK; } -NS_IMETHODIMP -nsRegressionTester::GetShowFrameBorders(PRBool *aShowFrameBorders) -{ - NS_ENSURE_ARG_POINTER(aShowFrameBorders); - NS_ENSURE_SUCCESS(EnsureLayoutDebugger(), NS_ERROR_FAILURE); - return mLayoutDebugger->GetShowFrameBorders(aShowFrameBorders); -} - -NS_IMETHODIMP -nsRegressionTester::SetShowFrameBorders(PRBool aShowFrameBorders) -{ - NS_ENSURE_SUCCESS(EnsureLayoutDebugger(), NS_ERROR_FAILURE); - nsresult rv = mLayoutDebugger->SetShowFrameBorders(aShowFrameBorders); - RefreshAllWindows(); - return rv; -} - -NS_IMETHODIMP -nsRegressionTester::GetShowEventTargetFrameBorder(PRBool *aShowEventTargetFrameBorder) -{ - NS_ENSURE_ARG_POINTER(aShowEventTargetFrameBorder); - NS_ENSURE_SUCCESS(EnsureLayoutDebugger(), NS_ERROR_FAILURE); - return mLayoutDebugger->GetShowEventTargetFrameBorder(aShowEventTargetFrameBorder); -} - -NS_IMETHODIMP -nsRegressionTester::SetShowEventTargetFrameBorder(PRBool aShowEventTargetFrameBorder) -{ - NS_ENSURE_SUCCESS(EnsureLayoutDebugger(), NS_ERROR_FAILURE); - nsresult rv = mLayoutDebugger->SetShowEventTargetFrameBorder(aShowEventTargetFrameBorder); - RefreshAllWindows(); - return rv; -} - -NS_IMETHODIMP -nsRegressionTester::SetShowReflowStats(nsIDOMWindow *aWindow, PRBool inShow) -{ - nsCOMPtr presShell; - nsresult rv = GetPresShellFromWindow(aWindow, getter_AddRefs(presShell)); - if (NS_FAILED(rv)) return rv; - -#ifdef MOZ_REFLOW_PERF - presShell->SetPaintFrameCount(inShow); -#else - printf("***********************************************\n"); - printf("Sorry, you haven't built with MOZ_REFLOW_PERF=1\n"); - printf("***********************************************\n"); -#endif - - return NS_OK; -} - -nsresult -nsRegressionTester::EnsureLayoutDebugger() -{ - if (!mLayoutDebugger) - { - nsresult rv; - mLayoutDebugger = do_CreateInstance(kLayoutDebuggerCID, &rv); - if (NS_FAILED(rv)) - return rv; - } - - return NS_OK; -} - -nsresult -nsRegressionTester::RefreshAllWindows() -{ - nsresult rv; - // hack. Toggle the underline links pref to get stuff to redisplay - nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefBranch) - { - PRBool underlineLinksPref; - rv = prefBranch->GetBoolPref("browser.underline_anchors", &underlineLinksPref); - if (NS_SUCCEEDED(rv)) - { - prefBranch->SetBoolPref("browser.underline_anchors", !underlineLinksPref); - prefBranch->SetBoolPref("browser.underline_anchors", underlineLinksPref); - } - } - return NS_OK; -} - - nsresult nsRegressionTester::GetDocShellFromWindow(nsIDOMWindow* inWindow, nsIDocShell** outShell) { @@ -471,205 +181,3 @@ nsRegressionTester::GetDocShellFromWindow(nsIDOMWindow* inWindow, nsIDocShell** return scriptObj->GetDocShell(outShell); } - - -nsresult -nsRegressionTester::GetPresShellFromWindow(nsIDOMWindow* inWindow, nsIPresShell** outShell) -{ - nsCOMPtr docShell; - GetDocShellFromWindow(inWindow, getter_AddRefs(docShell)); - if (!docShell) return NS_ERROR_FAILURE; - - nsresult rv = docShell->GetPresShell(outShell); - if (NS_FAILED(rv)) return rv; - if (!*outShell) return NS_ERROR_FAILURE; - - return NS_OK; -} - -#if 0 -#pragma mark - -#endif - -void -nsRegressionTester::DumpMultipleWebShells(nsIDOMWindow* aWindow, FILE* aOut) -{ - nsCOMPtr docShell; - GetDocShellFromWindow(aWindow, getter_AddRefs(docShell)); - if (!docShell) return; - - PRInt32 count; - nsCOMPtr docShellAsNode(do_QueryInterface(docShell)); - if (docShellAsNode) { - docShellAsNode->GetChildCount(&count); - if (count > 0) { - nsCOMPtr docShellAsStupidItem(do_QueryInterface(docShell)); - fprintf(aOut, "webshells= \n"); - DumpAWebShell(docShellAsStupidItem, aOut); - } - } -} - - -void -nsRegressionTester::DumpAWebShell(nsIDocShellTreeItem* aShellItem, FILE* aOut, PRInt32 aIndent) -{ - nsXPIDLString name; - nsAutoString str; - nsCOMPtr parent; - PRInt32 i; - - for (i = aIndent; --i >= 0; ) fprintf(aOut, " "); - - fprintf(aOut, "%p '", aShellItem); - aShellItem->GetName(getter_Copies(name)); - aShellItem->GetSameTypeParent(getter_AddRefs(parent)); - str.Assign(name); - fputs(NS_LossyConvertUCS2toASCII(str).get(), aOut); - fprintf(aOut, "' parent=%p <\n", parent.get()); - - aIndent++; - nsCOMPtr shellAsNode(do_QueryInterface(aShellItem)); - - PRInt32 numChildren; - shellAsNode->GetChildCount(&numChildren); - for (i = 0; i < numChildren; i++) { - nsCOMPtr child; - shellAsNode->GetChildAt(i, getter_AddRefs(child)); - if (child) { - DumpAWebShell(child, aOut, aIndent); - } - } - aIndent--; - for (i = aIndent; --i >= 0; ) fprintf(aOut, " "); - fputs(">\n", aOut); -} - - -void -nsRegressionTester::DumpContentRecurse(nsIDocShell* inDocShell, FILE* inDestFile) -{ - if (inDocShell) - { - fprintf(inDestFile, "docshell=%p \n", inDocShell); - nsCOMPtr presShell; - inDocShell->GetPresShell(getter_AddRefs(presShell)); - if (presShell) - { - nsCOMPtr doc; - presShell->GetDocument(getter_AddRefs(doc)); - if (doc) - { - nsCOMPtr root; - doc->GetRootContent(getter_AddRefs(root)); - if (root) - root->List(inDestFile); - } - } - else - { - fputs("null pres shell\n", inDestFile); - } - - // dump the frames of the sub documents - nsCOMPtr docShellAsNode(do_QueryInterface(inDocShell)); - PRInt32 numChildren; - docShellAsNode->GetChildCount(&numChildren); - for (PRInt32 i = 0; i < numChildren; i++) - { - nsCOMPtr child; - docShellAsNode->GetChildAt(i, getter_AddRefs(child)); - nsCOMPtr childAsShell(do_QueryInterface(child)); - if (child) - DumpContentRecurse(childAsShell, inDestFile); - } - } -} - - -void -nsRegressionTester::DumpFramesRecurse(nsIDocShell* aDocShell, FILE* inDestFile) -{ - if (aDocShell) - { - fprintf(inDestFile, "webshell=%p \n", aDocShell); - - nsCOMPtr presShell; - aDocShell->GetPresShell(getter_AddRefs(presShell)); - if (presShell) - { - nsIFrame* root; - presShell->GetRootFrame(&root); - if (root) - { - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); - - nsIFrameDebug* fdbg; - if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) - fdbg->List(presContext, inDestFile, 0); - } - } - else - { - fputs("null pres shell\n", inDestFile); - } - - // dump the frames of the sub documents - nsCOMPtr docShellAsNode(do_QueryInterface(aDocShell)); - PRInt32 numChildren; - docShellAsNode->GetChildCount(&numChildren); - for (PRInt32 i = 0; i < numChildren; i++) - { - nsCOMPtr child; - docShellAsNode->GetChildAt(i, getter_AddRefs(child)); - nsCOMPtr childAsShell(do_QueryInterface(child)); - if (childAsShell) - DumpFramesRecurse(childAsShell, inDestFile); - } - } -} - - - -void -nsRegressionTester::DumpViewsRecurse(nsIDocShell* aDocShell, FILE* inDestFile) -{ - if (aDocShell) - { - fprintf(inDestFile, "webshell=%p \n", aDocShell); - - nsCOMPtr presShell; - aDocShell->GetPresShell(getter_AddRefs(presShell)); - if (presShell) - { - nsCOMPtr vm; - presShell->GetViewManager(getter_AddRefs(vm)); - if (vm) - { - nsIView* root; - vm->GetRootView(root); - if (root) - root->List(inDestFile); - } - } - else - { - fputs("null pres shell\n", inDestFile); - } - - // dump the frames of the sub documents - nsCOMPtr docShellAsNode(do_QueryInterface(aDocShell)); - PRInt32 numChildren; - docShellAsNode->GetChildCount(&numChildren); - for (PRInt32 i = 0; i < numChildren; i++) - { - nsCOMPtr child; - docShellAsNode->GetChildAt(i, getter_AddRefs(child)); - nsCOMPtr childAsShell(do_QueryInterface(child)); - if (childAsShell) - DumpViewsRecurse(childAsShell, inDestFile); - } - } -} - diff --git a/mozilla/extensions/layout-debug/src/nsRegressionTester.h b/mozilla/extensions/layout-debug/src/nsRegressionTester.h index d0e72770f23..69aa48d51ae 100644 --- a/mozilla/extensions/layout-debug/src/nsRegressionTester.h +++ b/mozilla/extensions/layout-debug/src/nsRegressionTester.h @@ -45,23 +45,7 @@ public: virtual ~nsRegressionTester(); protected: - - nsresult EnsureLayoutDebugger(); - nsresult RefreshAllWindows(); - nsresult GetDocShellFromWindow(nsIDOMWindow* inWindow, nsIDocShell** outShell); - nsresult GetPresShellFromWindow(nsIDOMWindow* inWindow, nsIPresShell** outShell); - - void DumpAWebShell(nsIDocShellTreeItem* inShellItem, FILE* inDestFile, PRInt32 inIndent = 0); - void DumpMultipleWebShells(nsIDOMWindow* inWindow, FILE* inDestFile); - void DumpContentRecurse(nsIDocShell* inDocShell, FILE* inDestFile); - void DumpFramesRecurse(nsIDocShell* aDocShell, FILE* inDestFile); - void DumpViewsRecurse(nsIDocShell* aDocShell, FILE* inDestFile); - -protected: - - nsCOMPtr mLayoutDebugger; - }; diff --git a/mozilla/extensions/layout-debug/ui/Makefile.in b/mozilla/extensions/layout-debug/ui/Makefile.in new file mode 100644 index 00000000000..de9b7afe02f --- /dev/null +++ b/mozilla/extensions/layout-debug/ui/Makefile.in @@ -0,0 +1,29 @@ +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/extensions/layout-debug/ui/content/contents.rdf b/mozilla/extensions/layout-debug/ui/content/contents.rdf new file mode 100644 index 00000000000..e5e50dfef75 --- /dev/null +++ b/mozilla/extensions/layout-debug/ui/content/contents.rdf @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + chrome://layoutdebug/content/layoutdebug-overlay.xul + + diff --git a/mozilla/extensions/layout-debug/ui/content/layoutdebug-overlay.xul b/mozilla/extensions/layout-debug/ui/content/layoutdebug-overlay.xul new file mode 100644 index 00000000000..7e1358facdd --- /dev/null +++ b/mozilla/extensions/layout-debug/ui/content/layoutdebug-overlay.xul @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + diff --git a/mozilla/extensions/layout-debug/ui/content/layoutdebug.js b/mozilla/extensions/layout-debug/ui/content/layoutdebug.js new file mode 100644 index 00000000000..9d8324ce138 --- /dev/null +++ b/mozilla/extensions/layout-debug/ui/content/layoutdebug.js @@ -0,0 +1,406 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the layout debugging UI. + * + * The Initial Developer of the Original Code is L. David Baron. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * L. David Baron (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gBrowser; +var gProgressListener; +var gDebugger; +var gRTestIndexList; +var gRTestURLList = null; + +const nsILayoutDebuggingTools = Components.interfaces.nsILayoutDebuggingTools; +const nsIDocShell = Components.interfaces.nsIDocShell; +const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; + +const NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID = "@mozilla.org/layout-debug/layout-debuggingtools;1"; + +function nsLDBBrowserContentListener() +{ + this.init(); +} + +nsLDBBrowserContentListener.prototype = { + + init : function() + { + this.mStatusText = document.getElementById("status-text"); + this.mURLBar = document.getElementById("urlbar"); + this.mForwardButton = document.getElementById("forward-button"); + this.mBackButton = document.getElementById("back-button"); + this.mStopButton = document.getElementById("stop-button"); + }, + + QueryInterface : function(aIID) + { + if (aIID.equals(Components.interfaces.nsIWebProgressListener) || + aIID.equals(Components.interfaces.nsISupportsWeakReference) || + aIID.equals(Components.interfaces.nsISupports)) + return this; + throw Components.results.NS_NOINTERFACE; + }, + + // nsIWebProgressListener implementation + onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) + { + if (aStateFlags & nsIWebProgressListener.STATE_START) { + this.setButtonEnabled(this.mStopButton, true); + this.setButtonEnabled(this.mForwardButton, gBrowser.canGoForward); + this.setButtonEnabled(this.mBackButton, gBrowser.canGoBack); + + this.mLoading = true; + } else if (aStateFlags & nsIWebProgressListener.STATE_STOP) { + this.setButtonEnabled(this.mStopButton, false); + this.mStatusText.value = ""; + + if (gRTestURLList && this.mLoading) { + // Let other things happen in the first 20ms, since this + // doesn't really seem to be when the page is done loading. + setTimeout("gRTestURLList.doneURL()", 20); + } + this.mLoading = false; + } + }, + + onProgressChange : function(aWebProgress, aRequest, + aCurSelfProgress, aMaxSelfProgress, + aCurTotalProgress, aMaxTotalProgress) + { + }, + + onLocationChange : function(aWebProgress, aRequest, aLocation) + { + this.mURLBar.value = aLocation.spec; + }, + + onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) + { + this.mStatusText.value = aMessage; + }, + + onSecurityChange : function(aWebProgress, aRequest, aState) + { + }, + + // non-interface methods + setButtonEnabled : function(aButtonElement, aEnabled) + { + if (aEnabled) + aButtonElement.removeAttribute("disabled"); + else + aButtonElement.setAttribute("disabled", "true"); + }, + + mStatusText : null, + mURLBar : null, + mForwardButton : null, + mBackButton : null, + mStopButton : null, + + mLoading : false, + +} + +function OnLDBLoad() +{ + gBrowser = document.getElementById("browser"); + + gProgressListener = new nsLDBBrowserContentListener(); + gBrowser.addProgressListener(gProgressListener); + + gDebugger = Components.classes[NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID]. + createInstance(nsILayoutDebuggingTools); + + if (window.arguments && window.arguments[0]) + gBrowser.loadURI(window.arguments[0]); + else + gBrowser.goHome(); + + // XXX Shouldn't this be gBrowser.contentWindow? + var win = gBrowser.docShell.getInterface(Components.interfaces.nsIDOMWindow); + gDebugger.init(win); + + checkPersistentMenus(); + gRTestIndexList = new RTestIndexList(); +} + +function checkPersistentMenu(item) +{ + var menuitem = document.getElementById("menu_" + item); + menuitem.setAttribute("checked", gDebugger[item]); +} + +function checkPersistentMenus() +{ + // Restore the toggles that are stored in prefs. + checkPersistentMenu("paintFlashing"); + checkPersistentMenu("paintDumping"); + checkPersistentMenu("invalidateDumping"); + checkPersistentMenu("eventDumping"); + checkPersistentMenu("motionEventDumping"); + checkPersistentMenu("crossingEventDumping"); + checkPersistentMenu("reflowCounts"); +} + + +function OnLDBUnload() +{ + gBrowser.removeProgressListener(gProgressListener); +} + +function toggle(menuitem) +{ + // trim the initial "menu_" + var feature = menuitem.id.substring(5); + gDebugger[feature] = menuitem.getAttribute("checked") == "true"; +} + +const LDB_RDFNS = "http://mozilla.org/newlayout/LDB-rdf#"; +const NC_RDFNS = "http://home.netscape.com/NC-rdf#"; + +function RTestIndexList() { + this.init(); +} + +RTestIndexList.prototype = { + + init : function() + { + const nsIPrefService = Components.interfaces.nsIPrefService; + const PREF_SERVICE_CONTRACTID = "@mozilla.org/preferences-service;1"; + const PREF_BRANCH_NAME = "layout_debugger.rtest_url."; + const nsIRDFService = Components.interfaces.nsIRDFService; + const RDF_SERVICE_CONTRACTID = "@mozilla.org/rdf/rdf-service;1"; + const nsIRDFDataSource = Components.interfaces.nsIRDFDataSource; + const RDF_DATASOURCE_CONTRACTID = + "@mozilla.org/rdf/datasource;1?name=in-memory-datasource"; + + this.mPrefService = Components.classes[PREF_SERVICE_CONTRACTID]. + getService(nsIPrefService); + this.mPrefBranch = this.mPrefService.getBranch(PREF_BRANCH_NAME); + + this.mRDFService = Components.classes[RDF_SERVICE_CONTRACTID]. + getService(nsIRDFService); + this.mDataSource = Components.classes[RDF_DATASOURCE_CONTRACTID]. + createInstance(nsIRDFDataSource); + + this.mLDB_Root = this.mRDFService.GetResource(LDB_RDFNS + "Root"); + this.mNC_Name = this.mRDFService.GetResource(NC_RDFNS + "name"); + this.mNC_Child = this.mRDFService.GetResource(NC_RDFNS + "child"); + + this.load(); + + document.getElementById("menu_RTest_baseline").database. + AddDataSource(this.mDataSource); + document.getElementById("menu_RTest_verify").database. + AddDataSource(this.mDataSource); + document.getElementById("menu_RTest_remove").database. + AddDataSource(this.mDataSource); + }, + + save : function() + { + this.mPrefBranch.deleteBranch(""); + + const nsIRDFLiteral = Components.interfaces.nsIRDFLiteral; + const nsIRDFResource = Components.interfaces.nsIRDFResource; + var etor = this.mDataSource.GetTargets(this.mLDB_Root, + this.mNC_Child, true); + var i = 0; + while (etor.hasMoreElements()) { + var resource = etor.getNext().QueryInterface(nsIRDFResource); + var literal = this.mDataSource.GetTarget(resource, this.mNC_Name, true); + literal = literal.QueryInterface(nsIRDFLiteral); + this.mPrefBranch.setCharPref(i.toString(), literal.Value); + ++i; + } + + this.mPrefService.savePrefFile(null); + }, + + load : function() + { + var count = {value:null}; + var prefList = this.mPrefBranch.getChildList("", count); + + var i = 0; + for (var pref in prefList) { + var file = this.mPrefBranch.getCharPref(pref); + var resource = this.mRDFService.GetResource(file); + var literal = this.mRDFService.GetLiteral(file); + this.mDataSource.Assert(this.mLDB_Root, this.mNC_Child, resource, true); + this.mDataSource.Assert(resource, this.mNC_Name, literal, true); + ++i; + } + + }, + + /* Add a new list of regression tests to the menus. */ + add : function() + { + const nsIFilePicker = Components.interfaces.nsIFilePicker; + const NS_FILEPICKER_CONTRACTID = "@mozilla.org/filepicker;1"; + + var fp = Components.classes[NS_FILEPICKER_CONTRACTID]. + createInstance(nsIFilePicker); + + // XXX l10n (but this is just for 5 developers, so no problem) + fp.init(window, "New Regression Test List", nsIFilePicker.modeOpen); + fp.appendFilters(nsIFilePicker.filterAll); + fp.defaultString = "rtest.lst"; + if (fp.show() != nsIFilePicker.returnOK) + return; + + var file = fp.file.persistentDescriptor; + var resource = this.mRDFService.GetResource(file); + var literal = this.mRDFService.GetLiteral(file); + this.mDataSource.Assert(this.mLDB_Root, this.mNC_Child, resource, true); + this.mDataSource.Assert(resource, this.mNC_Name, literal, true); + + this.save(); + + }, + + remove : function(file) + { + var resource = this.mRDFService.GetResource(file); + var literal = this.mRDFService.GetLiteral(file); + this.mDataSource.Unassert(this.mLDB_Root, this.mNC_Child, resource); + this.mDataSource.Unassert(resource, this.mNC_Name, literal); + + this.save(); + }, + + mPrefBranch : null, + mPrefService : null, + mRDFService : null, + mDataSource : null, + mLDB_Root : null, + mNC_Child : null, + mNC_Name : null, +} + +const nsIFileInputStream = Components.interfaces.nsIFileInputStream; +const nsILineInputStream = Components.interfaces.nsILineInputStream; +const nsILocalFile = Components.interfaces.nsILocalFile; +const nsIFileURL = Components.interfaces.nsIFileURL; + +const NS_LOCAL_FILE_CONTRACTID = "@mozilla.org/file/local;1"; +const NS_STANDARDURL_CONTRACTID = "@mozilla.org/network/standard-url;1"; +const NS_LOCALFILEINPUTSTREAM_CONTRACTID = + "@mozilla.org/network/file-input-stream;1"; + + +function RunRTest(aFilename, aIsBaseline) +{ + if (gRTestURLList) { + // XXX Does alert work? + alert("Already running regression test.\n"); + return; + } + + dump("Running " + (aIsBaseline?"baseline":"verify") + " test for " + aFilename + ".\n"); + + var listFile = Components.classes[NS_LOCAL_FILE_CONTRACTID]. + createInstance(nsILocalFile); + listFile.persistentDescriptor = aFilename; + gRTestURLList = new RTestURLList(listFile, aIsBaseline); + gRTestURLList.startURL(); +} + +function RTestURLList(aLocalFile, aIsBaseline) { + this.init(aLocalFile, aIsBaseline); +} + +RTestURLList.prototype = { + init : function(aLocalFile, aIsBaseline) + { + this.mIsBaseline = aIsBaseline; + this.mURLs = new Array(); + this.readFileList(aLocalFile); + }, + + readFileList : function(aLocalFile) + { + var dirURL = Components.classes[NS_STANDARDURL_CONTRACTID]. + createInstance(nsIFileURL); + dirURL.file = aLocalFile.parent; + + var fis = Components.classes[NS_LOCALFILEINPUTSTREAM_CONTRACTID]. + createInstance(nsIFileInputStream); + fis.init(aLocalFile, -1, -1, false); + var lis = fis.QueryInterface(nsILineInputStream); + + var line = {value:null}; + while (lis.readLine(line)) { + var str = line.value; + str = /^[^#]*/.exec(str); // strip everything after "#" + str = /\S*/.exec(str); // take the first chunk of non-whitespace + if (!str || str == "") + continue; + + var item = dirURL.resolve(str); + if (item.match(/\/rtest.lst$/)) { + var itemurl = Components.classes[NS_STANDARDURL_CONTRACTID]. + createInstance(nsIFileURL); + itemurl.spec = item; + this.readFileList(itemurl.file); + } else { + this.mURLs.push(item); + } + } + }, + + doneURL : function() { + // XXX Dump or compare regression test data here! + + this.mCurrentURL = null; + + this.startURL(); + }, + + startURL : function() { + this.mCurrentURL = this.mURLs.shift(); + if (!this.mCurrentURL) { + gRTestURLList = null; + return; + } + + gBrowser.loadURI(this.mCurrentURL); + }, + + mURLs : null, + mCurrentURL : null, + mIsBaseline : null, +} diff --git a/mozilla/extensions/layout-debug/ui/content/layoutdebug.xul b/mozilla/extensions/layout-debug/ui/content/layoutdebug.xul new file mode 100644 index 00000000000..233a85e5533 --- /dev/null +++ b/mozilla/extensions/layout-debug/ui/content/layoutdebug.xul @@ -0,0 +1,225 @@ + + + + + %layoutdebugDTD; + + + + +]> + + + + + + + + + + + + - +
URL:
- - - - + + + + diff --git a/mozilla/layout/tools/tests/debug_utils.html b/mozilla/layout/tools/tests/debug_utils.html index 75cb635f7b7..310eac15e19 100644 --- a/mozilla/layout/tools/tests/debug_utils.html +++ b/mozilla/layout/tools/tests/debug_utils.html @@ -6,60 +6,61 @@ - +

Layout Debug Utils

Note that these only work in debug builds @@ -87,7 +88,7 @@ function DumpWebShells() + onchange="SetShowReflowStats(document.windowform.showReflowStatsCheck.checked)">

diff --git a/mozilla/layout/tools/tests/regression_tests.js b/mozilla/layout/tools/tests/regression_tests.js index 878b2ac3eec..330f03280f5 100644 --- a/mozilla/layout/tools/tests/regression_tests.js +++ b/mozilla/layout/tools/tests/regression_tests.js @@ -320,7 +320,7 @@ function ChooseOutputDirectory(inputElementID) function CompareFrameDumps(testFileBasename, baselineDir, baselineExt, verifyDir, verifyExt) { - var debugObject = Components.classes["@mozilla.org/layout_debug/regressiontester;1"].createInstance(nsILayoutRegressionTester); + var debugObject = Components.classes["@mozilla.org/layout-debug/regressiontester;1"].createInstance(nsILayoutRegressionTester); var baseFile = baselineDir.clone(); baseFile.append(testFileBasename + baselineExt); @@ -341,7 +341,7 @@ function CompareFrameDumps(testFileBasename, baselineDir, baselineExt, verifyDir function DumpFrames(testWindow, testFileName, outputDir, outputFileExtension) { - var debugObject = Components.classes["@mozilla.org/layout_debug/regressiontester;1"].createInstance(nsILayoutRegressionTester); + var debugObject = Components.classes["@mozilla.org/layout-debug/regressiontester;1"].createInstance(nsILayoutRegressionTester); var outputFile = outputDir.clone(); outputFile.append(testFileName.replace(".html", outputFileExtension));