AX: Form label text should be exposed as static text if it contains only static text
authord_russell@apple.com <d_russell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jun 2016 21:28:37 +0000 (21:28 +0000)
committerd_russell@apple.com <d_russell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jun 2016 21:28:37 +0000 (21:28 +0000)
commit2eb7c7e30d5d58127e364525de0e2c1f7d891042
treea518a366166c9e198b63da8ef6934a91d9aa6824
parentfc4575f259174aaf283c4cdbda25c25ad34c704f
AX: Form label text should be exposed as static text if it contains only static text
https://bugs.webkit.org/show_bug.cgi?id=158634

Reviewed by Chris Fleizach.

Use AccessibilityLabel to represent HTMLLabelElement to assistive technology.
AccessibilityLabel::containsOnlyStaticText() searches label subtree to evaluate
if all children are static text.
AccessibilityLabel::stringValue() consults containsOnlyStaticText() and returns
textUnderElement() if true.
WebAccessibilityObjectWrapperMac consults containsOnlyStaticText() and substitutes
StaticTextRole for LabelRole if true.
Cache containsOnlyStaticText() in the common case when updating children.

Source/WebCore:

Tests: accessibility/mac/label-element-all-text-string-value.html
       accessibility/mac/label-element-with-link-string-value.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* accessibility/AXObjectCache.cpp:
(WebCore::createFromRenderer):
* accessibility/AccessibilityAllInOne.cpp:
* accessibility/AccessibilityLabel.cpp: Added.
(WebCore::AccessibilityLabel::AccessibilityLabel):
(WebCore::AccessibilityLabel::~AccessibilityLabel):
(WebCore::AccessibilityLabel::create):
(WebCore::AccessibilityLabel::computeAccessibilityIsIgnored):
(WebCore::AccessibilityLabel::stringValue):
(WebCore::childrenContainOnlyStaticText):
(WebCore::AccessibilityLabel::containsOnlyStaticText):
(WebCore::AccessibilityLabel::updateChildrenIfNecessary):
(WebCore::AccessibilityLabel::clearChildren):
(WebCore::AccessibilityLabel::insertChild):
* accessibility/AccessibilityLabel.h: Added.
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::isLabel):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper role]):

LayoutTests:

* accessibility/aria-labelledby-overrides-label-expected.txt:
* accessibility/mac/label-element-all-text-string-value-expected.txt: Added.
* accessibility/mac/label-element-all-text-string-value.html: Added.
* accessibility/mac/label-element-with-hidden-control-expected.txt:
* accessibility/mac/label-element-with-hidden-control.html:
* accessibility/mac/label-element-with-link-string-value-expected.txt: Added.
* accessibility/mac/label-element-with-link-string-value.html: Added.
* accessibility/mac/slider-allows-title-ui-element-expected.txt:
* accessibility/mac/slider-allows-title-ui-element.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202063 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/aria-labelledby-overrides-label-expected.txt
LayoutTests/accessibility/mac/label-element-all-text-string-value-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/label-element-all-text-string-value.html [new file with mode: 0644]
LayoutTests/accessibility/mac/label-element-changing-children-string-value-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/label-element-changing-children-string-value.html [new file with mode: 0644]
LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value.html [new file with mode: 0644]
LayoutTests/accessibility/mac/label-element-with-hidden-control-expected.txt
LayoutTests/accessibility/mac/label-element-with-hidden-control.html
LayoutTests/accessibility/mac/label-element-with-link-string-value-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/label-element-with-link-string-value.html [new file with mode: 0644]
LayoutTests/accessibility/mac/slider-allows-title-ui-element-expected.txt
LayoutTests/accessibility/mac/slider-allows-title-ui-element.html
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityAllInOne.cpp
Source/WebCore/accessibility/AccessibilityLabel.cpp [new file with mode: 0644]
Source/WebCore/accessibility/AccessibilityLabel.h [new file with mode: 0644]
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm