Bug 1291016 - Track source-string position of possible prefix. r=heycam
authorJonathan Kew <jkew@mozilla.com>
Thu, 11 Aug 2016 09:08:22 +0100
changeset 309012 32695cf856683158ecd0f70081837c3a789305c9
parent 309011 422dd7521fa3e2d1712b5b011fc978e7d9e3cddd
child 309013 83860b1448ec931ac09889aa90ed9d388d050b67
push id80486
push userjkew@mozilla.com
push dateThu, 11 Aug 2016 08:08:47 +0000
treeherdermozilla-inbound@32695cf85668 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1291016
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1291016 - Track source-string position of possible prefix. r=heycam
layout/generic/nsTextRunTransformations.cpp
--- a/layout/generic/nsTextRunTransformations.cpp
+++ b/layout/generic/nsTextRunTransformations.cpp
@@ -301,16 +301,19 @@ nsCaseTransformTextRunFactory::Transform
   uint8_t style = aAllUppercase ? NS_STYLE_TEXT_TRANSFORM_UPPERCASE : 0;
   bool forceNonFullWidth = false;
   const nsIAtom* lang = aLanguage;
 
   LanguageSpecificCasingBehavior languageSpecificCasing = GetCasingFor(lang);
   mozilla::GreekCasing::State greekState;
   mozilla::IrishCasing::State irishState;
   uint32_t irishMark = uint32_t(-1); // location of possible prefix letter(s)
+                                     // in the output string
+  uint32_t irishMarkSrc; // corresponding location in source string (may differ
+                         // from output due to expansions like eszet -> 'SS')
 
   for (uint32_t i = 0; i < length; ++i) {
     uint32_t ch = str[i];
 
     RefPtr<nsTransformedCharStyle> charStyle;
     if (aTextRun) {
       charStyle = aTextRun->mStyles[i];
       style = aAllUppercase ? NS_STYLE_TEXT_TRANSFORM_UPPERCASE :
@@ -451,16 +454,17 @@ nsCaseTransformTextRunFactory::Transform
       }
 
       if (languageSpecificCasing == eLSCB_Irish) {
         bool mark;
         uint8_t action;
         ch = mozilla::IrishCasing::UpperCase(ch, irishState, mark, action);
         if (mark) {
           irishMark = aConvertedString.Length();
+          irishMarkSrc = i;
           break;
         } else if (action) {
           nsString& str = aConvertedString; // shorthand
           switch (action) {
           case 1:
             // lowercase a single prefix letter
             NS_ASSERTION(str.Length() > 0 && irishMark < str.Length(),
                          "bad irishMark!");
@@ -476,17 +480,17 @@ nsCaseTransformTextRunFactory::Transform
             irishMark = uint32_t(-1);
             break;
           case 3:
             // lowercase one prefix letter, and delete following hyphen
             // (which must be the immediately-preceding char)
             NS_ASSERTION(str.Length() >= 2 && irishMark == str.Length() - 2,
                          "bad irishMark!");
             str.Replace(irishMark, 2, ToLowerCase(str[irishMark]));
-            aDeletedCharsArray[irishMark + 1] = true;
+            aDeletedCharsArray[irishMarkSrc + 1] = true;
             // Remove the trailing entries (corresponding to the deleted hyphen)
             // from the auxiliary arrays.
             aCharsToMergeArray.SetLength(aCharsToMergeArray.Length() - 1);
             if (aTextRun) {
               aStyleArray->SetLength(aStyleArray->Length() - 1);
               aCanBreakBeforeArray->SetLength(aCanBreakBeforeArray->Length() - 1);
               inhibitBreakBefore = true;
             }