MDL-59817 atto_accessibilitychecker: Handle transparency properly
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 7 Jan 2020 09:28:10 +0000 (17:28 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 10 Jan 2020 07:26:51 +0000 (15:26 +0800)
commit43aa3cbe447cd367c2e1651d4debf2064bc0fa4c
tree1416296532ad133ad4d6b71210979a4d2ddcf37c
parent77d1c415025f99f1c36dae67aac7af11b8a34b50
MDL-59817 atto_accessibilitychecker: Handle transparency properly

Some browsers, notably Firefox, do not return the computed style for
background colour in a computed RGB format. Instead they return the RGBA
where the alpha channel is set to fully transparent.

To solve this we need to work up the hierarchy and compute the
background colour for each parent node until we reach full alpha (1).

We can use a standard calculation to approximate the value for the
resultant element background by multiplying the alpha of the current
transparent (or semi-transparent) node with the R, G, or B channel in
question, and that of the parent node's background colour.

There are cases where this will not be 100% accurate - notably where
there is some additional content in addition to the parent background,
but this gives us a reasoable approximation for the majority of cases.
Additionally the code has never considered the full set of node content
when calculating this information.
lib/editor/atto/plugins/accessibilitychecker/yui/build/moodle-atto_accessibilitychecker-button/moodle-atto_accessibilitychecker-button-debug.js
lib/editor/atto/plugins/accessibilitychecker/yui/build/moodle-atto_accessibilitychecker-button/moodle-atto_accessibilitychecker-button-min.js
lib/editor/atto/plugins/accessibilitychecker/yui/build/moodle-atto_accessibilitychecker-button/moodle-atto_accessibilitychecker-button.js
lib/editor/atto/plugins/accessibilitychecker/yui/src/button/js/button.js