Bug 1443358 - Consider that the target frame is scrolled out if scrollable parent frame size is empty. r=birtles

This patch adds three test cases;

1) Animation on position:absolute element in a zero-height iframe
  This animation should be throttled.
2) Animation on a non-zero width and hight position:absolute element but whose
   parent has a zero height
  This animation should NOT be throttled since the animation is visible
3) Animation on a zero-height position:absolute element whose parent also has
   zero height.
  This animation should be throttled since the animation is invisible

The first test fails without this fix and passes with the fix.
The second one passes regardless of the fix
The third one is marked as 'todo' since it doesn't pass with this fix.

MozReview-Commit-ID: 8pNUFQ71ivj

--HG--
extra : rebase_source : d1d37e5324247efc20a39d86a0f8849450cc7533
This commit is contained in:
Hiroyuki Ikezoe 2018-04-02 13:34:14 +09:00
Родитель 4de76df942
Коммит 2b9a5049f3
2 изменённых файлов: 79 добавлений и 2 удалений

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

@ -1645,6 +1645,78 @@ waitForAllPaints(() => {
}
);
add_task(
async function throttling_position_absolute_animations_in_collapsed_iframe() {
var iframe = document.createElement('iframe');
iframe.setAttribute('srcdoc', '<div id="target"></div>');
iframe.style.height = '0px';
document.documentElement.appendChild(iframe);
await new Promise(resolve => {
iframe.addEventListener('load', () => {
resolve();
});
});
const target = iframe.contentDocument.getElementById("target");
target.style= 'position: absolute; top: 50%; width: 100px; height: 100px';
var animation = target.animate({ opacity: [0, 1] },
{ duration: 100 * MS_PER_SEC,
iterations: Infinity });
await animation.ready;
var markers = await observeStylingInTargetWindow(iframe.contentWindow, 5);
is(markers.length, 0,
'Animation on position:absolute element in collapsed iframe should ' +
'be throttled');
await ensureElementRemoval(iframe);
}
);
add_task(
async function position_absolute_animations_in_collapsed_element() {
var parent = addDiv(null, { style: 'overflow: scroll; height: 0px;' });
var target = addDiv(null,
{ style: 'animation: background-color 100s infinite;' +
'position: absolute; top: 50%;' +
'width: 100px; height: 100px;' });
parent.appendChild(target);
var animation = target.getAnimations()[0];
await animation.ready;
const expectedRestyleCount = tweakExpectedRestyleCount(animation, 5);
var markers = await observeStyling(5);
is(markers.length, expectedRestyleCount,
'Animation on position:absolute element in collapsed element ' +
'should not be throttled');
await ensureElementRemoval(parent);
}
);
add_task(
async function throttling_position_absolute_animations_in_collapsed_element() {
var parent = addDiv(null, { style: 'overflow: scroll; height: 0px;' });
var target = addDiv(null,
{ style: 'animation: background-color 100s infinite;' +
'position: absolute; top: 50%;' });
parent.appendChild(target);
var animation = target.getAnimations()[0];
await animation.ready;
var markers = await observeStyling(5);
todo_is(markers.length, 0,
'Animation on collapsed position:absolute element in collapsed ' +
'element should be throttled');
await ensureElementRemoval(parent);
}
);
add_task_if_omta_enabled(
async function no_restyling_for_compositor_animation_on_unrelated_style_change() {
var div = addDiv(null);

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

@ -11034,14 +11034,19 @@ IsFrameScrolledOutOfView(nsIFrame* aTarget,
}
nsIFrame *scrollableParent = do_QueryFrame(scrollableFrame);
nsRect scrollableRect =
scrollableParent->GetVisualOverflowRectRelativeToSelf();
// We consider that the target is scrolled out if the scrollable frame is
// empty.
if (scrollableRect.IsEmpty()) {
return true;
}
nsRect transformedRect =
nsLayoutUtils::TransformFrameRectToAncestor(aTarget,
aTargetRect,
scrollableParent);
nsRect scrollableRect =
scrollableParent->GetVisualOverflowRectRelativeToSelf();
if (transformedRect.IsEmpty()) {
// If the transformed rect is empty it represents a line or a point that we
// should check is outside the the scrollable rect.