Bug 1647186 - Apply the cumulative resolution smaller than 1.0 to the root frame size for the partial pre-render. r=botond

So that we can reasonably expand the pre-render region on mobile environments.

Differential Revision: https://phabricator.services.mozilla.com/D81961
This commit is contained in:
Hiroyuki Ikezoe 2020-07-05 23:17:02 +00:00
Родитель e309ecf825
Коммит 43877bd8b5
5 изменённых файлов: 163 добавлений и 0 удалений

Просмотреть файл

@ -7748,6 +7748,15 @@ auto nsDisplayTransform::ShouldPrerenderTransformedContent(
uint32_t absoluteLimitY =
StaticPrefs::layout_animation_prerender_absolute_limit_y();
nsSize refSize = aBuilder->RootReferenceFrame()->GetSize();
float resolution = aFrame->PresShell()->GetCumulativeResolution();
if (resolution < 1.0f) {
refSize.SizeTo(
NSCoordSaturatingNonnegativeMultiply(refSize.width, 1.0f / resolution),
NSCoordSaturatingNonnegativeMultiply(refSize.height,
1.0f / resolution));
}
// Only prerender if the transformed frame's size is <= a multiple of the
// reference frame size (~viewport), and less than an absolute limit.
// Both the ratio and the absolute limit are configurable.

Просмотреть файл

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html class="reftest-wait reftest-no-flush" reftest-resolution="0.5">
<meta name="viewport" content="width=device-width,minimum-scale=0.5,initial-scale=1">
<!--
A test for a partial pre-rendered transform animation with <1.0 resolution.
-->
<style>
html {
scrollbar-width: none;
}
body {
margin: 0px;
padding: 0px;
}
@keyframes anim {
/* The reftest window size is (800x1000) and it's scaled by 0.5 */
/* (= 1600x2000), which means the partial pre-render size is (2250x2250) so */
/* move to a position inside the pre-render area and away from the */
/* pre-render right edge, translateX(-650px), so that we can avoid blurry */
/* edges in comparison with the reference. */
to { transform: translateX(-400px); }
}
#target {
width: 4000px;
height: 4000px;
position: absolute;
transform: translateX(0px);
}
</style>
<div id="target">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4000 4000">
<rect fill="green" x="0" width="1600" height="4000"></rect>
<rect fill="blue" x="1600" width="650" height="4000"></rect>
<rect fill="red" x="2250" width="1750" height="4000"></rect>
</svg>
</div>
<script>
document.addEventListener("MozReftestInvalidate", () => {
target.style.animation = "anim 100s 1s step-start";
target.addEventListener("animationstart", () => {
// animtionstart event is fired just before requestAnimationFrame callbacks,
// so we need to wait two rAF to make sure the initial animation value is
// composited on the compositor.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
document.documentElement.classList.remove("reftest-wait");
});
});
});
}, { once: true });
</script>
</html>

Просмотреть файл

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html class="reftest-wait reftest-no-flush" reftest-resolution="0.5">
<meta name="viewport" content="width=device-width,minimum-scale=0.5,initial-scale=1">
<!--
A variant of partial-prerender-expansion-with-resolution-2.html, a partial
pre-rendered transform animation in an iframe with <1.0 resolution.
-->
<style>
html {
scrollbar-width: none;
}
body {
margin: 0px;
padding: 0px;
}
</style>
<iframe style="width:1600px; height:2000px; border: 0"
srcdoc="<!DOCTYPE HTML>
<html>
<style>
html {
scrollbar-width: none;
}
html, body {
margin: 0;
padding: 0;
}
@keyframes anim {
/* The reftest window size is (800x1000) and it's scaled by */
/* 0.5 (= 1600x2000), which means the partial pre-render */
/* size is (2250x2250) so move to a position inside the */
/* pre-render area and away from the pre-render right edge, */
/* translateX(-650px), so that we can avoid blurry edges in */
/* comparison with the reference. */
to { transform: translateX(-400px); }
}
#target {
width: 4000px;
height: 4000px;
position: absolute;
transform: translateX(0px);
}
</style>
<div id='target'>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4000 4000'>
<rect fill='green' x='0' width='1600' height='4000'></rect>
<rect fill='blue' x='1600' width='650' height='4000'></rect>
<rect fill='red' x='2250' width='1750' height='4000'></rect>
</svg>
</div>
<script>
window.addEventListener('message', () => {
if (event.data == 'start') {
target.style.animation = 'anim 100s 1s step-start';
target.addEventListener('animationstart', () => {
parent.postMessage('animationstart', '*');
});
}
});
</script></html>">
</iframe>
<script>
document.addEventListener("MozReftestInvalidate", () => {
document.querySelector("iframe").contentWindow.postMessage("start", "*");
}, { once: true });
window.addEventListener("message", event => {
if (event.data == "animationstart") {
document.documentElement.classList.remove('reftest-wait');
}
});
</script>
</html>

Просмотреть файл

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html reftest-resolution="0.5">
<meta name="viewport" content="width=device-width,minimum-scale=0.5,initial-scale=1">
<style>
html {
scrollbar-width: none;
}
body {
margin: 0px;
padding: 0px;
}
#target {
width: 4000px;
height: 4000px;
position: absolute;
transform: translateX(-400px);
}
</style>
<div id="target">
<svg xmlns="http://www.w3.org/4000/svg" viewBox="0 0 4000 4000">
<rect fill="green" x="0" width="1600" height="4000"></rect>
<rect fill="blue" x="1600" width="650" height="4000"></rect>
<rect fill="red" x="2250" width="1750" height="4000"></rect>
</svg>
</div>
</html>

Просмотреть файл

@ -173,3 +173,5 @@ test-pref(layout.animation.prerender.partial.jank,true) test-pref(layout.animati
# This reftest heavily depends on layout.animation.prerender.viewport-ratio-limit
# and reftest viewport size (800, 1000).
skip-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)||Android) test-pref(layout.animation.prerender.partial,true) test-pref(layout.animation.prerender.viewport-ratio-limit,"1.125") == partial-prerender-expansion-rotate.html partial-prerender-expansion-ref.html
test-pref(layout.animation.prerender.partial,true) test-pref(layout.animation.prerender.viewport-ratio-limit,"1.125") pref(dom.meta-viewport.enabled,true) pref(apz.allow_zooming,true) == partial-prerender-expansion-with-resolution-1.html partial-prerender-expansion-with-resolution-ref.html
skip-if(webrender) test-pref(layout.animation.prerender.partial,true) test-pref(layout.animation.prerender.viewport-ratio-limit,"1.125") pref(dom.meta-viewport.enabled,true) pref(apz.allow_zooming,true) == partial-prerender-expansion-with-resolution-2.html partial-prerender-expansion-with-resolution-ref.html # bug 1650039 for WebRender