Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(engine): fix color contrast for text with graphic background and update role and attribute allowances for body/search/button/input/summary/li elements per ARIA in HTML updates #1432

Merged
merged 38 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7f43ca8
update the color logic #1202
shunguoy Apr 6, 2023
23792e7
add additional message to the color contrast rule #1202
shunguoy Apr 11, 2023
bbb8233
merge two color contrast rules and update test cases #1202
shunguoy Apr 11, 2023
3668b74
update color contrast rule #1202
shunguoy Apr 12, 2023
1abe939
update color contrast rule to fix graphic background issue #1202
shunguoy Apr 14, 2023
c30396a
update the rule for special characters #1202
shunguoy Apr 18, 2023
6f1651e
update color contrast rule for special characters #1202
shunguoy Apr 18, 2023
3e832c5
add potential violation for text shadow #1202
shunguoy Apr 18, 2023
f8af3fa
Merge branch 'master' into dev-1202
shunguoy Apr 19, 2023
bd64483
update the baselines #1202
shunguoy Apr 19, 2023
68c5b8e
update rule and test case #1336
shunguoy Apr 20, 2023
602a5ad
add search element support #1336
shunguoy Apr 20, 2023
7d5fe1b
Merge branch 'master' into dev-1336
shunguoy Apr 21, 2023
9ba2144
test cases #1301
shunguoy Apr 24, 2023
845c562
create test cases #1301
shunguoy Apr 26, 2023
7a28084
Merge branch 'master' into dev-1202
ErickRenteria Apr 28, 2023
48759a9
Merge branch 'master' into dev-1336
shunguoy Apr 28, 2023
2e093cf
Merge branch 'master' into dev-1301
shunguoy Apr 28, 2023
476bf68
update role support #1301
shunguoy Apr 28, 2023
73ded94
update test results #1301
shunguoy May 1, 2023
502033f
add test cases for li and update rule logic #1301
shunguoy May 1, 2023
f4bc86f
update aria definition #1304
shunguoy May 4, 2023
332dcff
test cases and test results #1304
shunguoy May 5, 2023
80192f4
Merge branch 'master' into dev-1202
tombrunet May 10, 2023
710ba30
Fix rules in test cases
tombrunet May 10, 2023
cef6c8b
Merge branch 'master' into dev-1336
tombrunet May 10, 2023
affb46a
Merge branch 'master' into dev-1301
tombrunet May 10, 2023
3daecbe
Merge branch 'master' into dev-1304
tombrunet May 10, 2023
4a66b6e
Merge pull request #1442 from IBMa/dev-1336
shunguoy May 11, 2023
0ee725c
Merge pull request #1441 from IBMa/dev-1301
shunguoy May 11, 2023
bc7a65a
Merge pull request #1443 from IBMa/dev-1202
shunguoy May 11, 2023
69e81cb
Merge branch 'master' into dev-1304
shunguoy May 11, 2023
0aa61e1
update test results #1304
shunguoy May 11, 2023
028b405
update test cases #1304
shunguoy May 11, 2023
db0d038
update test cases #1304
shunguoy May 11, 2023
af9628e
update the baselines #1304
shunguoy May 12, 2023
d3a6486
remove obsolete test cases #1304
shunguoy May 12, 2023
554c3d0
Merge branch 'master' into dev-1304
ErickRenteria May 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ jspm_packages
.gz
.tar
accessibility-checker-engine/karma.conf.js
karma-accessibility-checker/package.json
51 changes: 36 additions & 15 deletions accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,7 @@ export class ARIADefinitions {
"body": {
implicitRole: ["generic"],
validRoles: null,
otherDisallowedAriaAttributes: ['aria-hidden'],
globalAriaAttributesValid: true
},
"br": {
Expand All @@ -1720,7 +1721,7 @@ export class ARIADefinitions {
},
"button": {
implicitRole: ["button"],
validRoles: ["checkbox", "combobox", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch", "tab"],
validRoles: ["checkbox", "combobox", "gridcell", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "slider", "switch", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"canvas": {
Expand Down Expand Up @@ -1906,11 +1907,6 @@ export class ARIADefinitions {
validRoles: null,
globalAriaAttributesValid: true
},
"li": {
implicitRole: ["listitem"],
validRoles: ["menuitem", "menuitemcheckbox", "menuitemradio", "none", "option", "presentation", "radio", "separator", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"link": {
implicitRole: null,
validRoles: null,
Expand Down Expand Up @@ -2051,6 +2047,11 @@ export class ARIADefinitions {
validRoles: null,
globalAriaAttributesValid: false
},
"search": {
implicitRole: ['search'],
validRoles: ['search', 'form', 'group', 'none', 'presentation', 'region'],
globalAriaAttributesValid: true
},
"slot": {
implicitRole: null,
validRoles: null,
Expand Down Expand Up @@ -2086,11 +2087,6 @@ export class ARIADefinitions {
validRoles: ["any"],
globalAriaAttributesValid: true
},
"summary": {
implicitRole: ["button"],
validRoles: null,
globalAriaAttributesValid: true
},
"sup": {
implicitRole: ["superscript"],
validRoles: ["any"],
Expand Down Expand Up @@ -2294,7 +2290,7 @@ export class ARIADefinitions {
"input": {
"button": {
implicitRole: ["button"],
validRoles: ["checkbox", "combobox", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch", "tab"],
validRoles: ["checkbox", "combobox", "gridcell", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "slider", "switch", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"checkbox-with-aria-pressed": {
Expand Down Expand Up @@ -2358,7 +2354,7 @@ export class ARIADefinitions {
},
"image": {
implicitRole: ["button"],
validRoles: ["link", "menuitem", "menuitemcheckbox", "menuitemradio", "radio", "switch"],
validRoles: ["checkbox", "gridcell", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "slider", "switch", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"month": {
Expand Down Expand Up @@ -2396,7 +2392,7 @@ export class ARIADefinitions {
},
"reset": {
implicitRole: ["button"],
validRoles: null,
validRoles: ["checkbox", "combobox", "gridcell", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "slider", "switch", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"search-no-list": {
Expand All @@ -2412,7 +2408,7 @@ export class ARIADefinitions {
},
"submit": {
implicitRole: ["button"],
validRoles: null,
validRoles: ["checkbox", "combobox", "gridcell", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "slider", "switch", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"tel-no-list": {
Expand Down Expand Up @@ -2476,6 +2472,18 @@ export class ARIADefinitions {
globalAriaAttributesValid: true
}
},
"li": {
"child-of-list-role": {
implicitRole: ['listitem'],
validRoles: null,
globalAriaAttributesValid: true
},
"no-child-of-list-role": {
implicitRole: ['listitem'],
validRoles: ["any"],
globalAriaAttributesValid: true
}
},
"section": {
"with-name": {
implicitRole: ["region"],
Expand Down Expand Up @@ -2504,6 +2512,19 @@ export class ARIADefinitions {
otherDisallowedAriaAttributes: ["aria-multiselectable"]
}
},
"summary": {
"first-summary-of-detail": {
implicitRole: null,
validRoles: null,
globalAriaAttributesValid: true,
otherAllowedAriaAttributes: ["aria-disabled", "aria-haspopup"]
},
"no-first-summary-of-detail": {
implicitRole: null,
validRoles: ["any"],
globalAriaAttributesValid: true
}
},
"tbody": {
"des-table": {
implicitRole: ["rowgroup"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { DOMWalker } from "../../../dom/DOMWalker";
import { VisUtil } from "../../../dom/VisUtil";
import { FragmentUtil } from "./fragment";
import { getDefinedStyles } from "../../../../v4/util/CSSUtil";
import { DOMUtil } from "../../../dom/DOMUtil";

export class RPTUtil {

Expand Down Expand Up @@ -376,7 +377,15 @@ export class RPTUtil {
"video": function (element) {
return element.hasAttribute("controls");
},
"summary": true
"summary": function (element) {
// first summary child of a details element is automatically focusable
return element.parentElement && element.parentElement.nodeName.toLowerCase() === 'details'
&& DOMUtil.sameNode([...element.parentElement.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary')[0], element);
},
"details": function (element) {
//details element without a direct summary child is automatically focusable
return element.children && [...element.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary').length === 0;
}
}

public static wordCount(str) : number {
Expand Down Expand Up @@ -2543,14 +2552,21 @@ export class RPTUtil {
RPTUtil.attributeNonEmpty(ruleContext, "list") ? tagProperty = specialTagProperties["text-with-list"] : tagProperty = specialTagProperties["text-no-list"];
}
break;
case "li":
specialTagProperties = ARIADefinitions.documentConformanceRequirementSpecialTags["li"];
if (ruleContext.parentElement && RPTUtil.hasRoleInSemantics(ruleContext.parentElement, "list"))
tagProperty = specialTagProperties["child-of-list-role"];
else
tagProperty = specialTagProperties["no-child-of-list-role"];
break;
case "section":
name = ARIAMapper.computeName(ruleContext);
if (name && name.trim().length > 0) {
tagProperty = specialTagProperties["with-name"];
} else {
tagProperty = specialTagProperties["without-name"];
}
break;
break;
case "select":
specialTagProperties = ARIADefinitions.documentConformanceRequirementSpecialTags["select"];
if (ruleContext.hasAttribute("multiple") ||
Expand All @@ -2559,6 +2575,14 @@ export class RPTUtil {
else
tagProperty = specialTagProperties["no-multiple-attr-size-gt1"];
break;
case "summary":
specialTagProperties = ARIADefinitions.documentConformanceRequirementSpecialTags["summary"];
if (ruleContext.parentElement && ruleContext.parentElement.nodeName.toLowerCase() === 'details'
&& DOMUtil.sameNode([...ruleContext.parentElement.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary')[0], ruleContext))
tagProperty = specialTagProperties["first-summary-of-detail"];
else
tagProperty = specialTagProperties["no-first-summary-of-detail"];
break;
case "tbody":
case "td":
case "tr":
Expand Down
23 changes: 17 additions & 6 deletions accessibility-checker-engine/src/v2/dom/ColorUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export class ColorUtil {
var retVal = {
"hasGradient": false,
"hasBGImage": false,
"textShadow": false,
"fg": null,
"bg": null
};
Expand Down Expand Up @@ -267,7 +268,7 @@ export class ColorUtil {
overallWorst = worstColor;
}
}
return overallWorst;
return overallWorst; // return the darkest color
} catch (e) {
console.log(e);
}
Expand All @@ -285,7 +286,7 @@ export class ColorUtil {
// cStyle is the computed style of this layer
var cStyle = win.getComputedStyle(procNext);
if (cStyle === null) continue;

// thisBgColor is the color of this layer or null if the layer is transparent
var thisBgColor = null;
if (cStyle.backgroundColor && cStyle.backgroundColor != "transparent" && cStyle.backgroundColor != "rgba(0, 0, 0, 0)") {
Expand All @@ -300,13 +301,19 @@ export class ColorUtil {
if (!gradColors[i].length) {
gradColors.splice(i--, 1);
} else {
gradColorComp.push(ColorUtil.Color(gradColors[i]));
let colorComp = ColorUtil.Color(gradColors[i]);
if (colorComp.alpha !== undefined && colorComp.alpha < 1) {
// mix the grdient bg color wit parent bg if alpha < 1
let compStackBg = thisStackBG || priorStackBG;
colorComp = colorComp.getOverlayColor(compStackBg);
}
gradColorComp.push(colorComp);
}
}
thisBgColor = guessGradColor(gradColorComp, thisStackBG || priorStackBG, fg);
}
}

// Handle non-solid opacity
if (thisStackOpacity === null || (cStyle.opacity && cStyle.opacity.length > 0 && parseFloat(cStyle.opacity) < 1)) {
// New stack, reset
Expand Down Expand Up @@ -370,6 +377,10 @@ export class ColorUtil {
}
retVal.fg = fg;
retVal.bg = priorStackBG;

if (cStyle.textShadow && cStyle.textShadow !== 'none')
retVal.textShadow = true;

return retVal;
} catch (err) {
// something happened, then...
Expand Down Expand Up @@ -413,10 +424,10 @@ export class ColorObj {

contrastRatio(bgColor : ColorObj) {
let fgColor: ColorObj = this;

if (typeof (this.alpha) != "undefined")
fgColor = this.getOverlayColor(bgColor);

let lum1 = fgColor.relativeLuminance();
if (!bgColor.relativeLuminance) {
let s = "";
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion accessibility-checker-engine/src/v4/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export * from "./heading_content_exists"
export * from "./heading_markup_misuse"
export * from "./html_lang_exists"
export * from "./html_skipnav_exists"
export * from "./IBMA_Color_Contrast_WCAG2AA_PV"
export * from "./iframe_interactive_tabbable"
export * from "./imagebutton_alt_exists"
export * from "./imagemap_alt_exists"
Expand Down
Loading