summaryrefslogtreecommitdiffstats
path: root/devtools/server/actors/accessibility/constants.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /devtools/server/actors/accessibility/constants.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/actors/accessibility/constants.js')
-rw-r--r--devtools/server/actors/accessibility/constants.js150
1 files changed, 150 insertions, 0 deletions
diff --git a/devtools/server/actors/accessibility/constants.js b/devtools/server/actors/accessibility/constants.js
new file mode 100644
index 0000000000..0258cf29de
--- /dev/null
+++ b/devtools/server/actors/accessibility/constants.js
@@ -0,0 +1,150 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ accessibility: {
+ SIMULATION_TYPE: {
+ ACHROMATOPSIA,
+ DEUTERANOPIA,
+ PROTANOPIA,
+ TRITANOPIA,
+ CONTRAST_LOSS,
+ },
+ },
+} = require("resource://devtools/shared/constants.js");
+
+/**
+ * Constants used in accessibility actors.
+ */
+
+// Color blindness matrix values taken from Machado et al. (2009), https://doi.org/10.1109/TVCG.2009.113:
+// https://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html
+// Contrast loss matrix values are for 50% contrast (see https://docs.rainmeter.net/tips/colormatrix-guide/,
+// and https://stackoverflow.com/questions/23865511/contrast-with-color-matrix). The matrices are flattened
+// 4x5 matrices, needed for docShell setColorMatrix method. i.e. A 4x5 matrix of the form:
+// 1 2 3 4 5
+// 6 7 8 9 10
+// 11 12 13 14 15
+// 16 17 18 19 20
+// will be need to be set in docShell as:
+// [1, 6, 11, 16, 2, 7, 12, 17, 3, 8, 13, 18, 4, 9, 14, 19, 5, 10, 15, 20]
+const COLOR_TRANSFORMATION_MATRICES = {
+ NONE: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0],
+ [ACHROMATOPSIA]: [
+ 0.299,
+ 0.299,
+ 0.299,
+ 0,
+ 0.587,
+ 0.587,
+ 0.587,
+ 0,
+ 0.114,
+ 0.114,
+ 0.114,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ ],
+ [PROTANOPIA]: [
+ 0.152286,
+ 0.114503,
+ -0.003882,
+ 0,
+ 1.052583,
+ 0.786281,
+ -0.048116,
+ 0,
+ -0.204868,
+ 0.099216,
+ 1.051998,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ ],
+ [DEUTERANOPIA]: [
+ 0.367322,
+ 0.280085,
+ -0.01182,
+ 0,
+ 0.860646,
+ 0.672501,
+ 0.04294,
+ 0,
+ -0.227968,
+ 0.047413,
+ 0.968881,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ ],
+ [TRITANOPIA]: [
+ 1.255528,
+ -0.078411,
+ 0.004733,
+ 0,
+ -0.076749,
+ 0.930809,
+ 0.691367,
+ 0,
+ -0.178779,
+ 0.147602,
+ 0.3039,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ ],
+ [CONTRAST_LOSS]: [
+ 0.5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0.5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0.5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0.5,
+ 0.25,
+ 0.25,
+ 0.25,
+ 0,
+ ],
+};
+
+exports.simulation = {
+ COLOR_TRANSFORMATION_MATRICES,
+};