Closed Bug 1031202 Opened 6 years ago Closed 6 years ago

factor out gfxMixedFontFamily lookup/creation into a helper function

Categories

(Core :: Graphics: Text, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: heycam, Assigned: heycam)

References

Details

Attachments

(1 file)

Attached patch patchSplinter Review
There are a number of places in gfxUserFontSet where we look up mFontFamilies and perhaps create one if it doesn't exist.  We should have functions for this so we don't have to duplicate this code.
Attachment #8447034 - Flags: review?(jdaggett)
Blocks: 1031206
Comment on attachment 8447034 [details] [diff] [review]
patch

r+ with name change noted below.

gfx/thebes/gfxUserFontSet.cpp 
@@ -661,27 +652,17 @@ gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
> -gfxFontFamily*
> +gfxMixedFontFamily*
>  gfxUserFontSet::GetFamily(const nsAString& aFamilyName) const
>  {
>      nsAutoString key(aFamilyName);
>      ToLowerCase(key);
>  
>      return mFontFamilies.GetWeak(key);
>  }
>  
> +gfxMixedFontFamily*
> +gfxUserFontSet::MaybeCreateFamily(const nsAString& aFamilyName)
> +{
> +    nsAutoString key(aFamilyName);
> +    ToLowerCase(key);
> +
> +    gfxMixedFontFamily* family = mFontFamilies.GetWeak(key);
> +    if (!family) {
> +        family = new gfxMixedFontFamily(aFamilyName);
> +        mFontFamilies.Put(key, family);
> +    }
> +    return family;
> +}

Rather than using the "Maybe" in a method name, in this case let's:
  - switch GetFamily ==> LookupFamily
  - use GetFamily instead of MaybeCreateFamily (with comment noting its behavior)
Attachment #8447034 - Flags: review?(jdaggett) → review+
https://hg.mozilla.org/mozilla-central/rev/8214bea32abb
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in before you can comment on or make changes to this bug.