Bug 1460858 - Fix serialization/deserialization of SlantStyle for the Android startupCache, to ensure proper styled face selection. r=jwatt, a=RyanVM
authorJonathan Kew <jkew@mozilla.com>
Thu, 17 May 2018 14:44:37 +0100
changeset 470840 357d9f00469d
parent 470839 b6653a9f24fc
child 470841 617990cee57d
push id9239
push userryanvm@gmail.com
push date2018-05-18 15:23 +0000
treeherdermozilla-beta@617990cee57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt, RyanVM
bugs1460858
milestone61.0
Bug 1460858 - Fix serialization/deserialization of SlantStyle for the Android startupCache, to ensure proper styled face selection. r=jwatt, a=RyanVM
gfx/src/FontPropertyTypes.h
gfx/thebes/gfxFT2FontList.cpp
--- a/gfx/src/FontPropertyTypes.h
+++ b/gfx/src/FontPropertyTypes.h
@@ -342,18 +342,19 @@ public:
     } else if (strcmp(aString, "italic") == 0) {
       return Italic();
     } else {
       if (isdigit(aString[0]) && strstr(aString, "deg")) {
         float angle = strtof(aString, nullptr);
         return Oblique(angle);
       }
       // Not recognized as an oblique angle; maybe it's from a startup-cache
-      // created by an older version. Just treat it as 'normal'.      
-      return Normal();
+      // created by an older version. The style field there used a simple 0/1
+      // for normal/italic respectively.
+      return aString[0] == '0' ? Normal() : Italic();
     }
   }
 
   bool IsNormal() const { return mValue == kNormal; }
   bool IsItalic() const { return mValue == kItalic; }
   bool IsOblique() const { return mValue != kItalic && mValue != kNormal; }
 
   float ObliqueAngle() const
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -1001,17 +1001,17 @@ gfxFT2FontList::AppendFacesFromCachedFac
         if (!(end = strchr(beginning, ','))) {
             break;
         }
         nsAutoCString minStyle(beginning, end - beginning);
         nsAutoCString maxStyle(minStyle);
         int32_t colon = minStyle.FindChar(':');
         if (colon > 0) {
             maxStyle.Assign(minStyle.BeginReading() + colon + 1);
-            minStyle.Truncate(colon - 1);
+            minStyle.Truncate(colon);
         }
 
         beginning = end + 1;
         if (!(end = strchr(beginning, ','))) {
             break;
         }
         char* limit;
         float minWeight = strtof(beginning, &limit);
@@ -1055,17 +1055,21 @@ AppendToFaceList(nsCString& aFaceList,
                  nsAString& aFamilyName, FT2FontEntry* aFontEntry)
 {
     aFaceList.Append(NS_ConvertUTF16toUTF8(aFamilyName));
     aFaceList.Append(',');
     aFaceList.Append(NS_ConvertUTF16toUTF8(aFontEntry->Name()));
     aFaceList.Append(',');
     aFaceList.AppendInt(aFontEntry->mFTFontIndex);
     aFaceList.Append(',');
-    aFaceList.Append(aFontEntry->IsItalic() ? '1' : '0');
+    // Note that ToString() appends to the destination string without
+    // replacing existing contents (see FontPropertyTypes.h)
+    aFontEntry->SlantStyle().Min().ToString(aFaceList);
+    aFaceList.Append(':');
+    aFontEntry->SlantStyle().Max().ToString(aFaceList);
     aFaceList.Append(',');
     aFaceList.AppendFloat(aFontEntry->Weight().Min().ToFloat());
     aFaceList.Append(':');
     aFaceList.AppendFloat(aFontEntry->Weight().Max().ToFloat());
     aFaceList.Append(',');
     aFaceList.AppendFloat(aFontEntry->Stretch().Min().Percentage());
     aFaceList.Append(':');
     aFaceList.AppendFloat(aFontEntry->Stretch().Max().Percentage());