⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244061 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 5:58:19 PM (7 years ago)
Author:
Chris Fleizach
Message:

AX: Automatically compute accessibility labels for Apple Pay buttons
https://bugs.webkit.org/show_bug.cgi?id=196661

Reviewed by Joanmarie Diggs.

Source/WebCore:

Detect Apple Pay buttons and return a standard role and label for them based on their type.

Test: accessibility/mac/apple-pay-labels.html

accessibility/mac/apple-pay-session-v4.html

  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::AccessibilityNodeObject::isControl const):

  • accessibility/AccessibilityNodeObject.h:
  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::applePayButtonDescription const):
(WebCore::AccessibilityRenderObject::titleElementText const):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
(WebCore::AccessibilityRenderObject::isApplePayButton const):
(WebCore::AccessibilityRenderObject::applePayButtonType const):

  • accessibility/AccessibilityRenderObject.h:
  • en.lproj/Localizable.strings:
  • platform/LocalizedStrings.cpp:

(WebCore::AXApplePayPlainLabel):
(WebCore::AXApplePayBuyLabel):
(WebCore::AXApplePaySetupLabel):
(WebCore::AXApplePayDonateLabel):
(WebCore::AXApplePayCheckOutLabel):
(WebCore::AXApplePayBookLabel):
(WebCore::AXApplePaySubscribeLabel):

  • platform/LocalizedStrings.h:

LayoutTests:

  • accessibility/mac/apple-pay-labels-expected.txt: Added.
  • accessibility/mac/apple-pay-labels.html: Added.
  • accessibility/mac/apple-pay-session-v4-expected.txt: Added.
  • accessibility/mac/apple-pay-session-v4.html: Added.
Location:
trunk
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r244054 r244061  
     12019-04-08  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Automatically compute accessibility labels for Apple Pay buttons
     4        https://bugs.webkit.org/show_bug.cgi?id=196661
     5
     6        Reviewed by Joanmarie Diggs.
     7
     8        * accessibility/mac/apple-pay-labels-expected.txt: Added.
     9        * accessibility/mac/apple-pay-labels.html: Added.
     10        * accessibility/mac/apple-pay-session-v4-expected.txt: Added.
     11        * accessibility/mac/apple-pay-session-v4.html: Added.
     12
    1132019-04-08  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r243763 r244061  
    6262# ShouldOpenExternalURLs not yet supported in WK1
    6363loader/navigation-policy [ Skip ]
     64
     65[ Sierra ] accessibility/mac/apple-pay-labels.html [ Skip ]
     66[ HighSierra ] accessibility/mac/apple-pay-session-v4.html [ Skip ]
    6467
    6568# <a download> is not supported in WK1 yet.
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r244045 r244061  
    3434[ Sierra ] http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html [ Skip ]
    3535[ Sierra ] http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html [ Skip ]
     36[ Sierra ] accessibility/mac/apple-pay-labels.html [ Skip ]
    3637[ HighSierra ] http/tests/ssl/applepay/ApplePayButtonV4.html [ Skip ]
    3738[ HighSierra ] http/tests/ssl/applepay/ApplePaySessionV4.html [ Skip ]
    3839[ HighSierra ] http/tests/ssl/applepay/ApplePaySessionV5.html [ Skip ]
     40[ HighSierra ] accessibility/mac/apple-pay-session-v4.html [ Skip ]
    3941
    4042fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ]
     
    776778[ HighSierra+ ] http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html [ Pass ]
    777779[ HighSierra+ ] http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html [ Pass ]
     780[ HighSierra+ ] accessibility/mac/apple-pay-labels.html [ Pass ]
     781[ Mojave+ ] accessibility/mac/apple-pay-session-v4.html [ Pass ]
    778782# <rdar://problem/31634451>
    779783[ HighSierra+ ] http/tests/resourceLoadStatistics/cookies-with-and-without-user-interaction.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r244059 r244061  
     12019-04-08  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Automatically compute accessibility labels for Apple Pay buttons
     4        https://bugs.webkit.org/show_bug.cgi?id=196661
     5
     6        Reviewed by Joanmarie Diggs.
     7
     8        Detect Apple Pay buttons and return a standard role and label for them based on their type.
     9
     10        Test: accessibility/mac/apple-pay-labels.html
     11              accessibility/mac/apple-pay-session-v4.html
     12
     13        * accessibility/AccessibilityNodeObject.cpp:
     14        (WebCore::AccessibilityNodeObject::isControl const):
     15        * accessibility/AccessibilityNodeObject.h:
     16        * accessibility/AccessibilityRenderObject.cpp:
     17        (WebCore::AccessibilityRenderObject::applePayButtonDescription const):
     18        (WebCore::AccessibilityRenderObject::titleElementText const):
     19        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
     20        (WebCore::AccessibilityRenderObject::isApplePayButton const):
     21        (WebCore::AccessibilityRenderObject::applePayButtonType const):
     22        * accessibility/AccessibilityRenderObject.h:
     23        * en.lproj/Localizable.strings:
     24        * platform/LocalizedStrings.cpp:
     25        (WebCore::AXApplePayPlainLabel):
     26        (WebCore::AXApplePayBuyLabel):
     27        (WebCore::AXApplePaySetupLabel):
     28        (WebCore::AXApplePayDonateLabel):
     29        (WebCore::AXApplePayCheckOutLabel):
     30        (WebCore::AXApplePayBookLabel):
     31        (WebCore::AXApplePaySubscribeLabel):
     32        * platform/LocalizedStrings.h:
     33
    1342019-04-08  Chris Fleizach  <cfleizach@apple.com>
    235
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r242713 r244061  
    887887        return false;
    888888
    889     return is<HTMLFormControlElement>(*node) || AccessibilityObject::isARIAControl(ariaRoleAttribute());
     889    return is<HTMLFormControlElement>(*node) || AccessibilityObject::isARIAControl(ariaRoleAttribute()) || roleValue() == AccessibilityRole::Button;
    890890}
    891891
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.h

    r241321 r244061  
    178178    AccessibilityObject* menuButtonForMenu() const;
    179179    AccessibilityObject* captionForFigure() const;
     180    virtual void titleElementText(Vector<AccessibilityText>&) const;
    180181
    181182private:
    182183    bool isAccessibilityNodeObject() const final { return true; }
    183184    void accessibilityText(Vector<AccessibilityText>&) const override;
    184     virtual void titleElementText(Vector<AccessibilityText>&) const;
    185185    void alternativeText(Vector<AccessibilityText>&) const;
    186186    void visibleText(Vector<AccessibilityText>&) const;
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r244029 r244061  
    10761076    return true;
    10771077}
     1078
     1079#if ENABLE(APPLE_PAY)
     1080String AccessibilityRenderObject::applePayButtonDescription() const
     1081{
     1082    switch (applePayButtonType()) {
     1083    case ApplePayButtonType::Plain:
     1084        return AXApplePayPlainLabel();
     1085    case ApplePayButtonType::Buy:
     1086        return AXApplePayBuyLabel();
     1087    case ApplePayButtonType::SetUp:
     1088        return AXApplePaySetupLabel();
     1089    case ApplePayButtonType::Donate:
     1090        return AXApplePayDonateLabel();
     1091#if ENABLE(APPLE_PAY_SESSION_V4)
     1092    case ApplePayButtonType::CheckOut:
     1093        return AXApplePayCheckOutLabel();
     1094    case ApplePayButtonType::Book:
     1095        return AXApplePayBookLabel();
     1096    case ApplePayButtonType::Subscribe:
     1097        return AXApplePaySubscribeLabel();
     1098#endif
     1099    }
     1100}
     1101#endif
     1102
     1103void AccessibilityRenderObject::titleElementText(Vector<AccessibilityText>& textOrder) const
     1104{
     1105#if ENABLE(APPLE_PAY)
     1106    if (isApplePayButton()) {
     1107        textOrder.append(AccessibilityText(applePayButtonDescription(), AccessibilityTextSource::Alternative));
     1108        return;
     1109    }
     1110#endif
     1111
     1112    AccessibilityNodeObject::titleElementText(textOrder);
     1113}
    10781114   
    10791115AccessibilityObject* AccessibilityRenderObject::titleUIElement() const
     
    26732709        return AccessibilityRole::Unknown;
    26742710
     2711#if ENABLE(APPLE_PAY)
     2712    if (isApplePayButton())
     2713        return AccessibilityRole::Button;
     2714#endif
     2715
    26752716    // Sometimes we need to ignore the attribute role. Like if a tree is malformed,
    26762717    // we want to ignore the treeitem's attribute role.
     
    36303671}
    36313672
     3673#if ENABLE(APPLE_PAY)
     3674bool AccessibilityRenderObject::isApplePayButton() const
     3675{
     3676    if (!m_renderer)
     3677        return false;
     3678    return m_renderer->style().appearance() == ApplePayButtonPart;
     3679}
     3680
     3681ApplePayButtonType AccessibilityRenderObject::applePayButtonType() const
     3682{
     3683    if (!m_renderer)
     3684        return ApplePayButtonType::Plain;
     3685    return m_renderer->style().applePayButtonType();
     3686}
     3687#endif
     3688
    36323689bool AccessibilityRenderObject::hasSameFontColor(RenderObject* renderer) const
    36333690{
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h

    r242051 r244061  
    201201
    202202    String passwordFieldValue() const override;
     203    void titleElementText(Vector<AccessibilityText>&) const override;
    203204
    204205protected:
     
    284285    bool shouldGetTextFromNode(AccessibilityTextUnderElementMode) const;
    285286
     287#if ENABLE(APPLE_PAY)
     288    bool isApplePayButton() const;
     289    ApplePayButtonType applePayButtonType() const;
     290    String applePayButtonDescription() const;
     291#endif
     292
    286293    RenderObject* targetElementForActiveDescendant(const QualifiedName&, AccessibilityObject*) const;
    287294    bool canHavePlainText() const;
  • trunk/Source/WebCore/en.lproj/Localizable.strings

    r243173 r244061  
    104104"Align Right (Undo action name)" = "Align Right";
    105105
    106 /* Allow Storage Access API */
    107 "Allow" = "Allow";
    108 
    109 /* Title for Allow button label in the Storage Access API request dialog */
     106/* Button title in Storage Access API prompt */
    110107"Allow (cross-site cookie and website data access)" = "Allow";
    111108
    112 /* Storage Access API request validation (iOS phrasing) */
     109/* Message for requesting cross-site cookie and website data access. */
    113110"Allow \"%@\" to use cookies and website data while browsing \"%@\"?" = "Allow \"%@\" to use cookies and website data while browsing \"%@\"?";
    114111
     
    116113"An unknown error occurred" = "An unknown error occurred";
    117114
     115/* Label for the plain Apple Pay button. */
     116"Apple Pay" = "Apple Pay";
     117
    118118/* Malware confirmation dialog title */
    119119"Are you sure you wish to go to this site?" = "Are you sure you wish to go to this site?";
     
    140140"Bold (Undo action name)" = "Bold";
    141141
     142/* Label for the book with Apple Pay button. */
     143"Book with Apple Pay" = "Book with Apple Pay";
     144
    142145/* Option in segmented control for inserting a bulleted list in text editing */
    143146"Bulleted list" = "Bulleted list";
    144147
     148/* Label for the buy with Apple Pay button. */
     149"Buy with Apple Pay" = "Buy with Apple Pay";
     150
    145151/* Cancel */
    146152"Cancel" = "Cancel";
     
    167173"Check Spelling While Typing" = "Check Spelling While Typing";
    168174
     175/* Label for the check out with Apple Pay button. */
     176"Check out with Apple Pay" = "Check out with Apple Pay";
     177
    169178/* title for a single file chooser button used in HTML forms */
    170179"Choose File" = "Choose File";
     
    257266"Dictation (Undo action name)" = "Dictation";
    258267
    259 /* Storage Access API request validation (macOS phrasing) */
     268/* Message for requesting cross-site cookie and website data access. */
    260269"Do you want to allow \"%@\" to use cookies and website data while browsing \"%@\"?" = "Do you want to allow \"%@\" to use cookies and website data while browsing \"%@\"?";
    261270
    262 /* Storage Access API deny access */
    263 "Don't Allow" = "Don't Allow";
    264 
    265 /* Title for Don't Allow button label in the Storage Access API request dialog */
     271/* Button title in Storage Access API prompt */
    266272"Don't Allow (cross-site cookie and website data access)" = "Don't Allow";
     273
     274/* Label for the donate with Apple Pay button. */
     275"Donate with Apple Pay" = "Donate with Apple Pay";
    267276
    268277/* Title of the Done button for zoomed form controls. */
     
    665674"Set Writing Direction (Undo action name)" = "Set Writing Direction";
    666675
     676/* Label for the set up with Apple Pay button. */
     677"Set up with Apple Pay" = "Set up with Apple Pay";
     678
    667679/* Title for Share action button */
    668680"Share…" = "Share…";
     
    746758"Submit (input element)" = "Submit";
    747759
     760/* Label for the subcribe with Apple Pay button. */
     761"Subscribe with Apple Pay" = "Subscribe with Apple Pay";
     762
    748763/* Undo action name */
    749764"Subscript (Undo action name)" = "Subscript";
     
    821836"This website may try to trick you into installing software that harms your browsing experience, like changing your settings without your permission or showing you unwanted ads. Once installed, it may be difficult to remove." = "This website may try to trick you into installing software that harms your browsing experience, like changing your settings without your permission or showing you unwanted ads. Once installed, it may be difficult to remove.";
    822837
    823 /* Storage Access API tracking warning */
     838/* Informative text for requesting cross-site cookie and website data access. */
    824839"This will allow \"%@\" to track your activity." = "This will allow \"%@\" to track your activity.";
    825840
  • trunk/Source/WebCore/platform/LocalizedStrings.cpp

    r242920 r244061  
    628628    return "select";
    629629}
     630
     631#if ENABLE(APPLE_PAY)
     632String AXApplePayPlainLabel()
     633{
     634    return WEB_UI_STRING("Apple Pay", "Label for the plain Apple Pay button.");
     635}
     636
     637String AXApplePayBuyLabel()
     638{
     639    return WEB_UI_STRING("Buy with Apple Pay", "Label for the buy with Apple Pay button.");
     640}
     641
     642String AXApplePaySetupLabel()
     643{
     644    return WEB_UI_STRING("Set up with Apple Pay", "Label for the set up with Apple Pay button.");
     645}
     646
     647String AXApplePayDonateLabel()
     648{
     649    return WEB_UI_STRING("Donate with Apple Pay", "Label for the donate with Apple Pay button.");
     650}
     651
     652String AXApplePayCheckOutLabel()
     653{
     654    return WEB_UI_STRING("Check out with Apple Pay", "Label for the check out with Apple Pay button.");
     655}
     656
     657String AXApplePayBookLabel()
     658{
     659    return WEB_UI_STRING("Book with Apple Pay", "Label for the book with Apple Pay button.");
     660}
     661
     662String AXApplePaySubscribeLabel()
     663{
     664    return WEB_UI_STRING("Subscribe with Apple Pay", "Label for the subcribe with Apple Pay button.");
     665}
     666#endif
    630667
    631668String AXAutoFillCredentialsLabel()
  • trunk/Source/WebCore/platform/LocalizedStrings.h

    r242920 r244061  
    214214#endif
    215215#endif
    216    
     216#if ENABLE(APPLE_PAY)
     217    String AXApplePayPlainLabel();
     218    String AXApplePayBuyLabel();
     219    String AXApplePaySetupLabel();
     220    String AXApplePayDonateLabel();
     221    String AXApplePayCheckOutLabel();
     222    String AXApplePayBookLabel();
     223    String AXApplePaySubscribeLabel();
     224#endif
     225
    217226    String AXAutoFillCredentialsLabel();
    218227    String AXAutoFillContactsLabel();
Note: See TracChangeset for help on using the changeset viewer.