Changeset 271760 in webkit


Ignore:
Timestamp:
Jan 22, 2021 1:55:33 PM (18 months ago)
Author:
Chris Fleizach
Message:

AX: AT-synthesized key events for common user actions (increment/decrement) are detectably different in many ways, potentially causing both web app breakage and AT identification
https://bugs.webkit.org/show_bug.cgi?id=220675
<rdar://problem/73263977>

Reviewed by Zalan Bujtas.

Source/WebCore:

Test: accessibility/keyevents-for-actions-mimic-real-key-events.html

When accessibility posts keyboard events in response to ax actions, they should mimic
real key events so as to be indistinguishable.

https://github.com/WICG/aom/blob/gh-pages/explainer.md#deprecated-keyboardevent-object-properties-optional

  • accessibility/AccessibilityNodeObject.cpp:

(WebCore::dispatchSimulatedKeyboardUpDownEvent):
(WebCore::InitializeLegacyKeyInitProperties):
(WebCore::AccessibilityNodeObject::performDismissAction):
(WebCore::AccessibilityNodeObject::postKeyboardKeysForValueChange):

  • dom/KeyboardEvent.cpp:

(WebCore::KeyboardEvent::KeyboardEvent):
(WebCore::KeyboardEvent::create):

  • dom/KeyboardEvent.h:
  • dom/UIEvent.cpp:

(WebCore::UIEvent::UIEvent):

  • dom/UIEvent.h:

(WebCore::UIEvent::create):

  • dom/UIEventWithKeyState.h:

(WebCore::UIEventWithKeyState::UIEventWithKeyState):

LayoutTests:

  • accessibility/keyevents-for-actions-mimic-real-key-events-expected.txt: Added.
  • accessibility/keyevents-for-actions-mimic-real-key-events.html: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r271752 r271760  
     12021-01-22  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: AT-synthesized key events for common user actions (increment/decrement) are detectably different in many ways, potentially causing both web app breakage and AT identification
     4        https://bugs.webkit.org/show_bug.cgi?id=220675
     5        <rdar://problem/73263977>
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        * accessibility/keyevents-for-actions-mimic-real-key-events-expected.txt: Added.
     10        * accessibility/keyevents-for-actions-mimic-real-key-events.html: Added.
     11
    1122021-01-22  Devin Rousso  <drousso@apple.com>
    213
  • trunk/LayoutTests/accessibility/keyevents-for-increment-actions-with-node-removal-expected.txt

    r263823 r271760  
    44
    55
    6 Keycode received: identifier: right key name: ArrowRight
     6Keycode received: identifier: Right key name: ArrowRight
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/accessibility/keyevents-posted-for-increment-actions-expected.txt

    r271536 r271760  
    66Increment/Decrement - LTR
    77Horizontal orientation
    8 Keycode received: identifier: right key name: ArrowRight key code: 39
    9 Keycode received: identifier: left key name: ArrowLeft key code: 37
     8Keycode received: identifier: Right key name: ArrowRight key code: 39
     9Keycode received: identifier: Left key name: ArrowLeft key code: 37
    1010Vertical orientation
    11 Keycode received: identifier: up key name: ArrowUp key code: 38
    12 Keycode received: identifier: down key name: ArrowDown key code: 40
     11Keycode received: identifier: Up key name: ArrowUp key code: 38
     12Keycode received: identifier: Down key name: ArrowDown key code: 40
    1313Increment/Decrement - RTL
    1414Horizontal orientation
    15 Keycode received: identifier: left key name: ArrowLeft key code: 37
    16 Keycode received: identifier: right key name: ArrowRight key code: 39
     15Keycode received: identifier: Left key name: ArrowLeft key code: 37
     16Keycode received: identifier: Right key name: ArrowRight key code: 39
    1717Vertical orientation
    18 Keycode received: identifier: up key name: ArrowUp key code: 38
    19 Keycode received: identifier: down key name: ArrowDown key code: 40
     18Keycode received: identifier: Up key name: ArrowUp key code: 38
     19Keycode received: identifier: Down key name: ArrowDown key code: 40
    2020PASS successfullyParsed is true
    2121
  • trunk/LayoutTests/platform/win/TestExpectations

    r271593 r271760  
    13961396accessibility/keyevents-posted-for-increment-actions.html [ Skip ]
    13971397accessibility/keyevents-posted-for-dismiss-action.html [ Skip ]
     1398accessibility/keyevents-for-actions-mimic-real-key-events.html [ Skip ]
    13981399
    13991400webkit.org/b/140796 accessibility/alt-tag-on-image-with-nonimage-role.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r271758 r271760  
     12021-01-22  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: AT-synthesized key events for common user actions (increment/decrement) are detectably different in many ways, potentially causing both web app breakage and AT identification
     4        https://bugs.webkit.org/show_bug.cgi?id=220675
     5        <rdar://problem/73263977>
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        Test: accessibility/keyevents-for-actions-mimic-real-key-events.html
     10
     11        When accessibility posts keyboard events in response to ax actions, they should mimic
     12        real key events so as to be indistinguishable.
     13
     14        https://github.com/WICG/aom/blob/gh-pages/explainer.md#deprecated-keyboardevent-object-properties-optional
     15
     16        * accessibility/AccessibilityNodeObject.cpp:
     17        (WebCore::dispatchSimulatedKeyboardUpDownEvent):
     18        (WebCore::InitializeLegacyKeyInitProperties):
     19        (WebCore::AccessibilityNodeObject::performDismissAction):
     20        (WebCore::AccessibilityNodeObject::postKeyboardKeysForValueChange):
     21        * dom/KeyboardEvent.cpp:
     22        (WebCore::KeyboardEvent::KeyboardEvent):
     23        (WebCore::KeyboardEvent::create):
     24        * dom/KeyboardEvent.h:
     25        * dom/UIEvent.cpp:
     26        (WebCore::UIEvent::UIEvent):
     27        * dom/UIEvent.h:
     28        (WebCore::UIEvent::create):
     29        * dom/UIEventWithKeyState.h:
     30        (WebCore::UIEventWithKeyState::UIEventWithKeyState):
     31
    1322021-01-22  Rob Buis  <rbuis@igalia.com>
    233
  • trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

    r271536 r271760  
    3939#include "Editing.h"
    4040#include "ElementIterator.h"
     41#include "Event.h"
    4142#include "EventNames.h"
    4243#include "FloatRect.h"
     
    11051106    bool handled = false;
    11061107    if (auto* node = object->node()) {
    1107         auto event = KeyboardEvent::create(eventNames().keydownEvent, keyInit);
     1108        auto event = KeyboardEvent::create(eventNames().keydownEvent, keyInit, Event::IsTrusted::Yes);
    11081109        node->dispatchEvent(event);
    11091110        handled |= event->defaultHandled();
     
    11121113    // Ensure node is still valid and wasn't removed after the keydown.
    11131114    if (auto* node = object->node()) {
    1114         auto event = KeyboardEvent::create(eventNames().keyupEvent, keyInit);
     1115        auto event = KeyboardEvent::create(eventNames().keyupEvent, keyInit, Event::IsTrusted::Yes);
    11151116        node->dispatchEvent(event);
    11161117        handled |= event->defaultHandled();
    11171118    }
    11181119    return handled;
     1120}
     1121
     1122static void InitializeLegacyKeyInitProperties(KeyboardEvent::Init &keyInit, const AccessibilityObject& object)
     1123{
     1124    keyInit.which = keyInit.keyCode;
     1125    keyInit.code = keyInit.key;
     1126
     1127    keyInit.view = object.document()->windowProxy();
     1128    keyInit.cancelable = true;
     1129    keyInit.composed = true;
     1130    keyInit.bubbles = true;
    11191131}
    11201132
     
    11241136    keyInit.key = "Escape"_s;
    11251137    keyInit.keyCode = 0x1b;
    1126    
     1138    keyInit.keyIdentifier = "U+001B"_s;
     1139    InitializeLegacyKeyInitProperties(keyInit, *this);
     1140
    11271141    return dispatchSimulatedKeyboardUpDownEvent(this, keyInit);
    11281142}
     
    11351149    bool isLTR = page()->userInterfaceLayoutDirection() == UserInterfaceLayoutDirection::LTR;
    11361150   
     1151    // The goal is to mimic existing keyboard dispatch completely, so that this is indistinguishable from a real key press.
    11371152    typedef enum { left = 37, up = 38, right = 39, down = 40 } keyCode;
    11381153    keyInit.key = increase ? (vertical ? "ArrowUp"_s : (isLTR ? "ArrowRight"_s : "ArrowLeft"_s)) : (vertical ? "ArrowDown"_s : (isLTR ? "ArrowLeft"_s : "ArrowRight"_s));
    11391154    keyInit.keyCode = increase ? (vertical ? keyCode::up : (isLTR ? keyCode::right : keyCode::left)) : (vertical ? keyCode::down : (isLTR ? keyCode::left : keyCode::right));
    1140     keyInit.keyIdentifier = increase ? (vertical ? "up"_s : (isLTR ? "right"_s : "left"_s)) : (vertical ? "down"_s : (isLTR ? "left"_s : "right"_s));
     1155    keyInit.keyIdentifier = increase ? (vertical ? "Up"_s : (isLTR ? "Right"_s : "Left"_s)) : (vertical ? "Down"_s : (isLTR ? "Left"_s : "Right"_s));
     1156
     1157    InitializeLegacyKeyInitProperties(keyInit, *this);
    11411158
    11421159    return dispatchSimulatedKeyboardUpDownEvent(this, keyInit);
  • trunk/Source/WebCore/dom/KeyboardEvent.cpp

    r252936 r271760  
    122122}
    123123
    124 inline KeyboardEvent::KeyboardEvent(const AtomString& eventType, const Init& initializer)
    125     : UIEventWithKeyState(eventType, initializer)
     124inline KeyboardEvent::KeyboardEvent(const AtomString& eventType, const Init& initializer, IsTrusted isTrusted)
     125    : UIEventWithKeyState(eventType, initializer, isTrusted)
    126126    , m_key(initializer.key)
    127127    , m_code(initializer.code)
     
    148148}
    149149
    150 Ref<KeyboardEvent> KeyboardEvent::create(const AtomString& type, const Init& initializer)
    151 {
    152     return adoptRef(*new KeyboardEvent(type, initializer));
     150Ref<KeyboardEvent> KeyboardEvent::create(const AtomString& type, const Init& initializer, IsTrusted isTrusted)
     151{
     152    return adoptRef(*new KeyboardEvent(type, initializer, isTrusted));
    153153}
    154154
  • trunk/Source/WebCore/dom/KeyboardEvent.h

    r252936 r271760  
    6363    };
    6464
    65     static Ref<KeyboardEvent> create(const AtomString& type, const Init&);
     65    static Ref<KeyboardEvent> create(const AtomString& type, const Init&, IsTrusted = IsTrusted::No);
    6666
    6767    virtual ~KeyboardEvent();
     
    9898    KeyboardEvent();
    9999    KeyboardEvent(const PlatformKeyboardEvent&, RefPtr<WindowProxy>&&);
    100     KeyboardEvent(const AtomString&, const Init&);
     100    KeyboardEvent(const AtomString&, const Init&, IsTrusted = IsTrusted::No);
    101101
    102102    std::unique_ptr<PlatformKeyboardEvent> m_underlyingPlatformEvent;
  • trunk/Source/WebCore/dom/UIEvent.cpp

    r250060 r271760  
    5050}
    5151
    52 UIEvent::UIEvent(const AtomString& eventType, const UIEventInit& initializer)
    53     : Event(eventType, initializer, IsTrusted::No)
     52UIEvent::UIEvent(const AtomString& eventType, const UIEventInit& initializer, IsTrusted isTrusted)
     53    : Event(eventType, initializer, isTrusted)
    5454    , m_view(initializer.view.get())
    5555    , m_detail(initializer.detail)
  • trunk/Source/WebCore/dom/UIEvent.h

    r250060 r271760  
    4444        return adoptRef(*new UIEvent);
    4545    }
    46     static Ref<UIEvent> create(const AtomString& type, const UIEventInit& initializer)
     46    static Ref<UIEvent> create(const AtomString& type, const UIEventInit& initializer, IsTrusted = IsTrusted::No)
    4747    {
    4848        return adoptRef(*new UIEvent(type, initializer));
     
    7070    UIEvent(const AtomString& type, CanBubble, IsCancelable, IsComposed, RefPtr<WindowProxy>&&, int detail);
    7171    UIEvent(const AtomString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&&, int detail, IsTrusted = IsTrusted::Yes);
    72     UIEvent(const AtomString&, const UIEventInit&);
     72    UIEvent(const AtomString&, const UIEventInit&, IsTrusted = IsTrusted::No);
    7373
    7474private:
  • trunk/Source/WebCore/dom/UIEventWithKeyState.h

    r250060 r271760  
    6363    }
    6464
    65     UIEventWithKeyState(const AtomString& type, const EventModifierInit& initializer)
    66         : UIEvent(type, initializer)
     65    UIEventWithKeyState(const AtomString& type, const EventModifierInit& initializer, IsTrusted isTrusted = IsTrusted::No)
     66        : UIEvent(type, initializer, isTrusted)
    6767        , m_modifiers(modifiersFromInitializer(initializer))
    6868    {
Note: See TracChangeset for help on using the changeset viewer.