Bug 906521. Part 2: Change from using the 'glyphid' attribute to using id='glyphNNN'. r=jfkthame
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 20 Aug 2013 01:08:43 +1200
changeset 144295 7cad8a76e9712232483dce9227ad4f9534fce385
parent 144294 9766dc682c067c754a432346aebbb1e9994ab9ee
child 144296 cff6ff652c4c2fb949a47d580440084726824564
push id25157
push userryanvm@gmail.com
push dateMon, 26 Aug 2013 13:17:12 +0000
treeherdermozilla-central@14b1e8c2957e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs906521
milestone26.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 906521. Part 2: Change from using the 'glyphid' attribute to using id='glyphNNN'. r=jfkthame
gfx/thebes/gfxSVGGlyphs.cpp
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -352,28 +352,38 @@ gfxSVGGlyphsDocument::ParseDocument(cons
 
     return NS_OK;
 }
 
 void
 gfxSVGGlyphsDocument::InsertGlyphId(Element *aGlyphElement)
 {
     nsAutoString glyphIdStr;
-    if (!aGlyphElement->GetAttr(kNameSpaceID_None, nsGkAtoms::glyphid, glyphIdStr)) {
+    static const uint32_t glyphPrefixLength = 5;
+    // The maximum glyph ID is 65535 so the maximum length of the numeric part
+    // is 5.
+    if (!aGlyphElement->GetAttr(kNameSpaceID_None, nsGkAtoms::id, glyphIdStr) ||
+        !StringBeginsWith(glyphIdStr, NS_LITERAL_STRING("glyph")) ||
+        glyphIdStr.Length() > glyphPrefixLength + 5) {
         return;
     }
 
-    nsresult rv;
-    uint32_t glyphId = glyphIdStr.ToInteger(&rv);
-
-    if (NS_FAILED(rv)) {
+    uint32_t id = 0;
+    for (uint32_t i = glyphPrefixLength; i < glyphIdStr.Length(); ++i) {
+      PRUnichar ch = glyphIdStr.CharAt(i);
+      if (ch < '0' || ch > '9') {
         return;
+      }
+      if (ch == '0' && i == glyphPrefixLength) {
+        return;
+      }
+      id = id * 10 + (ch - '0');
     }
 
-    mGlyphIdMap.Put(glyphId, aGlyphElement);
+    mGlyphIdMap.Put(id, aGlyphElement);
 }
 
 void
 gfxTextObjectPaint::InitStrokeGeometry(gfxContext *aContext,
                                        float devUnitsPerSVGUnit)
 {
     mStrokeWidth = aContext->CurrentLineWidth() / devUnitsPerSVGUnit;
     aContext->CurrentDash(mDashes, &mDashOffset);