Split out checking whether the document is eligible for font size inflation into its own function.
draft
Split out checking whether the document is eligible for font size inflation into its own function.
Currently, we don't differentiate between font inflation being disabled because of the preferences, or because the document has been detected as being mobile-friendly. Because we now need to differentiate between the two cases for enabling or disabling global zooming, the latter check has been moved forward so it is run ever time.
MozReview-Commit-ID: 5KoOaxr1PEw
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -10857,16 +10857,22 @@ PresShell::SetupFontInflation()
NotifyFontSizeInflationEnabledIsDirty();
}
void
nsIPresShell::RecomputeFontSizeInflationEnabled()
{
mFontSizeInflationEnabledIsDirty = false;
+ RecomputeDocEligibleForFontSizeInflation();
+ if (!mDocIsFontSizeInflationEligible) {
+ mFontSizeInflationEnabled = false;
+ return;
+ }
+
MOZ_ASSERT(mPresContext, "our pres context should not be null");
if ((FontSizeInflationEmPerLine() == 0 &&
FontSizeInflationMinTwips() == 0) || mPresContext->IsChrome()) {
mFontSizeInflationEnabled = false;
return;
}
// Force-enabling font inflation always trumps the heuristics here.
@@ -10883,16 +10889,22 @@ nsIPresShell::RecomputeFontSizeInflation
// explicitly disabled.
if (FontSizeInflationDisabledInMasterProcess()) {
mFontSizeInflationEnabled = false;
return;
}
}
}
+ mFontSizeInflationEnabled = true;
+}
+
+void
+nsIPresShell::RecomputeDocEligibleForFontSizeInflation()
+{
// XXXjwir3:
// See bug 706918, comment 23 for more information on this particular section
// of the code. We're using "screen size" in place of the size of the content
// area, because on mobile, these are close or equal. This will work for our
// purposes (bug 706198), but it will need to be changed in the future to be
// more correct when we bring the rest of the viewport code into platform.
// We actually want the size of the content area, in the event that we don't
// have any metadata about the width and/or height. On mobile, the screen size
@@ -10903,36 +10915,36 @@ nsIPresShell::RecomputeFontSizeInflation
// TODO:
// Once bug 716575 has been resolved, this code should be changed so that it
// does the right thing on all platforms.
nsresult rv;
nsCOMPtr<nsIScreenManager> screenMgr =
do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
if (!NS_SUCCEEDED(rv)) {
- mFontSizeInflationEnabled = false;
+ mDocIsFontSizeInflationEligible = false;
return;
}
nsCOMPtr<nsIScreen> screen;
screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
if (screen) {
int32_t screenLeft, screenTop, screenWidth, screenHeight;
screen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight);
nsViewportInfo vInf =
GetDocument()->GetViewportInfo(ScreenIntSize(screenWidth, screenHeight));
if (vInf.GetDefaultZoom() >= CSSToScreenScale(1.0f) || vInf.IsAutoSizeEnabled()) {
- mFontSizeInflationEnabled = false;
+ mDocIsFontSizeInflationEligible = false;
return;
}
}
- mFontSizeInflationEnabled = true;
+ mDocIsFontSizeInflationEligible = true;
}
bool
nsIPresShell::FontSizeInflationEnabled()
{
if (mFontSizeInflationEnabledIsDirty) {
RecomputeFontSizeInflationEnabled();
PRES_LOG("%p: recomputed FontSizeInflationEnabled: %s\n", this, mFontSizeInflationEnabled?"true":"false");
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1628,16 +1628,23 @@ protected:
/**
* Do computations necessary to determine if font size inflation is enabled.
* This value is cached after computation, as the computation is somewhat
* expensive.
*/
void RecomputeFontSizeInflationEnabled();
+ /**
+ * Determine if the underlying document is eligible for font size inflation.
+ * This value is cached after computation, as the computation is somewhat
+ * expensive.
+ */
+ void RecomputeDocEligibleForFontSizeInflation();
+
void RecordAlloc(void* aPtr) {
#ifdef DEBUG
MOZ_ASSERT(!mAllocatedPointers.Contains(aPtr));
mAllocatedPointers.PutEntry(aPtr);
#endif
}
void RecordFree(void* aPtr) {
@@ -1822,16 +1829,17 @@ protected:
// Cached font inflation values. This is done to prevent changing of font
// inflation until a page is reloaded.
uint32_t mFontSizeInflationEmPerLine;
uint32_t mFontSizeInflationMinTwips;
uint32_t mFontSizeInflationLineThreshold;
bool mFontSizeInflationForceEnabled;
bool mFontSizeInflationDisabledInMasterProcess;
bool mFontSizeInflationEnabled;
+ bool mDocIsFontSizeInflationEligible;
bool mPaintingIsFrozen;
// Dirty bit indicating that mFontSizeInflationEnabled needs to be recomputed.
bool mFontSizeInflationEnabledIsDirty;
// If a document belongs to an invisible DocShell, this flag must be set
// to true, so we can avoid any paint calls for widget related to this
// presshell.