Bug 88845 - LocaleToScriptMappingDefault.cpp should also do what scriptCodeForFontSelection does in LocaleToScriptMappingICU.cpp
Summary: LocaleToScriptMappingDefault.cpp should also do what scriptCodeForFontSelecti...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Matt Falkenhagen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-12 01:12 PDT by Matt Falkenhagen
Modified: 2012-06-14 02:56 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.77 KB, patch)
2012-06-12 02:30 PDT, Matt Falkenhagen
no flags Details | Formatted Diff | Diff
Patch (5.36 KB, patch)
2012-06-13 18:32 PDT, Matt Falkenhagen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Falkenhagen 2012-06-12 01:12:59 PDT
LocaleToScriptMappingICU.cpp treats certain script codes as a single script for font selection purposes. For example "Hira", "Kana", "Jpan", and "Hrkt" are all treated as "Hrkt". This way we only have to set fonts for the "Hrkt" script in Settings, and have it be used for all of the Japanese scripts.

LocaleToScriptMappingDefault.cpp should do the same thing.
Comment 1 Matt Falkenhagen 2012-06-12 02:30:00 PDT
Created attachment 147042 [details]
Patch
Comment 2 Matt Falkenhagen 2012-06-12 02:31:33 PDT
Uploaded a patch.
Comment 3 Tony Chang 2012-06-12 11:11:39 PDT
Comment on attachment 147042 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=147042&action=review

Which ports use LocaleToScriptMappingICU and which use LocaleToScriptMappingDefault?

> Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp:49
> +    // Treat certain families of script codes as a single script for assigning a per-script font in Settings.
> +    static const UScriptCode japaneseScript = USCRIPT_KATAKANA_OR_HIRAGANA;
> +    static const UScriptCode koreanScript = USCRIPT_HANGUL;

Why do we use separate variables for these rather than just inlining USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_HANGUL?
Comment 4 Tony Chang 2012-06-12 11:17:30 PDT
It looks like Chromium uses Default.cpp.  Should it use ICU.cpp instead?
Comment 5 Matt Falkenhagen 2012-06-12 16:57:16 PDT
(In reply to comment #3)
> (From update of attachment 147042 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=147042&action=review
> 
> Which ports use LocaleToScriptMappingICU and which use LocaleToScriptMappingDefault?

Right now everyone uses Default. See <http://trac.webkit.org/changeset/110541>

> 
> > Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp:49
> > +    // Treat certain families of script codes as a single script for assigning a per-script font in Settings.
> > +    static const UScriptCode japaneseScript = USCRIPT_KATAKANA_OR_HIRAGANA;
> > +    static const UScriptCode koreanScript = USCRIPT_HANGUL;
> 
> Why do we use separate variables for these rather than just inlining USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_HANGUL?

It seemed to have better readability this way and I thought the compiler would inline it anyway. I can change to inlining them.
Comment 6 Tony Chang 2012-06-13 09:29:45 PDT
(In reply to comment #5)
> (In reply to comment #3)
> > (From update of attachment 147042 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=147042&action=review
> > 
> > Which ports use LocaleToScriptMappingICU and which use LocaleToScriptMappingDefault?
> 
> Right now everyone uses Default. See <http://trac.webkit.org/changeset/110541>

I see, so this would change font selection behavior for all ports. Is it possible to make a layout test demonstrating this change?  Is this more consistent with other browsers like Firefox, IE or Opera?

> > > Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp:49
> > > +    // Treat certain families of script codes as a single script for assigning a per-script font in Settings.
> > > +    static const UScriptCode japaneseScript = USCRIPT_KATAKANA_OR_HIRAGANA;
> > > +    static const UScriptCode koreanScript = USCRIPT_HANGUL;
> > 
> > Why do we use separate variables for these rather than just inlining USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_HANGUL?
> 
> It seemed to have better readability this way and I thought the compiler would inline it anyway. I can change to inlining them.

I think it would be more consistent if they were all USCRIPT_.
Comment 7 Tony Chang 2012-06-13 09:32:31 PDT
(In reply to comment #6)
> I see, so this would change font selection behavior for all ports. Is it possible to make a layout test demonstrating this change?  Is this more consistent with other browsers like Firefox, IE or Opera?

Oh, sorry, there is a test.  I'm still curious about the second question.  Also, are there sites currently using lang=ja-{Hira,Hrkt,Jpan,Kana}?
Comment 8 Matt Falkenhagen 2012-06-13 18:04:04 PDT
I'll make the change to use USCRIPT_.

(In reply to comment #7)
> (In reply to comment #6)
> > I see, so this would change font selection behavior for all ports. Is it possible to make a layout test demonstrating this change?  Is this more consistent with other browsers like Firefox, IE or Opera?

I think the other browsers don't really look at script and just use the language. I tested on Firefox, and it uses the font preference for Japanese to render all of "lang=ja-{Hira,Hrkt,Jpan,Kana}", as this patch would do.

> 
> Oh, sorry, there is a test.  I'm still curious about the second question.  Also, are there sites currently using lang=ja-{Hira,Hrkt,Jpan,Kana}?

It seems really rare, if it happens at all. I actually only noticed this because my demo to show per-script font settings uses the script directly to show how sample text looks under different per-script font settings.

I think no one would want different settings for Hira/Hrkt/Jpan/Kana though, so they should all be rendered with the same setting.
Comment 9 Matt Falkenhagen 2012-06-13 18:32:03 PDT
Created attachment 147460 [details]
Patch
Comment 10 Kent Tamura 2012-06-13 21:13:57 PDT
Comment on attachment 147460 [details]
Patch

Looks ok
Comment 11 Matt Falkenhagen 2012-06-13 21:21:01 PDT
Comment on attachment 147460 [details]
Patch

Thanks for the reviews.
Comment 12 WebKit Review Bot 2012-06-14 02:56:23 PDT
Comment on attachment 147460 [details]
Patch

Clearing flags on attachment: 147460

Committed r120303: <http://trac.webkit.org/changeset/120303>
Comment 13 WebKit Review Bot 2012-06-14 02:56:29 PDT
All reviewed patches have been landed.  Closing bug.