mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1031206 - Part 2: Split out creation of font faces in nsUserFontSet. r=jdaggett
This commit is contained in:
parent
301ffbc85a
commit
7e319341f4
@ -567,6 +567,36 @@ nsUserFontSet::InsertRule(nsCSSFontFaceRule* aRule, uint8_t aSheetType,
|
||||
}
|
||||
|
||||
// this is a new rule:
|
||||
FontFaceRuleRecord ruleRec;
|
||||
ruleRec.mFontEntry =
|
||||
FindOrCreateFontFaceFromRule(fontfamily, aRule, aSheetType);
|
||||
|
||||
if (!ruleRec.mFontEntry) {
|
||||
return;
|
||||
}
|
||||
|
||||
ruleRec.mContainer.mRule = aRule;
|
||||
ruleRec.mContainer.mSheetType = aSheetType;
|
||||
|
||||
// Add the entry to the end of the list. If an existing proxy entry was
|
||||
// returned by FindOrCreateFontFaceFromRule that was already stored on the
|
||||
// family, gfxMixedFontFamily::AddFontEntry(), which AddFontFace calls,
|
||||
// will automatically remove the earlier occurrence of the same proxy.
|
||||
AddFontFace(fontfamily, ruleRec.mFontEntry);
|
||||
|
||||
mRules.AppendElement(ruleRec);
|
||||
|
||||
// this was a new rule and font entry, so note that the set was modified
|
||||
aFontSetModified = true;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFontEntry>
|
||||
nsUserFontSet::FindOrCreateFontFaceFromRule(const nsAString& aFamilyName,
|
||||
nsCSSFontFaceRule* aRule,
|
||||
uint8_t aSheetType)
|
||||
{
|
||||
nsCSSValue val;
|
||||
uint32_t unit;
|
||||
|
||||
uint32_t weight = NS_STYLE_FONT_WEIGHT_NORMAL;
|
||||
int32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL;
|
||||
@ -653,7 +683,7 @@ nsUserFontSet::InsertRule(nsCSSFontFaceRule* aRule, uint8_t aSheetType,
|
||||
unit = val.GetUnit();
|
||||
gfxFontFaceSrc* face = srcArray.AppendElements(1);
|
||||
if (!face)
|
||||
return;
|
||||
return nullptr;
|
||||
|
||||
switch (unit) {
|
||||
|
||||
@ -718,26 +748,15 @@ nsUserFontSet::InsertRule(nsCSSFontFaceRule* aRule, uint8_t aSheetType,
|
||||
NS_ASSERTION(unit == eCSSUnit_Null, "@font-face src has unexpected unit");
|
||||
}
|
||||
|
||||
if (srcArray.Length() > 0) {
|
||||
FontFaceRuleRecord ruleRec;
|
||||
ruleRec.mContainer.mRule = aRule;
|
||||
ruleRec.mContainer.mSheetType = aSheetType;
|
||||
ruleRec.mFontEntry = FindOrCreateFontFace(fontfamily, srcArray,
|
||||
weight, stretch, italicStyle,
|
||||
featureSettings, languageOverride,
|
||||
nullptr /* aUnicodeRanges */);
|
||||
if (ruleRec.mFontEntry) {
|
||||
// Add the entry to the end of the list. If an existing proxy entry was
|
||||
// returned by FindOrCreateFontFace that was already stored on the
|
||||
// family, gfxMixedFontFamily::AddFontEntry(), which AddFontFace calls,
|
||||
// will automatically remove the earlier occurrence of the same proxy.
|
||||
AddFontFace(fontfamily, ruleRec.mFontEntry);
|
||||
|
||||
mRules.AppendElement(ruleRec);
|
||||
}
|
||||
// this was a new rule and fontEntry, so note that the set was modified
|
||||
aFontSetModified = true;
|
||||
if (srcArray.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxProxyFontEntry> entry =
|
||||
FindOrCreateFontFace(aFamilyName, srcArray, weight, stretch, italicStyle,
|
||||
featureSettings, languageOverride,
|
||||
nullptr /* aUnicodeRanges */);
|
||||
return entry.forget();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -70,6 +70,11 @@ protected:
|
||||
nsTArray<FontFaceRuleRecord>& oldRules,
|
||||
bool& aFontSetModified);
|
||||
|
||||
already_AddRefed<gfxFontEntry> FindOrCreateFontFaceFromRule(
|
||||
const nsAString& aFamilyName,
|
||||
nsCSSFontFaceRule* aRule,
|
||||
uint8_t aSheetType);
|
||||
|
||||
virtual nsresult LogMessage(gfxMixedFontFamily* aFamily,
|
||||
gfxProxyFontEntry* aProxy,
|
||||
const char* aMessage,
|
||||
|
Loading…
Reference in New Issue
Block a user