Bug 1028497 - Part 17: Factor out FontFace family-name getting. r=jdaggett

This commit is contained in:
Cameron McCormack 2014-10-02 12:32:08 +10:00
parent cf965693b0
commit b4bf68ac33
2 changed files with 22 additions and 0 deletions

View File

@ -418,6 +418,21 @@ FontFace::SetUserFontEntry(gfxUserFontEntry* aEntry)
}
}
bool
FontFace::GetFamilyName(nsString& aResult)
{
nsCSSValue value;
GetDesc(eCSSFontDesc_Family, value);
if (value.GetUnit() == eCSSUnit_String) {
nsString familyname;
value.GetStringValue(familyname);
aResult.Append(familyname);
}
return !aResult.IsEmpty();
}
// -- FontFace::Entry --------------------------------------------------------
/* virtual */ void

View File

@ -78,6 +78,13 @@ public:
gfxUserFontEntry* GetUserFontEntry() const { return mUserFontEntry; }
void SetUserFontEntry(gfxUserFontEntry* aEntry);
/**
* Gets the family name of the FontFace as a raw string (such as 'Times', as
* opposed to GetFamily, which returns a CSS-escaped string, such as
* '"Times"'). Returns whether a valid family name was available.
*/
bool GetFamilyName(nsString& aResult);
// Web IDL
static already_AddRefed<FontFace>
Constructor(const GlobalObject& aGlobal,