AX: Need to implement ColorWellRole
authordmazzoni@google.com <dmazzoni@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jan 2013 22:21:00 +0000 (22:21 +0000)
committerdmazzoni@google.com <dmazzoni@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jan 2013 22:21:00 +0000 (22:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106756

Reviewed by Chris Fleizach.

Source/WebCore:

Maps input type=color to the accessible role ColorWellRole.
Adds a new accessor to AccessibilityObject to get the color
value in a cross-platform way that doesn't require parsing.

Test: accessibility/color-well.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRole):
(WebCore::AccessibilityNodeObject::colorValue):
(WebCore):
* accessibility/AccessibilityNodeObject.h:
(AccessibilityNodeObject):
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::isColorWell):
(AccessibilityObject):
(WebCore::AccessibilityObject::colorValue):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::stringValue):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* accessibility/mac/WebAccessibilityObjectWrapper.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* html/HTMLInputElement.cpp:
(WebCore):
(WebCore::HTMLInputElement::isColorControl):
* html/HTMLInputElement.h:
(HTMLInputElement):

Source/WebKit/chromium:

Adds an accessibility interface to access the value of a
color control.

* public/WebAccessibilityObject.h:
(WebAccessibilityObject):
* src/WebAccessibilityObject.cpp:
(WebKit::WebAccessibilityObject::colorValue):
(WebKit):

Tools:

Returns a string representation of the value of a color
when the role is Color Well, to make it easy to write layout
tests for color controls.

* DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp:

LayoutTests:

Adds a test of accessibility attributes for input type=color.

* accessibility/color-well.html: Added.
* platform/chromium/accessibility/color-well-expected.txt: Added.
* platform/mac/accessibility/color-well-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139663 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/color-well.html [new file with mode: 0644]
LayoutTests/platform/chromium/accessibility/color-well-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/color-well-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityNodeObject.h
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebAccessibilityObject.h
Source/WebKit/chromium/src/WebAccessibilityObject.cpp
Tools/ChangeLog
Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp

index 6444a61..66c9d4e 100644 (file)
@@ -1,3 +1,16 @@
+2013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
+
+        AX: Need to implement ColorWellRole
+        https://bugs.webkit.org/show_bug.cgi?id=106756
+
+        Reviewed by Chris Fleizach.
+
+        Adds a test of accessibility attributes for input type=color.
+
+        * accessibility/color-well.html: Added.
+        * platform/chromium/accessibility/color-well-expected.txt: Added.
+        * platform/mac/accessibility/color-well-expected.txt: Added.
+
 2013-01-14  Stephen Chenney  <schenney@chromium.org>
 
         Re-enabling the SK_DISABLE_DASHING_OPTIMIZATION flag for Skia
diff --git a/LayoutTests/accessibility/color-well.html b/LayoutTests/accessibility/color-well.html
new file mode 100644 (file)
index 0000000..a32a2ed
--- /dev/null
@@ -0,0 +1,38 @@
+<html>
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+    <input id="empty_colorwell" type="color">
+    <input id="good_colorwell" type="color" value="#ff0000">
+    <input id="bad_colorwell" type="color" value="purple">
+    
+    <p id="description"></p>
+    <div id="console"></div>
+     
+    <script>
+        if (window.accessibilityController) {
+            description("This test checks the role of ColorWellRolean input with type=color");
+
+            var colorwell = document.getElementById("empty_colorwell").focus();
+            var axColorwell = accessibilityController.focusedElement;
+            debug("Role of input type=color is: " + axColorwell.role);
+
+            debug("Value of empty color well: " + axColorwell.stringValue);
+
+            colorwell = document.getElementById("good_colorwell").focus();
+            axColorwell = accessibilityController.focusedElement;
+            debug("Value of good color well: " + axColorwell.stringValue);
+
+            colorwell = document.getElementById("bad_colorwell").focus();
+            axColorwell = accessibilityController.focusedElement;
+            debug("Value of bad color well: " + axColorwell.stringValue);
+        }
+    </script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+
+</body> 
+</html>
diff --git a/LayoutTests/platform/chromium/accessibility/color-well-expected.txt b/LayoutTests/platform/chromium/accessibility/color-well-expected.txt
new file mode 100644 (file)
index 0000000..82675c4
--- /dev/null
@@ -0,0 +1,14 @@
+    
+This test checks the role of ColorWellRolean input with type=color
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Role of input type=color is: AXRole: AXColorWell
+Value of empty color well: AXValue: rgb 0.00000 0.00000 0.00000 1
+Value of good color well: AXValue: rgb 1.00000 0.00000 0.00000 1
+Value of bad color well: AXValue: rgb 0.00000 0.00000 0.00000 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/color-well-expected.txt b/LayoutTests/platform/mac/accessibility/color-well-expected.txt
new file mode 100644 (file)
index 0000000..bf82e88
--- /dev/null
@@ -0,0 +1,14 @@
+    
+This test checks the role of ColorWellRolean input with type=color
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Role of input type=color is: AXRole: AXTextField
+Value of empty color well: AXValue: 
+Value of good color well: AXValue: #ff0000
+Value of bad color well: AXValue: purple
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index 8816a12..25682d2 100644 (file)
@@ -1,3 +1,37 @@
+2013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
+
+        AX: Need to implement ColorWellRole
+        https://bugs.webkit.org/show_bug.cgi?id=106756
+
+        Reviewed by Chris Fleizach.
+
+        Maps input type=color to the accessible role ColorWellRole.
+        Adds a new accessor to AccessibilityObject to get the color
+        value in a cross-platform way that doesn't require parsing.
+
+        Test: accessibility/color-well.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::determineAccessibilityRole):
+        (WebCore::AccessibilityNodeObject::colorValue):
+        (WebCore):
+        * accessibility/AccessibilityNodeObject.h:
+        (AccessibilityNodeObject):
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::isColorWell):
+        (AccessibilityObject):
+        (WebCore::AccessibilityObject::colorValue):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::stringValue):
+        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
+        * accessibility/mac/WebAccessibilityObjectWrapper.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * html/HTMLInputElement.cpp:
+        (WebCore):
+        (WebCore::HTMLInputElement::isColorControl):
+        * html/HTMLInputElement.h:
+        (HTMLInputElement):
+
 2013-01-11  Emil A Eklund  <eae@chromium.org>
 
         offsetWidth/height incorrect for images when zoomed
index 235f79a..f74619a 100644 (file)
@@ -284,6 +284,13 @@ AccessibilityRole AccessibilityNodeObject::determineAccessibilityRole()
             return buttonRoleType();
         if (input->isRangeControl())
             return SliderRole;
+
+#if ENABLE(INPUT_TYPE_COLOR)
+        const AtomicString& type = input->getAttribute(typeAttr);
+        if (equalIgnoringCase(type, "color"))
+            return ColorWellRole;
+#endif
+
         return TextFieldRole;
     }
     if (node()->hasTagName(selectTag)) {
@@ -1611,6 +1618,30 @@ String AccessibilityNodeObject::stringValue() const
     return String();
 }
 
+void AccessibilityNodeObject::colorValue(int& r, int& g, int& b) const
+{
+    r = 0;
+    g = 0;
+    b = 0;
+
+    if (!isColorWell())
+        return;
+
+    if (!node() || !node()->hasTagName(inputTag))
+        return;
+
+    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+    const AtomicString& type = input->getAttribute(typeAttr);
+    if (!equalIgnoringCase(type, "color"))
+        return;
+
+    // HTMLInputElement::value always returns a string parseable by Color().
+    Color color(input->value());
+    r = color.red();
+    g = color.green();
+    b = color.blue();
+}
+
 // This function implements the ARIA accessible name as described by the Mozilla                                        
 // ARIA Implementer's Guide.                                                                                            
 static String accessibleNameForNode(Node* node)
index e46ca7e..8e04841 100644 (file)
@@ -123,6 +123,7 @@ public:
     virtual String title() const;
     virtual String text() const;
     virtual String stringValue() const;
+    virtual void colorValue(int& r, int& g, int& b) const;
     virtual String ariaLabeledByAttribute() const;
 
     virtual Element* actionElement() const;
index 5a70ae3..de96214 100644 (file)
@@ -429,6 +429,7 @@ public:
     bool isPopUpButton() const { return roleValue() == PopUpButtonRole; }
     bool isBlockquote() const;
     bool isLandmark() const;
+    bool isColorWell() const { return roleValue() == ColorWellRole; }
     
     virtual bool isChecked() const { return false; }
     virtual bool isEnabled() const { return false; }
@@ -560,6 +561,9 @@ public:
     virtual String ariaDescribedByAttribute() const { return String(); }
     const AtomicString& placeholderValue() const;
 
+    // Only if isColorWell()
+    virtual void colorValue(int& r, int& g, int& b) const { r = 0; g = 0; b = 0; }
+
     void setRoleValue(AccessibilityRole role) { m_role = role; }
     virtual AccessibilityRole roleValue() const { return m_role; }
 
index 5ba3c60..32fb3df 100644 (file)
@@ -2461,6 +2461,12 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
             return RadioButtonRole;
         if (input->isTextButton())
             return buttonRoleType();
+
+#if ENABLE(INPUT_TYPE_COLOR)
+        const AtomicString& type = input->getAttribute(typeAttr);
+        if (equalIgnoringCase(type, "color"))
+            return ColorWellRole;
+#endif
     }
 
     if (isFileUploadButton())
index f3cc81d..4d15823 100644 (file)
@@ -2243,6 +2243,12 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         
         if (m_object->isTabItem())
             return [NSNumber numberWithInt:m_object->isSelected()];
+
+        if (m_object->isColorWell()) {
+            int r, g, b;
+            m_object->colorValue(r, g, b);
+            return [NSString stringWithFormat:@"rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.];
+        }
         
         return m_object->stringValue();
     }
index 4acb76d..1d7febf 100644 (file)
@@ -1630,6 +1630,13 @@ bool HTMLInputElement::isRangeControl() const
     return m_inputType->isRangeControl();
 }
 
+#if ENABLE(INPUT_TYPE_COLOR)
+bool HTMLInputElement::isColorControl() const
+{
+    return m_inputType->isColorControl();
+}
+#endif
+
 bool HTMLInputElement::isText() const
 {
     return m_inputType->isTextType();
index f587b04..0a6d5d9 100644 (file)
@@ -97,6 +97,10 @@ public:
     bool isCheckbox() const;
     bool isRangeControl() const;
 
+#if ENABLE(INPUT_TYPE_COLOR)
+    bool isColorControl() const;
+#endif
+
     // FIXME: It's highly likely that any call site calling this function should instead
     // be using a different one. Many input elements behave like text fields, and in addition
     // any unknown input type is treated as text. Consider, for example, isTextField or
index 8e42ae5..a0a6b58 100644 (file)
@@ -1,3 +1,19 @@
+2013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
+
+        AX: Need to implement ColorWellRole
+        https://bugs.webkit.org/show_bug.cgi?id=106756
+
+        Reviewed by Chris Fleizach.
+
+        Adds an accessibility interface to access the value of a
+        color control.
+
+        * public/WebAccessibilityObject.h:
+        (WebAccessibilityObject):
+        * src/WebAccessibilityObject.cpp:
+        (WebKit::WebAccessibilityObject::colorValue):
+        (WebKit):
+
 2013-01-14  Mark Pilgrim  <pilgrim@chromium.org>
 
         [Chromium] Move AudioDestinationChromium into WebCore
index b77d108..ed3e171 100644 (file)
@@ -129,6 +129,7 @@ public:
     WEBKIT_EXPORT WebRect boundingBoxRect() const;
     WEBKIT_EXPORT bool canvasHasFallbackContent() const;
     WEBKIT_EXPORT WebPoint clickPoint() const;
+    WEBKIT_EXPORT void colorValue(int& r, int& g, int& b) const;
     WEBKIT_EXPORT double estimatedLoadingProgress() const;
     WEBKIT_EXPORT WebString helpText() const;
     WEBKIT_EXPORT int headingLevel() const;
index b920e4e..825b58b 100644 (file)
@@ -498,6 +498,14 @@ WebPoint WebAccessibilityObject::clickPoint() const
     return WebPoint(m_private->clickPoint());
 }
 
+void WebAccessibilityObject::colorValue(int& r, int& g, int& b) const
+{
+    if (isDetached())
+        return;
+
+    m_private->colorValue(r, g, b);
+}
+
 double WebAccessibilityObject::estimatedLoadingProgress() const
 {
     if (isDetached())
index a0b4975..e558ffa 100644 (file)
@@ -1,5 +1,18 @@
 2013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
 
+        AX: Need to implement ColorWellRole
+        https://bugs.webkit.org/show_bug.cgi?id=106756
+
+        Reviewed by Chris Fleizach.
+
+        Returns a string representation of the value of a color
+        when the role is Color Well, to make it easy to write layout
+        tests for color controls.
+
+        * DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp:
+
+2013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
+
         Chromium: Error in AccessibilityUIElement::intValueGetterCallback
         https://bugs.webkit.org/show_bug.cgi?id=106682
 
index 1a7d3ff..a0d4c70 100644 (file)
@@ -285,7 +285,15 @@ string getHelpText(const WebAccessibilityObject& object)
 
 string getStringValue(const WebAccessibilityObject& object)
 {
-    string value = object.stringValue().utf8();
+    string value;
+    if (object.roleValue() == WebAccessibilityRoleColorWell) {
+        int r, g, b;
+        char buffer[100];
+        object.colorValue(r, g, b);
+        snprintf(buffer, sizeof(buffer), "rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.);
+        value = buffer;
+    } else
+        value = object.stringValue().utf8();
     return value.insert(0, "AXValue: ");
 }