OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/accessibility/native_view_accessibility_win.h" | 5 #include "ui/views/accessibility/native_view_accessibility_win.h" |
6 | 6 |
7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
8 #include <oleacc.h> | 8 #include <oleacc.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 void NativeViewAccessibilityWin::Destroy() { | 246 void NativeViewAccessibilityWin::Destroy() { |
247 view_ = NULL; | 247 view_ = NULL; |
248 Release(); | 248 Release(); |
249 } | 249 } |
250 | 250 |
251 STDMETHODIMP NativeViewAccessibilityWin::accHitTest( | 251 STDMETHODIMP NativeViewAccessibilityWin::accHitTest( |
252 LONG x_left, LONG y_top, VARIANT* child) { | 252 LONG x_left, LONG y_top, VARIANT* child) { |
253 if (!child) | 253 if (!child) |
254 return E_INVALIDARG; | 254 return E_INVALIDARG; |
255 | 255 |
256 if (!view_) | 256 if (!view_ || !view_->GetWidget()) |
257 return E_FAIL; | 257 return E_FAIL; |
258 | 258 |
259 // If this is a root view, our widget might have child widgets. | 259 // If this is a root view, our widget might have child widgets. |
260 // Search child widgets first, since they're on top in the z-order. | 260 // Search child widgets first, since they're on top in the z-order. |
261 if (view_->GetWidget()->GetRootView() == view_) { | 261 if (view_->GetWidget()->GetRootView() == view_) { |
262 std::vector<Widget*> child_widgets; | 262 std::vector<Widget*> child_widgets; |
263 PopulateChildWidgetVector(&child_widgets); | 263 PopulateChildWidgetVector(&child_widgets); |
264 for (size_t i = 0; i < child_widgets.size(); ++i) { | 264 for (size_t i = 0; i < child_widgets.size(); ++i) { |
265 Widget* child_widget = child_widgets[i]; | 265 Widget* child_widget = child_widgets[i]; |
266 IAccessible* child_accessible = | 266 IAccessible* child_accessible = |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 // Navigation performed correctly. Global return for this function, if no | 454 // Navigation performed correctly. Global return for this function, if no |
455 // error triggered an escape earlier. | 455 // error triggered an escape earlier. |
456 return S_OK; | 456 return S_OK; |
457 } | 457 } |
458 | 458 |
459 STDMETHODIMP NativeViewAccessibilityWin::get_accChild(VARIANT var_child, | 459 STDMETHODIMP NativeViewAccessibilityWin::get_accChild(VARIANT var_child, |
460 IDispatch** disp_child) { | 460 IDispatch** disp_child) { |
461 if (var_child.vt != VT_I4 || !disp_child) | 461 if (var_child.vt != VT_I4 || !disp_child) |
462 return E_INVALIDARG; | 462 return E_INVALIDARG; |
463 | 463 |
464 if (!view_) | 464 if (!view_ || !view_->GetWidget()) |
465 return E_FAIL; | 465 return E_FAIL; |
466 | 466 |
467 LONG child_id = V_I4(&var_child); | 467 LONG child_id = V_I4(&var_child); |
468 | 468 |
469 if (child_id == CHILDID_SELF) { | 469 if (child_id == CHILDID_SELF) { |
470 // Remain with the same dispatch. | 470 // Remain with the same dispatch. |
471 return S_OK; | 471 return S_OK; |
472 } | 472 } |
473 | 473 |
474 // If this is a root view, our widget might have child widgets. Include | 474 // If this is a root view, our widget might have child widgets. Include |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 526 |
527 *disp_child = child_view->GetNativeViewAccessible(); | 527 *disp_child = child_view->GetNativeViewAccessible(); |
528 (*disp_child)->AddRef(); | 528 (*disp_child)->AddRef(); |
529 return S_OK; | 529 return S_OK; |
530 } | 530 } |
531 | 531 |
532 STDMETHODIMP NativeViewAccessibilityWin::get_accChildCount(LONG* child_count) { | 532 STDMETHODIMP NativeViewAccessibilityWin::get_accChildCount(LONG* child_count) { |
533 if (!child_count || !view_) | 533 if (!child_count || !view_) |
534 return E_INVALIDARG; | 534 return E_INVALIDARG; |
535 | 535 |
536 if (!view_) | 536 if (!view_ || !view_->GetWidget()) |
sky
2013/11/04 21:26:09
nit: you've got !view_ on 533 too.
dmazzoni
2013/11/04 21:31:19
Done.
| |
537 return E_FAIL; | 537 return E_FAIL; |
538 | 538 |
539 *child_count = view_->child_count(); | 539 *child_count = view_->child_count(); |
540 | 540 |
541 // If this is a root view, our widget might have child widgets. Include | 541 // If this is a root view, our widget might have child widgets. Include |
542 // them, too. | 542 // them, too. |
543 if (view_->GetWidget()->GetRootView() == view_) { | 543 if (view_->GetWidget()->GetRootView() == view_) { |
544 std::vector<Widget*> child_widgets; | 544 std::vector<Widget*> child_widgets; |
545 PopulateChildWidgetVector(&child_widgets); | 545 PopulateChildWidgetVector(&child_widgets); |
546 *child_count += child_widgets.size(); | 546 *child_count += child_widgets.size(); |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1385 HandleSpecialTextOffset(text, &start_offset); | 1385 HandleSpecialTextOffset(text, &start_offset); |
1386 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 1386 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
1387 std::vector<int32> line_breaks; | 1387 std::vector<int32> line_breaks; |
1388 return ui::FindAccessibleTextBoundary( | 1388 return ui::FindAccessibleTextBoundary( |
1389 text, line_breaks, boundary, start_offset, direction); | 1389 text, line_breaks, boundary, start_offset, direction); |
1390 } | 1390 } |
1391 | 1391 |
1392 void NativeViewAccessibilityWin::PopulateChildWidgetVector( | 1392 void NativeViewAccessibilityWin::PopulateChildWidgetVector( |
1393 std::vector<Widget*>* result_child_widgets) { | 1393 std::vector<Widget*>* result_child_widgets) { |
1394 const Widget* widget = view()->GetWidget(); | 1394 const Widget* widget = view()->GetWidget(); |
1395 if (!widget) | |
1396 return; | |
1397 | |
1395 std::set<Widget*> child_widgets; | 1398 std::set<Widget*> child_widgets; |
1396 Widget::GetAllChildWidgets(widget->GetNativeView(), &child_widgets); | 1399 Widget::GetAllChildWidgets(widget->GetNativeView(), &child_widgets); |
1397 Widget::GetAllOwnedWidgets(widget->GetNativeView(), &child_widgets); | 1400 Widget::GetAllOwnedWidgets(widget->GetNativeView(), &child_widgets); |
1398 for (std::set<Widget*>::const_iterator iter = child_widgets.begin(); | 1401 for (std::set<Widget*>::const_iterator iter = child_widgets.begin(); |
1399 iter != child_widgets.end(); ++iter) { | 1402 iter != child_widgets.end(); ++iter) { |
1400 Widget* child_widget = *iter; | 1403 Widget* child_widget = *iter; |
1401 if (child_widget == widget) | 1404 if (child_widget == widget) |
1402 continue; | 1405 continue; |
1403 | 1406 |
1404 if (!child_widget->IsVisible()) | 1407 if (!child_widget->IsVisible()) |
1405 continue; | 1408 continue; |
1406 | 1409 |
1407 if (widget->GetNativeWindowProperty(kWidgetNativeViewHostKey)) | 1410 if (widget->GetNativeWindowProperty(kWidgetNativeViewHostKey)) |
1408 continue; | 1411 continue; |
1409 | 1412 |
1410 result_child_widgets->push_back(child_widget); | 1413 result_child_widgets->push_back(child_widget); |
1411 } | 1414 } |
1412 } | 1415 } |
1413 | 1416 |
1414 } // namespace views | 1417 } // namespace views |
OLD | NEW |