Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(869)

Unified Diff: src/ports/SkFontConfigParser_android.cpp

Issue 880783003: Do not add indirection to XML_Parser. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Build locally after rebasing all the changes. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigParser_android.cpp
diff --git a/src/ports/SkFontConfigParser_android.cpp b/src/ports/SkFontConfigParser_android.cpp
index a9ce0c9d3131a5cc9d79d87ad7caf3260a9a472b..991552fc712bcc93aec7ef1206ceadc294e28ba2 100644
--- a/src/ports/SkFontConfigParser_android.cpp
+++ b/src/ports/SkFontConfigParser_android.cpp
@@ -51,17 +51,17 @@
* can read these variables that are relevant to the current parsing.
*/
struct FamilyData {
- FamilyData(XML_Parser* parserRef, SkTDArray<FontFamily*> &familiesRef) :
+ FamilyData(XML_Parser parserRef, SkTDArray<FontFamily*> &familiesRef) :
parser(parserRef),
families(familiesRef),
currentFamily(NULL),
currentFontInfo(NULL),
currentTag(NO_TAG) {};
- XML_Parser* parser; // The expat parser doing the work
- SkTDArray<FontFamily*> &families; // The array that each family is put into as it is parsed
- FontFamily* currentFamily; // The current family being created
- FontFileInfo* currentFontInfo; // The current fontInfo being created
+ XML_Parser parser; // The expat parser doing the work, owned by caller
+ SkTDArray<FontFamily*>& families; // The array to append families, owned by caller
+ FontFamily* currentFamily; // The current family being created, owned by this
+ FontFileInfo* currentFontInfo; // The current fontInfo being created, owned by currentFamily
int currentTag; // A flag to indicate whether we're in nameset/fileset tags
};
@@ -122,7 +122,7 @@ void fontFileNameHandler(void* data, const char* s, int len) {
familyData->currentFontInfo->fFileName.set(s, len);
}
-void fontElementHandler(XML_Parser* parser, FontFileInfo* file, const char** attributes) {
+void fontElementHandler(XML_Parser parser, FontFileInfo* file, const char** attributes) {
// A <font> should have weight (integer) and style (normal, italic) attributes.
// NOTE: we ignore the style.
// The element should contain a filename.
@@ -138,7 +138,7 @@ void fontElementHandler(XML_Parser* parser, FontFileInfo* file, const char** att
}
}
}
- XML_SetCharacterDataHandler(*parser, fontFileNameHandler);
+ XML_SetCharacterDataHandler(parser, fontFileNameHandler);
}
FontFamily* findFamily(FamilyData* familyData, const char* familyName) {
@@ -225,7 +225,7 @@ void endElementHandler(void* data, const char* tag) {
*familyData->families.append() = familyData->currentFamily;
familyData->currentFamily = NULL;
} else if (len == 4 && !strncmp(tag, "font", len)) {
- XML_SetCharacterDataHandler(*familyData->parser, NULL);
+ XML_SetCharacterDataHandler(familyData->parser, NULL);
}
}
@@ -309,7 +309,7 @@ static void fontFileElementHandler(FamilyData* familyData, const char** attribut
}
}
familyData->currentFontInfo = &newFileInfo;
- XML_SetCharacterDataHandler(*familyData->parser, textHandler);
+ XML_SetCharacterDataHandler(familyData->parser, textHandler);
}
/**
@@ -328,7 +328,7 @@ static void startElementHandler(void* data, const char* tag, const char** atts)
const char* valueString = atts[i+1];
int version;
if (parseNonNegativeInteger(valueString, &version) && (version >= 21)) {
- XML_SetElementHandler(*familyData->parser,
+ XML_SetElementHandler(familyData->parser,
lmpParser::startElementHandler,
lmpParser::endElementHandler);
}
@@ -351,7 +351,7 @@ static void startElementHandler(void* data, const char* tag, const char** atts)
familyData->currentTag = FILESET_TAG;
} else if (len == 4 && strncmp(tag, "name", len) == 0 && familyData->currentTag == NAMESET_TAG) {
// If it's a Name, parse the text inside
- XML_SetCharacterDataHandler(*familyData->parser, textHandler);
+ XML_SetCharacterDataHandler(familyData->parser, textHandler);
} else if (len == 4 && strncmp(tag, "file", len) == 0 && familyData->currentTag == FILESET_TAG) {
// If it's a file, parse the attributes, then parse the text inside
fontFileElementHandler(familyData, atts);
@@ -380,7 +380,7 @@ static void endElementHandler(void* data, const char* tag) {
strncmp(tag, "file", len) == 0 &&
familyData->currentTag == FILESET_TAG)) {
// Disable the arbitrary text handler installed to load Name data
- XML_SetCharacterDataHandler(*familyData->parser, NULL);
+ XML_SetCharacterDataHandler(familyData->parser, NULL);
}
}
@@ -401,7 +401,7 @@ static void parseConfigFile(const char* filename, SkTDArray<FontFamily*> &famili
}
XML_Parser parser = XML_ParserCreate(NULL);
- FamilyData* familyData = new FamilyData(&parser, families);
+ FamilyData* familyData = new FamilyData(parser, families);
XML_SetUserData(parser, familyData);
// Start parsing oldschool; switch these in flight if we detect a newer version of the file.
XML_SetElementHandler(parser, jbParser::startElementHandler, jbParser::endElementHandler);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698