Changeset 139663 in webkit


Ignore:
Timestamp:
Jan 14, 2013 2:21:00 PM (11 years ago)
Author:
dmazzoni@google.com
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.
Location:
trunk
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139660 r139663  
     12013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
     2
     3        AX: Need to implement ColorWellRole
     4        https://bugs.webkit.org/show_bug.cgi?id=106756
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Adds a test of accessibility attributes for input type=color.
     9
     10        * accessibility/color-well.html: Added.
     11        * platform/chromium/accessibility/color-well-expected.txt: Added.
     12        * platform/mac/accessibility/color-well-expected.txt: Added.
     13
    1142013-01-14  Stephen Chenney  <schenney@chromium.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r139659 r139663  
     12013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
     2
     3        AX: Need to implement ColorWellRole
     4        https://bugs.webkit.org/show_bug.cgi?id=106756
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Maps input type=color to the accessible role ColorWellRole.
     9        Adds a new accessor to AccessibilityObject to get the color
     10        value in a cross-platform way that doesn't require parsing.
     11
     12        Test: accessibility/color-well.html
     13
     14        * accessibility/AccessibilityNodeObject.cpp:
     15        (WebCore::AccessibilityNodeObject::determineAccessibilityRole):
     16        (WebCore::AccessibilityNodeObject::colorValue):
     17        (WebCore):
     18        * accessibility/AccessibilityNodeObject.h:
     19        (AccessibilityNodeObject):
     20        * accessibility/AccessibilityObject.h:
     21        (WebCore::AccessibilityObject::isColorWell):
     22        (AccessibilityObject):
     23        (WebCore::AccessibilityObject::colorValue):
     24        * accessibility/AccessibilityRenderObject.cpp:
     25        (WebCore::AccessibilityRenderObject::stringValue):
     26        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
     27        * accessibility/mac/WebAccessibilityObjectWrapper.mm:
     28        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
     29        * html/HTMLInputElement.cpp:
     30        (WebCore):
     31        (WebCore::HTMLInputElement::isColorControl):
     32        * html/HTMLInputElement.h:
     33        (HTMLInputElement):
     34
    1352013-01-11  Emil A Eklund  <eae@chromium.org>
    236
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r139456 r139663  
    285285        if (input->isRangeControl())
    286286            return SliderRole;
     287
     288#if ENABLE(INPUT_TYPE_COLOR)
     289        const AtomicString& type = input->getAttribute(typeAttr);
     290        if (equalIgnoringCase(type, "color"))
     291            return ColorWellRole;
     292#endif
     293
    287294        return TextFieldRole;
    288295    }
     
    16121619}
    16131620
     1621void AccessibilityNodeObject::colorValue(int& r, int& g, int& b) const
     1622{
     1623    r = 0;
     1624    g = 0;
     1625    b = 0;
     1626
     1627    if (!isColorWell())
     1628        return;
     1629
     1630    if (!node() || !node()->hasTagName(inputTag))
     1631        return;
     1632
     1633    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
     1634    const AtomicString& type = input->getAttribute(typeAttr);
     1635    if (!equalIgnoringCase(type, "color"))
     1636        return;
     1637
     1638    // HTMLInputElement::value always returns a string parseable by Color().
     1639    Color color(input->value());
     1640    r = color.red();
     1641    g = color.green();
     1642    b = color.blue();
     1643}
     1644
    16141645// This function implements the ARIA accessible name as described by the Mozilla                                       
    16151646// ARIA Implementer's Guide.                                                                                           
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h

    r137962 r139663  
    124124    virtual String text() const;
    125125    virtual String stringValue() const;
     126    virtual void colorValue(int& r, int& g, int& b) const;
    126127    virtual String ariaLabeledByAttribute() const;
    127128
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r139456 r139663  
    430430    bool isBlockquote() const;
    431431    bool isLandmark() const;
     432    bool isColorWell() const { return roleValue() == ColorWellRole; }
    432433   
    433434    virtual bool isChecked() const { return false; }
     
    561562    const AtomicString& placeholderValue() const;
    562563
     564    // Only if isColorWell()
     565    virtual void colorValue(int& r, int& g, int& b) const { r = 0; g = 0; b = 0; }
     566
    563567    void setRoleValue(AccessibilityRole role) { m_role = role; }
    564568    virtual AccessibilityRole roleValue() const { return m_role; }
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r139250 r139663  
    24622462        if (input->isTextButton())
    24632463            return buttonRoleType();
     2464
     2465#if ENABLE(INPUT_TYPE_COLOR)
     2466        const AtomicString& type = input->getAttribute(typeAttr);
     2467        if (equalIgnoringCase(type, "color"))
     2468            return ColorWellRole;
     2469#endif
    24642470    }
    24652471
  • trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm

    r139456 r139663  
    22442244        if (m_object->isTabItem())
    22452245            return [NSNumber numberWithInt:m_object->isSelected()];
     2246
     2247        if (m_object->isColorWell()) {
     2248            int r, g, b;
     2249            m_object->colorValue(r, g, b);
     2250            return [NSString stringWithFormat:@"rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.];
     2251        }
    22462252       
    22472253        return m_object->stringValue();
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r139064 r139663  
    16311631}
    16321632
     1633#if ENABLE(INPUT_TYPE_COLOR)
     1634bool HTMLInputElement::isColorControl() const
     1635{
     1636    return m_inputType->isColorControl();
     1637}
     1638#endif
     1639
    16331640bool HTMLInputElement::isText() const
    16341641{
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r137565 r139663  
    9898    bool isRangeControl() const;
    9999
     100#if ENABLE(INPUT_TYPE_COLOR)
     101    bool isColorControl() const;
     102#endif
     103
    100104    // FIXME: It's highly likely that any call site calling this function should instead
    101105    // be using a different one. Many input elements behave like text fields, and in addition
  • trunk/Source/WebKit/chromium/ChangeLog

    r139652 r139663  
     12013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
     2
     3        AX: Need to implement ColorWellRole
     4        https://bugs.webkit.org/show_bug.cgi?id=106756
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Adds an accessibility interface to access the value of a
     9        color control.
     10
     11        * public/WebAccessibilityObject.h:
     12        (WebAccessibilityObject):
     13        * src/WebAccessibilityObject.cpp:
     14        (WebKit::WebAccessibilityObject::colorValue):
     15        (WebKit):
     16
    1172013-01-14  Mark Pilgrim  <pilgrim@chromium.org>
    218
  • trunk/Source/WebKit/chromium/public/WebAccessibilityObject.h

    r139323 r139663  
    130130    WEBKIT_EXPORT bool canvasHasFallbackContent() const;
    131131    WEBKIT_EXPORT WebPoint clickPoint() const;
     132    WEBKIT_EXPORT void colorValue(int& r, int& g, int& b) const;
    132133    WEBKIT_EXPORT double estimatedLoadingProgress() const;
    133134    WEBKIT_EXPORT WebString helpText() const;
  • trunk/Source/WebKit/chromium/src/WebAccessibilityObject.cpp

    r138260 r139663  
    499499}
    500500
     501void WebAccessibilityObject::colorValue(int& r, int& g, int& b) const
     502{
     503    if (isDetached())
     504        return;
     505
     506    m_private->colorValue(r, g, b);
     507}
     508
    501509double WebAccessibilityObject::estimatedLoadingProgress() const
    502510{
  • trunk/Tools/ChangeLog

    r139658 r139663  
     12013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
     2
     3        AX: Need to implement ColorWellRole
     4        https://bugs.webkit.org/show_bug.cgi?id=106756
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Returns a string representation of the value of a color
     9        when the role is Color Well, to make it easy to write layout
     10        tests for color controls.
     11
     12        * DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp:
     13
    1142013-01-14  Dominic Mazzoni  <dmazzoni@google.com>
    215
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp

    r139658 r139663  
    286286string getStringValue(const WebAccessibilityObject& object)
    287287{
    288     string value = object.stringValue().utf8();
     288    string value;
     289    if (object.roleValue() == WebAccessibilityRoleColorWell) {
     290        int r, g, b;
     291        char buffer[100];
     292        object.colorValue(r, g, b);
     293        snprintf(buffer, sizeof(buffer), "rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.);
     294        value = buffer;
     295    } else
     296        value = object.stringValue().utf8();
    289297    return value.insert(0, "AXValue: ");
    290298}
Note: See TracChangeset for help on using the changeset viewer.