Changeset 206581 in webkit
- Timestamp:
- Sep 29, 2016 8:13:00 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206576 r206581 1 2016-09-29 Nan Wang <n_wang@apple.com> 2 3 AX: Meter: [Mac] Content in label element should be used as AXTitle or AXDescription 4 https://bugs.webkit.org/show_bug.cgi?id=162586 5 6 Reviewed by Chris Fleizach. 7 8 * accessibility/mac/aria-label-on-label-element-expected.txt: 9 * accessibility/mac/aria-label-on-label-element.html: 10 * accessibility/mac/meter-with-label-element-expected.txt: Added. 11 * accessibility/mac/meter-with-label-element.html: Added. 12 1 13 2016-09-28 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/accessibility/mac/aria-label-on-label-element-expected.txt
r200318 r206581 1 1 Some text Some other text 2 aria 3 4 labelledby 5 6 Some text 2 7 This tests that the aria-label attribute works on element. 3 8 … … 9 14 PASS titleUIElement2.isEqual(accessibilityController.accessibleElementById('label2')) is true 10 15 PASS input3.title is 'AXTitle: hidden aria label' 16 PASS input4.title is 'AXTitle: aria labelledby' 11 17 PASS successfullyParsed is true 12 18 -
trunk/LayoutTests/accessibility/mac/aria-label-on-label-element.html
r200318 r206581 14 14 <label id="label3" for="input3" hidden aria-label="hidden aria label">hidden text</label> 15 15 <input id="input3" type="text"> 16 17 <p id="p1">aria</p> 18 <p id="p2">labelledby</p> 19 <label for="input4" aria-labelledby="p1 p2">Some text</label> 20 <input id="input4" type="text" size=20> 16 21 17 22 <p id="description"></p> … … 38 43 var input3 = accessibilityController.accessibleElementById("input3"); 39 44 shouldBe("input3.title", "'AXTitle: hidden aria label'"); 45 46 // aria-labelledby also works. 47 var input4 = accessibilityController.accessibleElementById("input4"); 48 shouldBe("input4.title", "'AXTitle: aria labelledby'"); 40 49 } 41 50 -
trunk/Source/WebCore/ChangeLog
r206579 r206581 1 2016-09-29 Nan Wang <n_wang@apple.com> 2 3 AX: Meter: [Mac] Content in label element should be used as AXTitle or AXDescription 4 https://bugs.webkit.org/show_bug.cgi?id=162586 5 6 Reviewed by Chris Fleizach. 7 8 Exposed the label element's text as AXDescription for meter elements. 9 Also refactored the code for fetching the label element's text and taken care of 10 the case where aria-label and aria-labelledby attributes are used on label elements. 11 12 Test: accessibility/mac/meter-with-label-element.html 13 14 * accessibility/AccessibilityNodeObject.cpp: 15 (WebCore::AccessibilityNodeObject::isLabelable): 16 (WebCore::AccessibilityNodeObject::textForLabelElement): 17 (WebCore::AccessibilityNodeObject::titleElementText): 18 (WebCore::AccessibilityNodeObject::title): 19 (WebCore::AccessibilityNodeObject::usesAltTagForTextComputation): Deleted. 20 * accessibility/AccessibilityNodeObject.h: 21 * accessibility/AccessibilityRenderObject.cpp: 22 (WebCore::AccessibilityRenderObject::exposesTitleUIElement): 23 1 24 2016-09-29 Romain Bellessort <romain.bellessort@crf.canon.fr> 2 25 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
r206391 r206581 1231 1231 return isImage() || isInputImage() || isNativeImage() || isCanvas() || (node() && node()->hasTagName(imgTag)); 1232 1232 } 1233 1234 bool AccessibilityNodeObject::isLabelable() const 1235 { 1236 Node* node = this->node(); 1237 if (!node) 1238 return false; 1239 1240 return is<HTMLInputElement>(*node) || AccessibilityObject::isARIAInput(ariaRoleAttribute()) || isControl() || isProgressIndicator() || isMeter(); 1241 } 1242 1243 String AccessibilityNodeObject::textForLabelElement(Element* element) const 1244 { 1245 String result = String(); 1246 if (!is<HTMLLabelElement>(*element)) 1247 return result; 1248 1249 HTMLLabelElement* label = downcast<HTMLLabelElement>(element); 1250 // Check to see if there's aria-labelledby attribute on the label element. 1251 if (AccessibilityObject* labelObject = axObjectCache()->getOrCreate(label)) 1252 result = labelObject->ariaLabeledByAttribute(); 1253 1254 // Then check for aria-label attribute. 1255 if (result.isEmpty()) 1256 result = label->attributeWithoutSynchronization(aria_labelAttr); 1257 1258 return !result.isEmpty() ? result : label->innerText(); 1259 } 1233 1260 1234 1261 void AccessibilityNodeObject::titleElementText(Vector<AccessibilityText>& textOrder) const … … 1238 1265 return; 1239 1266 1240 bool isInputTag = is<HTMLInputElement>(*node); 1241 if (isInputTag || AccessibilityObject::isARIAInput(ariaRoleAttribute()) || isControl() || isProgressIndicator()) { 1267 if (isLabelable()) { 1242 1268 if (HTMLLabelElement* label = labelForElement(downcast<Element>(node))) { 1243 1269 AccessibilityObject* labelObject = axObjectCache()->getOrCreate(label); 1244 String innerText = label->innerText(); 1245 1246 const AtomicString& ariaLabel = label->attributeWithoutSynchronization(aria_labelAttr); 1247 if (!ariaLabel.isEmpty()) 1248 innerText = ariaLabel; 1270 String innerText = textForLabelElement(label); 1249 1271 1250 1272 // Only use the <label> text if there's no ARIA override. 1251 1273 if (!innerText.isEmpty() && !ariaAccessibilityDescription()) 1252 textOrder.append(AccessibilityText(innerText, LabelByElementText, labelObject));1274 textOrder.append(AccessibilityText(innerText, isMeter() ? AlternativeText : LabelByElementText, labelObject)); 1253 1275 return; 1254 1276 } … … 1711 1733 } 1712 1734 1713 if (is InputTag || AccessibilityObject::isARIAInput(ariaRoleAttribute()) || isControl() || isProgressIndicator()) {1735 if (isLabelable()) { 1714 1736 HTMLLabelElement* label = labelForElement(downcast<Element>(node)); 1715 1737 // Use the label text as the title if 1) the title element is NOT an exposed element and 2) there's no ARIA override. 1716 1738 if (label && !exposesTitleUIElement() && !ariaAccessibilityDescription().length()) 1717 return label->innerText();1739 return textForLabelElement(label); 1718 1740 } 1719 1741 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h
r201087 r206581 184 184 // This returns true if it's focusable but it's not content editable and it's not a control or ARIA control. 185 185 bool isGenericFocusableElement() const; 186 bool isLabelable() const; 186 187 HTMLLabelElement* labelForElement(Element*) const; 188 String textForLabelElement(Element*) const; 187 189 String ariaAccessibilityDescription() const; 188 190 void ariaLabeledByElements(Vector<Element*>& elements) const; -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r205865 r206581 1058 1058 return false; 1059 1059 1060 // When <label> element has aria-label o n it, we shouldn't expose it as the titleUIElement,1061 // otherwise its inner text will be announced by a screenreader.1062 if (is <HTMLInputElement>(*this->node()) || AccessibilityObject::isARIAInput(ariaRoleAttribute())) {1060 // When <label> element has aria-label or aria-labelledby on it, we shouldn't expose it as the 1061 // titleUIElement, otherwise its inner text will be announced by a screenreader. 1062 if (isLabelable()) { 1063 1063 if (HTMLLabelElement* label = labelForElement(downcast<Element>(node()))) { 1064 1064 if (!label->attributeWithoutSynchronization(aria_labelAttr).isEmpty()) 1065 1065 return false; 1066 if (AccessibilityObject* labelObject = axObjectCache()->getOrCreate(label)) { 1067 if (!labelObject->ariaLabeledByAttribute().isEmpty()) 1068 return false; 1069 } 1066 1070 } 1067 1071 }
Note: See TracChangeset
for help on using the changeset viewer.