Bug 1028497 - Part 13: Implement FontFace.load(). r=jdaggett

This commit is contained in:
Cameron McCormack 2014-10-02 12:32:07 +10:00
parent c82125e2b6
commit 21a470ab25
3 changed files with 30 additions and 0 deletions

View File

@ -246,11 +246,24 @@ FontFace::Status()
Promise*
FontFace::Load(ErrorResult& aRv)
{
mPresContext->FlushUserFontSet();
if (!mLoaded) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
if (mStatus != FontFaceLoadStatus::Unloaded) {
return mLoaded;
}
SetStatus(FontFaceLoadStatus::Loading);
gfxUserFontEntry* entry =
mPresContext->Fonts()->FindUserFontEntryForFontFace(this);
if (entry) {
entry->Load();
}
return mLoaded;
}

View File

@ -701,6 +701,17 @@ FontFaceSet::FindUserFontEntryForRule(nsCSSFontFaceRule* aRule)
return nullptr;
}
gfxUserFontEntry*
FontFaceSet::FindUserFontEntryForFontFace(FontFace* aFontFace)
{
for (size_t i = 0; i < mRules.Length(); i++) {
if (mRules[i].mContainer.mRule->GetFontFace() == aFontFace) {
return mRules[i].mUserFontEntry;
}
}
return nullptr;
}
nsresult
FontFaceSet::LogMessage(gfxUserFontEntry* aUserFontEntry,
const char* aMessage,

View File

@ -118,6 +118,12 @@ public:
*/
FontFace* FindFontFaceForEntry(gfxUserFontEntry* aUserFontEntry);
/**
* Looks up the corresponding user font entry for the given FontFace object.
* Returns null if there was none.
*/
gfxUserFontEntry* FindUserFontEntryForFontFace(FontFace* aFontFace);
// -- Web IDL --------------------------------------------------------------
IMPL_EVENT_HANDLER(loading)