Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: ui/views/accessibility/native_view_accessibility_win.cc

Issue 57833004: Always check if View::GetWidget() is NULL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_)
257 return E_FAIL; 257 return E_FAIL;
sky 2013/11/04 21:06:36 Should the check for widget be moved here?
dmazzoni 2013/11/04 21:12:16 That seems reasonable. If there's no widget, it ca
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() && 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 =
267 child_widget->GetRootView()->GetNativeViewAccessible(); 267 child_widget->GetRootView()->GetNativeViewAccessible();
268 HRESULT result = child_accessible->accHitTest(x_left, y_top, child); 268 HRESULT result = child_accessible->accHitTest(x_left, y_top, child);
269 if (result == S_OK) 269 if (result == S_OK)
270 return result; 270 return result;
271 } 271 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
475 std::vector<Widget*> child_widgets; 475 std::vector<Widget*> child_widgets;
476 if (view_->GetWidget()->GetRootView() == view_) 476 if (view_->GetWidget() && view_->GetWidget()->GetRootView() == view_)
477 PopulateChildWidgetVector(&child_widgets); 477 PopulateChildWidgetVector(&child_widgets);
478 int child_widget_count = static_cast<int>(child_widgets.size()); 478 int child_widget_count = static_cast<int>(child_widgets.size());
479 479
480 View* child_view = NULL; 480 View* child_view = NULL;
481 if (child_id > 0) { 481 if (child_id > 0) {
482 // Positive child ids are a 1-based child index, used by clients 482 // Positive child ids are a 1-based child index, used by clients
483 // that want to enumerate all immediate children. 483 // that want to enumerate all immediate children.
484 int child_id_as_index = child_id - 1; 484 int child_id_as_index = child_id - 1;
485 if (child_id_as_index < view_->child_count()) { 485 if (child_id_as_index < view_->child_count()) {
486 child_view = view_->child_at(child_id_as_index); 486 child_view = view_->child_at(child_id_as_index);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_)
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() && 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();
547 } 547 }
548 548
549 return S_OK; 549 return S_OK;
550 } 550 }
551 551
552 STDMETHODIMP NativeViewAccessibilityWin::get_accDefaultAction( 552 STDMETHODIMP NativeViewAccessibilityWin::get_accDefaultAction(
553 VARIANT var_id, BSTR* def_action) { 553 VARIANT var_id, BSTR* def_action) {
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698