Commit 935fac58 authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe
Browse files

Bug 1640223 - Expand the given size in ExpandHeightForViewportUnits by...

Bug 1640223 - Expand the given size in ExpandHeightForViewportUnits by multiplying the 'vh value / visible area height'. r=botond

The viewport units size doesn't match the aspect ratio of the screen size in
some cases.

For example, in the case of the reftest in this commit, the meta viewport is
"width=1600, height=device-height" and the screen size during reftest is
"800x1000". Thus the viewport units size will be "1600x1000". In such cases
with the old way ExpandHeightForViewportUnits shrinks the given size
"1600x1800" to "1600x1000" with 100px dynamic toolbar max height (and the
MOZ_ASSERT in the function happens on debug builds).

Differential Revision: https://phabricator.services.mozilla.com/D77176
parent eba22e22
......@@ -3165,14 +3165,15 @@ template <typename SizeType>
// |aSize| might be the size expanded to the minimum-scale size whereas the
// size for viewport units is not scaled so that we need to expand the |aSize|
// height with the aspect ratio of the size for viewport units instead of just
// expanding to the size for viewport units.
float ratio = (float)sizeForViewportUnits.height / sizeForViewportUnits.width;
MOZ_ASSERT(aSize.height <=
NSCoordSaturatingNonnegativeMultiply(aSize.width, ratio));
return SizeType(aSize.width,
NSCoordSaturatingNonnegativeMultiply(aSize.width, ratio));
// height by multiplying by the ratio of the viewport units height to the
// visible area height.
float vhExpansionRatio = (float)sizeForViewportUnits.height /
aPresContext->GetVisibleArea().height;
MOZ_ASSERT(aSize.height <= NSCoordSaturatingNonnegativeMultiply(
aSize.height, vhExpansionRatio));
return SizeType(aSize.width, NSCoordSaturatingNonnegativeMultiply(
aSize.height, vhExpansionRatio));
}
template <typename T>
......
......@@ -252,6 +252,12 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType)
// maybe we could throttle and only collect stats on 1% of page-loads,
// or something like that.
mFontStats = MakeUnique<FontMatchingStats>();
if (StaticPrefs::layout_dynamic_toolbar_max_height() > 0) {
// The pref for dynamic toolbar max height is only used in reftests so it's
// fine to set here.
mDynamicToolbarMaxHeight = StaticPrefs::layout_dynamic_toolbar_max_height();
}
}
static const char* gExactCallbackPrefs[] = {
......
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
html {
scrollbar-width: none;
}
body {
margin: 0px;
padding: 0px;
}
div {
width: 100vw;
height: 50vh;
}
</style>
<div style="background-color: green;"></div>
<div style="background-color: blue;"></div>
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=1600, height=device-height">
<style>
html {
scrollbar-width: none;
}
body {
margin: 0px;
padding: 0px;
}
div {
width: 100vw;
}
</style>
<div style="height: 100vh; background-color: green;"></div>
<div style="height: 500vh; background-color: blue;"></div>
......@@ -38,3 +38,4 @@ pref(layout.viewport_contains_no_contents_area,true) == dynamic-grow-width.html
== dynamic-grow-width-and-height.html overflow-region-ref.html
== not-able-to-scrollTo.html about:blank
== min-scale-aspect-ratio.html about:blank
pref(layout.dynamic-toolbar-max-height,100) == device-height-with-dynamic-toolbar.html device-height-with-dynamic-toolbar-ref.html
......@@ -6258,6 +6258,12 @@
value: true
mirror: always
# Test only.
- name: layout.dynamic-toolbar-max-height
type: RelaxedAtomicInt32
value: 0
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "mathml."
#---------------------------------------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment