Changeset 228827 in webkit


Ignore:
Timestamp:
Feb 20, 2018 11:02:25 AM (6 years ago)
Author:
n_wang@apple.com
Message:

AX: AOM: Dispatch accessibleclick event
https://bugs.webkit.org/show_bug.cgi?id=180898
<rdar://problem/36086710>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Accessibility events.
Spec: https://wicg.github.io/aom/spec/phase2.html

This patch allows developers to register event handlers on Elements
for custom accessibility events.

Accessibility events go through a capturing and bubbling phase just
like DOM events, but in the accessibility tree.

Implemented "accessibleclick" event.

Test: accessibility/mac/AOM-events.html

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::press):
(WebCore::AccessibilityObject::dispatchAccessibilityEvent):

  • accessibility/AccessibilityObject.h:
  • accessibility/mac/WebAccessibilityObjectWrapperMac.mm:

(-[WebAccessibilityObjectWrapper accessibilityPerformAction:]):

  • dom/Element.idl:
  • dom/EventDispatcher.cpp:

(WebCore::dispatchEventWithType):
(WebCore::EventDispatcher::dispatchEvent):

  • dom/EventDispatcher.h:
  • dom/EventNames.h:
  • dom/EventPath.cpp:

(WebCore::EventPath::EventPath):

  • dom/EventPath.h:

Tools:

  • WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:

(WTR::AccessibilityUIElement::syncPress):

  • WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
  • WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:

(WTR::AccessibilityUIElement::syncPress):

LayoutTests:

  • accessibility/mac/AOM-events-expected.txt: Added.
  • accessibility/mac/AOM-events.html: Added.
  • js/dom/dom-static-property-for-in-iteration-expected.txt:
  • platform/mac-wk1/TestExpectations:
Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r228822 r228827  
     12018-02-20  Nan Wang  <n_wang@apple.com>
     2
     3        AX: AOM: Dispatch accessibleclick event
     4        https://bugs.webkit.org/show_bug.cgi?id=180898
     5        <rdar://problem/36086710>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * accessibility/mac/AOM-events-expected.txt: Added.
     10        * accessibility/mac/AOM-events.html: Added.
     11        * js/dom/dom-static-property-for-in-iteration-expected.txt:
     12        * platform/mac-wk1/TestExpectations:
     13
    1142018-02-19  Dean Jackson  <dino@apple.com>
    215
  • trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt

    r228427 r228827  
    135135PASS a["innerHTML"] is nerget
    136136PASS a["outerHTML"] is <a id="foo" href="bar">nerget</a>
     137PASS a["onaccessibleclick"] is null
    137138PASS a["oncopy"] is null
    138139PASS a["oncut"] is null
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r228700 r228827  
    487487webkit.org/b/172044 [ Debug ] imported/w3c/web-platform-tests/IndexedDB/open-request-queue.html [ Pass Timeout ]
    488488
     489webkit.org/b/180898 accessibility/mac/AOM-events.html [ Skip ]
     490
    489491# User-installed fonts test infrastructure is not present in WK1
    490492webkit.org/b/180062 fast/text/user-installed-fonts [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r228825 r228827  
     12018-02-20  Nan Wang  <n_wang@apple.com>
     2
     3        AX: AOM: Dispatch accessibleclick event
     4        https://bugs.webkit.org/show_bug.cgi?id=180898
     5        <rdar://problem/36086710>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Accessibility events.
     10        Spec: https://wicg.github.io/aom/spec/phase2.html
     11
     12        This patch allows developers to register event handlers on Elements
     13        for custom accessibility events.
     14
     15        Accessibility events go through a capturing and bubbling phase just
     16        like DOM events, but in the accessibility tree.
     17
     18        Implemented "accessibleclick" event.
     19
     20        Test: accessibility/mac/AOM-events.html
     21
     22        * accessibility/AccessibilityObject.cpp:
     23        (WebCore::AccessibilityObject::press):
     24        (WebCore::AccessibilityObject::dispatchAccessibilityEvent):
     25        * accessibility/AccessibilityObject.h:
     26        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
     27        (-[WebAccessibilityObjectWrapper accessibilityPerformAction:]):
     28        * dom/Element.idl:
     29        * dom/EventDispatcher.cpp:
     30        (WebCore::dispatchEventWithType):
     31        (WebCore::EventDispatcher::dispatchEvent):
     32        * dom/EventDispatcher.h:
     33        * dom/EventNames.h:
     34        * dom/EventPath.cpp:
     35        (WebCore::EventPath::EventPath):
     36        * dom/EventPath.h:
     37
    1382018-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
    239
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r228427 r228827  
    3838#include "Editor.h"
    3939#include "ElementIterator.h"
     40#include "Event.h"
     41#include "EventDispatcher.h"
    4042#include "EventHandler.h"
    4143#include "FloatRect.h"
     
    992994        pressElement = hitTestElement;
    993995   
     996    // dispatch accessibleclick event
     997    if (auto* cache = axObjectCache()) {
     998        if (auto* pressObject = cache->getOrCreate(pressElement)) {
     999            auto event = Event::create(eventNames().accessibleclickEvent, true, true);
     1000            pressObject->dispatchAccessibilityEvent(event);
     1001            if (event->defaultPrevented())
     1002                return true;
     1003        }
     1004    }
     1005   
    9941006    UserGestureIndicator gestureIndicator(ProcessingUserGesture, document);
    9951007   
     
    21402152        return element->attributeWithoutSynchronization(attribute);
    21412153    return nullAtom();
     2154}
     2155
     2156void AccessibilityObject::dispatchAccessibilityEvent(Event& event)
     2157{
     2158    Vector<Element*> eventPath;
     2159    for (auto* parentObject = this; parentObject; parentObject = parentObject->parentObject()) {
     2160        if (auto* parentElement = parentObject->element())
     2161            eventPath.append(parentElement);
     2162    }
     2163   
     2164    EventDispatcher::dispatchEvent(eventPath, event);
    21422165}
    21432166
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r228427 r228827  
    9090class ScrollView;
    9191class Widget;
    92 
    93 enum class AXPropertyName;
    9492
    9593typedef unsigned AXID;
     
    897895    const AtomicString& getAttribute(const QualifiedName&) const;
    898896    bool hasTagName(const QualifiedName&) const;
    899 
    900     bool hasProperty(AXPropertyName) const;
    901     const String stringValueForProperty(AXPropertyName) const;
    902     std::optional<bool> boolValueForProperty(AXPropertyName) const;
    903     int intValueForProperty(AXPropertyName) const;
    904     unsigned unsignedValueForProperty(AXPropertyName) const;
    905     double doubleValueForProperty(AXPropertyName) const;
    906     Element* elementValueForProperty(AXPropertyName) const;
     897   
     898    void dispatchAccessibilityEvent(Event&);
    907899
    908900    virtual VisiblePositionRange visiblePositionRange() const { return VisiblePositionRange(); }
  • trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

    r228531 r228827  
    35783578        [self accessibilityPerformPressAction];
    35793579   
     3580    // Used in layout tests, so that we don't have to wait for the async press action.
     3581    else if ([action isEqualToString:@"AXSyncPressAction"])
     3582        [self _accessibilityPerformPressAction];
     3583   
    35803584    else if ([action isEqualToString:NSAccessibilityShowMenuAction])
    35813585        [self accessibilityPerformShowMenuAction];
  • trunk/Source/WebCore/dom/Element.idl

    r228427 r228827  
    141141    // Non standard event handler (https://developer.apple.com/reference/webkitjs/element/1629580-onwebkitplaybacktargetavailabili).
    142142    [NotEnumerable, Conditional=WIRELESS_PLAYBACK_TARGET] attribute EventHandler onwebkitplaybacktargetavailabilitychanged;
     143
     144    // Accessibility events.
     145    [EnabledAtRuntime=AccessibilityObjectModel] attribute EventHandler onaccessibleclick;
    143146};
    144147
  • trunk/Source/WebCore/dom/EventDispatcher.cpp

    r228260 r228827  
    178178}
    179179
    180 void EventDispatcher::dispatchEvent(const Vector<EventTarget*>& targets, Event& event)
     180template<typename T>
     181static void dispatchEventWithType(const Vector<T*>& targets, Event& event)
    181182{
    182183    ASSERT(targets.size() >= 1);
     
    191192}
    192193
    193 }
     194void EventDispatcher::dispatchEvent(const Vector<EventTarget*>& targets, Event& event)
     195{
     196    dispatchEventWithType<EventTarget>(targets, event);
     197}
     198
     199void EventDispatcher::dispatchEvent(const Vector<Element*>& targets, Event& event)
     200{
     201    dispatchEventWithType<Element>(targets, event);
     202}
     203
     204}
  • trunk/Source/WebCore/dom/EventDispatcher.h

    r224459 r228827  
    2525namespace WebCore {
    2626
     27class Element;
    2728class Event;
    2829class EventTarget;
     
    3334void dispatchEvent(Node&, Event&);
    3435void dispatchEvent(const Vector<EventTarget*>&, Event&);
     36void dispatchEvent(const Vector<Element*>&, Event&);
    3537
    3638void dispatchScopedEvent(Node&, Event&);
  • trunk/Source/WebCore/dom/EventNames.h

    r226766 r228827  
    4646    macro(DOMSubtreeModified) \
    4747    macro(abort) \
     48    macro(accessibleclick) \
    4849    macro(activate) \
    4950    macro(active) \
  • trunk/Source/WebCore/dom/EventPath.cpp

    r224740 r228827  
    271271}
    272272
     273EventPath::EventPath(const Vector<Element*>& targets)
     274{
     275    for (auto* target : targets) {
     276        ASSERT(target);
     277        Node* origin = *targets.begin();
     278        if (!target->isClosedShadowHidden(*origin))
     279            m_path.append(std::make_unique<EventContext>(target, target, origin));
     280    }
     281}
     282
    273283EventPath::EventPath(const Vector<EventTarget*>& targets)
    274284{
  • trunk/Source/WebCore/dom/EventPath.h

    r224615 r228827  
    3434    EventPath(Node& origin, Event&);
    3535    explicit EventPath(const Vector<EventTarget*>&);
     36    explicit EventPath(const Vector<Element*>&);
    3637
    3738    bool isEmpty() const { return m_path.isEmpty(); }
  • trunk/Tools/ChangeLog

    r228825 r228827  
     12018-02-20  Nan Wang  <n_wang@apple.com>
     2
     3        AX: AOM: Dispatch accessibleclick event
     4        https://bugs.webkit.org/show_bug.cgi?id=180898
     5        <rdar://problem/36086710>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
     10        (WTR::AccessibilityUIElement::syncPress):
     11        * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
     12        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
     13        (WTR::AccessibilityUIElement::syncPress):
     14
    1152018-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
    216
  • trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h

    r226432 r228827  
    9898    void showMenu();
    9999    void press();
     100#if PLATFORM(MAC)
     101    void syncPress();
     102#else
     103    void syncPress() { press(); }
     104#endif
    100105
    101106    // Attributes - platform-independent implementations
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl

    r226432 r228827  
    117117    void decrement();
    118118    void press();
     119    void syncPress();
    119120    void showMenu();
    120121
  • trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

    r226432 r228827  
    14331433}
    14341434
     1435void AccessibilityUIElement::syncPress()
     1436{
     1437    BEGIN_AX_OBJC_EXCEPTIONS
     1438    [m_element accessibilityPerformAction:@"AXSyncPressAction"];
     1439    END_AX_OBJC_EXCEPTIONS
     1440}
     1441
    14351442void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement* element) const
    14361443{
Note: See TracChangeset for help on using the changeset viewer.