Bug 1108616 - part 3 - Only do language-specific shaping when the language was explicitly tagged. r=jdaggett a=sledru
authorJonathan Kew <jkew@mozilla.com>
Tue, 23 Dec 2014 12:50:10 +0000
changeset 242603 84a11039a407eda808f9954b921be332fa8930ab
parent 242602 311e27cefcebf67a19b8342a3df9d3a4b736ac13
child 242604 901b7325b2c860c9bf0dc23c446ee36a46ee661b
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett, sledru
bugs1108616
milestone36.0a2
Bug 1108616 - part 3 - Only do language-specific shaping when the language was explicitly tagged. r=jdaggett a=sledru
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxGraphiteShaper.cpp
gfx/thebes/gfxHarfBuzzShaper.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2891,17 +2891,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) {
@@ -2943,17 +2944,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
@@ -140,17 +140,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
@@ -1223,21 +1223,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);