Bug 1028497 - Part 8: Implement Length and array access on FontFaceSet. r=jfkthame
authorCameron McCormack <cam@mcc.id.au>
Thu, 02 Oct 2014 12:32:06 +1000
changeset 231535 6b1db854ca0b5a350352bacc3723fb76fa5bec82
parent 231534 ab71716ae728d245e2eacfd76a291ed02a3c9f0e
child 231536 10325066cd8d2dc7cd8d16e8c42b198cfc54d2a1
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)
reviewersjfkthame
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 8: Implement Length and array access on FontFaceSet. r=jfkthame This is a temporary measure until we support iterators on the FontFaceSet; the spec does not expose FontFaces as indexed properties on the FontFaceSet.
layout/style/FontFaceSet.cpp
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -158,24 +158,33 @@ bool
 FontFaceSet::Has(FontFace& aFontFace)
 {
   return false;
 }
 
 FontFace*
 FontFaceSet::IndexedGetter(uint32_t aIndex, bool& aFound)
 {
-  aFound = false;
-  return nullptr;
+  mPresContext->FlushUserFontSet();
+
+  if (aIndex >= mRules.Length()) {
+    aFound = false;
+    return nullptr;
+  }
+
+  aFound = true;
+  return FontFaceForRule(mRules[aIndex].mContainer.mRule);
 }
 
 uint32_t
 FontFaceSet::Length()
 {
-  return 0;
+  mPresContext->FlushUserFontSet();
+
+  return mRules.Length();
 }
 
 static PLDHashOperator DestroyIterator(nsPtrHashKey<nsFontFaceLoader>* aKey,
                                        void* aUserArg)
 {
   aKey->GetKey()->Cancel();
   return PL_DHASH_REMOVE;
 }