Loading gfx/thebes/SharedFontList.cpp +23 −12 Original line number Diff line number Diff line Loading @@ -168,7 +168,11 @@ class SetCharMapRunnable : public mozilla::Runnable { void Face::SetCharacterMap(FontList* aList, gfxCharacterMap* aCharMap, const Family* aFamily) { if (!XRE_IsParentProcess()) { std::pair<uint32_t, bool> familyIndex = aFamily->FindIndex(aList); Maybe<std::pair<uint32_t, bool>> familyIndex = aFamily->FindIndex(aList); if (!familyIndex) { NS_WARNING("Family index not found! Ignoring SetCharacterMap"); return; } const auto* faces = aFamily->Faces(aList); uint32_t faceIndex = 0; while (faceIndex < aFamily->NumFaces()) { Loading @@ -177,14 +181,17 @@ void Face::SetCharacterMap(FontList* aList, gfxCharacterMap* aCharMap, } ++faceIndex; } MOZ_RELEASE_ASSERT(faceIndex < aFamily->NumFaces(), "Face ptr not found!"); if (faceIndex >= aFamily->NumFaces()) { NS_WARNING("Face not found in family! Ignoring SetCharacterMap"); return; } if (NS_IsMainThread()) { dom::ContentChild::GetSingleton()->SendSetCharacterMap( aList->GetGeneration(), familyIndex.first, familyIndex.second, aList->GetGeneration(), familyIndex->first, familyIndex->second, faceIndex, *aCharMap); } else { NS_DispatchToMainThread(new SetCharMapRunnable( aList->GetGeneration(), familyIndex, faceIndex, aCharMap)); aList->GetGeneration(), familyIndex.value(), faceIndex, aCharMap)); } return; } Loading Loading @@ -629,16 +636,20 @@ void Family::SetupFamilyCharMap(FontList* aList) { if (!XRE_IsParentProcess()) { // |this| could be a Family record in either the Families() or Aliases() // arrays; FindIndex will map it back to its index and which array. std::pair<uint32_t, bool> index = FindIndex(aList); Maybe<std::pair<uint32_t, bool>> index = FindIndex(aList); if (!index) { NS_WARNING("Family index not found! Ignoring SetupFamilyCharMap"); return; } if (NS_IsMainThread()) { dom::ContentChild::GetSingleton()->SendSetupFamilyCharMap( aList->GetGeneration(), index.first, index.second); aList->GetGeneration(), index->first, index->second); return; } NS_DispatchToMainThread(NS_NewRunnableFunction( "SetupFamilyCharMap callback", [gen = aList->GetGeneration(), idx = index.first, alias = index.second] { [gen = aList->GetGeneration(), idx = index->first, alias = index->second] { dom::ContentChild::GetSingleton()->SendSetupFamilyCharMap(gen, idx, alias); })); Loading Loading @@ -685,13 +696,13 @@ void Family::SetupFamilyCharMap(FontList* aList) { } } std::pair<uint32_t, bool> Family::FindIndex(FontList* aList) const { Maybe<std::pair<uint32_t, bool>> Family::FindIndex(FontList* aList) const { const auto* start = aList->Families(); const auto* end = start + aList->NumFamilies(); if (this >= start && this < end) { uint32_t index = this - start; MOZ_RELEASE_ASSERT(start + index == this, "misaligned Family ptr!"); return std::pair(index, false); return Some(std::pair(index, false)); } start = aList->AliasFamilies(); Loading @@ -699,10 +710,10 @@ std::pair<uint32_t, bool> Family::FindIndex(FontList* aList) const { if (this >= start && this < end) { uint32_t index = this - start; MOZ_RELEASE_ASSERT(start + index == this, "misaligned AliasFamily ptr!"); return std::pair(index, true); return Some(std::pair(index, true)); } MOZ_CRASH("invalid font-list Family ptr!"); return Nothing(); } FontList::FontList(uint32_t aGeneration) { Loading gfx/thebes/SharedFontList.h +2 −1 Original line number Diff line number Diff line Loading @@ -333,7 +333,8 @@ struct Family { // Return the index of this family in the font-list's Families() or // AliasFamilies() list, and which of those it belongs to. std::pair<uint32_t, bool> FindIndex(FontList* aList) const; // Returns Nothing if the family cannot be found. mozilla::Maybe<std::pair<uint32_t, bool>> FindIndex(FontList* aList) const; private: // Returns true if there are specifically-sized bitmap faces in the list, Loading Loading
gfx/thebes/SharedFontList.cpp +23 −12 Original line number Diff line number Diff line Loading @@ -168,7 +168,11 @@ class SetCharMapRunnable : public mozilla::Runnable { void Face::SetCharacterMap(FontList* aList, gfxCharacterMap* aCharMap, const Family* aFamily) { if (!XRE_IsParentProcess()) { std::pair<uint32_t, bool> familyIndex = aFamily->FindIndex(aList); Maybe<std::pair<uint32_t, bool>> familyIndex = aFamily->FindIndex(aList); if (!familyIndex) { NS_WARNING("Family index not found! Ignoring SetCharacterMap"); return; } const auto* faces = aFamily->Faces(aList); uint32_t faceIndex = 0; while (faceIndex < aFamily->NumFaces()) { Loading @@ -177,14 +181,17 @@ void Face::SetCharacterMap(FontList* aList, gfxCharacterMap* aCharMap, } ++faceIndex; } MOZ_RELEASE_ASSERT(faceIndex < aFamily->NumFaces(), "Face ptr not found!"); if (faceIndex >= aFamily->NumFaces()) { NS_WARNING("Face not found in family! Ignoring SetCharacterMap"); return; } if (NS_IsMainThread()) { dom::ContentChild::GetSingleton()->SendSetCharacterMap( aList->GetGeneration(), familyIndex.first, familyIndex.second, aList->GetGeneration(), familyIndex->first, familyIndex->second, faceIndex, *aCharMap); } else { NS_DispatchToMainThread(new SetCharMapRunnable( aList->GetGeneration(), familyIndex, faceIndex, aCharMap)); aList->GetGeneration(), familyIndex.value(), faceIndex, aCharMap)); } return; } Loading Loading @@ -629,16 +636,20 @@ void Family::SetupFamilyCharMap(FontList* aList) { if (!XRE_IsParentProcess()) { // |this| could be a Family record in either the Families() or Aliases() // arrays; FindIndex will map it back to its index and which array. std::pair<uint32_t, bool> index = FindIndex(aList); Maybe<std::pair<uint32_t, bool>> index = FindIndex(aList); if (!index) { NS_WARNING("Family index not found! Ignoring SetupFamilyCharMap"); return; } if (NS_IsMainThread()) { dom::ContentChild::GetSingleton()->SendSetupFamilyCharMap( aList->GetGeneration(), index.first, index.second); aList->GetGeneration(), index->first, index->second); return; } NS_DispatchToMainThread(NS_NewRunnableFunction( "SetupFamilyCharMap callback", [gen = aList->GetGeneration(), idx = index.first, alias = index.second] { [gen = aList->GetGeneration(), idx = index->first, alias = index->second] { dom::ContentChild::GetSingleton()->SendSetupFamilyCharMap(gen, idx, alias); })); Loading Loading @@ -685,13 +696,13 @@ void Family::SetupFamilyCharMap(FontList* aList) { } } std::pair<uint32_t, bool> Family::FindIndex(FontList* aList) const { Maybe<std::pair<uint32_t, bool>> Family::FindIndex(FontList* aList) const { const auto* start = aList->Families(); const auto* end = start + aList->NumFamilies(); if (this >= start && this < end) { uint32_t index = this - start; MOZ_RELEASE_ASSERT(start + index == this, "misaligned Family ptr!"); return std::pair(index, false); return Some(std::pair(index, false)); } start = aList->AliasFamilies(); Loading @@ -699,10 +710,10 @@ std::pair<uint32_t, bool> Family::FindIndex(FontList* aList) const { if (this >= start && this < end) { uint32_t index = this - start; MOZ_RELEASE_ASSERT(start + index == this, "misaligned AliasFamily ptr!"); return std::pair(index, true); return Some(std::pair(index, true)); } MOZ_CRASH("invalid font-list Family ptr!"); return Nothing(); } FontList::FontList(uint32_t aGeneration) { Loading
gfx/thebes/SharedFontList.h +2 −1 Original line number Diff line number Diff line Loading @@ -333,7 +333,8 @@ struct Family { // Return the index of this family in the font-list's Families() or // AliasFamilies() list, and which of those it belongs to. std::pair<uint32_t, bool> FindIndex(FontList* aList) const; // Returns Nothing if the family cannot be found. mozilla::Maybe<std::pair<uint32_t, bool>> FindIndex(FontList* aList) const; private: // Returns true if there are specifically-sized bitmap faces in the list, Loading