Closed Bug 943270 Opened 11 years ago Closed 11 years ago

gfxFontUtils should use EncodingUtils::DecoderForEncoding instead of nsICharsetConverterManager::GetUnicodeDecoderRaw

Categories

(Core :: Graphics: Text, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla28

People

(Reporter: hsivonen, Assigned: jfkthame)

References

Details

(Whiteboard: [qa-])

Attachments

(1 file)

EncodingUtils::DecoderForEncoding is a deCOMtaminated replacement for nsICharsetConverterManager::GetUnicodeDecoderRaw.

https://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxFontUtils.cpp#1306 should use the new method. However, it's not quite a drop-in replacement, because gfxFontUtils sometimes passes in an empty string, but EncodingUtils::DecoderForEncoding only accepts real Gecko-canonical labels. Hence, gfxFontUtils would need to deal with failure to find a Gecko-canonical label on its own first.
For clarity, the new method is from bug 919935 and is on inbound at the moment.
AFAICS, gfxFontUtils::DecodeFontName() *won't* ever pass an empty string to this method. It gets the encoding label from GetCharsetForFontName(), which may indeed return either nullptr or "" in addition to valid labels, but these two "special" values are handled separately without trying to get an actual decoder.
Assignee: nobody → jfkthame
Comment on attachment 8338432 [details] [diff] [review]
use EncodingUtils::DecoderForEncoding instead of nsICharsetConverterManager::GetUnicodeDecoderRaw when decoding font names

>+    nsCOMPtr<nsIUnicodeDecoder> decoder =
>+        mozilla::dom::EncodingUtils::DecoderForEncoding(csName);
>+    if (!decoder) {
>         NS_WARNING("failed to get the decoder for a font name string");
>         return false;

This should never happen if csName is indeed a Gecko-canonical label, since we have infallible malloc. (DecoderForEncoding MOZ_ASSERTs this.)
I believe the intention is that GetCharsetForFontName() should always return a Gecko-canonical name (or empty/null).

Still, I'd be inclined to leave the extra null check here, as a safeguard against possible future changes (e.g. if we switch Gecko to using some other (more standard) naming system, or remove support for certain encodings, etc., and fail to update everything correctly). Some of the possible results from GetCharsetForFontName() are probably very rare, only occurring if a user happens to have an unusual font installed that has specific localized names, so I'm not confident we have unit test coverage that would immediately detect future breakage.
OK.
Attachment #8338432 - Flags: review?(jdaggett) → review+
Thank you.
https://hg.mozilla.org/mozilla-central/rev/068411d02b1b
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [qa-]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: