зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1028497 - Part 13: Implement FontFace.load(). r=jdaggett
This commit is contained in:
Родитель
45d38e257f
Коммит
2ec90e70e6
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче