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

Side by Side Diff: content/browser/accessibility/browser_accessibility_win.cc

Issue 642313003: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Including id in the AUTHORS file. Created 6 years, 2 months 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
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 "content/browser/accessibility/browser_accessibility_win.h" 5 #include "content/browser/accessibility/browser_accessibility_win.h"
6 6
7 #include <UIAutomationClient.h> 7 #include <UIAutomationClient.h>
8 #include <UIAutomationCoreApi.h> 8 #include <UIAutomationCoreApi.h>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return E_INVALIDARG; 298 return E_INVALIDARG;
299 299
300 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && 300 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) &&
301 start.lVal != CHILDID_SELF) { 301 start.lVal != CHILDID_SELF) {
302 // MSAA states that navigating to first/last child can only be from self. 302 // MSAA states that navigating to first/last child can only be from self.
303 return E_INVALIDARG; 303 return E_INVALIDARG;
304 } 304 }
305 305
306 uint32 child_count = target->PlatformChildCount(); 306 uint32 child_count = target->PlatformChildCount();
307 307
308 BrowserAccessibility* result = NULL; 308 BrowserAccessibility* result = nullptr;
309 switch (nav_dir) { 309 switch (nav_dir) {
310 case NAVDIR_DOWN: 310 case NAVDIR_DOWN:
311 case NAVDIR_UP: 311 case NAVDIR_UP:
312 case NAVDIR_LEFT: 312 case NAVDIR_LEFT:
313 case NAVDIR_RIGHT: 313 case NAVDIR_RIGHT:
314 // These directions are not implemented, matching Mozilla and IE. 314 // These directions are not implemented, matching Mozilla and IE.
315 return E_NOTIMPL; 315 return E_NOTIMPL;
316 case NAVDIR_FIRSTCHILD: 316 case NAVDIR_FIRSTCHILD:
317 if (child_count > 0) 317 if (child_count > 0)
318 result = target->PlatformGetChild(0); 318 result = target->PlatformGetChild(0);
(...skipping 21 matching lines...) Expand all
340 } 340 }
341 341
342 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, 342 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child,
343 IDispatch** disp_child) { 343 IDispatch** disp_child) {
344 if (!instance_active()) 344 if (!instance_active())
345 return E_FAIL; 345 return E_FAIL;
346 346
347 if (!disp_child) 347 if (!disp_child)
348 return E_INVALIDARG; 348 return E_INVALIDARG;
349 349
350 *disp_child = NULL; 350 *disp_child = nullptr;
351 351
352 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child); 352 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child);
353 if (!target) 353 if (!target)
354 return E_INVALIDARG; 354 return E_INVALIDARG;
355 355
356 (*disp_child) = target->NewReference(); 356 (*disp_child) = target->NewReference();
357 return S_OK; 357 return S_OK;
358 } 358 }
359 359
360 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { 360 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 return E_FAIL; 406 return E_FAIL;
407 407
408 if (!focus_child) 408 if (!focus_child)
409 return E_INVALIDARG; 409 return E_INVALIDARG;
410 410
411 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>( 411 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>(
412 manager()->GetFocus(this)); 412 manager()->GetFocus(this));
413 if (focus == this) { 413 if (focus == this) {
414 focus_child->vt = VT_I4; 414 focus_child->vt = VT_I4;
415 focus_child->lVal = CHILDID_SELF; 415 focus_child->lVal = CHILDID_SELF;
416 } else if (focus == NULL) { 416 } else if (focus == nullptr) {
417 focus_child->vt = VT_EMPTY; 417 focus_child->vt = VT_EMPTY;
418 } else { 418 } else {
419 focus_child->vt = VT_DISPATCH; 419 focus_child->vt = VT_DISPATCH;
420 focus_child->pdispVal = focus->NewReference(); 420 focus_child->pdispVal = focus->NewReference();
421 } 421 }
422 422
423 return S_OK; 423 return S_OK;
424 } 424 }
425 425
426 STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { 426 STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 489 }
490 490
491 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { 491 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) {
492 if (!instance_active()) 492 if (!instance_active())
493 return E_FAIL; 493 return E_FAIL;
494 494
495 if (!disp_parent) 495 if (!disp_parent)
496 return E_INVALIDARG; 496 return E_INVALIDARG;
497 497
498 IAccessible* parent_obj = GetParent()->ToBrowserAccessibilityWin(); 498 IAccessible* parent_obj = GetParent()->ToBrowserAccessibilityWin();
499 if (parent_obj == NULL) { 499 if (parent_obj == nullptr) {
500 // This happens if we're the root of the tree; 500 // This happens if we're the root of the tree;
501 // return the IAccessible for the window. 501 // return the IAccessible for the window.
502 parent_obj = 502 parent_obj =
503 manager()->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); 503 manager()->ToBrowserAccessibilityManagerWin()->GetParentIAccessible();
504 // |parent| can only be NULL if the manager was created before the parent 504 // |parent| can only be nullptr if the manager was created before the parent
505 // IAccessible was known and it wasn't subsequently set before a client 505 // IAccessible was known and it wasn't subsequently set before a client
506 // requested it. This has been fixed. |parent| may also be NULL during 506 // requested it. This has been fixed. |parent| may also be nullptr during
507 // destruction. Possible cases where this could occur include tabs being 507 // destruction. Possible cases where this could occur include tabs being
508 // dragged to a new window, etc. 508 // dragged to a new window, etc.
509 if (!parent_obj) { 509 if (!parent_obj) {
510 DVLOG(1) << "In Function: " 510 DVLOG(1) << "In Function: "
511 << __FUNCTION__ 511 << __FUNCTION__
512 << ". Parent IAccessible interface is NULL. Returning failure"; 512 << ". Parent IAccessible interface is nullptr. Returning failure" ;
513 return E_FAIL; 513 return E_FAIL;
514 } 514 }
515 } 515 }
516 parent_obj->AddRef(); 516 parent_obj->AddRef();
517 *disp_parent = parent_obj; 517 *disp_parent = parent_obj;
518 return S_OK; 518 return S_OK;
519 } 519 }
520 520
521 STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, 521 STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id,
522 VARIANT* role) { 522 VARIANT* role) {
(...skipping 24 matching lines...) Expand all
547 547
548 if (!state) 548 if (!state)
549 return E_INVALIDARG; 549 return E_INVALIDARG;
550 550
551 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 551 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
552 if (!target) 552 if (!target)
553 return E_INVALIDARG; 553 return E_INVALIDARG;
554 554
555 state->vt = VT_I4; 555 state->vt = VT_I4;
556 state->lVal = target->ia_state_; 556 state->lVal = target->ia_state_;
557 if (manager()->GetFocus(NULL) == this) 557 if (manager()->GetFocus(nullptr) == this)
558 state->lVal |= STATE_SYSTEM_FOCUSED; 558 state->lVal |= STATE_SYSTEM_FOCUSED;
559 559
560 return S_OK; 560 return S_OK;
561 } 561 }
562 562
563 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, 563 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id,
564 BSTR* value) { 564 BSTR* value) {
565 if (!instance_active()) 565 if (!instance_active())
566 return E_FAIL; 566 return E_FAIL;
567 567
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 ui::AX_ATTR_CELL_IDS); 1062 ui::AX_ATTR_CELL_IDS);
1063 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); 1063 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size()));
1064 1064
1065 int cell_id = cell_ids[row * columns + column]; 1065 int cell_id = cell_ids[row * columns + column];
1066 BrowserAccessibilityWin* cell = GetFromID(cell_id); 1066 BrowserAccessibilityWin* cell = GetFromID(cell_id);
1067 if (cell) { 1067 if (cell) {
1068 *accessible = static_cast<IAccessible*>(cell->NewReference()); 1068 *accessible = static_cast<IAccessible*>(cell->NewReference());
1069 return S_OK; 1069 return S_OK;
1070 } 1070 }
1071 1071
1072 *accessible = NULL; 1072 *accessible = nullptr;
1073 return E_INVALIDARG; 1073 return E_INVALIDARG;
1074 } 1074 }
1075 1075
1076 STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { 1076 STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) {
1077 if (!instance_active()) 1077 if (!instance_active())
1078 return E_FAIL; 1078 return E_FAIL;
1079 1079
1080 if (!accessible) 1080 if (!accessible)
1081 return E_INVALIDARG; 1081 return E_INVALIDARG;
1082 1082
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 return E_FAIL; 2063 return E_FAIL;
2064 2064
2065 if (!start_offset || !end_offset || !text) 2065 if (!start_offset || !end_offset || !text)
2066 return E_INVALIDARG; 2066 return E_INVALIDARG;
2067 2067
2068 // The IAccessible2 spec says we don't have to implement the "sentence" 2068 // The IAccessible2 spec says we don't have to implement the "sentence"
2069 // boundary type, we can just let the screenreader handle it. 2069 // boundary type, we can just let the screenreader handle it.
2070 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { 2070 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) {
2071 *start_offset = 0; 2071 *start_offset = 0;
2072 *end_offset = 0; 2072 *end_offset = 0;
2073 *text = NULL; 2073 *text = nullptr;
2074 return S_FALSE; 2074 return S_FALSE;
2075 } 2075 }
2076 2076
2077 const base::string16& text_str = TextForIAccessibleText(); 2077 const base::string16& text_str = TextForIAccessibleText();
2078 2078
2079 *start_offset = FindBoundary( 2079 *start_offset = FindBoundary(
2080 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); 2080 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION);
2081 *end_offset = FindBoundary( 2081 *end_offset = FindBoundary(
2082 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); 2082 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION);
2083 return get_text(*start_offset, *end_offset, text); 2083 return get_text(*start_offset, *end_offset, text);
2084 } 2084 }
2085 2085
2086 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( 2086 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset(
2087 LONG offset, 2087 LONG offset,
2088 enum IA2TextBoundaryType boundary_type, 2088 enum IA2TextBoundaryType boundary_type,
2089 LONG* start_offset, 2089 LONG* start_offset,
2090 LONG* end_offset, 2090 LONG* end_offset,
2091 BSTR* text) { 2091 BSTR* text) {
2092 if (!instance_active()) 2092 if (!instance_active())
2093 return E_FAIL; 2093 return E_FAIL;
2094 2094
2095 if (!start_offset || !end_offset || !text) 2095 if (!start_offset || !end_offset || !text)
2096 return E_INVALIDARG; 2096 return E_INVALIDARG;
2097 2097
2098 // The IAccessible2 spec says we don't have to implement the "sentence" 2098 // The IAccessible2 spec says we don't have to implement the "sentence"
2099 // boundary type, we can just let the screenreader handle it. 2099 // boundary type, we can just let the screenreader handle it.
2100 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { 2100 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) {
2101 *start_offset = 0; 2101 *start_offset = 0;
2102 *end_offset = 0; 2102 *end_offset = 0;
2103 *text = NULL; 2103 *text = nullptr;
2104 return S_FALSE; 2104 return S_FALSE;
2105 } 2105 }
2106 2106
2107 const base::string16& text_str = TextForIAccessibleText(); 2107 const base::string16& text_str = TextForIAccessibleText();
2108 2108
2109 *start_offset = FindBoundary( 2109 *start_offset = FindBoundary(
2110 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); 2110 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION);
2111 *end_offset = offset; 2111 *end_offset = offset;
2112 return get_text(*start_offset, *end_offset, text); 2112 return get_text(*start_offset, *end_offset, text);
2113 } 2113 }
2114 2114
2115 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( 2115 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset(
2116 LONG offset, 2116 LONG offset,
2117 enum IA2TextBoundaryType boundary_type, 2117 enum IA2TextBoundaryType boundary_type,
2118 LONG* start_offset, 2118 LONG* start_offset,
2119 LONG* end_offset, 2119 LONG* end_offset,
2120 BSTR* text) { 2120 BSTR* text) {
2121 if (!instance_active()) 2121 if (!instance_active())
2122 return E_FAIL; 2122 return E_FAIL;
2123 2123
2124 if (!start_offset || !end_offset || !text) 2124 if (!start_offset || !end_offset || !text)
2125 return E_INVALIDARG; 2125 return E_INVALIDARG;
2126 2126
2127 // The IAccessible2 spec says we don't have to implement the "sentence" 2127 // The IAccessible2 spec says we don't have to implement the "sentence"
2128 // boundary type, we can just let the screenreader handle it. 2128 // boundary type, we can just let the screenreader handle it.
2129 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { 2129 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) {
2130 *start_offset = 0; 2130 *start_offset = 0;
2131 *end_offset = 0; 2131 *end_offset = 0;
2132 *text = NULL; 2132 *text = nullptr;
2133 return S_FALSE; 2133 return S_FALSE;
2134 } 2134 }
2135 2135
2136 const base::string16& text_str = TextForIAccessibleText(); 2136 const base::string16& text_str = TextForIAccessibleText();
2137 2137
2138 *start_offset = offset; 2138 *start_offset = offset;
2139 *end_offset = FindBoundary( 2139 *end_offset = FindBoundary(
2140 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); 2140 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION);
2141 return get_text(*start_offset, *end_offset, text); 2141 return get_text(*start_offset, *end_offset, text);
2142 } 2142 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 2439
2440 if (!node_name || !name_space_id || !node_value || !num_children || 2440 if (!node_name || !name_space_id || !node_value || !num_children ||
2441 !unique_id || !node_type) { 2441 !unique_id || !node_type) {
2442 return E_INVALIDARG; 2442 return E_INVALIDARG;
2443 } 2443 }
2444 2444
2445 base::string16 tag; 2445 base::string16 tag;
2446 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) 2446 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag))
2447 *node_name = SysAllocString(tag.c_str()); 2447 *node_name = SysAllocString(tag.c_str());
2448 else 2448 else
2449 *node_name = NULL; 2449 *node_name = nullptr;
2450 2450
2451 *name_space_id = 0; 2451 *name_space_id = 0;
2452 *node_value = SysAllocString(base::UTF8ToUTF16(value()).c_str()); 2452 *node_value = SysAllocString(base::UTF8ToUTF16(value()).c_str());
2453 *num_children = PlatformChildCount(); 2453 *num_children = PlatformChildCount();
2454 *unique_id = unique_id_win_; 2454 *unique_id = unique_id_win_;
2455 2455
2456 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) { 2456 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) {
2457 *node_type = NODETYPE_DOCUMENT; 2457 *node_type = NODETYPE_DOCUMENT;
2458 } else if (ia_role_ == ROLE_SYSTEM_TEXT && 2458 } else if (ia_role_ == ROLE_SYSTEM_TEXT &&
2459 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { 2459 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); 2508 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]);
2509 for (unsigned int j = 0; j < GetHtmlAttributes().size(); ++j) { 2509 for (unsigned int j = 0; j < GetHtmlAttributes().size(); ++j) {
2510 if (GetHtmlAttributes()[j].first == name) { 2510 if (GetHtmlAttributes()[j].first == name) {
2511 attrib_values[i] = SysAllocString( 2511 attrib_values[i] = SysAllocString(
2512 base::UTF8ToUTF16(GetHtmlAttributes()[j].second).c_str()); 2512 base::UTF8ToUTF16(GetHtmlAttributes()[j].second).c_str());
2513 found = true; 2513 found = true;
2514 break; 2514 break;
2515 } 2515 }
2516 } 2516 }
2517 if (!found) { 2517 if (!found) {
2518 attrib_values[i] = NULL; 2518 attrib_values[i] = nullptr;
2519 } 2519 }
2520 } 2520 }
2521 return S_OK; 2521 return S_OK;
2522 } 2522 }
2523 2523
2524 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( 2524 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle(
2525 unsigned short max_style_properties, 2525 unsigned short max_style_properties,
2526 boolean use_alternate_view, 2526 boolean use_alternate_view,
2527 BSTR* style_properties, 2527 BSTR* style_properties,
2528 BSTR* style_values, 2528 BSTR* style_values,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 // We only cache a single style property for now: DISPLAY 2563 // We only cache a single style property for now: DISPLAY
2564 2564
2565 for (unsigned short i = 0; i < num_style_properties; ++i) { 2565 for (unsigned short i = 0; i < num_style_properties; ++i) {
2566 base::string16 name = (LPCWSTR)style_properties[i]; 2566 base::string16 name = (LPCWSTR)style_properties[i];
2567 base::StringToLowerASCII(&name); 2567 base::StringToLowerASCII(&name);
2568 if (name == L"display") { 2568 if (name == L"display") {
2569 base::string16 display = GetString16Attribute( 2569 base::string16 display = GetString16Attribute(
2570 ui::AX_ATTR_DISPLAY); 2570 ui::AX_ATTR_DISPLAY);
2571 style_values[i] = SysAllocString(display.c_str()); 2571 style_values[i] = SysAllocString(display.c_str());
2572 } else { 2572 } else {
2573 style_values[i] = NULL; 2573 style_values[i] = nullptr;
2574 } 2574 }
2575 } 2575 }
2576 2576
2577 return S_OK; 2577 return S_OK;
2578 } 2578 }
2579 2579
2580 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { 2580 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) {
2581 return scrollTo(placeTopLeft ? 2581 return scrollTo(placeTopLeft ?
2582 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE); 2582 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE);
2583 } 2583 }
(...skipping 10 matching lines...) Expand all
2594 } 2594 }
2595 2595
2596 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { 2596 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) {
2597 if (!instance_active()) 2597 if (!instance_active())
2598 return E_FAIL; 2598 return E_FAIL;
2599 2599
2600 if (!node) 2600 if (!node)
2601 return E_INVALIDARG; 2601 return E_INVALIDARG;
2602 2602
2603 if (PlatformChildCount() == 0) { 2603 if (PlatformChildCount() == 0) {
2604 *node = NULL; 2604 *node = nullptr;
2605 return S_FALSE; 2605 return S_FALSE;
2606 } 2606 }
2607 2607
2608 *node = PlatformGetChild(0)->ToBrowserAccessibilityWin()->NewReference(); 2608 *node = PlatformGetChild(0)->ToBrowserAccessibilityWin()->NewReference();
2609 return S_OK; 2609 return S_OK;
2610 } 2610 }
2611 2611
2612 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { 2612 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) {
2613 if (!instance_active()) 2613 if (!instance_active())
2614 return E_FAIL; 2614 return E_FAIL;
2615 2615
2616 if (!node) 2616 if (!node)
2617 return E_INVALIDARG; 2617 return E_INVALIDARG;
2618 2618
2619 if (PlatformChildCount() == 0) { 2619 if (PlatformChildCount() == 0) {
2620 *node = NULL; 2620 *node = nullptr;
2621 return S_FALSE; 2621 return S_FALSE;
2622 } 2622 }
2623 2623
2624 *node = PlatformGetChild(PlatformChildCount() - 1) 2624 *node = PlatformGetChild(PlatformChildCount() - 1)
2625 ->ToBrowserAccessibilityWin()->NewReference(); 2625 ->ToBrowserAccessibilityWin()->NewReference();
2626 return S_OK; 2626 return S_OK;
2627 } 2627 }
2628 2628
2629 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( 2629 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling(
2630 ISimpleDOMNode** node) { 2630 ISimpleDOMNode** node) {
2631 if (!instance_active()) 2631 if (!instance_active())
2632 return E_FAIL; 2632 return E_FAIL;
2633 2633
2634 if (!node) 2634 if (!node)
2635 return E_INVALIDARG; 2635 return E_INVALIDARG;
2636 2636
2637 if (!GetParent() || GetIndexInParent() <= 0) { 2637 if (!GetParent() || GetIndexInParent() <= 0) {
2638 *node = NULL; 2638 *node = nullptr;
2639 return S_FALSE; 2639 return S_FALSE;
2640 } 2640 }
2641 2641
2642 *node = GetParent()->InternalGetChild(GetIndexInParent() - 1)-> 2642 *node = GetParent()->InternalGetChild(GetIndexInParent() - 1)->
2643 ToBrowserAccessibilityWin()->NewReference(); 2643 ToBrowserAccessibilityWin()->NewReference();
2644 return S_OK; 2644 return S_OK;
2645 } 2645 }
2646 2646
2647 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { 2647 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) {
2648 if (!instance_active()) 2648 if (!instance_active())
2649 return E_FAIL; 2649 return E_FAIL;
2650 2650
2651 if (!node) 2651 if (!node)
2652 return E_INVALIDARG; 2652 return E_INVALIDARG;
2653 2653
2654 if (!GetParent() || 2654 if (!GetParent() ||
2655 GetIndexInParent() < 0 || 2655 GetIndexInParent() < 0 ||
2656 GetIndexInParent() >= static_cast<int>( 2656 GetIndexInParent() >= static_cast<int>(
2657 GetParent()->InternalChildCount()) - 1) { 2657 GetParent()->InternalChildCount()) - 1) {
2658 *node = NULL; 2658 *node = nullptr;
2659 return S_FALSE; 2659 return S_FALSE;
2660 } 2660 }
2661 2661
2662 *node = GetParent()->InternalGetChild(GetIndexInParent() + 1)-> 2662 *node = GetParent()->InternalGetChild(GetIndexInParent() + 1)->
2663 ToBrowserAccessibilityWin()->NewReference(); 2663 ToBrowserAccessibilityWin()->NewReference();
2664 return S_OK; 2664 return S_OK;
2665 } 2665 }
2666 2666
2667 STDMETHODIMP BrowserAccessibilityWin::get_childAt( 2667 STDMETHODIMP BrowserAccessibilityWin::get_childAt(
2668 unsigned int child_index, 2668 unsigned int child_index,
2669 ISimpleDOMNode** node) { 2669 ISimpleDOMNode** node) {
2670 if (!instance_active()) 2670 if (!instance_active())
2671 return E_FAIL; 2671 return E_FAIL;
2672 2672
2673 if (!node) 2673 if (!node)
2674 return E_INVALIDARG; 2674 return E_INVALIDARG;
2675 2675
2676 if (child_index >= PlatformChildCount()) 2676 if (child_index >= PlatformChildCount())
2677 return E_INVALIDARG; 2677 return E_INVALIDARG;
2678 2678
2679 BrowserAccessibility* child = PlatformGetChild(child_index); 2679 BrowserAccessibility* child = PlatformGetChild(child_index);
2680 if (!child) { 2680 if (!child) {
2681 *node = NULL; 2681 *node = nullptr;
2682 return S_FALSE; 2682 return S_FALSE;
2683 } 2683 }
2684 2684
2685 *node = child->ToBrowserAccessibilityWin()->NewReference(); 2685 *node = child->ToBrowserAccessibilityWin()->NewReference();
2686 return S_OK; 2686 return S_OK;
2687 } 2687 }
2688 2688
2689 // 2689 //
2690 // ISimpleDOMText methods. 2690 // ISimpleDOMText methods.
2691 // 2691 //
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 2808
2809 // We only support the IAccessibleEx interface on Windows 8 and above. This 2809 // We only support the IAccessibleEx interface on Windows 8 and above. This
2810 // is needed for the on-screen Keyboard to show up in metro mode, when the 2810 // is needed for the on-screen Keyboard to show up in metro mode, when the
2811 // user taps an editable portion on the page. 2811 // user taps an editable portion on the page.
2812 // All methods in the IAccessibleEx interface are unimplemented. 2812 // All methods in the IAccessibleEx interface are unimplemented.
2813 if (riid == IID_IAccessibleEx && 2813 if (riid == IID_IAccessibleEx &&
2814 base::win::GetVersion() >= base::win::VERSION_WIN8) { 2814 base::win::GetVersion() >= base::win::VERSION_WIN8) {
2815 return QueryInterface(riid, object); 2815 return QueryInterface(riid, object);
2816 } 2816 }
2817 2817
2818 *object = NULL; 2818 *object = nullptr;
2819 return E_FAIL; 2819 return E_FAIL;
2820 } 2820 }
2821 2821
2822 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, 2822 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id,
2823 IUnknown** provider) { 2823 IUnknown** provider) {
2824 DVLOG(1) << "In Function: " 2824 DVLOG(1) << "In Function: "
2825 << __FUNCTION__ 2825 << __FUNCTION__
2826 << " for pattern id: " 2826 << " for pattern id: "
2827 << id; 2827 << id;
2828 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { 2828 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) {
(...skipping 30 matching lines...) Expand all
2859 // CComObjectRootEx methods. 2859 // CComObjectRootEx methods.
2860 // 2860 //
2861 2861
2862 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( 2862 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface(
2863 void* this_ptr, 2863 void* this_ptr,
2864 const _ATL_INTMAP_ENTRY* entries, 2864 const _ATL_INTMAP_ENTRY* entries,
2865 REFIID iid, 2865 REFIID iid,
2866 void** object) { 2866 void** object) {
2867 if (iid == IID_IAccessibleImage) { 2867 if (iid == IID_IAccessibleImage) {
2868 if (ia_role_ != ROLE_SYSTEM_GRAPHIC) { 2868 if (ia_role_ != ROLE_SYSTEM_GRAPHIC) {
2869 *object = NULL; 2869 *object = nullptr;
2870 return E_NOINTERFACE; 2870 return E_NOINTERFACE;
2871 } 2871 }
2872 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { 2872 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) {
2873 if (ia_role_ != ROLE_SYSTEM_TABLE) { 2873 if (ia_role_ != ROLE_SYSTEM_TABLE) {
2874 *object = NULL; 2874 *object = nullptr;
2875 return E_NOINTERFACE; 2875 return E_NOINTERFACE;
2876 } 2876 }
2877 } else if (iid == IID_IAccessibleTableCell) { 2877 } else if (iid == IID_IAccessibleTableCell) {
2878 if (ia_role_ != ROLE_SYSTEM_CELL) { 2878 if (ia_role_ != ROLE_SYSTEM_CELL) {
2879 *object = NULL; 2879 *object = nullptr;
2880 return E_NOINTERFACE; 2880 return E_NOINTERFACE;
2881 } 2881 }
2882 } else if (iid == IID_IAccessibleValue) { 2882 } else if (iid == IID_IAccessibleValue) {
2883 if (ia_role_ != ROLE_SYSTEM_PROGRESSBAR && 2883 if (ia_role_ != ROLE_SYSTEM_PROGRESSBAR &&
2884 ia_role_ != ROLE_SYSTEM_SCROLLBAR && 2884 ia_role_ != ROLE_SYSTEM_SCROLLBAR &&
2885 ia_role_ != ROLE_SYSTEM_SLIDER) { 2885 ia_role_ != ROLE_SYSTEM_SLIDER) {
2886 *object = NULL; 2886 *object = nullptr;
2887 return E_NOINTERFACE; 2887 return E_NOINTERFACE;
2888 } 2888 }
2889 } else if (iid == IID_ISimpleDOMDocument) { 2889 } else if (iid == IID_ISimpleDOMDocument) {
2890 if (ia_role_ != ROLE_SYSTEM_DOCUMENT) { 2890 if (ia_role_ != ROLE_SYSTEM_DOCUMENT) {
2891 *object = NULL; 2891 *object = nullptr;
2892 return E_NOINTERFACE; 2892 return E_NOINTERFACE;
2893 } 2893 }
2894 } 2894 }
2895 2895
2896 return CComObjectRootBase::InternalQueryInterface( 2896 return CComObjectRootBase::InternalQueryInterface(
2897 this_ptr, entries, iid, object); 2897 this_ptr, entries, iid, object);
2898 } 2898 }
2899 2899
2900 // 2900 //
2901 // Private methods. 2901 // Private methods.
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 } 3183 }
3184 3184
3185 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { 3185 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() {
3186 AddRef(); 3186 AddRef();
3187 return this; 3187 return this;
3188 } 3188 }
3189 3189
3190 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( 3190 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID(
3191 const VARIANT& var_id) { 3191 const VARIANT& var_id) {
3192 if (var_id.vt != VT_I4) 3192 if (var_id.vt != VT_I4)
3193 return NULL; 3193 return nullptr;
3194 3194
3195 LONG child_id = var_id.lVal; 3195 LONG child_id = var_id.lVal;
3196 if (child_id == CHILDID_SELF) 3196 if (child_id == CHILDID_SELF)
3197 return this; 3197 return this;
3198 3198
3199 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) 3199 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount()))
3200 return PlatformGetChild(child_id - 1)->ToBrowserAccessibilityWin(); 3200 return PlatformGetChild(child_id - 1)->ToBrowserAccessibilityWin();
3201 3201
3202 return manager()->ToBrowserAccessibilityManagerWin()-> 3202 return manager()->ToBrowserAccessibilityManagerWin()->
3203 GetFromUniqueIdWin(child_id); 3203 GetFromUniqueIdWin(child_id);
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
3825 // The role should always be set. 3825 // The role should always be set.
3826 DCHECK(!role_name_.empty() || ia_role_); 3826 DCHECK(!role_name_.empty() || ia_role_);
3827 3827
3828 // If we didn't explicitly set the IAccessible2 role, make it the same 3828 // If we didn't explicitly set the IAccessible2 role, make it the same
3829 // as the MSAA role. 3829 // as the MSAA role.
3830 if (!ia2_role_) 3830 if (!ia2_role_)
3831 ia2_role_ = ia_role_; 3831 ia2_role_ = ia_role_;
3832 } 3832 }
3833 3833
3834 } // namespace content 3834 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698