Bug 906521. Part 2: Change from using the 'glyphid' attribute to using id='glyphNNN'. r=jfkthame

--HG--
extra : rebase_source : 5ce6484e72faacf6412987b27ca8179d495e0067
This commit is contained in:
Robert O'Callahan 2013-08-20 01:08:43 +12:00
parent 4c69c3cd1c
commit 1e89525430

View File

@ -357,18 +357,28 @@ 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