diff --git a/admin/tool/brickfield/classes/local/htmlchecker/common/brickfield_accessibility_color_test.php b/admin/tool/brickfield/classes/local/htmlchecker/common/brickfield_accessibility_color_test.php index 319864cb87f8..f93e43e2abc8 100644 --- a/admin/tool/brickfield/classes/local/htmlchecker/common/brickfield_accessibility_color_test.php +++ b/admin/tool/brickfield/classes/local/htmlchecker/common/brickfield_accessibility_color_test.php @@ -245,7 +245,6 @@ public function luminosity(string $r, string $r2, string $g, string $g2, string return $luminosity; } - /** * Returns the decimal equivalents for a HEX color. Returns null if it cannot be determined. * @param string $color The hex color value @@ -304,9 +303,20 @@ public function convert_color(string $color): string { } // RGB values. if (strtolower(substr($color, 0, 3)) == 'rgb') { - $colors = explode(',', trim(str_replace('rgb(', '', $color), '()')); - if (count($colors) != 3) { - return false; + if (strpos($color, 'rgba') !== false) { + $tmpbg = $this->get_rgb($this->defaultbackground); + $colors = explode(',', trim(str_replace('rgba(', '', $color), '()')); + if (count($colors) != 4) { + return false; + } + $colors[0] = round(((1 - $colors[3]) * $tmpbg['r']) + ($colors[3] * $colors[0])); + $colors[1] = round((1 - $colors[3]) * $tmpbg['g']) + ($colors[3] * $colors[1]); + $colors[2] = round((1 - $colors[3]) * $tmpbg['b']) + ($colors[3] * $colors[2]); + } else { + $colors = explode(',', trim(str_replace('rgb(', '', $color), '()')); + if (count($colors) != 3) { + return false; + } } $r = intval($colors[0]); $g = intval($colors[1]); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php index 046483b12ba5..b03ad43def43 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php @@ -348,7 +348,7 @@ public function test_check_for_largerbold_pass(): void { $this->assertEmpty($results); } - /** + /** * Test for rgb colors with insufficient contrast. */ public function test_bad_rgbcolor() { @@ -449,12 +449,12 @@ public function test_bad_backgroundcssrgba() { } /** - * Test for background value with rgb with sufficient contrast. + * Test for background value with rgba with sufficient contrast. */ public function test_good_backgroundcssrgba() { - $html = '

+ $html = '

This is contrasty enough.

'; $results = $this->get_checker_results($html); $this->assertEmpty($results); } -} \ No newline at end of file +}