Title: [202063] trunk
Revision
202063
Author
[email protected]
Date
2016-06-14 14:28:37 -0700 (Tue, 14 Jun 2016)

Log Message

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:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202062 => 202063)


--- trunk/LayoutTests/ChangeLog	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/LayoutTests/ChangeLog	2016-06-14 21:28:37 UTC (rev 202063)
@@ -1,3 +1,29 @@
+2016-06-14  Doug Russell  <[email protected]>
+
+        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.
+
+        * 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:
+
 2016-06-14  Ryan Haddad  <[email protected]>
 
         Increase timeouts for userscripts/window-onerror-for-isolated-world-3.html to fix flakiness.

Modified: trunk/LayoutTests/accessibility/aria-labelledby-overrides-label-expected.txt (202062 => 202063)


--- trunk/LayoutTests/accessibility/aria-labelledby-overrides-label-expected.txt	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/LayoutTests/accessibility/aria-labelledby-overrides-label-expected.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -5,7 +5,7 @@
 
 PASS platformValueForW3CName(text) is "Shut down computer after 10 minutes"
 PASS text.titleUIElement() != null && text.titleUIElement().isValid is false
-Label element role is: AXRole: AXGroup
+Label element role is: AXRole: AXStaticText
 PASS successfullyParsed is true
 
 TEST COMPLETE

Added: trunk/LayoutTests/accessibility/mac/label-element-all-text-string-value-expected.txt (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-all-text-string-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-all-text-string-value-expected.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,12 @@
+ first choice
+This tests that if a label element contains text children it's AXValue will be their concatenated AXValues.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS label.role is 'AXRole: AXStaticText'
+PASS label.stringValue is 'AXValue: first choice'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/label-element-all-text-string-value.html (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-all-text-string-value.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-all-text-string-value.html	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<input type="radio" id="input" />
+<label for="" id="label">
+    <span>first</span>
+    <span>choice</span>
+</label>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    var label = 0;
+
+    description("This tests that if a label element contains text children it's AXValue will be their concatenated AXValues.");
+    if (window.accessibilityController) {
+
+        if (window.accessibilityController) {
+
+            var body = document.getElementById("body");
+            body.focus();
+            
+            label = accessibilityController.accessibleElementById("label");
+            shouldBe("label.role", "'AXRole: AXStaticText'");
+            shouldBe("label.stringValue", "'AXValue: first choice'");          
+        }
+    }
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/accessibility/mac/label-element-changing-children-string-value-expected.txt (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-changing-children-string-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-changing-children-string-value-expected.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,13 @@
+ firstfoo choice
+This tests that if a label element's children change, the string value updates
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS label.role is 'AXRole: AXStaticText'
+PASS initialStringValue is 'AXValue: first choice'
+PASS mutatedStringValue is 'AXValue: first foo choice'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/label-element-changing-children-string-value.html (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-changing-children-string-value.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-changing-children-string-value.html	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<input type="radio" id="input" />
+<label for="" id="label">
+    <span id="first">first</span>
+    <span>choice</span>
+</label>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    var label = 0;
+    var initialStringValue = 0;
+    var mutatedStringValue = 0;
+
+    description("This tests that if a label element's children change, the string value updates");
+    if (window.accessibilityController) {
+
+        if (window.accessibilityController) {
+
+            var body = document.getElementById("body");
+            body.focus();
+            
+            label = accessibilityController.accessibleElementById("label");
+            initialStringValue = label.stringValue;
+            var first = document.getElementById("first")
+            var element = document.createElement("span");
+            var foo = document.createTextNode("foo");
+            element.appendChild(foo);
+            first.appendChild(foo);
+            mutatedStringValue = label.stringValue;
+
+            shouldBe("label.role", "'AXRole: AXStaticText'");
+            shouldBe("initialStringValue", "'AXValue: first choice'");
+            shouldBe("mutatedStringValue", "'AXValue: first foo choice'");
+        }
+    }
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value-expected.txt (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value-expected.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,13 @@
+ second choice
+This tests that if a label element's children's textContent changes, the string value updates
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS label.role is 'AXRole: AXStaticText'
+PASS initialStringValue is 'AXValue: first choice'
+PASS mutatedStringValue is 'AXValue: second choice'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value.html (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-changing-textcontent-string-value.html	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<input type="radio" id="input" />
+<label for="" id="label">
+    <span id="first">first</span>
+    <span>choice</span>
+</label>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    var label = 0;
+    var initialStringValue = 0;
+    var mutatedStringValue = 0;
+
+    description("This tests that if a label element's children's textContent changes, the string value updates");
+    if (window.accessibilityController) {
+
+        if (window.accessibilityController) {
+
+            var body = document.getElementById("body");
+            body.focus();
+            
+            label = accessibilityController.accessibleElementById("label");
+            initialStringValue = label.stringValue;
+            var first = document.getElementById("first")
+            first.textContent = "second";
+            mutatedStringValue = label.stringValue;
+
+            shouldBe("label.role", "'AXRole: AXStaticText'");
+            shouldBe("initialStringValue", "'AXValue: first choice'");
+            shouldBe("mutatedStringValue", "'AXValue: second choice'");
+        }
+    }
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/accessibility/mac/label-element-with-hidden-control-expected.txt (202062 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-with-hidden-control-expected.txt	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/LayoutTests/accessibility/mac/label-element-with-hidden-control-expected.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -4,7 +4,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS container.childAtIndex('0').role is 'AXRole: AXGroup'
+PASS container.childAtIndex('0').role is 'AXRole: AXStaticText'
 PASS container.childAtIndex('0').childAtIndex(0).role is 'AXRole: AXStaticText'
 PASS container.childAtIndex('0').childAtIndex(0).stringValue is 'AXValue: Test label1'
 PASS container.childAtIndex('2').role is 'AXRole: AXCheckBox'

Modified: trunk/LayoutTests/accessibility/mac/label-element-with-hidden-control.html (202062 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-with-hidden-control.html	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/LayoutTests/accessibility/mac/label-element-with-hidden-control.html	2016-06-14 21:28:37 UTC (rev 202063)
@@ -21,7 +21,7 @@
             var body = document.getElementById("body");
             body.focus();
             var container = accessibilityController.focusedElement.childAtIndex(0);
-            shouldBe("container.childAtIndex('0').role", "'AXRole: AXGroup'");            
+            shouldBe("container.childAtIndex('0').role", "'AXRole: AXStaticText'");            
             shouldBe("container.childAtIndex('0').childAtIndex(0).role", "'AXRole: AXStaticText'");            
             shouldBe("container.childAtIndex('0').childAtIndex(0).stringValue", "'AXValue: Test label1'");            
             shouldBe("container.childAtIndex('2').role", "'AXRole: AXCheckBox'");

Added: trunk/LayoutTests/accessibility/mac/label-element-with-link-string-value-expected.txt (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-with-link-string-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-with-link-string-value-expected.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,12 @@
+ first choice
+This tests that if a label element contains a link it will be exposed as a group with no AXValue.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS label.role is 'AXRole: AXGroup'
+PASS label.stringValue is 'AXValue: '
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/label-element-with-link-string-value.html (0 => 202063)


--- trunk/LayoutTests/accessibility/mac/label-element-with-link-string-value.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/label-element-with-link-string-value.html	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<input type="radio" id="input" />
+<label for="" id="label">
+	<span>first</span>
+	<span><a href=""
+</label>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+	var label = 0;
+
+    description("This tests that if a label element contains a link it will be exposed as a group with no AXValue.");
+    if (window.accessibilityController) {
+
+        if (window.accessibilityController) {
+
+            var body = document.getElementById("body");
+            body.focus();
+            
+            label = accessibilityController.accessibleElementById("label");
+            shouldBe("label.role", "'AXRole: AXGroup'");
+            shouldBe("label.stringValue", "'AXValue: '");          
+        }
+    }
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/accessibility/mac/slider-allows-title-ui-element-expected.txt (202062 => 202063)


--- trunk/LayoutTests/accessibility/mac/slider-allows-title-ui-element-expected.txt	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/LayoutTests/accessibility/mac/slider-allows-title-ui-element-expected.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -5,7 +5,7 @@
 
 
 PASS slider.titleUIElement().isEqual(title) is true
-PASS title.role is 'AXRole: AXGroup'
+PASS title.role is 'AXRole: AXStaticText'
 PASS title.childAtIndex(0).role is 'AXRole: AXStaticText'
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/accessibility/mac/slider-allows-title-ui-element.html (202062 => 202063)


--- trunk/LayoutTests/accessibility/mac/slider-allows-title-ui-element.html	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/LayoutTests/accessibility/mac/slider-allows-title-ui-element.html	2016-06-14 21:28:37 UTC (rev 202063)
@@ -24,7 +24,7 @@
         var title = accessibilityController.rootElement.childAtIndex(0).childAtIndex(0).childAtIndex(0);
 
         shouldBeTrue("slider.titleUIElement().isEqual(title)");
-        shouldBe("title.role", "'AXRole: AXGroup'");
+        shouldBe("title.role", "'AXRole: AXStaticText'");
         shouldBe("title.childAtIndex(0).role", "'AXRole: AXStaticText'");
     }
 

Modified: trunk/Source/WebCore/CMakeLists.txt (202062 => 202063)


--- trunk/Source/WebCore/CMakeLists.txt	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-06-14 21:28:37 UTC (rev 202063)
@@ -1050,6 +1050,7 @@
     accessibility/AccessibilityARIAGridRow.cpp
     accessibility/AccessibilityAttachment.cpp
     accessibility/AccessibilityImageMapLink.cpp
+    accessibility/AccessibilityLabel.cpp
     accessibility/AccessibilityList.cpp
     accessibility/AccessibilityListBox.cpp
     accessibility/AccessibilityListBoxOption.cpp

Modified: trunk/Source/WebCore/ChangeLog (202062 => 202063)


--- trunk/Source/WebCore/ChangeLog	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/Source/WebCore/ChangeLog	2016-06-14 21:28:37 UTC (rev 202063)
@@ -1,3 +1,44 @@
+2016-06-14  Doug Russell  <[email protected]>
+
+        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.
+
+        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]):
+
 2016-06-14  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r202057.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202062 => 202063)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-06-14 21:28:37 UTC (rev 202063)
@@ -6775,6 +6775,7 @@
 		F50664F7157F52DC00AC226F /* FormController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F50664F5157F52DC00AC226F /* FormController.cpp */; };
 		F50664F8157F52DC00AC226F /* FormController.h in Headers */ = {isa = PBXBuildFile; fileRef = F50664F6157F52DC00AC226F /* FormController.h */; };
 		F513A3EA15FF4841001526DB /* ValidationMessageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = F513A3E915FF4841001526DB /* ValidationMessageClient.h */; };
+		F52A8FD71D0A8D0E0073CF42 /* AccessibilityLabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F52A8FD51D0A88010073CF42 /* AccessibilityLabel.cpp */; };
 		F52AD5E41534245F0059FBE6 /* EmptyClients.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F52AD5E31534245F0059FBE6 /* EmptyClients.cpp */; };
 		F544F78815CFB2A800AF33A8 /* PlatformLocale.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F544F78615CFB2A800AF33A8 /* PlatformLocale.cpp */; };
 		F544F78915CFB2A800AF33A8 /* PlatformLocale.h in Headers */ = {isa = PBXBuildFile; fileRef = F544F78715CFB2A800AF33A8 /* PlatformLocale.h */; };
@@ -14871,6 +14872,8 @@
 		F523D27902DE43D7018635CA /* TextResourceDecoder.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = TextResourceDecoder.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F523D30302DE4476018635CA /* Range.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Range.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F523D30402DE4476018635CA /* Range.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Range.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+		F52A8FD51D0A88010073CF42 /* AccessibilityLabel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityLabel.cpp; sourceTree = "<group>"; };
+		F52A8FD61D0A88010073CF42 /* AccessibilityLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityLabel.h; sourceTree = "<group>"; };
 		F52AD5E31534245F0059FBE6 /* EmptyClients.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmptyClients.cpp; sourceTree = "<group>"; };
 		F544F78615CFB2A800AF33A8 /* PlatformLocale.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformLocale.cpp; sourceTree = "<group>"; };
 		F544F78715CFB2A800AF33A8 /* PlatformLocale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformLocale.h; sourceTree = "<group>"; };
@@ -16520,6 +16523,8 @@
 				2914E3061CAB5A440049966F /* AccessibilityAttachment.h */,
 				2981CAA0131822EC00D12F2A /* AccessibilityImageMapLink.cpp */,
 				29A8121D0FBB9C1D00510293 /* AccessibilityImageMapLink.h */,
+				F52A8FD51D0A88010073CF42 /* AccessibilityLabel.cpp */,
+				F52A8FD61D0A88010073CF42 /* AccessibilityLabel.h */,
 				2981CAA1131822EC00D12F2A /* AccessibilityList.cpp */,
 				29A8120E0FBB9C1D00510293 /* AccessibilityList.h */,
 				2981CAA2131822EC00D12F2A /* AccessibilityListBox.cpp */,
@@ -29777,6 +29782,7 @@
 				FE6938B61045D67E008EABB6 /* EventHandlerIOS.mm in Sources */,
 				93C09A7F0B064EEF005ABD4D /* EventHandlerMac.mm in Sources */,
 				AD4495F3141FC08900541EDF /* EventListenerMap.cpp in Sources */,
+				F52A8FD71D0A8D0E0073CF42 /* AccessibilityLabel.cpp in Sources */,
 				C400D10918F1C8F60090D863 /* EventLoopInput.cpp in Sources */,
 				99CC0B5018BE9849006CEBCC /* EventLoopInputDispatcher.cpp in Sources */,
 				26F40D4A14904A6300CA67C4 /* EventLoopIOS.mm in Sources */,

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (202062 => 202063)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2016-06-14 21:28:37 UTC (rev 202063)
@@ -37,6 +37,7 @@
 #include "AccessibilityARIAGridRow.h"
 #include "AccessibilityAttachment.h"
 #include "AccessibilityImageMapLink.h"
+#include "AccessibilityLabel.h"
 #include "AccessibilityList.h"
 #include "AccessibilityListBox.h"
 #include "AccessibilityListBoxOption.h"
@@ -428,6 +429,9 @@
     if (nodeHasRole(node, "treeitem"))
         return AccessibilityTreeItem::create(renderer);
 
+    if (node && is<HTMLLabelElement>(node))
+        return AccessibilityLabel::create(renderer);
+
 #if ENABLE(VIDEO)
     // media controls
     if (node && node->isMediaControlElement())

Modified: trunk/Source/WebCore/accessibility/AccessibilityAllInOne.cpp (202062 => 202063)


--- trunk/Source/WebCore/accessibility/AccessibilityAllInOne.cpp	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/Source/WebCore/accessibility/AccessibilityAllInOne.cpp	2016-06-14 21:28:37 UTC (rev 202063)
@@ -31,6 +31,7 @@
 #include "AccessibilityARIAGridRow.cpp"
 #include "AccessibilityAttachment.cpp"
 #include "AccessibilityImageMapLink.cpp"
+#include "AccessibilityLabel.cpp"
 #include "AccessibilityList.cpp"
 #include "AccessibilityListBox.cpp"
 #include "AccessibilityListBoxOption.cpp"

Added: trunk/Source/WebCore/accessibility/AccessibilityLabel.cpp (0 => 202063)


--- trunk/Source/WebCore/accessibility/AccessibilityLabel.cpp	                        (rev 0)
+++ trunk/Source/WebCore/accessibility/AccessibilityLabel.cpp	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AccessibilityLabel.h"
+
+#include "AXObjectCache.h"
+#include "HTMLNames.h"
+
+namespace WebCore {
+    
+using namespace HTMLNames;
+
+AccessibilityLabel::AccessibilityLabel(RenderObject* renderer)
+    : AccessibilityRenderObject(renderer)
+{
+}
+
+AccessibilityLabel::~AccessibilityLabel()
+{
+}
+
+Ref<AccessibilityLabel> AccessibilityLabel::create(RenderObject* renderer)
+{
+    return adoptRef(*new AccessibilityLabel(renderer));
+}
+
+bool AccessibilityLabel::computeAccessibilityIsIgnored() const
+{
+    return accessibilityIsIgnoredByDefault();
+}
+
+String AccessibilityLabel::stringValue() const
+{
+    if (containsOnlyStaticText())
+        return textUnderElement();
+    return AccessibilityNodeObject::stringValue();
+}
+
+static bool childrenContainOnlyStaticText(const AccessibilityObject::AccessibilityChildrenVector& children)
+{
+    if (!children.size())
+        return false;
+    for (const auto& child : children) {
+        if (child->roleValue() == StaticTextRole)
+            continue;
+        if (child->roleValue() == GroupRole) {
+            if (!childrenContainOnlyStaticText(child->children()))
+                return false;
+        } else
+            return false;
+    }
+    return true;
+}
+
+bool AccessibilityLabel::containsOnlyStaticText() const
+{
+    if (m_containsOnlyStaticTextDirty)
+        return childrenContainOnlyStaticText(m_children);
+    return m_containsOnlyStaticText;
+}
+
+void AccessibilityLabel::updateChildrenIfNecessary()
+{
+    AccessibilityRenderObject::updateChildrenIfNecessary();
+    if (m_containsOnlyStaticTextDirty)
+        m_containsOnlyStaticText = childrenContainOnlyStaticText(m_children);
+    m_containsOnlyStaticTextDirty = false;
+}
+
+void AccessibilityLabel::clearChildren()
+{
+    AccessibilityRenderObject::clearChildren();
+    m_containsOnlyStaticText = false;
+    m_containsOnlyStaticTextDirty = false;
+}
+
+void AccessibilityLabel::insertChild(AccessibilityObject* object, unsigned index)
+{
+    AccessibilityRenderObject::insertChild(object, index);
+    m_containsOnlyStaticTextDirty = true;
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/accessibility/AccessibilityLabel.h (0 => 202063)


--- trunk/Source/WebCore/accessibility/AccessibilityLabel.h	                        (rev 0)
+++ trunk/Source/WebCore/accessibility/AccessibilityLabel.h	2016-06-14 21:28:37 UTC (rev 202063)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AccessibilityLabel_h
+#define AccessibilityLabel_h
+
+#include "AccessibilityRenderObject.h"
+
+namespace WebCore {
+    
+class AccessibilityLabel final : public AccessibilityRenderObject {
+public:
+    static Ref<AccessibilityLabel> create(RenderObject*);
+    virtual ~AccessibilityLabel();
+    
+    bool containsOnlyStaticText() const;
+
+private:
+    explicit AccessibilityLabel(RenderObject*);
+    bool computeAccessibilityIsIgnored() const final;
+    AccessibilityRole roleValue() const final { return LabelRole; }
+    bool isLabel() const final { return true; }
+    String stringValue() const final;
+    void updateChildrenIfNecessary() final;
+    void clearChildren() final;
+    void insertChild(AccessibilityObject*, unsigned) final;
+    bool m_containsOnlyStaticTextDirty : 1;
+    bool m_containsOnlyStaticText : 1;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityLabel, isLabel())
+
+#endif // AccessibilityLabel_h

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (202062 => 202063)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2016-06-14 21:28:37 UTC (rev 202063)
@@ -512,6 +512,7 @@
     virtual bool isSliderThumb() const { return false; }
     virtual bool isInputSlider() const { return false; }
     virtual bool isControl() const { return false; }
+    virtual bool isLabel() const { return false; }
     virtual bool isList() const { return false; }
     virtual bool isTable() const { return false; }
     virtual bool isDataTable() const { return false; }

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (202062 => 202063)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2016-06-14 21:27:19 UTC (rev 202062)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2016-06-14 21:28:37 UTC (rev 202063)
@@ -33,6 +33,7 @@
 
 #import "AXObjectCache.h"
 #import "AccessibilityARIAGridRow.h"
+#import "AccessibilityLabel.h"
 #import "AccessibilityList.h"
 #import "AccessibilityListBox.h"
 #import "AccessibilityRenderObject.h"
@@ -2232,6 +2233,10 @@
         return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityRoleAttribute];
 #pragma clang diagnostic pop
     AccessibilityRole role = m_object->roleValue();
+
+    if (role == LabelRole && is<AccessibilityLabel>(*m_object) && downcast<AccessibilityLabel>(*m_object).containsOnlyStaticText())
+        role = StaticTextRole;
+
     if (role == CanvasRole && m_object->canvasHasFallbackContent())
         role = GroupRole;
     NSString* string = roleValueToNSString(role);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to