Bug 1108616 - Part 3: Only do language-specific shaping when the language was explicitly tagged. r=jdaggett, a=lsblakk
authorJonathan Kew <jkew@mozilla.com>
Tue, 23 Dec 2014 12:50:10 +0000
changeset 234369 4444b0b3ce95730c53b251ddd9c949d43c8d0e1b
parent 234368 eb13a999ffeba4eba10e9f674abc32eed55f11ee
child 234370 8bdb452f0eceb12e90e3421374a078ca2539ba93
push id4282
push userryanvm@gmail.com
push dateFri, 26 Dec 2014 20:24:10 +0000
treeherdermozilla-beta@775454fb4f3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett, lsblakk
bugs1108616
milestone35.0
Bug 1108616 - Part 3: Only do language-specific shaping when the language was explicitly tagged. r=jdaggett, a=lsblakk
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxGraphiteShaper.cpp
gfx/thebes/gfxHarfBuzzShaper.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2849,17 +2849,18 @@ gfxFont::InitFakeSmallCapsRun(gfxContext
                 chAction = runAction;
             } else {
                 if (ch != ToUpperCase(ch) || SpecialUpper(ch)) {
                     // ch is lower case
                     chAction = (aSyntheticLower ? kUppercaseReduce : kNoChange);
                 } else if (ch != ToLowerCase(ch)) {
                     // ch is upper case
                     chAction = (aSyntheticUpper ? kUppercaseReduce : kNoChange);
-                    if (mStyle.language == nsGkAtoms::el) {
+                    if (mStyle.explicitLanguage &&
+                        mStyle.language == nsGkAtoms::el) {
                         // In Greek, check for characters that will be modified by
                         // the GreekUpperCase mapping - this catches accented
                         // capitals where the accent is to be removed (bug 307039).
                         // These are handled by using the full-size font with the
                         // uppercasing transform.
                         mozilla::GreekCasing::State state;
                         uint32_t ch2 = mozilla::GreekCasing::UpperCase(ch, state);
                         if (ch != ch2 && !aSyntheticUpper) {
@@ -2901,17 +2902,18 @@ gfxFont::InitFakeSmallCapsRun(gfxContext
                 nsAutoString convertedString;
                 nsAutoTArray<bool,50> charsToMergeArray;
                 nsAutoTArray<bool,50> deletedCharsArray;
 
                 bool mergeNeeded = nsCaseTransformTextRunFactory::
                     TransformString(origString,
                                     convertedString,
                                     true,
-                                    mStyle.language,
+                                    mStyle.explicitLanguage
+                                      ? mStyle.language : nullptr,
                                     charsToMergeArray,
                                     deletedCharsArray);
 
                 if (mergeNeeded) {
                     // This is the hard case: the transformation caused chars
                     // to be inserted or deleted, so we can't shape directly
                     // into the destination textrun but have to handle the
                     // mismatch of character positions.
--- a/gfx/thebes/gfxGraphiteShaper.cpp
+++ b/gfx/thebes/gfxGraphiteShaper.cpp
@@ -139,17 +139,17 @@ gfxGraphiteShaper::ShapeText(gfxContext 
     }
 
     gfxFontEntry *entry = mFont->GetFontEntry();
     uint32_t grLang = 0;
     if (style->languageOverride) {
         grLang = MakeGraphiteLangTag(style->languageOverride);
     } else if (entry->mLanguageOverride) {
         grLang = MakeGraphiteLangTag(entry->mLanguageOverride);
-    } else {
+    } else if (style->explicitLanguage) {
         nsAutoCString langString;
         style->language->ToUTF8String(langString);
         grLang = GetGraphiteTagForLang(langString);
     }
     gr_feature_val *grFeatures = gr_face_featureval_for_lang(mGrFace, grLang);
 
     // if style contains font-specific features
     nsDataHashtable<nsUint32HashKey,uint32_t> mergedFeatures;
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -1227,21 +1227,23 @@ gfxHarfBuzzShaper::ShapeText(gfxContext 
     }
     hb_buffer_set_script(buffer, scriptTag);
 
     hb_language_t language;
     if (style->languageOverride) {
         language = hb_ot_tag_to_language(style->languageOverride);
     } else if (entry->mLanguageOverride) {
         language = hb_ot_tag_to_language(entry->mLanguageOverride);
-    } else {
+    } else if (style->explicitLanguage) {
         nsCString langString;
         style->language->ToUTF8String(langString);
         language =
             hb_language_from_string(langString.get(), langString.Length());
+    } else {
+        language = hb_ot_tag_to_language(HB_OT_TAG_DEFAULT_LANGUAGE);
     }
     hb_buffer_set_language(buffer, language);
 
     uint32_t length = aLength;
     hb_buffer_add_utf16(buffer,
                         reinterpret_cast<const uint16_t*>(aText),
                         length, 0, length);