зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1566215 - Part 3: Move debugging state management into layoutdebug.js. r=dbaron
Many of these features are non-functional these days, but I'll keep them hooked up in case we decide to fix them. Differential Revision: https://phabricator.services.mozilla.com/D38413 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b92599beb1
Коммит
3c7a36d829
|
@ -22,16 +22,13 @@ interface nsILayoutDebuggingTools : nsISupports
|
|||
*/
|
||||
void init(in mozIDOMWindow win);
|
||||
|
||||
// Repaint the window.
|
||||
void forceRefresh();
|
||||
|
||||
/* 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;
|
||||
void setVisualDebugging(in boolean enabled);
|
||||
void setVisualEventDebugging(in boolean enabled);
|
||||
void setReflowCounts(in boolean enabled);
|
||||
|
||||
/* Run various tests. */
|
||||
void dumpWebShells();
|
||||
|
|
|
@ -88,31 +88,6 @@ nsLayoutDebuggingTools::Init(mozIDOMWindow* aWin) {
|
|||
}
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
mPaintFlashing =
|
||||
Preferences::GetBool("nglayout.debug.paint_flashing", mPaintFlashing);
|
||||
mPaintDumping =
|
||||
Preferences::GetBool("nglayout.debug.paint_dumping", mPaintDumping);
|
||||
mInvalidateDumping = Preferences::GetBool("nglayout.debug.invalidate_dumping",
|
||||
mInvalidateDumping);
|
||||
mEventDumping =
|
||||
Preferences::GetBool("nglayout.debug.event_dumping", mEventDumping);
|
||||
mMotionEventDumping = Preferences::GetBool(
|
||||
"nglayout.debug.motion_event_dumping", mMotionEventDumping);
|
||||
mCrossingEventDumping = Preferences::GetBool(
|
||||
"nglayout.debug.crossing_event_dumping", mCrossingEventDumping);
|
||||
mReflowCounts =
|
||||
Preferences::GetBool("layout.reflow.showframecounts", mReflowCounts);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetVisualDebugging(bool* aVisualDebugging) {
|
||||
#ifdef DEBUG
|
||||
*aVisualDebugging = nsFrame::GetShowFrameBorders();
|
||||
#else
|
||||
*aVisualDebugging = false;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -125,16 +100,6 @@ nsLayoutDebuggingTools::SetVisualDebugging(bool aVisualDebugging) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetVisualEventDebugging(bool* aVisualEventDebugging) {
|
||||
#ifdef DEBUG
|
||||
*aVisualEventDebugging = nsFrame::GetShowEventTargetFrameBorder();
|
||||
#else
|
||||
*aVisualEventDebugging = false;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetVisualEventDebugging(bool aVisualEventDebugging) {
|
||||
#ifdef DEBUG
|
||||
|
@ -144,95 +109,12 @@ nsLayoutDebuggingTools::SetVisualEventDebugging(bool aVisualEventDebugging) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetPaintFlashing(bool* aPaintFlashing) {
|
||||
*aPaintFlashing = mPaintFlashing;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetPaintFlashing(bool aPaintFlashing) {
|
||||
mPaintFlashing = aPaintFlashing;
|
||||
return SetBoolPrefAndRefresh("nglayout.debug.paint_flashing", mPaintFlashing);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetPaintDumping(bool* aPaintDumping) {
|
||||
*aPaintDumping = mPaintDumping;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetPaintDumping(bool aPaintDumping) {
|
||||
mPaintDumping = aPaintDumping;
|
||||
return SetBoolPrefAndRefresh("nglayout.debug.paint_dumping", mPaintDumping);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetInvalidateDumping(bool* aInvalidateDumping) {
|
||||
*aInvalidateDumping = mInvalidateDumping;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetInvalidateDumping(bool aInvalidateDumping) {
|
||||
mInvalidateDumping = aInvalidateDumping;
|
||||
return SetBoolPrefAndRefresh("nglayout.debug.invalidate_dumping",
|
||||
mInvalidateDumping);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetEventDumping(bool* aEventDumping) {
|
||||
*aEventDumping = mEventDumping;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetEventDumping(bool aEventDumping) {
|
||||
mEventDumping = aEventDumping;
|
||||
return SetBoolPrefAndRefresh("nglayout.debug.event_dumping", mEventDumping);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetMotionEventDumping(bool* aMotionEventDumping) {
|
||||
*aMotionEventDumping = mMotionEventDumping;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetMotionEventDumping(bool aMotionEventDumping) {
|
||||
mMotionEventDumping = aMotionEventDumping;
|
||||
return SetBoolPrefAndRefresh("nglayout.debug.motion_event_dumping",
|
||||
mMotionEventDumping);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetCrossingEventDumping(bool* aCrossingEventDumping) {
|
||||
*aCrossingEventDumping = mCrossingEventDumping;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetCrossingEventDumping(bool aCrossingEventDumping) {
|
||||
mCrossingEventDumping = aCrossingEventDumping;
|
||||
return SetBoolPrefAndRefresh("nglayout.debug.crossing_event_dumping",
|
||||
mCrossingEventDumping);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::GetReflowCounts(bool* aShow) {
|
||||
*aShow = mReflowCounts;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetReflowCounts(bool aShow) {
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_NOT_INITIALIZED);
|
||||
if (PresShell* presShell = GetPresShell(mDocShell)) {
|
||||
#ifdef MOZ_REFLOW_PERF
|
||||
presShell->SetPaintFrameCount(aShow);
|
||||
SetBoolPrefAndRefresh("layout.reflow.showframecounts", aShow);
|
||||
mReflowCounts = aShow;
|
||||
#else
|
||||
printf("************************************************\n");
|
||||
printf("Sorry, you have not built with MOZ_REFLOW_PERF=1\n");
|
||||
|
@ -440,13 +322,14 @@ nsLayoutDebuggingTools::DumpReflowStats() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsLayoutDebuggingTools::ForceRefresh() {
|
||||
nsresult nsLayoutDebuggingTools::ForceRefresh() {
|
||||
RefPtr<nsViewManager> vm(view_manager(mDocShell));
|
||||
if (!vm) return;
|
||||
if (!vm) return NS_OK;
|
||||
nsView* root = vm->GetRootView();
|
||||
if (root) {
|
||||
vm->InvalidateView(root);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsLayoutDebuggingTools::SetBoolPrefAndRefresh(const char* aPrefName,
|
||||
|
|
|
@ -22,7 +22,6 @@ class nsLayoutDebuggingTools : public nsILayoutDebuggingTools {
|
|||
protected:
|
||||
virtual ~nsLayoutDebuggingTools();
|
||||
|
||||
void ForceRefresh();
|
||||
nsresult SetBoolPrefAndRefresh(const char* aPrefName, bool aNewValue);
|
||||
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
|
|
|
@ -6,9 +6,94 @@ var gBrowser;
|
|||
var gProgressListener;
|
||||
var gDebugger;
|
||||
|
||||
const { Preferences } = ChromeUtils.import(
|
||||
"resource://gre/modules/Preferences.jsm"
|
||||
);
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID =
|
||||
"@mozilla.org/layout-debug/layout-debuggingtools;1";
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const FEATURES = {
|
||||
paintFlashing: "nglayout.debug.paint_flashing",
|
||||
paintDumping: "nglayout.debug.paint_dumping",
|
||||
invalidateDumping: "nglayout.debug.invalidate_dumping",
|
||||
eventDumping: "nglayout.debug.event_dumping",
|
||||
motionEventDumping: "nglayout.debug.motion_event_dumping",
|
||||
crossingEventDumping: "nglayout.debug.crossing_event_dumping",
|
||||
reflowCounts: "layout.reflow.showframecounts",
|
||||
};
|
||||
|
||||
const COMMANDS = [
|
||||
"dumpWebShells",
|
||||
"dumpContent",
|
||||
"dumpFrames",
|
||||
"dumpViews",
|
||||
"dumpStyleSheets",
|
||||
"dumpMatchedRules",
|
||||
"dumpComputedStyles",
|
||||
"dumpReflowStats",
|
||||
];
|
||||
|
||||
class Debugger {
|
||||
constructor() {
|
||||
this._flags = new Map();
|
||||
this._visualDebugging = false;
|
||||
this._visualEventDebugging = false;
|
||||
this._tools = Cc[NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID].createInstance(
|
||||
Ci.nsILayoutDebuggingTools
|
||||
);
|
||||
|
||||
for (let [name, pref] of Object.entries(FEATURES)) {
|
||||
this._flags.set(name, !!Preferences.get(pref, false));
|
||||
}
|
||||
this._tools.init(gBrowser.contentWindow);
|
||||
}
|
||||
|
||||
get visualDebugging() {
|
||||
return this._visualDebugging;
|
||||
}
|
||||
|
||||
set visualDebugging(v) {
|
||||
v = !!v;
|
||||
this._visualDebugging = v;
|
||||
this._tools.setVisualDebugging(v);
|
||||
}
|
||||
|
||||
get visualEventDebugging() {
|
||||
return this._visualEventDebugging;
|
||||
}
|
||||
|
||||
set visualEventDebugging(v) {
|
||||
v = !!v;
|
||||
this._visualEventDebugging = v;
|
||||
this._tools.setVisualEventDebugging(v);
|
||||
}
|
||||
}
|
||||
|
||||
for (let [name, pref] of Object.entries(FEATURES)) {
|
||||
Object.defineProperty(Debugger.prototype, name, {
|
||||
get: function() {
|
||||
return this._flags.get(name);
|
||||
},
|
||||
set: function(v) {
|
||||
v = !!v;
|
||||
Preferences.set(pref, v);
|
||||
this._flags.set(name, v);
|
||||
// XXX PresShell should watch for this pref change itself.
|
||||
if (name == "reflowCounts") {
|
||||
this._tools.setReflowCounts(v);
|
||||
}
|
||||
this._tools.forceRefresh();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
for (let name of COMMANDS) {
|
||||
Debugger.prototype[name] = function() {
|
||||
this._tools[name]();
|
||||
};
|
||||
}
|
||||
|
||||
function nsLDBBrowserContentListener() {
|
||||
this.init();
|
||||
|
@ -97,9 +182,7 @@ function OnLDBLoad() {
|
|||
gProgressListener = new nsLDBBrowserContentListener();
|
||||
gBrowser.addProgressListener(gProgressListener);
|
||||
|
||||
gDebugger = Cc[NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID].createInstance(
|
||||
Ci.nsILayoutDebuggingTools
|
||||
);
|
||||
gDebugger = new Debugger();
|
||||
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
gBrowser.loadURI(window.arguments[0], {
|
||||
|
@ -113,8 +196,6 @@ function OnLDBLoad() {
|
|||
});
|
||||
}
|
||||
|
||||
gDebugger.init(gBrowser.contentWindow);
|
||||
|
||||
checkPersistentMenus();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче