Bug 1521137 - Remove another font API outside of the pres context. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 22 Jan 2019 15:52:41 +0100
changeset 514830 1a43fcfbf783fe3d134c30394d5d83f474faf93b
parent 514829 b707a2928093bab22e8959f144e72d6654c586ac
child 514831 d9e1039ecab03119610f4dea535eff9d9a51c901
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1521137
milestone66.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 1521137 - Remove another font API outside of the pres context. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D17005
layout/base/nsPresContext.h
layout/style/GeckoBindings.cpp
layout/style/nsStyleStruct.cpp
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -554,31 +554,16 @@ class nsPresContext : public nsISupports
    * by zoom.maxPercent and minPercent.
    * As the system font scale is automatically set by the PresShell, code that
    * e.g. wants to transfer zoom levels to a new document should use TextZoom()
    * instead, which corresponds to the text zoom level that was actually set by
    * the front-end/user.
    */
   float EffectiveTextZoom() const { return mEffectiveTextZoom; }
 
-  /**
-   * Get the minimum font size for the specified language. If aLanguage
-   * is nullptr, then the document's language is used.  This combines
-   * the language-specific global preference with the per-presentation
-   * base minimum font size.
-   */
-  int32_t MinFontSize(nsAtom* aLanguage, bool* aNeedsToCache = nullptr) const {
-    const auto* prefs =
-        Document()->GetFontPrefsForLang(aLanguage, aNeedsToCache);
-    if (aNeedsToCache && *aNeedsToCache) {
-      return 0;
-    }
-    return prefs->mMinimumFontSize;
-  }
-
   float GetFullZoom() { return mFullZoom; }
   /**
    * Device full zoom differs from full zoom because it gets the zoom from
    * the device context, which may be using a different zoom due to rounding
    * of app units to device pixels.
    */
   float GetDeviceFullZoom();
   void SetFullZoom(float aZoom);
--- a/layout/style/GeckoBindings.cpp
+++ b/layout/style/GeckoBindings.cpp
@@ -1943,24 +1943,30 @@ void Gecko_nsStyleFont_PrefillDefaultFor
   }
 }
 
 void Gecko_nsStyleFont_FixupMinFontSize(
     nsStyleFont* aFont, RawGeckoPresContextBorrowed aPresContext) {
   nscoord minFontSize;
   bool needsCache = false;
 
+  auto MinFontSize = [&](bool* aNeedsToCache) {
+    auto* prefs = aPresContext->Document()->GetFontPrefsForLang(
+        aFont->mLanguage, aNeedsToCache);
+    return prefs ? prefs->mMinimumFontSize : 0;
+  };
+
   {
     AutoReadLock guard(*sServoFFILock);
-    minFontSize = aPresContext->MinFontSize(aFont->mLanguage, &needsCache);
+    minFontSize = MinFontSize(&needsCache);
   }
 
   if (needsCache) {
     AutoWriteLock guard(*sServoFFILock);
-    minFontSize = aPresContext->MinFontSize(aFont->mLanguage, nullptr);
+    minFontSize = MinFontSize(nullptr);
   }
 
   nsLayoutUtils::ApplyMinFontSize(aFont, aPresContext, minFontSize);
 }
 
 void FontSizePrefs::CopyFrom(const LangGroupFontPrefs& prefs) {
   mDefaultVariableSize = prefs.mDefaultVariableFont.size;
   mDefaultFixedSize = prefs.mDefaultFixedFont.size;
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -125,21 +125,21 @@ nsStyleFont::nsStyleFont(const nsPresCon
       mAllowZoom(true),
       mScriptUnconstrainedSize(mSize),
       mScriptMinSize(nsPresContext::CSSTwipsToAppUnits(
           NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT))),
       mScriptSizeMultiplier(NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER),
       mLanguage(aContext->Document()->GetLanguageForStyle()) {
   MOZ_COUNT_CTOR(nsStyleFont);
   MOZ_ASSERT(NS_IsMainThread());
-  nscoord minimumFontSize = aContext->MinFontSize(mLanguage);
-  if (minimumFontSize > 0 && !aContext->IsChrome()) {
+  mFont.size = mSize;
+  if (!aContext->IsChrome()) {
+    nscoord minimumFontSize =
+        aContext->Document()->GetFontPrefsForLang(mLanguage)->mMinimumFontSize;
     mFont.size = std::max(mSize, minimumFontSize);
-  } else {
-    mFont.size = mSize;
   }
 }
 
 nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aNewData) const {
   MOZ_ASSERT(mAllowZoom == aNewData.mAllowZoom,
              "expected mAllowZoom to be the same on both nsStyleFonts");
   if (mSize != aNewData.mSize || mLanguage != aNewData.mLanguage ||
       mExplicitLanguage != aNewData.mExplicitLanguage ||