Closed
Bug 228529
Opened 21 years ago
Closed 21 years ago
JS Warnings in printing/print preview
Categories
(Core :: Printing: Output, defect)
Core
Printing: Output
Tracking
()
RESOLVED
FIXED
People
(Reporter: timeless, Assigned: timeless)
References
Details
Attachments
(8 obsolete files)
Warning ``assignment to undeclared variable gPrintSettingsAreGlobal'' [xs] in
file ``chrome://communicator/content/printing.js'', line 65, character 0.
Stopped for error handler.
#0: function GetPrintSettings() in <chrome://communicator/content/printing.js>
line 65
063: .getService(Components.interfaces.nsIPrefBranch);
064: if (pref) {
065: gPrintSettingsAreGlobal =
pref.getBoolPref("print.use_global_printsettings", false);
066: gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false);
067: }
Continuing from error handler.
Warning ``assignment to undeclared variable gSavePrintSettings'' [xs] in file
``chrome://communicator/content/printing.js'', line 66, character 0.
Stopped for error handler.
#0: function GetPrintSettings() in <chrome://communicator/content/printing.js>
line 66
064: if (pref) {
065: gPrintSettingsAreGlobal =
pref.getBoolPref("print.use_global_printsettings", false);
066: gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false);
067: }
068:
Warning ``redeclaration of var str'' [xs] in file
``chrome://global/content/printPreviewProgress.js'', line 52, character 10.
Warning ``assignment to undeclared variable gWebProgress'' [xs] in file
``chrome://messenger/content/msgPrintEngine.js'', line 149, character 0.
Stopped for error handler.
#0: function PrintPreview() in <chrome://messenger/content/msgPrintEngine.js>
line 149
147: //
148: // Doing it all from script, means it lays out before hand and we can let
printing do it's own thing
149: gWebProgress = new Object();
150:
151: var printPreviewParams = new Object();
Warning ``redeclaration of var total'' [xs] in file
``chrome://communicator/content/printPreviewBindings.xml'', line 293, character 16.
Warning ``redeclaration of var ifreq'' [xs] in file
``chrome://communicator/content/printPreviewBindings.xml'', line 402, character 16.
Attachment #137446 -
Flags: superreview?(bz-vacation)
Attachment #137446 -
Flags: review?(neil.parkwaycc.co.uk)
Attachment #137446 -
Flags: superreview?(bz-vacation)
Attachment #137446 -
Flags: review?(neil.parkwaycc.co.uk)
Attachment #137446 -
Attachment is obsolete: true
Attachment #137447 -
Flags: superreview?(bz-vacation)
Attachment #137447 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 3•21 years ago
|
||
*** Bug 160939 has been marked as a duplicate of this bug. ***
![]() |
||
Comment 4•21 years ago
|
||
Comment on attachment 137447 [details] [diff] [review]
(Av1b) declare globals, remove duplicate decls, ...
[Checked in: Comment 6]
sr=bzbarsky
Attachment #137447 -
Flags: superreview?(bz-vacation) → superreview+
Comment 5•21 years ago
|
||
Comment on attachment 137447 [details] [diff] [review]
(Av1b) declare globals, remove duplicate decls, ...
[Checked in: Comment 6]
> var total = print.printPreviewNumPages;
>
> // bounds check potentially user-entered number
> if (newPageNum > 0 && newPageNum <= total)
> {
> this.mPageTextBox.value = newPageNum;
> print.printPreviewNavigate(
> print.PRINTPREVIEW_GOTO_PAGENUM, newPageNum);
> validInput = true;
> }
> }
> else
> {
>- var total = print.printPreviewNumPages;
>+ total = print.printPreviewNumPages;
I see you didn't bother to lexically scope this one :-P
>+var gPrintSettingsAreGlobal;
>+var gSavePrintSettings;
Explicit initialization to false would be nice.
>Index: xpfe/global/resources/content/printPreviewProgress.js
You don't need this now :-)
Attachment #137447 -
Flags: review?(neil.parkwaycc.co.uk) → review+
Updated•21 years ago
|
Attachment #137446 -
Attachment description: declare global, remove duplicate decls, ... → (Av1) declare global, remove duplicate decls, ...
Comment 6•21 years ago
|
||
Comment on attachment 137447 [details] [diff] [review]
(Av1b) declare globals, remove duplicate decls, ...
[Checked in: Comment 6]
Check in: { 12/20/2003 20:04 timeless%mozdev.org }
Attachment #137447 -
Attachment description: declare globals, remove duplicate decls, ... → (Av1b) declare globals, remove duplicate decls, ...
[Checked in: Comment 6]
Attachment #137447 -
Attachment is obsolete: true
Comment 7•21 years ago
|
||
Comment 8•21 years ago
|
||
Comment on attachment 137792 [details] [diff] [review]
(Bv1) additional |var ...| cleanup
'r=?': (see comment 7)
Attachment #137792 -
Flags: review?(neil.parkwaycc.co.uk)
Updated•21 years ago
|
OS: Windows XP → All
Hardware: PC → All
Comment on attachment 137792 [details] [diff] [review]
(Bv1) additional |var ...| cleanup
Since ifreq isn't used beyond the next line, skip the variable and just do
.QueryInterface(IFR).QueryInterface(IDOMWindow)
Updated•21 years ago
|
Attachment #137792 -
Attachment description: (Bv1) |webBrowserPrint| removal, and more → (Bv1) additional |var ...| cleanup
Attachment #137792 -
Attachment is obsolete: true
Attachment #137792 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 10•21 years ago
|
||
Bv1, plus comment 9 suggestion.
Updated•21 years ago
|
Attachment #137800 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 11•21 years ago
|
||
Comment on attachment 137800 [details] [diff] [review]
(Bv1b) additional |var ...| cleanup
As "total" is only used at most once you could replace each reference with
print.printPreviewNumPages instead.
>- var ifreq;
>- var webBrowserPrint;
> var domWin;
> try {
>- ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
>- domWin = ifreq.QueryInterface(Components.interfaces.nsIDOMWindow);
>+ domWin = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
>+ .QueryInterface(Components.interfaces.nsIDOMWindow);
> } catch (e) {
Bah, how did I not spot this before... these QueryInterface calls have no
useful effect, the entire code sequence is for all print preview purposes
equivalent to var domWin = content; i.e you can remove this code and replace
the two uses of domWin with content.
Oh, and I'm not too happy with your use of const, at least not for user input
variables; the one I'm vaguely OK with is the print preview settings one but
only because no matter how many times you call that method you'll probably get
a similar object reference.
Comment 12•21 years ago
|
||
Bv1b, with comment 11 suggestions.
Updated•21 years ago
|
Attachment #137863 -
Flags: review?(neil.parkwaycc.co.uk)
Updated•21 years ago
|
Attachment #137800 -
Attachment is obsolete: true
Attachment #137800 -
Flags: review?(neil.parkwaycc.co.uk)
Updated•21 years ago
|
Attachment #137863 -
Flags: review?(neil.parkwaycc.co.uk) → review+
Updated•21 years ago
|
Attachment #137863 -
Flags: superreview?(bz-vacation)
![]() |
||
Comment 13•21 years ago
|
||
I may not get to this any time soon.
Updated•21 years ago
|
Attachment #137863 -
Flags: superreview?(bz-vacation) → superreview?(alecf)
Comment 14•21 years ago
|
||
has this code been compiled and tested? Please don't waste reviewers time with
untested patches.
Updated•21 years ago
|
Attachment #137863 -
Attachment is obsolete: true
Attachment #137863 -
Flags: superreview?(alecf)
Comment 15•21 years ago
|
||
Bv1c, with more cleanup.
Comment 16•21 years ago
|
||
Comment on attachment 138033 [details] [diff] [review]
(Bv2) additional |var ...| cleanup
(alec)
Re comment 14:
Compile: JavaScript only, no compilation !?
Test: I successfully did some simple tests on the modified parts. (and I had
'neil: r+')
Please, explain me what I can do better. Thanks.
(neil)
'r=?': (see comment 15)
This is the "full" job, after your previous r+, as I had a closer look at it...
Attachment #138033 -
Flags: superreview?(alecf)
Attachment #138033 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 17•21 years ago
|
||
Comment on attachment 138033 [details] [diff] [review]
(Bv2) additional |var ...| cleanup
>+ var confirmed = Components
>+ .classes["@mozilla.org/embedcomp/prompt-service;1"]
>+ .getService(Components.interfaces.nsIPromptService)
>+ .prompt(window,
>+ this.mCustomTitle,
>+ this.mScaleLabel.value,
>+ result,
>+ null,
>+ {value:aValue});
This is just getting silly.
> if (!settings.shrinkToFit) {
> settings.shrinkToFit = true;
> this.doPrintPreview(print, settings, this.mTotalPages, this.mScaleCombobox);
>- return;
>- } else {
>- return;
> }
>+ return;
This was the only useful change from the last patch.
Attachment #138033 -
Flags: review?(neil.parkwaycc.co.uk) → review-
Updated•21 years ago
|
Attachment #138033 -
Attachment is obsolete: true
Attachment #138033 -
Flags: superreview?(alecf)
Comment 18•21 years ago
|
||
Bv2, revised a little.
Comment 19•21 years ago
|
||
Comment on attachment 138041 [details] [diff] [review]
(Bv3) additional |var ...| cleanup
Re comment 17:
I compacted the |.prompt()| line(s) of |confirmed|,
and (un)did 4 other minor changes.
For the record, there are 2 other actual code fixes included in Bv2 (and Bv3):
- var prevPS = gPrintSettings;
- return true;
} catch(e) {
return false;
}
return true;
Besides these, the idea was/is to remove as many "used once" |var| as possible,
based on what you wrote about |total| in comment 11...
Attachment #138041 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 20•21 years ago
|
||
Comment on attachment 138041 [details] [diff] [review]
(Bv3) additional |var ...| cleanup
That unused variable and the other fix are fine, thanks for pointing that out.
However, you should not try to do too much in one statement. Ideally statements
should fit on one line, except calls to methods with a large number of
arguments, which should be in their own statement, or well-known patterns such
as creating a component or getting a service.
Attachment #138041 -
Flags: review?(neil.parkwaycc.co.uk) → review-
Updated•21 years ago
|
Attachment #138041 -
Attachment is obsolete: true
Comment 21•21 years ago
|
||
Bv3, with 3 '*Service' |var| restored.
Updated•21 years ago
|
Attachment #138059 -
Flags: review?(neil.parkwaycc.co.uk)
Updated•21 years ago
|
Attachment #138059 -
Flags: review?(neil.parkwaycc.co.uk) → review+
Updated•21 years ago
|
Attachment #138059 -
Flags: superreview?(alecf)
Comment 22•21 years ago
|
||
Comment on attachment 138059 [details] [diff] [review]
(Bv4) additional |var ...| cleanup
[Checked in: Comment 23]
sr=alecf
Attachment #138059 -
Flags: superreview?(alecf) → superreview+
Comment 23•21 years ago
|
||
Comment on attachment 138059 [details] [diff] [review]
(Bv4) additional |var ...| cleanup
[Checked in: Comment 23]
Check in: { 01/18/2004 14:50 neil%parkwaycc.co.uk }
Attachment #138059 -
Attachment description: (Bv4) additional |var ...| cleanup → (Bv4) additional |var ...| cleanup
[Checked in: Comment 23]
Attachment #138059 -
Attachment is obsolete: true
Updated•21 years ago
|
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•