Bug 1028497 - Part 17: Factor out FontFace family-name getting. r=jdaggett
authorCameron McCormack <cam@mcc.id.au>
Thu, 02 Oct 2014 12:32:08 +1000
changeset 231545 90f3ab4d59c924ee47fc8e3602ea109b43328c25
parent 231544 173f651e00217dd15cc3f84fcffe954a90babb60
child 231546 e37382cb217343afd8efd35268eab571932be209
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1028497
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1028497 - Part 17: Factor out FontFace family-name getting. r=jdaggett
layout/style/FontFace.cpp
layout/style/FontFace.h
--- a/layout/style/FontFace.cpp
+++ b/layout/style/FontFace.cpp
@@ -413,16 +413,31 @@ FontFace::SetUserFontEntry(gfxUserFontEn
     FontFaceLoadStatus newStatus =
       LoadStateToStatus(mUserFontEntry->LoadState());
     if (newStatus > mStatus) {
       SetStatus(newStatus);
     }
   }
 }
 
+bool
+FontFace::GetFamilyName(nsString& aResult)
+{
+  nsCSSValue value;
+  GetDesc(eCSSFontDesc_Family, value);
+
+  if (value.GetUnit() == eCSSUnit_String) {
+    nsString familyname;
+    value.GetStringValue(familyname);
+    aResult.Append(familyname);
+  }
+
+  return !aResult.IsEmpty();
+}
+
 // -- FontFace::Entry --------------------------------------------------------
 
 /* virtual */ void
 FontFace::Entry::SetLoadState(UserFontLoadState aLoadState)
 {
   gfxUserFontEntry::SetLoadState(aLoadState);
 
   for (size_t i = 0; i < mFontFaces.Length(); i++) {
--- a/layout/style/FontFace.h
+++ b/layout/style/FontFace.h
@@ -73,16 +73,23 @@ public:
 
   nsCSSFontFaceRule* GetRule() { return mRule; }
 
   void GetDesc(nsCSSFontDesc aDescID, nsCSSValue& aResult) const;
 
   gfxUserFontEntry* GetUserFontEntry() const { return mUserFontEntry; }
   void SetUserFontEntry(gfxUserFontEntry* aEntry);
 
+  /**
+   * Gets the family name of the FontFace as a raw string (such as 'Times', as
+   * opposed to GetFamily, which returns a CSS-escaped string, such as
+   * '"Times"').  Returns whether a valid family name was available.
+   */
+  bool GetFamilyName(nsString& aResult);
+
   // Web IDL
   static already_AddRefed<FontFace>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aFamily,
               const mozilla::dom::StringOrArrayBufferOrArrayBufferView& aSource,
               const mozilla::dom::FontFaceDescriptors& aDescriptors,
               ErrorResult& aRV);