Title: [139663] trunk
Revision
139663
Author
dmazz...@google.com
Date
2013-01-14 14:21:00 -0800 (Mon, 14 Jan 2013)

Log Message

AX: Need to implement ColorWellRole
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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139662 => 139663)


--- trunk/LayoutTests/ChangeLog	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/LayoutTests/ChangeLog	2013-01-14 22:21:00 UTC (rev 139663)
@@ -1,3 +1,16 @@
+2013-01-14  Dominic Mazzoni  <dmazz...@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  <schen...@chromium.org>
 
         Re-enabling the SK_DISABLE_DASHING_OPTIMIZATION flag for Skia

Added: trunk/LayoutTests/accessibility/color-well.html (0 => 139663)


--- trunk/LayoutTests/accessibility/color-well.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/color-well.html	2013-01-14 22:21:00 UTC (rev 139663)
@@ -0,0 +1,38 @@
+<html>
+<html>
+<head>
+<script src=""
+</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=""
+
+</body> 
+</html>

Added: trunk/LayoutTests/platform/chromium/accessibility/color-well-expected.txt (0 => 139663)


--- trunk/LayoutTests/platform/chromium/accessibility/color-well-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/accessibility/color-well-expected.txt	2013-01-14 22:21:00 UTC (rev 139663)
@@ -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
+

Added: trunk/LayoutTests/platform/mac/accessibility/color-well-expected.txt (0 => 139663)


--- trunk/LayoutTests/platform/mac/accessibility/color-well-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/color-well-expected.txt	2013-01-14 22:21:00 UTC (rev 139663)
@@ -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
+

Modified: trunk/Source/WebCore/ChangeLog (139662 => 139663)


--- trunk/Source/WebCore/ChangeLog	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/ChangeLog	2013-01-14 22:21:00 UTC (rev 139663)
@@ -1,3 +1,37 @@
+2013-01-14  Dominic Mazzoni  <dmazz...@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  <e...@chromium.org>
 
         offsetWidth/height incorrect for images when zoomed

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (139662 => 139663)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-01-14 22:21:00 UTC (rev 139663)
@@ -284,6 +284,13 @@
             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 @@
     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)

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h (139662 => 139663)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h	2013-01-14 22:21:00 UTC (rev 139663)
@@ -123,6 +123,7 @@
     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;

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (139662 => 139663)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2013-01-14 22:21:00 UTC (rev 139663)
@@ -429,6 +429,7 @@
     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 @@
     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; }
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (139662 => 139663)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-01-14 22:21:00 UTC (rev 139663)
@@ -2461,6 +2461,12 @@
             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())

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm (139662 => 139663)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm	2013-01-14 22:21:00 UTC (rev 139663)
@@ -2243,6 +2243,12 @@
         
         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();
     }

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (139662 => 139663)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2013-01-14 22:21:00 UTC (rev 139663)
@@ -1630,6 +1630,13 @@
     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();

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (139662 => 139663)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2013-01-14 22:21:00 UTC (rev 139663)
@@ -97,6 +97,10 @@
     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

Modified: trunk/Source/WebKit/chromium/ChangeLog (139662 => 139663)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-01-14 22:21:00 UTC (rev 139663)
@@ -1,3 +1,19 @@
+2013-01-14  Dominic Mazzoni  <dmazz...@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  <pilg...@chromium.org>
 
         [Chromium] Move AudioDestinationChromium into WebCore

Modified: trunk/Source/WebKit/chromium/public/WebAccessibilityObject.h (139662 => 139663)


--- trunk/Source/WebKit/chromium/public/WebAccessibilityObject.h	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebKit/chromium/public/WebAccessibilityObject.h	2013-01-14 22:21:00 UTC (rev 139663)
@@ -129,6 +129,7 @@
     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;

Modified: trunk/Source/WebKit/chromium/src/WebAccessibilityObject.cpp (139662 => 139663)


--- trunk/Source/WebKit/chromium/src/WebAccessibilityObject.cpp	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Source/WebKit/chromium/src/WebAccessibilityObject.cpp	2013-01-14 22:21:00 UTC (rev 139663)
@@ -498,6 +498,14 @@
     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())

Modified: trunk/Tools/ChangeLog (139662 => 139663)


--- trunk/Tools/ChangeLog	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Tools/ChangeLog	2013-01-14 22:21:00 UTC (rev 139663)
@@ -1,5 +1,18 @@
 2013-01-14  Dominic Mazzoni  <dmazz...@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  <dmazz...@google.com>
+
         Chromium: Error in AccessibilityUIElement::intValueGetterCallback
         https://bugs.webkit.org/show_bug.cgi?id=106682
 

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp (139662 => 139663)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp	2013-01-14 22:14:33 UTC (rev 139662)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp	2013-01-14 22:21:00 UTC (rev 139663)
@@ -285,7 +285,15 @@
 
 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: ");
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to