зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1590185 Part 2 - Support paged mode layout in layout debugger. r=dbaron
This patch adds a menu item in "Toggle" -> "Paged Mode". If the item is toggled, after finishing loading the document, the document will be forced into paged mode. The print settings in `nsLayoutDebuggingTools::SetPagedMode()` are similar to `setupPrintMode()` in reftest-content.js. Remove the hack in nsDocumentViewer::InitInternal() because we don't want to set a new document when mIsPageMode = false. Differential Revision: https://phabricator.services.mozilla.com/D49993 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3f0609ea5d
Коммит
0023c0c92d
|
@ -875,12 +875,6 @@ nsresult nsDocumentViewer::InitInternal(
|
|||
nsIWidget* aParentWidget, nsISupports* aState, WindowGlobalChild* aActor,
|
||||
const nsIntRect& aBounds, bool aDoCreation, bool aNeedMakeCX /*= true*/,
|
||||
bool aForceSetNewDocument /* = true*/) {
|
||||
if (mIsPageMode) {
|
||||
// XXXbz should the InitInternal in SetPageModeForTesting just pass false
|
||||
// here itself?
|
||||
aForceSetNewDocument = false;
|
||||
}
|
||||
|
||||
// We don't want any scripts to run here. That can cause flushing,
|
||||
// which can cause reentry into initialization of this document viewer,
|
||||
// which would be disastrous.
|
||||
|
@ -4119,8 +4113,8 @@ NS_IMETHODIMP nsDocumentViewer::SetPageModeForTesting(
|
|||
nsresult rv = mPresContext->Init(mDeviceContext);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(
|
||||
InitInternal(mParentWidget, nullptr, nullptr, mBounds, true, false),
|
||||
NS_ENSURE_SUCCESS(InitInternal(mParentWidget, nullptr, nullptr, mBounds, true,
|
||||
false, false),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
Show();
|
||||
|
|
|
@ -29,6 +29,7 @@ interface nsILayoutDebuggingTools : nsISupports
|
|||
void setVisualDebugging(in boolean enabled);
|
||||
void setVisualEventDebugging(in boolean enabled);
|
||||
void setReflowCounts(in boolean enabled);
|
||||
void setPagedMode(in boolean enabled);
|
||||
|
||||
/* Run various tests. */
|
||||
void dumpWebShells();
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "nsIDocShell.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsIPrintSettingsService.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsAtom.h"
|
||||
|
@ -115,6 +117,38 @@ nsLayoutDebuggingTools::SetReflowCounts(bool aShow) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::SetPagedMode(bool aPagedMode) {
|
||||
nsCOMPtr<nsIPrintSettingsService> printSettingsService =
|
||||
do_GetService("@mozilla.org/gfx/printsettings-service;1");
|
||||
nsCOMPtr<nsIPrintSettings> printSettings;
|
||||
|
||||
printSettingsService->GetNewPrintSettings(getter_AddRefs(printSettings));
|
||||
|
||||
// The setup is the similar as setupPrintMode() in reftest-content.js except
|
||||
// we set the paper size by using US letter size 8.5 x 11 inches, so the page
|
||||
// area is larger and easier read when debugging real web pages.
|
||||
printSettings->SetPaperWidth(8.5);
|
||||
printSettings->SetPaperHeight(11);
|
||||
|
||||
nsIntMargin unwriteableMargin(0, 0, 0, 0);
|
||||
printSettings->SetUnwriteableMarginInTwips(unwriteableMargin);
|
||||
|
||||
printSettings->SetHeaderStrLeft(NS_LITERAL_STRING(""));
|
||||
printSettings->SetHeaderStrCenter(NS_LITERAL_STRING(""));
|
||||
printSettings->SetHeaderStrRight(NS_LITERAL_STRING(""));
|
||||
|
||||
printSettings->SetFooterStrLeft(NS_LITERAL_STRING(""));
|
||||
printSettings->SetFooterStrCenter(NS_LITERAL_STRING(""));
|
||||
printSettings->SetFooterStrRight(NS_LITERAL_STRING(""));
|
||||
|
||||
nsCOMPtr<nsIContentViewer> contentViewer(doc_viewer(mDocShell));
|
||||
contentViewer->SetPageModeForTesting(aPagedMode, printSettings);
|
||||
|
||||
ForceRefresh();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static void DumpAWebShell(nsIDocShellTreeItem* aShellItem, FILE* out,
|
||||
int32_t aIndent) {
|
||||
nsString name;
|
||||
|
|
|
@ -50,6 +50,7 @@ class Debugger {
|
|||
this._flags = new Map();
|
||||
this._visualDebugging = false;
|
||||
this._visualEventDebugging = false;
|
||||
this._pagedMode = false;
|
||||
this._attached = false;
|
||||
|
||||
for (let [name, pref] of Object.entries(FEATURES)) {
|
||||
|
@ -112,6 +113,20 @@ class Debugger {
|
|||
this._sendMessage("setVisualEventDebugging", v);
|
||||
}
|
||||
|
||||
get pagedMode() {
|
||||
return this._pagedMode;
|
||||
}
|
||||
|
||||
set pagedMode(v) {
|
||||
v = !!v;
|
||||
this._pagedMode = v;
|
||||
this.setPagedMode(this._pagedMode);
|
||||
}
|
||||
|
||||
setPagedMode(v) {
|
||||
this._sendMessage("setPagedMode", v);
|
||||
}
|
||||
|
||||
_sendMessage(name, arg) {
|
||||
gBrowser.messageManager.sendAsyncMessage("LayoutDebug:Call", { name, arg });
|
||||
}
|
||||
|
@ -201,6 +216,11 @@ nsLDBBrowserContentListener.prototype = {
|
|||
this.mStatusText.value = gURLBar.value + " loaded";
|
||||
this.mLoading = false;
|
||||
|
||||
if (gDebugger.pagedMode) {
|
||||
// Change to paged mode after the page is loaded.
|
||||
gDebugger.setPagedMode(true);
|
||||
}
|
||||
|
||||
if (gBrowser.currentURI.spec != "about:blank") {
|
||||
// We check for about:blank just to avoid one or two STATE_STOP
|
||||
// notifications that occur before the loadURI() call completes.
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
<menuitem type="checkbox" id="menu_crossingEventDumping" label="&ldb.crossingEventDumping.label;" accesskey="&ldb.crossingEventDumping.accesskey;" oncommand="toggle(this);" />
|
||||
<menuseparator />
|
||||
<menuitem type="checkbox" id="menu_reflowCounts" label="&ldb.reflowCounts.label;" accesskey="&ldb.reflowCounts.accesskey;" oncommand="toggle(this);" />
|
||||
<menuitem type="checkbox" id="menu_pagedMode" label="&ldb.pagedMode.label;" accesskey="&ldb.pagedMode.accesskey;" oncommand="toggle(this);" />
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&ldb.DumpMenu.label;"
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
<!ENTITY ldb.crossingEventDumping.accesskey "C">
|
||||
<!ENTITY ldb.reflowCounts.label "Reflow Counts">
|
||||
<!ENTITY ldb.reflowCounts.accesskey "R">
|
||||
<!ENTITY ldb.pagedMode.label "Paged Mode">
|
||||
<!ENTITY ldb.pagedMode.accesskey "G">
|
||||
|
||||
<!ENTITY ldb.DumpMenu.label "Dump">
|
||||
<!ENTITY ldb.DumpMenu.accesskey "D">
|
||||
|
|
Загрузка…
Ссылка в новой задаче