зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1365601 Part 2: Disable parts of the Print Preview toolbar until update has finished. r=mconley
This commit is contained in:
Родитель
e7a3237ac5
Коммит
d10183d0a6
|
@ -25,7 +25,7 @@
|
|||
<xul:button label="&print.label;" accesskey="&print.accesskey;"
|
||||
oncommand="this.parentNode.print();" icon="print"/>
|
||||
|
||||
<xul:button label="&pageSetup.label;" accesskey="&pageSetup.accesskey;"
|
||||
<xul:button anonid="pageSetup" label="&pageSetup.label;" accesskey="&pageSetup.accesskey;"
|
||||
oncommand="this.parentNode.doPageSetup();"/>
|
||||
|
||||
<xul:vbox align="center" pack="center">
|
||||
|
@ -104,9 +104,24 @@
|
|||
<field name="mPrintButton">
|
||||
document.getAnonymousNodes(this)[0]
|
||||
</field>
|
||||
<field name="mPageSetupButton">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "pageSetup");
|
||||
</field>
|
||||
<field name="mNavigateHomeButton">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "navigateHome");
|
||||
</field>
|
||||
<field name="mNavigatePreviousButton">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "navigatePrevious");
|
||||
</field>
|
||||
<field name="mPageTextBox">
|
||||
document.getAnonymousNodes(this)[5].childNodes[0]
|
||||
</field>
|
||||
<field name="mNavigateNextButton">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "navigateNext");
|
||||
</field>
|
||||
<field name="mNavigateEndButton">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "navigateEnd");
|
||||
</field>
|
||||
<field name="mTotalPages">
|
||||
document.getAnonymousNodes(this)[5].childNodes[2]
|
||||
</field>
|
||||
|
@ -128,6 +143,9 @@
|
|||
<field name="mSimplifyPageCheckbox">
|
||||
document.getAnonymousNodes(this)[14]
|
||||
</field>
|
||||
<field name="mSimplifyPageNotAllowed">
|
||||
this.mSimplifyPageCheckbox.disabled
|
||||
</field>
|
||||
<field name="mSimplifyPageToolbarSeparator">
|
||||
document.getAnonymousNodes(this)[15]
|
||||
</field>
|
||||
|
@ -185,6 +203,25 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<method name="disableUpdateTriggers">
|
||||
<parameter name="aDisabled"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.mPrintButton.disabled = aDisabled;
|
||||
this.mPageSetupButton.disabled = aDisabled;
|
||||
this.mNavigateHomeButton.disabled = aDisabled;
|
||||
this.mNavigatePreviousButton.disabled = aDisabled;
|
||||
this.mPageTextBox.disabled = aDisabled;
|
||||
this.mNavigateNextButton.disabled = aDisabled;
|
||||
this.mNavigateEndButton.disabled = aDisabled;
|
||||
this.mScaleCombobox.disabled = aDisabled;
|
||||
this.mPortaitButton.disabled = aDisabled;
|
||||
this.mLandscapeButton.disabled = aDisabled;
|
||||
this.mSimplifyPageCheckbox.disabled = this.mSimplifyPageNotAllowed || aDisabled;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="doPageSetup">
|
||||
<body>
|
||||
<![CDATA[
|
||||
|
@ -355,6 +392,7 @@
|
|||
<method name="enableSimplifyPage">
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.mSimplifyPageNotAllowed = false;
|
||||
this.mSimplifyPageCheckbox.disabled = false;
|
||||
this.mSimplifyPageCheckbox.setAttribute("tooltiptext",
|
||||
this.mSimplifyPageCheckbox.getAttribute("tooltiptext-enabled"));
|
||||
|
@ -365,6 +403,7 @@
|
|||
<method name="disableSimplifyPage">
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.mSimplifyPageNotAllowed = true;
|
||||
this.mSimplifyPageCheckbox.disabled = true;
|
||||
this.mSimplifyPageCheckbox.setAttribute("tooltiptext",
|
||||
this.mSimplifyPageCheckbox.getAttribute("tooltiptext-disabled"));
|
||||
|
|
|
@ -213,10 +213,10 @@ var PrintUtils = {
|
|||
* to it will be used).
|
||||
*/
|
||||
printPreview(aListenerObj) {
|
||||
// if we're already in PP mode, don't set the listener; chances
|
||||
// are it is null because someone is calling printPreview() to
|
||||
// get us to refresh the display.
|
||||
if (!this.inPrintPreview) {
|
||||
// If we already have a toolbar someone is calling printPreview() to get us
|
||||
// to refresh the display and aListenerObj won't be passed.
|
||||
let printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||
if (!printPreviewTB) {
|
||||
this._listener = aListenerObj;
|
||||
this._sourceBrowser = aListenerObj.getSourceBrowser();
|
||||
this._originalTitle = this._sourceBrowser.contentTitle;
|
||||
|
@ -225,6 +225,10 @@ var PrintUtils = {
|
|||
// Here we log telemetry data for when the user enters print preview.
|
||||
this.logTelemetry("PRINT_PREVIEW_OPENED_COUNT");
|
||||
} else {
|
||||
// Disable toolbar elements that can cause another update to be triggered
|
||||
// during this update.
|
||||
printPreviewTB.disableUpdateTriggers(true);
|
||||
|
||||
// collapse the browser here -- it will be shown in
|
||||
// enterPrintPreview; this forces a reflow which fixes display
|
||||
// issues in bug 267422.
|
||||
|
@ -319,10 +323,6 @@ var PrintUtils = {
|
|||
return this._currentPPBrowser.docShell.printPreview;
|
||||
},
|
||||
|
||||
get inPrintPreview() {
|
||||
return document.getElementById("print-preview-toolbar") != null;
|
||||
},
|
||||
|
||||
// "private" methods and members. Don't use them.
|
||||
|
||||
_listener: null,
|
||||
|
@ -445,6 +445,10 @@ var PrintUtils = {
|
|||
// thrown. This should all get torn out once bug 1088061 is fixed.
|
||||
mm.removeMessageListener("Printing:Preview:StateChange", this);
|
||||
mm.removeMessageListener("Printing:Preview:ProgressChange", this);
|
||||
|
||||
// Enable toobar elements that we disabled during update.
|
||||
let printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||
printPreviewTB.disableUpdateTriggers(false);
|
||||
}
|
||||
|
||||
return listener.onStateChange(null, null,
|
||||
|
@ -593,9 +597,11 @@ var PrintUtils = {
|
|||
sendEnterPreviewMessage(this._sourceBrowser, false);
|
||||
}
|
||||
|
||||
let waitForPrintProgressToEnableToolbar = false;
|
||||
if (this._webProgressPP.value) {
|
||||
mm.addMessageListener("Printing:Preview:StateChange", this);
|
||||
mm.addMessageListener("Printing:Preview:ProgressChange", this);
|
||||
waitForPrintProgressToEnableToolbar = true;
|
||||
}
|
||||
|
||||
let onEntered = (message) => {
|
||||
|
@ -622,6 +628,12 @@ var PrintUtils = {
|
|||
// printPreviewTB.initialize above already calls updateToolbar.
|
||||
printPreviewTB.updateToolbar();
|
||||
}
|
||||
|
||||
// If we don't have a progress listener to enable the toolbar do it now.
|
||||
if (!waitForPrintProgressToEnableToolbar) {
|
||||
printPreviewTB.disableUpdateTriggers(false);
|
||||
}
|
||||
|
||||
ppBrowser.collapsed = false;
|
||||
ppBrowser.focus();
|
||||
return;
|
||||
|
@ -648,6 +660,13 @@ var PrintUtils = {
|
|||
navToolbox.parentNode.insertBefore(printPreviewTB, navToolbox);
|
||||
printPreviewTB.initialize(ppBrowser);
|
||||
|
||||
// The print preview processing may not have fully completed, so if we
|
||||
// have a progress listener, disable the toolbar elements that can trigger
|
||||
// updates and it will enable them when completed.
|
||||
if (waitForPrintProgressToEnableToolbar) {
|
||||
printPreviewTB.disableUpdateTriggers(true);
|
||||
}
|
||||
|
||||
// Enable simplify page checkbox when the page is an article
|
||||
if (this._sourceBrowser.isArticle) {
|
||||
printPreviewTB.enableSimplifyPage();
|
||||
|
|
Загрузка…
Ссылка в новой задаче