Title: [207540] trunk
Revision
207540
Author
n_w...@apple.com
Date
2016-10-19 09:48:41 -0700 (Wed, 19 Oct 2016)

Log Message

AX: [Mac] Meter element should use AXValueDescription to descrbe the status of the value
https://bugs.webkit.org/show_bug.cgi?id=163610

Reviewed by Chris Fleizach.

Source/WebCore:

Exposed the goodness of the meter value in AXValueDescription.

Test: accessibility/mac/meter-gauge-value-description.html

* English.lproj/Localizable.strings:
* accessibility/AccessibilityProgressIndicator.cpp:
(WebCore::AccessibilityProgressIndicator::gaugeRegionValueDescription):
* accessibility/AccessibilityProgressIndicator.h:
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper valueDescriptionForMeter]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* platform/LocalizedStrings.cpp:
(WebCore::AXMeterGaugeRegionOptimumText):
(WebCore::AXMeterGaugeRegionSuboptimalText):
(WebCore::AXMeterGaugeRegionLessGoodText):
* platform/LocalizedStrings.h:

LayoutTests:

* accessibility/mac/meter-gauge-value-description-expected.txt: Added.
* accessibility/mac/meter-gauge-value-description.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207539 => 207540)


--- trunk/LayoutTests/ChangeLog	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/LayoutTests/ChangeLog	2016-10-19 16:48:41 UTC (rev 207540)
@@ -1,3 +1,13 @@
+2016-10-19  Nan Wang  <n_w...@apple.com>
+
+        AX: [Mac] Meter element should use AXValueDescription to descrbe the status of the value
+        https://bugs.webkit.org/show_bug.cgi?id=163610
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/meter-gauge-value-description-expected.txt: Added.
+        * accessibility/mac/meter-gauge-value-description.html: Added.
+
 2016-10-19  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking WPT html/webappapis/animation-frames/callback-* tests as flaky on mac-wk1.

Added: trunk/LayoutTests/accessibility/mac/meter-gauge-value-description-expected.txt (0 => 207540)


--- trunk/LayoutTests/accessibility/mac/meter-gauge-value-description-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/meter-gauge-value-description-expected.txt	2016-10-19 16:48:41 UTC (rev 207540)
@@ -0,0 +1,15 @@
+    
+This tests the gauge value description for meter elements.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS meter1.valueDescription is 'AXValueDescription: '
+PASS meter2.valueDescription is 'AXValueDescription: suboptimal value'
+PASS meter3.valueDescription is 'AXValueDescription: optimal value'
+PASS meter4.valueDescription is 'AXValueDescription: critical value'
+PASS meter5.valueDescription is 'AXValueDescription: 50 hours, optimal value'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/meter-gauge-value-description.html (0 => 207540)


--- trunk/LayoutTests/accessibility/mac/meter-gauge-value-description.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/meter-gauge-value-description.html	2016-10-19 16:48:41 UTC (rev 207540)
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<meter id="meter" value="83.5"></meter>
+<meter id="meter2" value="5" optimum="50" min="0" max="100" low="10" high="80"></meter>
+<meter id="meter3" value="50" optimum="50" min="0" max="100" low="10" high="80"></meter>
+<meter id="meter4" value="90" optimum="20" min="0" max="100" low="50" high="80"></meter>
+<meter id="meter5" value="50" optimum="50" min="0" max="100" low="10" high="80">50 hours</meter>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests the gauge value description for meter elements.");
+
+    if (window.accessibilityController) {
+
+          // Test that we are not exposing the gauge value description if author 
+          // didn't specify low, high or optimum attribute.
+          var meter1 = accessibilityController.accessibleElementById("meter");
+          shouldBe("meter1.valueDescription", "'AXValueDescription: '");
+
+          var meter2 = accessibilityController.accessibleElementById("meter2");
+          shouldBe("meter2.valueDescription", "'AXValueDescription: suboptimal value'");
+          
+          var meter3 = accessibilityController.accessibleElementById("meter3");
+          shouldBe("meter3.valueDescription", "'AXValueDescription: optimal value'");
+          
+          var meter4 = accessibilityController.accessibleElementById("meter4");
+          shouldBe("meter4.valueDescription", "'AXValueDescription: critical value'");
+          
+          // Test meter with inner text.
+          var meter5 = accessibilityController.accessibleElementById("meter5");
+          shouldBe("meter5.valueDescription", "'AXValueDescription: 50 hours, optimal value'");
+    }
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (207539 => 207540)


--- trunk/Source/WebCore/ChangeLog	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/Source/WebCore/ChangeLog	2016-10-19 16:48:41 UTC (rev 207540)
@@ -1,3 +1,27 @@
+2016-10-19  Nan Wang  <n_w...@apple.com>
+
+        AX: [Mac] Meter element should use AXValueDescription to descrbe the status of the value
+        https://bugs.webkit.org/show_bug.cgi?id=163610
+
+        Reviewed by Chris Fleizach.
+
+        Exposed the goodness of the meter value in AXValueDescription.
+
+        Test: accessibility/mac/meter-gauge-value-description.html
+
+        * English.lproj/Localizable.strings:
+        * accessibility/AccessibilityProgressIndicator.cpp:
+        (WebCore::AccessibilityProgressIndicator::gaugeRegionValueDescription):
+        * accessibility/AccessibilityProgressIndicator.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper valueDescriptionForMeter]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * platform/LocalizedStrings.cpp:
+        (WebCore::AXMeterGaugeRegionOptimumText):
+        (WebCore::AXMeterGaugeRegionSuboptimalText):
+        (WebCore::AXMeterGaugeRegionLessGoodText):
+        * platform/LocalizedStrings.h:
+
 2016-10-19  Dave Hyatt  <hy...@apple.com>
 
         [CSS Parser] Fix named color parsing

Modified: trunk/Source/WebCore/English.lproj/Localizable.strings (207539 => 207540)


--- trunk/Source/WebCore/English.lproj/Localizable.strings	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/Source/WebCore/English.lproj/Localizable.strings	2016-10-19 16:48:41 UTC (rev 207540)
@@ -931,6 +931,9 @@
 /* HTTP result code string */
 "length required" = "length required";
 
+/* The less good value description for a meter element */
+"less good" = "critical value";
+
 /* accessibility role description for link */
 "link" = "link";
 
@@ -1018,6 +1021,9 @@
 /* accessibility role description for an output element */
 "output" = "output";
 
+/* The optimum value description for a meter element */
+"optimum" = "optimal value";
+
 /* HTTP result code string */
 "partial content" = "partial content";
 
@@ -1120,6 +1126,9 @@
 /* accessibility help text for hide closed captions button */
 "stop displaying closed captions" = "stop displaying closed captions";
 
+/* The suboptimal value description for a meter element */
+"suboptimal" = "suboptimal value";
+
 /* HTTP result code string */
 "success" = "success";
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityProgressIndicator.cpp (207539 => 207540)


--- trunk/Source/WebCore/accessibility/AccessibilityProgressIndicator.cpp	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/Source/WebCore/accessibility/AccessibilityProgressIndicator.cpp	2016-10-19 16:48:41 UTC (rev 207540)
@@ -26,6 +26,7 @@
 #include "HTMLMeterElement.h"
 #include "HTMLNames.h"
 #include "HTMLProgressElement.h"
+#include "LocalizedStrings.h"
 #include "RenderMeter.h"
 #include "RenderObject.h"
 #include "RenderProgress.h"
@@ -167,7 +168,33 @@
 
     return downcast<RenderMeter>(*m_renderer).meterElement();
 }
+
+String AccessibilityProgressIndicator::gaugeRegionValueDescription() const
+{
+#if PLATFORM(COCOA)
+    if (!m_renderer || !m_renderer->isMeter())
+        return String();
+    
+    // Only expose this when the author has explicitly specified the following attributes.
+    if (!hasAttribute(lowAttr) && !hasAttribute(highAttr) && !hasAttribute(optimumAttr))
+        return String();
+    
+    if (HTMLMeterElement* element = meterElement()) {
+        switch (element->gaugeRegion()) {
+        case HTMLMeterElement::GaugeRegionOptimum:
+            return AXMeterGaugeRegionOptimumText();
+        case HTMLMeterElement::GaugeRegionSuboptimal:
+            return AXMeterGaugeRegionSuboptimalText();
+        case HTMLMeterElement::GaugeRegionEvenLessGood:
+            return AXMeterGaugeRegionLessGoodText();
+        default:
+            break;
+        }
+    }
 #endif
+    return String();
+}
+#endif
 
 Element* AccessibilityProgressIndicator::element() const
 {

Modified: trunk/Source/WebCore/accessibility/AccessibilityProgressIndicator.h (207539 => 207540)


--- trunk/Source/WebCore/accessibility/AccessibilityProgressIndicator.h	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/Source/WebCore/accessibility/AccessibilityProgressIndicator.h	2016-10-19 16:48:41 UTC (rev 207540)
@@ -38,6 +38,7 @@
     static Ref<AccessibilityProgressIndicator> create(RenderProgress*);
 #if ENABLE(METER_ELEMENT)
     static Ref<AccessibilityProgressIndicator> create(RenderMeter*);
+    String gaugeRegionValueDescription() const;
 #endif
     Element* element() const override;
 
@@ -65,4 +66,6 @@
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityProgressIndicator, isProgressIndicator())
+
 #endif // AccessibilityProgressIndicator_h

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (207539 => 207540)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2016-10-19 16:48:41 UTC (rev 207540)
@@ -36,6 +36,7 @@
 #import "AccessibilityLabel.h"
 #import "AccessibilityList.h"
 #import "AccessibilityListBox.h"
+#import "AccessibilityProgressIndicator.h"
 #import "AccessibilityRenderObject.h"
 #import "AccessibilityScrollView.h"
 #import "AccessibilitySpinButton.h"
@@ -76,7 +77,7 @@
 #import "WebCoreSystemInterface.h"
 #import "htmlediting.h"
 #import <wtf/ObjcRuntimeExtras.h>
-#if ENABLE(TREE_DEBUGGING)
+#if ENABLE(TREE_DEBUGGING) || ENABLE(METER_ELEMENT)
 #import <wtf/text/StringBuilder.h>
 #endif
 
@@ -2602,6 +2603,29 @@
     return [self remoteAccessibilityParentObject];
 }
 
+- (NSString *)valueDescriptionForMeter
+{
+    if (!m_object)
+        return nil;
+    
+    String valueDescription = m_object->valueDescription();
+#if ENABLE(METER_ELEMENT)
+    if (!is<AccessibilityProgressIndicator>(m_object))
+        return valueDescription;
+    auto &meter = downcast<AccessibilityProgressIndicator>(*m_object);
+    String gaugeRegionValue = meter.gaugeRegionValueDescription();
+    if (!gaugeRegionValue.isEmpty()) {
+        StringBuilder builder;
+        builder.append(valueDescription);
+        if (builder.length())
+            builder.appendLiteral(", ");
+        builder.append(gaugeRegionValue);
+        return builder.toString();
+    }
+#endif
+    return valueDescription;
+}
+
 // FIXME: split up this function in a better way.
 // suggestions: Use a hash table that maps attribute names to function calls,
 // or maybe pointers to member functions
@@ -3199,8 +3223,11 @@
         return nil;
     }
     
-    if ([attributeName isEqualToString:NSAccessibilityValueDescriptionAttribute])
+    if ([attributeName isEqualToString:NSAccessibilityValueDescriptionAttribute]) {
+        if (m_object->isMeter())
+            return [self valueDescriptionForMeter];
         return m_object->valueDescription();
+    }
     
     if ([attributeName isEqualToString:NSAccessibilityOrientationAttribute]) {
         AccessibilityOrientation elementOrientation = m_object->orientation();

Modified: trunk/Source/WebCore/platform/LocalizedStrings.cpp (207539 => 207540)


--- trunk/Source/WebCore/platform/LocalizedStrings.cpp	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/Source/WebCore/platform/LocalizedStrings.cpp	2016-10-19 16:48:41 UTC (rev 207540)
@@ -781,6 +781,22 @@
     return WEB_UI_STRING("separator", "accessibility role description for a horizontal rule [<hr>]");
 }
     
+#if ENABLE(METER_ELEMENT)
+String AXMeterGaugeRegionOptimumText()
+{
+    return WEB_UI_STRING("optimum", "The optimum value description for a meter element.");
+}
+
+String AXMeterGaugeRegionSuboptimalText()
+{
+    return WEB_UI_STRING("suboptimal", "The suboptimal value description for a meter element.");
+}
+
+String AXMeterGaugeRegionLessGoodText()
+{
+    return WEB_UI_STRING("less good", "The less good value description for a meter element.");
+}
+#endif // ENABLE(METER_ELEMENT)
 #endif // PLATFORM(COCOA)
 
 String missingPluginText()

Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (207539 => 207540)


--- trunk/Source/WebCore/platform/LocalizedStrings.h	2016-10-19 16:38:42 UTC (rev 207539)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h	2016-10-19 16:48:41 UTC (rev 207540)
@@ -196,7 +196,12 @@
 #if PLATFORM(COCOA)
     String AXARIAContentGroupText(const String& ariaType);
     String AXHorizontalRuleDescriptionText();
+#if ENABLE(METER_ELEMENT)
+    String AXMeterGaugeRegionOptimumText();
+    String AXMeterGaugeRegionSuboptimalText();
+    String AXMeterGaugeRegionLessGoodText();
 #endif
+#endif
     
     String AXAutoFillCredentialsLabel();
     String AXAutoFillContactsLabel();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to