diff options
author | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 21:47:32 +0000 |
---|---|---|
committer | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 21:47:32 +0000 |
commit | 8052999773954f5a4144d810c651c634a4730c7c (patch) | |
tree | e08e2f973526913d6ac93bba0cf95b57de786d42 /views | |
parent | ffb1e9fe7c9a3ab90617d35c0f55e9ba0717f2aa (diff) | |
download | chromium_src-8052999773954f5a4144d810c651c634a4730c7c.zip chromium_src-8052999773954f5a4144d810c651c634a4730c7c.tar.gz chromium_src-8052999773954f5a4144d810c651c634a4730c7c.tar.bz2 |
Return the IAccessible interface of the deepest descent that contains the speficied point in view accessibility's accHitTest.
Previously accHitTest would
1. Only return a direct child that contained the specified point (accHitTest was called repeatedly until it returned CHILDID_SELF).
2. Always return a VT_I4 variant for a view that has no children instead of returing an IAccessible interface (which didn't work with the AT programs for some reason).
BUG=none
TEST=Manual: NVDA reads views on mouse overwith no children on mouse over like toolbar buttons.
TEST=Manual: AccExplorer32 and Inspect32 can select views with no children.
Review URL: http://codereview.chromium.org/3890003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/accessibility/view_accessibility.cc | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/views/accessibility/view_accessibility.cc b/views/accessibility/view_accessibility.cc index 2bb7c55..bd1d32d 100644 --- a/views/accessibility/view_accessibility.cc +++ b/views/accessibility/view_accessibility.cc @@ -27,59 +27,36 @@ HRESULT ViewAccessibility::Initialize(views::View* view) { // TODO(ctguil): Handle case where child View is not contained by parent. STDMETHODIMP ViewAccessibility::accHitTest( LONG x_left, LONG y_top, VARIANT* child) { - if (!child) { + if (!child) return E_INVALIDARG; - } if (!view_) return E_FAIL; - gfx::Point pt(x_left, y_top); - views::View::ConvertPointToView(NULL, view_, &pt); + gfx::Point point(x_left, y_top); + views::View::ConvertPointToView(NULL, view_, &point); - if (!view_->HitTest(pt)) { + if (!view_->HitTest(point)) { // If containing parent is not hit, return with failure. child->vt = VT_EMPTY; return S_FALSE; } - int child_count = view_->GetChildViewCount(); - bool child_hit = false; - views::View* child_view = NULL; - for (int child_id = 0; child_id < child_count; ++child_id) { - // Search for hit within any of the children. - child_view = view_->GetChildViewAt(child_id); - views::View::ConvertPointToView(view_, child_view, &pt); - if (child_view->HitTest(pt)) { - // Store child_id (adjusted with +1 to convert to MSAA indexing). - child->lVal = child_id + 1; - child_hit = true; - break; - } - // Convert point back to parent view to test next child. - views::View::ConvertPointToView(child_view, view_, &pt); - } - - child->vt = VT_I4; - - if (!child_hit) { + views::View* view = view_->GetViewForPoint(point); + if (view == view_) { // No child hit, return parent id. + child->vt = VT_I4; child->lVal = CHILDID_SELF; } else { - if (child_view == NULL) { - return E_FAIL; - } else if (child_view->GetChildViewCount() != 0) { - // Retrieve IDispatch for child, if it is not a leaf. - child->vt = VT_DISPATCH; - if ((GetViewAccessibilityWrapper(child_view))-> - GetInstance(IID_IAccessible, - reinterpret_cast<void**>(&child->pdispVal)) == S_OK) { - // Increment the reference count for the retrieved interface. - child->pdispVal->AddRef(); - return S_OK; - } else { - return E_NOINTERFACE; - } + child->vt = VT_DISPATCH; + if ((GetViewAccessibilityWrapper(view))-> + GetInstance(IID_IAccessible, + reinterpret_cast<void**>(&child->pdispVal)) == S_OK) { + // Increment the reference count for the retrieved interface. + child->pdispVal->AddRef(); + return S_OK; + } else { + return E_NOINTERFACE; } } |