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

Changeset 181484 in webkit


Ignore:
Timestamp:
Mar 13, 2015, 12:24:01 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

AX: Provide API for assistive tech to ignore DOM key event handlers
https://bugs.webkit.org/show_bug.cgi?id=142059

Patch by Doug Russell <d_russell@apple.com> on 2015-03-13
Reviewed by Beth Dakin.

Assistive technology applications on the desktop are heavily dependent on keyboard navigation being reliable. This is greatly hindered by sites that handle key events without updating keyboard selection and then consume the event. It is important for assistive technology apps to allow users to decide to ignore these handlers that are incorrect for their purposes.

This can be fixed by exposing, via a new accessibility attribute, a way to decide, for a given WebCore::Frame, to pre-empt DOM dispatch and instead let accessibility caret browsing take place.

Source/WebCore:

Test: platform/mac/accessibility/prevent-keyboard-event-dispatch.html

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::preventKeyboardDOMEventDispatch):
(WebCore::AccessibilityObject::setPreventKeyboardDOMEventDispatch):

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

(-[WebAccessibilityObjectWrapper accessibilityAttributeNames]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
(-[WebAccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
(-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):

  • dom/Element.cpp:

(WebCore::Element::dispatchKeyEvent):

  • page/EventHandler.cpp:

(WebCore::EventHandler::keyEvent):
(WebCore::handleKeyboardSelectionMovement):
(WebCore::EventHandler::handleKeyboardSelectionMovementForAccessibility):

  • page/EventHandler.h:
  • page/Settings.in:

LayoutTests:

  • accessibility/parent-delete-expected.txt:
  • platform/mac/accessibility/document-attributes-expected.txt:
  • platform/mac/accessibility/prevent-keyboard-event-dispatch-expected.txt: Added.
  • platform/mac/accessibility/prevent-keyboard-event-dispatch.html: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181480 r181484  
     12015-03-13  Doug Russell  <d_russell@apple.com>
     2
     3        AX: Provide API for assistive tech to ignore DOM key event handlers
     4        https://bugs.webkit.org/show_bug.cgi?id=142059
     5
     6        Reviewed by Beth Dakin.
     7
     8        Assistive technology applications on the desktop are heavily dependent on keyboard navigation being reliable. This is greatly hindered by sites that handle key events without updating keyboard selection and then consume the event. It is important for assistive technology apps to allow users to decide to ignore these handlers that are incorrect for their purposes.
     9
     10        This can be fixed by exposing, via a new accessibility attribute, a way to decide, for a given WebCore::Frame, to pre-empt DOM dispatch and instead let accessibility caret browsing take place.
     11
     12        * accessibility/parent-delete-expected.txt:
     13        * platform/mac/accessibility/document-attributes-expected.txt:
     14        * platform/mac/accessibility/prevent-keyboard-event-dispatch-expected.txt: Added.
     15        * platform/mac/accessibility/prevent-keyboard-event-dispatch.html: Added.
     16
    1172015-03-13  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/LayoutTests/accessibility/parent-delete-expected.txt

    r180718 r181484  
    2929AXURL: LayoutTests/accessibility/parent-delete.html
    3030AXCaretBrowsingEnabled: 0
     31AXPreventKeyboardDOMEventDispatch: 0
    3132AXElementBusy: 0
    3233
  • trunk/LayoutTests/platform/mac/accessibility/document-attributes-expected.txt

    r180718 r181484  
    2828AXURL: LayoutTests/platform/mac/accessibility/document-attributes.html
    2929AXCaretBrowsingEnabled: 0
     30AXPreventKeyboardDOMEventDispatch: 0
    3031AXElementBusy: 0
    3132
  • trunk/Source/WebCore/ChangeLog

    r181483 r181484  
     12015-03-13  Doug Russell  <d_russell@apple.com>
     2
     3        AX: Provide API for assistive tech to ignore DOM key event handlers
     4        https://bugs.webkit.org/show_bug.cgi?id=142059
     5
     6        Reviewed by Beth Dakin.
     7
     8        Assistive technology applications on the desktop are heavily dependent on keyboard navigation being reliable. This is greatly hindered by sites that handle key events without updating keyboard selection and then consume the event. It is important for assistive technology apps to allow users to decide to ignore these handlers that are incorrect for their purposes.
     9
     10        This can be fixed by exposing, via a new accessibility attribute, a way to decide, for a given WebCore::Frame, to pre-empt DOM dispatch and instead let accessibility caret browsing take place.
     11
     12        Test: platform/mac/accessibility/prevent-keyboard-event-dispatch.html
     13
     14        * accessibility/AccessibilityObject.cpp:
     15        (WebCore::AccessibilityObject::preventKeyboardDOMEventDispatch):
     16        (WebCore::AccessibilityObject::setPreventKeyboardDOMEventDispatch):
     17        * accessibility/AccessibilityObject.h:
     18        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
     19        (-[WebAccessibilityObjectWrapper accessibilityAttributeNames]):
     20        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
     21        (-[WebAccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
     22        (-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):
     23        * dom/Element.cpp:
     24        (WebCore::Element::dispatchKeyEvent):
     25        * page/EventHandler.cpp:
     26        (WebCore::EventHandler::keyEvent):
     27        (WebCore::handleKeyboardSelectionMovement):
     28        (WebCore::EventHandler::handleKeyboardSelectionMovementForAccessibility):
     29        * page/EventHandler.h:
     30        * page/Settings.in:
     31
    1322015-03-09  Conrad Shultz  <conrad_shultz@apple.com>
    233
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r181408 r181484  
    26062606}
    26072607
     2608#if PLATFORM(COCOA)
     2609bool AccessibilityObject::preventKeyboardDOMEventDispatch() const
     2610{
     2611    Frame* frame = this->frame();
     2612    return frame && frame->settings().preventKeyboardDOMEventDispatch();
     2613}
     2614
     2615void AccessibilityObject::setPreventKeyboardDOMEventDispatch(bool on)
     2616{
     2617    Frame* frame = this->frame();
     2618    if (!frame)
     2619        return;
     2620    frame->settings().setPreventKeyboardDOMEventDispatch(on);
     2621}
     2622#endif
     2623
    26082624} // namespace WebCore
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r180718 r181484  
    979979    void updateBackingStore();
    980980   
     981#if PLATFORM(COCOA)
     982    bool preventKeyboardDOMEventDispatch() const;
     983    void setPreventKeyboardDOMEventDispatch(bool);
     984#endif
     985   
    981986#if PLATFORM(COCOA) && !PLATFORM(IOS)
    982987    bool caretBrowsingEnabled() const;
  • trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

    r180718 r181484  
    464464#define NSAccessibilityMathPrescriptsAttribute @"AXMathPrescripts"
    465465#define NSAccessibilityMathPostscriptsAttribute @"AXMathPostscripts"
     466
     467#ifndef NSAccessibilityPreventKeyboardDOMEventDispatchAttribute
     468#define NSAccessibilityPreventKeyboardDOMEventDispatchAttribute @"AXPreventKeyboardDOMEventDispatch"
     469#endif
    466470
    467471#ifndef NSAccessibilityCaretBrowsingEnabledAttribute
     
    13601364        [tempArray addObject:NSAccessibilityURLAttribute];
    13611365        [tempArray addObject:NSAccessibilityCaretBrowsingEnabledAttribute];
     1366        [tempArray addObject:NSAccessibilityPreventKeyboardDOMEventDispatchAttribute];
    13621367        webAreaAttrs = [[NSArray alloc] initWithArray:tempArray];
    13631368        [tempArray release];
     
    29592964        return m_object->getAttribute(idAttr);
    29602965   
     2966    if (m_object->isWebArea() && [attributeName isEqualToString:NSAccessibilityPreventKeyboardDOMEventDispatchAttribute])
     2967        return [NSNumber numberWithBool:m_object->preventKeyboardDOMEventDispatch()];
     2968   
    29612969    if (m_object->isWebArea() && [attributeName isEqualToString:NSAccessibilityCaretBrowsingEnabledAttribute])
    29622970        return [NSNumber numberWithBool:m_object->caretBrowsingEnabled()];
     
    30323040   
    30333041    if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
     3042        return YES;
     3043   
     3044    if (m_object->isWebArea() && [attributeName isEqualToString:NSAccessibilityPreventKeyboardDOMEventDispatchAttribute])
    30343045        return YES;
    30353046   
     
    33533364    } else if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
    33543365        m_object->setARIAGrabbed([number boolValue]);
     3366    else if (m_object->isWebArea() && [attributeName isEqualToString:NSAccessibilityPreventKeyboardDOMEventDispatchAttribute])
     3367        m_object->setPreventKeyboardDOMEventDispatch([number boolValue]);
    33553368    else if (m_object->isWebArea() && [attributeName isEqualToString:NSAccessibilityCaretBrowsingEnabledAttribute])
    33563369        m_object->setCaretBrowsingEnabled([number boolValue]);
  • trunk/Source/WebCore/dom/Element.cpp

    r181396 r181484  
    4040#include "ElementRareData.h"
    4141#include "EventDispatcher.h"
     42#include "EventHandler.h"
    4243#include "FlowThreadController.h"
    4344#include "FocusController.h"
     
    290291{
    291292    RefPtr<KeyboardEvent> event = KeyboardEvent::create(platformEvent, document().defaultView());
     293    if (Frame* frame = document().frame()) {
     294        if (frame->eventHandler().accessibilityPreventsEventPropogation(event.get()))
     295            event->stopPropagation();
     296    }
    292297    return EventDispatcher::dispatchEvent(this, event) && !event->defaultHandled();
    293298}
  • trunk/Source/WebCore/page/EventHandler.cpp

    r181420 r181484  
    30883088        keydown->setDefaultHandled();
    30893089    }
     3090   
     3091    if (accessibilityPreventsEventPropogation(keydown.get()))
     3092        keydown->stopPropagation();
    30903093
    30913094    element->dispatchEvent(keydown, IGNORE_EXCEPTION);
     
    32293232            handleKeyboardSelectionMovement(m_frame, event);
    32303233    }
     3234}
     3235
     3236bool EventHandler::accessibilityPreventsEventPropogation(KeyboardEvent* event)
     3237{
     3238#if PLATFORM(COCOA)
     3239    if (!AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
     3240        return false;
     3241
     3242    if (!m_frame.settings().preventKeyboardDOMEventDispatch())
     3243        return false;
     3244
     3245    // Check for key events that are relevant to accessibility: tab and arrows keys that change focus
     3246    if (event->keyIdentifier() == "U+0009")
     3247        return true;
     3248    FocusDirection direction = focusDirectionForKey(event->keyIdentifier());
     3249    if (direction != FocusDirectionNone)
     3250        return true;
     3251#else
     3252    UNUSED_PARAM(event);
     3253#endif
     3254    return false;
    32313255}
    32323256
  • trunk/Source/WebCore/page/EventHandler.h

    r180548 r181484  
    240240    void defaultKeyboardEventHandler(KeyboardEvent*);
    241241
     242    bool accessibilityPreventsEventPropogation(KeyboardEvent*);
    242243    WEBCORE_EXPORT void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent*);
    243244
  • trunk/Source/WebCore/page/Settings.in

    r181134 r181484  
    4646
    4747caretBrowsingEnabled initial=false
     48preventKeyboardDOMEventDispatch initial=false
    4849localStorageEnabled initial=false
    4950allowUniversalAccessFromFileURLs initial=true
Note: See TracChangeset for help on using the changeset viewer.