зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
2eaa5a9634
Коммит
6ef703115e
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
const { Cu, Cc, Ci } = require("chrome");
|
const { Cc, Ci } = require("chrome");
|
||||||
const Services = require("Services");
|
const Services = require("Services");
|
||||||
const { LocalizationHelper } = require("devtools/shared/l10n");
|
const { LocalizationHelper } = require("devtools/shared/l10n");
|
||||||
|
|
||||||
|
@ -26,9 +26,16 @@ const MAX_IMAGE_HEIGHT = 10000;
|
||||||
* The target document.
|
* The target document.
|
||||||
*/
|
*/
|
||||||
function simulateCameraFlash(document) {
|
function simulateCameraFlash(document) {
|
||||||
const window = document.defaultView;
|
const node = document.documentElement;
|
||||||
const frames = Cu.cloneInto({ opacity: [0, 1] }, window);
|
|
||||||
document.documentElement.animate(frames, CONTAINER_FLASHING_DURATION);
|
// 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,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче