Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_win.cc |
| =================================================================== |
| --- content/browser/accessibility/browser_accessibility_win.cc (revision 112482) |
| +++ content/browser/accessibility/browser_accessibility_win.cc (working copy) |
| @@ -683,6 +683,83 @@ |
| return S_OK; |
| } |
| +STDMETHODIMP BrowserAccessibilityWin::scrollTo(enum IA2ScrollType scroll_type) { |
| + if (!instance_active_) |
| + return E_FAIL; |
| + |
| + // TODO(dmazzoni): Extend this to scroll every scrollable element as |
| + // needed, not just the root. |
| + BrowserAccessibility* root = this; |
| + while (root->parent()) |
| + root = root->parent(); |
| + |
| + gfx::Rect r = location_; |
| + gfx::Rect view(-1000000, -1000000, 1000000, 1000000); |
|
David Tseng
2011/12/02 00:51:51
#include <limits>
...
std::numeric_limits<int>::m
dmazzoni
2011/12/03 00:37:10
Done.
|
| + switch(scroll_type) { |
| + case IA2_SCROLL_TYPE_TOP_LEFT: |
|
David Tseng
2011/12/02 00:51:51
indent
dmazzoni
2011/12/03 00:37:10
Done.
|
| + root->ScrollToMakeVisible(gfx::Rect(r.x(), r.y(), 0, 0), r, view); |
| + break; |
| + case IA2_SCROLL_TYPE_BOTTOM_RIGHT: |
| + root->ScrollToMakeVisible(gfx::Rect(r.right(), r.bottom(), 0, 0), r, view); |
| + break; |
| + case IA2_SCROLL_TYPE_TOP_EDGE: |
| + root->ScrollToMakeVisible(gfx::Rect(r.x(), r.y(), r.width(), 0), r, view); |
| + break; |
| + case IA2_SCROLL_TYPE_BOTTOM_EDGE: |
| + root->ScrollToMakeVisible( |
| + gfx::Rect(r.x(), r.bottom(), r.width(), 0), r, view); |
| + break; |
| + case IA2_SCROLL_TYPE_LEFT_EDGE: |
| + root->ScrollToMakeVisible(gfx::Rect(r.x(), r.y(), 0, r.height()), r, view); |
| + break; |
| + case IA2_SCROLL_TYPE_RIGHT_EDGE: |
| + root->ScrollToMakeVisible( |
| + gfx::Rect(r.right(), r.y(), 0, r.height()), r, view); |
| + break; |
| + case IA2_SCROLL_TYPE_ANYWHERE: |
| + default: |
| + root->ScrollToMakeVisible(r, r, view); |
| + break; |
| + } |
| + |
| + return S_OK; |
| +} |
| + |
| +STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( |
| + enum IA2CoordinateType coordinate_type, |
| + LONG x, |
| + LONG y) { |
| + if (!instance_active_) |
| + return E_FAIL; |
| + |
| + // TODO(dmazzoni): Extend this to scroll every scrollable element as |
| + // needed, not just the root. |
| + BrowserAccessibility* root = this; |
| + while (root->parent()) |
| + root = root->parent(); |
| + |
| + if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
|
David Tseng
2011/12/02 00:51:51
switch? Are we not handling all the cord types?
dmazzoni
2011/12/03 00:37:10
Actually there are only two.
|
| + gfx::Point top_left = manager_->GetViewBounds().origin(); |
| + x -= top_left.x(); |
| + y -= top_left.y(); |
| + } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| + if (parent_) { |
| + gfx::Rect parent_bounds = parent_->location(); |
| + x += parent_bounds.x(); |
| + y += parent_bounds.y(); |
| + } |
| + } else { |
| + return E_INVALIDARG; |
| + } |
| + |
| + gfx::Rect r = location_; |
| + root->ScrollToMakeVisible(gfx::Rect(r.x(), r.y(), 0, 0), |
| + r, |
| + gfx::Rect(x, y, 0, 0)); |
| + |
| + return S_OK; |
| +} |
| + |
| // |
| // IAccessibleImage methods. |
| // |
| @@ -1853,6 +1930,74 @@ |
| return S_OK; |
| } |
| +STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo( |
| + LONG start_index, |
| + LONG end_index, |
| + enum IA2ScrollType scroll_type) { |
| + // TODO(dmazzoni): adjust this for the start and end index, too. |
| + return scrollTo(scroll_type); |
| +} |
| + |
| +STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( |
| + LONG start_index, |
| + LONG end_index, |
| + enum IA2CoordinateType coordinate_type, |
| + LONG x, LONG y) { |
| + // TODO(dmazzoni): adjust this for the start and end index, too. |
| + return scrollToPoint(coordinate_type, x, y); |
| +} |
| + |
| +STDMETHODIMP BrowserAccessibilityWin::addSelection( |
|
David Tseng
2011/12/02 00:51:51
Part of another patch?
dmazzoni
2011/12/03 00:37:10
Yep, sorry. Gone now.
|
| + LONG start_offset, LONG end_offset) { |
| + if (!instance_active_) |
| + return E_FAIL; |
| + |
| + const string16& text_str = TextForIAccessibleText(); |
| + HandleSpecialTextOffset(text_str, &start_offset); |
| + HandleSpecialTextOffset(text_str, &end_offset); |
| + |
| + manager_->SetTextSelection(*this, start_offset, end_offset); |
| + return S_OK; |
| +} |
| + |
| +STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { |
| + if (!instance_active_) |
| + return E_FAIL; |
| + |
| + if (selection_index != 0) |
| + return E_INVALIDARG; |
| + |
| + manager_->SetTextSelection(*this, 0, 0); |
| + return S_OK; |
| +} |
| + |
| +STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { |
| + if (!instance_active_) |
| + return E_FAIL; |
| + |
| + const string16& text_str = TextForIAccessibleText(); |
| + HandleSpecialTextOffset(text_str, &offset); |
| + manager_->SetTextSelection(*this, offset, offset); |
| + return S_OK; |
| +} |
| + |
| +STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, |
| + LONG start_offset, |
| + LONG end_offset) { |
| + if (!instance_active_) |
| + return E_FAIL; |
| + |
| + if (selection_index != 0) |
| + return E_INVALIDARG; |
| + |
| + const string16& text_str = TextForIAccessibleText(); |
| + HandleSpecialTextOffset(text_str, &start_offset); |
| + HandleSpecialTextOffset(text_str, &end_offset); |
| + |
| + manager_->SetTextSelection(*this, start_offset, end_offset); |
| + return S_OK; |
| +} |
| + |
| // |
| // IAccessibleValue methods. |
| // |
| @@ -2115,7 +2260,9 @@ |
| } |
| STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { |
| - return E_NOTIMPL; |
| + return scrollTo(placeTopLeft ? |
| + IA2_SCROLL_TYPE_TOP_LEFT : |
| + IA2_SCROLL_TYPE_ANYWHERE); |
| } |
| STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { |