mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 784375: Add a preference to control maximum font size inflation ratio.
This commit is contained in:
parent
e5fff3ba10
commit
293a66e4de
@ -106,7 +106,8 @@ typedef FrameMetrics::ViewID ViewID;
|
||||
/* static */ uint32_t nsLayoutUtils::sFontSizeInflationEmPerLine;
|
||||
/* static */ uint32_t nsLayoutUtils::sFontSizeInflationMinTwips;
|
||||
/* static */ uint32_t nsLayoutUtils::sFontSizeInflationLineThreshold;
|
||||
/* static */ int32_t nsLayoutUtils::sFontSizeInflationMappingIntercept;
|
||||
/* static */ int32_t nsLayoutUtils::sFontSizeInflationMappingIntercept;
|
||||
/* static */ uint32_t nsLayoutUtils::sFontSizeInflationMaxRatio;
|
||||
|
||||
static ViewID sScrollIdCounter = FrameMetrics::START_SCROLL_ID;
|
||||
|
||||
@ -4679,6 +4680,8 @@ nsLayoutUtils::SizeOfTextRunsForFrames(nsIFrame* aFrame,
|
||||
void
|
||||
nsLayoutUtils::Initialize()
|
||||
{
|
||||
Preferences::AddUintVarCache(&sFontSizeInflationMaxRatio,
|
||||
"font.size.inflation.maxRatio");
|
||||
Preferences::AddUintVarCache(&sFontSizeInflationEmPerLine,
|
||||
"font.size.inflation.emPerLine");
|
||||
Preferences::AddUintVarCache(&sFontSizeInflationMinTwips,
|
||||
@ -4960,8 +4963,10 @@ nsLayoutUtils::FontSizeInflationInner(const nsIFrame *aFrame,
|
||||
}
|
||||
|
||||
int32_t interceptParam = nsLayoutUtils::FontSizeInflationMappingIntercept();
|
||||
float maxRatio = (float)nsLayoutUtils::FontSizeInflationMaxRatio() / 100.0f;
|
||||
|
||||
float ratio = float(styleFontSize) / float(aMinFontSize);
|
||||
float inflationRatio;
|
||||
|
||||
// Given a minimum inflated font size m, a specified font size s, we want to
|
||||
// find the inflated font size i and then return the ratio of i to s (i/s).
|
||||
@ -4984,12 +4989,18 @@ nsLayoutUtils::FontSizeInflationInner(const nsIFrame *aFrame,
|
||||
// graph is a line from (0, m), to that point). We calculate the
|
||||
// intersection point to be ((1+P/2)m, (1+P/2)m), where P is the
|
||||
// intercept parameter above. We then need to return i/s.
|
||||
return (1.0f + (ratio * (intercept - 1) / intercept)) / ratio;
|
||||
inflationRatio = (1.0f + (ratio * (intercept - 1) / intercept)) / ratio;
|
||||
} else {
|
||||
// This is the case where P is negative. We essentially want to implement
|
||||
// the case for P=infinity here, so we make i = s + m, which means that
|
||||
// i/s = s/s + m/s = 1 + 1/ratio
|
||||
return 1 + 1.0f / ratio;
|
||||
inflationRatio = 1 + 1.0f / ratio;
|
||||
}
|
||||
|
||||
if (maxRatio > 1.0 && inflationRatio > maxRatio) {
|
||||
return maxRatio;
|
||||
} else {
|
||||
return inflationRatio;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1611,6 +1611,14 @@ public:
|
||||
|
||||
static bool FontSizeInflationEnabled(nsPresContext *aPresContext);
|
||||
|
||||
/**
|
||||
* See comment above "font.size.inflation.maxRatio" in
|
||||
* modules/libpref/src/init/all.js .
|
||||
*/
|
||||
static uint32_t FontSizeInflationMaxRatio() {
|
||||
return sFontSizeInflationMaxRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* See comment above "font.size.inflation.emPerLine" in
|
||||
* modules/libpref/src/init/all.js .
|
||||
@ -1751,7 +1759,8 @@ private:
|
||||
static uint32_t sFontSizeInflationEmPerLine;
|
||||
static uint32_t sFontSizeInflationMinTwips;
|
||||
static uint32_t sFontSizeInflationLineThreshold;
|
||||
static int32_t sFontSizeInflationMappingIntercept;
|
||||
static int32_t sFontSizeInflationMappingIntercept;
|
||||
static uint32_t sFontSizeInflationMaxRatio;
|
||||
};
|
||||
|
||||
template<typename PointType, typename RectType, typename CoordType>
|
||||
|
@ -997,6 +997,9 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"layout.css.devPixelsPerPx",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"font.size.inflation",
|
||||
this);
|
||||
|
||||
nsresult rv = mEventManager->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
13
layout/reftests/font-inflation/maxRatio-1-ref.html
Normal file
13
layout/reftests/font-inflation/maxRatio-1-ref.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML>
|
||||
<style>
|
||||
div { background: yellow }
|
||||
div { font-size: 24px; width: 450px }
|
||||
</style>
|
||||
<!--
|
||||
In a 450px container, the minimum font size at 15em per line is 30px.
|
||||
This means we map 0px-45px into 30px-45px, so 12px gets mapped to 34px.
|
||||
However, because we've enabled the maxRatio at a value of 2.0, the mapping
|
||||
function, which would normally return 34px/12px, or about 2.83, now
|
||||
returns a ratio capped at 2.0, thus the actual font size is 24px.
|
||||
-->
|
||||
<div>Hello world</div>
|
13
layout/reftests/font-inflation/maxRatio-1.html
Normal file
13
layout/reftests/font-inflation/maxRatio-1.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML>
|
||||
<style>
|
||||
div { background: yellow }
|
||||
div { font-size: 12px; width: 450px }
|
||||
</style>
|
||||
<!--
|
||||
In a 450px container, the minimum font size at 15em per line is 30px.
|
||||
This means we map 0px-45px into 30px-45px, so 12px gets mapped to 34px.
|
||||
However, because we've enabled the maxRatio at a value of 2.0, the mapping
|
||||
function, which would normally return 34px/12px, or about 2.83, now
|
||||
returns a ratio capped at 2.0, thus the actual font size is 24px.
|
||||
-->
|
||||
<div>Hello world</div>
|
@ -5,6 +5,7 @@
|
||||
# with the lineThreshold preference explicitly set to zero. However,
|
||||
# newer tests should probably focus more on testing nonzero values of
|
||||
# that preference.
|
||||
test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,0) test-pref(font.size.inflation.maxRatio,200) == maxRatio-1.html maxRatio-1-ref.html
|
||||
test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,0) == text-1.html text-1-ref.html
|
||||
test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,0) == text-2.html text-2-ref.html
|
||||
test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,0) == text-3.html text-3-ref.html
|
||||
|
@ -1814,6 +1814,19 @@ pref("font.size.inflation.lineThreshold", 400);
|
||||
*/
|
||||
pref("font.size.inflation.mappingIntercept", 1);
|
||||
|
||||
|
||||
/*
|
||||
* This controls the percentage that fonts will be inflated, if font
|
||||
* size inflation is enabled. Essentially, if we have a specified font
|
||||
* size, s, and an inflated font size, i, this specifies that the ratio
|
||||
* i/s * 100 should never exceed the value of this preference.
|
||||
*
|
||||
* In order for this preference to have any effect, its value must be
|
||||
* greater than 100, since font inflation can never decrease the ratio
|
||||
* i/s.
|
||||
*/
|
||||
pref("font.size.inflation.maxRatio", 0);
|
||||
|
||||
/*
|
||||
* When enabled, the touch.radius and mouse.radius prefs allow events to be dispatched
|
||||
* to nearby elements that are sensitive to the event. See PositionedEventTargeting.cpp.
|
||||
|
Loading…
Reference in New Issue
Block a user