Closed Bug 445753 Opened 16 years ago Closed 16 years ago

"Rewrite" <nsSidebar.js> |function srGetStrBundle()|

Categories

(Core :: XUL, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla1.9.1b1

People

(Reporter: sgautherie, Assigned: sgautherie)

References

()

Details

Attachments

(2 files, 4 obsolete files)

This case can not be replaced by a |<stringbundle/>|,
nor even use </toolkit/obsolete/content/strres.js>;
but it can still be improved a little.

{{
/browser/components/sidebar/src/nsSidebar.js
/suite/common/sidebar/nsSidebar.js
}}
Attached patch (Av1-SM) <nsSidebar.js> (obsolete) — Splinter Review
Assignee: jag → sgautherie.bz
Status: NEW → ASSIGNED
Attachment #330034 - Flags: superreview?(jag)
Attachment #330034 - Flags: review?(jag)
Attached patch (Av1a-SM) <nsSidebar.js> (obsolete) — Splinter Review
Av1-SM still had an occurrence of the old global variable name.
Attachment #330034 - Attachment is obsolete: true
Attachment #330037 - Flags: superreview?(jag)
Attachment #330037 - Flags: review?(jag)
Attachment #330034 - Flags: superreview?(jag)
Attachment #330034 - Flags: review?(jag)
Attachment #330037 - Flags: superreview?(neil)
Attachment #330037 - Flags: superreview?(jag)
Attachment #330037 - Flags: review?(neil)
Attachment #330037 - Flags: review?(jag)
Comment on attachment 330037 [details] [diff] [review]
(Av1a-SM) <nsSidebar.js>

>+  const strBundle = gStrBundleService.createBundle(path);
var please.
Attachment #330037 - Flags: superreview?(neil)
Attachment #330037 - Flags: superreview+
Attachment #330037 - Flags: review?(neil)
Attachment #330037 - Flags: review+
Attached patch (Av1b-SM) <nsSidebar.js> (obsolete) — Splinter Review
Av1a-SM, with comment 3 suggestion(s).
Attachment #330037 - Attachment is obsolete: true
Flags: in-testsuite-
Keywords: checkin-needed
Whiteboard: [c-n: Av1b-SM // Leave opened]
Target Milestone: mozilla1.9.1a1 → mozilla1.9.1a2
Attached patch (Bv1-FF) <nsSidebar.js> (obsolete) — Splinter Review
Sync SM -> FF:
*Copy/Port patch Av1b-SM.
*"Rewrite" |nsSidebar.prototype.QueryInterface()|.
*Do the white-space cleanups.
Attachment #334908 - Flags: review?(gavin.sharp)
Comment on attachment 334908 [details] [diff] [review]
(Bv1-FF) <nsSidebar.js>

>diff --git a/browser/components/sidebar/src/nsSidebar.js b/browser/components/sidebar/src/nsSidebar.js

>+  var strBundle = gStrBundleService.createBundle(path);
>+  if (!strBundle)

createBundle will either return a bundle, or throw as far as I can tell, so this check is useless.
Attachment #334908 - Flags: review?(gavin.sharp) → review+
(In reply to comment #6)
> createBundle will either return a bundle, or throw as far as I can tell, so
> this check is useless.

Right:
createBundle() -> getStringBundle() -> |if (!bundle) return NS_ERROR_OUT_OF_MEMORY;|

Then, should I simply remove the test and let the exception spring, as it actually does,
or add another try+catch and return null here too, as it seems it was initially wanted ?
Currently, I seems odd to have the two behaviors in the same function :-<
Keywords: checkin-needed
OOM is exceptional, just let it throw in that case.
I would remove the other try/catch as well, that getService failing should also be pretty exceptional and it looks like no one null checks the return value of this function anyways.
(In reply to comment #8)
> OOM is exceptional, just let it throw in that case.

(In reply to comment #9)
> I would remove the other try/catch as well, that getService failing should also
> be pretty exceptional and it looks like no one null checks the return value of
> this function anyways.

Fully agreed :-)
Severity: trivial → minor
Summary: (minor) "Rewrite" <nsSidebar.js> |function srGetStrBundle()| → "Rewrite" <nsSidebar.js> |function srGetStrBundle()|
Whiteboard: [c-n: Av1b-SM // Leave opened]
Av1a-SM, with comment 9 suggestion(s).
Attachment #334904 - Attachment is obsolete: true
Attachment #334984 - Flags: superreview?(neil)
Attachment #334984 - Flags: review?(neil)
Bv1-FF, with comment 9 suggestion(s).
Attachment #334908 - Attachment is obsolete: true
Attachment #334988 - Flags: review?(gavin.sharp)
Comment on attachment 334984 [details] [diff] [review]
(Av2-SM) <nsSidebar.js>
[Checkin: Comment 18]

>Bug 445753 � "Rewrite" <nsSidebar.js> |function srGetStrBundle()|
Does TortoiseHg not handle Unicode correctly? ;-)
Attachment #334984 - Flags: superreview?(neil)
Attachment #334984 - Flags: superreview+
Attachment #334984 - Flags: review?(neil)
Attachment #334984 - Flags: review+
(In reply to comment #13)
> Does TortoiseHg not handle Unicode correctly? ;-)

Ah ! It must be caused by Windows (2000) Notepad, which I use to input the commit comment.
This character (in the patch file) is actually 0x96 (in Windows-1252).

I don't know why SeaMonkey tries to display it as UTF-8 :-/
It displays fine as ISO-8859-1...

Is this causing other issues ?
Keywords: checkin-needed
Whiteboard: [c-n: Av2-SM // Leave opened]
iirc hg is supposed to use UTF-8
Comment on attachment 334988 [details] [diff] [review]
(Bv2-FF) <nsSidebar.js>
[Checkin: Comment 20]

at this point it seems silly to have a helper at all, but... let's not get carried away.
Attachment #334988 - Flags: review?(gavin.sharp) → review+
Whiteboard: [c-n: Av2-SM // Leave opened] → [c-n: Av2-SM, Bv2-FF]
(In reply to comment #14)
> (In reply to comment #13)
> > Does TortoiseHg not handle Unicode correctly? ;-)
> 
> Ah ! It must be caused by Windows (2000) Notepad, which I use to input the
> commit comment.
> This character (in the patch file) is actually 0x96 (in Windows-1252).
> 
> I don't know why SeaMonkey tries to display it as UTF-8 :-/
> It displays fine as ISO-8859-1...
> 
> Is this causing other issues ?
> 

Windows-1252 0x96 corresponds IIUC to Unicode U+2013 i.e. &#8211;
in Latin1 (ISO-8859-1) 0x96 it is actually a control character, "START OF GUARDED AREA". On some systems (esp. some Windows systems) it will be displayed as if it were Windows-1252, on others you'll get the "unknown character" glyph.

Bugzilla pages are in UTF-8 nowadays; not sure about Mercurial but I'd bet on UTF-8 for anything recent which was originally developed on Unix.
Comment on attachment 334984 [details] [diff] [review]
(Av2-SM) <nsSidebar.js>
[Checkin: Comment 18]

Checked in, changeset 076411b96f5c
Attachment #334984 - Attachment description: (Av2-SM) <nsSidebar.js> → (Av2-SM) <nsSidebar.js> [Checkin: Comment 18]
Whiteboard: [c-n: Av2-SM, Bv2-FF] → [c-n: Bv2-FF]
+  if (!gStrBundleService)
+    gStrBundleService =
+      Components.classes["@mozilla.org/intl/stringbundle;1"]
+                .getService(Components.interfaces.nsIStringBundleService);
+
+  return gStrBundleService.createBundle(path);

Hmm. FYI. Firefox is moving towards using smart GETTERs instead.
Comment on attachment 334988 [details] [diff] [review]
(Bv2-FF) <nsSidebar.js>
[Checkin: Comment 20]

http://hg.mozilla.org/mozilla-central/rev/e3649faaaf18
Attachment #334988 - Attachment description: (Bv2-FF) <nsSidebar.js> → (Bv2-FF) <nsSidebar.js> [Checkin: Comment 19]
Attachment #334988 - Attachment description: (Bv2-FF) <nsSidebar.js> [Checkin: Comment 19] → (Bv2-FF) <nsSidebar.js> [Checkin: Comment 20]
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Flags: in-testsuite- → in-testsuite?
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: [c-n: Bv2-FF]
Target Milestone: mozilla1.9.1a2 → mozilla1.9.1b1
Blocks: 453980
(In reply to comment #16)
> at this point it seems silly to have a helper at all, but... let's not get
> carried away.

(In reply to comment #19)
> Hmm. FYI. Firefox is moving towards using smart GETTERs instead.

I filed bug 453980 as a followup.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: