Commit 56259ab2 authored by cfleizach@apple.com's avatar cfleizach@apple.com

<rdar://problem/5710317> REGRESSION:Selecting ranges of text should be...

<rdar://problem/5710317> REGRESSION:Selecting ranges of text should be possible using the keyboard (15310)

Adds support to select text ranges when enhanced accessibility is turned on



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f9f3710d
2008-05-16 Chris Fleizach <cfleizach@apple.com>
Reviewed by Alice Liu
<rdar://problem/5710317> REGRESSION:Selecting ranges of text should be possible using the keyboard (15310)
* WebCore.base.exp:
* editing/VisiblePosition.cpp:
(WebCore::VisiblePosition::leftVisuallyDistinctCandidate):
(WebCore::VisiblePosition::rightVisuallyDistinctCandidate):
* page/AXObjectCache.cpp:
* page/AXObjectCache.h:
(WebCore::AXObjectCache::enableEnhancedUserInterfaceAccessibility):
(WebCore::AXObjectCache::accessibilityEnabled):
(WebCore::AXObjectCache::accessibilityEnhancedUserInterfaceEnabled):
* page/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::visiblePositionRange):
(WebCore::AccessibilityRenderObject::doSetAXSelectedTextMarkerRange):
(WebCore::AccessibilityRenderObject::addChildren):
(WebCore::AccessibilityRenderObject::actionVerb):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleKeyboardSelectionMovement):
(WebCore::EventHandler::defaultKeyboardEventHandler):
* page/EventHandler.h:
2008-05-15 Ariya Hidayat <ariya.hidayat@trolltech.com>
Reviewed by Simon.
......@@ -138,6 +138,7 @@ __ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_7ElementEiib
__ZN7WebCore12TextIterator7advanceEv
__ZN7WebCore12TextIteratorC1EPKNS_5RangeEb
__ZN7WebCore13AXObjectCache21gAccessibilityEnabledE
__ZN7WebCore13AXObjectCache42gAccessibilityEnhancedUserInterfaceEnabledE
__ZN7WebCore13AXObjectCache3getEPNS_12RenderObjectE
__ZN7WebCore13HitTestResultC1ERKS0_
__ZN7WebCore13HitTestResultD1Ev
......
......@@ -105,8 +105,10 @@ VisiblePosition VisiblePosition::previous(bool stayInEditableContent) const
Position VisiblePosition::leftVisuallyDistinctCandidate() const
{
Position p = m_deepPosition;
Position downstreamStart = p.downstream();
if (!p.node())
return Position();
Position downstreamStart = p.downstream();
TextDirection primaryDirection = LTR;
for (RenderObject* r = p.node()->renderer(); r; r = r->parent()) {
if (r->isBlockFlow()) {
......@@ -244,8 +246,10 @@ VisiblePosition VisiblePosition::left(bool stayInEditableContent) const
Position VisiblePosition::rightVisuallyDistinctCandidate() const
{
Position p = m_deepPosition;
Position downstreamStart = p.downstream();
if (!p.node())
return Position();
Position downstreamStart = p.downstream();
TextDirection primaryDirection = LTR;
for (RenderObject* r = p.node()->renderer(); r; r = r->parent()) {
if (r->isBlockFlow()) {
......
......@@ -39,6 +39,7 @@
namespace WebCore {
bool AXObjectCache::gAccessibilityEnabled = false;
bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false;
AXObjectCache::~AXObjectCache()
{
......
......@@ -77,8 +77,11 @@ namespace WebCore {
void handleActiveDescendantChanged(RenderObject*);
void handleFocusedUIElementChanged();
static void enableAccessibility() { gAccessibilityEnabled = true; }
static bool accessibilityEnabled() { return gAccessibilityEnabled; }
static void enableEnhancedUserInterfaceAccessibility() { gAccessibilityEnhancedUserInterfaceEnabled = true; }
static bool accessibilityEnabled() { return gAccessibilityEnabled; }
static bool accessibilityEnhancedUserInterfaceEnabled() { return gAccessibilityEnhancedUserInterfaceEnabled; }
void removeAXID(AccessibilityObject*);
bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); }
......@@ -86,6 +89,8 @@ namespace WebCore {
HashMap<AXID, RefPtr<AccessibilityObject> > m_objects;
HashMap<RenderObject*, AXID> m_renderObjectMapping;
static bool gAccessibilityEnabled;
static bool gAccessibilityEnhancedUserInterfaceEnabled;
HashSet<AXID> m_idsInUse;
AXID getAXID(AccessibilityObject*);
......
......@@ -1211,6 +1211,9 @@ VisiblePositionRange AccessibilityRenderObject::visiblePositionRange() const
// construct VisiblePositions for start and end
Node* node = m_renderer->element();
if (!node)
return VisiblePositionRange();
VisiblePosition startPos = VisiblePosition(node, 0, VP_DEFAULT_AFFINITY);
VisiblePosition endPos = VisiblePosition(node, maxDeepOffset(node), VP_DEFAULT_AFFINITY);
......@@ -1345,9 +1348,14 @@ void AccessibilityRenderObject::doSetAXSelectedTextMarkerRange(const VisiblePosi
if (textMarkerRange.start.isNull() || textMarkerRange.end.isNull())
return;
// make selection and tell the document to use it
Selection newSelection = Selection(textMarkerRange.start, textMarkerRange.end);
m_renderer->document()->frame()->selectionController()->setSelection(newSelection);
// make selection and tell the document to use it. if it's zero length, then move to that position
if (textMarkerRange.start == textMarkerRange.end) {
m_renderer->document()->frame()->selectionController()->moveTo(textMarkerRange.start, true);
}
else {
Selection newSelection = Selection(textMarkerRange.start, textMarkerRange.end);
m_renderer->document()->frame()->selectionController()->setSelection(newSelection);
}
}
VisiblePosition AccessibilityRenderObject::doAXTextMarkerForPosition(const IntPoint& point) const
......@@ -1885,7 +1893,7 @@ void AccessibilityRenderObject::addChildren()
// add all unignored acc children
for (RefPtr<AccessibilityObject> obj = firstChild(); obj; obj = obj->nextSibling()) {
if (obj->accessibilityIsIgnored()) {
if (!m_haveChildren)
if (!obj->hasChildren())
obj->addChildren();
Vector<RefPtr<AccessibilityObject> >children = obj->children();
unsigned length = children.size();
......@@ -1991,7 +1999,7 @@ void AccessibilityRenderObject::removeAXObjectID()
#endif
}
const String& AccessibilityRenderObject::actionVerb() const
const String& AccessibilityRenderObject::actionVerb() const
{
// FIXME: Need to add verbs for select elements.
static const String buttonAction = AXButtonActionVerb();
......
......@@ -27,6 +27,7 @@
#include "config.h"
#include "EventHandler.h"
#include "AXObjectCache.h"
#include "CachedImage.h"
#include "ChromeClient.h"
#include "Cursor.h"
......@@ -1578,6 +1579,33 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
return keydownResult || keypress->defaultPrevented() || keypress->defaultHandled();
}
void EventHandler::handleKeyboardSelectionMovement(KeyboardEvent* event)
{
if (!event)
return;
String key = event->keyIdentifier();
bool isShifted = event->getModifierState("Shift");
bool isOptioned = event->getModifierState("Alt");
if (key == "Up") {
m_frame->selectionController()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::BACKWARD, LineGranularity, true);
event->setDefaultHandled();
}
else if (key == "Down") {
m_frame->selectionController()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::FORWARD, LineGranularity, true);
event->setDefaultHandled();
}
else if (key == "Left") {
m_frame->selectionController()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::LEFT, (isOptioned) ? WordGranularity : CharacterGranularity, true);
event->setDefaultHandled();
}
else if (key == "Right") {
m_frame->selectionController()->modify((isShifted) ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::RIGHT, (isOptioned) ? WordGranularity : CharacterGranularity, true);
event->setDefaultHandled();
}
}
void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
{
if (event->type() == keydownEvent) {
......@@ -1586,6 +1614,10 @@ void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
return;
if (event->keyIdentifier() == "U+0009")
defaultTabEventHandler(event);
// provides KB navigation and selection for enhanced accessibility users
if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
handleKeyboardSelectionMovement(event);
}
if (event->type() == keypressEvent) {
m_frame->editor()->handleKeyboardEvent(event);
......
......@@ -202,6 +202,8 @@ private:
bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
void handleKeyboardSelectionMovement(KeyboardEvent*);
Cursor selectCursor(const MouseEventWithHitTestResults&, PlatformScrollbar*);
void hoverTimerFired(Timer<EventHandler>*);
......
2008-05-16 Chris Fleizach <cfleizach@apple.com>
Reviewed by Alice Liu
<rdar://problem/5710317> REGRESSION:Selecting ranges of text should be possible using the keyboard (15310)
* WebView/WebFrame.mm:
(-[WebFrame _accessibilityTree]):
2008-05-15 Stephanie Lewis <slewis@apple.com>
fix mac build
......
......@@ -120,6 +120,9 @@ NSString *WebPageCacheEntryDateKey = @"WebPageCacheEntryDateKey";
NSString *WebPageCacheDataSourceKey = @"WebPageCacheDataSourceKey";
NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
// FIXME: Remove when this key becomes publicly defined
NSString *NSAccessibilityEnhancedUserInterfaceAttribute = @"AXEnhancedUserInterface";
@implementation WebFramePrivate
- (void)dealloc
......@@ -669,7 +672,12 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
- (id)_accessibilityTree
{
AXObjectCache::enableAccessibility();
if (!AXObjectCache::accessibilityEnabled()) {
AXObjectCache::enableAccessibility();
if ([[NSApp accessibilityAttributeValue:NSAccessibilityEnhancedUserInterfaceAttribute] boolValue])
AXObjectCache::enableEnhancedUserInterfaceAccessibility();
}
if (!_private->coreFrame || !_private->coreFrame->document())
return nil;
RenderView* root = static_cast<RenderView *>(_private->coreFrame->document()->renderer());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment