mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 1b2c43ed9fdc (bug 879963) for intermittent failures in test_redundant_font_download.html
This commit is contained in:
parent
9424eb7c9e
commit
0917f8d010
@ -413,54 +413,39 @@ static PLDHashOperator DetachFontEntries(const nsAString& aKey,
|
|||||||
return PL_DHASH_NEXT;
|
return PL_DHASH_NEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PLDHashOperator RemoveIfEmpty(const nsAString& aKey,
|
|
||||||
nsRefPtr<gfxMixedFontFamily>& aFamily,
|
|
||||||
void* aUserArg)
|
|
||||||
{
|
|
||||||
return aFamily->GetFontList().Length() ? PL_DHASH_NEXT : PL_DHASH_REMOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsUserFontSet::UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules)
|
nsUserFontSet::UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules)
|
||||||
{
|
{
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|
||||||
// The @font-face rules that make up the user font set have changed,
|
// destroy any current loaders, as the entries they refer to
|
||||||
// so we need to update the set. However, we want to preserve existing
|
// may be about to get replaced
|
||||||
// font entries wherever possible, so that we don't discard and then
|
if (mLoaders.Count() > 0) {
|
||||||
// re-download resources in the (common) case where at least some of the
|
modified = true; // trigger reflow so that any necessary downloads
|
||||||
// same rules are still present.
|
// will be reinitiated
|
||||||
|
}
|
||||||
|
mLoaders.EnumerateEntries(DestroyIterator, nullptr);
|
||||||
|
|
||||||
nsTArray<FontFaceRuleRecord> oldRules;
|
nsTArray<FontFaceRuleRecord> oldRules;
|
||||||
mRules.SwapElements(oldRules);
|
mRules.SwapElements(oldRules);
|
||||||
|
|
||||||
// Remove faces from the font family records; we need to re-insert them
|
// destroy the font family records; we need to re-create them
|
||||||
// because we might end up with faces in a different order even if they're
|
// because we might end up with faces in a different order,
|
||||||
// the same font entries as before. (The order can affect font selection
|
// even if they're the same font entries as before
|
||||||
// where multiple faces match the requested style, perhaps with overlapping
|
|
||||||
// unicode-range coverage.)
|
|
||||||
mFontFamilies.Enumerate(DetachFontEntries, nullptr);
|
mFontFamilies.Enumerate(DetachFontEntries, nullptr);
|
||||||
|
mFontFamilies.Clear();
|
||||||
|
|
||||||
for (uint32_t i = 0, i_end = aRules.Length(); i < i_end; ++i) {
|
for (uint32_t i = 0, i_end = aRules.Length(); i < i_end; ++i) {
|
||||||
// Insert each rule into our list, migrating old font entries if possible
|
// insert each rule into our list, migrating old font entries if possible
|
||||||
// rather than creating new ones; set modified to true if we detect
|
// rather than creating new ones; set modified to true if we detect
|
||||||
// that rule ordering has changed, or if a new entry is created.
|
// that rule ordering has changed, or if a new entry is created
|
||||||
InsertRule(aRules[i].mRule, aRules[i].mSheetType, oldRules, modified);
|
InsertRule(aRules[i].mRule, aRules[i].mSheetType, oldRules, modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any residual families that have no font entries (i.e., they were
|
// if any rules are left in the old list, note that the set has changed
|
||||||
// not defined at all by the updated set of @font-face rules).
|
|
||||||
mFontFamilies.Enumerate(RemoveIfEmpty, nullptr);
|
|
||||||
|
|
||||||
// If any rules are left in the old list, note that the set has changed
|
|
||||||
// (even if the new set was built entirely by migrating old font entries).
|
|
||||||
if (oldRules.Length() > 0) {
|
if (oldRules.Length() > 0) {
|
||||||
modified = true;
|
modified = true;
|
||||||
// Any in-progress loaders for obsolete rules should be cancelled,
|
// any in-progress loaders for obsolete rules should be cancelled
|
||||||
// as the resource being downloaded will no longer be required.
|
|
||||||
// We need to explicitly remove any loaders here, otherwise the loaders
|
|
||||||
// will keep their "orphaned" font entries alive until they complete,
|
|
||||||
// even after the oldRules array is deleted.
|
|
||||||
size_t count = oldRules.Length();
|
size_t count = oldRules.Length();
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
gfxFontEntry *fe = oldRules[i].mFontEntry;
|
gfxFontEntry *fe = oldRules[i].mFontEntry;
|
||||||
|
Loading…
Reference in New Issue
Block a user