diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index f43025978225..4fb4afd9af1d 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,14 @@ +2017-09-12 Chris Fleizach + + AX: On generic container elements, WebKit should distinguish between tooltip (e.g. @title) and label (e.g. @aria-label) attributes + https://bugs.webkit.org/show_bug.cgi?id=170475 + + + Reviewed by Joanmarie Diggs. + + * accessibility/title-tag-on-unimportant-elements-is-help-text-expected.txt: Added. + * accessibility/title-tag-on-unimportant-elements-is-help-text.html: Added. + 2017-09-11 Joanmarie Diggs AX: [ATK] aria-autocomplete not exposed on comboboxes diff --git a/LayoutTests/accessibility/title-tag-on-unimportant-elements-is-help-text-expected.txt b/LayoutTests/accessibility/title-tag-on-unimportant-elements-is-help-text-expected.txt new file mode 100644 index 000000000000..1c30f33865f9 --- /dev/null +++ b/LayoutTests/accessibility/title-tag-on-unimportant-elements-is-help-text-expected.txt @@ -0,0 +1,18 @@ +a +a + +This tests that if a semantically unimportant element has title text, that text is exposed as help text rather than descriptive text. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS platformValueForW3CDescription(accessibilityController.accessibleElementById('div1')) is 'test1' +PASS platformValueForW3CName(accessibilityController.accessibleElementById('div1')) is '' +PASS platformValueForW3CDescription(accessibilityController.accessibleElementById('div2')) is '' +PASS platformValueForW3CName(accessibilityController.accessibleElementById('div2')) is 'test2' +PASS platformValueForW3CDescription(accessibilityController.accessibleElementById('button1')) is '' +PASS platformValueForW3CName(accessibilityController.accessibleElementById('button1')) is 'test5' +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/accessibility/title-tag-on-unimportant-elements-is-help-text.html b/LayoutTests/accessibility/title-tag-on-unimportant-elements-is-help-text.html new file mode 100644 index 000000000000..40cf9556411c --- /dev/null +++ b/LayoutTests/accessibility/title-tag-on-unimportant-elements-is-help-text.html @@ -0,0 +1,40 @@ + + + + + + + + +
a
+
a
+ + + +

+
+ + + + + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 47b9c8bbe975..d6d121c89c34 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2017-09-12 Chris Fleizach + + AX: On generic container elements, WebKit should distinguish between tooltip (e.g. @title) and label (e.g. @aria-label) attributes + https://bugs.webkit.org/show_bug.cgi?id=170475 + + + Reviewed by Joanmarie Diggs. + + Test: accessibility/title-tag-on-unimportant-elements-is-help-text.html + + * accessibility/AccessibilityNodeObject.cpp: + (WebCore::AccessibilityNodeObject::helpText): + (WebCore::AccessibilityNodeObject::accessibilityDescription): + (WebCore::AccessibilityNodeObject::roleIgnoresTitle): + * accessibility/AccessibilityNodeObject.h: + 2017-09-12 Antti Koivisto Remove RenderElement::isCSSAnimating boolean diff --git a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp b/Source/WebCore/accessibility/AccessibilityNodeObject.cpp index b28f646441f7..696e18dd6a65 100644 --- a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp +++ b/Source/WebCore/accessibility/AccessibilityNodeObject.cpp @@ -1452,7 +1452,7 @@ void AccessibilityNodeObject::helpText(Vector& textOrder) con // type to HelpText. const AtomicString& title = getAttribute(titleAttr); if (!title.isEmpty()) { - if (!isMeter()) + if (!isMeter() && !roleIgnoresTitle()) textOrder.append(AccessibilityText(title, TitleTagText)); else textOrder.append(AccessibilityText(title, HelpText)); @@ -1557,12 +1557,29 @@ String AccessibilityNodeObject::accessibilityDescription() const // Both are used to generate what a screen reader speaks. // If this point is reached (i.e. there's no accessibilityDescription) and there's no title(), we should fallback to using the title attribute. // The title attribute is normally used as help text (because it is a tooltip), but if there is nothing else available, this should be used (according to ARIA). - if (title().isEmpty()) + // https://bugs.webkit.org/show_bug.cgi?id=170475: An exception is when the element is semantically unimportant. In those cases, title text should remain as help text. + if (title().isEmpty() && !roleIgnoresTitle()) return getAttribute(titleAttr); return String(); } +// Returns whether the role was not intended to play a semantically meaningful part of the +// accessibility hierarchy. This applies to generic groups like
's with no role value set. +bool AccessibilityNodeObject::roleIgnoresTitle() const +{ + if (ariaRoleAttribute() != UnknownRole) + return false; + + switch (roleValue()) { + case DivRole: + case UnknownRole: + return true; + default: + return false; + } +} + String AccessibilityNodeObject::helpText() const { Node* node = this->node(); diff --git a/Source/WebCore/accessibility/AccessibilityNodeObject.h b/Source/WebCore/accessibility/AccessibilityNodeObject.h index 2a9b04f0bfdb..ad636864190f 100644 --- a/Source/WebCore/accessibility/AccessibilityNodeObject.h +++ b/Source/WebCore/accessibility/AccessibilityNodeObject.h @@ -189,7 +189,8 @@ class AccessibilityNodeObject : public AccessibilityObject { void ariaLabeledByText(Vector&) const; bool computeAccessibilityIsIgnored() const override; bool usesAltTagForTextComputation() const; - + bool roleIgnoresTitle() const; + Node* m_node; };