Bug 1689548 - [devtools] Don't simulate flash on screenshot when prefers-reduced-motion is enabled. r=ladybenko.

We also take this opportunity to simplify the simulateCameraFlash function by
using a simpler version of element.animate.

Differential Revision: https://phabricator.services.mozilla.com/D103457
This commit is contained in:
Nicolas Chevobbe 2021-01-29 15:05:05 +00:00
Родитель 2eaa5a9634
Коммит 6ef703115e
1 изменённых файлов: 11 добавлений и 4 удалений

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

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { Cu, Cc, Ci } = require("chrome");
const { Cc, Ci } = require("chrome");
const Services = require("Services");
const { LocalizationHelper } = require("devtools/shared/l10n");
@ -26,9 +26,16 @@ const MAX_IMAGE_HEIGHT = 10000;
* The target document.
*/
function simulateCameraFlash(document) {
const window = document.defaultView;
const frames = Cu.cloneInto({ opacity: [0, 1] }, window);
document.documentElement.animate(frames, CONTAINER_FLASHING_DURATION);
const node = document.documentElement;
// Don't take a screenshot if the user prefers reduced motion.
if (node.ownerGlobal.matchMedia("(prefers-reduced-motion)").matches) {
return;
}
node.animate([{ opacity: 0 }, { opacity: 1 }], {
duration: CONTAINER_FLASHING_DURATION,
});
}
/**