| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_com_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_com_win.h" |
| 6 | 6 |
| 7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
| 8 #include <UIAutomationCoreApi.h> | 8 #include <UIAutomationCoreApi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 target_ids_.erase( | 304 target_ids_.erase( |
| 305 std::remove(target_ids_.begin(), target_ids_.end(), target_id), | 305 std::remove(target_ids_.begin(), target_ids_.end(), target_id), |
| 306 target_ids_.end()); | 306 target_ids_.end()); |
| 307 } | 307 } |
| 308 | 308 |
| 309 STDMETHODIMP BrowserAccessibilityRelation::get_relationType( | 309 STDMETHODIMP BrowserAccessibilityRelation::get_relationType( |
| 310 BSTR* relation_type) { | 310 BSTR* relation_type) { |
| 311 if (!relation_type) | 311 if (!relation_type) |
| 312 return E_INVALIDARG; | 312 return E_INVALIDARG; |
| 313 | 313 |
| 314 if (!owner_->GetOwner()) | 314 if (!owner_->owner()) |
| 315 return E_FAIL; | 315 return E_FAIL; |
| 316 | 316 |
| 317 *relation_type = SysAllocString(type_.c_str()); | 317 *relation_type = SysAllocString(type_.c_str()); |
| 318 DCHECK(*relation_type); | 318 DCHECK(*relation_type); |
| 319 return S_OK; | 319 return S_OK; |
| 320 } | 320 } |
| 321 | 321 |
| 322 STDMETHODIMP BrowserAccessibilityRelation::get_nTargets(long* n_targets) { | 322 STDMETHODIMP BrowserAccessibilityRelation::get_nTargets(long* n_targets) { |
| 323 if (!n_targets) | 323 if (!n_targets) |
| 324 return E_INVALIDARG; | 324 return E_INVALIDARG; |
| 325 | 325 |
| 326 if (!owner_->GetOwner()) | 326 if (!owner_->owner()) |
| 327 return E_FAIL; | 327 return E_FAIL; |
| 328 | 328 |
| 329 *n_targets = static_cast<long>(target_ids_.size()); | 329 *n_targets = static_cast<long>(target_ids_.size()); |
| 330 | 330 |
| 331 for (long i = *n_targets - 1; i >= 0; --i) { | 331 for (long i = *n_targets - 1; i >= 0; --i) { |
| 332 BrowserAccessibilityComWin* result = owner_->GetFromID(target_ids_[i]); | 332 BrowserAccessibilityComWin* result = owner_->GetFromID(target_ids_[i]); |
| 333 if (!result || !result->GetOwner()) { | 333 if (!result || !result->owner()) { |
| 334 *n_targets = 0; | 334 *n_targets = 0; |
| 335 break; | 335 break; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 return S_OK; | 338 return S_OK; |
| 339 } | 339 } |
| 340 | 340 |
| 341 STDMETHODIMP BrowserAccessibilityRelation::get_target(long target_index, | 341 STDMETHODIMP BrowserAccessibilityRelation::get_target(long target_index, |
| 342 IUnknown** target) { | 342 IUnknown** target) { |
| 343 if (!target) | 343 if (!target) |
| 344 return E_INVALIDARG; | 344 return E_INVALIDARG; |
| 345 | 345 |
| 346 if (!owner_->GetOwner()) | 346 if (!owner_->owner()) |
| 347 return E_FAIL; | 347 return E_FAIL; |
| 348 | 348 |
| 349 auto* manager = owner_->Manager(); | 349 auto* manager = owner_->Manager(); |
| 350 if (!manager) | 350 if (!manager) |
| 351 return E_FAIL; | 351 return E_FAIL; |
| 352 | 352 |
| 353 if (target_index < 0 || | 353 if (target_index < 0 || |
| 354 target_index >= static_cast<long>(target_ids_.size())) { | 354 target_index >= static_cast<long>(target_ids_.size())) { |
| 355 return E_INVALIDARG; | 355 return E_INVALIDARG; |
| 356 } | 356 } |
| 357 | 357 |
| 358 BrowserAccessibility* result = manager->GetFromID(target_ids_[target_index]); | 358 BrowserAccessibility* result = manager->GetFromID(target_ids_[target_index]); |
| 359 if (!result || !result->instance_active()) | 359 if (!result || !result->instance_active()) |
| 360 return E_FAIL; | 360 return E_FAIL; |
| 361 | 361 |
| 362 *target = static_cast<IAccessible*>( | 362 *target = static_cast<IAccessible*>( |
| 363 ToBrowserAccessibilityComWin(result)->NewReference()); | 363 ToBrowserAccessibilityComWin(result)->NewReference()); |
| 364 return S_OK; | 364 return S_OK; |
| 365 } | 365 } |
| 366 | 366 |
| 367 STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, | 367 STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, |
| 368 IUnknown** targets, | 368 IUnknown** targets, |
| 369 long* n_targets) { | 369 long* n_targets) { |
| 370 if (!targets || !n_targets) | 370 if (!targets || !n_targets) |
| 371 return E_INVALIDARG; | 371 return E_INVALIDARG; |
| 372 | 372 |
| 373 if (!owner_->GetOwner()) | 373 if (!owner_->owner()) |
| 374 return E_FAIL; | 374 return E_FAIL; |
| 375 | 375 |
| 376 long count = static_cast<long>(target_ids_.size()); | 376 long count = static_cast<long>(target_ids_.size()); |
| 377 if (count > max_targets) | 377 if (count > max_targets) |
| 378 count = max_targets; | 378 count = max_targets; |
| 379 | 379 |
| 380 *n_targets = count; | 380 *n_targets = count; |
| 381 if (count == 0) | 381 if (count == 0) |
| 382 return S_FALSE; | 382 return S_FALSE; |
| 383 | 383 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 410 | 410 |
| 411 BrowserAccessibilityComWin::~BrowserAccessibilityComWin() { | 411 BrowserAccessibilityComWin::~BrowserAccessibilityComWin() { |
| 412 for (BrowserAccessibilityRelation* relation : relations_) | 412 for (BrowserAccessibilityRelation* relation : relations_) |
| 413 relation->Release(); | 413 relation->Release(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 // | 416 // |
| 417 // IAccessible methods. | 417 // IAccessible methods. |
| 418 // | 418 // |
| 419 // Conventions: | 419 // Conventions: |
| 420 // * Always test for GetOwner() first and return E_FAIL if it's false. | 420 // * Always test for owner() first and return E_FAIL if it's false. |
| 421 // * Always check for invalid arguments first, even if they're unused. | 421 // * Always check for invalid arguments first, even if they're unused. |
| 422 // * Return S_FALSE if the only output is a string argument and it's empty. | 422 // * Return S_FALSE if the only output is a string argument and it's empty. |
| 423 // * There are some methods that don't touch any state such as get_toolkitName. | 423 // * There are some methods that don't touch any state such as get_toolkitName. |
| 424 // For these rare cases, you may not need to call GetOwner(). | 424 // For these rare cases, you may not need to call owner(). |
| 425 // | 425 // |
| 426 | 426 |
| 427 HRESULT BrowserAccessibilityComWin::accDoDefaultAction(VARIANT var_id) { | 427 HRESULT BrowserAccessibilityComWin::accDoDefaultAction(VARIANT var_id) { |
| 428 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); | 428 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); |
| 429 | 429 |
| 430 if (!GetOwner()) | 430 if (!owner()) |
| 431 return E_FAIL; | 431 return E_FAIL; |
| 432 | 432 |
| 433 auto* manager = Manager(); | 433 auto* manager = Manager(); |
| 434 if (!manager) | 434 if (!manager) |
| 435 return E_FAIL; | 435 return E_FAIL; |
| 436 | 436 |
| 437 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 437 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 438 if (!target) | 438 if (!target) |
| 439 return E_INVALIDARG; | 439 return E_INVALIDARG; |
| 440 | 440 |
| 441 // Return an error if it's not clickable. | 441 // Return an error if it's not clickable. |
| 442 if (!target->GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION)) | 442 if (!target->owner()->HasIntAttribute(ui::AX_ATTR_ACTION)) |
| 443 return DISP_E_MEMBERNOTFOUND; | 443 return DISP_E_MEMBERNOTFOUND; |
| 444 | 444 |
| 445 manager->DoDefaultAction(*target->GetOwner()); | 445 manager->DoDefaultAction(*target->owner()); |
| 446 return S_OK; | 446 return S_OK; |
| 447 } | 447 } |
| 448 | 448 |
| 449 STDMETHODIMP BrowserAccessibilityComWin::accHitTest(LONG x_left, | 449 STDMETHODIMP BrowserAccessibilityComWin::accHitTest(LONG x_left, |
| 450 LONG y_top, | 450 LONG y_top, |
| 451 VARIANT* child) { | 451 VARIANT* child) { |
| 452 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); | 452 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); |
| 453 | 453 |
| 454 if (!GetOwner()) | 454 if (!owner()) |
| 455 return E_FAIL; | 455 return E_FAIL; |
| 456 | 456 |
| 457 auto* manager = Manager(); | 457 auto* manager = Manager(); |
| 458 if (!manager) | 458 if (!manager) |
| 459 return E_FAIL; | 459 return E_FAIL; |
| 460 | 460 |
| 461 if (!child) | 461 if (!child) |
| 462 return E_INVALIDARG; | 462 return E_INVALIDARG; |
| 463 | 463 |
| 464 gfx::Point point(x_left, y_top); | 464 gfx::Point point(x_left, y_top); |
| 465 if (!GetOwner()->GetScreenBoundsRect().Contains(point)) { | 465 if (!owner()->GetScreenBoundsRect().Contains(point)) { |
| 466 // Return S_FALSE and VT_EMPTY when outside the object's boundaries. | 466 // Return S_FALSE and VT_EMPTY when outside the object's boundaries. |
| 467 child->vt = VT_EMPTY; | 467 child->vt = VT_EMPTY; |
| 468 return S_FALSE; | 468 return S_FALSE; |
| 469 } | 469 } |
| 470 | 470 |
| 471 BrowserAccessibility* result = manager->CachingAsyncHitTest(point); | 471 BrowserAccessibility* result = manager->CachingAsyncHitTest(point); |
| 472 if (result == GetOwner()) { | 472 if (result == owner()) { |
| 473 // Point is within this object. | 473 // Point is within this object. |
| 474 child->vt = VT_I4; | 474 child->vt = VT_I4; |
| 475 child->lVal = CHILDID_SELF; | 475 child->lVal = CHILDID_SELF; |
| 476 } else { | 476 } else { |
| 477 child->vt = VT_DISPATCH; | 477 child->vt = VT_DISPATCH; |
| 478 child->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); | 478 child->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); |
| 479 } | 479 } |
| 480 return S_OK; | 480 return S_OK; |
| 481 } | 481 } |
| 482 | 482 |
| 483 STDMETHODIMP BrowserAccessibilityComWin::accLocation(LONG* x_left, | 483 STDMETHODIMP BrowserAccessibilityComWin::accLocation(LONG* x_left, |
| 484 LONG* y_top, | 484 LONG* y_top, |
| 485 LONG* width, | 485 LONG* width, |
| 486 LONG* height, | 486 LONG* height, |
| 487 VARIANT var_id) { | 487 VARIANT var_id) { |
| 488 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_LOCATION); | 488 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_LOCATION); |
| 489 if (!GetOwner()) | 489 if (!owner()) |
| 490 return E_FAIL; | 490 return E_FAIL; |
| 491 | 491 |
| 492 return AXPlatformNodeWin::accLocation(x_left, y_top, width, height, var_id); | 492 return AXPlatformNodeWin::accLocation(x_left, y_top, width, height, var_id); |
| 493 } | 493 } |
| 494 | 494 |
| 495 STDMETHODIMP BrowserAccessibilityComWin::accNavigate(LONG nav_dir, | 495 STDMETHODIMP BrowserAccessibilityComWin::accNavigate(LONG nav_dir, |
| 496 VARIANT start, | 496 VARIANT start, |
| 497 VARIANT* end) { | 497 VARIANT* end) { |
| 498 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_NAVIGATE); | 498 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_NAVIGATE); |
| 499 if (!GetOwner()) | 499 if (!owner()) |
| 500 return E_FAIL; | 500 return E_FAIL; |
| 501 | 501 |
| 502 // Forward all directions but NAVDIR_ to the platform node implementation. | 502 // Forward all directions but NAVDIR_ to the platform node implementation. |
| 503 if (nav_dir != NAVDIR_DOWN && nav_dir != NAVDIR_UP && | 503 if (nav_dir != NAVDIR_DOWN && nav_dir != NAVDIR_UP && |
| 504 nav_dir != NAVDIR_LEFT && nav_dir != NAVDIR_RIGHT) { | 504 nav_dir != NAVDIR_LEFT && nav_dir != NAVDIR_RIGHT) { |
| 505 return AXPlatformNodeWin::accNavigate(nav_dir, start, end); | 505 return AXPlatformNodeWin::accNavigate(nav_dir, start, end); |
| 506 } | 506 } |
| 507 | 507 |
| 508 BrowserAccessibilityComWin* target = GetTargetFromChildID(start); | 508 BrowserAccessibilityComWin* target = GetTargetFromChildID(start); |
| 509 if (!target) | 509 if (!target) |
| 510 return E_INVALIDARG; | 510 return E_INVALIDARG; |
| 511 | 511 |
| 512 BrowserAccessibility* result = nullptr; | 512 BrowserAccessibility* result = nullptr; |
| 513 switch (nav_dir) { | 513 switch (nav_dir) { |
| 514 case NAVDIR_DOWN: | 514 case NAVDIR_DOWN: |
| 515 result = target->GetOwner()->GetTableCell( | 515 result = target->owner()->GetTableCell( |
| 516 GetOwner()->GetTableRow() + GetOwner()->GetTableRowSpan(), | 516 owner()->GetTableRow() + owner()->GetTableRowSpan(), |
| 517 GetOwner()->GetTableColumn()); | 517 owner()->GetTableColumn()); |
| 518 break; | 518 break; |
| 519 case NAVDIR_UP: | 519 case NAVDIR_UP: |
| 520 result = target->GetOwner()->GetTableCell(GetOwner()->GetTableRow() - 1, | 520 result = target->owner()->GetTableCell(owner()->GetTableRow() - 1, |
| 521 GetOwner()->GetTableColumn()); | 521 owner()->GetTableColumn()); |
| 522 break; | 522 break; |
| 523 case NAVDIR_LEFT: | 523 case NAVDIR_LEFT: |
| 524 result = target->GetOwner()->GetTableCell( | 524 result = target->owner()->GetTableCell(owner()->GetTableRow(), |
| 525 GetOwner()->GetTableRow(), GetOwner()->GetTableColumn() - 1); | 525 owner()->GetTableColumn() - 1); |
| 526 break; | 526 break; |
| 527 case NAVDIR_RIGHT: | 527 case NAVDIR_RIGHT: |
| 528 result = target->GetOwner()->GetTableCell( | 528 result = target->owner()->GetTableCell( |
| 529 GetOwner()->GetTableRow(), | 529 owner()->GetTableRow(), |
| 530 GetOwner()->GetTableColumn() + GetOwner()->GetTableColumnSpan()); | 530 owner()->GetTableColumn() + owner()->GetTableColumnSpan()); |
| 531 break; | 531 break; |
| 532 } | 532 } |
| 533 | 533 |
| 534 if (!result) { | 534 if (!result) { |
| 535 end->vt = VT_EMPTY; | 535 end->vt = VT_EMPTY; |
| 536 return S_FALSE; | 536 return S_FALSE; |
| 537 } | 537 } |
| 538 | 538 |
| 539 end->vt = VT_DISPATCH; | 539 end->vt = VT_DISPATCH; |
| 540 end->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); | 540 end->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); |
| 541 return S_OK; | 541 return S_OK; |
| 542 } | 542 } |
| 543 | 543 |
| 544 STDMETHODIMP BrowserAccessibilityComWin::get_accChild(VARIANT var_child, | 544 STDMETHODIMP BrowserAccessibilityComWin::get_accChild(VARIANT var_child, |
| 545 IDispatch** disp_child) { | 545 IDispatch** disp_child) { |
| 546 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD); | 546 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD); |
| 547 if (!GetOwner()) | 547 if (!owner()) |
| 548 return E_FAIL; | 548 return E_FAIL; |
| 549 | 549 |
| 550 if (!disp_child) | 550 if (!disp_child) |
| 551 return E_INVALIDARG; | 551 return E_INVALIDARG; |
| 552 | 552 |
| 553 *disp_child = NULL; | 553 *disp_child = NULL; |
| 554 | 554 |
| 555 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_child); | 555 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_child); |
| 556 if (!target) | 556 if (!target) |
| 557 return E_INVALIDARG; | 557 return E_INVALIDARG; |
| 558 | 558 |
| 559 (*disp_child) = target->NewReference(); | 559 (*disp_child) = target->NewReference(); |
| 560 return S_OK; | 560 return S_OK; |
| 561 } | 561 } |
| 562 | 562 |
| 563 STDMETHODIMP BrowserAccessibilityComWin::get_accChildCount(LONG* child_count) { | 563 STDMETHODIMP BrowserAccessibilityComWin::get_accChildCount(LONG* child_count) { |
| 564 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT); | 564 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT); |
| 565 if (!GetOwner()) | 565 if (!owner()) |
| 566 return E_FAIL; | 566 return E_FAIL; |
| 567 | 567 |
| 568 if (!child_count) | 568 if (!child_count) |
| 569 return E_INVALIDARG; | 569 return E_INVALIDARG; |
| 570 | 570 |
| 571 *child_count = GetOwner()->PlatformChildCount(); | 571 *child_count = owner()->PlatformChildCount(); |
| 572 | 572 |
| 573 return S_OK; | 573 return S_OK; |
| 574 } | 574 } |
| 575 | 575 |
| 576 STDMETHODIMP BrowserAccessibilityComWin::get_accDefaultAction( | 576 STDMETHODIMP BrowserAccessibilityComWin::get_accDefaultAction( |
| 577 VARIANT var_id, | 577 VARIANT var_id, |
| 578 BSTR* def_action) { | 578 BSTR* def_action) { |
| 579 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION); | 579 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION); |
| 580 if (!GetOwner()) | 580 if (!owner()) |
| 581 return E_FAIL; | 581 return E_FAIL; |
| 582 | 582 |
| 583 if (!def_action) | 583 if (!def_action) |
| 584 return E_INVALIDARG; | 584 return E_INVALIDARG; |
| 585 | 585 |
| 586 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 586 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 587 if (!target) | 587 if (!target) |
| 588 return E_INVALIDARG; | 588 return E_INVALIDARG; |
| 589 | 589 |
| 590 return target->get_localizedName(0, def_action); | 590 return target->get_localizedName(0, def_action); |
| 591 } | 591 } |
| 592 | 592 |
| 593 STDMETHODIMP BrowserAccessibilityComWin::get_accDescription(VARIANT var_id, | 593 STDMETHODIMP BrowserAccessibilityComWin::get_accDescription(VARIANT var_id, |
| 594 BSTR* desc) { | 594 BSTR* desc) { |
| 595 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION); | 595 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION); |
| 596 if (!GetOwner()) | 596 if (!owner()) |
| 597 return E_FAIL; | 597 return E_FAIL; |
| 598 | 598 |
| 599 if (!desc) | 599 if (!desc) |
| 600 return E_INVALIDARG; | 600 return E_INVALIDARG; |
| 601 | 601 |
| 602 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 602 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 603 if (!target) | 603 if (!target) |
| 604 return E_INVALIDARG; | 604 return E_INVALIDARG; |
| 605 | 605 |
| 606 base::string16 description_str = target->description(); | 606 base::string16 description_str = target->description(); |
| 607 if (description_str.empty()) | 607 if (description_str.empty()) |
| 608 return S_FALSE; | 608 return S_FALSE; |
| 609 | 609 |
| 610 *desc = SysAllocString(description_str.c_str()); | 610 *desc = SysAllocString(description_str.c_str()); |
| 611 | 611 |
| 612 DCHECK(*desc); | 612 DCHECK(*desc); |
| 613 return S_OK; | 613 return S_OK; |
| 614 } | 614 } |
| 615 | 615 |
| 616 STDMETHODIMP BrowserAccessibilityComWin::get_accFocus(VARIANT* focus_child) { | 616 STDMETHODIMP BrowserAccessibilityComWin::get_accFocus(VARIANT* focus_child) { |
| 617 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_FOCUS); | 617 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_FOCUS); |
| 618 if (!GetOwner()) | 618 if (!owner()) |
| 619 return E_FAIL; | 619 return E_FAIL; |
| 620 | 620 |
| 621 auto* manager = Manager(); | 621 auto* manager = Manager(); |
| 622 if (!manager) | 622 if (!manager) |
| 623 return E_FAIL; | 623 return E_FAIL; |
| 624 | 624 |
| 625 if (!focus_child) | 625 if (!focus_child) |
| 626 return E_INVALIDARG; | 626 return E_INVALIDARG; |
| 627 | 627 |
| 628 BrowserAccessibilityWin* focus = | 628 BrowserAccessibilityWin* focus = |
| 629 static_cast<BrowserAccessibilityWin*>(manager->GetFocus()); | 629 static_cast<BrowserAccessibilityWin*>(manager->GetFocus()); |
| 630 if (focus == GetOwner()) { | 630 if (focus == owner()) { |
| 631 focus_child->vt = VT_I4; | 631 focus_child->vt = VT_I4; |
| 632 focus_child->lVal = CHILDID_SELF; | 632 focus_child->lVal = CHILDID_SELF; |
| 633 } else if (focus == NULL) { | 633 } else if (focus == NULL) { |
| 634 focus_child->vt = VT_EMPTY; | 634 focus_child->vt = VT_EMPTY; |
| 635 } else { | 635 } else { |
| 636 focus_child->vt = VT_DISPATCH; | 636 focus_child->vt = VT_DISPATCH; |
| 637 focus_child->pdispVal = focus->GetCOM()->NewReference(); | 637 focus_child->pdispVal = focus->GetCOM()->NewReference(); |
| 638 } | 638 } |
| 639 | 639 |
| 640 return S_OK; | 640 return S_OK; |
| 641 } | 641 } |
| 642 | 642 |
| 643 STDMETHODIMP BrowserAccessibilityComWin::get_accHelp(VARIANT var_id, | 643 STDMETHODIMP BrowserAccessibilityComWin::get_accHelp(VARIANT var_id, |
| 644 BSTR* help) { | 644 BSTR* help) { |
| 645 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP); | 645 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP); |
| 646 if (!GetOwner()) | 646 if (!owner()) |
| 647 return E_FAIL; | 647 return E_FAIL; |
| 648 | 648 |
| 649 return AXPlatformNodeWin::get_accHelp(var_id, help); | 649 return AXPlatformNodeWin::get_accHelp(var_id, help); |
| 650 } | 650 } |
| 651 | 651 |
| 652 STDMETHODIMP BrowserAccessibilityComWin::get_accKeyboardShortcut( | 652 STDMETHODIMP BrowserAccessibilityComWin::get_accKeyboardShortcut( |
| 653 VARIANT var_id, | 653 VARIANT var_id, |
| 654 BSTR* acc_key) { | 654 BSTR* acc_key) { |
| 655 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_KEYBOARD_SHORTCUT); | 655 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_KEYBOARD_SHORTCUT); |
| 656 if (!GetOwner()) | 656 if (!owner()) |
| 657 return E_FAIL; | 657 return E_FAIL; |
| 658 | 658 |
| 659 if (!acc_key) | 659 if (!acc_key) |
| 660 return E_INVALIDARG; | 660 return E_INVALIDARG; |
| 661 | 661 |
| 662 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 662 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 663 if (!target) | 663 if (!target) |
| 664 return E_INVALIDARG; | 664 return E_INVALIDARG; |
| 665 | 665 |
| 666 if (target->HasStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS)) { | 666 if (target->HasStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS)) { |
| 667 return target->GetStringAttributeAsBstr(ui::AX_ATTR_KEY_SHORTCUTS, acc_key); | 667 return target->GetStringAttributeAsBstr(ui::AX_ATTR_KEY_SHORTCUTS, acc_key); |
| 668 } | 668 } |
| 669 | 669 |
| 670 return target->GetStringAttributeAsBstr(ui::AX_ATTR_SHORTCUT, acc_key); | 670 return target->GetStringAttributeAsBstr(ui::AX_ATTR_SHORTCUT, acc_key); |
| 671 } | 671 } |
| 672 | 672 |
| 673 STDMETHODIMP BrowserAccessibilityComWin::get_accName(VARIANT var_id, | 673 STDMETHODIMP BrowserAccessibilityComWin::get_accName(VARIANT var_id, |
| 674 BSTR* name) { | 674 BSTR* name) { |
| 675 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME); | 675 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME); |
| 676 if (!GetOwner()) | 676 if (!owner()) |
| 677 return E_FAIL; | 677 return E_FAIL; |
| 678 | 678 |
| 679 return AXPlatformNodeWin::get_accName(var_id, name); | 679 return AXPlatformNodeWin::get_accName(var_id, name); |
| 680 } | 680 } |
| 681 | 681 |
| 682 STDMETHODIMP BrowserAccessibilityComWin::get_accParent( | 682 STDMETHODIMP BrowserAccessibilityComWin::get_accParent( |
| 683 IDispatch** disp_parent) { | 683 IDispatch** disp_parent) { |
| 684 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); | 684 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); |
| 685 if (!GetOwner()) | 685 if (!owner()) |
| 686 return E_FAIL; | 686 return E_FAIL; |
| 687 | 687 |
| 688 if (!disp_parent) | 688 if (!disp_parent) |
| 689 return E_INVALIDARG; | 689 return E_INVALIDARG; |
| 690 | 690 |
| 691 IAccessible* parent_obj = | 691 IAccessible* parent_obj = |
| 692 ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()); | 692 ToBrowserAccessibilityComWin(owner()->PlatformGetParent()); |
| 693 if (parent_obj == NULL) { | 693 if (parent_obj == NULL) { |
| 694 // This happens if we're the root of the tree; | 694 // This happens if we're the root of the tree; |
| 695 // return the IAccessible for the window. | 695 // return the IAccessible for the window. |
| 696 parent_obj = | 696 parent_obj = |
| 697 Manager()->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); | 697 Manager()->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); |
| 698 // |parent| can only be NULL if the manager was created before the parent | 698 // |parent| can only be NULL if the manager was created before the parent |
| 699 // IAccessible was known and it wasn't subsequently set before a client | 699 // IAccessible was known and it wasn't subsequently set before a client |
| 700 // requested it. This has been fixed. |parent| may also be NULL during | 700 // requested it. This has been fixed. |parent| may also be NULL during |
| 701 // destruction. Possible cases where this could occur include tabs being | 701 // destruction. Possible cases where this could occur include tabs being |
| 702 // dragged to a new window, etc. | 702 // dragged to a new window, etc. |
| 703 if (!parent_obj) { | 703 if (!parent_obj) { |
| 704 DVLOG(1) << "In Function: " << __func__ | 704 DVLOG(1) << "In Function: " << __func__ |
| 705 << ". Parent IAccessible interface is NULL. Returning failure"; | 705 << ". Parent IAccessible interface is NULL. Returning failure"; |
| 706 return E_FAIL; | 706 return E_FAIL; |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 parent_obj->AddRef(); | 709 parent_obj->AddRef(); |
| 710 *disp_parent = parent_obj; | 710 *disp_parent = parent_obj; |
| 711 return S_OK; | 711 return S_OK; |
| 712 } | 712 } |
| 713 | 713 |
| 714 STDMETHODIMP BrowserAccessibilityComWin::get_accRole(VARIANT var_id, | 714 STDMETHODIMP BrowserAccessibilityComWin::get_accRole(VARIANT var_id, |
| 715 VARIANT* role) { | 715 VARIANT* role) { |
| 716 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_ROLE); | 716 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_ROLE); |
| 717 if (!GetOwner()) | 717 if (!owner()) |
| 718 return E_FAIL; | 718 return E_FAIL; |
| 719 | 719 |
| 720 if (!role) | 720 if (!role) |
| 721 return E_INVALIDARG; | 721 return E_INVALIDARG; |
| 722 | 722 |
| 723 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 723 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 724 if (!target) | 724 if (!target) |
| 725 return E_INVALIDARG; | 725 return E_INVALIDARG; |
| 726 | 726 |
| 727 if (!target->role_name().empty()) { | 727 if (!target->role_name().empty()) { |
| 728 role->vt = VT_BSTR; | 728 role->vt = VT_BSTR; |
| 729 role->bstrVal = SysAllocString(target->role_name().c_str()); | 729 role->bstrVal = SysAllocString(target->role_name().c_str()); |
| 730 } else { | 730 } else { |
| 731 role->vt = VT_I4; | 731 role->vt = VT_I4; |
| 732 role->lVal = target->ia_role(); | 732 role->lVal = target->ia_role(); |
| 733 } | 733 } |
| 734 return S_OK; | 734 return S_OK; |
| 735 } | 735 } |
| 736 | 736 |
| 737 STDMETHODIMP BrowserAccessibilityComWin::get_accState(VARIANT var_id, | 737 STDMETHODIMP BrowserAccessibilityComWin::get_accState(VARIANT var_id, |
| 738 VARIANT* state) { | 738 VARIANT* state) { |
| 739 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE); | 739 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE); |
| 740 if (!GetOwner()) | 740 if (!owner()) |
| 741 return E_FAIL; | 741 return E_FAIL; |
| 742 | 742 |
| 743 auto* manager = Manager(); | 743 auto* manager = Manager(); |
| 744 if (!manager) | 744 if (!manager) |
| 745 return E_FAIL; | 745 return E_FAIL; |
| 746 | 746 |
| 747 if (!state) | 747 if (!state) |
| 748 return E_INVALIDARG; | 748 return E_INVALIDARG; |
| 749 | 749 |
| 750 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 750 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 751 if (!target) | 751 if (!target) |
| 752 return E_INVALIDARG; | 752 return E_INVALIDARG; |
| 753 | 753 |
| 754 state->vt = VT_I4; | 754 state->vt = VT_I4; |
| 755 state->lVal = target->ia_state(); | 755 state->lVal = target->ia_state(); |
| 756 if (manager->GetFocus() == GetOwner()) | 756 if (manager->GetFocus() == owner()) |
| 757 state->lVal |= STATE_SYSTEM_FOCUSED; | 757 state->lVal |= STATE_SYSTEM_FOCUSED; |
| 758 | 758 |
| 759 return S_OK; | 759 return S_OK; |
| 760 } | 760 } |
| 761 | 761 |
| 762 STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, | 762 STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, |
| 763 BSTR* value) { | 763 BSTR* value) { |
| 764 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); | 764 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); |
| 765 if (!GetOwner()) | 765 if (!owner()) |
| 766 return E_FAIL; | 766 return E_FAIL; |
| 767 | 767 |
| 768 if (!value) | 768 if (!value) |
| 769 return E_INVALIDARG; | 769 return E_INVALIDARG; |
| 770 | 770 |
| 771 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 771 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 772 if (!target) | 772 if (!target) |
| 773 return E_INVALIDARG; | 773 return E_INVALIDARG; |
| 774 | 774 |
| 775 if (target->ia_role() == ROLE_SYSTEM_PROGRESSBAR || | 775 if (target->ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| 776 target->ia_role() == ROLE_SYSTEM_SCROLLBAR || | 776 target->ia_role() == ROLE_SYSTEM_SCROLLBAR || |
| 777 target->ia_role() == ROLE_SYSTEM_SLIDER) { | 777 target->ia_role() == ROLE_SYSTEM_SLIDER) { |
| 778 base::string16 value_text = target->GetValueText(); | 778 base::string16 value_text = target->GetValueText(); |
| 779 *value = SysAllocString(value_text.c_str()); | 779 *value = SysAllocString(value_text.c_str()); |
| 780 DCHECK(*value); | 780 DCHECK(*value); |
| 781 return S_OK; | 781 return S_OK; |
| 782 } | 782 } |
| 783 | 783 |
| 784 // Expose color well value. | 784 // Expose color well value. |
| 785 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { | 785 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { |
| 786 unsigned int color = static_cast<unsigned int>( | 786 unsigned int color = static_cast<unsigned int>( |
| 787 target->GetOwner()->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); | 787 target->owner()->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); |
| 788 unsigned int red = SkColorGetR(color); | 788 unsigned int red = SkColorGetR(color); |
| 789 unsigned int green = SkColorGetG(color); | 789 unsigned int green = SkColorGetG(color); |
| 790 unsigned int blue = SkColorGetB(color); | 790 unsigned int blue = SkColorGetB(color); |
| 791 base::string16 value_text; | 791 base::string16 value_text; |
| 792 value_text = base::UintToString16(red * 100 / 255) + L"% red " + | 792 value_text = base::UintToString16(red * 100 / 255) + L"% red " + |
| 793 base::UintToString16(green * 100 / 255) + L"% green " + | 793 base::UintToString16(green * 100 / 255) + L"% green " + |
| 794 base::UintToString16(blue * 100 / 255) + L"% blue"; | 794 base::UintToString16(blue * 100 / 255) + L"% blue"; |
| 795 *value = SysAllocString(value_text.c_str()); | 795 *value = SysAllocString(value_text.c_str()); |
| 796 DCHECK(*value); | 796 DCHECK(*value); |
| 797 return S_OK; | 797 return S_OK; |
| 798 } | 798 } |
| 799 | 799 |
| 800 *value = SysAllocString(target->value().c_str()); | 800 *value = SysAllocString(target->value().c_str()); |
| 801 DCHECK(*value); | 801 DCHECK(*value); |
| 802 return S_OK; | 802 return S_OK; |
| 803 } | 803 } |
| 804 | 804 |
| 805 STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, | 805 STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, |
| 806 VARIANT var_id, | 806 VARIANT var_id, |
| 807 LONG* topic_id) { | 807 LONG* topic_id) { |
| 808 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); | 808 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); |
| 809 return E_NOTIMPL; | 809 return E_NOTIMPL; |
| 810 } | 810 } |
| 811 | 811 |
| 812 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { | 812 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { |
| 813 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); | 813 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); |
| 814 if (!GetOwner()) | 814 if (!owner()) |
| 815 return E_FAIL; | 815 return E_FAIL; |
| 816 | 816 |
| 817 if (GetOwner()->GetRole() != ui::AX_ROLE_LIST_BOX) | 817 if (owner()->GetRole() != ui::AX_ROLE_LIST_BOX) |
| 818 return E_NOTIMPL; | 818 return E_NOTIMPL; |
| 819 | 819 |
| 820 unsigned long selected_count = 0; | 820 unsigned long selected_count = 0; |
| 821 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { | 821 for (size_t i = 0; i < owner()->InternalChildCount(); ++i) { |
| 822 if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) | 822 if (owner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) |
| 823 ++selected_count; | 823 ++selected_count; |
| 824 } | 824 } |
| 825 | 825 |
| 826 if (selected_count == 0) { | 826 if (selected_count == 0) { |
| 827 selected->vt = VT_EMPTY; | 827 selected->vt = VT_EMPTY; |
| 828 return S_OK; | 828 return S_OK; |
| 829 } | 829 } |
| 830 | 830 |
| 831 if (selected_count == 1) { | 831 if (selected_count == 1) { |
| 832 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { | 832 for (size_t i = 0; i < owner()->InternalChildCount(); ++i) { |
| 833 if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { | 833 if (owner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| 834 selected->vt = VT_DISPATCH; | 834 selected->vt = VT_DISPATCH; |
| 835 selected->pdispVal = | 835 selected->pdispVal = |
| 836 ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)) | 836 ToBrowserAccessibilityComWin(owner()->InternalGetChild(i)) |
| 837 ->NewReference(); | 837 ->NewReference(); |
| 838 return S_OK; | 838 return S_OK; |
| 839 } | 839 } |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 | 842 |
| 843 // Multiple items are selected. | 843 // Multiple items are selected. |
| 844 base::win::EnumVariant* enum_variant = | 844 base::win::EnumVariant* enum_variant = |
| 845 new base::win::EnumVariant(selected_count); | 845 new base::win::EnumVariant(selected_count); |
| 846 enum_variant->AddRef(); | 846 enum_variant->AddRef(); |
| 847 unsigned long index = 0; | 847 unsigned long index = 0; |
| 848 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { | 848 for (size_t i = 0; i < owner()->InternalChildCount(); ++i) { |
| 849 if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { | 849 if (owner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| 850 enum_variant->ItemAt(index)->vt = VT_DISPATCH; | 850 enum_variant->ItemAt(index)->vt = VT_DISPATCH; |
| 851 enum_variant->ItemAt(index)->pdispVal = | 851 enum_variant->ItemAt(index)->pdispVal = |
| 852 ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)) | 852 ToBrowserAccessibilityComWin(owner()->InternalGetChild(i)) |
| 853 ->NewReference(); | 853 ->NewReference(); |
| 854 ++index; | 854 ++index; |
| 855 } | 855 } |
| 856 } | 856 } |
| 857 selected->vt = VT_UNKNOWN; | 857 selected->vt = VT_UNKNOWN; |
| 858 selected->punkVal = static_cast<IUnknown*>( | 858 selected->punkVal = static_cast<IUnknown*>( |
| 859 static_cast<base::win::IUnknownImpl*>(enum_variant)); | 859 static_cast<base::win::IUnknownImpl*>(enum_variant)); |
| 860 return S_OK; | 860 return S_OK; |
| 861 } | 861 } |
| 862 | 862 |
| 863 STDMETHODIMP BrowserAccessibilityComWin::accSelect(LONG flags_sel, | 863 STDMETHODIMP BrowserAccessibilityComWin::accSelect(LONG flags_sel, |
| 864 VARIANT var_id) { | 864 VARIANT var_id) { |
| 865 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); | 865 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); |
| 866 if (!GetOwner()) | 866 if (!owner()) |
| 867 return E_FAIL; | 867 return E_FAIL; |
| 868 | 868 |
| 869 auto* manager = Manager(); | 869 auto* manager = Manager(); |
| 870 if (!manager) | 870 if (!manager) |
| 871 return E_FAIL; | 871 return E_FAIL; |
| 872 | 872 |
| 873 if (flags_sel & SELFLAG_TAKEFOCUS) { | 873 if (flags_sel & SELFLAG_TAKEFOCUS) { |
| 874 manager->SetFocus(*GetOwner()); | 874 manager->SetFocus(*owner()); |
| 875 return S_OK; | 875 return S_OK; |
| 876 } | 876 } |
| 877 | 877 |
| 878 return S_FALSE; | 878 return S_FALSE; |
| 879 } | 879 } |
| 880 | 880 |
| 881 STDMETHODIMP | 881 STDMETHODIMP |
| 882 BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { | 882 BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { |
| 883 return E_NOTIMPL; | 883 return E_NOTIMPL; |
| 884 } | 884 } |
| 885 STDMETHODIMP | 885 STDMETHODIMP |
| 886 BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { | 886 BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { |
| 887 return E_NOTIMPL; | 887 return E_NOTIMPL; |
| 888 } | 888 } |
| 889 | 889 |
| 890 // | 890 // |
| 891 // IAccessible2 methods. | 891 // IAccessible2 methods. |
| 892 // | 892 // |
| 893 | 893 |
| 894 STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { | 894 STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { |
| 895 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); | 895 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); |
| 896 if (!GetOwner()) | 896 if (!owner()) |
| 897 return E_FAIL; | 897 return E_FAIL; |
| 898 | 898 |
| 899 if (!role) | 899 if (!role) |
| 900 return E_INVALIDARG; | 900 return E_INVALIDARG; |
| 901 | 901 |
| 902 *role = ia2_role(); | 902 *role = ia2_role(); |
| 903 return S_OK; | 903 return S_OK; |
| 904 } | 904 } |
| 905 | 905 |
| 906 STDMETHODIMP BrowserAccessibilityComWin::get_attributes(BSTR* attributes) { | 906 STDMETHODIMP BrowserAccessibilityComWin::get_attributes(BSTR* attributes) { |
| 907 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES); | 907 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES); |
| 908 if (!GetOwner()) | 908 if (!owner()) |
| 909 return E_FAIL; | 909 return E_FAIL; |
| 910 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 910 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 911 if (!attributes) | 911 if (!attributes) |
| 912 return E_INVALIDARG; | 912 return E_INVALIDARG; |
| 913 *attributes = nullptr; | 913 *attributes = nullptr; |
| 914 | 914 |
| 915 if (!GetOwner()) | 915 if (!owner()) |
| 916 return E_FAIL; | 916 return E_FAIL; |
| 917 | 917 |
| 918 base::string16 str; | 918 base::string16 str; |
| 919 for (const base::string16& attribute : ia2_attributes()) | 919 for (const base::string16& attribute : ia2_attributes()) |
| 920 str += attribute + L';'; | 920 str += attribute + L';'; |
| 921 | 921 |
| 922 if (str.empty()) | 922 if (str.empty()) |
| 923 return S_FALSE; | 923 return S_FALSE; |
| 924 | 924 |
| 925 *attributes = SysAllocString(str.c_str()); | 925 *attributes = SysAllocString(str.c_str()); |
| 926 DCHECK(*attributes); | 926 DCHECK(*attributes); |
| 927 return S_OK; | 927 return S_OK; |
| 928 } | 928 } |
| 929 | 929 |
| 930 STDMETHODIMP BrowserAccessibilityComWin::get_states(AccessibleStates* states) { | 930 STDMETHODIMP BrowserAccessibilityComWin::get_states(AccessibleStates* states) { |
| 931 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES); | 931 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES); |
| 932 if (!GetOwner()) | 932 if (!owner()) |
| 933 return E_FAIL; | 933 return E_FAIL; |
| 934 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 934 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 935 | 935 |
| 936 if (!states) | 936 if (!states) |
| 937 return E_INVALIDARG; | 937 return E_INVALIDARG; |
| 938 | 938 |
| 939 *states = ia2_state(); | 939 *states = ia2_state(); |
| 940 | 940 |
| 941 return S_OK; | 941 return S_OK; |
| 942 } | 942 } |
| 943 | 943 |
| 944 STDMETHODIMP BrowserAccessibilityComWin::get_uniqueID(LONG* unique_id) { | 944 STDMETHODIMP BrowserAccessibilityComWin::get_uniqueID(LONG* unique_id) { |
| 945 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID); | 945 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID); |
| 946 if (!GetOwner()) | 946 if (!owner()) |
| 947 return E_FAIL; | 947 return E_FAIL; |
| 948 | 948 |
| 949 if (!unique_id) | 949 if (!unique_id) |
| 950 return E_INVALIDARG; | 950 return E_INVALIDARG; |
| 951 | 951 |
| 952 *unique_id = -GetOwner()->unique_id(); | 952 *unique_id = -owner()->unique_id(); |
| 953 return S_OK; | 953 return S_OK; |
| 954 } | 954 } |
| 955 | 955 |
| 956 STDMETHODIMP BrowserAccessibilityComWin::get_windowHandle(HWND* window_handle) { | 956 STDMETHODIMP BrowserAccessibilityComWin::get_windowHandle(HWND* window_handle) { |
| 957 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE); | 957 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE); |
| 958 if (!GetOwner()) | 958 if (!owner()) |
| 959 return E_FAIL; | 959 return E_FAIL; |
| 960 | 960 |
| 961 if (!window_handle) | 961 if (!window_handle) |
| 962 return E_INVALIDARG; | 962 return E_INVALIDARG; |
| 963 | 963 |
| 964 *window_handle = | 964 *window_handle = |
| 965 Manager()->ToBrowserAccessibilityManagerWin()->GetParentHWND(); | 965 Manager()->ToBrowserAccessibilityManagerWin()->GetParentHWND(); |
| 966 if (!*window_handle) | 966 if (!*window_handle) |
| 967 return E_FAIL; | 967 return E_FAIL; |
| 968 | 968 |
| 969 return S_OK; | 969 return S_OK; |
| 970 } | 970 } |
| 971 | 971 |
| 972 STDMETHODIMP BrowserAccessibilityComWin::get_indexInParent( | 972 STDMETHODIMP BrowserAccessibilityComWin::get_indexInParent( |
| 973 LONG* index_in_parent) { | 973 LONG* index_in_parent) { |
| 974 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT); | 974 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT); |
| 975 if (!GetOwner()) | 975 if (!owner()) |
| 976 return E_FAIL; | 976 return E_FAIL; |
| 977 | 977 |
| 978 if (!index_in_parent) | 978 if (!index_in_parent) |
| 979 return E_INVALIDARG; | 979 return E_INVALIDARG; |
| 980 | 980 |
| 981 *index_in_parent = GetIndexInParent(); | 981 *index_in_parent = GetIndexInParent(); |
| 982 return S_OK; | 982 return S_OK; |
| 983 } | 983 } |
| 984 | 984 |
| 985 STDMETHODIMP BrowserAccessibilityComWin::get_nRelations(LONG* n_relations) { | 985 STDMETHODIMP BrowserAccessibilityComWin::get_nRelations(LONG* n_relations) { |
| 986 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_RELATIONS); | 986 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_RELATIONS); |
| 987 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 987 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 988 if (!GetOwner()) | 988 if (!owner()) |
| 989 return E_FAIL; | 989 return E_FAIL; |
| 990 | 990 |
| 991 if (!n_relations) | 991 if (!n_relations) |
| 992 return E_INVALIDARG; | 992 return E_INVALIDARG; |
| 993 | 993 |
| 994 *n_relations = relations_.size(); | 994 *n_relations = relations_.size(); |
| 995 return S_OK; | 995 return S_OK; |
| 996 } | 996 } |
| 997 | 997 |
| 998 STDMETHODIMP BrowserAccessibilityComWin::get_relation( | 998 STDMETHODIMP BrowserAccessibilityComWin::get_relation( |
| 999 LONG relation_index, | 999 LONG relation_index, |
| 1000 IAccessibleRelation** relation) { | 1000 IAccessibleRelation** relation) { |
| 1001 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATION); | 1001 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATION); |
| 1002 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1002 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1003 if (!GetOwner()) | 1003 if (!owner()) |
| 1004 return E_FAIL; | 1004 return E_FAIL; |
| 1005 | 1005 |
| 1006 if (relation_index < 0 || | 1006 if (relation_index < 0 || |
| 1007 relation_index >= static_cast<long>(relations_.size())) { | 1007 relation_index >= static_cast<long>(relations_.size())) { |
| 1008 return E_INVALIDARG; | 1008 return E_INVALIDARG; |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 if (!relation) | 1011 if (!relation) |
| 1012 return E_INVALIDARG; | 1012 return E_INVALIDARG; |
| 1013 | 1013 |
| 1014 relations_[relation_index]->AddRef(); | 1014 relations_[relation_index]->AddRef(); |
| 1015 *relation = relations_[relation_index]; | 1015 *relation = relations_[relation_index]; |
| 1016 return S_OK; | 1016 return S_OK; |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 STDMETHODIMP BrowserAccessibilityComWin::get_relations( | 1019 STDMETHODIMP BrowserAccessibilityComWin::get_relations( |
| 1020 LONG max_relations, | 1020 LONG max_relations, |
| 1021 IAccessibleRelation** relations, | 1021 IAccessibleRelation** relations, |
| 1022 LONG* n_relations) { | 1022 LONG* n_relations) { |
| 1023 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATIONS); | 1023 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATIONS); |
| 1024 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1024 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1025 if (!GetOwner()) | 1025 if (!owner()) |
| 1026 return E_FAIL; | 1026 return E_FAIL; |
| 1027 | 1027 |
| 1028 if (!relations || !n_relations) | 1028 if (!relations || !n_relations) |
| 1029 return E_INVALIDARG; | 1029 return E_INVALIDARG; |
| 1030 | 1030 |
| 1031 long count = static_cast<long>(relations_.size()); | 1031 long count = static_cast<long>(relations_.size()); |
| 1032 *n_relations = count; | 1032 *n_relations = count; |
| 1033 if (count == 0) | 1033 if (count == 0) |
| 1034 return S_FALSE; | 1034 return S_FALSE; |
| 1035 | 1035 |
| 1036 for (long i = 0; i < count; ++i) { | 1036 for (long i = 0; i < count; ++i) { |
| 1037 relations_[i]->AddRef(); | 1037 relations_[i]->AddRef(); |
| 1038 relations[i] = relations_[i]; | 1038 relations[i] = relations_[i]; |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 return S_OK; | 1041 return S_OK; |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 STDMETHODIMP BrowserAccessibilityComWin::scrollTo(IA2ScrollType scroll_type) { | 1044 STDMETHODIMP BrowserAccessibilityComWin::scrollTo(IA2ScrollType scroll_type) { |
| 1045 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_SCROLL_TO); | 1045 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_SCROLL_TO); |
| 1046 if (!GetOwner()) | 1046 if (!owner()) |
| 1047 return E_FAIL; | 1047 return E_FAIL; |
| 1048 | 1048 |
| 1049 auto* manager = Manager(); | 1049 auto* manager = Manager(); |
| 1050 | 1050 |
| 1051 if (!manager) | 1051 if (!manager) |
| 1052 return E_FAIL; | 1052 return E_FAIL; |
| 1053 | 1053 |
| 1054 gfx::Rect r = GetOwner()->GetFrameBoundsRect(); | 1054 gfx::Rect r = owner()->GetFrameBoundsRect(); |
| 1055 switch (scroll_type) { | 1055 switch (scroll_type) { |
| 1056 case IA2_SCROLL_TYPE_TOP_LEFT: | 1056 case IA2_SCROLL_TYPE_TOP_LEFT: |
| 1057 manager->ScrollToMakeVisible(*GetOwner(), gfx::Rect(r.x(), r.y(), 0, 0)); | 1057 manager->ScrollToMakeVisible(*owner(), gfx::Rect(r.x(), r.y(), 0, 0)); |
| 1058 break; | 1058 break; |
| 1059 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: | 1059 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: |
| 1060 manager->ScrollToMakeVisible(*GetOwner(), | 1060 manager->ScrollToMakeVisible(*owner(), |
| 1061 gfx::Rect(r.right(), r.bottom(), 0, 0)); | 1061 gfx::Rect(r.right(), r.bottom(), 0, 0)); |
| 1062 break; | 1062 break; |
| 1063 case IA2_SCROLL_TYPE_TOP_EDGE: | 1063 case IA2_SCROLL_TYPE_TOP_EDGE: |
| 1064 manager->ScrollToMakeVisible(*GetOwner(), | 1064 manager->ScrollToMakeVisible(*owner(), |
| 1065 gfx::Rect(r.x(), r.y(), r.width(), 0)); | 1065 gfx::Rect(r.x(), r.y(), r.width(), 0)); |
| 1066 break; | 1066 break; |
| 1067 case IA2_SCROLL_TYPE_BOTTOM_EDGE: | 1067 case IA2_SCROLL_TYPE_BOTTOM_EDGE: |
| 1068 manager->ScrollToMakeVisible(*GetOwner(), | 1068 manager->ScrollToMakeVisible(*owner(), |
| 1069 gfx::Rect(r.x(), r.bottom(), r.width(), 0)); | 1069 gfx::Rect(r.x(), r.bottom(), r.width(), 0)); |
| 1070 break; | 1070 break; |
| 1071 case IA2_SCROLL_TYPE_LEFT_EDGE: | 1071 case IA2_SCROLL_TYPE_LEFT_EDGE: |
| 1072 manager->ScrollToMakeVisible(*GetOwner(), | 1072 manager->ScrollToMakeVisible(*owner(), |
| 1073 gfx::Rect(r.x(), r.y(), 0, r.height())); | 1073 gfx::Rect(r.x(), r.y(), 0, r.height())); |
| 1074 break; | 1074 break; |
| 1075 case IA2_SCROLL_TYPE_RIGHT_EDGE: | 1075 case IA2_SCROLL_TYPE_RIGHT_EDGE: |
| 1076 manager->ScrollToMakeVisible(*GetOwner(), | 1076 manager->ScrollToMakeVisible(*owner(), |
| 1077 gfx::Rect(r.right(), r.y(), 0, r.height())); | 1077 gfx::Rect(r.right(), r.y(), 0, r.height())); |
| 1078 break; | 1078 break; |
| 1079 case IA2_SCROLL_TYPE_ANYWHERE: | 1079 case IA2_SCROLL_TYPE_ANYWHERE: |
| 1080 default: | 1080 default: |
| 1081 manager->ScrollToMakeVisible(*GetOwner(), r); | 1081 manager->ScrollToMakeVisible(*owner(), r); |
| 1082 break; | 1082 break; |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 return S_OK; | 1085 return S_OK; |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 STDMETHODIMP BrowserAccessibilityComWin::scrollToPoint( | 1088 STDMETHODIMP BrowserAccessibilityComWin::scrollToPoint( |
| 1089 IA2CoordinateType coordinate_type, | 1089 IA2CoordinateType coordinate_type, |
| 1090 LONG x, | 1090 LONG x, |
| 1091 LONG y) { | 1091 LONG y) { |
| 1092 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT); | 1092 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT); |
| 1093 if (!GetOwner()) | 1093 if (!owner()) |
| 1094 return E_FAIL; | 1094 return E_FAIL; |
| 1095 | 1095 |
| 1096 auto* manager = Manager(); | 1096 auto* manager = Manager(); |
| 1097 if (!manager) | 1097 if (!manager) |
| 1098 return E_FAIL; | 1098 return E_FAIL; |
| 1099 | 1099 |
| 1100 gfx::Point scroll_to(x, y); | 1100 gfx::Point scroll_to(x, y); |
| 1101 | 1101 |
| 1102 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1102 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 1103 scroll_to -= manager->GetViewBounds().OffsetFromOrigin(); | 1103 scroll_to -= manager->GetViewBounds().OffsetFromOrigin(); |
| 1104 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 1104 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 1105 if (GetOwner()->PlatformGetParent()) { | 1105 if (owner()->PlatformGetParent()) { |
| 1106 scroll_to += GetOwner() | 1106 scroll_to += |
| 1107 ->PlatformGetParent() | 1107 owner()->PlatformGetParent()->GetFrameBoundsRect().OffsetFromOrigin(); |
| 1108 ->GetFrameBoundsRect() | |
| 1109 .OffsetFromOrigin(); | |
| 1110 } | 1108 } |
| 1111 } else { | 1109 } else { |
| 1112 return E_INVALIDARG; | 1110 return E_INVALIDARG; |
| 1113 } | 1111 } |
| 1114 | 1112 |
| 1115 manager->ScrollToPoint(*GetOwner(), scroll_to); | 1113 manager->ScrollToPoint(*owner(), scroll_to); |
| 1116 | 1114 |
| 1117 return S_OK; | 1115 return S_OK; |
| 1118 } | 1116 } |
| 1119 | 1117 |
| 1120 STDMETHODIMP BrowserAccessibilityComWin::get_groupPosition( | 1118 STDMETHODIMP BrowserAccessibilityComWin::get_groupPosition( |
| 1121 LONG* group_level, | 1119 LONG* group_level, |
| 1122 LONG* similar_items_in_group, | 1120 LONG* similar_items_in_group, |
| 1123 LONG* position_in_group) { | 1121 LONG* position_in_group) { |
| 1124 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_GROUP_POSITION); | 1122 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_GROUP_POSITION); |
| 1125 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1123 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1126 if (!GetOwner()) | 1124 if (!owner()) |
| 1127 return E_FAIL; | 1125 return E_FAIL; |
| 1128 | 1126 |
| 1129 if (!group_level || !similar_items_in_group || !position_in_group) | 1127 if (!group_level || !similar_items_in_group || !position_in_group) |
| 1130 return E_INVALIDARG; | 1128 return E_INVALIDARG; |
| 1131 | 1129 |
| 1132 *group_level = GetOwner()->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); | 1130 *group_level = owner()->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); |
| 1133 *similar_items_in_group = GetOwner()->GetIntAttribute(ui::AX_ATTR_SET_SIZE); | 1131 *similar_items_in_group = owner()->GetIntAttribute(ui::AX_ATTR_SET_SIZE); |
| 1134 *position_in_group = GetOwner()->GetIntAttribute(ui::AX_ATTR_POS_IN_SET); | 1132 *position_in_group = owner()->GetIntAttribute(ui::AX_ATTR_POS_IN_SET); |
| 1135 | 1133 |
| 1136 if (*group_level == *similar_items_in_group == *position_in_group == 0) | 1134 if (*group_level == *similar_items_in_group == *position_in_group == 0) |
| 1137 return S_FALSE; | 1135 return S_FALSE; |
| 1138 return S_OK; | 1136 return S_OK; |
| 1139 } | 1137 } |
| 1140 | 1138 |
| 1141 STDMETHODIMP | 1139 STDMETHODIMP |
| 1142 BrowserAccessibilityComWin::get_localizedExtendedRole( | 1140 BrowserAccessibilityComWin::get_localizedExtendedRole( |
| 1143 BSTR* localized_extended_role) { | 1141 BSTR* localized_extended_role) { |
| 1144 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_ROLE); | 1142 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_ROLE); |
| 1145 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1143 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1146 if (!GetOwner()) | 1144 if (!owner()) |
| 1147 return E_FAIL; | 1145 return E_FAIL; |
| 1148 | 1146 |
| 1149 if (!localized_extended_role) | 1147 if (!localized_extended_role) |
| 1150 return E_INVALIDARG; | 1148 return E_INVALIDARG; |
| 1151 | 1149 |
| 1152 return GetStringAttributeAsBstr(ui::AX_ATTR_ROLE_DESCRIPTION, | 1150 return GetStringAttributeAsBstr(ui::AX_ATTR_ROLE_DESCRIPTION, |
| 1153 localized_extended_role); | 1151 localized_extended_role); |
| 1154 } | 1152 } |
| 1155 | 1153 |
| 1156 // | 1154 // |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 DCHECK(*toolkit_version); | 1256 DCHECK(*toolkit_version); |
| 1259 return *toolkit_version ? S_OK : E_FAIL; | 1257 return *toolkit_version ? S_OK : E_FAIL; |
| 1260 } | 1258 } |
| 1261 | 1259 |
| 1262 // | 1260 // |
| 1263 // IAccessibleImage methods. | 1261 // IAccessibleImage methods. |
| 1264 // | 1262 // |
| 1265 | 1263 |
| 1266 STDMETHODIMP BrowserAccessibilityComWin::get_description(BSTR* desc) { | 1264 STDMETHODIMP BrowserAccessibilityComWin::get_description(BSTR* desc) { |
| 1267 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DESCRIPTION); | 1265 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DESCRIPTION); |
| 1268 if (!GetOwner()) | 1266 if (!owner()) |
| 1269 return E_FAIL; | 1267 return E_FAIL; |
| 1270 | 1268 |
| 1271 if (!desc) | 1269 if (!desc) |
| 1272 return E_INVALIDARG; | 1270 return E_INVALIDARG; |
| 1273 | 1271 |
| 1274 if (description().empty()) | 1272 if (description().empty()) |
| 1275 return S_FALSE; | 1273 return S_FALSE; |
| 1276 | 1274 |
| 1277 *desc = SysAllocString(description().c_str()); | 1275 *desc = SysAllocString(description().c_str()); |
| 1278 | 1276 |
| 1279 DCHECK(*desc); | 1277 DCHECK(*desc); |
| 1280 return S_OK; | 1278 return S_OK; |
| 1281 } | 1279 } |
| 1282 | 1280 |
| 1283 STDMETHODIMP BrowserAccessibilityComWin::get_imagePosition( | 1281 STDMETHODIMP BrowserAccessibilityComWin::get_imagePosition( |
| 1284 IA2CoordinateType coordinate_type, | 1282 IA2CoordinateType coordinate_type, |
| 1285 LONG* x, | 1283 LONG* x, |
| 1286 LONG* y) { | 1284 LONG* y) { |
| 1287 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_POSITION); | 1285 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_POSITION); |
| 1288 if (!GetOwner()) | 1286 if (!owner()) |
| 1289 return E_FAIL; | 1287 return E_FAIL; |
| 1290 | 1288 |
| 1291 if (!x || !y) | 1289 if (!x || !y) |
| 1292 return E_INVALIDARG; | 1290 return E_INVALIDARG; |
| 1293 | 1291 |
| 1294 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1292 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 1295 gfx::Rect bounds = GetOwner()->GetScreenBoundsRect(); | 1293 gfx::Rect bounds = owner()->GetScreenBoundsRect(); |
| 1296 *x = bounds.x(); | 1294 *x = bounds.x(); |
| 1297 *y = bounds.y(); | 1295 *y = bounds.y(); |
| 1298 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 1296 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 1299 gfx::Rect bounds = GetOwner()->GetPageBoundsRect(); | 1297 gfx::Rect bounds = owner()->GetPageBoundsRect(); |
| 1300 gfx::Rect parent_bounds = | 1298 gfx::Rect parent_bounds = |
| 1301 GetOwner()->PlatformGetParent() | 1299 owner()->PlatformGetParent() |
| 1302 ? GetOwner()->PlatformGetParent()->GetPageBoundsRect() | 1300 ? owner()->PlatformGetParent()->GetPageBoundsRect() |
| 1303 : gfx::Rect(); | 1301 : gfx::Rect(); |
| 1304 *x = bounds.x() - parent_bounds.x(); | 1302 *x = bounds.x() - parent_bounds.x(); |
| 1305 *y = bounds.y() - parent_bounds.y(); | 1303 *y = bounds.y() - parent_bounds.y(); |
| 1306 } else { | 1304 } else { |
| 1307 return E_INVALIDARG; | 1305 return E_INVALIDARG; |
| 1308 } | 1306 } |
| 1309 | 1307 |
| 1310 return S_OK; | 1308 return S_OK; |
| 1311 } | 1309 } |
| 1312 | 1310 |
| 1313 STDMETHODIMP BrowserAccessibilityComWin::get_imageSize(LONG* height, | 1311 STDMETHODIMP BrowserAccessibilityComWin::get_imageSize(LONG* height, |
| 1314 LONG* width) { | 1312 LONG* width) { |
| 1315 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_SIZE); | 1313 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_SIZE); |
| 1316 if (!GetOwner()) | 1314 if (!owner()) |
| 1317 return E_FAIL; | 1315 return E_FAIL; |
| 1318 | 1316 |
| 1319 if (!height || !width) | 1317 if (!height || !width) |
| 1320 return E_INVALIDARG; | 1318 return E_INVALIDARG; |
| 1321 | 1319 |
| 1322 *height = GetOwner()->GetPageBoundsRect().height(); | 1320 *height = owner()->GetPageBoundsRect().height(); |
| 1323 *width = GetOwner()->GetPageBoundsRect().width(); | 1321 *width = owner()->GetPageBoundsRect().width(); |
| 1324 return S_OK; | 1322 return S_OK; |
| 1325 } | 1323 } |
| 1326 | 1324 |
| 1327 // | 1325 // |
| 1328 // IAccessibleTable methods. | 1326 // IAccessibleTable methods. |
| 1329 // | 1327 // |
| 1330 | 1328 |
| 1331 STDMETHODIMP BrowserAccessibilityComWin::get_accessibleAt( | 1329 STDMETHODIMP BrowserAccessibilityComWin::get_accessibleAt( |
| 1332 long row, | 1330 long row, |
| 1333 long column, | 1331 long column, |
| 1334 IUnknown** accessible) { | 1332 IUnknown** accessible) { |
| 1335 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT); | 1333 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT); |
| 1336 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1334 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1337 if (!GetOwner()) | 1335 if (!owner()) |
| 1338 return E_FAIL; | 1336 return E_FAIL; |
| 1339 | 1337 |
| 1340 if (!accessible) | 1338 if (!accessible) |
| 1341 return E_INVALIDARG; | 1339 return E_INVALIDARG; |
| 1342 | 1340 |
| 1343 BrowserAccessibility* cell = | 1341 BrowserAccessibility* cell = |
| 1344 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1342 owner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1345 if (cell && ToBrowserAccessibilityComWin(cell)) { | 1343 if (cell && ToBrowserAccessibilityComWin(cell)) { |
| 1346 *accessible = static_cast<IAccessible*>( | 1344 *accessible = static_cast<IAccessible*>( |
| 1347 ToBrowserAccessibilityComWin(cell)->NewReference()); | 1345 ToBrowserAccessibilityComWin(cell)->NewReference()); |
| 1348 return S_OK; | 1346 return S_OK; |
| 1349 } | 1347 } |
| 1350 | 1348 |
| 1351 *accessible = nullptr; | 1349 *accessible = nullptr; |
| 1352 return E_INVALIDARG; | 1350 return E_INVALIDARG; |
| 1353 } | 1351 } |
| 1354 | 1352 |
| 1355 STDMETHODIMP BrowserAccessibilityComWin::get_caption(IUnknown** accessible) { | 1353 STDMETHODIMP BrowserAccessibilityComWin::get_caption(IUnknown** accessible) { |
| 1356 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION); | 1354 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION); |
| 1357 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1355 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1358 if (!GetOwner()) | 1356 if (!owner()) |
| 1359 return E_FAIL; | 1357 return E_FAIL; |
| 1360 | 1358 |
| 1361 if (!accessible) | 1359 if (!accessible) |
| 1362 return E_INVALIDARG; | 1360 return E_INVALIDARG; |
| 1363 | 1361 |
| 1364 // TODO(dmazzoni): implement | 1362 // TODO(dmazzoni): implement |
| 1365 *accessible = nullptr; | 1363 *accessible = nullptr; |
| 1366 return S_FALSE; | 1364 return S_FALSE; |
| 1367 } | 1365 } |
| 1368 | 1366 |
| 1369 STDMETHODIMP BrowserAccessibilityComWin::get_childIndex(long row, | 1367 STDMETHODIMP BrowserAccessibilityComWin::get_childIndex(long row, |
| 1370 long column, | 1368 long column, |
| 1371 long* cell_index) { | 1369 long* cell_index) { |
| 1372 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX); | 1370 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX); |
| 1373 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1371 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1374 if (!GetOwner()) | 1372 if (!owner()) |
| 1375 return E_FAIL; | 1373 return E_FAIL; |
| 1376 | 1374 |
| 1377 if (!cell_index) | 1375 if (!cell_index) |
| 1378 return E_INVALIDARG; | 1376 return E_INVALIDARG; |
| 1379 | 1377 |
| 1380 BrowserAccessibility* cell = | 1378 BrowserAccessibility* cell = |
| 1381 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1379 owner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1382 if (cell) { | 1380 if (cell) { |
| 1383 *cell_index = static_cast<LONG>(cell->GetTableCellIndex()); | 1381 *cell_index = static_cast<LONG>(cell->GetTableCellIndex()); |
| 1384 return S_OK; | 1382 return S_OK; |
| 1385 } | 1383 } |
| 1386 | 1384 |
| 1387 *cell_index = 0; | 1385 *cell_index = 0; |
| 1388 return E_INVALIDARG; | 1386 return E_INVALIDARG; |
| 1389 } | 1387 } |
| 1390 | 1388 |
| 1391 STDMETHODIMP BrowserAccessibilityComWin::get_columnDescription( | 1389 STDMETHODIMP BrowserAccessibilityComWin::get_columnDescription( |
| 1392 long column, | 1390 long column, |
| 1393 BSTR* description) { | 1391 BSTR* description) { |
| 1394 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION); | 1392 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION); |
| 1395 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1393 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1396 if (!GetOwner()) | 1394 if (!owner()) |
| 1397 return E_FAIL; | 1395 return E_FAIL; |
| 1398 | 1396 |
| 1399 if (!description) | 1397 if (!description) |
| 1400 return E_INVALIDARG; | 1398 return E_INVALIDARG; |
| 1401 | 1399 |
| 1402 int columns = GetOwner()->GetTableColumnCount(); | 1400 int columns = owner()->GetTableColumnCount(); |
| 1403 if (column < 0 || column >= columns) | 1401 if (column < 0 || column >= columns) |
| 1404 return E_INVALIDARG; | 1402 return E_INVALIDARG; |
| 1405 | 1403 |
| 1406 int rows = GetOwner()->GetTableRowCount(); | 1404 int rows = owner()->GetTableRowCount(); |
| 1407 if (rows <= 0) { | 1405 if (rows <= 0) { |
| 1408 *description = nullptr; | 1406 *description = nullptr; |
| 1409 return S_FALSE; | 1407 return S_FALSE; |
| 1410 } | 1408 } |
| 1411 | 1409 |
| 1412 for (int i = 0; i < rows; ++i) { | 1410 for (int i = 0; i < rows; ++i) { |
| 1413 BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); | 1411 BrowserAccessibility* cell = owner()->GetTableCell(i, column); |
| 1414 if (ToBrowserAccessibilityComWin(cell) && | 1412 if (ToBrowserAccessibilityComWin(cell) && |
| 1415 cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { | 1413 cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
| 1416 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); | 1414 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); |
| 1417 if (cell_name.size() > 0) { | 1415 if (cell_name.size() > 0) { |
| 1418 *description = SysAllocString(cell_name.c_str()); | 1416 *description = SysAllocString(cell_name.c_str()); |
| 1419 return S_OK; | 1417 return S_OK; |
| 1420 } | 1418 } |
| 1421 | 1419 |
| 1422 if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { | 1420 if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { |
| 1423 *description = SysAllocString( | 1421 *description = SysAllocString( |
| 1424 ToBrowserAccessibilityComWin(cell)->description().c_str()); | 1422 ToBrowserAccessibilityComWin(cell)->description().c_str()); |
| 1425 return S_OK; | 1423 return S_OK; |
| 1426 } | 1424 } |
| 1427 } | 1425 } |
| 1428 } | 1426 } |
| 1429 | 1427 |
| 1430 *description = nullptr; | 1428 *description = nullptr; |
| 1431 return S_FALSE; | 1429 return S_FALSE; |
| 1432 } | 1430 } |
| 1433 | 1431 |
| 1434 STDMETHODIMP BrowserAccessibilityComWin::get_columnExtentAt( | 1432 STDMETHODIMP BrowserAccessibilityComWin::get_columnExtentAt( |
| 1435 long row, | 1433 long row, |
| 1436 long column, | 1434 long column, |
| 1437 long* n_columns_spanned) { | 1435 long* n_columns_spanned) { |
| 1438 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT); | 1436 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT); |
| 1439 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1437 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1440 if (!GetOwner()) | 1438 if (!owner()) |
| 1441 return E_FAIL; | 1439 return E_FAIL; |
| 1442 | 1440 |
| 1443 if (!n_columns_spanned) | 1441 if (!n_columns_spanned) |
| 1444 return E_INVALIDARG; | 1442 return E_INVALIDARG; |
| 1445 | 1443 |
| 1446 BrowserAccessibility* cell = | 1444 BrowserAccessibility* cell = |
| 1447 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1445 owner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1448 if (!cell) | 1446 if (!cell) |
| 1449 return E_INVALIDARG; | 1447 return E_INVALIDARG; |
| 1450 | 1448 |
| 1451 *n_columns_spanned = cell->GetTableColumnSpan(); | 1449 *n_columns_spanned = cell->GetTableColumnSpan(); |
| 1452 return S_OK; | 1450 return S_OK; |
| 1453 } | 1451 } |
| 1454 | 1452 |
| 1455 STDMETHODIMP BrowserAccessibilityComWin::get_columnHeader( | 1453 STDMETHODIMP BrowserAccessibilityComWin::get_columnHeader( |
| 1456 IAccessibleTable** accessible_table, | 1454 IAccessibleTable** accessible_table, |
| 1457 long* starting_row_index) { | 1455 long* starting_row_index) { |
| 1458 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER); | 1456 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER); |
| 1459 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1457 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1460 // TODO(dmazzoni): implement | 1458 // TODO(dmazzoni): implement |
| 1461 return E_NOTIMPL; | 1459 return E_NOTIMPL; |
| 1462 } | 1460 } |
| 1463 | 1461 |
| 1464 STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long cell_index, | 1462 STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long cell_index, |
| 1465 long* column_index) { | 1463 long* column_index) { |
| 1466 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX); | 1464 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX); |
| 1467 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1465 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1468 if (!GetOwner()) | 1466 if (!owner()) |
| 1469 return E_FAIL; | 1467 return E_FAIL; |
| 1470 | 1468 |
| 1471 if (!column_index) | 1469 if (!column_index) |
| 1472 return E_INVALIDARG; | 1470 return E_INVALIDARG; |
| 1473 | 1471 |
| 1474 BrowserAccessibility* cell = GetOwner()->GetTableCell(cell_index); | 1472 BrowserAccessibility* cell = owner()->GetTableCell(cell_index); |
| 1475 if (!cell) | 1473 if (!cell) |
| 1476 return E_INVALIDARG; | 1474 return E_INVALIDARG; |
| 1477 *column_index = cell->GetTableColumn(); | 1475 *column_index = cell->GetTableColumn(); |
| 1478 return S_OK; | 1476 return S_OK; |
| 1479 } | 1477 } |
| 1480 | 1478 |
| 1481 STDMETHODIMP BrowserAccessibilityComWin::get_nColumns(long* column_count) { | 1479 STDMETHODIMP BrowserAccessibilityComWin::get_nColumns(long* column_count) { |
| 1482 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS); | 1480 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS); |
| 1483 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1481 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1484 if (!GetOwner()) | 1482 if (!owner()) |
| 1485 return E_FAIL; | 1483 return E_FAIL; |
| 1486 | 1484 |
| 1487 if (!column_count) | 1485 if (!column_count) |
| 1488 return E_INVALIDARG; | 1486 return E_INVALIDARG; |
| 1489 | 1487 |
| 1490 *column_count = GetOwner()->GetTableColumnCount(); | 1488 *column_count = owner()->GetTableColumnCount(); |
| 1491 return S_OK; | 1489 return S_OK; |
| 1492 } | 1490 } |
| 1493 | 1491 |
| 1494 STDMETHODIMP BrowserAccessibilityComWin::get_nRows(long* row_count) { | 1492 STDMETHODIMP BrowserAccessibilityComWin::get_nRows(long* row_count) { |
| 1495 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS); | 1493 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS); |
| 1496 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1494 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1497 if (!GetOwner()) | 1495 if (!owner()) |
| 1498 return E_FAIL; | 1496 return E_FAIL; |
| 1499 | 1497 |
| 1500 if (!row_count) | 1498 if (!row_count) |
| 1501 return E_INVALIDARG; | 1499 return E_INVALIDARG; |
| 1502 | 1500 |
| 1503 *row_count = GetOwner()->GetTableRowCount(); | 1501 *row_count = owner()->GetTableRowCount(); |
| 1504 return S_OK; | 1502 return S_OK; |
| 1505 } | 1503 } |
| 1506 | 1504 |
| 1507 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedChildren( | 1505 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedChildren( |
| 1508 long* cell_count) { | 1506 long* cell_count) { |
| 1509 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN); | 1507 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN); |
| 1510 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1508 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1511 if (!GetOwner()) | 1509 if (!owner()) |
| 1512 return E_FAIL; | 1510 return E_FAIL; |
| 1513 | 1511 |
| 1514 if (!cell_count) | 1512 if (!cell_count) |
| 1515 return E_INVALIDARG; | 1513 return E_INVALIDARG; |
| 1516 | 1514 |
| 1517 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. | 1515 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. |
| 1518 *cell_count = 0; | 1516 *cell_count = 0; |
| 1519 return S_FALSE; | 1517 return S_FALSE; |
| 1520 } | 1518 } |
| 1521 | 1519 |
| 1522 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedColumns( | 1520 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedColumns( |
| 1523 long* column_count) { | 1521 long* column_count) { |
| 1524 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS); | 1522 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS); |
| 1525 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1523 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1526 if (!GetOwner()) | 1524 if (!owner()) |
| 1527 return E_FAIL; | 1525 return E_FAIL; |
| 1528 | 1526 |
| 1529 if (!column_count) | 1527 if (!column_count) |
| 1530 return E_INVALIDARG; | 1528 return E_INVALIDARG; |
| 1531 | 1529 |
| 1532 *column_count = 0; | 1530 *column_count = 0; |
| 1533 return S_FALSE; | 1531 return S_FALSE; |
| 1534 } | 1532 } |
| 1535 | 1533 |
| 1536 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedRows(long* row_count) { | 1534 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedRows(long* row_count) { |
| 1537 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS); | 1535 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS); |
| 1538 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1536 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1539 if (!GetOwner()) | 1537 if (!owner()) |
| 1540 return E_FAIL; | 1538 return E_FAIL; |
| 1541 | 1539 |
| 1542 if (!row_count) | 1540 if (!row_count) |
| 1543 return E_INVALIDARG; | 1541 return E_INVALIDARG; |
| 1544 | 1542 |
| 1545 *row_count = 0; | 1543 *row_count = 0; |
| 1546 return S_FALSE; | 1544 return S_FALSE; |
| 1547 } | 1545 } |
| 1548 | 1546 |
| 1549 STDMETHODIMP BrowserAccessibilityComWin::get_rowDescription(long row, | 1547 STDMETHODIMP BrowserAccessibilityComWin::get_rowDescription(long row, |
| 1550 BSTR* description) { | 1548 BSTR* description) { |
| 1551 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION); | 1549 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION); |
| 1552 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1550 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1553 if (!GetOwner()) | 1551 if (!owner()) |
| 1554 return E_FAIL; | 1552 return E_FAIL; |
| 1555 | 1553 |
| 1556 if (!description) | 1554 if (!description) |
| 1557 return E_INVALIDARG; | 1555 return E_INVALIDARG; |
| 1558 | 1556 |
| 1559 if (row < 0 || row >= GetOwner()->GetTableRowCount()) | 1557 if (row < 0 || row >= owner()->GetTableRowCount()) |
| 1560 return E_INVALIDARG; | 1558 return E_INVALIDARG; |
| 1561 | 1559 |
| 1562 int columns = GetOwner()->GetTableColumnCount(); | 1560 int columns = owner()->GetTableColumnCount(); |
| 1563 if (columns <= 0) { | 1561 if (columns <= 0) { |
| 1564 *description = nullptr; | 1562 *description = nullptr; |
| 1565 return S_FALSE; | 1563 return S_FALSE; |
| 1566 } | 1564 } |
| 1567 | 1565 |
| 1568 for (int i = 0; i < columns; ++i) { | 1566 for (int i = 0; i < columns; ++i) { |
| 1569 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); | 1567 BrowserAccessibility* cell = owner()->GetTableCell(row, i); |
| 1570 if (ToBrowserAccessibilityComWin(cell) && | 1568 if (ToBrowserAccessibilityComWin(cell) && |
| 1571 cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { | 1569 cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
| 1572 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); | 1570 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); |
| 1573 if (cell_name.size() > 0) { | 1571 if (cell_name.size() > 0) { |
| 1574 *description = SysAllocString(cell_name.c_str()); | 1572 *description = SysAllocString(cell_name.c_str()); |
| 1575 return S_OK; | 1573 return S_OK; |
| 1576 } | 1574 } |
| 1577 | 1575 |
| 1578 if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { | 1576 if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { |
| 1579 *description = SysAllocString( | 1577 *description = SysAllocString( |
| 1580 ToBrowserAccessibilityComWin(cell)->description().c_str()); | 1578 ToBrowserAccessibilityComWin(cell)->description().c_str()); |
| 1581 return S_OK; | 1579 return S_OK; |
| 1582 } | 1580 } |
| 1583 } | 1581 } |
| 1584 } | 1582 } |
| 1585 | 1583 |
| 1586 *description = nullptr; | 1584 *description = nullptr; |
| 1587 return S_FALSE; | 1585 return S_FALSE; |
| 1588 } | 1586 } |
| 1589 | 1587 |
| 1590 STDMETHODIMP BrowserAccessibilityComWin::get_rowExtentAt(long row, | 1588 STDMETHODIMP BrowserAccessibilityComWin::get_rowExtentAt(long row, |
| 1591 long column, | 1589 long column, |
| 1592 long* n_rows_spanned) { | 1590 long* n_rows_spanned) { |
| 1593 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT); | 1591 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT); |
| 1594 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1592 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1595 if (!GetOwner()) | 1593 if (!owner()) |
| 1596 return E_FAIL; | 1594 return E_FAIL; |
| 1597 | 1595 |
| 1598 if (!n_rows_spanned) | 1596 if (!n_rows_spanned) |
| 1599 return E_INVALIDARG; | 1597 return E_INVALIDARG; |
| 1600 | 1598 |
| 1601 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, column); | 1599 BrowserAccessibility* cell = owner()->GetTableCell(row, column); |
| 1602 if (!cell) | 1600 if (!cell) |
| 1603 return E_INVALIDARG; | 1601 return E_INVALIDARG; |
| 1604 | 1602 |
| 1605 *n_rows_spanned = GetOwner()->GetTableRowSpan(); | 1603 *n_rows_spanned = owner()->GetTableRowSpan(); |
| 1606 return S_OK; | 1604 return S_OK; |
| 1607 } | 1605 } |
| 1608 | 1606 |
| 1609 STDMETHODIMP BrowserAccessibilityComWin::get_rowHeader( | 1607 STDMETHODIMP BrowserAccessibilityComWin::get_rowHeader( |
| 1610 IAccessibleTable** accessible_table, | 1608 IAccessibleTable** accessible_table, |
| 1611 long* starting_column_index) { | 1609 long* starting_column_index) { |
| 1612 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER); | 1610 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER); |
| 1613 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1611 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1614 // TODO(dmazzoni): implement | 1612 // TODO(dmazzoni): implement |
| 1615 return E_NOTIMPL; | 1613 return E_NOTIMPL; |
| 1616 } | 1614 } |
| 1617 | 1615 |
| 1618 STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long cell_index, | 1616 STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long cell_index, |
| 1619 long* row_index) { | 1617 long* row_index) { |
| 1620 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_INDEX); | 1618 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_INDEX); |
| 1621 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1619 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1622 if (!GetOwner()) | 1620 if (!owner()) |
| 1623 return E_FAIL; | 1621 return E_FAIL; |
| 1624 | 1622 |
| 1625 if (!row_index) | 1623 if (!row_index) |
| 1626 return E_INVALIDARG; | 1624 return E_INVALIDARG; |
| 1627 | 1625 |
| 1628 BrowserAccessibility* cell = GetOwner()->GetTableCell(cell_index); | 1626 BrowserAccessibility* cell = owner()->GetTableCell(cell_index); |
| 1629 if (!cell) | 1627 if (!cell) |
| 1630 return E_INVALIDARG; | 1628 return E_INVALIDARG; |
| 1631 | 1629 |
| 1632 *row_index = cell->GetTableRow(); | 1630 *row_index = cell->GetTableRow(); |
| 1633 return S_OK; | 1631 return S_OK; |
| 1634 } | 1632 } |
| 1635 | 1633 |
| 1636 STDMETHODIMP BrowserAccessibilityComWin::get_selectedChildren( | 1634 STDMETHODIMP BrowserAccessibilityComWin::get_selectedChildren( |
| 1637 long max_children, | 1635 long max_children, |
| 1638 long** children, | 1636 long** children, |
| 1639 long* n_children) { | 1637 long* n_children) { |
| 1640 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CHILDREN); | 1638 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CHILDREN); |
| 1641 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1639 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1642 if (!GetOwner()) | 1640 if (!owner()) |
| 1643 return E_FAIL; | 1641 return E_FAIL; |
| 1644 | 1642 |
| 1645 if (!children || !n_children) | 1643 if (!children || !n_children) |
| 1646 return E_INVALIDARG; | 1644 return E_INVALIDARG; |
| 1647 | 1645 |
| 1648 // TODO(dmazzoni): Implement this. | 1646 // TODO(dmazzoni): Implement this. |
| 1649 *n_children = 0; | 1647 *n_children = 0; |
| 1650 return S_FALSE; | 1648 return S_FALSE; |
| 1651 } | 1649 } |
| 1652 | 1650 |
| 1653 STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long max_columns, | 1651 STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long max_columns, |
| 1654 long** columns, | 1652 long** columns, |
| 1655 long* n_columns) { | 1653 long* n_columns) { |
| 1656 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_COLUMNS); | 1654 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_COLUMNS); |
| 1657 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1655 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1658 if (!GetOwner()) | 1656 if (!owner()) |
| 1659 return E_FAIL; | 1657 return E_FAIL; |
| 1660 | 1658 |
| 1661 if (!columns || !n_columns) | 1659 if (!columns || !n_columns) |
| 1662 return E_INVALIDARG; | 1660 return E_INVALIDARG; |
| 1663 | 1661 |
| 1664 // TODO(dmazzoni): Implement this. | 1662 // TODO(dmazzoni): Implement this. |
| 1665 *n_columns = 0; | 1663 *n_columns = 0; |
| 1666 return S_FALSE; | 1664 return S_FALSE; |
| 1667 } | 1665 } |
| 1668 | 1666 |
| 1669 STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long max_rows, | 1667 STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long max_rows, |
| 1670 long** rows, | 1668 long** rows, |
| 1671 long* n_rows) { | 1669 long* n_rows) { |
| 1672 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_ROWS); | 1670 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_ROWS); |
| 1673 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1671 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1674 if (!GetOwner()) | 1672 if (!owner()) |
| 1675 return E_FAIL; | 1673 return E_FAIL; |
| 1676 | 1674 |
| 1677 if (!rows || !n_rows) | 1675 if (!rows || !n_rows) |
| 1678 return E_INVALIDARG; | 1676 return E_INVALIDARG; |
| 1679 | 1677 |
| 1680 // TODO(dmazzoni): Implement this. | 1678 // TODO(dmazzoni): Implement this. |
| 1681 *n_rows = 0; | 1679 *n_rows = 0; |
| 1682 return S_FALSE; | 1680 return S_FALSE; |
| 1683 } | 1681 } |
| 1684 | 1682 |
| 1685 STDMETHODIMP BrowserAccessibilityComWin::get_summary(IUnknown** accessible) { | 1683 STDMETHODIMP BrowserAccessibilityComWin::get_summary(IUnknown** accessible) { |
| 1686 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SUMMARY); | 1684 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SUMMARY); |
| 1687 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1685 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1688 if (!GetOwner()) | 1686 if (!owner()) |
| 1689 return E_FAIL; | 1687 return E_FAIL; |
| 1690 | 1688 |
| 1691 if (!accessible) | 1689 if (!accessible) |
| 1692 return E_INVALIDARG; | 1690 return E_INVALIDARG; |
| 1693 | 1691 |
| 1694 // TODO(dmazzoni): implement | 1692 // TODO(dmazzoni): implement |
| 1695 *accessible = nullptr; | 1693 *accessible = nullptr; |
| 1696 return S_FALSE; | 1694 return S_FALSE; |
| 1697 } | 1695 } |
| 1698 | 1696 |
| 1699 STDMETHODIMP BrowserAccessibilityComWin::get_isColumnSelected( | 1697 STDMETHODIMP BrowserAccessibilityComWin::get_isColumnSelected( |
| 1700 long column, | 1698 long column, |
| 1701 boolean* is_selected) { | 1699 boolean* is_selected) { |
| 1702 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_COLUMN_SELECTED); | 1700 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_COLUMN_SELECTED); |
| 1703 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1701 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1704 if (!GetOwner()) | 1702 if (!owner()) |
| 1705 return E_FAIL; | 1703 return E_FAIL; |
| 1706 | 1704 |
| 1707 if (!is_selected) | 1705 if (!is_selected) |
| 1708 return E_INVALIDARG; | 1706 return E_INVALIDARG; |
| 1709 | 1707 |
| 1710 // TODO(dmazzoni): Implement this. | 1708 // TODO(dmazzoni): Implement this. |
| 1711 *is_selected = false; | 1709 *is_selected = false; |
| 1712 return S_OK; | 1710 return S_OK; |
| 1713 } | 1711 } |
| 1714 | 1712 |
| 1715 STDMETHODIMP BrowserAccessibilityComWin::get_isRowSelected( | 1713 STDMETHODIMP BrowserAccessibilityComWin::get_isRowSelected( |
| 1716 long row, | 1714 long row, |
| 1717 boolean* is_selected) { | 1715 boolean* is_selected) { |
| 1718 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_ROW_SELECTED); | 1716 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_ROW_SELECTED); |
| 1719 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1717 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1720 if (!GetOwner()) | 1718 if (!owner()) |
| 1721 return E_FAIL; | 1719 return E_FAIL; |
| 1722 | 1720 |
| 1723 if (!is_selected) | 1721 if (!is_selected) |
| 1724 return E_INVALIDARG; | 1722 return E_INVALIDARG; |
| 1725 | 1723 |
| 1726 // TODO(dmazzoni): Implement this. | 1724 // TODO(dmazzoni): Implement this. |
| 1727 *is_selected = false; | 1725 *is_selected = false; |
| 1728 return S_OK; | 1726 return S_OK; |
| 1729 } | 1727 } |
| 1730 | 1728 |
| 1731 STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(long row, | 1729 STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(long row, |
| 1732 long column, | 1730 long column, |
| 1733 boolean* is_selected) { | 1731 boolean* is_selected) { |
| 1734 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_SELECTED); | 1732 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_SELECTED); |
| 1735 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1733 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1736 if (!GetOwner()) | 1734 if (!owner()) |
| 1737 return E_FAIL; | 1735 return E_FAIL; |
| 1738 | 1736 |
| 1739 if (!is_selected) | 1737 if (!is_selected) |
| 1740 return E_INVALIDARG; | 1738 return E_INVALIDARG; |
| 1741 | 1739 |
| 1742 // TODO(dmazzoni): Implement this. | 1740 // TODO(dmazzoni): Implement this. |
| 1743 *is_selected = false; | 1741 *is_selected = false; |
| 1744 return S_OK; | 1742 return S_OK; |
| 1745 } | 1743 } |
| 1746 | 1744 |
| 1747 STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtentsAtIndex( | 1745 STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtentsAtIndex( |
| 1748 long index, | 1746 long index, |
| 1749 long* row, | 1747 long* row, |
| 1750 long* column, | 1748 long* column, |
| 1751 long* row_extents, | 1749 long* row_extents, |
| 1752 long* column_extents, | 1750 long* column_extents, |
| 1753 boolean* is_selected) { | 1751 boolean* is_selected) { |
| 1754 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX); | 1752 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX); |
| 1755 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1753 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1756 if (!GetOwner()) | 1754 if (!owner()) |
| 1757 return E_FAIL; | 1755 return E_FAIL; |
| 1758 | 1756 |
| 1759 if (!row || !column || !row_extents || !column_extents || !is_selected) | 1757 if (!row || !column || !row_extents || !column_extents || !is_selected) |
| 1760 return E_INVALIDARG; | 1758 return E_INVALIDARG; |
| 1761 | 1759 |
| 1762 BrowserAccessibility* cell = GetOwner()->GetTableCell(index); | 1760 BrowserAccessibility* cell = owner()->GetTableCell(index); |
| 1763 if (!cell) | 1761 if (!cell) |
| 1764 return E_INVALIDARG; | 1762 return E_INVALIDARG; |
| 1765 | 1763 |
| 1766 *row = cell->GetTableRow(); | 1764 *row = cell->GetTableRow(); |
| 1767 *column = cell->GetTableColumn(); | 1765 *column = cell->GetTableColumn(); |
| 1768 *row_extents = GetOwner()->GetTableRowSpan(); | 1766 *row_extents = owner()->GetTableRowSpan(); |
| 1769 *column_extents = GetOwner()->GetTableColumnSpan(); | 1767 *column_extents = owner()->GetTableColumnSpan(); |
| 1770 *is_selected = false; // Not supported. | 1768 *is_selected = false; // Not supported. |
| 1771 | 1769 |
| 1772 return S_OK; | 1770 return S_OK; |
| 1773 } | 1771 } |
| 1774 | 1772 |
| 1775 STDMETHODIMP BrowserAccessibilityComWin::selectRow(long row) { | 1773 STDMETHODIMP BrowserAccessibilityComWin::selectRow(long row) { |
| 1776 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_ROW); | 1774 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_ROW); |
| 1777 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1775 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1778 return E_NOTIMPL; | 1776 return E_NOTIMPL; |
| 1779 } | 1777 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1803 | 1801 |
| 1804 // | 1802 // |
| 1805 // IAccessibleTable2 methods. | 1803 // IAccessibleTable2 methods. |
| 1806 // | 1804 // |
| 1807 | 1805 |
| 1808 STDMETHODIMP BrowserAccessibilityComWin::get_cellAt(long row, | 1806 STDMETHODIMP BrowserAccessibilityComWin::get_cellAt(long row, |
| 1809 long column, | 1807 long column, |
| 1810 IUnknown** cell) { | 1808 IUnknown** cell) { |
| 1811 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CELL_AT); | 1809 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CELL_AT); |
| 1812 AddAccessibilityModeFlags(AccessibilityMode::kScreenReader); | 1810 AddAccessibilityModeFlags(AccessibilityMode::kScreenReader); |
| 1813 if (!GetOwner()) | 1811 if (!owner()) |
| 1814 return E_FAIL; | 1812 return E_FAIL; |
| 1815 | 1813 |
| 1816 if (!cell) | 1814 if (!cell) |
| 1817 return E_INVALIDARG; | 1815 return E_INVALIDARG; |
| 1818 | 1816 |
| 1819 BrowserAccessibility* table_cell = | 1817 BrowserAccessibility* table_cell = |
| 1820 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1818 owner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1821 if (ToBrowserAccessibilityComWin(table_cell)) { | 1819 if (ToBrowserAccessibilityComWin(table_cell)) { |
| 1822 return ToBrowserAccessibilityComWin(table_cell) | 1820 return ToBrowserAccessibilityComWin(table_cell) |
| 1823 ->QueryInterface(IID_IUnknown, reinterpret_cast<void**>(cell)); | 1821 ->QueryInterface(IID_IUnknown, reinterpret_cast<void**>(cell)); |
| 1824 } | 1822 } |
| 1825 | 1823 |
| 1826 *cell = nullptr; | 1824 *cell = nullptr; |
| 1827 return E_INVALIDARG; | 1825 return E_INVALIDARG; |
| 1828 } | 1826 } |
| 1829 | 1827 |
| 1830 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedCells(long* cell_count) { | 1828 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedCells(long* cell_count) { |
| 1831 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CELLS); | 1829 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CELLS); |
| 1832 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1830 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1833 return get_nSelectedChildren(cell_count); | 1831 return get_nSelectedChildren(cell_count); |
| 1834 } | 1832 } |
| 1835 | 1833 |
| 1836 STDMETHODIMP BrowserAccessibilityComWin::get_selectedCells( | 1834 STDMETHODIMP BrowserAccessibilityComWin::get_selectedCells( |
| 1837 IUnknown*** cells, | 1835 IUnknown*** cells, |
| 1838 long* n_selected_cells) { | 1836 long* n_selected_cells) { |
| 1839 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CELLS); | 1837 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CELLS); |
| 1840 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1838 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1841 if (!GetOwner()) | 1839 if (!owner()) |
| 1842 return E_FAIL; | 1840 return E_FAIL; |
| 1843 | 1841 |
| 1844 if (!cells || !n_selected_cells) | 1842 if (!cells || !n_selected_cells) |
| 1845 return E_INVALIDARG; | 1843 return E_INVALIDARG; |
| 1846 | 1844 |
| 1847 // TODO(dmazzoni): Implement this. | 1845 // TODO(dmazzoni): Implement this. |
| 1848 *n_selected_cells = 0; | 1846 *n_selected_cells = 0; |
| 1849 return S_OK; | 1847 return S_OK; |
| 1850 } | 1848 } |
| 1851 | 1849 |
| 1852 STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long** columns, | 1850 STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long** columns, |
| 1853 long* n_columns) { | 1851 long* n_columns) { |
| 1854 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_COLUMNS); | 1852 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_COLUMNS); |
| 1855 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1853 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1856 if (!GetOwner()) | 1854 if (!owner()) |
| 1857 return E_FAIL; | 1855 return E_FAIL; |
| 1858 | 1856 |
| 1859 if (!columns || !n_columns) | 1857 if (!columns || !n_columns) |
| 1860 return E_INVALIDARG; | 1858 return E_INVALIDARG; |
| 1861 | 1859 |
| 1862 // TODO(dmazzoni): Implement this. | 1860 // TODO(dmazzoni): Implement this. |
| 1863 *n_columns = 0; | 1861 *n_columns = 0; |
| 1864 return S_OK; | 1862 return S_OK; |
| 1865 } | 1863 } |
| 1866 | 1864 |
| 1867 STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long** rows, | 1865 STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long** rows, |
| 1868 long* n_rows) { | 1866 long* n_rows) { |
| 1869 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_ROWS); | 1867 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_ROWS); |
| 1870 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1868 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1871 if (!GetOwner()) | 1869 if (!owner()) |
| 1872 return E_FAIL; | 1870 return E_FAIL; |
| 1873 | 1871 |
| 1874 if (!rows || !n_rows) | 1872 if (!rows || !n_rows) |
| 1875 return E_INVALIDARG; | 1873 return E_INVALIDARG; |
| 1876 | 1874 |
| 1877 // TODO(dmazzoni): Implement this. | 1875 // TODO(dmazzoni): Implement this. |
| 1878 *n_rows = 0; | 1876 *n_rows = 0; |
| 1879 return S_OK; | 1877 return S_OK; |
| 1880 } | 1878 } |
| 1881 | 1879 |
| 1882 // | 1880 // |
| 1883 // IAccessibleTableCell methods. | 1881 // IAccessibleTableCell methods. |
| 1884 // | 1882 // |
| 1885 | 1883 |
| 1886 STDMETHODIMP BrowserAccessibilityComWin::get_columnExtent( | 1884 STDMETHODIMP BrowserAccessibilityComWin::get_columnExtent( |
| 1887 long* n_columns_spanned) { | 1885 long* n_columns_spanned) { |
| 1888 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT); | 1886 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT); |
| 1889 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1887 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1890 if (!GetOwner()) | 1888 if (!owner()) |
| 1891 return E_FAIL; | 1889 return E_FAIL; |
| 1892 | 1890 |
| 1893 if (!n_columns_spanned) | 1891 if (!n_columns_spanned) |
| 1894 return E_INVALIDARG; | 1892 return E_INVALIDARG; |
| 1895 | 1893 |
| 1896 *n_columns_spanned = GetOwner()->GetTableColumnSpan(); | 1894 *n_columns_spanned = owner()->GetTableColumnSpan(); |
| 1897 return S_OK; | 1895 return S_OK; |
| 1898 } | 1896 } |
| 1899 | 1897 |
| 1900 STDMETHODIMP BrowserAccessibilityComWin::get_columnHeaderCells( | 1898 STDMETHODIMP BrowserAccessibilityComWin::get_columnHeaderCells( |
| 1901 IUnknown*** cell_accessibles, | 1899 IUnknown*** cell_accessibles, |
| 1902 long* n_column_header_cells) { | 1900 long* n_column_header_cells) { |
| 1903 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER_CELLS); | 1901 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER_CELLS); |
| 1904 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1902 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1905 if (!GetOwner()) | 1903 if (!owner()) |
| 1906 return E_FAIL; | 1904 return E_FAIL; |
| 1907 | 1905 |
| 1908 if (!cell_accessibles || !n_column_header_cells) | 1906 if (!cell_accessibles || !n_column_header_cells) |
| 1909 return E_INVALIDARG; | 1907 return E_INVALIDARG; |
| 1910 | 1908 |
| 1911 *n_column_header_cells = 0; | 1909 *n_column_header_cells = 0; |
| 1912 BrowserAccessibility* table = GetOwner()->GetTable(); | 1910 BrowserAccessibility* table = owner()->GetTable(); |
| 1913 if (!table) { | 1911 if (!table) { |
| 1914 NOTREACHED(); | 1912 NOTREACHED(); |
| 1915 return S_FALSE; | 1913 return S_FALSE; |
| 1916 } | 1914 } |
| 1917 | 1915 |
| 1918 int column = GetOwner()->GetTableColumn(); | 1916 int column = owner()->GetTableColumn(); |
| 1919 int columns = GetOwner()->GetTableColumnCount(); | 1917 int columns = owner()->GetTableColumnCount(); |
| 1920 int rows = GetOwner()->GetTableRowCount(); | 1918 int rows = owner()->GetTableRowCount(); |
| 1921 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) | 1919 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) |
| 1922 return S_FALSE; | 1920 return S_FALSE; |
| 1923 | 1921 |
| 1924 for (int i = 0; i < rows; ++i) { | 1922 for (int i = 0; i < rows; ++i) { |
| 1925 BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); | 1923 BrowserAccessibility* cell = owner()->GetTableCell(i, column); |
| 1926 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) | 1924 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) |
| 1927 (*n_column_header_cells)++; | 1925 (*n_column_header_cells)++; |
| 1928 } | 1926 } |
| 1929 | 1927 |
| 1930 *cell_accessibles = static_cast<IUnknown**>( | 1928 *cell_accessibles = static_cast<IUnknown**>( |
| 1931 CoTaskMemAlloc((*n_column_header_cells) * sizeof(cell_accessibles[0]))); | 1929 CoTaskMemAlloc((*n_column_header_cells) * sizeof(cell_accessibles[0]))); |
| 1932 int index = 0; | 1930 int index = 0; |
| 1933 for (int i = 0; i < rows; ++i) { | 1931 for (int i = 0; i < rows; ++i) { |
| 1934 BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); | 1932 BrowserAccessibility* cell = owner()->GetTableCell(i, column); |
| 1935 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { | 1933 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
| 1936 (*cell_accessibles)[index] = static_cast<IAccessible*>( | 1934 (*cell_accessibles)[index] = static_cast<IAccessible*>( |
| 1937 ToBrowserAccessibilityComWin(cell)->NewReference()); | 1935 ToBrowserAccessibilityComWin(cell)->NewReference()); |
| 1938 ++index; | 1936 ++index; |
| 1939 } | 1937 } |
| 1940 } | 1938 } |
| 1941 | 1939 |
| 1942 return S_OK; | 1940 return S_OK; |
| 1943 } | 1941 } |
| 1944 | 1942 |
| 1945 STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long* column_index) { | 1943 STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long* column_index) { |
| 1946 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_COLUMN_INDEX); | 1944 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_COLUMN_INDEX); |
| 1947 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1945 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1948 if (!GetOwner()) | 1946 if (!owner()) |
| 1949 return E_FAIL; | 1947 return E_FAIL; |
| 1950 | 1948 |
| 1951 if (!column_index) | 1949 if (!column_index) |
| 1952 return E_INVALIDARG; | 1950 return E_INVALIDARG; |
| 1953 | 1951 |
| 1954 *column_index = GetOwner()->GetTableColumn(); | 1952 *column_index = owner()->GetTableColumn(); |
| 1955 return S_OK; | 1953 return S_OK; |
| 1956 } | 1954 } |
| 1957 | 1955 |
| 1958 STDMETHODIMP BrowserAccessibilityComWin::get_rowExtent(long* n_rows_spanned) { | 1956 STDMETHODIMP BrowserAccessibilityComWin::get_rowExtent(long* n_rows_spanned) { |
| 1959 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT); | 1957 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT); |
| 1960 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1958 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1961 if (!GetOwner()) | 1959 if (!owner()) |
| 1962 return E_FAIL; | 1960 return E_FAIL; |
| 1963 | 1961 |
| 1964 if (!n_rows_spanned) | 1962 if (!n_rows_spanned) |
| 1965 return E_INVALIDARG; | 1963 return E_INVALIDARG; |
| 1966 | 1964 |
| 1967 *n_rows_spanned = GetOwner()->GetTableRowSpan(); | 1965 *n_rows_spanned = owner()->GetTableRowSpan(); |
| 1968 return S_OK; | 1966 return S_OK; |
| 1969 } | 1967 } |
| 1970 | 1968 |
| 1971 STDMETHODIMP BrowserAccessibilityComWin::get_rowHeaderCells( | 1969 STDMETHODIMP BrowserAccessibilityComWin::get_rowHeaderCells( |
| 1972 IUnknown*** cell_accessibles, | 1970 IUnknown*** cell_accessibles, |
| 1973 long* n_row_header_cells) { | 1971 long* n_row_header_cells) { |
| 1974 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER_CELLS); | 1972 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER_CELLS); |
| 1975 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1973 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1976 if (!GetOwner()) | 1974 if (!owner()) |
| 1977 return E_FAIL; | 1975 return E_FAIL; |
| 1978 | 1976 |
| 1979 if (!cell_accessibles || !n_row_header_cells) | 1977 if (!cell_accessibles || !n_row_header_cells) |
| 1980 return E_INVALIDARG; | 1978 return E_INVALIDARG; |
| 1981 | 1979 |
| 1982 *n_row_header_cells = 0; | 1980 *n_row_header_cells = 0; |
| 1983 BrowserAccessibility* table = GetOwner()->GetTable(); | 1981 BrowserAccessibility* table = owner()->GetTable(); |
| 1984 if (!table) { | 1982 if (!table) { |
| 1985 NOTREACHED(); | 1983 NOTREACHED(); |
| 1986 return S_FALSE; | 1984 return S_FALSE; |
| 1987 } | 1985 } |
| 1988 | 1986 |
| 1989 int row = GetOwner()->GetTableRow(); | 1987 int row = owner()->GetTableRow(); |
| 1990 int columns = GetOwner()->GetTableColumnCount(); | 1988 int columns = owner()->GetTableColumnCount(); |
| 1991 int rows = GetOwner()->GetTableRowCount(); | 1989 int rows = owner()->GetTableRowCount(); |
| 1992 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) | 1990 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) |
| 1993 return S_FALSE; | 1991 return S_FALSE; |
| 1994 | 1992 |
| 1995 for (int i = 0; i < columns; ++i) { | 1993 for (int i = 0; i < columns; ++i) { |
| 1996 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); | 1994 BrowserAccessibility* cell = owner()->GetTableCell(row, i); |
| 1997 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) | 1995 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) |
| 1998 (*n_row_header_cells)++; | 1996 (*n_row_header_cells)++; |
| 1999 } | 1997 } |
| 2000 | 1998 |
| 2001 *cell_accessibles = static_cast<IUnknown**>( | 1999 *cell_accessibles = static_cast<IUnknown**>( |
| 2002 CoTaskMemAlloc((*n_row_header_cells) * sizeof(cell_accessibles[0]))); | 2000 CoTaskMemAlloc((*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| 2003 int index = 0; | 2001 int index = 0; |
| 2004 for (int i = 0; i < columns; ++i) { | 2002 for (int i = 0; i < columns; ++i) { |
| 2005 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); | 2003 BrowserAccessibility* cell = owner()->GetTableCell(row, i); |
| 2006 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { | 2004 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
| 2007 (*cell_accessibles)[index] = static_cast<IAccessible*>( | 2005 (*cell_accessibles)[index] = static_cast<IAccessible*>( |
| 2008 ToBrowserAccessibilityComWin(cell)->NewReference()); | 2006 ToBrowserAccessibilityComWin(cell)->NewReference()); |
| 2009 ++index; | 2007 ++index; |
| 2010 } | 2008 } |
| 2011 } | 2009 } |
| 2012 | 2010 |
| 2013 return S_OK; | 2011 return S_OK; |
| 2014 } | 2012 } |
| 2015 | 2013 |
| 2016 STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long* row_index) { | 2014 STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long* row_index) { |
| 2017 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_ROW_INDEX); | 2015 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_ROW_INDEX); |
| 2018 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2016 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2019 if (!GetOwner()) | 2017 if (!owner()) |
| 2020 return E_FAIL; | 2018 return E_FAIL; |
| 2021 | 2019 |
| 2022 if (!row_index) | 2020 if (!row_index) |
| 2023 return E_INVALIDARG; | 2021 return E_INVALIDARG; |
| 2024 | 2022 |
| 2025 *row_index = GetOwner()->GetTableRow(); | 2023 *row_index = owner()->GetTableRow(); |
| 2026 return S_OK; | 2024 return S_OK; |
| 2027 } | 2025 } |
| 2028 | 2026 |
| 2029 STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(boolean* is_selected) { | 2027 STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(boolean* is_selected) { |
| 2030 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_IS_SELECTED); | 2028 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_IS_SELECTED); |
| 2031 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2029 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2032 if (!GetOwner()) | 2030 if (!owner()) |
| 2033 return E_FAIL; | 2031 return E_FAIL; |
| 2034 | 2032 |
| 2035 if (!is_selected) | 2033 if (!is_selected) |
| 2036 return E_INVALIDARG; | 2034 return E_INVALIDARG; |
| 2037 | 2035 |
| 2038 *is_selected = false; | 2036 *is_selected = false; |
| 2039 return S_OK; | 2037 return S_OK; |
| 2040 } | 2038 } |
| 2041 | 2039 |
| 2042 STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtents( | 2040 STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtents( |
| 2043 long* row_index, | 2041 long* row_index, |
| 2044 long* column_index, | 2042 long* column_index, |
| 2045 long* row_extents, | 2043 long* row_extents, |
| 2046 long* column_extents, | 2044 long* column_extents, |
| 2047 boolean* is_selected) { | 2045 boolean* is_selected) { |
| 2048 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS); | 2046 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS); |
| 2049 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2047 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2050 if (!GetOwner()) | 2048 if (!owner()) |
| 2051 return E_FAIL; | 2049 return E_FAIL; |
| 2052 | 2050 |
| 2053 if (!row_index || !column_index || !row_extents || !column_extents || | 2051 if (!row_index || !column_index || !row_extents || !column_extents || |
| 2054 !is_selected) { | 2052 !is_selected) { |
| 2055 return E_INVALIDARG; | 2053 return E_INVALIDARG; |
| 2056 } | 2054 } |
| 2057 | 2055 |
| 2058 *row_index = GetOwner()->GetTableRow(); | 2056 *row_index = owner()->GetTableRow(); |
| 2059 *column_index = GetOwner()->GetTableColumn(); | 2057 *column_index = owner()->GetTableColumn(); |
| 2060 *row_extents = GetOwner()->GetTableRowSpan(); | 2058 *row_extents = owner()->GetTableRowSpan(); |
| 2061 *column_extents = GetOwner()->GetTableColumnSpan(); | 2059 *column_extents = owner()->GetTableColumnSpan(); |
| 2062 *is_selected = false; // Not supported. | 2060 *is_selected = false; // Not supported. |
| 2063 | 2061 |
| 2064 return S_OK; | 2062 return S_OK; |
| 2065 } | 2063 } |
| 2066 | 2064 |
| 2067 STDMETHODIMP BrowserAccessibilityComWin::get_table(IUnknown** table) { | 2065 STDMETHODIMP BrowserAccessibilityComWin::get_table(IUnknown** table) { |
| 2068 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TABLE); | 2066 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TABLE); |
| 2069 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2067 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2070 if (!GetOwner()) | 2068 if (!owner()) |
| 2071 return E_FAIL; | 2069 return E_FAIL; |
| 2072 | 2070 |
| 2073 if (!table) | 2071 if (!table) |
| 2074 return E_INVALIDARG; | 2072 return E_INVALIDARG; |
| 2075 | 2073 |
| 2076 BrowserAccessibility* find_table = GetOwner()->GetTable(); | 2074 BrowserAccessibility* find_table = owner()->GetTable(); |
| 2077 if (!find_table || !ToBrowserAccessibilityComWin(find_table)) { | 2075 if (!find_table || !ToBrowserAccessibilityComWin(find_table)) { |
| 2078 *table = nullptr; | 2076 *table = nullptr; |
| 2079 return S_FALSE; | 2077 return S_FALSE; |
| 2080 } | 2078 } |
| 2081 | 2079 |
| 2082 *table = static_cast<IAccessibleTable*>( | 2080 *table = static_cast<IAccessibleTable*>( |
| 2083 ToBrowserAccessibilityComWin(find_table)->NewReference()); | 2081 ToBrowserAccessibilityComWin(find_table)->NewReference()); |
| 2084 return S_OK; | 2082 return S_OK; |
| 2085 } | 2083 } |
| 2086 | 2084 |
| 2087 // | 2085 // |
| 2088 // IAccessibleText methods. | 2086 // IAccessibleText methods. |
| 2089 // | 2087 // |
| 2090 | 2088 |
| 2091 STDMETHODIMP BrowserAccessibilityComWin::get_nCharacters(LONG* n_characters) { | 2089 STDMETHODIMP BrowserAccessibilityComWin::get_nCharacters(LONG* n_characters) { |
| 2092 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_CHARACTERS); | 2090 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_CHARACTERS); |
| 2093 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2091 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2094 AccessibilityMode::kInlineTextBoxes); | 2092 AccessibilityMode::kInlineTextBoxes); |
| 2095 if (!GetOwner()) | 2093 if (!owner()) |
| 2096 return E_FAIL; | 2094 return E_FAIL; |
| 2097 | 2095 |
| 2098 if (!n_characters) | 2096 if (!n_characters) |
| 2099 return E_INVALIDARG; | 2097 return E_INVALIDARG; |
| 2100 | 2098 |
| 2101 *n_characters = static_cast<LONG>(GetOwner()->GetText().size()); | 2099 *n_characters = static_cast<LONG>(owner()->GetText().size()); |
| 2102 return S_OK; | 2100 return S_OK; |
| 2103 } | 2101 } |
| 2104 | 2102 |
| 2105 STDMETHODIMP BrowserAccessibilityComWin::get_caretOffset(LONG* offset) { | 2103 STDMETHODIMP BrowserAccessibilityComWin::get_caretOffset(LONG* offset) { |
| 2106 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CARET_OFFSET); | 2104 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CARET_OFFSET); |
| 2107 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2105 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2108 if (!GetOwner()) | 2106 if (!owner()) |
| 2109 return E_FAIL; | 2107 return E_FAIL; |
| 2110 | 2108 |
| 2111 if (!offset) | 2109 if (!offset) |
| 2112 return E_INVALIDARG; | 2110 return E_INVALIDARG; |
| 2113 | 2111 |
| 2114 if (!GetOwner()->HasCaret()) | 2112 if (!owner()->HasCaret()) |
| 2115 return S_FALSE; | 2113 return S_FALSE; |
| 2116 | 2114 |
| 2117 int selection_start, selection_end; | 2115 int selection_start, selection_end; |
| 2118 GetSelectionOffsets(&selection_start, &selection_end); | 2116 GetSelectionOffsets(&selection_start, &selection_end); |
| 2119 // The caret is always at the end of the selection. | 2117 // The caret is always at the end of the selection. |
| 2120 *offset = selection_end; | 2118 *offset = selection_end; |
| 2121 if (*offset < 0) | 2119 if (*offset < 0) |
| 2122 return S_FALSE; | 2120 return S_FALSE; |
| 2123 | 2121 |
| 2124 return S_OK; | 2122 return S_OK; |
| 2125 } | 2123 } |
| 2126 | 2124 |
| 2127 STDMETHODIMP BrowserAccessibilityComWin::get_characterExtents( | 2125 STDMETHODIMP BrowserAccessibilityComWin::get_characterExtents( |
| 2128 LONG offset, | 2126 LONG offset, |
| 2129 IA2CoordinateType coordinate_type, | 2127 IA2CoordinateType coordinate_type, |
| 2130 LONG* out_x, | 2128 LONG* out_x, |
| 2131 LONG* out_y, | 2129 LONG* out_y, |
| 2132 LONG* out_width, | 2130 LONG* out_width, |
| 2133 LONG* out_height) { | 2131 LONG* out_height) { |
| 2134 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHARACTER_EXTENTS); | 2132 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHARACTER_EXTENTS); |
| 2135 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2133 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2136 AccessibilityMode::kInlineTextBoxes); | 2134 AccessibilityMode::kInlineTextBoxes); |
| 2137 if (!GetOwner()) | 2135 if (!owner()) |
| 2138 return E_FAIL; | 2136 return E_FAIL; |
| 2139 | 2137 |
| 2140 if (!out_x || !out_y || !out_width || !out_height) | 2138 if (!out_x || !out_y || !out_width || !out_height) |
| 2141 return E_INVALIDARG; | 2139 return E_INVALIDARG; |
| 2142 | 2140 |
| 2143 const base::string16& text_str = GetOwner()->GetText(); | 2141 const base::string16& text_str = owner()->GetText(); |
| 2144 HandleSpecialTextOffset(&offset); | 2142 HandleSpecialTextOffset(&offset); |
| 2145 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) | 2143 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) |
| 2146 return E_INVALIDARG; | 2144 return E_INVALIDARG; |
| 2147 | 2145 |
| 2148 gfx::Rect character_bounds; | 2146 gfx::Rect character_bounds; |
| 2149 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 2147 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 2150 character_bounds = GetOwner()->GetScreenBoundsForRange(offset, 1); | 2148 character_bounds = owner()->GetScreenBoundsForRange(offset, 1); |
| 2151 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 2149 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 2152 character_bounds = GetOwner()->GetPageBoundsForRange(offset, 1); | 2150 character_bounds = owner()->GetPageBoundsForRange(offset, 1); |
| 2153 if (GetOwner()->PlatformGetParent()) { | 2151 if (owner()->PlatformGetParent()) { |
| 2154 character_bounds -= GetOwner() | 2152 character_bounds -= |
| 2155 ->PlatformGetParent() | 2153 owner()->PlatformGetParent()->GetPageBoundsRect().OffsetFromOrigin(); |
| 2156 ->GetPageBoundsRect() | |
| 2157 .OffsetFromOrigin(); | |
| 2158 } | 2154 } |
| 2159 } else { | 2155 } else { |
| 2160 return E_INVALIDARG; | 2156 return E_INVALIDARG; |
| 2161 } | 2157 } |
| 2162 | 2158 |
| 2163 *out_x = character_bounds.x(); | 2159 *out_x = character_bounds.x(); |
| 2164 *out_y = character_bounds.y(); | 2160 *out_y = character_bounds.y(); |
| 2165 *out_width = character_bounds.width(); | 2161 *out_width = character_bounds.width(); |
| 2166 *out_height = character_bounds.height(); | 2162 *out_height = character_bounds.height(); |
| 2167 | 2163 |
| 2168 return S_OK; | 2164 return S_OK; |
| 2169 } | 2165 } |
| 2170 | 2166 |
| 2171 STDMETHODIMP BrowserAccessibilityComWin::get_nSelections(LONG* n_selections) { | 2167 STDMETHODIMP BrowserAccessibilityComWin::get_nSelections(LONG* n_selections) { |
| 2172 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTIONS); | 2168 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTIONS); |
| 2173 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2169 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2174 if (!GetOwner()) | 2170 if (!owner()) |
| 2175 return E_FAIL; | 2171 return E_FAIL; |
| 2176 | 2172 |
| 2177 if (!n_selections) | 2173 if (!n_selections) |
| 2178 return E_INVALIDARG; | 2174 return E_INVALIDARG; |
| 2179 | 2175 |
| 2180 *n_selections = 0; | 2176 *n_selections = 0; |
| 2181 int selection_start, selection_end; | 2177 int selection_start, selection_end; |
| 2182 GetSelectionOffsets(&selection_start, &selection_end); | 2178 GetSelectionOffsets(&selection_start, &selection_end); |
| 2183 if (selection_start >= 0 && selection_end >= 0 && | 2179 if (selection_start >= 0 && selection_end >= 0 && |
| 2184 selection_start != selection_end) { | 2180 selection_start != selection_end) { |
| 2185 *n_selections = 1; | 2181 *n_selections = 1; |
| 2186 } | 2182 } |
| 2187 | 2183 |
| 2188 return S_OK; | 2184 return S_OK; |
| 2189 } | 2185 } |
| 2190 | 2186 |
| 2191 STDMETHODIMP BrowserAccessibilityComWin::get_selection(LONG selection_index, | 2187 STDMETHODIMP BrowserAccessibilityComWin::get_selection(LONG selection_index, |
| 2192 LONG* start_offset, | 2188 LONG* start_offset, |
| 2193 LONG* end_offset) { | 2189 LONG* end_offset) { |
| 2194 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTION); | 2190 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTION); |
| 2195 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2191 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2196 if (!GetOwner()) | 2192 if (!owner()) |
| 2197 return E_FAIL; | 2193 return E_FAIL; |
| 2198 | 2194 |
| 2199 if (!start_offset || !end_offset || selection_index != 0) | 2195 if (!start_offset || !end_offset || selection_index != 0) |
| 2200 return E_INVALIDARG; | 2196 return E_INVALIDARG; |
| 2201 | 2197 |
| 2202 *start_offset = 0; | 2198 *start_offset = 0; |
| 2203 *end_offset = 0; | 2199 *end_offset = 0; |
| 2204 int selection_start, selection_end; | 2200 int selection_start, selection_end; |
| 2205 GetSelectionOffsets(&selection_start, &selection_end); | 2201 GetSelectionOffsets(&selection_start, &selection_end); |
| 2206 if (selection_start >= 0 && selection_end >= 0 && | 2202 if (selection_start >= 0 && selection_end >= 0 && |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2218 } | 2214 } |
| 2219 | 2215 |
| 2220 return E_INVALIDARG; | 2216 return E_INVALIDARG; |
| 2221 } | 2217 } |
| 2222 | 2218 |
| 2223 STDMETHODIMP BrowserAccessibilityComWin::get_text(LONG start_offset, | 2219 STDMETHODIMP BrowserAccessibilityComWin::get_text(LONG start_offset, |
| 2224 LONG end_offset, | 2220 LONG end_offset, |
| 2225 BSTR* text) { | 2221 BSTR* text) { |
| 2226 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT); | 2222 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT); |
| 2227 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2223 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2228 if (!GetOwner()) | 2224 if (!owner()) |
| 2229 return E_FAIL; | 2225 return E_FAIL; |
| 2230 | 2226 |
| 2231 if (!text) | 2227 if (!text) |
| 2232 return E_INVALIDARG; | 2228 return E_INVALIDARG; |
| 2233 | 2229 |
| 2234 const base::string16& text_str = GetOwner()->GetText(); | 2230 const base::string16& text_str = owner()->GetText(); |
| 2235 HandleSpecialTextOffset(&start_offset); | 2231 HandleSpecialTextOffset(&start_offset); |
| 2236 HandleSpecialTextOffset(&end_offset); | 2232 HandleSpecialTextOffset(&end_offset); |
| 2237 | 2233 |
| 2238 // The spec allows the arguments to be reversed. | 2234 // The spec allows the arguments to be reversed. |
| 2239 if (start_offset > end_offset) { | 2235 if (start_offset > end_offset) { |
| 2240 LONG tmp = start_offset; | 2236 LONG tmp = start_offset; |
| 2241 start_offset = end_offset; | 2237 start_offset = end_offset; |
| 2242 end_offset = tmp; | 2238 end_offset = tmp; |
| 2243 } | 2239 } |
| 2244 | 2240 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2263 | 2259 |
| 2264 STDMETHODIMP BrowserAccessibilityComWin::get_textAtOffset( | 2260 STDMETHODIMP BrowserAccessibilityComWin::get_textAtOffset( |
| 2265 LONG offset, | 2261 LONG offset, |
| 2266 IA2TextBoundaryType boundary_type, | 2262 IA2TextBoundaryType boundary_type, |
| 2267 LONG* start_offset, | 2263 LONG* start_offset, |
| 2268 LONG* end_offset, | 2264 LONG* end_offset, |
| 2269 BSTR* text) { | 2265 BSTR* text) { |
| 2270 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AT_OFFSET); | 2266 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AT_OFFSET); |
| 2271 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2267 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2272 AccessibilityMode::kInlineTextBoxes); | 2268 AccessibilityMode::kInlineTextBoxes); |
| 2273 if (!GetOwner()) | 2269 if (!owner()) |
| 2274 return E_FAIL; | 2270 return E_FAIL; |
| 2275 | 2271 |
| 2276 if (!start_offset || !end_offset || !text) | 2272 if (!start_offset || !end_offset || !text) |
| 2277 return E_INVALIDARG; | 2273 return E_INVALIDARG; |
| 2278 | 2274 |
| 2279 HandleSpecialTextOffset(&offset); | 2275 HandleSpecialTextOffset(&offset); |
| 2280 if (offset < 0) | 2276 if (offset < 0) |
| 2281 return E_INVALIDARG; | 2277 return E_INVALIDARG; |
| 2282 | 2278 |
| 2283 const base::string16& text_str = GetOwner()->GetText(); | 2279 const base::string16& text_str = owner()->GetText(); |
| 2284 LONG text_len = text_str.length(); | 2280 LONG text_len = text_str.length(); |
| 2285 if (offset > text_len) | 2281 if (offset > text_len) |
| 2286 return E_INVALIDARG; | 2282 return E_INVALIDARG; |
| 2287 | 2283 |
| 2288 // The IAccessible2 spec says we don't have to implement the "sentence" | 2284 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2289 // boundary type, we can just let the screenreader handle it. | 2285 // boundary type, we can just let the screenreader handle it. |
| 2290 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2286 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2291 *start_offset = 0; | 2287 *start_offset = 0; |
| 2292 *end_offset = 0; | 2288 *end_offset = 0; |
| 2293 *text = NULL; | 2289 *text = NULL; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2316 | 2312 |
| 2317 STDMETHODIMP BrowserAccessibilityComWin::get_textBeforeOffset( | 2313 STDMETHODIMP BrowserAccessibilityComWin::get_textBeforeOffset( |
| 2318 LONG offset, | 2314 LONG offset, |
| 2319 IA2TextBoundaryType boundary_type, | 2315 IA2TextBoundaryType boundary_type, |
| 2320 LONG* start_offset, | 2316 LONG* start_offset, |
| 2321 LONG* end_offset, | 2317 LONG* end_offset, |
| 2322 BSTR* text) { | 2318 BSTR* text) { |
| 2323 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_BEFORE_OFFSET); | 2319 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_BEFORE_OFFSET); |
| 2324 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2320 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2325 AccessibilityMode::kInlineTextBoxes); | 2321 AccessibilityMode::kInlineTextBoxes); |
| 2326 if (!GetOwner()) | 2322 if (!owner()) |
| 2327 return E_FAIL; | 2323 return E_FAIL; |
| 2328 | 2324 |
| 2329 if (!start_offset || !end_offset || !text) | 2325 if (!start_offset || !end_offset || !text) |
| 2330 return E_INVALIDARG; | 2326 return E_INVALIDARG; |
| 2331 | 2327 |
| 2332 // The IAccessible2 spec says we don't have to implement the "sentence" | 2328 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2333 // boundary type, we can just let the screenreader handle it. | 2329 // boundary type, we can just let the screenreader handle it. |
| 2334 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2330 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2335 *start_offset = 0; | 2331 *start_offset = 0; |
| 2336 *end_offset = 0; | 2332 *end_offset = 0; |
| 2337 *text = NULL; | 2333 *text = NULL; |
| 2338 return S_FALSE; | 2334 return S_FALSE; |
| 2339 } | 2335 } |
| 2340 | 2336 |
| 2341 const base::string16& text_str = GetOwner()->GetText(); | 2337 const base::string16& text_str = owner()->GetText(); |
| 2342 | 2338 |
| 2343 *start_offset = | 2339 *start_offset = |
| 2344 FindBoundary(text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2340 FindBoundary(text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| 2345 *end_offset = offset; | 2341 *end_offset = offset; |
| 2346 return get_text(*start_offset, *end_offset, text); | 2342 return get_text(*start_offset, *end_offset, text); |
| 2347 } | 2343 } |
| 2348 | 2344 |
| 2349 STDMETHODIMP BrowserAccessibilityComWin::get_textAfterOffset( | 2345 STDMETHODIMP BrowserAccessibilityComWin::get_textAfterOffset( |
| 2350 LONG offset, | 2346 LONG offset, |
| 2351 IA2TextBoundaryType boundary_type, | 2347 IA2TextBoundaryType boundary_type, |
| 2352 LONG* start_offset, | 2348 LONG* start_offset, |
| 2353 LONG* end_offset, | 2349 LONG* end_offset, |
| 2354 BSTR* text) { | 2350 BSTR* text) { |
| 2355 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AFTER_OFFSET); | 2351 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AFTER_OFFSET); |
| 2356 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2352 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2357 AccessibilityMode::kInlineTextBoxes); | 2353 AccessibilityMode::kInlineTextBoxes); |
| 2358 if (!GetOwner()) | 2354 if (!owner()) |
| 2359 return E_FAIL; | 2355 return E_FAIL; |
| 2360 | 2356 |
| 2361 if (!start_offset || !end_offset || !text) | 2357 if (!start_offset || !end_offset || !text) |
| 2362 return E_INVALIDARG; | 2358 return E_INVALIDARG; |
| 2363 | 2359 |
| 2364 // The IAccessible2 spec says we don't have to implement the "sentence" | 2360 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2365 // boundary type, we can just let the screenreader handle it. | 2361 // boundary type, we can just let the screenreader handle it. |
| 2366 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2362 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2367 *start_offset = 0; | 2363 *start_offset = 0; |
| 2368 *end_offset = 0; | 2364 *end_offset = 0; |
| 2369 *text = NULL; | 2365 *text = NULL; |
| 2370 return S_FALSE; | 2366 return S_FALSE; |
| 2371 } | 2367 } |
| 2372 | 2368 |
| 2373 const base::string16& text_str = GetOwner()->GetText(); | 2369 const base::string16& text_str = owner()->GetText(); |
| 2374 | 2370 |
| 2375 *start_offset = offset; | 2371 *start_offset = offset; |
| 2376 *end_offset = | 2372 *end_offset = |
| 2377 FindBoundary(text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2373 FindBoundary(text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| 2378 return get_text(*start_offset, *end_offset, text); | 2374 return get_text(*start_offset, *end_offset, text); |
| 2379 } | 2375 } |
| 2380 | 2376 |
| 2381 STDMETHODIMP BrowserAccessibilityComWin::get_newText(IA2TextSegment* new_text) { | 2377 STDMETHODIMP BrowserAccessibilityComWin::get_newText(IA2TextSegment* new_text) { |
| 2382 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEW_TEXT); | 2378 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEW_TEXT); |
| 2383 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2379 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2384 if (!GetOwner()) | 2380 if (!owner()) |
| 2385 return E_FAIL; | 2381 return E_FAIL; |
| 2386 | 2382 |
| 2387 if (!new_text) | 2383 if (!new_text) |
| 2388 return E_INVALIDARG; | 2384 return E_INVALIDARG; |
| 2389 | 2385 |
| 2390 if (!old_win_attributes_) | 2386 if (!old_win_attributes_) |
| 2391 return E_FAIL; | 2387 return E_FAIL; |
| 2392 | 2388 |
| 2393 int start, old_len, new_len; | 2389 int start, old_len, new_len; |
| 2394 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | 2390 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
| 2395 if (new_len == 0) | 2391 if (new_len == 0) |
| 2396 return E_FAIL; | 2392 return E_FAIL; |
| 2397 | 2393 |
| 2398 base::string16 substr = GetOwner()->GetText().substr(start, new_len); | 2394 base::string16 substr = owner()->GetText().substr(start, new_len); |
| 2399 new_text->text = SysAllocString(substr.c_str()); | 2395 new_text->text = SysAllocString(substr.c_str()); |
| 2400 new_text->start = static_cast<long>(start); | 2396 new_text->start = static_cast<long>(start); |
| 2401 new_text->end = static_cast<long>(start + new_len); | 2397 new_text->end = static_cast<long>(start + new_len); |
| 2402 return S_OK; | 2398 return S_OK; |
| 2403 } | 2399 } |
| 2404 | 2400 |
| 2405 STDMETHODIMP BrowserAccessibilityComWin::get_oldText(IA2TextSegment* old_text) { | 2401 STDMETHODIMP BrowserAccessibilityComWin::get_oldText(IA2TextSegment* old_text) { |
| 2406 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OLD_TEXT); | 2402 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OLD_TEXT); |
| 2407 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2403 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2408 if (!GetOwner()) | 2404 if (!owner()) |
| 2409 return E_FAIL; | 2405 return E_FAIL; |
| 2410 | 2406 |
| 2411 if (!old_text) | 2407 if (!old_text) |
| 2412 return E_INVALIDARG; | 2408 return E_INVALIDARG; |
| 2413 | 2409 |
| 2414 if (!old_win_attributes_) | 2410 if (!old_win_attributes_) |
| 2415 return E_FAIL; | 2411 return E_FAIL; |
| 2416 | 2412 |
| 2417 int start, old_len, new_len; | 2413 int start, old_len, new_len; |
| 2418 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | 2414 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
| 2419 if (old_len == 0) | 2415 if (old_len == 0) |
| 2420 return E_FAIL; | 2416 return E_FAIL; |
| 2421 | 2417 |
| 2422 base::string16 old_hypertext = old_win_attributes_->hypertext; | 2418 base::string16 old_hypertext = old_win_attributes_->hypertext; |
| 2423 base::string16 substr = old_hypertext.substr(start, old_len); | 2419 base::string16 substr = old_hypertext.substr(start, old_len); |
| 2424 old_text->text = SysAllocString(substr.c_str()); | 2420 old_text->text = SysAllocString(substr.c_str()); |
| 2425 old_text->start = static_cast<long>(start); | 2421 old_text->start = static_cast<long>(start); |
| 2426 old_text->end = static_cast<long>(start + old_len); | 2422 old_text->end = static_cast<long>(start + old_len); |
| 2427 return S_OK; | 2423 return S_OK; |
| 2428 } | 2424 } |
| 2429 | 2425 |
| 2430 STDMETHODIMP BrowserAccessibilityComWin::get_offsetAtPoint( | 2426 STDMETHODIMP BrowserAccessibilityComWin::get_offsetAtPoint( |
| 2431 LONG x, | 2427 LONG x, |
| 2432 LONG y, | 2428 LONG y, |
| 2433 IA2CoordinateType coord_type, | 2429 IA2CoordinateType coord_type, |
| 2434 LONG* offset) { | 2430 LONG* offset) { |
| 2435 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OFFSET_AT_POINT); | 2431 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OFFSET_AT_POINT); |
| 2436 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2432 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2437 AccessibilityMode::kInlineTextBoxes); | 2433 AccessibilityMode::kInlineTextBoxes); |
| 2438 if (!GetOwner()) | 2434 if (!owner()) |
| 2439 return E_FAIL; | 2435 return E_FAIL; |
| 2440 | 2436 |
| 2441 if (!offset) | 2437 if (!offset) |
| 2442 return E_INVALIDARG; | 2438 return E_INVALIDARG; |
| 2443 | 2439 |
| 2444 // TODO(dmazzoni): implement this. We're returning S_OK for now so that | 2440 // TODO(dmazzoni): implement this. We're returning S_OK for now so that |
| 2445 // screen readers still return partially accurate results rather than | 2441 // screen readers still return partially accurate results rather than |
| 2446 // completely failing. | 2442 // completely failing. |
| 2447 *offset = 0; | 2443 *offset = 0; |
| 2448 return S_OK; | 2444 return S_OK; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2461 | 2457 |
| 2462 STDMETHODIMP BrowserAccessibilityComWin::scrollSubstringToPoint( | 2458 STDMETHODIMP BrowserAccessibilityComWin::scrollSubstringToPoint( |
| 2463 LONG start_index, | 2459 LONG start_index, |
| 2464 LONG end_index, | 2460 LONG end_index, |
| 2465 IA2CoordinateType coordinate_type, | 2461 IA2CoordinateType coordinate_type, |
| 2466 LONG x, | 2462 LONG x, |
| 2467 LONG y) { | 2463 LONG y) { |
| 2468 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO_POINT); | 2464 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO_POINT); |
| 2469 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2465 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2470 AccessibilityMode::kInlineTextBoxes); | 2466 AccessibilityMode::kInlineTextBoxes); |
| 2471 if (!GetOwner()) | 2467 if (!owner()) |
| 2472 return E_FAIL; | 2468 return E_FAIL; |
| 2473 | 2469 |
| 2474 if (start_index > end_index) | 2470 if (start_index > end_index) |
| 2475 std::swap(start_index, end_index); | 2471 std::swap(start_index, end_index); |
| 2476 LONG length = end_index - start_index + 1; | 2472 LONG length = end_index - start_index + 1; |
| 2477 DCHECK_GE(length, 0); | 2473 DCHECK_GE(length, 0); |
| 2478 | 2474 |
| 2479 gfx::Rect string_bounds = | 2475 gfx::Rect string_bounds = owner()->GetPageBoundsForRange(start_index, length); |
| 2480 GetOwner()->GetPageBoundsForRange(start_index, length); | 2476 string_bounds -= owner()->GetPageBoundsRect().OffsetFromOrigin(); |
| 2481 string_bounds -= GetOwner()->GetPageBoundsRect().OffsetFromOrigin(); | |
| 2482 x -= string_bounds.x(); | 2477 x -= string_bounds.x(); |
| 2483 y -= string_bounds.y(); | 2478 y -= string_bounds.y(); |
| 2484 | 2479 |
| 2485 return scrollToPoint(coordinate_type, x, y); | 2480 return scrollToPoint(coordinate_type, x, y); |
| 2486 } | 2481 } |
| 2487 | 2482 |
| 2488 STDMETHODIMP BrowserAccessibilityComWin::addSelection(LONG start_offset, | 2483 STDMETHODIMP BrowserAccessibilityComWin::addSelection(LONG start_offset, |
| 2489 LONG end_offset) { | 2484 LONG end_offset) { |
| 2490 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADD_SELECTION); | 2485 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADD_SELECTION); |
| 2491 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2486 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2492 if (!GetOwner()) | 2487 if (!owner()) |
| 2493 return E_FAIL; | 2488 return E_FAIL; |
| 2494 | 2489 |
| 2495 // We only support one selection. | 2490 // We only support one selection. |
| 2496 SetIA2HypertextSelection(start_offset, end_offset); | 2491 SetIA2HypertextSelection(start_offset, end_offset); |
| 2497 return S_OK; | 2492 return S_OK; |
| 2498 } | 2493 } |
| 2499 | 2494 |
| 2500 STDMETHODIMP BrowserAccessibilityComWin::removeSelection(LONG selection_index) { | 2495 STDMETHODIMP BrowserAccessibilityComWin::removeSelection(LONG selection_index) { |
| 2501 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_REMOVE_SELECTION); | 2496 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_REMOVE_SELECTION); |
| 2502 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2497 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2503 if (!GetOwner()) | 2498 if (!owner()) |
| 2504 return E_FAIL; | 2499 return E_FAIL; |
| 2505 | 2500 |
| 2506 if (selection_index != 0) | 2501 if (selection_index != 0) |
| 2507 return E_INVALIDARG; | 2502 return E_INVALIDARG; |
| 2508 | 2503 |
| 2509 // Simply collapse the selection to the position of the caret if a caret is | 2504 // Simply collapse the selection to the position of the caret if a caret is |
| 2510 // visible, otherwise set the selection to 0. | 2505 // visible, otherwise set the selection to 0. |
| 2511 LONG caret_offset = 0; | 2506 LONG caret_offset = 0; |
| 2512 int selection_start, selection_end; | 2507 int selection_start, selection_end; |
| 2513 GetSelectionOffsets(&selection_start, &selection_end); | 2508 GetSelectionOffsets(&selection_start, &selection_end); |
| 2514 if (GetOwner()->HasCaret() && selection_end >= 0) | 2509 if (owner()->HasCaret() && selection_end >= 0) |
| 2515 caret_offset = selection_end; | 2510 caret_offset = selection_end; |
| 2516 SetIA2HypertextSelection(caret_offset, caret_offset); | 2511 SetIA2HypertextSelection(caret_offset, caret_offset); |
| 2517 return S_OK; | 2512 return S_OK; |
| 2518 } | 2513 } |
| 2519 | 2514 |
| 2520 STDMETHODIMP BrowserAccessibilityComWin::setCaretOffset(LONG offset) { | 2515 STDMETHODIMP BrowserAccessibilityComWin::setCaretOffset(LONG offset) { |
| 2521 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CARET_OFFSET); | 2516 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CARET_OFFSET); |
| 2522 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2517 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2523 if (!GetOwner()) | 2518 if (!owner()) |
| 2524 return E_FAIL; | 2519 return E_FAIL; |
| 2525 SetIA2HypertextSelection(offset, offset); | 2520 SetIA2HypertextSelection(offset, offset); |
| 2526 return S_OK; | 2521 return S_OK; |
| 2527 } | 2522 } |
| 2528 | 2523 |
| 2529 STDMETHODIMP BrowserAccessibilityComWin::setSelection(LONG selection_index, | 2524 STDMETHODIMP BrowserAccessibilityComWin::setSelection(LONG selection_index, |
| 2530 LONG start_offset, | 2525 LONG start_offset, |
| 2531 LONG end_offset) { | 2526 LONG end_offset) { |
| 2532 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_SELECTION); | 2527 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_SELECTION); |
| 2533 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2528 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2534 if (!GetOwner()) | 2529 if (!owner()) |
| 2535 return E_FAIL; | 2530 return E_FAIL; |
| 2536 if (selection_index != 0) | 2531 if (selection_index != 0) |
| 2537 return E_INVALIDARG; | 2532 return E_INVALIDARG; |
| 2538 SetIA2HypertextSelection(start_offset, end_offset); | 2533 SetIA2HypertextSelection(start_offset, end_offset); |
| 2539 return S_OK; | 2534 return S_OK; |
| 2540 } | 2535 } |
| 2541 | 2536 |
| 2542 STDMETHODIMP BrowserAccessibilityComWin::get_attributes(LONG offset, | 2537 STDMETHODIMP BrowserAccessibilityComWin::get_attributes(LONG offset, |
| 2543 LONG* start_offset, | 2538 LONG* start_offset, |
| 2544 LONG* end_offset, | 2539 LONG* end_offset, |
| 2545 BSTR* text_attributes) { | 2540 BSTR* text_attributes) { |
| 2546 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IATEXT_GET_ATTRIBUTES); | 2541 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IATEXT_GET_ATTRIBUTES); |
| 2547 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2542 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2548 if (!start_offset || !end_offset || !text_attributes) | 2543 if (!start_offset || !end_offset || !text_attributes) |
| 2549 return E_INVALIDARG; | 2544 return E_INVALIDARG; |
| 2550 | 2545 |
| 2551 *start_offset = *end_offset = 0; | 2546 *start_offset = *end_offset = 0; |
| 2552 *text_attributes = nullptr; | 2547 *text_attributes = nullptr; |
| 2553 if (!GetOwner()) | 2548 if (!owner()) |
| 2554 return E_FAIL; | 2549 return E_FAIL; |
| 2555 | 2550 |
| 2556 const base::string16 text = GetOwner()->GetText(); | 2551 const base::string16 text = owner()->GetText(); |
| 2557 HandleSpecialTextOffset(&offset); | 2552 HandleSpecialTextOffset(&offset); |
| 2558 if (offset < 0 || offset > static_cast<LONG>(text.size())) | 2553 if (offset < 0 || offset > static_cast<LONG>(text.size())) |
| 2559 return E_INVALIDARG; | 2554 return E_INVALIDARG; |
| 2560 | 2555 |
| 2561 ComputeStylesIfNeeded(); | 2556 ComputeStylesIfNeeded(); |
| 2562 *start_offset = FindStartOfStyle(offset, ui::BACKWARDS_DIRECTION); | 2557 *start_offset = FindStartOfStyle(offset, ui::BACKWARDS_DIRECTION); |
| 2563 *end_offset = FindStartOfStyle(offset, ui::FORWARDS_DIRECTION); | 2558 *end_offset = FindStartOfStyle(offset, ui::FORWARDS_DIRECTION); |
| 2564 | 2559 |
| 2565 base::string16 attributes_str; | 2560 base::string16 attributes_str; |
| 2566 const std::vector<base::string16>& attributes = | 2561 const std::vector<base::string16>& attributes = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2578 } | 2573 } |
| 2579 | 2574 |
| 2580 // | 2575 // |
| 2581 // IAccessibleHypertext methods. | 2576 // IAccessibleHypertext methods. |
| 2582 // | 2577 // |
| 2583 | 2578 |
| 2584 STDMETHODIMP BrowserAccessibilityComWin::get_nHyperlinks( | 2579 STDMETHODIMP BrowserAccessibilityComWin::get_nHyperlinks( |
| 2585 long* hyperlink_count) { | 2580 long* hyperlink_count) { |
| 2586 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_HYPERLINKS); | 2581 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_HYPERLINKS); |
| 2587 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2582 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2588 if (!GetOwner()) | 2583 if (!owner()) |
| 2589 return E_FAIL; | 2584 return E_FAIL; |
| 2590 | 2585 |
| 2591 if (!hyperlink_count) | 2586 if (!hyperlink_count) |
| 2592 return E_INVALIDARG; | 2587 return E_INVALIDARG; |
| 2593 | 2588 |
| 2594 *hyperlink_count = hyperlink_offset_to_index().size(); | 2589 *hyperlink_count = hyperlink_offset_to_index().size(); |
| 2595 return S_OK; | 2590 return S_OK; |
| 2596 } | 2591 } |
| 2597 | 2592 |
| 2598 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlink( | 2593 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlink( |
| 2599 long index, | 2594 long index, |
| 2600 IAccessibleHyperlink** hyperlink) { | 2595 IAccessibleHyperlink** hyperlink) { |
| 2601 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK); | 2596 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK); |
| 2602 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2597 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2603 if (!GetOwner()) | 2598 if (!owner()) |
| 2604 return E_FAIL; | 2599 return E_FAIL; |
| 2605 | 2600 |
| 2606 if (!hyperlink || index < 0 || | 2601 if (!hyperlink || index < 0 || |
| 2607 index >= static_cast<long>(hyperlinks().size())) { | 2602 index >= static_cast<long>(hyperlinks().size())) { |
| 2608 return E_INVALIDARG; | 2603 return E_INVALIDARG; |
| 2609 } | 2604 } |
| 2610 | 2605 |
| 2611 int32_t id = hyperlinks()[index]; | 2606 int32_t id = hyperlinks()[index]; |
| 2612 BrowserAccessibilityComWin* link = | 2607 BrowserAccessibilityComWin* link = |
| 2613 ToBrowserAccessibilityComWin(GetOwner()->GetFromUniqueID(id)); | 2608 ToBrowserAccessibilityComWin(owner()->GetFromUniqueID(id)); |
| 2614 if (!link) | 2609 if (!link) |
| 2615 return E_FAIL; | 2610 return E_FAIL; |
| 2616 | 2611 |
| 2617 *hyperlink = static_cast<IAccessibleHyperlink*>(link->NewReference()); | 2612 *hyperlink = static_cast<IAccessibleHyperlink*>(link->NewReference()); |
| 2618 return S_OK; | 2613 return S_OK; |
| 2619 } | 2614 } |
| 2620 | 2615 |
| 2621 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlinkIndex( | 2616 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlinkIndex( |
| 2622 long char_index, | 2617 long char_index, |
| 2623 long* hyperlink_index) { | 2618 long* hyperlink_index) { |
| 2624 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX); | 2619 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX); |
| 2625 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2620 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2626 if (!GetOwner()) | 2621 if (!owner()) |
| 2627 return E_FAIL; | 2622 return E_FAIL; |
| 2628 | 2623 |
| 2629 if (!hyperlink_index) | 2624 if (!hyperlink_index) |
| 2630 return E_INVALIDARG; | 2625 return E_INVALIDARG; |
| 2631 | 2626 |
| 2632 if (char_index < 0 || | 2627 if (char_index < 0 || |
| 2633 char_index >= static_cast<long>(GetOwner()->GetText().size())) { | 2628 char_index >= static_cast<long>(owner()->GetText().size())) { |
| 2634 return E_INVALIDARG; | 2629 return E_INVALIDARG; |
| 2635 } | 2630 } |
| 2636 | 2631 |
| 2637 std::map<int32_t, int32_t>::iterator it = | 2632 std::map<int32_t, int32_t>::iterator it = |
| 2638 hyperlink_offset_to_index().find(char_index); | 2633 hyperlink_offset_to_index().find(char_index); |
| 2639 if (it == hyperlink_offset_to_index().end()) { | 2634 if (it == hyperlink_offset_to_index().end()) { |
| 2640 *hyperlink_index = -1; | 2635 *hyperlink_index = -1; |
| 2641 return S_FALSE; | 2636 return S_FALSE; |
| 2642 } | 2637 } |
| 2643 | 2638 |
| 2644 *hyperlink_index = it->second; | 2639 *hyperlink_index = it->second; |
| 2645 return S_OK; | 2640 return S_OK; |
| 2646 } | 2641 } |
| 2647 | 2642 |
| 2648 // | 2643 // |
| 2649 // IAccessibleHyperlink methods. | 2644 // IAccessibleHyperlink methods. |
| 2650 // | 2645 // |
| 2651 | 2646 |
| 2652 // Currently, only text links are supported. | 2647 // Currently, only text links are supported. |
| 2653 STDMETHODIMP BrowserAccessibilityComWin::get_anchor(long index, | 2648 STDMETHODIMP BrowserAccessibilityComWin::get_anchor(long index, |
| 2654 VARIANT* anchor) { | 2649 VARIANT* anchor) { |
| 2655 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR); | 2650 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR); |
| 2656 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2651 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2657 if (!GetOwner() || !IsHyperlink()) | 2652 if (!owner() || !IsHyperlink()) |
| 2658 return E_FAIL; | 2653 return E_FAIL; |
| 2659 | 2654 |
| 2660 // IA2 text links can have only one anchor, that is the text inside them. | 2655 // IA2 text links can have only one anchor, that is the text inside them. |
| 2661 if (index != 0 || !anchor) | 2656 if (index != 0 || !anchor) |
| 2662 return E_INVALIDARG; | 2657 return E_INVALIDARG; |
| 2663 | 2658 |
| 2664 BSTR ia2_hypertext = SysAllocString(GetOwner()->GetText().c_str()); | 2659 BSTR ia2_hypertext = SysAllocString(owner()->GetText().c_str()); |
| 2665 DCHECK(ia2_hypertext); | 2660 DCHECK(ia2_hypertext); |
| 2666 anchor->vt = VT_BSTR; | 2661 anchor->vt = VT_BSTR; |
| 2667 anchor->bstrVal = ia2_hypertext; | 2662 anchor->bstrVal = ia2_hypertext; |
| 2668 | 2663 |
| 2669 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been | 2664 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been |
| 2670 // an oversight. | 2665 // an oversight. |
| 2671 if (!SysStringLen(ia2_hypertext)) | 2666 if (!SysStringLen(ia2_hypertext)) |
| 2672 return S_FALSE; | 2667 return S_FALSE; |
| 2673 | 2668 |
| 2674 return S_OK; | 2669 return S_OK; |
| 2675 } | 2670 } |
| 2676 | 2671 |
| 2677 // Currently, only text links are supported. | 2672 // Currently, only text links are supported. |
| 2678 STDMETHODIMP BrowserAccessibilityComWin::get_anchorTarget( | 2673 STDMETHODIMP BrowserAccessibilityComWin::get_anchorTarget( |
| 2679 long index, | 2674 long index, |
| 2680 VARIANT* anchor_target) { | 2675 VARIANT* anchor_target) { |
| 2681 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR_TARGET); | 2676 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR_TARGET); |
| 2682 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2677 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2683 if (!GetOwner() || !IsHyperlink()) | 2678 if (!owner() || !IsHyperlink()) |
| 2684 return E_FAIL; | 2679 return E_FAIL; |
| 2685 | 2680 |
| 2686 // IA2 text links can have at most one target, that is when they represent an | 2681 // IA2 text links can have at most one target, that is when they represent an |
| 2687 // HTML hyperlink, i.e. an <a> element with a "href" attribute. | 2682 // HTML hyperlink, i.e. an <a> element with a "href" attribute. |
| 2688 if (index != 0 || !anchor_target) | 2683 if (index != 0 || !anchor_target) |
| 2689 return E_INVALIDARG; | 2684 return E_INVALIDARG; |
| 2690 | 2685 |
| 2691 BSTR target; | 2686 BSTR target; |
| 2692 if (!(ia_state() & STATE_SYSTEM_LINKED) || | 2687 if (!(ia_state() & STATE_SYSTEM_LINKED) || |
| 2693 FAILED(GetStringAttributeAsBstr(ui::AX_ATTR_URL, &target))) { | 2688 FAILED(GetStringAttributeAsBstr(ui::AX_ATTR_URL, &target))) { |
| 2694 target = SysAllocString(L""); | 2689 target = SysAllocString(L""); |
| 2695 } | 2690 } |
| 2696 DCHECK(target); | 2691 DCHECK(target); |
| 2697 anchor_target->vt = VT_BSTR; | 2692 anchor_target->vt = VT_BSTR; |
| 2698 anchor_target->bstrVal = target; | 2693 anchor_target->bstrVal = target; |
| 2699 | 2694 |
| 2700 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been | 2695 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been |
| 2701 // an oversight. | 2696 // an oversight. |
| 2702 if (!SysStringLen(target)) | 2697 if (!SysStringLen(target)) |
| 2703 return S_FALSE; | 2698 return S_FALSE; |
| 2704 | 2699 |
| 2705 return S_OK; | 2700 return S_OK; |
| 2706 } | 2701 } |
| 2707 | 2702 |
| 2708 STDMETHODIMP BrowserAccessibilityComWin::get_startIndex(long* index) { | 2703 STDMETHODIMP BrowserAccessibilityComWin::get_startIndex(long* index) { |
| 2709 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX); | 2704 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX); |
| 2710 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2705 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2711 if (!GetOwner() || !IsHyperlink()) | 2706 if (!owner() || !IsHyperlink()) |
| 2712 return E_FAIL; | 2707 return E_FAIL; |
| 2713 | 2708 |
| 2714 if (!index) | 2709 if (!index) |
| 2715 return E_INVALIDARG; | 2710 return E_INVALIDARG; |
| 2716 | 2711 |
| 2717 int32_t hypertext_offset = 0; | 2712 int32_t hypertext_offset = 0; |
| 2718 auto* parent = GetOwner()->PlatformGetParent(); | 2713 auto* parent = owner()->PlatformGetParent(); |
| 2719 if (parent) { | 2714 if (parent) { |
| 2720 hypertext_offset = | 2715 hypertext_offset = |
| 2721 ToBrowserAccessibilityComWin(parent)->GetHypertextOffsetFromChild( | 2716 ToBrowserAccessibilityComWin(parent)->GetHypertextOffsetFromChild( |
| 2722 *this); | 2717 *this); |
| 2723 } | 2718 } |
| 2724 *index = static_cast<LONG>(hypertext_offset); | 2719 *index = static_cast<LONG>(hypertext_offset); |
| 2725 return S_OK; | 2720 return S_OK; |
| 2726 } | 2721 } |
| 2727 | 2722 |
| 2728 STDMETHODIMP BrowserAccessibilityComWin::get_endIndex(long* index) { | 2723 STDMETHODIMP BrowserAccessibilityComWin::get_endIndex(long* index) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2742 return E_NOTIMPL; | 2737 return E_NOTIMPL; |
| 2743 } | 2738 } |
| 2744 | 2739 |
| 2745 // | 2740 // |
| 2746 // IAccessibleAction partly implemented. | 2741 // IAccessibleAction partly implemented. |
| 2747 // | 2742 // |
| 2748 | 2743 |
| 2749 STDMETHODIMP BrowserAccessibilityComWin::nActions(long* n_actions) { | 2744 STDMETHODIMP BrowserAccessibilityComWin::nActions(long* n_actions) { |
| 2750 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS); | 2745 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS); |
| 2751 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2746 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2752 if (!GetOwner()) | 2747 if (!owner()) |
| 2753 return E_FAIL; | 2748 return E_FAIL; |
| 2754 | 2749 |
| 2755 if (!n_actions) | 2750 if (!n_actions) |
| 2756 return E_INVALIDARG; | 2751 return E_INVALIDARG; |
| 2757 | 2752 |
| 2758 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| | 2753 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| |
| 2759 // to work properly because the |IAccessibleHyperlink| interface inherits from | 2754 // to work properly because the |IAccessibleHyperlink| interface inherits from |
| 2760 // |IAccessibleAction|. | 2755 // |IAccessibleAction|. |
| 2761 if (IsHyperlink() || GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION)) { | 2756 if (IsHyperlink() || owner()->HasIntAttribute(ui::AX_ATTR_ACTION)) { |
| 2762 *n_actions = 1; | 2757 *n_actions = 1; |
| 2763 } else { | 2758 } else { |
| 2764 *n_actions = 0; | 2759 *n_actions = 0; |
| 2765 } | 2760 } |
| 2766 | 2761 |
| 2767 return S_OK; | 2762 return S_OK; |
| 2768 } | 2763 } |
| 2769 | 2764 |
| 2770 STDMETHODIMP BrowserAccessibilityComWin::doAction(long action_index) { | 2765 STDMETHODIMP BrowserAccessibilityComWin::doAction(long action_index) { |
| 2771 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); | 2766 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); |
| 2772 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2767 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2773 if (!GetOwner()) | 2768 if (!owner()) |
| 2774 return E_FAIL; | 2769 return E_FAIL; |
| 2775 | 2770 |
| 2776 if (!GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) | 2771 if (!owner()->HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) |
| 2777 return E_INVALIDARG; | 2772 return E_INVALIDARG; |
| 2778 | 2773 |
| 2779 Manager()->DoDefaultAction(*GetOwner()); | 2774 Manager()->DoDefaultAction(*owner()); |
| 2780 return S_OK; | 2775 return S_OK; |
| 2781 } | 2776 } |
| 2782 | 2777 |
| 2783 STDMETHODIMP | 2778 STDMETHODIMP |
| 2784 BrowserAccessibilityComWin::get_description(long action_index, | 2779 BrowserAccessibilityComWin::get_description(long action_index, |
| 2785 BSTR* description) { | 2780 BSTR* description) { |
| 2786 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); | 2781 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); |
| 2787 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2782 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2788 return E_NOTIMPL; | 2783 return E_NOTIMPL; |
| 2789 } | 2784 } |
| 2790 | 2785 |
| 2791 STDMETHODIMP BrowserAccessibilityComWin::get_keyBinding(long action_index, | 2786 STDMETHODIMP BrowserAccessibilityComWin::get_keyBinding(long action_index, |
| 2792 long n_max_bindings, | 2787 long n_max_bindings, |
| 2793 BSTR** key_bindings, | 2788 BSTR** key_bindings, |
| 2794 long* n_bindings) { | 2789 long* n_bindings) { |
| 2795 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING); | 2790 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING); |
| 2796 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2791 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2797 return E_NOTIMPL; | 2792 return E_NOTIMPL; |
| 2798 } | 2793 } |
| 2799 | 2794 |
| 2800 STDMETHODIMP BrowserAccessibilityComWin::get_name(long action_index, | 2795 STDMETHODIMP BrowserAccessibilityComWin::get_name(long action_index, |
| 2801 BSTR* name) { | 2796 BSTR* name) { |
| 2802 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); | 2797 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); |
| 2803 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2798 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2804 if (!GetOwner()) | 2799 if (!owner()) |
| 2805 return E_FAIL; | 2800 return E_FAIL; |
| 2806 | 2801 |
| 2807 if (!name) | 2802 if (!name) |
| 2808 return E_INVALIDARG; | 2803 return E_INVALIDARG; |
| 2809 | 2804 |
| 2810 int action; | 2805 int action; |
| 2811 if (!GetOwner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || | 2806 if (!owner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || |
| 2812 action_index != 0) { | 2807 action_index != 0) { |
| 2813 *name = nullptr; | 2808 *name = nullptr; |
| 2814 return E_INVALIDARG; | 2809 return E_INVALIDARG; |
| 2815 } | 2810 } |
| 2816 | 2811 |
| 2817 base::string16 action_verb = | 2812 base::string16 action_verb = |
| 2818 ui::ActionToUnlocalizedString(static_cast<ui::AXSupportedAction>(action)); | 2813 ui::ActionToUnlocalizedString(static_cast<ui::AXSupportedAction>(action)); |
| 2819 if (action_verb.empty() || action_verb == L"none") { | 2814 if (action_verb.empty() || action_verb == L"none") { |
| 2820 *name = nullptr; | 2815 *name = nullptr; |
| 2821 return S_FALSE; | 2816 return S_FALSE; |
| 2822 } | 2817 } |
| 2823 | 2818 |
| 2824 *name = SysAllocString(action_verb.c_str()); | 2819 *name = SysAllocString(action_verb.c_str()); |
| 2825 DCHECK(name); | 2820 DCHECK(name); |
| 2826 return S_OK; | 2821 return S_OK; |
| 2827 } | 2822 } |
| 2828 | 2823 |
| 2829 STDMETHODIMP | 2824 STDMETHODIMP |
| 2830 BrowserAccessibilityComWin::get_localizedName(long action_index, | 2825 BrowserAccessibilityComWin::get_localizedName(long action_index, |
| 2831 BSTR* localized_name) { | 2826 BSTR* localized_name) { |
| 2832 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); | 2827 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); |
| 2833 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2828 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2834 if (!GetOwner()) | 2829 if (!owner()) |
| 2835 return E_FAIL; | 2830 return E_FAIL; |
| 2836 | 2831 |
| 2837 if (!localized_name) | 2832 if (!localized_name) |
| 2838 return E_INVALIDARG; | 2833 return E_INVALIDARG; |
| 2839 | 2834 |
| 2840 int action; | 2835 int action; |
| 2841 if (!GetOwner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || | 2836 if (!owner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || |
| 2842 action_index != 0) { | 2837 action_index != 0) { |
| 2843 *localized_name = nullptr; | 2838 *localized_name = nullptr; |
| 2844 return E_INVALIDARG; | 2839 return E_INVALIDARG; |
| 2845 } | 2840 } |
| 2846 | 2841 |
| 2847 base::string16 action_verb = | 2842 base::string16 action_verb = |
| 2848 ui::ActionToString(static_cast<ui::AXSupportedAction>(action)); | 2843 ui::ActionToString(static_cast<ui::AXSupportedAction>(action)); |
| 2849 if (action_verb.empty()) { | 2844 if (action_verb.empty()) { |
| 2850 *localized_name = nullptr; | 2845 *localized_name = nullptr; |
| 2851 return S_FALSE; | 2846 return S_FALSE; |
| 2852 } | 2847 } |
| 2853 | 2848 |
| 2854 *localized_name = SysAllocString(action_verb.c_str()); | 2849 *localized_name = SysAllocString(action_verb.c_str()); |
| 2855 DCHECK(localized_name); | 2850 DCHECK(localized_name); |
| 2856 return S_OK; | 2851 return S_OK; |
| 2857 } | 2852 } |
| 2858 | 2853 |
| 2859 // | 2854 // |
| 2860 // IAccessibleValue methods. | 2855 // IAccessibleValue methods. |
| 2861 // | 2856 // |
| 2862 | 2857 |
| 2863 STDMETHODIMP BrowserAccessibilityComWin::get_currentValue(VARIANT* value) { | 2858 STDMETHODIMP BrowserAccessibilityComWin::get_currentValue(VARIANT* value) { |
| 2864 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE); | 2859 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE); |
| 2865 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2860 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2866 if (!GetOwner()) | 2861 if (!owner()) |
| 2867 return E_FAIL; | 2862 return E_FAIL; |
| 2868 | 2863 |
| 2869 if (!value) | 2864 if (!value) |
| 2870 return E_INVALIDARG; | 2865 return E_INVALIDARG; |
| 2871 | 2866 |
| 2872 float float_val; | 2867 float float_val; |
| 2873 if (GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { | 2868 if (GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { |
| 2874 value->vt = VT_R8; | 2869 value->vt = VT_R8; |
| 2875 value->dblVal = float_val; | 2870 value->dblVal = float_val; |
| 2876 return S_OK; | 2871 return S_OK; |
| 2877 } | 2872 } |
| 2878 | 2873 |
| 2879 value->vt = VT_EMPTY; | 2874 value->vt = VT_EMPTY; |
| 2880 return S_FALSE; | 2875 return S_FALSE; |
| 2881 } | 2876 } |
| 2882 | 2877 |
| 2883 STDMETHODIMP BrowserAccessibilityComWin::get_minimumValue(VARIANT* value) { | 2878 STDMETHODIMP BrowserAccessibilityComWin::get_minimumValue(VARIANT* value) { |
| 2884 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MINIMUM_VALUE); | 2879 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MINIMUM_VALUE); |
| 2885 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2880 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2886 if (!GetOwner()) | 2881 if (!owner()) |
| 2887 return E_FAIL; | 2882 return E_FAIL; |
| 2888 | 2883 |
| 2889 if (!value) | 2884 if (!value) |
| 2890 return E_INVALIDARG; | 2885 return E_INVALIDARG; |
| 2891 | 2886 |
| 2892 float float_val; | 2887 float float_val; |
| 2893 if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, &float_val)) { | 2888 if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, &float_val)) { |
| 2894 value->vt = VT_R8; | 2889 value->vt = VT_R8; |
| 2895 value->dblVal = float_val; | 2890 value->dblVal = float_val; |
| 2896 return S_OK; | 2891 return S_OK; |
| 2897 } | 2892 } |
| 2898 | 2893 |
| 2899 value->vt = VT_EMPTY; | 2894 value->vt = VT_EMPTY; |
| 2900 return S_FALSE; | 2895 return S_FALSE; |
| 2901 } | 2896 } |
| 2902 | 2897 |
| 2903 STDMETHODIMP BrowserAccessibilityComWin::get_maximumValue(VARIANT* value) { | 2898 STDMETHODIMP BrowserAccessibilityComWin::get_maximumValue(VARIANT* value) { |
| 2904 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MAXIMUM_VALUE); | 2899 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MAXIMUM_VALUE); |
| 2905 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2900 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2906 if (!GetOwner()) | 2901 if (!owner()) |
| 2907 return E_FAIL; | 2902 return E_FAIL; |
| 2908 | 2903 |
| 2909 if (!value) | 2904 if (!value) |
| 2910 return E_INVALIDARG; | 2905 return E_INVALIDARG; |
| 2911 | 2906 |
| 2912 float float_val; | 2907 float float_val; |
| 2913 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, &float_val)) { | 2908 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, &float_val)) { |
| 2914 value->vt = VT_R8; | 2909 value->vt = VT_R8; |
| 2915 value->dblVal = float_val; | 2910 value->dblVal = float_val; |
| 2916 return S_OK; | 2911 return S_OK; |
| 2917 } | 2912 } |
| 2918 | 2913 |
| 2919 value->vt = VT_EMPTY; | 2914 value->vt = VT_EMPTY; |
| 2920 return S_FALSE; | 2915 return S_FALSE; |
| 2921 } | 2916 } |
| 2922 | 2917 |
| 2923 STDMETHODIMP BrowserAccessibilityComWin::setCurrentValue(VARIANT new_value) { | 2918 STDMETHODIMP BrowserAccessibilityComWin::setCurrentValue(VARIANT new_value) { |
| 2924 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CURRENT_VALUE); | 2919 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CURRENT_VALUE); |
| 2925 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2920 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2926 // TODO(dmazzoni): Implement this. | 2921 // TODO(dmazzoni): Implement this. |
| 2927 return E_NOTIMPL; | 2922 return E_NOTIMPL; |
| 2928 } | 2923 } |
| 2929 | 2924 |
| 2930 // | 2925 // |
| 2931 // ISimpleDOMDocument methods. | 2926 // ISimpleDOMDocument methods. |
| 2932 // | 2927 // |
| 2933 | 2928 |
| 2934 STDMETHODIMP BrowserAccessibilityComWin::get_URL(BSTR* url) { | 2929 STDMETHODIMP BrowserAccessibilityComWin::get_URL(BSTR* url) { |
| 2935 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_URL); | 2930 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_URL); |
| 2936 if (!GetOwner()) | 2931 if (!owner()) |
| 2937 return E_FAIL; | 2932 return E_FAIL; |
| 2938 | 2933 |
| 2939 auto* manager = Manager(); | 2934 auto* manager = Manager(); |
| 2940 if (!manager) | 2935 if (!manager) |
| 2941 return E_FAIL; | 2936 return E_FAIL; |
| 2942 | 2937 |
| 2943 if (!url) | 2938 if (!url) |
| 2944 return E_INVALIDARG; | 2939 return E_INVALIDARG; |
| 2945 | 2940 |
| 2946 if (GetOwner() != manager->GetRoot()) | 2941 if (owner() != manager->GetRoot()) |
| 2947 return E_FAIL; | 2942 return E_FAIL; |
| 2948 | 2943 |
| 2949 std::string str = manager->GetTreeData().url; | 2944 std::string str = manager->GetTreeData().url; |
| 2950 if (str.empty()) | 2945 if (str.empty()) |
| 2951 return S_FALSE; | 2946 return S_FALSE; |
| 2952 | 2947 |
| 2953 *url = SysAllocString(base::UTF8ToUTF16(str).c_str()); | 2948 *url = SysAllocString(base::UTF8ToUTF16(str).c_str()); |
| 2954 DCHECK(*url); | 2949 DCHECK(*url); |
| 2955 | 2950 |
| 2956 return S_OK; | 2951 return S_OK; |
| 2957 } | 2952 } |
| 2958 | 2953 |
| 2959 STDMETHODIMP BrowserAccessibilityComWin::get_title(BSTR* title) { | 2954 STDMETHODIMP BrowserAccessibilityComWin::get_title(BSTR* title) { |
| 2960 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TITLE); | 2955 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TITLE); |
| 2961 if (!GetOwner()) | 2956 if (!owner()) |
| 2962 return E_FAIL; | 2957 return E_FAIL; |
| 2963 | 2958 |
| 2964 auto* manager = Manager(); | 2959 auto* manager = Manager(); |
| 2965 if (!manager) | 2960 if (!manager) |
| 2966 return E_FAIL; | 2961 return E_FAIL; |
| 2967 | 2962 |
| 2968 if (!title) | 2963 if (!title) |
| 2969 return E_INVALIDARG; | 2964 return E_INVALIDARG; |
| 2970 | 2965 |
| 2971 std::string str = manager->GetTreeData().title; | 2966 std::string str = manager->GetTreeData().title; |
| 2972 if (str.empty()) | 2967 if (str.empty()) |
| 2973 return S_FALSE; | 2968 return S_FALSE; |
| 2974 | 2969 |
| 2975 *title = SysAllocString(base::UTF8ToUTF16(str).c_str()); | 2970 *title = SysAllocString(base::UTF8ToUTF16(str).c_str()); |
| 2976 DCHECK(*title); | 2971 DCHECK(*title); |
| 2977 | 2972 |
| 2978 return S_OK; | 2973 return S_OK; |
| 2979 } | 2974 } |
| 2980 | 2975 |
| 2981 STDMETHODIMP BrowserAccessibilityComWin::get_mimeType(BSTR* mime_type) { | 2976 STDMETHODIMP BrowserAccessibilityComWin::get_mimeType(BSTR* mime_type) { |
| 2982 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MIME_TYPE); | 2977 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MIME_TYPE); |
| 2983 if (!GetOwner()) | 2978 if (!owner()) |
| 2984 return E_FAIL; | 2979 return E_FAIL; |
| 2985 | 2980 |
| 2986 auto* manager = Manager(); | 2981 auto* manager = Manager(); |
| 2987 if (!manager) | 2982 if (!manager) |
| 2988 return E_FAIL; | 2983 return E_FAIL; |
| 2989 | 2984 |
| 2990 if (!mime_type) | 2985 if (!mime_type) |
| 2991 return E_INVALIDARG; | 2986 return E_INVALIDARG; |
| 2992 | 2987 |
| 2993 std::string str = manager->GetTreeData().mimetype; | 2988 std::string str = manager->GetTreeData().mimetype; |
| 2994 if (str.empty()) | 2989 if (str.empty()) |
| 2995 return S_FALSE; | 2990 return S_FALSE; |
| 2996 | 2991 |
| 2997 *mime_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); | 2992 *mime_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); |
| 2998 DCHECK(*mime_type); | 2993 DCHECK(*mime_type); |
| 2999 | 2994 |
| 3000 return S_OK; | 2995 return S_OK; |
| 3001 } | 2996 } |
| 3002 | 2997 |
| 3003 STDMETHODIMP BrowserAccessibilityComWin::get_docType(BSTR* doc_type) { | 2998 STDMETHODIMP BrowserAccessibilityComWin::get_docType(BSTR* doc_type) { |
| 3004 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOC_TYPE); | 2999 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOC_TYPE); |
| 3005 if (!GetOwner()) | 3000 if (!owner()) |
| 3006 return E_FAIL; | 3001 return E_FAIL; |
| 3007 | 3002 |
| 3008 auto* manager = Manager(); | 3003 auto* manager = Manager(); |
| 3009 if (!manager) | 3004 if (!manager) |
| 3010 return E_FAIL; | 3005 return E_FAIL; |
| 3011 | 3006 |
| 3012 if (!doc_type) | 3007 if (!doc_type) |
| 3013 return E_INVALIDARG; | 3008 return E_INVALIDARG; |
| 3014 | 3009 |
| 3015 std::string str = manager->GetTreeData().doctype; | 3010 std::string str = manager->GetTreeData().doctype; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3042 | 3037 |
| 3043 STDMETHODIMP BrowserAccessibilityComWin::get_nodeInfo( | 3038 STDMETHODIMP BrowserAccessibilityComWin::get_nodeInfo( |
| 3044 BSTR* node_name, | 3039 BSTR* node_name, |
| 3045 short* name_space_id, | 3040 short* name_space_id, |
| 3046 BSTR* node_value, | 3041 BSTR* node_value, |
| 3047 unsigned int* num_children, | 3042 unsigned int* num_children, |
| 3048 unsigned int* unique_id, | 3043 unsigned int* unique_id, |
| 3049 unsigned short* node_type) { | 3044 unsigned short* node_type) { |
| 3050 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NODE_INFO); | 3045 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NODE_INFO); |
| 3051 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3046 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3052 if (!GetOwner()) | 3047 if (!owner()) |
| 3053 return E_FAIL; | 3048 return E_FAIL; |
| 3054 | 3049 |
| 3055 if (!node_name || !name_space_id || !node_value || !num_children || | 3050 if (!node_name || !name_space_id || !node_value || !num_children || |
| 3056 !unique_id || !node_type) { | 3051 !unique_id || !node_type) { |
| 3057 return E_INVALIDARG; | 3052 return E_INVALIDARG; |
| 3058 } | 3053 } |
| 3059 | 3054 |
| 3060 base::string16 tag; | 3055 base::string16 tag; |
| 3061 if (GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) | 3056 if (owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) |
| 3062 *node_name = SysAllocString(tag.c_str()); | 3057 *node_name = SysAllocString(tag.c_str()); |
| 3063 else | 3058 else |
| 3064 *node_name = nullptr; | 3059 *node_name = nullptr; |
| 3065 | 3060 |
| 3066 *name_space_id = 0; | 3061 *name_space_id = 0; |
| 3067 *node_value = SysAllocString(value().c_str()); | 3062 *node_value = SysAllocString(value().c_str()); |
| 3068 *num_children = GetOwner()->PlatformChildCount(); | 3063 *num_children = owner()->PlatformChildCount(); |
| 3069 *unique_id = -GetOwner()->unique_id(); | 3064 *unique_id = -owner()->unique_id(); |
| 3070 | 3065 |
| 3071 if (GetOwner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 3066 if (owner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| 3072 GetOwner()->GetRole() == ui::AX_ROLE_WEB_AREA) { | 3067 owner()->GetRole() == ui::AX_ROLE_WEB_AREA) { |
| 3073 *node_type = NODETYPE_DOCUMENT; | 3068 *node_type = NODETYPE_DOCUMENT; |
| 3074 } else if (GetOwner()->IsTextOnlyObject()) { | 3069 } else if (owner()->IsTextOnlyObject()) { |
| 3075 *node_type = NODETYPE_TEXT; | 3070 *node_type = NODETYPE_TEXT; |
| 3076 } else { | 3071 } else { |
| 3077 *node_type = NODETYPE_ELEMENT; | 3072 *node_type = NODETYPE_ELEMENT; |
| 3078 } | 3073 } |
| 3079 | 3074 |
| 3080 return S_OK; | 3075 return S_OK; |
| 3081 } | 3076 } |
| 3082 | 3077 |
| 3083 STDMETHODIMP BrowserAccessibilityComWin::get_attributes( | 3078 STDMETHODIMP BrowserAccessibilityComWin::get_attributes( |
| 3084 unsigned short max_attribs, | 3079 unsigned short max_attribs, |
| 3085 BSTR* attrib_names, | 3080 BSTR* attrib_names, |
| 3086 short* name_space_id, | 3081 short* name_space_id, |
| 3087 BSTR* attrib_values, | 3082 BSTR* attrib_values, |
| 3088 unsigned short* num_attribs) { | 3083 unsigned short* num_attribs) { |
| 3089 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES); | 3084 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES); |
| 3090 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3085 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3091 if (!GetOwner()) | 3086 if (!owner()) |
| 3092 return E_FAIL; | 3087 return E_FAIL; |
| 3093 | 3088 |
| 3094 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) | 3089 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) |
| 3095 return E_INVALIDARG; | 3090 return E_INVALIDARG; |
| 3096 | 3091 |
| 3097 *num_attribs = max_attribs; | 3092 *num_attribs = max_attribs; |
| 3098 if (*num_attribs > GetOwner()->GetHtmlAttributes().size()) | 3093 if (*num_attribs > owner()->GetHtmlAttributes().size()) |
| 3099 *num_attribs = GetOwner()->GetHtmlAttributes().size(); | 3094 *num_attribs = owner()->GetHtmlAttributes().size(); |
| 3100 | 3095 |
| 3101 for (unsigned short i = 0; i < *num_attribs; ++i) { | 3096 for (unsigned short i = 0; i < *num_attribs; ++i) { |
| 3102 attrib_names[i] = SysAllocString( | 3097 attrib_names[i] = SysAllocString( |
| 3103 base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[i].first).c_str()); | 3098 base::UTF8ToUTF16(owner()->GetHtmlAttributes()[i].first).c_str()); |
| 3104 name_space_id[i] = 0; | 3099 name_space_id[i] = 0; |
| 3105 attrib_values[i] = SysAllocString( | 3100 attrib_values[i] = SysAllocString( |
| 3106 base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[i].second).c_str()); | 3101 base::UTF8ToUTF16(owner()->GetHtmlAttributes()[i].second).c_str()); |
| 3107 } | 3102 } |
| 3108 return S_OK; | 3103 return S_OK; |
| 3109 } | 3104 } |
| 3110 | 3105 |
| 3111 STDMETHODIMP BrowserAccessibilityComWin::get_attributesForNames( | 3106 STDMETHODIMP BrowserAccessibilityComWin::get_attributesForNames( |
| 3112 unsigned short num_attribs, | 3107 unsigned short num_attribs, |
| 3113 BSTR* attrib_names, | 3108 BSTR* attrib_names, |
| 3114 short* name_space_id, | 3109 short* name_space_id, |
| 3115 BSTR* attrib_values) { | 3110 BSTR* attrib_values) { |
| 3116 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ATTRIBUTES_FOR_NAMES); | 3111 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ATTRIBUTES_FOR_NAMES); |
| 3117 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3112 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3118 if (!GetOwner()) | 3113 if (!owner()) |
| 3119 return E_FAIL; | 3114 return E_FAIL; |
| 3120 | 3115 |
| 3121 if (!attrib_names || !name_space_id || !attrib_values) | 3116 if (!attrib_names || !name_space_id || !attrib_values) |
| 3122 return E_INVALIDARG; | 3117 return E_INVALIDARG; |
| 3123 | 3118 |
| 3124 for (unsigned short i = 0; i < num_attribs; ++i) { | 3119 for (unsigned short i = 0; i < num_attribs; ++i) { |
| 3125 name_space_id[i] = 0; | 3120 name_space_id[i] = 0; |
| 3126 bool found = false; | 3121 bool found = false; |
| 3127 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); | 3122 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); |
| 3128 for (unsigned int j = 0; j < GetOwner()->GetHtmlAttributes().size(); ++j) { | 3123 for (unsigned int j = 0; j < owner()->GetHtmlAttributes().size(); ++j) { |
| 3129 if (GetOwner()->GetHtmlAttributes()[j].first == name) { | 3124 if (owner()->GetHtmlAttributes()[j].first == name) { |
| 3130 attrib_values[i] = SysAllocString( | 3125 attrib_values[i] = SysAllocString( |
| 3131 base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[j].second) | 3126 base::UTF8ToUTF16(owner()->GetHtmlAttributes()[j].second).c_str()); |
| 3132 .c_str()); | |
| 3133 found = true; | 3127 found = true; |
| 3134 break; | 3128 break; |
| 3135 } | 3129 } |
| 3136 } | 3130 } |
| 3137 if (!found) { | 3131 if (!found) { |
| 3138 attrib_values[i] = NULL; | 3132 attrib_values[i] = NULL; |
| 3139 } | 3133 } |
| 3140 } | 3134 } |
| 3141 return S_OK; | 3135 return S_OK; |
| 3142 } | 3136 } |
| 3143 | 3137 |
| 3144 STDMETHODIMP BrowserAccessibilityComWin::get_computedStyle( | 3138 STDMETHODIMP BrowserAccessibilityComWin::get_computedStyle( |
| 3145 unsigned short max_style_properties, | 3139 unsigned short max_style_properties, |
| 3146 boolean use_alternate_view, | 3140 boolean use_alternate_view, |
| 3147 BSTR* style_properties, | 3141 BSTR* style_properties, |
| 3148 BSTR* style_values, | 3142 BSTR* style_values, |
| 3149 unsigned short* num_style_properties) { | 3143 unsigned short* num_style_properties) { |
| 3150 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE); | 3144 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE); |
| 3151 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3145 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3152 if (!GetOwner()) | 3146 if (!owner()) |
| 3153 return E_FAIL; | 3147 return E_FAIL; |
| 3154 | 3148 |
| 3155 if (!style_properties || !style_values) | 3149 if (!style_properties || !style_values) |
| 3156 return E_INVALIDARG; | 3150 return E_INVALIDARG; |
| 3157 | 3151 |
| 3158 // We only cache a single style property for now: DISPLAY | 3152 // We only cache a single style property for now: DISPLAY |
| 3159 | 3153 |
| 3160 base::string16 display; | 3154 base::string16 display; |
| 3161 if (max_style_properties == 0 || | 3155 if (max_style_properties == 0 || |
| 3162 !GetOwner()->GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { | 3156 !owner()->GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { |
| 3163 *num_style_properties = 0; | 3157 *num_style_properties = 0; |
| 3164 return S_OK; | 3158 return S_OK; |
| 3165 } | 3159 } |
| 3166 | 3160 |
| 3167 *num_style_properties = 1; | 3161 *num_style_properties = 1; |
| 3168 style_properties[0] = SysAllocString(L"display"); | 3162 style_properties[0] = SysAllocString(L"display"); |
| 3169 style_values[0] = SysAllocString(display.c_str()); | 3163 style_values[0] = SysAllocString(display.c_str()); |
| 3170 | 3164 |
| 3171 return S_OK; | 3165 return S_OK; |
| 3172 } | 3166 } |
| 3173 | 3167 |
| 3174 STDMETHODIMP BrowserAccessibilityComWin::get_computedStyleForProperties( | 3168 STDMETHODIMP BrowserAccessibilityComWin::get_computedStyleForProperties( |
| 3175 unsigned short num_style_properties, | 3169 unsigned short num_style_properties, |
| 3176 boolean use_alternate_view, | 3170 boolean use_alternate_view, |
| 3177 BSTR* style_properties, | 3171 BSTR* style_properties, |
| 3178 BSTR* style_values) { | 3172 BSTR* style_values) { |
| 3179 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES); | 3173 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES); |
| 3180 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3174 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3181 if (!GetOwner()) | 3175 if (!owner()) |
| 3182 return E_FAIL; | 3176 return E_FAIL; |
| 3183 | 3177 |
| 3184 if (!style_properties || !style_values) | 3178 if (!style_properties || !style_values) |
| 3185 return E_INVALIDARG; | 3179 return E_INVALIDARG; |
| 3186 | 3180 |
| 3187 // We only cache a single style property for now: DISPLAY | 3181 // We only cache a single style property for now: DISPLAY |
| 3188 | 3182 |
| 3189 for (unsigned short i = 0; i < num_style_properties; ++i) { | 3183 for (unsigned short i = 0; i < num_style_properties; ++i) { |
| 3190 base::string16 name = base::ToLowerASCII( | 3184 base::string16 name = base::ToLowerASCII( |
| 3191 reinterpret_cast<const base::char16*>(style_properties[i])); | 3185 reinterpret_cast<const base::char16*>(style_properties[i])); |
| 3192 if (name == L"display") { | 3186 if (name == L"display") { |
| 3193 base::string16 display = | 3187 base::string16 display = |
| 3194 GetOwner()->GetString16Attribute(ui::AX_ATTR_DISPLAY); | 3188 owner()->GetString16Attribute(ui::AX_ATTR_DISPLAY); |
| 3195 style_values[i] = SysAllocString(display.c_str()); | 3189 style_values[i] = SysAllocString(display.c_str()); |
| 3196 } else { | 3190 } else { |
| 3197 style_values[i] = NULL; | 3191 style_values[i] = NULL; |
| 3198 } | 3192 } |
| 3199 } | 3193 } |
| 3200 | 3194 |
| 3201 return S_OK; | 3195 return S_OK; |
| 3202 } | 3196 } |
| 3203 | 3197 |
| 3204 STDMETHODIMP BrowserAccessibilityComWin::scrollTo(boolean placeTopLeft) { | 3198 STDMETHODIMP BrowserAccessibilityComWin::scrollTo(boolean placeTopLeft) { |
| 3205 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_SCROLL_TO); | 3199 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_SCROLL_TO); |
| 3206 return scrollTo(placeTopLeft ? IA2_SCROLL_TYPE_TOP_LEFT | 3200 return scrollTo(placeTopLeft ? IA2_SCROLL_TYPE_TOP_LEFT |
| 3207 : IA2_SCROLL_TYPE_ANYWHERE); | 3201 : IA2_SCROLL_TYPE_ANYWHERE); |
| 3208 } | 3202 } |
| 3209 | 3203 |
| 3210 STDMETHODIMP BrowserAccessibilityComWin::get_parentNode(ISimpleDOMNode** node) { | 3204 STDMETHODIMP BrowserAccessibilityComWin::get_parentNode(ISimpleDOMNode** node) { |
| 3211 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE); | 3205 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE); |
| 3212 if (!GetOwner()) | 3206 if (!owner()) |
| 3213 return E_FAIL; | 3207 return E_FAIL; |
| 3214 | 3208 |
| 3215 if (!node) | 3209 if (!node) |
| 3216 return E_INVALIDARG; | 3210 return E_INVALIDARG; |
| 3217 | 3211 |
| 3218 *node = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()) | 3212 *node = ToBrowserAccessibilityComWin(owner()->PlatformGetParent()) |
| 3219 ->NewReference(); | 3213 ->NewReference(); |
| 3220 return S_OK; | 3214 return S_OK; |
| 3221 } | 3215 } |
| 3222 | 3216 |
| 3223 STDMETHODIMP BrowserAccessibilityComWin::get_firstChild(ISimpleDOMNode** node) { | 3217 STDMETHODIMP BrowserAccessibilityComWin::get_firstChild(ISimpleDOMNode** node) { |
| 3224 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD); | 3218 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD); |
| 3225 if (!GetOwner()) | 3219 if (!owner()) |
| 3226 return E_FAIL; | 3220 return E_FAIL; |
| 3227 | 3221 |
| 3228 if (!node) | 3222 if (!node) |
| 3229 return E_INVALIDARG; | 3223 return E_INVALIDARG; |
| 3230 | 3224 |
| 3231 if (GetOwner()->PlatformChildCount() == 0) { | 3225 if (owner()->PlatformChildCount() == 0) { |
| 3232 *node = NULL; | 3226 *node = NULL; |
| 3233 return S_FALSE; | 3227 return S_FALSE; |
| 3234 } | 3228 } |
| 3235 | 3229 |
| 3236 *node = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(0)) | 3230 *node = ToBrowserAccessibilityComWin(owner()->PlatformGetChild(0)) |
| 3237 ->NewReference(); | 3231 ->NewReference(); |
| 3238 return S_OK; | 3232 return S_OK; |
| 3239 } | 3233 } |
| 3240 | 3234 |
| 3241 STDMETHODIMP BrowserAccessibilityComWin::get_lastChild(ISimpleDOMNode** node) { | 3235 STDMETHODIMP BrowserAccessibilityComWin::get_lastChild(ISimpleDOMNode** node) { |
| 3242 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LAST_CHILD); | 3236 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LAST_CHILD); |
| 3243 if (!GetOwner()) | 3237 if (!owner()) |
| 3244 return E_FAIL; | 3238 return E_FAIL; |
| 3245 | 3239 |
| 3246 if (!node) | 3240 if (!node) |
| 3247 return E_INVALIDARG; | 3241 return E_INVALIDARG; |
| 3248 | 3242 |
| 3249 if (GetOwner()->PlatformChildCount() == 0) { | 3243 if (owner()->PlatformChildCount() == 0) { |
| 3250 *node = NULL; | 3244 *node = NULL; |
| 3251 return S_FALSE; | 3245 return S_FALSE; |
| 3252 } | 3246 } |
| 3253 | 3247 |
| 3254 *node = | 3248 *node = ToBrowserAccessibilityComWin( |
| 3255 ToBrowserAccessibilityComWin( | 3249 owner()->PlatformGetChild(owner()->PlatformChildCount() - 1)) |
| 3256 GetOwner()->PlatformGetChild(GetOwner()->PlatformChildCount() - 1)) | 3250 ->NewReference(); |
| 3257 ->NewReference(); | |
| 3258 return S_OK; | 3251 return S_OK; |
| 3259 } | 3252 } |
| 3260 | 3253 |
| 3261 STDMETHODIMP BrowserAccessibilityComWin::get_previousSibling( | 3254 STDMETHODIMP BrowserAccessibilityComWin::get_previousSibling( |
| 3262 ISimpleDOMNode** node) { | 3255 ISimpleDOMNode** node) { |
| 3263 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING); | 3256 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING); |
| 3264 if (!GetOwner()) | 3257 if (!owner()) |
| 3265 return E_FAIL; | 3258 return E_FAIL; |
| 3266 | 3259 |
| 3267 if (!node) | 3260 if (!node) |
| 3268 return E_INVALIDARG; | 3261 return E_INVALIDARG; |
| 3269 | 3262 |
| 3270 if (!GetOwner()->PlatformGetParent() || GetIndexInParent() <= 0) { | 3263 if (!owner()->PlatformGetParent() || GetIndexInParent() <= 0) { |
| 3271 *node = NULL; | 3264 *node = NULL; |
| 3272 return S_FALSE; | 3265 return S_FALSE; |
| 3273 } | 3266 } |
| 3274 | 3267 |
| 3275 *node = ToBrowserAccessibilityComWin( | 3268 *node = ToBrowserAccessibilityComWin( |
| 3276 GetOwner()->PlatformGetParent()->InternalGetChild( | 3269 owner()->PlatformGetParent()->InternalGetChild( |
| 3277 GetIndexInParent() - 1)) | 3270 GetIndexInParent() - 1)) |
| 3278 ->NewReference(); | 3271 ->NewReference(); |
| 3279 return S_OK; | 3272 return S_OK; |
| 3280 } | 3273 } |
| 3281 | 3274 |
| 3282 STDMETHODIMP BrowserAccessibilityComWin::get_nextSibling( | 3275 STDMETHODIMP BrowserAccessibilityComWin::get_nextSibling( |
| 3283 ISimpleDOMNode** node) { | 3276 ISimpleDOMNode** node) { |
| 3284 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING); | 3277 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING); |
| 3285 if (!GetOwner()) | 3278 if (!owner()) |
| 3286 return E_FAIL; | 3279 return E_FAIL; |
| 3287 | 3280 |
| 3288 if (!node) | 3281 if (!node) |
| 3289 return E_INVALIDARG; | 3282 return E_INVALIDARG; |
| 3290 | 3283 |
| 3291 if (!GetOwner()->PlatformGetParent() || GetIndexInParent() < 0 || | 3284 if (!owner()->PlatformGetParent() || GetIndexInParent() < 0 || |
| 3292 GetIndexInParent() >= | 3285 GetIndexInParent() >= |
| 3293 static_cast<int>( | 3286 static_cast<int>(owner()->PlatformGetParent()->InternalChildCount()) - |
| 3294 GetOwner()->PlatformGetParent()->InternalChildCount()) - | |
| 3295 1) { | 3287 1) { |
| 3296 *node = NULL; | 3288 *node = NULL; |
| 3297 return S_FALSE; | 3289 return S_FALSE; |
| 3298 } | 3290 } |
| 3299 | 3291 |
| 3300 *node = ToBrowserAccessibilityComWin( | 3292 *node = ToBrowserAccessibilityComWin( |
| 3301 GetOwner()->PlatformGetParent()->InternalGetChild( | 3293 owner()->PlatformGetParent()->InternalGetChild( |
| 3302 GetIndexInParent() + 1)) | 3294 GetIndexInParent() + 1)) |
| 3303 ->NewReference(); | 3295 ->NewReference(); |
| 3304 return S_OK; | 3296 return S_OK; |
| 3305 } | 3297 } |
| 3306 | 3298 |
| 3307 STDMETHODIMP BrowserAccessibilityComWin::get_childAt(unsigned int child_index, | 3299 STDMETHODIMP BrowserAccessibilityComWin::get_childAt(unsigned int child_index, |
| 3308 ISimpleDOMNode** node) { | 3300 ISimpleDOMNode** node) { |
| 3309 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT); | 3301 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT); |
| 3310 if (!GetOwner()) | 3302 if (!owner()) |
| 3311 return E_FAIL; | 3303 return E_FAIL; |
| 3312 | 3304 |
| 3313 if (!node) | 3305 if (!node) |
| 3314 return E_INVALIDARG; | 3306 return E_INVALIDARG; |
| 3315 | 3307 |
| 3316 if (child_index >= GetOwner()->PlatformChildCount()) | 3308 if (child_index >= owner()->PlatformChildCount()) |
| 3317 return E_INVALIDARG; | 3309 return E_INVALIDARG; |
| 3318 | 3310 |
| 3319 BrowserAccessibility* child = GetOwner()->PlatformGetChild(child_index); | 3311 BrowserAccessibility* child = owner()->PlatformGetChild(child_index); |
| 3320 if (!child) { | 3312 if (!child) { |
| 3321 *node = NULL; | 3313 *node = NULL; |
| 3322 return S_FALSE; | 3314 return S_FALSE; |
| 3323 } | 3315 } |
| 3324 | 3316 |
| 3325 *node = ToBrowserAccessibilityComWin(child)->NewReference(); | 3317 *node = ToBrowserAccessibilityComWin(child)->NewReference(); |
| 3326 return S_OK; | 3318 return S_OK; |
| 3327 } | 3319 } |
| 3328 | 3320 |
| 3329 // We only support this method for retrieving MathML content. | 3321 // We only support this method for retrieving MathML content. |
| 3330 STDMETHODIMP BrowserAccessibilityComWin::get_innerHTML(BSTR* innerHTML) { | 3322 STDMETHODIMP BrowserAccessibilityComWin::get_innerHTML(BSTR* innerHTML) { |
| 3331 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INNER_HTML); | 3323 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INNER_HTML); |
| 3332 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3324 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3333 if (!GetOwner()) | 3325 if (!owner()) |
| 3334 return E_FAIL; | 3326 return E_FAIL; |
| 3335 if (GetOwner()->GetRole() != ui::AX_ROLE_MATH) | 3327 if (owner()->GetRole() != ui::AX_ROLE_MATH) |
| 3336 return E_NOTIMPL; | 3328 return E_NOTIMPL; |
| 3337 | 3329 |
| 3338 base::string16 inner_html = | 3330 base::string16 inner_html = |
| 3339 GetOwner()->GetString16Attribute(ui::AX_ATTR_INNER_HTML); | 3331 owner()->GetString16Attribute(ui::AX_ATTR_INNER_HTML); |
| 3340 *innerHTML = SysAllocString(inner_html.c_str()); | 3332 *innerHTML = SysAllocString(inner_html.c_str()); |
| 3341 DCHECK(*innerHTML); | 3333 DCHECK(*innerHTML); |
| 3342 return S_OK; | 3334 return S_OK; |
| 3343 } | 3335 } |
| 3344 | 3336 |
| 3345 STDMETHODIMP | 3337 STDMETHODIMP |
| 3346 BrowserAccessibilityComWin::get_localInterface(void** local_interface) { | 3338 BrowserAccessibilityComWin::get_localInterface(void** local_interface) { |
| 3347 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCAL_INTERFACE); | 3339 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCAL_INTERFACE); |
| 3348 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3340 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3349 return E_NOTIMPL; | 3341 return E_NOTIMPL; |
| 3350 } | 3342 } |
| 3351 | 3343 |
| 3352 STDMETHODIMP BrowserAccessibilityComWin::get_language(BSTR* language) { | 3344 STDMETHODIMP BrowserAccessibilityComWin::get_language(BSTR* language) { |
| 3353 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LANGUAGE); | 3345 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LANGUAGE); |
| 3354 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3346 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3355 if (!language) | 3347 if (!language) |
| 3356 return E_INVALIDARG; | 3348 return E_INVALIDARG; |
| 3357 *language = nullptr; | 3349 *language = nullptr; |
| 3358 | 3350 |
| 3359 if (!GetOwner()) | 3351 if (!owner()) |
| 3360 return E_FAIL; | 3352 return E_FAIL; |
| 3361 | 3353 |
| 3362 base::string16 lang = | 3354 base::string16 lang = |
| 3363 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); | 3355 owner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); |
| 3364 if (lang.empty()) | 3356 if (lang.empty()) |
| 3365 lang = L"en-US"; | 3357 lang = L"en-US"; |
| 3366 | 3358 |
| 3367 *language = SysAllocString(lang.c_str()); | 3359 *language = SysAllocString(lang.c_str()); |
| 3368 DCHECK(*language); | 3360 DCHECK(*language); |
| 3369 return S_OK; | 3361 return S_OK; |
| 3370 } | 3362 } |
| 3371 | 3363 |
| 3372 // | 3364 // |
| 3373 // ISimpleDOMText methods. | 3365 // ISimpleDOMText methods. |
| 3374 // | 3366 // |
| 3375 | 3367 |
| 3376 STDMETHODIMP BrowserAccessibilityComWin::get_domText(BSTR* dom_text) { | 3368 STDMETHODIMP BrowserAccessibilityComWin::get_domText(BSTR* dom_text) { |
| 3377 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOM_TEXT); | 3369 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOM_TEXT); |
| 3378 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3370 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3379 if (!GetOwner()) | 3371 if (!owner()) |
| 3380 return E_FAIL; | 3372 return E_FAIL; |
| 3381 | 3373 |
| 3382 if (!dom_text) | 3374 if (!dom_text) |
| 3383 return E_INVALIDARG; | 3375 return E_INVALIDARG; |
| 3384 | 3376 |
| 3385 return GetStringAttributeAsBstr(ui::AX_ATTR_NAME, dom_text); | 3377 return GetStringAttributeAsBstr(ui::AX_ATTR_NAME, dom_text); |
| 3386 } | 3378 } |
| 3387 | 3379 |
| 3388 STDMETHODIMP BrowserAccessibilityComWin::get_clippedSubstringBounds( | 3380 STDMETHODIMP BrowserAccessibilityComWin::get_clippedSubstringBounds( |
| 3389 unsigned int start_index, | 3381 unsigned int start_index, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3404 STDMETHODIMP BrowserAccessibilityComWin::get_unclippedSubstringBounds( | 3396 STDMETHODIMP BrowserAccessibilityComWin::get_unclippedSubstringBounds( |
| 3405 unsigned int start_index, | 3397 unsigned int start_index, |
| 3406 unsigned int end_index, | 3398 unsigned int end_index, |
| 3407 int* out_x, | 3399 int* out_x, |
| 3408 int* out_y, | 3400 int* out_y, |
| 3409 int* out_width, | 3401 int* out_width, |
| 3410 int* out_height) { | 3402 int* out_height) { |
| 3411 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS); | 3403 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS); |
| 3412 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 3404 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 3413 AccessibilityMode::kInlineTextBoxes); | 3405 AccessibilityMode::kInlineTextBoxes); |
| 3414 if (!GetOwner()) | 3406 if (!owner()) |
| 3415 return E_FAIL; | 3407 return E_FAIL; |
| 3416 | 3408 |
| 3417 if (!out_x || !out_y || !out_width || !out_height) | 3409 if (!out_x || !out_y || !out_width || !out_height) |
| 3418 return E_INVALIDARG; | 3410 return E_INVALIDARG; |
| 3419 | 3411 |
| 3420 unsigned int text_length = | 3412 unsigned int text_length = |
| 3421 static_cast<unsigned int>(GetOwner()->GetText().size()); | 3413 static_cast<unsigned int>(owner()->GetText().size()); |
| 3422 if (start_index > text_length || end_index > text_length || | 3414 if (start_index > text_length || end_index > text_length || |
| 3423 start_index > end_index) { | 3415 start_index > end_index) { |
| 3424 return E_INVALIDARG; | 3416 return E_INVALIDARG; |
| 3425 } | 3417 } |
| 3426 | 3418 |
| 3427 gfx::Rect bounds = | 3419 gfx::Rect bounds = |
| 3428 GetOwner()->GetScreenBoundsForRange(start_index, end_index - start_index); | 3420 owner()->GetScreenBoundsForRange(start_index, end_index - start_index); |
| 3429 *out_x = bounds.x(); | 3421 *out_x = bounds.x(); |
| 3430 *out_y = bounds.y(); | 3422 *out_y = bounds.y(); |
| 3431 *out_width = bounds.width(); | 3423 *out_width = bounds.width(); |
| 3432 *out_height = bounds.height(); | 3424 *out_height = bounds.height(); |
| 3433 return S_OK; | 3425 return S_OK; |
| 3434 } | 3426 } |
| 3435 | 3427 |
| 3436 STDMETHODIMP BrowserAccessibilityComWin::scrollToSubstring( | 3428 STDMETHODIMP BrowserAccessibilityComWin::scrollToSubstring( |
| 3437 unsigned int start_index, | 3429 unsigned int start_index, |
| 3438 unsigned int end_index) { | 3430 unsigned int end_index) { |
| 3439 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_SUBSTRING); | 3431 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_SUBSTRING); |
| 3440 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 3432 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 3441 AccessibilityMode::kInlineTextBoxes); | 3433 AccessibilityMode::kInlineTextBoxes); |
| 3442 if (!GetOwner()) | 3434 if (!owner()) |
| 3443 return E_FAIL; | 3435 return E_FAIL; |
| 3444 | 3436 |
| 3445 auto* manager = Manager(); | 3437 auto* manager = Manager(); |
| 3446 if (!manager) | 3438 if (!manager) |
| 3447 return E_FAIL; | 3439 return E_FAIL; |
| 3448 | 3440 |
| 3449 unsigned int text_length = | 3441 unsigned int text_length = |
| 3450 static_cast<unsigned int>(GetOwner()->GetText().size()); | 3442 static_cast<unsigned int>(owner()->GetText().size()); |
| 3451 if (start_index > text_length || end_index > text_length || | 3443 if (start_index > text_length || end_index > text_length || |
| 3452 start_index > end_index) { | 3444 start_index > end_index) { |
| 3453 return E_INVALIDARG; | 3445 return E_INVALIDARG; |
| 3454 } | 3446 } |
| 3455 | 3447 |
| 3456 manager->ScrollToMakeVisible( | 3448 manager->ScrollToMakeVisible( |
| 3457 *GetOwner(), | 3449 *owner(), |
| 3458 GetOwner()->GetPageBoundsForRange(start_index, end_index - start_index)); | 3450 owner()->GetPageBoundsForRange(start_index, end_index - start_index)); |
| 3459 | 3451 |
| 3460 return S_OK; | 3452 return S_OK; |
| 3461 } | 3453 } |
| 3462 | 3454 |
| 3463 STDMETHODIMP BrowserAccessibilityComWin::get_fontFamily(BSTR* font_family) { | 3455 STDMETHODIMP BrowserAccessibilityComWin::get_fontFamily(BSTR* font_family) { |
| 3464 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FONT_FAMILY); | 3456 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FONT_FAMILY); |
| 3465 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3457 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3466 if (!font_family) | 3458 if (!font_family) |
| 3467 return E_INVALIDARG; | 3459 return E_INVALIDARG; |
| 3468 *font_family = nullptr; | 3460 *font_family = nullptr; |
| 3469 | 3461 |
| 3470 if (!GetOwner()) | 3462 if (!owner()) |
| 3471 return E_FAIL; | 3463 return E_FAIL; |
| 3472 | 3464 |
| 3473 base::string16 family = | 3465 base::string16 family = |
| 3474 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); | 3466 owner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); |
| 3475 if (family.empty()) | 3467 if (family.empty()) |
| 3476 return S_FALSE; | 3468 return S_FALSE; |
| 3477 | 3469 |
| 3478 *font_family = SysAllocString(family.c_str()); | 3470 *font_family = SysAllocString(family.c_str()); |
| 3479 DCHECK(*font_family); | 3471 DCHECK(*font_family); |
| 3480 return S_OK; | 3472 return S_OK; |
| 3481 } | 3473 } |
| 3482 | 3474 |
| 3483 // | 3475 // |
| 3484 // IServiceProvider methods. | 3476 // IServiceProvider methods. |
| 3485 // | 3477 // |
| 3486 | 3478 |
| 3487 STDMETHODIMP BrowserAccessibilityComWin::QueryService(REFGUID guid_service, | 3479 STDMETHODIMP BrowserAccessibilityComWin::QueryService(REFGUID guid_service, |
| 3488 REFIID riid, | 3480 REFIID riid, |
| 3489 void** object) { | 3481 void** object) { |
| 3490 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE); | 3482 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE); |
| 3491 if (!GetOwner()) | 3483 if (!owner()) |
| 3492 return E_FAIL; | 3484 return E_FAIL; |
| 3493 | 3485 |
| 3494 if (guid_service == GUID_IAccessibleContentDocument) { | 3486 if (guid_service == GUID_IAccessibleContentDocument) { |
| 3495 // Special Mozilla extension: return the accessible for the root document. | 3487 // Special Mozilla extension: return the accessible for the root document. |
| 3496 // Screen readers use this to distinguish between a document loaded event | 3488 // Screen readers use this to distinguish between a document loaded event |
| 3497 // on the root document vs on an iframe. | 3489 // on the root document vs on an iframe. |
| 3498 BrowserAccessibility* node = GetOwner(); | 3490 BrowserAccessibility* node = owner(); |
| 3499 while (node->PlatformGetParent()) | 3491 while (node->PlatformGetParent()) |
| 3500 node = node->PlatformGetParent()->manager()->GetRoot(); | 3492 node = node->PlatformGetParent()->manager()->GetRoot(); |
| 3501 return ToBrowserAccessibilityComWin(node)->QueryInterface(IID_IAccessible2, | 3493 return ToBrowserAccessibilityComWin(node)->QueryInterface(IID_IAccessible2, |
| 3502 object); | 3494 object); |
| 3503 } | 3495 } |
| 3504 | 3496 |
| 3505 if (guid_service == IID_IAccessible || guid_service == IID_IAccessible2 || | 3497 if (guid_service == IID_IAccessible || guid_service == IID_IAccessible2 || |
| 3506 guid_service == IID_IAccessibleAction || | 3498 guid_service == IID_IAccessibleAction || |
| 3507 guid_service == IID_IAccessibleApplication || | 3499 guid_service == IID_IAccessibleApplication || |
| 3508 guid_service == IID_IAccessibleHyperlink || | 3500 guid_service == IID_IAccessibleHyperlink || |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3557 IAccessibleEx** acc) { | 3549 IAccessibleEx** acc) { |
| 3558 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_CONVERT_RETURNED_ELEMENT); | 3550 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_CONVERT_RETURNED_ELEMENT); |
| 3559 return E_NOTIMPL; | 3551 return E_NOTIMPL; |
| 3560 } | 3552 } |
| 3561 | 3553 |
| 3562 STDMETHODIMP BrowserAccessibilityComWin::GetPatternProvider( | 3554 STDMETHODIMP BrowserAccessibilityComWin::GetPatternProvider( |
| 3563 PATTERNID id, | 3555 PATTERNID id, |
| 3564 IUnknown** provider) { | 3556 IUnknown** provider) { |
| 3565 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PATTERN_PROVIDER); | 3557 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PATTERN_PROVIDER); |
| 3566 DVLOG(1) << "In Function: " << __func__ << " for pattern id: " << id; | 3558 DVLOG(1) << "In Function: " << __func__ << " for pattern id: " << id; |
| 3567 if (!GetOwner()) | 3559 if (!owner()) |
| 3568 return E_FAIL; | 3560 return E_FAIL; |
| 3569 | 3561 |
| 3570 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { | 3562 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { |
| 3571 if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) { | 3563 if (owner()->HasState(ui::AX_STATE_EDITABLE)) { |
| 3572 DVLOG(1) << "Returning UIA text provider"; | 3564 DVLOG(1) << "Returning UIA text provider"; |
| 3573 base::win::UIATextProvider::CreateTextProvider(GetValueText(), true, | 3565 base::win::UIATextProvider::CreateTextProvider(GetValueText(), true, |
| 3574 provider); | 3566 provider); |
| 3575 return S_OK; | 3567 return S_OK; |
| 3576 } | 3568 } |
| 3577 } | 3569 } |
| 3578 return E_NOTIMPL; | 3570 return E_NOTIMPL; |
| 3579 } | 3571 } |
| 3580 | 3572 |
| 3581 STDMETHODIMP BrowserAccessibilityComWin::GetPropertyValue(PROPERTYID id, | 3573 STDMETHODIMP BrowserAccessibilityComWin::GetPropertyValue(PROPERTYID id, |
| 3582 VARIANT* ret) { | 3574 VARIANT* ret) { |
| 3583 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROPERTY_VALUE); | 3575 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROPERTY_VALUE); |
| 3584 DVLOG(1) << "In Function: " << __func__ << " for property id: " << id; | 3576 DVLOG(1) << "In Function: " << __func__ << " for property id: " << id; |
| 3585 if (!GetOwner()) | 3577 if (!owner()) |
| 3586 return E_FAIL; | 3578 return E_FAIL; |
| 3587 | 3579 |
| 3588 V_VT(ret) = VT_EMPTY; | 3580 V_VT(ret) = VT_EMPTY; |
| 3589 if (id == UIA_ControlTypePropertyId) { | 3581 if (id == UIA_ControlTypePropertyId) { |
| 3590 if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) { | 3582 if (owner()->HasState(ui::AX_STATE_EDITABLE)) { |
| 3591 V_VT(ret) = VT_I4; | 3583 V_VT(ret) = VT_I4; |
| 3592 ret->lVal = UIA_EditControlTypeId; | 3584 ret->lVal = UIA_EditControlTypeId; |
| 3593 DVLOG(1) << "Returning Edit control type"; | 3585 DVLOG(1) << "Returning Edit control type"; |
| 3594 } else { | 3586 } else { |
| 3595 DVLOG(1) << "Returning empty control type"; | 3587 DVLOG(1) << "Returning empty control type"; |
| 3596 } | 3588 } |
| 3597 } | 3589 } |
| 3598 return S_OK; | 3590 return S_OK; |
| 3599 } | 3591 } |
| 3600 | 3592 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3627 if (ia_role != ROLE_SYSTEM_GRAPHIC) { | 3619 if (ia_role != ROLE_SYSTEM_GRAPHIC) { |
| 3628 *object = NULL; | 3620 *object = NULL; |
| 3629 return E_NOINTERFACE; | 3621 return E_NOINTERFACE; |
| 3630 } | 3622 } |
| 3631 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { | 3623 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { |
| 3632 if (ia_role != ROLE_SYSTEM_TABLE) { | 3624 if (ia_role != ROLE_SYSTEM_TABLE) { |
| 3633 *object = NULL; | 3625 *object = NULL; |
| 3634 return E_NOINTERFACE; | 3626 return E_NOINTERFACE; |
| 3635 } | 3627 } |
| 3636 } else if (iid == IID_IAccessibleTableCell) { | 3628 } else if (iid == IID_IAccessibleTableCell) { |
| 3637 if (!accessibility->GetOwner()->IsCellOrTableHeaderRole()) { | 3629 if (!accessibility->owner()->IsCellOrTableHeaderRole()) { |
| 3638 *object = NULL; | 3630 *object = NULL; |
| 3639 return E_NOINTERFACE; | 3631 return E_NOINTERFACE; |
| 3640 } | 3632 } |
| 3641 } else if (iid == IID_IAccessibleValue) { | 3633 } else if (iid == IID_IAccessibleValue) { |
| 3642 if (ia_role != ROLE_SYSTEM_PROGRESSBAR && | 3634 if (ia_role != ROLE_SYSTEM_PROGRESSBAR && |
| 3643 ia_role != ROLE_SYSTEM_SCROLLBAR && ia_role != ROLE_SYSTEM_SLIDER) { | 3635 ia_role != ROLE_SYSTEM_SCROLLBAR && ia_role != ROLE_SYSTEM_SLIDER) { |
| 3644 *object = NULL; | 3636 *object = NULL; |
| 3645 return E_NOINTERFACE; | 3637 return E_NOINTERFACE; |
| 3646 } | 3638 } |
| 3647 } else if (iid == IID_ISimpleDOMDocument) { | 3639 } else if (iid == IID_ISimpleDOMDocument) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3660 | 3652 |
| 3661 return CComObjectRootBase::InternalQueryInterface(this_ptr, entries, iid, | 3653 return CComObjectRootBase::InternalQueryInterface(this_ptr, entries, iid, |
| 3662 object); | 3654 object); |
| 3663 } | 3655 } |
| 3664 | 3656 |
| 3665 void BrowserAccessibilityComWin::ComputeStylesIfNeeded() { | 3657 void BrowserAccessibilityComWin::ComputeStylesIfNeeded() { |
| 3666 if (!offset_to_text_attributes().empty()) | 3658 if (!offset_to_text_attributes().empty()) |
| 3667 return; | 3659 return; |
| 3668 | 3660 |
| 3669 std::map<int, std::vector<base::string16>> attributes_map; | 3661 std::map<int, std::vector<base::string16>> attributes_map; |
| 3670 if (GetOwner()->PlatformIsLeaf() || GetOwner()->IsSimpleTextControl()) { | 3662 if (owner()->PlatformIsLeaf() || owner()->IsSimpleTextControl()) { |
| 3671 attributes_map[0] = ComputeTextAttributes(); | 3663 attributes_map[0] = ComputeTextAttributes(); |
| 3672 std::map<int, std::vector<base::string16>> spelling_attributes = | 3664 std::map<int, std::vector<base::string16>> spelling_attributes = |
| 3673 GetSpellingAttributes(); | 3665 GetSpellingAttributes(); |
| 3674 for (auto& spelling_attribute : spelling_attributes) { | 3666 for (auto& spelling_attribute : spelling_attributes) { |
| 3675 auto attributes_iterator = attributes_map.find(spelling_attribute.first); | 3667 auto attributes_iterator = attributes_map.find(spelling_attribute.first); |
| 3676 if (attributes_iterator == attributes_map.end()) { | 3668 if (attributes_iterator == attributes_map.end()) { |
| 3677 attributes_map[spelling_attribute.first] = | 3669 attributes_map[spelling_attribute.first] = |
| 3678 std::move(spelling_attribute.second); | 3670 std::move(spelling_attribute.second); |
| 3679 } else { | 3671 } else { |
| 3680 std::vector<base::string16>& existing_attributes = | 3672 std::vector<base::string16>& existing_attributes = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3691 existing_attributes.insert(existing_attributes.end(), | 3683 existing_attributes.insert(existing_attributes.end(), |
| 3692 spelling_attribute.second.begin(), | 3684 spelling_attribute.second.begin(), |
| 3693 spelling_attribute.second.end()); | 3685 spelling_attribute.second.end()); |
| 3694 } | 3686 } |
| 3695 } | 3687 } |
| 3696 win_attributes_->offset_to_text_attributes.swap(attributes_map); | 3688 win_attributes_->offset_to_text_attributes.swap(attributes_map); |
| 3697 return; | 3689 return; |
| 3698 } | 3690 } |
| 3699 | 3691 |
| 3700 int start_offset = 0; | 3692 int start_offset = 0; |
| 3701 for (size_t i = 0; i < GetOwner()->PlatformChildCount(); ++i) { | 3693 for (size_t i = 0; i < owner()->PlatformChildCount(); ++i) { |
| 3702 auto* child = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(i)); | 3694 auto* child = ToBrowserAccessibilityComWin(owner()->PlatformGetChild(i)); |
| 3703 DCHECK(child); | 3695 DCHECK(child); |
| 3704 std::vector<base::string16> attributes(child->ComputeTextAttributes()); | 3696 std::vector<base::string16> attributes(child->ComputeTextAttributes()); |
| 3705 | 3697 |
| 3706 if (attributes_map.empty()) { | 3698 if (attributes_map.empty()) { |
| 3707 attributes_map[start_offset] = attributes; | 3699 attributes_map[start_offset] = attributes; |
| 3708 } else { | 3700 } else { |
| 3709 // Only add the attributes for this child if we are at the start of a new | 3701 // Only add the attributes for this child if we are at the start of a new |
| 3710 // style span. | 3702 // style span. |
| 3711 std::vector<base::string16> previous_attributes = | 3703 std::vector<base::string16> previous_attributes = |
| 3712 attributes_map.rbegin()->second; | 3704 attributes_map.rbegin()->second; |
| 3713 if (!std::equal(attributes.begin(), attributes.end(), | 3705 if (!std::equal(attributes.begin(), attributes.end(), |
| 3714 previous_attributes.begin())) { | 3706 previous_attributes.begin())) { |
| 3715 attributes_map[start_offset] = attributes; | 3707 attributes_map[start_offset] = attributes; |
| 3716 } | 3708 } |
| 3717 } | 3709 } |
| 3718 | 3710 |
| 3719 if (child->GetOwner()->IsTextOnlyObject()) | 3711 if (child->owner()->IsTextOnlyObject()) |
| 3720 start_offset += child->GetOwner()->GetText().length(); | 3712 start_offset += child->owner()->GetText().length(); |
| 3721 else | 3713 else |
| 3722 start_offset += 1; | 3714 start_offset += 1; |
| 3723 } | 3715 } |
| 3724 | 3716 |
| 3725 win_attributes_->offset_to_text_attributes.swap(attributes_map); | 3717 win_attributes_->offset_to_text_attributes.swap(attributes_map); |
| 3726 } | 3718 } |
| 3727 | 3719 |
| 3728 // |offset| could either be a text character or a child index in case of | 3720 // |offset| could either be a text character or a child index in case of |
| 3729 // non-text objects. | 3721 // non-text objects. |
| 3730 // TODO(nektar): Remove this function once selection bugs are fixed in Blink. | 3722 // TODO(nektar): Remove this function once selection bugs are fixed in Blink. |
| 3731 AXPlatformPosition::AXPositionInstance | 3723 AXPlatformPosition::AXPositionInstance |
| 3732 BrowserAccessibilityComWin::CreatePositionForSelectionAt(int offset) const { | 3724 BrowserAccessibilityComWin::CreatePositionForSelectionAt(int offset) const { |
| 3733 if (!GetOwner()->IsNativeTextControl() && !GetOwner()->IsTextOnlyObject()) { | 3725 if (!owner()->IsNativeTextControl() && !owner()->IsTextOnlyObject()) { |
| 3734 auto* manager = Manager(); | 3726 auto* manager = Manager(); |
| 3735 DCHECK(manager); | 3727 DCHECK(manager); |
| 3736 const BrowserAccessibilityComWin* child = this; | 3728 const BrowserAccessibilityComWin* child = this; |
| 3737 // TODO(nektar): Make parents of text-only objects not include the text of | 3729 // TODO(nektar): Make parents of text-only objects not include the text of |
| 3738 // children in their hypertext. | 3730 // children in their hypertext. |
| 3739 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { | 3731 for (size_t i = 0; i < owner()->InternalChildCount(); ++i) { |
| 3740 int new_offset = offset; | 3732 int new_offset = offset; |
| 3741 child = ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)); | 3733 child = ToBrowserAccessibilityComWin(owner()->InternalGetChild(i)); |
| 3742 DCHECK(child); | 3734 DCHECK(child); |
| 3743 if (child->GetOwner()->IsTextOnlyObject()) { | 3735 if (child->owner()->IsTextOnlyObject()) { |
| 3744 new_offset -= child->GetOwner()->GetText().length(); | 3736 new_offset -= child->owner()->GetText().length(); |
| 3745 } else { | 3737 } else { |
| 3746 new_offset -= 1; | 3738 new_offset -= 1; |
| 3747 } | 3739 } |
| 3748 if (new_offset <= 0) | 3740 if (new_offset <= 0) |
| 3749 break; | 3741 break; |
| 3750 offset = new_offset; | 3742 offset = new_offset; |
| 3751 } | 3743 } |
| 3752 AXPlatformPositionInstance position = | 3744 AXPlatformPositionInstance position = |
| 3753 AXPlatformPosition::CreateTextPosition( | 3745 AXPlatformPosition::CreateTextPosition(manager->ax_tree_id(), |
| 3754 manager->ax_tree_id(), child->GetOwner()->GetId(), offset, | 3746 child->owner()->GetId(), offset, |
| 3755 ui::AX_TEXT_AFFINITY_DOWNSTREAM) | 3747 ui::AX_TEXT_AFFINITY_DOWNSTREAM) |
| 3756 ->AsLeafTextPosition(); | 3748 ->AsLeafTextPosition(); |
| 3757 if (position->GetAnchor() && | 3749 if (position->GetAnchor() && |
| 3758 position->GetAnchor()->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) { | 3750 position->GetAnchor()->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) { |
| 3759 return position->CreateParentPosition(); | 3751 return position->CreateParentPosition(); |
| 3760 } | 3752 } |
| 3761 return position; | 3753 return position; |
| 3762 } | 3754 } |
| 3763 return GetOwner()->CreatePositionAt(offset); | 3755 return owner()->CreatePositionAt(offset); |
| 3764 } | 3756 } |
| 3765 | 3757 |
| 3766 // | 3758 // |
| 3767 // Private methods. | 3759 // Private methods. |
| 3768 // | 3760 // |
| 3769 | 3761 |
| 3770 void BrowserAccessibilityComWin::UpdateStep1ComputeWinAttributes() { | 3762 void BrowserAccessibilityComWin::UpdateStep1ComputeWinAttributes() { |
| 3771 // Swap win_attributes_ to old_win_attributes_, allowing us to see | 3763 // Swap win_attributes_ to old_win_attributes_, allowing us to see |
| 3772 // exactly what changed and fire appropriate events. Note that | 3764 // exactly what changed and fire appropriate events. Note that |
| 3773 // old_win_attributes_ is cleared at the end of UpdateStep3FireEvents. | 3765 // old_win_attributes_ is cleared at the end of UpdateStep3FireEvents. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3811 | 3803 |
| 3812 // Expose container live region attributes. | 3804 // Expose container live region attributes. |
| 3813 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, "container-live"); | 3805 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, "container-live"); |
| 3814 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, | 3806 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, |
| 3815 "container-relevant"); | 3807 "container-relevant"); |
| 3816 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, "container-atomic"); | 3808 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, "container-atomic"); |
| 3817 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy"); | 3809 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy"); |
| 3818 | 3810 |
| 3819 // Expose the non-standard explicit-name IA2 attribute. | 3811 // Expose the non-standard explicit-name IA2 attribute. |
| 3820 int name_from; | 3812 int name_from; |
| 3821 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_NAME_FROM, &name_from) && | 3813 if (owner()->GetIntAttribute(ui::AX_ATTR_NAME_FROM, &name_from) && |
| 3822 name_from != ui::AX_NAME_FROM_CONTENTS) { | 3814 name_from != ui::AX_NAME_FROM_CONTENTS) { |
| 3823 win_attributes_->ia2_attributes.push_back(L"explicit-name:true"); | 3815 win_attributes_->ia2_attributes.push_back(L"explicit-name:true"); |
| 3824 } | 3816 } |
| 3825 | 3817 |
| 3826 // Expose the aria-current attribute. | 3818 // Expose the aria-current attribute. |
| 3827 int32_t aria_current_state; | 3819 int32_t aria_current_state; |
| 3828 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, | 3820 if (owner()->GetIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, |
| 3829 &aria_current_state)) { | 3821 &aria_current_state)) { |
| 3830 switch (static_cast<ui::AXAriaCurrentState>(aria_current_state)) { | 3822 switch (static_cast<ui::AXAriaCurrentState>(aria_current_state)) { |
| 3831 case ui::AX_ARIA_CURRENT_STATE_NONE: | 3823 case ui::AX_ARIA_CURRENT_STATE_NONE: |
| 3832 break; | 3824 break; |
| 3833 case ui::AX_ARIA_CURRENT_STATE_FALSE: | 3825 case ui::AX_ARIA_CURRENT_STATE_FALSE: |
| 3834 win_attributes_->ia2_attributes.push_back(L"current:false"); | 3826 win_attributes_->ia2_attributes.push_back(L"current:false"); |
| 3835 break; | 3827 break; |
| 3836 case ui::AX_ARIA_CURRENT_STATE_TRUE: | 3828 case ui::AX_ARIA_CURRENT_STATE_TRUE: |
| 3837 win_attributes_->ia2_attributes.push_back(L"current:true"); | 3829 win_attributes_->ia2_attributes.push_back(L"current:true"); |
| 3838 break; | 3830 break; |
| 3839 case ui::AX_ARIA_CURRENT_STATE_PAGE: | 3831 case ui::AX_ARIA_CURRENT_STATE_PAGE: |
| 3840 win_attributes_->ia2_attributes.push_back(L"current:page"); | 3832 win_attributes_->ia2_attributes.push_back(L"current:page"); |
| 3841 break; | 3833 break; |
| 3842 case ui::AX_ARIA_CURRENT_STATE_STEP: | 3834 case ui::AX_ARIA_CURRENT_STATE_STEP: |
| 3843 win_attributes_->ia2_attributes.push_back(L"current:step"); | 3835 win_attributes_->ia2_attributes.push_back(L"current:step"); |
| 3844 break; | 3836 break; |
| 3845 case ui::AX_ARIA_CURRENT_STATE_LOCATION: | 3837 case ui::AX_ARIA_CURRENT_STATE_LOCATION: |
| 3846 win_attributes_->ia2_attributes.push_back(L"current:location"); | 3838 win_attributes_->ia2_attributes.push_back(L"current:location"); |
| 3847 break; | 3839 break; |
| 3848 case ui::AX_ARIA_CURRENT_STATE_DATE: | 3840 case ui::AX_ARIA_CURRENT_STATE_DATE: |
| 3849 win_attributes_->ia2_attributes.push_back(L"current:date"); | 3841 win_attributes_->ia2_attributes.push_back(L"current:date"); |
| 3850 break; | 3842 break; |
| 3851 case ui::AX_ARIA_CURRENT_STATE_TIME: | 3843 case ui::AX_ARIA_CURRENT_STATE_TIME: |
| 3852 win_attributes_->ia2_attributes.push_back(L"current:time"); | 3844 win_attributes_->ia2_attributes.push_back(L"current:time"); |
| 3853 break; | 3845 break; |
| 3854 } | 3846 } |
| 3855 } | 3847 } |
| 3856 | 3848 |
| 3857 // Expose table cell index. | 3849 // Expose table cell index. |
| 3858 if (GetOwner()->IsCellOrTableHeaderRole()) { | 3850 if (owner()->IsCellOrTableHeaderRole()) { |
| 3859 BrowserAccessibility* table = GetOwner()->PlatformGetParent(); | 3851 BrowserAccessibility* table = owner()->PlatformGetParent(); |
| 3860 while (table && !table->IsTableLikeRole()) | 3852 while (table && !table->IsTableLikeRole()) |
| 3861 table = table->PlatformGetParent(); | 3853 table = table->PlatformGetParent(); |
| 3862 if (table) { | 3854 if (table) { |
| 3863 const std::vector<int32_t>& unique_cell_ids = | 3855 const std::vector<int32_t>& unique_cell_ids = |
| 3864 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 3856 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 3865 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 3857 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
| 3866 if (unique_cell_ids[i] == GetOwner()->GetId()) { | 3858 if (unique_cell_ids[i] == owner()->GetId()) { |
| 3867 win_attributes_->ia2_attributes.push_back( | 3859 win_attributes_->ia2_attributes.push_back( |
| 3868 base::string16(L"table-cell-index:") + base::IntToString16(i)); | 3860 base::string16(L"table-cell-index:") + base::IntToString16(i)); |
| 3869 } | 3861 } |
| 3870 } | 3862 } |
| 3871 } | 3863 } |
| 3872 } | 3864 } |
| 3873 | 3865 |
| 3874 // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. | 3866 // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. |
| 3875 if (GetOwner()->IsTableLikeRole()) { | 3867 if (owner()->IsTableLikeRole()) { |
| 3876 IntAttributeToIA2(ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); | 3868 IntAttributeToIA2(ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); |
| 3877 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); | 3869 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); |
| 3878 } | 3870 } |
| 3879 | 3871 |
| 3880 // Expose aria-colindex and aria-rowindex in a cell or row. | 3872 // Expose aria-colindex and aria-rowindex in a cell or row. |
| 3881 if (GetOwner()->IsCellOrTableHeaderRole() || | 3873 if (owner()->IsCellOrTableHeaderRole() || |
| 3882 GetOwner()->GetRole() == ui::AX_ROLE_ROW) { | 3874 owner()->GetRole() == ui::AX_ROLE_ROW) { |
| 3883 if (GetOwner()->GetRole() != ui::AX_ROLE_ROW) | 3875 if (owner()->GetRole() != ui::AX_ROLE_ROW) |
| 3884 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); | 3876 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); |
| 3885 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); | 3877 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); |
| 3886 } | 3878 } |
| 3887 | 3879 |
| 3888 // Expose row or column header sort direction. | 3880 // Expose row or column header sort direction. |
| 3889 int32_t sort_direction; | 3881 int32_t sort_direction; |
| 3890 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || | 3882 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || |
| 3891 ia_role() == ROLE_SYSTEM_ROWHEADER) && | 3883 ia_role() == ROLE_SYSTEM_ROWHEADER) && |
| 3892 GetOwner()->GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, | 3884 owner()->GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { |
| 3893 &sort_direction)) { | |
| 3894 switch (static_cast<ui::AXSortDirection>(sort_direction)) { | 3885 switch (static_cast<ui::AXSortDirection>(sort_direction)) { |
| 3895 case ui::AX_SORT_DIRECTION_NONE: | 3886 case ui::AX_SORT_DIRECTION_NONE: |
| 3896 break; | 3887 break; |
| 3897 case ui::AX_SORT_DIRECTION_UNSORTED: | 3888 case ui::AX_SORT_DIRECTION_UNSORTED: |
| 3898 win_attributes_->ia2_attributes.push_back(L"sort:none"); | 3889 win_attributes_->ia2_attributes.push_back(L"sort:none"); |
| 3899 break; | 3890 break; |
| 3900 case ui::AX_SORT_DIRECTION_ASCENDING: | 3891 case ui::AX_SORT_DIRECTION_ASCENDING: |
| 3901 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); | 3892 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); |
| 3902 break; | 3893 break; |
| 3903 case ui::AX_SORT_DIRECTION_DESCENDING: | 3894 case ui::AX_SORT_DIRECTION_DESCENDING: |
| 3904 win_attributes_->ia2_attributes.push_back(L"sort:descending"); | 3895 win_attributes_->ia2_attributes.push_back(L"sort:descending"); |
| 3905 break; | 3896 break; |
| 3906 case ui::AX_SORT_DIRECTION_OTHER: | 3897 case ui::AX_SORT_DIRECTION_OTHER: |
| 3907 win_attributes_->ia2_attributes.push_back(L"sort:other"); | 3898 win_attributes_->ia2_attributes.push_back(L"sort:other"); |
| 3908 break; | 3899 break; |
| 3909 } | 3900 } |
| 3910 } | 3901 } |
| 3911 | 3902 |
| 3912 win_attributes_->name = GetOwner()->GetString16Attribute(ui::AX_ATTR_NAME); | 3903 win_attributes_->name = owner()->GetString16Attribute(ui::AX_ATTR_NAME); |
| 3913 win_attributes_->description = | 3904 win_attributes_->description = |
| 3914 GetOwner()->GetString16Attribute(ui::AX_ATTR_DESCRIPTION); | 3905 owner()->GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
| 3915 StringAttributeToIA2(ui::AX_ATTR_PLACEHOLDER, "placeholder"); | 3906 StringAttributeToIA2(ui::AX_ATTR_PLACEHOLDER, "placeholder"); |
| 3916 | 3907 |
| 3917 base::string16 value = GetOwner()->GetValue(); | 3908 base::string16 value = owner()->GetValue(); |
| 3918 // On Windows, the value of a document should be its url. | 3909 // On Windows, the value of a document should be its url. |
| 3919 if (GetOwner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 3910 if (owner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| 3920 GetOwner()->GetRole() == ui::AX_ROLE_WEB_AREA) { | 3911 owner()->GetRole() == ui::AX_ROLE_WEB_AREA) { |
| 3921 value = base::UTF8ToUTF16(Manager()->GetTreeData().url); | 3912 value = base::UTF8ToUTF16(Manager()->GetTreeData().url); |
| 3922 } | 3913 } |
| 3923 // If this doesn't have a value and is linked then set its value to the url | 3914 // If this doesn't have a value and is linked then set its value to the url |
| 3924 // attribute. This allows screen readers to read an empty link's destination. | 3915 // attribute. This allows screen readers to read an empty link's destination. |
| 3925 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) | 3916 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) |
| 3926 value = GetOwner()->GetString16Attribute(ui::AX_ATTR_URL); | 3917 value = owner()->GetString16Attribute(ui::AX_ATTR_URL); |
| 3927 win_attributes_->value = value; | 3918 win_attributes_->value = value; |
| 3928 | 3919 |
| 3929 ClearOwnRelations(); | 3920 ClearOwnRelations(); |
| 3930 AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR, | 3921 AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR, |
| 3931 IA2_RELATION_CONTROLLED_BY, | 3922 IA2_RELATION_CONTROLLED_BY, |
| 3932 ui::AX_ATTR_CONTROLS_IDS); | 3923 ui::AX_ATTR_CONTROLS_IDS); |
| 3933 AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY, | 3924 AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY, |
| 3934 IA2_RELATION_DESCRIPTION_FOR, | 3925 IA2_RELATION_DESCRIPTION_FOR, |
| 3935 ui::AX_ATTR_DESCRIBEDBY_IDS); | 3926 ui::AX_ATTR_DESCRIBEDBY_IDS); |
| 3936 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, | 3927 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, |
| 3937 ui::AX_ATTR_FLOWTO_IDS); | 3928 ui::AX_ATTR_FLOWTO_IDS); |
| 3938 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, | 3929 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, |
| 3939 ui::AX_ATTR_LABELLEDBY_IDS); | 3930 ui::AX_ATTR_LABELLEDBY_IDS); |
| 3940 AddBidirectionalRelations(IA2_RELATION_DETAILS, IA2_RELATION_DETAILS_FOR, | 3931 AddBidirectionalRelations(IA2_RELATION_DETAILS, IA2_RELATION_DETAILS_FOR, |
| 3941 ui::AX_ATTR_DETAILS_IDS); | 3932 ui::AX_ATTR_DETAILS_IDS); |
| 3942 | 3933 |
| 3943 int member_of_id; | 3934 int member_of_id; |
| 3944 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) | 3935 if (owner()->GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) |
| 3945 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); | 3936 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); |
| 3946 | 3937 |
| 3947 int error_message_id; | 3938 int error_message_id; |
| 3948 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, | 3939 if (owner()->GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, &error_message_id)) |
| 3949 &error_message_id)) | |
| 3950 AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id); | 3940 AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id); |
| 3951 | 3941 |
| 3952 // Expose slider value. | 3942 // Expose slider value. |
| 3953 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || | 3943 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| 3954 ia_role() == ROLE_SYSTEM_SCROLLBAR || ia_role() == ROLE_SYSTEM_SLIDER) { | 3944 ia_role() == ROLE_SYSTEM_SCROLLBAR || ia_role() == ROLE_SYSTEM_SLIDER) { |
| 3955 base::string16 value_text = GetValueText(); | 3945 base::string16 value_text = GetValueText(); |
| 3956 SanitizeStringAttributeForIA2(value_text, &value_text); | 3946 SanitizeStringAttributeForIA2(value_text, &value_text); |
| 3957 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); | 3947 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); |
| 3958 } | 3948 } |
| 3959 | 3949 |
| 3960 UpdateRequiredAttributes(); | 3950 UpdateRequiredAttributes(); |
| 3961 // If this is a web area for a presentational iframe, give it a role of | 3951 // If this is a web area for a presentational iframe, give it a role of |
| 3962 // something other than DOCUMENT so that the fact that it's a separate doc | 3952 // something other than DOCUMENT so that the fact that it's a separate doc |
| 3963 // is not exposed to AT. | 3953 // is not exposed to AT. |
| 3964 if (GetOwner()->IsWebAreaForPresentationalIframe()) { | 3954 if (owner()->IsWebAreaForPresentationalIframe()) { |
| 3965 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; | 3955 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
| 3966 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; | 3956 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
| 3967 } | 3957 } |
| 3968 } | 3958 } |
| 3969 | 3959 |
| 3970 void BrowserAccessibilityComWin::UpdateStep2ComputeHypertext() { | 3960 void BrowserAccessibilityComWin::UpdateStep2ComputeHypertext() { |
| 3971 if (GetOwner()->IsSimpleTextControl()) { | 3961 if (owner()->IsSimpleTextControl()) { |
| 3972 win_attributes_->hypertext = value(); | 3962 win_attributes_->hypertext = value(); |
| 3973 return; | 3963 return; |
| 3974 } | 3964 } |
| 3975 | 3965 |
| 3976 if (!GetOwner()->PlatformChildCount()) { | 3966 if (!owner()->PlatformChildCount()) { |
| 3977 if (GetOwner()->IsRichTextControl()) { | 3967 if (owner()->IsRichTextControl()) { |
| 3978 // We don't want to expose any associated label in IA2 Hypertext. | 3968 // We don't want to expose any associated label in IA2 Hypertext. |
| 3979 return; | 3969 return; |
| 3980 } | 3970 } |
| 3981 win_attributes_->hypertext = name(); | 3971 win_attributes_->hypertext = name(); |
| 3982 return; | 3972 return; |
| 3983 } | 3973 } |
| 3984 | 3974 |
| 3985 // Construct the hypertext for this node, which contains the concatenation | 3975 // Construct the hypertext for this node, which contains the concatenation |
| 3986 // of all of the static text and widespace of this node's children and an | 3976 // of all of the static text and widespace of this node's children and an |
| 3987 // embedded object character for all the other children. Build up a map from | 3977 // embedded object character for all the other children. Build up a map from |
| 3988 // the character index of each embedded object character to the id of the | 3978 // the character index of each embedded object character to the id of the |
| 3989 // child object it points to. | 3979 // child object it points to. |
| 3990 for (unsigned int i = 0; i < GetOwner()->PlatformChildCount(); ++i) { | 3980 for (unsigned int i = 0; i < owner()->PlatformChildCount(); ++i) { |
| 3991 auto* child = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(i)); | 3981 auto* child = ToBrowserAccessibilityComWin(owner()->PlatformGetChild(i)); |
| 3992 DCHECK(child); | 3982 DCHECK(child); |
| 3993 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. | 3983 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. |
| 3994 if (child->GetOwner()->IsTextOnlyObject()) { | 3984 if (child->owner()->IsTextOnlyObject()) { |
| 3995 win_attributes_->hypertext += child->name(); | 3985 win_attributes_->hypertext += child->name(); |
| 3996 } else { | 3986 } else { |
| 3997 int32_t char_offset = static_cast<int32_t>(GetOwner()->GetText().size()); | 3987 int32_t char_offset = static_cast<int32_t>(owner()->GetText().size()); |
| 3998 int32_t child_unique_id = child->GetOwner()->unique_id(); | 3988 int32_t child_unique_id = child->owner()->unique_id(); |
| 3999 int32_t index = hyperlinks().size(); | 3989 int32_t index = hyperlinks().size(); |
| 4000 win_attributes_->hyperlink_offset_to_index[char_offset] = index; | 3990 win_attributes_->hyperlink_offset_to_index[char_offset] = index; |
| 4001 win_attributes_->hyperlinks.push_back(child_unique_id); | 3991 win_attributes_->hyperlinks.push_back(child_unique_id); |
| 4002 win_attributes_->hypertext += kEmbeddedCharacter; | 3992 win_attributes_->hypertext += kEmbeddedCharacter; |
| 4003 } | 3993 } |
| 4004 } | 3994 } |
| 4005 } | 3995 } |
| 4006 | 3996 |
| 4007 void BrowserAccessibilityComWin::UpdateStep3FireEvents( | 3997 void BrowserAccessibilityComWin::UpdateStep3FireEvents( |
| 4008 bool is_subtree_creation) { | 3998 bool is_subtree_creation) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4022 FireNativeEvent(EVENT_OBJECT_VALUECHANGE); | 4012 FireNativeEvent(EVENT_OBJECT_VALUECHANGE); |
| 4023 if (ia_state() != old_win_attributes_->ia_state) | 4013 if (ia_state() != old_win_attributes_->ia_state) |
| 4024 FireNativeEvent(EVENT_OBJECT_STATECHANGE); | 4014 FireNativeEvent(EVENT_OBJECT_STATECHANGE); |
| 4025 | 4015 |
| 4026 // Handle selection being added or removed. | 4016 // Handle selection being added or removed. |
| 4027 bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0; | 4017 bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0; |
| 4028 bool was_selected_before = | 4018 bool was_selected_before = |
| 4029 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; | 4019 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; |
| 4030 if (is_selected_now || was_selected_before) { | 4020 if (is_selected_now || was_selected_before) { |
| 4031 bool multiselect = false; | 4021 bool multiselect = false; |
| 4032 if (GetOwner()->PlatformGetParent() && | 4022 if (owner()->PlatformGetParent() && |
| 4033 GetOwner()->PlatformGetParent()->HasState( | 4023 owner()->PlatformGetParent()->HasState(ui::AX_STATE_MULTISELECTABLE)) |
| 4034 ui::AX_STATE_MULTISELECTABLE)) | |
| 4035 multiselect = true; | 4024 multiselect = true; |
| 4036 | 4025 |
| 4037 if (multiselect) { | 4026 if (multiselect) { |
| 4038 // In a multi-select box, fire SELECTIONADD and SELECTIONREMOVE events. | 4027 // In a multi-select box, fire SELECTIONADD and SELECTIONREMOVE events. |
| 4039 if (is_selected_now && !was_selected_before) { | 4028 if (is_selected_now && !was_selected_before) { |
| 4040 FireNativeEvent(EVENT_OBJECT_SELECTIONADD); | 4029 FireNativeEvent(EVENT_OBJECT_SELECTIONADD); |
| 4041 } else if (!is_selected_now && was_selected_before) { | 4030 } else if (!is_selected_now && was_selected_before) { |
| 4042 FireNativeEvent(EVENT_OBJECT_SELECTIONREMOVE); | 4031 FireNativeEvent(EVENT_OBJECT_SELECTIONREMOVE); |
| 4043 } | 4032 } |
| 4044 } else if (is_selected_now && !was_selected_before) { | 4033 } else if (is_selected_now && !was_selected_before) { |
| 4045 // In a single-select box, only fire SELECTION events. | 4034 // In a single-select box, only fire SELECTION events. |
| 4046 FireNativeEvent(EVENT_OBJECT_SELECTION); | 4035 FireNativeEvent(EVENT_OBJECT_SELECTION); |
| 4047 } | 4036 } |
| 4048 } | 4037 } |
| 4049 | 4038 |
| 4050 // Fire an event if this container object has scrolled. | 4039 // Fire an event if this container object has scrolled. |
| 4051 int sx = 0; | 4040 int sx = 0; |
| 4052 int sy = 0; | 4041 int sy = 0; |
| 4053 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && | 4042 if (owner()->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && |
| 4054 GetOwner()->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { | 4043 owner()->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { |
| 4055 if (sx != previous_scroll_x_ || sy != previous_scroll_y_) | 4044 if (sx != previous_scroll_x_ || sy != previous_scroll_y_) |
| 4056 FireNativeEvent(EVENT_SYSTEM_SCROLLINGEND); | 4045 FireNativeEvent(EVENT_SYSTEM_SCROLLINGEND); |
| 4057 previous_scroll_x_ = sx; | 4046 previous_scroll_x_ = sx; |
| 4058 previous_scroll_y_ = sy; | 4047 previous_scroll_y_ = sy; |
| 4059 } | 4048 } |
| 4060 | 4049 |
| 4061 // Fire hypertext-related events. | 4050 // Fire hypertext-related events. |
| 4062 int start, old_len, new_len; | 4051 int start, old_len, new_len; |
| 4063 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | 4052 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
| 4064 if (old_len > 0) { | 4053 if (old_len > 0) { |
| 4065 // In-process screen readers may call IAccessibleText::get_oldText | 4054 // In-process screen readers may call IAccessibleText::get_oldText |
| 4066 // in reaction to this event to retrieve the text that was removed. | 4055 // in reaction to this event to retrieve the text that was removed. |
| 4067 FireNativeEvent(IA2_EVENT_TEXT_REMOVED); | 4056 FireNativeEvent(IA2_EVENT_TEXT_REMOVED); |
| 4068 } | 4057 } |
| 4069 if (new_len > 0) { | 4058 if (new_len > 0) { |
| 4070 // In-process screen readers may call IAccessibleText::get_newText | 4059 // In-process screen readers may call IAccessibleText::get_newText |
| 4071 // in reaction to this event to retrieve the text that was inserted. | 4060 // in reaction to this event to retrieve the text that was inserted. |
| 4072 FireNativeEvent(IA2_EVENT_TEXT_INSERTED); | 4061 FireNativeEvent(IA2_EVENT_TEXT_INSERTED); |
| 4073 } | 4062 } |
| 4074 | 4063 |
| 4075 // Changing a static text node can affect the IAccessibleText hypertext | 4064 // Changing a static text node can affect the IAccessibleText hypertext |
| 4076 // of the parent node, so force an update on the parent. | 4065 // of the parent node, so force an update on the parent. |
| 4077 BrowserAccessibilityComWin* parent = | 4066 BrowserAccessibilityComWin* parent = |
| 4078 ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()); | 4067 ToBrowserAccessibilityComWin(owner()->PlatformGetParent()); |
| 4079 if (parent && GetOwner()->IsTextOnlyObject() && | 4068 if (parent && owner()->IsTextOnlyObject() && |
| 4080 name() != old_win_attributes_->name) { | 4069 name() != old_win_attributes_->name) { |
| 4081 parent->GetOwner()->UpdatePlatformAttributes(); | 4070 parent->owner()->UpdatePlatformAttributes(); |
| 4082 } | 4071 } |
| 4083 } | 4072 } |
| 4084 | 4073 |
| 4085 old_win_attributes_.reset(nullptr); | 4074 old_win_attributes_.reset(nullptr); |
| 4086 } | 4075 } |
| 4087 | 4076 |
| 4088 BrowserAccessibilityManager* BrowserAccessibilityComWin::Manager() const { | 4077 BrowserAccessibilityManager* BrowserAccessibilityComWin::Manager() const { |
| 4089 auto* owner = GetOwner(); | 4078 DCHECK(owner()); |
| 4090 DCHECK(owner); | |
| 4091 | 4079 |
| 4092 auto* manager = owner->manager(); | 4080 auto* manager = owner()->manager(); |
| 4093 DCHECK(manager); | 4081 DCHECK(manager); |
| 4094 return manager; | 4082 return manager; |
| 4095 } | 4083 } |
| 4096 | 4084 |
| 4097 std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes() | 4085 std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes() |
| 4098 const { | 4086 const { |
| 4099 std::vector<base::string16> attributes; | 4087 std::vector<base::string16> attributes; |
| 4100 | 4088 |
| 4101 // We include list markers for now, but there might be other objects that are | 4089 // We include list markers for now, but there might be other objects that are |
| 4102 // auto generated. | 4090 // auto generated. |
| 4103 // TODO(nektar): Compute what objects are auto-generated in Blink. | 4091 // TODO(nektar): Compute what objects are auto-generated in Blink. |
| 4104 if (GetOwner()->GetRole() == ui::AX_ROLE_LIST_MARKER) | 4092 if (owner()->GetRole() == ui::AX_ROLE_LIST_MARKER) |
| 4105 attributes.push_back(L"auto-generated:true"); | 4093 attributes.push_back(L"auto-generated:true"); |
| 4106 else | 4094 else |
| 4107 attributes.push_back(L"auto-generated:false"); | 4095 attributes.push_back(L"auto-generated:false"); |
| 4108 | 4096 |
| 4109 int color; | 4097 int color; |
| 4110 base::string16 color_value(L"transparent"); | 4098 base::string16 color_value(L"transparent"); |
| 4111 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, &color)) { | 4099 if (owner()->GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, &color)) { |
| 4112 unsigned int alpha = SkColorGetA(color); | 4100 unsigned int alpha = SkColorGetA(color); |
| 4113 unsigned int red = SkColorGetR(color); | 4101 unsigned int red = SkColorGetR(color); |
| 4114 unsigned int green = SkColorGetG(color); | 4102 unsigned int green = SkColorGetG(color); |
| 4115 unsigned int blue = SkColorGetB(color); | 4103 unsigned int blue = SkColorGetB(color); |
| 4116 if (alpha) { | 4104 if (alpha) { |
| 4117 color_value = L"rgb(" + base::UintToString16(red) + L',' + | 4105 color_value = L"rgb(" + base::UintToString16(red) + L',' + |
| 4118 base::UintToString16(green) + L',' + | 4106 base::UintToString16(green) + L',' + |
| 4119 base::UintToString16(blue) + L')'; | 4107 base::UintToString16(blue) + L')'; |
| 4120 } | 4108 } |
| 4121 } | 4109 } |
| 4122 SanitizeStringAttributeForIA2(color_value, &color_value); | 4110 SanitizeStringAttributeForIA2(color_value, &color_value); |
| 4123 attributes.push_back(L"background-color:" + color_value); | 4111 attributes.push_back(L"background-color:" + color_value); |
| 4124 | 4112 |
| 4125 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_COLOR, &color)) { | 4113 if (owner()->GetIntAttribute(ui::AX_ATTR_COLOR, &color)) { |
| 4126 unsigned int red = SkColorGetR(color); | 4114 unsigned int red = SkColorGetR(color); |
| 4127 unsigned int green = SkColorGetG(color); | 4115 unsigned int green = SkColorGetG(color); |
| 4128 unsigned int blue = SkColorGetB(color); | 4116 unsigned int blue = SkColorGetB(color); |
| 4129 color_value = L"rgb(" + base::UintToString16(red) + L',' + | 4117 color_value = L"rgb(" + base::UintToString16(red) + L',' + |
| 4130 base::UintToString16(green) + L',' + | 4118 base::UintToString16(green) + L',' + |
| 4131 base::UintToString16(blue) + L')'; | 4119 base::UintToString16(blue) + L')'; |
| 4132 } else { | 4120 } else { |
| 4133 color_value = L"rgb(0,0,0)"; | 4121 color_value = L"rgb(0,0,0)"; |
| 4134 } | 4122 } |
| 4135 SanitizeStringAttributeForIA2(color_value, &color_value); | 4123 SanitizeStringAttributeForIA2(color_value, &color_value); |
| 4136 attributes.push_back(L"color:" + color_value); | 4124 attributes.push_back(L"color:" + color_value); |
| 4137 | 4125 |
| 4138 base::string16 font_family( | 4126 base::string16 font_family( |
| 4139 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY)); | 4127 owner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY)); |
| 4140 // Attribute has no default value. | 4128 // Attribute has no default value. |
| 4141 if (!font_family.empty()) { | 4129 if (!font_family.empty()) { |
| 4142 SanitizeStringAttributeForIA2(font_family, &font_family); | 4130 SanitizeStringAttributeForIA2(font_family, &font_family); |
| 4143 attributes.push_back(L"font-family:" + font_family); | 4131 attributes.push_back(L"font-family:" + font_family); |
| 4144 } | 4132 } |
| 4145 | 4133 |
| 4146 float font_size; | 4134 float font_size; |
| 4147 // Attribute has no default value. | 4135 // Attribute has no default value. |
| 4148 if (GetFloatAttribute(ui::AX_ATTR_FONT_SIZE, &font_size)) { | 4136 if (GetFloatAttribute(ui::AX_ATTR_FONT_SIZE, &font_size)) { |
| 4149 // The IA2 Spec requires the value to be in pt, not in pixels. | 4137 // The IA2 Spec requires the value to be in pt, not in pixels. |
| 4150 // There are 72 points per inch. | 4138 // There are 72 points per inch. |
| 4151 // We assume that there are 96 pixels per inch on a standard display. | 4139 // We assume that there are 96 pixels per inch on a standard display. |
| 4152 // TODO(nektar): Figure out the current value of pixels per inch. | 4140 // TODO(nektar): Figure out the current value of pixels per inch. |
| 4153 float points = font_size * 72.0 / 96.0; | 4141 float points = font_size * 72.0 / 96.0; |
| 4154 attributes.push_back(L"font-size:" + | 4142 attributes.push_back(L"font-size:" + |
| 4155 base::UTF8ToUTF16(base::DoubleToString(points)) + | 4143 base::UTF8ToUTF16(base::DoubleToString(points)) + |
| 4156 L"pt"); | 4144 L"pt"); |
| 4157 } | 4145 } |
| 4158 | 4146 |
| 4159 auto text_style = static_cast<ui::AXTextStyle>( | 4147 auto text_style = static_cast<ui::AXTextStyle>( |
| 4160 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); | 4148 owner()->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); |
| 4161 if (text_style == ui::AX_TEXT_STYLE_NONE) { | 4149 if (text_style == ui::AX_TEXT_STYLE_NONE) { |
| 4162 attributes.push_back(L"font-style:normal"); | 4150 attributes.push_back(L"font-style:normal"); |
| 4163 attributes.push_back(L"font-weight:normal"); | 4151 attributes.push_back(L"font-weight:normal"); |
| 4164 } else { | 4152 } else { |
| 4165 if (text_style & ui::AX_TEXT_STYLE_ITALIC) { | 4153 if (text_style & ui::AX_TEXT_STYLE_ITALIC) { |
| 4166 attributes.push_back(L"font-style:italic"); | 4154 attributes.push_back(L"font-style:italic"); |
| 4167 } else { | 4155 } else { |
| 4168 attributes.push_back(L"font-style:normal"); | 4156 attributes.push_back(L"font-style:normal"); |
| 4169 } | 4157 } |
| 4170 | 4158 |
| 4171 if (text_style & ui::AX_TEXT_STYLE_BOLD) { | 4159 if (text_style & ui::AX_TEXT_STYLE_BOLD) { |
| 4172 attributes.push_back(L"font-weight:bold"); | 4160 attributes.push_back(L"font-weight:bold"); |
| 4173 } else { | 4161 } else { |
| 4174 attributes.push_back(L"font-weight:normal"); | 4162 attributes.push_back(L"font-weight:normal"); |
| 4175 } | 4163 } |
| 4176 } | 4164 } |
| 4177 | 4165 |
| 4178 auto invalid_state = static_cast<ui::AXInvalidState>( | 4166 auto invalid_state = static_cast<ui::AXInvalidState>( |
| 4179 GetOwner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); | 4167 owner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); |
| 4180 switch (invalid_state) { | 4168 switch (invalid_state) { |
| 4181 case ui::AX_INVALID_STATE_NONE: | 4169 case ui::AX_INVALID_STATE_NONE: |
| 4182 case ui::AX_INVALID_STATE_FALSE: | 4170 case ui::AX_INVALID_STATE_FALSE: |
| 4183 attributes.push_back(L"invalid:false"); | 4171 attributes.push_back(L"invalid:false"); |
| 4184 break; | 4172 break; |
| 4185 case ui::AX_INVALID_STATE_TRUE: | 4173 case ui::AX_INVALID_STATE_TRUE: |
| 4186 attributes.push_back(L"invalid:true"); | 4174 attributes.push_back(L"invalid:true"); |
| 4187 break; | 4175 break; |
| 4188 case ui::AX_INVALID_STATE_SPELLING: | 4176 case ui::AX_INVALID_STATE_SPELLING: |
| 4189 case ui::AX_INVALID_STATE_GRAMMAR: { | 4177 case ui::AX_INVALID_STATE_GRAMMAR: { |
| 4190 base::string16 spelling_grammar_value; | 4178 base::string16 spelling_grammar_value; |
| 4191 if (invalid_state & ui::AX_INVALID_STATE_SPELLING) | 4179 if (invalid_state & ui::AX_INVALID_STATE_SPELLING) |
| 4192 spelling_grammar_value = L"spelling"; | 4180 spelling_grammar_value = L"spelling"; |
| 4193 else if (invalid_state & ui::AX_INVALID_STATE_GRAMMAR) | 4181 else if (invalid_state & ui::AX_INVALID_STATE_GRAMMAR) |
| 4194 spelling_grammar_value = L"grammar"; | 4182 spelling_grammar_value = L"grammar"; |
| 4195 else | 4183 else |
| 4196 spelling_grammar_value = L"spelling,grammar"; | 4184 spelling_grammar_value = L"spelling,grammar"; |
| 4197 attributes.push_back(L"invalid:" + spelling_grammar_value); | 4185 attributes.push_back(L"invalid:" + spelling_grammar_value); |
| 4198 break; | 4186 break; |
| 4199 } | 4187 } |
| 4200 case ui::AX_INVALID_STATE_OTHER: { | 4188 case ui::AX_INVALID_STATE_OTHER: { |
| 4201 base::string16 aria_invalid_value; | 4189 base::string16 aria_invalid_value; |
| 4202 if (GetOwner()->GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, | 4190 if (owner()->GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
| 4203 &aria_invalid_value)) { | 4191 &aria_invalid_value)) { |
| 4204 SanitizeStringAttributeForIA2(aria_invalid_value, &aria_invalid_value); | 4192 SanitizeStringAttributeForIA2(aria_invalid_value, &aria_invalid_value); |
| 4205 attributes.push_back(L"invalid:" + aria_invalid_value); | 4193 attributes.push_back(L"invalid:" + aria_invalid_value); |
| 4206 } else { | 4194 } else { |
| 4207 // Set the attribute to L"true", since we cannot be more specific. | 4195 // Set the attribute to L"true", since we cannot be more specific. |
| 4208 attributes.push_back(L"invalid:true"); | 4196 attributes.push_back(L"invalid:true"); |
| 4209 } | 4197 } |
| 4210 break; | 4198 break; |
| 4211 } | 4199 } |
| 4212 } | 4200 } |
| 4213 | 4201 |
| 4214 base::string16 language( | 4202 base::string16 language( |
| 4215 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); | 4203 owner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); |
| 4216 // Default value should be L"en-US". | 4204 // Default value should be L"en-US". |
| 4217 if (language.empty()) { | 4205 if (language.empty()) { |
| 4218 attributes.push_back(L"language:en-US"); | 4206 attributes.push_back(L"language:en-US"); |
| 4219 } else { | 4207 } else { |
| 4220 SanitizeStringAttributeForIA2(language, &language); | 4208 SanitizeStringAttributeForIA2(language, &language); |
| 4221 attributes.push_back(L"language:" + language); | 4209 attributes.push_back(L"language:" + language); |
| 4222 } | 4210 } |
| 4223 | 4211 |
| 4224 // TODO(nektar): Add Blink support for the following attributes. | 4212 // TODO(nektar): Add Blink support for the following attributes. |
| 4225 // Currently set to their default values as dictated by the IA2 Spec. | 4213 // Currently set to their default values as dictated by the IA2 Spec. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4247 // TODO(nektar): Figure out a more specific value. | 4235 // TODO(nektar): Figure out a more specific value. |
| 4248 attributes.push_back(L"text-underline-style:solid"); | 4236 attributes.push_back(L"text-underline-style:solid"); |
| 4249 attributes.push_back(L"text-underline-type:single"); | 4237 attributes.push_back(L"text-underline-type:single"); |
| 4250 } else { | 4238 } else { |
| 4251 attributes.push_back(L"text-underline-style:none"); | 4239 attributes.push_back(L"text-underline-style:none"); |
| 4252 attributes.push_back(L"text-underline-type:none"); | 4240 attributes.push_back(L"text-underline-type:none"); |
| 4253 } | 4241 } |
| 4254 attributes.push_back(L"text-underline-width:auto"); | 4242 attributes.push_back(L"text-underline-width:auto"); |
| 4255 | 4243 |
| 4256 auto text_direction = static_cast<ui::AXTextDirection>( | 4244 auto text_direction = static_cast<ui::AXTextDirection>( |
| 4257 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); | 4245 owner()->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); |
| 4258 switch (text_direction) { | 4246 switch (text_direction) { |
| 4259 case ui::AX_TEXT_DIRECTION_NONE: | 4247 case ui::AX_TEXT_DIRECTION_NONE: |
| 4260 case ui::AX_TEXT_DIRECTION_LTR: | 4248 case ui::AX_TEXT_DIRECTION_LTR: |
| 4261 attributes.push_back(L"writing-mode:lr"); | 4249 attributes.push_back(L"writing-mode:lr"); |
| 4262 break; | 4250 break; |
| 4263 case ui::AX_TEXT_DIRECTION_RTL: | 4251 case ui::AX_TEXT_DIRECTION_RTL: |
| 4264 attributes.push_back(L"writing-mode:rl"); | 4252 attributes.push_back(L"writing-mode:rl"); |
| 4265 break; | 4253 break; |
| 4266 case ui::AX_TEXT_DIRECTION_TTB: | 4254 case ui::AX_TEXT_DIRECTION_TTB: |
| 4267 attributes.push_back(L"writing-mode:tb"); | 4255 attributes.push_back(L"writing-mode:tb"); |
| 4268 break; | 4256 break; |
| 4269 case ui::AX_TEXT_DIRECTION_BTT: | 4257 case ui::AX_TEXT_DIRECTION_BTT: |
| 4270 // Not listed in the IA2 Spec. | 4258 // Not listed in the IA2 Spec. |
| 4271 attributes.push_back(L"writing-mode:bt"); | 4259 attributes.push_back(L"writing-mode:bt"); |
| 4272 break; | 4260 break; |
| 4273 } | 4261 } |
| 4274 | 4262 |
| 4275 return attributes; | 4263 return attributes; |
| 4276 } | 4264 } |
| 4277 | 4265 |
| 4278 BrowserAccessibilityComWin* BrowserAccessibilityComWin::NewReference() { | 4266 BrowserAccessibilityComWin* BrowserAccessibilityComWin::NewReference() { |
| 4279 AddRef(); | 4267 AddRef(); |
| 4280 return this; | 4268 return this; |
| 4281 } | 4269 } |
| 4282 | 4270 |
| 4283 std::map<int, std::vector<base::string16>> | 4271 std::map<int, std::vector<base::string16>> |
| 4284 BrowserAccessibilityComWin::GetSpellingAttributes() { | 4272 BrowserAccessibilityComWin::GetSpellingAttributes() { |
| 4285 std::map<int, std::vector<base::string16>> spelling_attributes; | 4273 std::map<int, std::vector<base::string16>> spelling_attributes; |
| 4286 if (GetOwner()->IsTextOnlyObject()) { | 4274 if (owner()->IsTextOnlyObject()) { |
| 4287 const std::vector<int32_t>& marker_types = | 4275 const std::vector<int32_t>& marker_types = |
| 4288 GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); | 4276 owner()->GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); |
| 4289 const std::vector<int>& marker_starts = | 4277 const std::vector<int>& marker_starts = |
| 4290 GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); | 4278 owner()->GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); |
| 4291 const std::vector<int>& marker_ends = | 4279 const std::vector<int>& marker_ends = |
| 4292 GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); | 4280 owner()->GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); |
| 4293 for (size_t i = 0; i < marker_types.size(); ++i) { | 4281 for (size_t i = 0; i < marker_types.size(); ++i) { |
| 4294 if (!(static_cast<ui::AXMarkerType>(marker_types[i]) & | 4282 if (!(static_cast<ui::AXMarkerType>(marker_types[i]) & |
| 4295 ui::AX_MARKER_TYPE_SPELLING)) | 4283 ui::AX_MARKER_TYPE_SPELLING)) |
| 4296 continue; | 4284 continue; |
| 4297 int start_offset = marker_starts[i]; | 4285 int start_offset = marker_starts[i]; |
| 4298 int end_offset = marker_ends[i]; | 4286 int end_offset = marker_ends[i]; |
| 4299 std::vector<base::string16> start_attributes; | 4287 std::vector<base::string16> start_attributes; |
| 4300 start_attributes.push_back(L"invalid:spelling"); | 4288 start_attributes.push_back(L"invalid:spelling"); |
| 4301 std::vector<base::string16> end_attributes; | 4289 std::vector<base::string16> end_attributes; |
| 4302 end_attributes.push_back(L"invalid:false"); | 4290 end_attributes.push_back(L"invalid:false"); |
| 4303 spelling_attributes[start_offset] = start_attributes; | 4291 spelling_attributes[start_offset] = start_attributes; |
| 4304 spelling_attributes[end_offset] = end_attributes; | 4292 spelling_attributes[end_offset] = end_attributes; |
| 4305 } | 4293 } |
| 4306 } | 4294 } |
| 4307 if (GetOwner()->IsSimpleTextControl()) { | 4295 if (owner()->IsSimpleTextControl()) { |
| 4308 int start_offset = 0; | 4296 int start_offset = 0; |
| 4309 for (BrowserAccessibility* static_text = | 4297 for (BrowserAccessibility* static_text = |
| 4310 BrowserAccessibilityManager::NextTextOnlyObject( | 4298 BrowserAccessibilityManager::NextTextOnlyObject( |
| 4311 GetOwner()->InternalGetChild(0)); | 4299 owner()->InternalGetChild(0)); |
| 4312 static_text; static_text = static_text->GetNextSibling()) { | 4300 static_text; static_text = static_text->GetNextSibling()) { |
| 4313 auto* text_win = ToBrowserAccessibilityComWin(static_text); | 4301 auto* text_win = ToBrowserAccessibilityComWin(static_text); |
| 4314 if (text_win) { | 4302 if (text_win) { |
| 4315 std::map<int, std::vector<base::string16>> text_spelling_attributes = | 4303 std::map<int, std::vector<base::string16>> text_spelling_attributes = |
| 4316 text_win->GetSpellingAttributes(); | 4304 text_win->GetSpellingAttributes(); |
| 4317 for (auto& attribute : text_spelling_attributes) { | 4305 for (auto& attribute : text_spelling_attributes) { |
| 4318 spelling_attributes[start_offset + attribute.first] = | 4306 spelling_attributes[start_offset + attribute.first] = |
| 4319 std::move(attribute.second); | 4307 std::move(attribute.second); |
| 4320 } | 4308 } |
| 4321 start_offset += | 4309 start_offset += static_cast<int>(text_win->owner()->GetText().length()); |
| 4322 static_cast<int>(text_win->GetOwner()->GetText().length()); | |
| 4323 } | 4310 } |
| 4324 } | 4311 } |
| 4325 } | 4312 } |
| 4326 return spelling_attributes; | 4313 return spelling_attributes; |
| 4327 } | 4314 } |
| 4328 | 4315 |
| 4329 BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetTargetFromChildID( | 4316 BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetTargetFromChildID( |
| 4330 const VARIANT& var_id) { | 4317 const VARIANT& var_id) { |
| 4331 if (!GetOwner()) | 4318 if (!owner()) |
| 4332 return nullptr; | 4319 return nullptr; |
| 4333 | 4320 |
| 4334 if (var_id.vt != VT_I4) | 4321 if (var_id.vt != VT_I4) |
| 4335 return nullptr; | 4322 return nullptr; |
| 4336 | 4323 |
| 4337 LONG child_id = var_id.lVal; | 4324 LONG child_id = var_id.lVal; |
| 4338 if (child_id == CHILDID_SELF) | 4325 if (child_id == CHILDID_SELF) |
| 4339 return this; | 4326 return this; |
| 4340 | 4327 |
| 4341 if (child_id >= 1 && | 4328 if (child_id >= 1 && |
| 4342 child_id <= static_cast<LONG>(GetOwner()->PlatformChildCount())) | 4329 child_id <= static_cast<LONG>(owner()->PlatformChildCount())) |
| 4343 return ToBrowserAccessibilityComWin( | 4330 return ToBrowserAccessibilityComWin( |
| 4344 GetOwner()->PlatformGetChild(child_id - 1)); | 4331 owner()->PlatformGetChild(child_id - 1)); |
| 4345 | 4332 |
| 4346 BrowserAccessibilityComWin* child = ToBrowserAccessibilityComWin( | 4333 BrowserAccessibilityComWin* child = ToBrowserAccessibilityComWin( |
| 4347 BrowserAccessibility::GetFromUniqueID(-child_id)); | 4334 BrowserAccessibility::GetFromUniqueID(-child_id)); |
| 4348 if (child && child->GetOwner()->IsDescendantOf(GetOwner())) | 4335 if (child && child->owner()->IsDescendantOf(owner())) |
| 4349 return child; | 4336 return child; |
| 4350 | 4337 |
| 4351 return nullptr; | 4338 return nullptr; |
| 4352 } | 4339 } |
| 4353 | 4340 |
| 4354 HRESULT BrowserAccessibilityComWin::GetStringAttributeAsBstr( | 4341 HRESULT BrowserAccessibilityComWin::GetStringAttributeAsBstr( |
| 4355 ui::AXStringAttribute attribute, | 4342 ui::AXStringAttribute attribute, |
| 4356 BSTR* value_bstr) { | 4343 BSTR* value_bstr) { |
| 4357 base::string16 str; | 4344 base::string16 str; |
| 4358 if (!GetOwner()) | 4345 if (!owner()) |
| 4359 return E_FAIL; | 4346 return E_FAIL; |
| 4360 | 4347 |
| 4361 if (!GetOwner()->GetString16Attribute(attribute, &str)) | 4348 if (!owner()->GetString16Attribute(attribute, &str)) |
| 4362 return S_FALSE; | 4349 return S_FALSE; |
| 4363 | 4350 |
| 4364 *value_bstr = SysAllocString(str.c_str()); | 4351 *value_bstr = SysAllocString(str.c_str()); |
| 4365 DCHECK(*value_bstr); | 4352 DCHECK(*value_bstr); |
| 4366 | 4353 |
| 4367 return S_OK; | 4354 return S_OK; |
| 4368 } | 4355 } |
| 4369 | 4356 |
| 4370 // Static | 4357 // Static |
| 4371 void BrowserAccessibilityComWin::SanitizeStringAttributeForIA2( | 4358 void BrowserAccessibilityComWin::SanitizeStringAttributeForIA2( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4391 AXPlatformPositionInstance end_position = | 4378 AXPlatformPositionInstance end_position = |
| 4392 CreatePositionForSelectionAt(static_cast<int>(end_offset)); | 4379 CreatePositionForSelectionAt(static_cast<int>(end_offset)); |
| 4393 Manager()->SetSelection(AXPlatformRange(start_position->AsTextPosition(), | 4380 Manager()->SetSelection(AXPlatformRange(start_position->AsTextPosition(), |
| 4394 end_position->AsTextPosition())); | 4381 end_position->AsTextPosition())); |
| 4395 } | 4382 } |
| 4396 | 4383 |
| 4397 void BrowserAccessibilityComWin::StringAttributeToIA2( | 4384 void BrowserAccessibilityComWin::StringAttributeToIA2( |
| 4398 ui::AXStringAttribute attribute, | 4385 ui::AXStringAttribute attribute, |
| 4399 const char* ia2_attr) { | 4386 const char* ia2_attr) { |
| 4400 base::string16 value; | 4387 base::string16 value; |
| 4401 if (GetOwner()->GetString16Attribute(attribute, &value)) { | 4388 if (owner()->GetString16Attribute(attribute, &value)) { |
| 4402 SanitizeStringAttributeForIA2(value, &value); | 4389 SanitizeStringAttributeForIA2(value, &value); |
| 4403 win_attributes_->ia2_attributes.push_back(base::ASCIIToUTF16(ia2_attr) + | 4390 win_attributes_->ia2_attributes.push_back(base::ASCIIToUTF16(ia2_attr) + |
| 4404 L":" + value); | 4391 L":" + value); |
| 4405 } | 4392 } |
| 4406 } | 4393 } |
| 4407 | 4394 |
| 4408 void BrowserAccessibilityComWin::BoolAttributeToIA2( | 4395 void BrowserAccessibilityComWin::BoolAttributeToIA2( |
| 4409 ui::AXBoolAttribute attribute, | 4396 ui::AXBoolAttribute attribute, |
| 4410 const char* ia2_attr) { | 4397 const char* ia2_attr) { |
| 4411 bool value; | 4398 bool value; |
| 4412 if (GetOwner()->GetBoolAttribute(attribute, &value)) { | 4399 if (owner()->GetBoolAttribute(attribute, &value)) { |
| 4413 win_attributes_->ia2_attributes.push_back( | 4400 win_attributes_->ia2_attributes.push_back( |
| 4414 (base::ASCIIToUTF16(ia2_attr) + L":") + (value ? L"true" : L"false")); | 4401 (base::ASCIIToUTF16(ia2_attr) + L":") + (value ? L"true" : L"false")); |
| 4415 } | 4402 } |
| 4416 } | 4403 } |
| 4417 | 4404 |
| 4418 void BrowserAccessibilityComWin::IntAttributeToIA2(ui::AXIntAttribute attribute, | 4405 void BrowserAccessibilityComWin::IntAttributeToIA2(ui::AXIntAttribute attribute, |
| 4419 const char* ia2_attr) { | 4406 const char* ia2_attr) { |
| 4420 int value; | 4407 int value; |
| 4421 if (GetOwner()->GetIntAttribute(attribute, &value)) { | 4408 if (owner()->GetIntAttribute(attribute, &value)) { |
| 4422 win_attributes_->ia2_attributes.push_back( | 4409 win_attributes_->ia2_attributes.push_back( |
| 4423 base::ASCIIToUTF16(ia2_attr) + L":" + base::IntToString16(value)); | 4410 base::ASCIIToUTF16(ia2_attr) + L":" + base::IntToString16(value)); |
| 4424 } | 4411 } |
| 4425 } | 4412 } |
| 4426 | 4413 |
| 4427 bool BrowserAccessibilityComWin::IsHyperlink() const { | 4414 bool BrowserAccessibilityComWin::IsHyperlink() const { |
| 4428 int32_t hyperlink_index = -1; | 4415 int32_t hyperlink_index = -1; |
| 4429 auto* parent = GetOwner()->PlatformGetParent(); | 4416 auto* parent = owner()->PlatformGetParent(); |
| 4430 if (parent) { | 4417 if (parent) { |
| 4431 hyperlink_index = | 4418 hyperlink_index = |
| 4432 ToBrowserAccessibilityComWin(parent)->GetHyperlinkIndexFromChild(*this); | 4419 ToBrowserAccessibilityComWin(parent)->GetHyperlinkIndexFromChild(*this); |
| 4433 } | 4420 } |
| 4434 | 4421 |
| 4435 if (hyperlink_index >= 0) | 4422 if (hyperlink_index >= 0) |
| 4436 return true; | 4423 return true; |
| 4437 return false; | 4424 return false; |
| 4438 } | 4425 } |
| 4439 | 4426 |
| 4440 BrowserAccessibilityComWin* | 4427 BrowserAccessibilityComWin* |
| 4441 BrowserAccessibilityComWin::GetHyperlinkFromHypertextOffset(int offset) const { | 4428 BrowserAccessibilityComWin::GetHyperlinkFromHypertextOffset(int offset) const { |
| 4442 std::map<int32_t, int32_t>::iterator iterator = | 4429 std::map<int32_t, int32_t>::iterator iterator = |
| 4443 hyperlink_offset_to_index().find(offset); | 4430 hyperlink_offset_to_index().find(offset); |
| 4444 if (iterator == hyperlink_offset_to_index().end()) | 4431 if (iterator == hyperlink_offset_to_index().end()) |
| 4445 return nullptr; | 4432 return nullptr; |
| 4446 | 4433 |
| 4447 int32_t index = iterator->second; | 4434 int32_t index = iterator->second; |
| 4448 DCHECK_GE(index, 0); | 4435 DCHECK_GE(index, 0); |
| 4449 DCHECK_LT(index, static_cast<int32_t>(hyperlinks().size())); | 4436 DCHECK_LT(index, static_cast<int32_t>(hyperlinks().size())); |
| 4450 int32_t id = hyperlinks()[index]; | 4437 int32_t id = hyperlinks()[index]; |
| 4451 BrowserAccessibilityComWin* hyperlink = | 4438 BrowserAccessibilityComWin* hyperlink = |
| 4452 ToBrowserAccessibilityComWin(GetOwner()->GetFromUniqueID(id)); | 4439 ToBrowserAccessibilityComWin(owner()->GetFromUniqueID(id)); |
| 4453 if (!hyperlink) | 4440 if (!hyperlink) |
| 4454 return nullptr; | 4441 return nullptr; |
| 4455 return hyperlink; | 4442 return hyperlink; |
| 4456 } | 4443 } |
| 4457 | 4444 |
| 4458 int32_t BrowserAccessibilityComWin::GetHyperlinkIndexFromChild( | 4445 int32_t BrowserAccessibilityComWin::GetHyperlinkIndexFromChild( |
| 4459 const BrowserAccessibilityComWin& child) const { | 4446 const BrowserAccessibilityComWin& child) const { |
| 4460 if (hyperlinks().empty()) | 4447 if (hyperlinks().empty()) |
| 4461 return -1; | 4448 return -1; |
| 4462 | 4449 |
| 4463 auto iterator = std::find(hyperlinks().begin(), hyperlinks().end(), | 4450 auto iterator = std::find(hyperlinks().begin(), hyperlinks().end(), |
| 4464 child.GetOwner()->unique_id()); | 4451 child.owner()->unique_id()); |
| 4465 if (iterator == hyperlinks().end()) | 4452 if (iterator == hyperlinks().end()) |
| 4466 return -1; | 4453 return -1; |
| 4467 | 4454 |
| 4468 return static_cast<int32_t>(iterator - hyperlinks().begin()); | 4455 return static_cast<int32_t>(iterator - hyperlinks().begin()); |
| 4469 } | 4456 } |
| 4470 | 4457 |
| 4471 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromHyperlinkIndex( | 4458 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromHyperlinkIndex( |
| 4472 int32_t hyperlink_index) const { | 4459 int32_t hyperlink_index) const { |
| 4473 for (auto& offset_index : hyperlink_offset_to_index()) { | 4460 for (auto& offset_index : hyperlink_offset_to_index()) { |
| 4474 if (offset_index.second == hyperlink_index) | 4461 if (offset_index.second == hyperlink_index) |
| 4475 return offset_index.first; | 4462 return offset_index.first; |
| 4476 } | 4463 } |
| 4477 | 4464 |
| 4478 return -1; | 4465 return -1; |
| 4479 } | 4466 } |
| 4480 | 4467 |
| 4481 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromChild( | 4468 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromChild( |
| 4482 BrowserAccessibilityComWin& child) { | 4469 BrowserAccessibilityComWin& child) { |
| 4483 DCHECK(child.GetOwner()->PlatformGetParent() == GetOwner()); | 4470 DCHECK(child.owner()->PlatformGetParent() == owner()); |
| 4484 | 4471 |
| 4485 // Handle the case when we are dealing with a direct text-only child. | 4472 // Handle the case when we are dealing with a direct text-only child. |
| 4486 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, | 4473 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, |
| 4487 // and so |GetOwner()->InternalChild...| functions need to be used. Also, | 4474 // and so |owner()->InternalChild...| functions need to be used. Also, |
| 4488 // direct text-only children should not be present at tree roots and so no | 4475 // direct text-only children should not be present at tree roots and so no |
| 4489 // cross-tree traversal is necessary.) | 4476 // cross-tree traversal is necessary.) |
| 4490 if (child.GetOwner()->IsTextOnlyObject()) { | 4477 if (child.owner()->IsTextOnlyObject()) { |
| 4491 int32_t hypertextOffset = 0; | 4478 int32_t hypertextOffset = 0; |
| 4492 int32_t index_in_parent = child.GetIndexInParent(); | 4479 int32_t index_in_parent = child.GetIndexInParent(); |
| 4493 DCHECK_GE(index_in_parent, 0); | 4480 DCHECK_GE(index_in_parent, 0); |
| 4494 DCHECK_LT(index_in_parent, | 4481 DCHECK_LT(index_in_parent, |
| 4495 static_cast<int32_t>(GetOwner()->InternalChildCount())); | 4482 static_cast<int32_t>(owner()->InternalChildCount())); |
| 4496 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { | 4483 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { |
| 4497 const BrowserAccessibilityComWin* sibling = | 4484 const BrowserAccessibilityComWin* sibling = |
| 4498 ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)); | 4485 ToBrowserAccessibilityComWin(owner()->InternalGetChild(i)); |
| 4499 DCHECK(sibling); | 4486 DCHECK(sibling); |
| 4500 if (sibling->GetOwner()->IsTextOnlyObject()) | 4487 if (sibling->owner()->IsTextOnlyObject()) |
| 4501 hypertextOffset += sibling->GetOwner()->GetText().size(); | 4488 hypertextOffset += sibling->owner()->GetText().size(); |
| 4502 else | 4489 else |
| 4503 ++hypertextOffset; | 4490 ++hypertextOffset; |
| 4504 } | 4491 } |
| 4505 return hypertextOffset; | 4492 return hypertextOffset; |
| 4506 } | 4493 } |
| 4507 | 4494 |
| 4508 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); | 4495 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); |
| 4509 if (hyperlink_index < 0) | 4496 if (hyperlink_index < 0) |
| 4510 return -1; | 4497 return -1; |
| 4511 | 4498 |
| 4512 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); | 4499 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); |
| 4513 } | 4500 } |
| 4514 | 4501 |
| 4515 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromDescendant( | 4502 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromDescendant( |
| 4516 const BrowserAccessibilityComWin& descendant) const { | 4503 const BrowserAccessibilityComWin& descendant) const { |
| 4517 auto* parent_object = | 4504 auto* parent_object = |
| 4518 ToBrowserAccessibilityComWin(descendant.GetOwner()->PlatformGetParent()); | 4505 ToBrowserAccessibilityComWin(descendant.owner()->PlatformGetParent()); |
| 4519 auto* current_object = const_cast<BrowserAccessibilityComWin*>(&descendant); | 4506 auto* current_object = const_cast<BrowserAccessibilityComWin*>(&descendant); |
| 4520 while (parent_object && parent_object != this) { | 4507 while (parent_object && parent_object != this) { |
| 4521 current_object = parent_object; | 4508 current_object = parent_object; |
| 4522 parent_object = ToBrowserAccessibilityComWin( | 4509 parent_object = ToBrowserAccessibilityComWin( |
| 4523 current_object->GetOwner()->PlatformGetParent()); | 4510 current_object->owner()->PlatformGetParent()); |
| 4524 } | 4511 } |
| 4525 if (!parent_object) | 4512 if (!parent_object) |
| 4526 return -1; | 4513 return -1; |
| 4527 | 4514 |
| 4528 return parent_object->GetHypertextOffsetFromChild(*current_object); | 4515 return parent_object->GetHypertextOffsetFromChild(*current_object); |
| 4529 } | 4516 } |
| 4530 | 4517 |
| 4531 int BrowserAccessibilityComWin::GetHypertextOffsetFromEndpoint( | 4518 int BrowserAccessibilityComWin::GetHypertextOffsetFromEndpoint( |
| 4532 const BrowserAccessibilityComWin& endpoint_object, | 4519 const BrowserAccessibilityComWin& endpoint_object, |
| 4533 int endpoint_offset) const { | 4520 int endpoint_offset) const { |
| 4534 // There are three cases: | 4521 // There are three cases: |
| 4535 // 1. Either the selection endpoint is inside this object or is an ancestor of | 4522 // 1. Either the selection endpoint is inside this object or is an ancestor of |
| 4536 // of this object. endpoint_offset should be returned. | 4523 // of this object. endpoint_offset should be returned. |
| 4537 // 2. The selection endpoint is a pure descendant of this object. The offset | 4524 // 2. The selection endpoint is a pure descendant of this object. The offset |
| 4538 // of the character corresponding to the subtree in which the endpoint is | 4525 // of the character corresponding to the subtree in which the endpoint is |
| 4539 // located should be returned. | 4526 // located should be returned. |
| 4540 // 3. The selection endpoint is in a completely different part of the tree. | 4527 // 3. The selection endpoint is in a completely different part of the tree. |
| 4541 // Either 0 or text_length should be returned depending on the direction that | 4528 // Either 0 or text_length should be returned depending on the direction that |
| 4542 // one needs to travel to find the endpoint. | 4529 // one needs to travel to find the endpoint. |
| 4543 | 4530 |
| 4544 // Case 1. | 4531 // Case 1. |
| 4545 // | 4532 // |
| 4546 // IsDescendantOf includes the case when endpoint_object == this. | 4533 // IsDescendantOf includes the case when endpoint_object == this. |
| 4547 if (GetOwner()->IsDescendantOf(endpoint_object.GetOwner())) | 4534 if (owner()->IsDescendantOf(endpoint_object.owner())) |
| 4548 return endpoint_offset; | 4535 return endpoint_offset; |
| 4549 | 4536 |
| 4550 const BrowserAccessibility* common_parent = GetOwner(); | 4537 const BrowserAccessibility* common_parent = owner(); |
| 4551 int32_t index_in_common_parent = GetOwner()->GetIndexInParent(); | 4538 int32_t index_in_common_parent = owner()->GetIndexInParent(); |
| 4552 while (common_parent && | 4539 while (common_parent && |
| 4553 !endpoint_object.GetOwner()->IsDescendantOf(common_parent)) { | 4540 !endpoint_object.owner()->IsDescendantOf(common_parent)) { |
| 4554 index_in_common_parent = common_parent->GetIndexInParent(); | 4541 index_in_common_parent = common_parent->GetIndexInParent(); |
| 4555 common_parent = common_parent->PlatformGetParent(); | 4542 common_parent = common_parent->PlatformGetParent(); |
| 4556 } | 4543 } |
| 4557 if (!common_parent) | 4544 if (!common_parent) |
| 4558 return -1; | 4545 return -1; |
| 4559 | 4546 |
| 4560 DCHECK_GE(index_in_common_parent, 0); | 4547 DCHECK_GE(index_in_common_parent, 0); |
| 4561 DCHECK(!(common_parent->IsTextOnlyObject())); | 4548 DCHECK(!(common_parent->IsTextOnlyObject())); |
| 4562 | 4549 |
| 4563 // Case 2. | 4550 // Case 2. |
| 4564 // | 4551 // |
| 4565 // We already checked in case 1 if our endpoint is inside this object. | 4552 // We already checked in case 1 if our endpoint is inside this object. |
| 4566 // We can safely assume that it is a descendant or in a completely different | 4553 // We can safely assume that it is a descendant or in a completely different |
| 4567 // part of the tree. | 4554 // part of the tree. |
| 4568 if (common_parent == GetOwner()) { | 4555 if (common_parent == owner()) { |
| 4569 int32_t hypertext_offset = | 4556 int32_t hypertext_offset = |
| 4570 GetHypertextOffsetFromDescendant(endpoint_object); | 4557 GetHypertextOffsetFromDescendant(endpoint_object); |
| 4571 if (endpoint_object.GetOwner()->PlatformGetParent() == GetOwner() && | 4558 if (endpoint_object.owner()->PlatformGetParent() == owner() && |
| 4572 endpoint_object.GetOwner()->IsTextOnlyObject()) { | 4559 endpoint_object.owner()->IsTextOnlyObject()) { |
| 4573 hypertext_offset += endpoint_offset; | 4560 hypertext_offset += endpoint_offset; |
| 4574 } | 4561 } |
| 4575 | 4562 |
| 4576 return hypertext_offset; | 4563 return hypertext_offset; |
| 4577 } | 4564 } |
| 4578 | 4565 |
| 4579 // Case 3. | 4566 // Case 3. |
| 4580 // | 4567 // |
| 4581 // We can safely assume that the endpoint is in another part of the tree or | 4568 // We can safely assume that the endpoint is in another part of the tree or |
| 4582 // at common parent, and that this object is a descendant of common parent. | 4569 // at common parent, and that this object is a descendant of common parent. |
| 4583 int32_t endpoint_index_in_common_parent = -1; | 4570 int32_t endpoint_index_in_common_parent = -1; |
| 4584 for (uint32_t i = 0; i < common_parent->InternalChildCount(); ++i) { | 4571 for (uint32_t i = 0; i < common_parent->InternalChildCount(); ++i) { |
| 4585 const BrowserAccessibility* child = common_parent->InternalGetChild(i); | 4572 const BrowserAccessibility* child = common_parent->InternalGetChild(i); |
| 4586 DCHECK(child); | 4573 DCHECK(child); |
| 4587 if (endpoint_object.GetOwner()->IsDescendantOf(child)) { | 4574 if (endpoint_object.owner()->IsDescendantOf(child)) { |
| 4588 endpoint_index_in_common_parent = child->GetIndexInParent(); | 4575 endpoint_index_in_common_parent = child->GetIndexInParent(); |
| 4589 break; | 4576 break; |
| 4590 } | 4577 } |
| 4591 } | 4578 } |
| 4592 DCHECK_GE(endpoint_index_in_common_parent, 0); | 4579 DCHECK_GE(endpoint_index_in_common_parent, 0); |
| 4593 | 4580 |
| 4594 if (endpoint_index_in_common_parent < index_in_common_parent) | 4581 if (endpoint_index_in_common_parent < index_in_common_parent) |
| 4595 return 0; | 4582 return 0; |
| 4596 if (endpoint_index_in_common_parent > index_in_common_parent) | 4583 if (endpoint_index_in_common_parent > index_in_common_parent) |
| 4597 return GetOwner()->GetText().size(); | 4584 return owner()->GetText().size(); |
| 4598 | 4585 |
| 4599 NOTREACHED(); | 4586 NOTREACHED(); |
| 4600 return -1; | 4587 return -1; |
| 4601 } | 4588 } |
| 4602 | 4589 |
| 4603 int BrowserAccessibilityComWin::GetSelectionAnchor() const { | 4590 int BrowserAccessibilityComWin::GetSelectionAnchor() const { |
| 4604 int32_t anchor_id = Manager()->GetTreeData().sel_anchor_object_id; | 4591 int32_t anchor_id = Manager()->GetTreeData().sel_anchor_object_id; |
| 4605 const BrowserAccessibilityComWin* anchor_object = GetFromID(anchor_id); | 4592 const BrowserAccessibilityComWin* anchor_object = GetFromID(anchor_id); |
| 4606 if (!anchor_object) | 4593 if (!anchor_object) |
| 4607 return -1; | 4594 return -1; |
| 4608 | 4595 |
| 4609 int anchor_offset = Manager()->GetTreeData().sel_anchor_offset; | 4596 int anchor_offset = Manager()->GetTreeData().sel_anchor_offset; |
| 4610 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); | 4597 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); |
| 4611 } | 4598 } |
| 4612 | 4599 |
| 4613 int BrowserAccessibilityComWin::GetSelectionFocus() const { | 4600 int BrowserAccessibilityComWin::GetSelectionFocus() const { |
| 4614 int32_t focus_id = Manager()->GetTreeData().sel_focus_object_id; | 4601 int32_t focus_id = Manager()->GetTreeData().sel_focus_object_id; |
| 4615 const BrowserAccessibilityComWin* focus_object = GetFromID(focus_id); | 4602 const BrowserAccessibilityComWin* focus_object = GetFromID(focus_id); |
| 4616 if (!focus_object) | 4603 if (!focus_object) |
| 4617 return -1; | 4604 return -1; |
| 4618 | 4605 |
| 4619 int focus_offset = Manager()->GetTreeData().sel_focus_offset; | 4606 int focus_offset = Manager()->GetTreeData().sel_focus_offset; |
| 4620 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); | 4607 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); |
| 4621 } | 4608 } |
| 4622 | 4609 |
| 4623 void BrowserAccessibilityComWin::GetSelectionOffsets(int* selection_start, | 4610 void BrowserAccessibilityComWin::GetSelectionOffsets(int* selection_start, |
| 4624 int* selection_end) const { | 4611 int* selection_end) const { |
| 4625 DCHECK(selection_start && selection_end); | 4612 DCHECK(selection_start && selection_end); |
| 4626 | 4613 |
| 4627 if (GetOwner()->IsSimpleTextControl() && | 4614 if (owner()->IsSimpleTextControl() && |
| 4628 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, | 4615 owner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) && |
| 4629 selection_start) && | 4616 owner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { |
| 4630 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { | |
| 4631 return; | 4617 return; |
| 4632 } | 4618 } |
| 4633 | 4619 |
| 4634 *selection_start = GetSelectionAnchor(); | 4620 *selection_start = GetSelectionAnchor(); |
| 4635 *selection_end = GetSelectionFocus(); | 4621 *selection_end = GetSelectionFocus(); |
| 4636 if (*selection_start < 0 || *selection_end < 0) | 4622 if (*selection_start < 0 || *selection_end < 0) |
| 4637 return; | 4623 return; |
| 4638 | 4624 |
| 4639 // There are three cases when a selection would start and end on the same | 4625 // There are three cases when a selection would start and end on the same |
| 4640 // character: | 4626 // character: |
| 4641 // 1. Anchor and focus are both in a subtree that is to the right of this | 4627 // 1. Anchor and focus are both in a subtree that is to the right of this |
| 4642 // object. | 4628 // object. |
| 4643 // 2. Anchor and focus are both in a subtree that is to the left of this | 4629 // 2. Anchor and focus are both in a subtree that is to the left of this |
| 4644 // object. | 4630 // object. |
| 4645 // 3. Anchor and focus are in a subtree represented by a single embedded | 4631 // 3. Anchor and focus are in a subtree represented by a single embedded |
| 4646 // object character. | 4632 // object character. |
| 4647 // Only case 3 refers to a valid selection because cases 1 and 2 fall | 4633 // Only case 3 refers to a valid selection because cases 1 and 2 fall |
| 4648 // outside this object in their entirety. | 4634 // outside this object in their entirety. |
| 4649 // Selections that span more than one character are by definition inside this | 4635 // Selections that span more than one character are by definition inside this |
| 4650 // object, so checking them is not necessary. | 4636 // object, so checking them is not necessary. |
| 4651 if (*selection_start == *selection_end && !GetOwner()->HasCaret()) { | 4637 if (*selection_start == *selection_end && !owner()->HasCaret()) { |
| 4652 *selection_start = -1; | 4638 *selection_start = -1; |
| 4653 *selection_end = -1; | 4639 *selection_end = -1; |
| 4654 return; | 4640 return; |
| 4655 } | 4641 } |
| 4656 | 4642 |
| 4657 // The IA2 Spec says that if the largest of the two offsets falls on an | 4643 // The IA2 Spec says that if the largest of the two offsets falls on an |
| 4658 // embedded object character and if there is a selection in that embedded | 4644 // embedded object character and if there is a selection in that embedded |
| 4659 // object, it should be incremented by one so that it points after the | 4645 // object, it should be incremented by one so that it points after the |
| 4660 // embedded object character. | 4646 // embedded object character. |
| 4661 // This is a signal to AT software that the embedded object is also part of | 4647 // This is a signal to AT software that the embedded object is also part of |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4728 int* start, | 4714 int* start, |
| 4729 int* old_len, | 4715 int* old_len, |
| 4730 int* new_len) { | 4716 int* new_len) { |
| 4731 CHECK(old_win_attributes_); | 4717 CHECK(old_win_attributes_); |
| 4732 | 4718 |
| 4733 *start = 0; | 4719 *start = 0; |
| 4734 *old_len = 0; | 4720 *old_len = 0; |
| 4735 *new_len = 0; | 4721 *new_len = 0; |
| 4736 | 4722 |
| 4737 const base::string16& old_text = old_win_attributes_->hypertext; | 4723 const base::string16& old_text = old_win_attributes_->hypertext; |
| 4738 const base::string16& new_text = GetOwner()->GetText(); | 4724 const base::string16& new_text = owner()->GetText(); |
| 4739 | 4725 |
| 4740 size_t common_prefix = 0; | 4726 size_t common_prefix = 0; |
| 4741 while (common_prefix < old_text.size() && common_prefix < new_text.size() && | 4727 while (common_prefix < old_text.size() && common_prefix < new_text.size() && |
| 4742 IsSameHypertextCharacter(common_prefix, common_prefix)) { | 4728 IsSameHypertextCharacter(common_prefix, common_prefix)) { |
| 4743 ++common_prefix; | 4729 ++common_prefix; |
| 4744 } | 4730 } |
| 4745 | 4731 |
| 4746 size_t common_suffix = 0; | 4732 size_t common_suffix = 0; |
| 4747 while (common_prefix + common_suffix < old_text.size() && | 4733 while (common_prefix + common_suffix < old_text.size() && |
| 4748 common_prefix + common_suffix < new_text.size() && | 4734 common_prefix + common_suffix < new_text.size() && |
| 4749 IsSameHypertextCharacter(old_text.size() - common_suffix - 1, | 4735 IsSameHypertextCharacter(old_text.size() - common_suffix - 1, |
| 4750 new_text.size() - common_suffix - 1)) { | 4736 new_text.size() - common_suffix - 1)) { |
| 4751 ++common_suffix; | 4737 ++common_suffix; |
| 4752 } | 4738 } |
| 4753 | 4739 |
| 4754 *start = common_prefix; | 4740 *start = common_prefix; |
| 4755 *old_len = old_text.size() - common_prefix - common_suffix; | 4741 *old_len = old_text.size() - common_prefix - common_suffix; |
| 4756 *new_len = new_text.size() - common_prefix - common_suffix; | 4742 *new_len = new_text.size() - common_prefix - common_suffix; |
| 4757 } | 4743 } |
| 4758 | 4744 |
| 4759 void BrowserAccessibilityComWin::HandleSpecialTextOffset(LONG* offset) { | 4745 void BrowserAccessibilityComWin::HandleSpecialTextOffset(LONG* offset) { |
| 4760 if (*offset == IA2_TEXT_OFFSET_LENGTH) { | 4746 if (*offset == IA2_TEXT_OFFSET_LENGTH) { |
| 4761 *offset = static_cast<LONG>(GetOwner()->GetText().length()); | 4747 *offset = static_cast<LONG>(owner()->GetText().length()); |
| 4762 } else if (*offset == IA2_TEXT_OFFSET_CARET) { | 4748 } else if (*offset == IA2_TEXT_OFFSET_CARET) { |
| 4763 // We shouldn't call |get_caretOffset| here as it affects UMA counts. | 4749 // We shouldn't call |get_caretOffset| here as it affects UMA counts. |
| 4764 int selection_start, selection_end; | 4750 int selection_start, selection_end; |
| 4765 GetSelectionOffsets(&selection_start, &selection_end); | 4751 GetSelectionOffsets(&selection_start, &selection_end); |
| 4766 *offset = selection_end; | 4752 *offset = selection_end; |
| 4767 } | 4753 } |
| 4768 } | 4754 } |
| 4769 | 4755 |
| 4770 ui::TextBoundaryType BrowserAccessibilityComWin::IA2TextBoundaryToTextBoundary( | 4756 ui::TextBoundaryType BrowserAccessibilityComWin::IA2TextBoundaryToTextBoundary( |
| 4771 IA2TextBoundaryType ia2_boundary) { | 4757 IA2TextBoundaryType ia2_boundary) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4796 // affinity, otherwise default to downstream affinity. | 4782 // affinity, otherwise default to downstream affinity. |
| 4797 ui::AXTextAffinity affinity = | 4783 ui::AXTextAffinity affinity = |
| 4798 start_offset == IA2_TEXT_OFFSET_CARET | 4784 start_offset == IA2_TEXT_OFFSET_CARET |
| 4799 ? Manager()->GetTreeData().sel_focus_affinity | 4785 ? Manager()->GetTreeData().sel_focus_affinity |
| 4800 : ui::AX_TEXT_AFFINITY_DOWNSTREAM; | 4786 : ui::AX_TEXT_AFFINITY_DOWNSTREAM; |
| 4801 | 4787 |
| 4802 HandleSpecialTextOffset(&start_offset); | 4788 HandleSpecialTextOffset(&start_offset); |
| 4803 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) { | 4789 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) { |
| 4804 switch (direction) { | 4790 switch (direction) { |
| 4805 case ui::FORWARDS_DIRECTION: { | 4791 case ui::FORWARDS_DIRECTION: { |
| 4806 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( | 4792 AXPlatformPositionInstance position = |
| 4807 static_cast<int>(start_offset), affinity); | 4793 owner()->CreatePositionAt(static_cast<int>(start_offset), affinity); |
| 4808 AXPlatformPositionInstance next_word = | 4794 AXPlatformPositionInstance next_word = |
| 4809 position->CreateNextWordStartPosition(); | 4795 position->CreateNextWordStartPosition(); |
| 4810 if (next_word->anchor_id() != GetOwner()->GetId()) | 4796 if (next_word->anchor_id() != owner()->GetId()) |
| 4811 next_word = position->CreatePositionAtEndOfAnchor(); | 4797 next_word = position->CreatePositionAtEndOfAnchor(); |
| 4812 return next_word->text_offset(); | 4798 return next_word->text_offset(); |
| 4813 } | 4799 } |
| 4814 case ui::BACKWARDS_DIRECTION: { | 4800 case ui::BACKWARDS_DIRECTION: { |
| 4815 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( | 4801 AXPlatformPositionInstance position = |
| 4816 static_cast<int>(start_offset), affinity); | 4802 owner()->CreatePositionAt(static_cast<int>(start_offset), affinity); |
| 4817 AXPlatformPositionInstance previous_word; | 4803 AXPlatformPositionInstance previous_word; |
| 4818 if (!position->AtStartOfWord()) { | 4804 if (!position->AtStartOfWord()) { |
| 4819 previous_word = position->CreatePreviousWordStartPosition(); | 4805 previous_word = position->CreatePreviousWordStartPosition(); |
| 4820 if (previous_word->anchor_id() != GetOwner()->GetId()) | 4806 if (previous_word->anchor_id() != owner()->GetId()) |
| 4821 previous_word = position->CreatePositionAtStartOfAnchor(); | 4807 previous_word = position->CreatePositionAtStartOfAnchor(); |
| 4822 } else { | 4808 } else { |
| 4823 previous_word = std::move(position); | 4809 previous_word = std::move(position); |
| 4824 } | 4810 } |
| 4825 return previous_word->text_offset(); | 4811 return previous_word->text_offset(); |
| 4826 } | 4812 } |
| 4827 } | 4813 } |
| 4828 } | 4814 } |
| 4829 | 4815 |
| 4830 if (ia2_boundary == IA2_TEXT_BOUNDARY_LINE) { | 4816 if (ia2_boundary == IA2_TEXT_BOUNDARY_LINE) { |
| 4831 switch (direction) { | 4817 switch (direction) { |
| 4832 case ui::FORWARDS_DIRECTION: { | 4818 case ui::FORWARDS_DIRECTION: { |
| 4833 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( | 4819 AXPlatformPositionInstance position = |
| 4834 static_cast<int>(start_offset), affinity); | 4820 owner()->CreatePositionAt(static_cast<int>(start_offset), affinity); |
| 4835 AXPlatformPositionInstance next_line = | 4821 AXPlatformPositionInstance next_line = |
| 4836 position->CreateNextLineStartPosition(); | 4822 position->CreateNextLineStartPosition(); |
| 4837 if (next_line->anchor_id() != GetOwner()->GetId()) | 4823 if (next_line->anchor_id() != owner()->GetId()) |
| 4838 next_line = position->CreatePositionAtEndOfAnchor(); | 4824 next_line = position->CreatePositionAtEndOfAnchor(); |
| 4839 return next_line->text_offset(); | 4825 return next_line->text_offset(); |
| 4840 } | 4826 } |
| 4841 case ui::BACKWARDS_DIRECTION: { | 4827 case ui::BACKWARDS_DIRECTION: { |
| 4842 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( | 4828 AXPlatformPositionInstance position = |
| 4843 static_cast<int>(start_offset), affinity); | 4829 owner()->CreatePositionAt(static_cast<int>(start_offset), affinity); |
| 4844 AXPlatformPositionInstance previous_line; | 4830 AXPlatformPositionInstance previous_line; |
| 4845 if (!position->AtStartOfLine()) { | 4831 if (!position->AtStartOfLine()) { |
| 4846 previous_line = position->CreatePreviousLineStartPosition(); | 4832 previous_line = position->CreatePreviousLineStartPosition(); |
| 4847 if (previous_line->anchor_id() != GetOwner()->GetId()) | 4833 if (previous_line->anchor_id() != owner()->GetId()) |
| 4848 previous_line = position->CreatePositionAtStartOfAnchor(); | 4834 previous_line = position->CreatePositionAtStartOfAnchor(); |
| 4849 } else { | 4835 } else { |
| 4850 previous_line = std::move(position); | 4836 previous_line = std::move(position); |
| 4851 } | 4837 } |
| 4852 return previous_line->text_offset(); | 4838 return previous_line->text_offset(); |
| 4853 } | 4839 } |
| 4854 } | 4840 } |
| 4855 } | 4841 } |
| 4856 | 4842 |
| 4857 // TODO(nektar): |AXPosition| can handle other types of boundaries as well. | 4843 // TODO(nektar): |AXPosition| can handle other types of boundaries as well. |
| 4858 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 4844 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| 4859 return ui::FindAccessibleTextBoundary(text, GetOwner()->GetLineStartOffsets(), | 4845 return ui::FindAccessibleTextBoundary(text, owner()->GetLineStartOffsets(), |
| 4860 boundary, start_offset, direction, | 4846 boundary, start_offset, direction, |
| 4861 affinity); | 4847 affinity); |
| 4862 } | 4848 } |
| 4863 | 4849 |
| 4864 LONG BrowserAccessibilityComWin::FindStartOfStyle( | 4850 LONG BrowserAccessibilityComWin::FindStartOfStyle( |
| 4865 LONG start_offset, | 4851 LONG start_offset, |
| 4866 ui::TextBoundaryDirection direction) const { | 4852 ui::TextBoundaryDirection direction) const { |
| 4867 LONG text_length = static_cast<LONG>(GetOwner()->GetText().length()); | 4853 LONG text_length = static_cast<LONG>(owner()->GetText().length()); |
| 4868 DCHECK_GE(start_offset, 0); | 4854 DCHECK_GE(start_offset, 0); |
| 4869 DCHECK_LE(start_offset, text_length); | 4855 DCHECK_LE(start_offset, text_length); |
| 4870 | 4856 |
| 4871 switch (direction) { | 4857 switch (direction) { |
| 4872 case ui::BACKWARDS_DIRECTION: { | 4858 case ui::BACKWARDS_DIRECTION: { |
| 4873 if (offset_to_text_attributes().empty()) | 4859 if (offset_to_text_attributes().empty()) |
| 4874 return 0; | 4860 return 0; |
| 4875 | 4861 |
| 4876 auto iterator = offset_to_text_attributes().upper_bound(start_offset); | 4862 auto iterator = offset_to_text_attributes().upper_bound(start_offset); |
| 4877 --iterator; | 4863 --iterator; |
| 4878 return static_cast<LONG>(iterator->first); | 4864 return static_cast<LONG>(iterator->first); |
| 4879 } | 4865 } |
| 4880 case ui::FORWARDS_DIRECTION: { | 4866 case ui::FORWARDS_DIRECTION: { |
| 4881 const auto iterator = | 4867 const auto iterator = |
| 4882 offset_to_text_attributes().upper_bound(start_offset); | 4868 offset_to_text_attributes().upper_bound(start_offset); |
| 4883 if (iterator == offset_to_text_attributes().end()) | 4869 if (iterator == offset_to_text_attributes().end()) |
| 4884 return text_length; | 4870 return text_length; |
| 4885 return static_cast<LONG>(iterator->first); | 4871 return static_cast<LONG>(iterator->first); |
| 4886 } | 4872 } |
| 4887 } | 4873 } |
| 4888 | 4874 |
| 4889 NOTREACHED(); | 4875 NOTREACHED(); |
| 4890 return start_offset; | 4876 return start_offset; |
| 4891 } | 4877 } |
| 4892 | 4878 |
| 4893 BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetFromID( | 4879 BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetFromID( |
| 4894 int32_t id) const { | 4880 int32_t id) const { |
| 4895 if (!GetOwner()) | 4881 if (!owner()) |
| 4896 return nullptr; | 4882 return nullptr; |
| 4897 return ToBrowserAccessibilityComWin(Manager()->GetFromID(id)); | 4883 return ToBrowserAccessibilityComWin(Manager()->GetFromID(id)); |
| 4898 } | 4884 } |
| 4899 | 4885 |
| 4900 bool BrowserAccessibilityComWin::IsListBoxOptionOrMenuListOption() { | 4886 bool BrowserAccessibilityComWin::IsListBoxOptionOrMenuListOption() { |
| 4901 if (!GetOwner()->PlatformGetParent()) | 4887 if (!owner()->PlatformGetParent()) |
| 4902 return false; | 4888 return false; |
| 4903 | 4889 |
| 4904 int32_t role = GetOwner()->GetRole(); | 4890 int32_t role = owner()->GetRole(); |
| 4905 int32_t parent_role = GetOwner()->PlatformGetParent()->GetRole(); | 4891 int32_t parent_role = owner()->PlatformGetParent()->GetRole(); |
| 4906 | 4892 |
| 4907 if (role == ui::AX_ROLE_LIST_BOX_OPTION && | 4893 if (role == ui::AX_ROLE_LIST_BOX_OPTION && |
| 4908 parent_role == ui::AX_ROLE_LIST_BOX) { | 4894 parent_role == ui::AX_ROLE_LIST_BOX) { |
| 4909 return true; | 4895 return true; |
| 4910 } | 4896 } |
| 4911 | 4897 |
| 4912 if (role == ui::AX_ROLE_MENU_LIST_OPTION && | 4898 if (role == ui::AX_ROLE_MENU_LIST_OPTION && |
| 4913 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { | 4899 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { |
| 4914 return true; | 4900 return true; |
| 4915 } | 4901 } |
| 4916 | 4902 |
| 4917 return false; | 4903 return false; |
| 4918 } | 4904 } |
| 4919 | 4905 |
| 4920 void BrowserAccessibilityComWin::AddRelation( | 4906 void BrowserAccessibilityComWin::AddRelation( |
| 4921 const base::string16& relation_type, | 4907 const base::string16& relation_type, |
| 4922 int target_id) { | 4908 int target_id) { |
| 4923 // Reflexive relations don't need to be exposed through IA2. | 4909 // Reflexive relations don't need to be exposed through IA2. |
| 4924 if (target_id == GetOwner()->GetId()) | 4910 if (target_id == owner()->GetId()) |
| 4925 return; | 4911 return; |
| 4926 | 4912 |
| 4927 CComObject<BrowserAccessibilityRelation>* relation; | 4913 CComObject<BrowserAccessibilityRelation>* relation; |
| 4928 HRESULT hr = | 4914 HRESULT hr = |
| 4929 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); | 4915 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); |
| 4930 DCHECK(SUCCEEDED(hr)); | 4916 DCHECK(SUCCEEDED(hr)); |
| 4931 relation->AddRef(); | 4917 relation->AddRef(); |
| 4932 relation->Initialize(this, relation_type); | 4918 relation->Initialize(this, relation_type); |
| 4933 relation->AddTarget(target_id); | 4919 relation->AddTarget(target_id); |
| 4934 relations_.push_back(relation); | 4920 relations_.push_back(relation); |
| 4935 } | 4921 } |
| 4936 | 4922 |
| 4937 void BrowserAccessibilityComWin::AddBidirectionalRelations( | 4923 void BrowserAccessibilityComWin::AddBidirectionalRelations( |
| 4938 const base::string16& relation_type, | 4924 const base::string16& relation_type, |
| 4939 const base::string16& reverse_relation_type, | 4925 const base::string16& reverse_relation_type, |
| 4940 ui::AXIntListAttribute attribute) { | 4926 ui::AXIntListAttribute attribute) { |
| 4941 if (!GetOwner()->HasIntListAttribute(attribute)) | 4927 if (!owner()->HasIntListAttribute(attribute)) |
| 4942 return; | 4928 return; |
| 4943 | 4929 |
| 4944 const std::vector<int32_t>& target_ids = | 4930 const std::vector<int32_t>& target_ids = |
| 4945 GetOwner()->GetIntListAttribute(attribute); | 4931 owner()->GetIntListAttribute(attribute); |
| 4946 // Reflexive relations don't need to be exposed through IA2. | 4932 // Reflexive relations don't need to be exposed through IA2. |
| 4947 std::vector<int32_t> filtered_target_ids; | 4933 std::vector<int32_t> filtered_target_ids; |
| 4948 int32_t current_id = GetOwner()->GetId(); | 4934 int32_t current_id = owner()->GetId(); |
| 4949 std::copy_if(target_ids.begin(), target_ids.end(), | 4935 std::copy_if(target_ids.begin(), target_ids.end(), |
| 4950 std::back_inserter(filtered_target_ids), | 4936 std::back_inserter(filtered_target_ids), |
| 4951 [current_id](int32_t id) { return id != current_id; }); | 4937 [current_id](int32_t id) { return id != current_id; }); |
| 4952 if (filtered_target_ids.empty()) | 4938 if (filtered_target_ids.empty()) |
| 4953 return; | 4939 return; |
| 4954 | 4940 |
| 4955 CComObject<BrowserAccessibilityRelation>* relation; | 4941 CComObject<BrowserAccessibilityRelation>* relation; |
| 4956 HRESULT hr = | 4942 HRESULT hr = |
| 4957 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); | 4943 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); |
| 4958 DCHECK(SUCCEEDED(hr)); | 4944 DCHECK(SUCCEEDED(hr)); |
| 4959 relation->AddRef(); | 4945 relation->AddRef(); |
| 4960 relation->Initialize(this, relation_type); | 4946 relation->Initialize(this, relation_type); |
| 4961 | 4947 |
| 4962 for (int target_id : filtered_target_ids) { | 4948 for (int target_id : filtered_target_ids) { |
| 4963 BrowserAccessibilityComWin* target = | 4949 BrowserAccessibilityComWin* target = |
| 4964 GetFromID(static_cast<int32_t>(target_id)); | 4950 GetFromID(static_cast<int32_t>(target_id)); |
| 4965 if (!target || !target->GetOwner()) | 4951 if (!target || !target->owner()) |
| 4966 continue; | 4952 continue; |
| 4967 relation->AddTarget(target_id); | 4953 relation->AddTarget(target_id); |
| 4968 target->AddRelation(reverse_relation_type, GetOwner()->GetId()); | 4954 target->AddRelation(reverse_relation_type, owner()->GetId()); |
| 4969 } | 4955 } |
| 4970 | 4956 |
| 4971 relations_.push_back(relation); | 4957 relations_.push_back(relation); |
| 4972 } | 4958 } |
| 4973 | 4959 |
| 4974 // Clears all the forward relations from this object to any other object and the | 4960 // Clears all the forward relations from this object to any other object and the |
| 4975 // associated reverse relations on the other objects, but leaves any reverse | 4961 // associated reverse relations on the other objects, but leaves any reverse |
| 4976 // relations on this object alone. | 4962 // relations on this object alone. |
| 4977 void BrowserAccessibilityComWin::ClearOwnRelations() { | 4963 void BrowserAccessibilityComWin::ClearOwnRelations() { |
| 4978 RemoveBidirectionalRelationsOfType(IA2_RELATION_CONTROLLER_FOR, | 4964 RemoveBidirectionalRelationsOfType(IA2_RELATION_CONTROLLER_FOR, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4999 void BrowserAccessibilityComWin::RemoveBidirectionalRelationsOfType( | 4985 void BrowserAccessibilityComWin::RemoveBidirectionalRelationsOfType( |
| 5000 const base::string16& relation_type, | 4986 const base::string16& relation_type, |
| 5001 const base::string16& reverse_relation_type) { | 4987 const base::string16& reverse_relation_type) { |
| 5002 for (auto iter = relations_.begin(); iter != relations_.end();) { | 4988 for (auto iter = relations_.begin(); iter != relations_.end();) { |
| 5003 BrowserAccessibilityRelation* relation = *iter; | 4989 BrowserAccessibilityRelation* relation = *iter; |
| 5004 DCHECK(relation); | 4990 DCHECK(relation); |
| 5005 if (relation->get_type() == relation_type) { | 4991 if (relation->get_type() == relation_type) { |
| 5006 for (int target_id : relation->get_target_ids()) { | 4992 for (int target_id : relation->get_target_ids()) { |
| 5007 BrowserAccessibilityComWin* target = | 4993 BrowserAccessibilityComWin* target = |
| 5008 GetFromID(static_cast<int32_t>(target_id)); | 4994 GetFromID(static_cast<int32_t>(target_id)); |
| 5009 if (!target || !target->GetOwner()) | 4995 if (!target || !target->owner()) |
| 5010 continue; | 4996 continue; |
| 5011 DCHECK_NE(target, this); | 4997 DCHECK_NE(target, this); |
| 5012 target->RemoveTargetFromRelation(reverse_relation_type, | 4998 target->RemoveTargetFromRelation(reverse_relation_type, |
| 5013 GetOwner()->GetId()); | 4999 owner()->GetId()); |
| 5014 } | 5000 } |
| 5015 iter = relations_.erase(iter); | 5001 iter = relations_.erase(iter); |
| 5016 relation->Release(); | 5002 relation->Release(); |
| 5017 } else { | 5003 } else { |
| 5018 ++iter; | 5004 ++iter; |
| 5019 } | 5005 } |
| 5020 } | 5006 } |
| 5021 } | 5007 } |
| 5022 | 5008 |
| 5023 void BrowserAccessibilityComWin::RemoveTargetFromRelation( | 5009 void BrowserAccessibilityComWin::RemoveTargetFromRelation( |
| 5024 const base::string16& relation_type, | 5010 const base::string16& relation_type, |
| 5025 int target_id) { | 5011 int target_id) { |
| 5026 for (auto iter = relations_.begin(); iter != relations_.end();) { | 5012 for (auto iter = relations_.begin(); iter != relations_.end();) { |
| 5027 BrowserAccessibilityRelation* relation = *iter; | 5013 BrowserAccessibilityRelation* relation = *iter; |
| 5028 DCHECK(relation); | 5014 DCHECK(relation); |
| 5029 if (relation->get_type() == relation_type) { | 5015 if (relation->get_type() == relation_type) { |
| 5030 // If |target_id| is not present, |RemoveTarget| will do nothing. | 5016 // If |target_id| is not present, |RemoveTarget| will do nothing. |
| 5031 relation->RemoveTarget(target_id); | 5017 relation->RemoveTarget(target_id); |
| 5032 } | 5018 } |
| 5033 if (relation->get_target_ids().empty()) { | 5019 if (relation->get_target_ids().empty()) { |
| 5034 iter = relations_.erase(iter); | 5020 iter = relations_.erase(iter); |
| 5035 relation->Release(); | 5021 relation->Release(); |
| 5036 } else { | 5022 } else { |
| 5037 ++iter; | 5023 ++iter; |
| 5038 } | 5024 } |
| 5039 } | 5025 } |
| 5040 } | 5026 } |
| 5041 | 5027 |
| 5042 void BrowserAccessibilityComWin::UpdateRequiredAttributes() { | 5028 void BrowserAccessibilityComWin::UpdateRequiredAttributes() { |
| 5043 if (GetOwner()->IsCellOrTableHeaderRole()) { | 5029 if (owner()->IsCellOrTableHeaderRole()) { |
| 5044 // Expose colspan attribute. | 5030 // Expose colspan attribute. |
| 5045 base::string16 colspan; | 5031 base::string16 colspan; |
| 5046 if (GetOwner()->GetHtmlAttribute("aria-colspan", &colspan)) { | 5032 if (owner()->GetHtmlAttribute("aria-colspan", &colspan)) { |
| 5047 SanitizeStringAttributeForIA2(colspan, &colspan); | 5033 SanitizeStringAttributeForIA2(colspan, &colspan); |
| 5048 win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); | 5034 win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); |
| 5049 } | 5035 } |
| 5050 // Expose rowspan attribute. | 5036 // Expose rowspan attribute. |
| 5051 base::string16 rowspan; | 5037 base::string16 rowspan; |
| 5052 if (GetOwner()->GetHtmlAttribute("aria-rowspan", &rowspan)) { | 5038 if (owner()->GetHtmlAttribute("aria-rowspan", &rowspan)) { |
| 5053 SanitizeStringAttributeForIA2(rowspan, &rowspan); | 5039 SanitizeStringAttributeForIA2(rowspan, &rowspan); |
| 5054 win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan); | 5040 win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan); |
| 5055 } | 5041 } |
| 5056 } | 5042 } |
| 5057 | 5043 |
| 5058 // Expose dropeffect attribute. | 5044 // Expose dropeffect attribute. |
| 5059 base::string16 drop_effect; | 5045 base::string16 drop_effect; |
| 5060 if (GetOwner()->GetHtmlAttribute("aria-dropeffect", &drop_effect)) { | 5046 if (owner()->GetHtmlAttribute("aria-dropeffect", &drop_effect)) { |
| 5061 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); | 5047 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); |
| 5062 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); | 5048 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); |
| 5063 } | 5049 } |
| 5064 | 5050 |
| 5065 // Expose grabbed attribute. | 5051 // Expose grabbed attribute. |
| 5066 base::string16 grabbed; | 5052 base::string16 grabbed; |
| 5067 if (GetOwner()->GetHtmlAttribute("aria-grabbed", &grabbed)) { | 5053 if (owner()->GetHtmlAttribute("aria-grabbed", &grabbed)) { |
| 5068 SanitizeStringAttributeForIA2(grabbed, &grabbed); | 5054 SanitizeStringAttributeForIA2(grabbed, &grabbed); |
| 5069 win_attributes_->ia2_attributes.push_back(L"grabbed:" + grabbed); | 5055 win_attributes_->ia2_attributes.push_back(L"grabbed:" + grabbed); |
| 5070 } | 5056 } |
| 5071 | 5057 |
| 5072 // Expose class attribute. | 5058 // Expose class attribute. |
| 5073 base::string16 class_attr; | 5059 base::string16 class_attr; |
| 5074 if (GetOwner()->GetHtmlAttribute("class", &class_attr)) { | 5060 if (owner()->GetHtmlAttribute("class", &class_attr)) { |
| 5075 SanitizeStringAttributeForIA2(class_attr, &class_attr); | 5061 SanitizeStringAttributeForIA2(class_attr, &class_attr); |
| 5076 win_attributes_->ia2_attributes.push_back(L"class:" + class_attr); | 5062 win_attributes_->ia2_attributes.push_back(L"class:" + class_attr); |
| 5077 } | 5063 } |
| 5078 | 5064 |
| 5079 // Expose datetime attribute. | 5065 // Expose datetime attribute. |
| 5080 base::string16 datetime; | 5066 base::string16 datetime; |
| 5081 if (GetOwner()->GetRole() == ui::AX_ROLE_TIME && | 5067 if (owner()->GetRole() == ui::AX_ROLE_TIME && |
| 5082 GetOwner()->GetHtmlAttribute("datetime", &datetime)) { | 5068 owner()->GetHtmlAttribute("datetime", &datetime)) { |
| 5083 SanitizeStringAttributeForIA2(datetime, &datetime); | 5069 SanitizeStringAttributeForIA2(datetime, &datetime); |
| 5084 win_attributes_->ia2_attributes.push_back(L"datetime:" + datetime); | 5070 win_attributes_->ia2_attributes.push_back(L"datetime:" + datetime); |
| 5085 } | 5071 } |
| 5086 | 5072 |
| 5087 // Expose id attribute. | 5073 // Expose id attribute. |
| 5088 base::string16 id; | 5074 base::string16 id; |
| 5089 if (GetOwner()->GetHtmlAttribute("id", &id)) { | 5075 if (owner()->GetHtmlAttribute("id", &id)) { |
| 5090 SanitizeStringAttributeForIA2(id, &id); | 5076 SanitizeStringAttributeForIA2(id, &id); |
| 5091 win_attributes_->ia2_attributes.push_back(L"id:" + id); | 5077 win_attributes_->ia2_attributes.push_back(L"id:" + id); |
| 5092 } | 5078 } |
| 5093 | 5079 |
| 5094 // Expose src attribute. | 5080 // Expose src attribute. |
| 5095 base::string16 src; | 5081 base::string16 src; |
| 5096 if (GetOwner()->GetRole() == ui::AX_ROLE_IMAGE && | 5082 if (owner()->GetRole() == ui::AX_ROLE_IMAGE && |
| 5097 GetOwner()->GetHtmlAttribute("src", &src)) { | 5083 owner()->GetHtmlAttribute("src", &src)) { |
| 5098 SanitizeStringAttributeForIA2(src, &src); | 5084 SanitizeStringAttributeForIA2(src, &src); |
| 5099 win_attributes_->ia2_attributes.push_back(L"src:" + src); | 5085 win_attributes_->ia2_attributes.push_back(L"src:" + src); |
| 5100 } | 5086 } |
| 5101 | 5087 |
| 5102 // Expose input-text type attribute. | 5088 // Expose input-text type attribute. |
| 5103 base::string16 type; | 5089 base::string16 type; |
| 5104 base::string16 html_tag = | 5090 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| 5105 GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); | 5091 if (owner()->IsSimpleTextControl() && html_tag == L"input" && |
| 5106 if (GetOwner()->IsSimpleTextControl() && html_tag == L"input" && | 5092 owner()->GetHtmlAttribute("type", &type)) { |
| 5107 GetOwner()->GetHtmlAttribute("type", &type)) { | |
| 5108 SanitizeStringAttributeForIA2(type, &type); | 5093 SanitizeStringAttributeForIA2(type, &type); |
| 5109 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); | 5094 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); |
| 5110 } | 5095 } |
| 5111 } | 5096 } |
| 5112 | 5097 |
| 5113 void BrowserAccessibilityComWin::FireNativeEvent(LONG win_event_type) const { | 5098 void BrowserAccessibilityComWin::FireNativeEvent(LONG win_event_type) const { |
| 5114 (new BrowserAccessibilityEventWin(BrowserAccessibilityEvent::FromTreeChange, | 5099 (new BrowserAccessibilityEventWin(BrowserAccessibilityEvent::FromTreeChange, |
| 5115 ui::AX_EVENT_NONE, win_event_type, | 5100 ui::AX_EVENT_NONE, win_event_type, owner())) |
| 5116 GetOwner())) | |
| 5117 ->Fire(); | 5101 ->Fire(); |
| 5118 } | 5102 } |
| 5119 | 5103 |
| 5120 void BrowserAccessibilityComWin::InitRoleAndState() { | 5104 void BrowserAccessibilityComWin::InitRoleAndState() { |
| 5121 int32_t ia_role = 0; | 5105 int32_t ia_role = 0; |
| 5122 int32_t ia_state = 0; | 5106 int32_t ia_state = 0; |
| 5123 base::string16 role_name; | 5107 base::string16 role_name; |
| 5124 int32_t ia2_role = 0; | 5108 int32_t ia2_role = 0; |
| 5125 int32_t ia2_state = IA2_STATE_OPAQUE; | 5109 int32_t ia2_state = IA2_STATE_OPAQUE; |
| 5126 | 5110 |
| 5127 if (GetOwner()->HasState(ui::AX_STATE_BUSY)) | 5111 if (owner()->HasState(ui::AX_STATE_BUSY)) |
| 5128 ia_state |= STATE_SYSTEM_BUSY; | 5112 ia_state |= STATE_SYSTEM_BUSY; |
| 5129 | 5113 |
| 5130 const auto checked_state = static_cast<ui::AXCheckedState>( | 5114 const auto checked_state = static_cast<ui::AXCheckedState>( |
| 5131 GetOwner()->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); | 5115 owner()->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); |
| 5132 switch (checked_state) { | 5116 switch (checked_state) { |
| 5133 case ui::AX_CHECKED_STATE_TRUE: | 5117 case ui::AX_CHECKED_STATE_TRUE: |
| 5134 ia_state |= STATE_SYSTEM_CHECKED; | 5118 ia_state |= STATE_SYSTEM_CHECKED; |
| 5135 break; | 5119 break; |
| 5136 case ui::AX_CHECKED_STATE_MIXED: | 5120 case ui::AX_CHECKED_STATE_MIXED: |
| 5137 ia_state |= STATE_SYSTEM_MIXED; | 5121 ia_state |= STATE_SYSTEM_MIXED; |
| 5138 break; | 5122 break; |
| 5139 default: | 5123 default: |
| 5140 break; | 5124 break; |
| 5141 } | 5125 } |
| 5142 | 5126 |
| 5143 if (GetOwner()->HasState(ui::AX_STATE_COLLAPSED)) | 5127 if (owner()->HasState(ui::AX_STATE_COLLAPSED)) |
| 5144 ia_state |= STATE_SYSTEM_COLLAPSED; | 5128 ia_state |= STATE_SYSTEM_COLLAPSED; |
| 5145 if (GetOwner()->HasState(ui::AX_STATE_EXPANDED)) | 5129 if (owner()->HasState(ui::AX_STATE_EXPANDED)) |
| 5146 ia_state |= STATE_SYSTEM_EXPANDED; | 5130 ia_state |= STATE_SYSTEM_EXPANDED; |
| 5147 if (GetOwner()->HasState(ui::AX_STATE_FOCUSABLE)) | 5131 if (owner()->HasState(ui::AX_STATE_FOCUSABLE)) |
| 5148 ia_state |= STATE_SYSTEM_FOCUSABLE; | 5132 ia_state |= STATE_SYSTEM_FOCUSABLE; |
| 5149 if (GetOwner()->HasState(ui::AX_STATE_HASPOPUP)) | 5133 if (owner()->HasState(ui::AX_STATE_HASPOPUP)) |
| 5150 ia_state |= STATE_SYSTEM_HASPOPUP; | 5134 ia_state |= STATE_SYSTEM_HASPOPUP; |
| 5151 if (GetOwner()->HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && | 5135 if (owner()->HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && |
| 5152 GetOwner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != | 5136 owner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != |
| 5153 ui::AX_INVALID_STATE_FALSE) | 5137 ui::AX_INVALID_STATE_FALSE) |
| 5154 ia2_state |= IA2_STATE_INVALID_ENTRY; | 5138 ia2_state |= IA2_STATE_INVALID_ENTRY; |
| 5155 if (GetOwner()->HasState(ui::AX_STATE_INVISIBLE)) | 5139 if (owner()->HasState(ui::AX_STATE_INVISIBLE)) |
| 5156 ia_state |= STATE_SYSTEM_INVISIBLE; | 5140 ia_state |= STATE_SYSTEM_INVISIBLE; |
| 5157 if (GetOwner()->HasState(ui::AX_STATE_LINKED)) | 5141 if (owner()->HasState(ui::AX_STATE_LINKED)) |
| 5158 ia_state |= STATE_SYSTEM_LINKED; | 5142 ia_state |= STATE_SYSTEM_LINKED; |
| 5159 if (GetOwner()->HasState(ui::AX_STATE_MULTISELECTABLE)) { | 5143 if (owner()->HasState(ui::AX_STATE_MULTISELECTABLE)) { |
| 5160 ia_state |= STATE_SYSTEM_EXTSELECTABLE; | 5144 ia_state |= STATE_SYSTEM_EXTSELECTABLE; |
| 5161 ia_state |= STATE_SYSTEM_MULTISELECTABLE; | 5145 ia_state |= STATE_SYSTEM_MULTISELECTABLE; |
| 5162 } | 5146 } |
| 5163 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. | 5147 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
| 5164 if (GetOwner()->HasState(ui::AX_STATE_OFFSCREEN)) | 5148 if (owner()->HasState(ui::AX_STATE_OFFSCREEN)) |
| 5165 ia_state |= STATE_SYSTEM_OFFSCREEN; | 5149 ia_state |= STATE_SYSTEM_OFFSCREEN; |
| 5166 if (GetOwner()->HasState(ui::AX_STATE_PRESSED)) | 5150 if (owner()->HasState(ui::AX_STATE_PRESSED)) |
| 5167 ia_state |= STATE_SYSTEM_PRESSED; | 5151 ia_state |= STATE_SYSTEM_PRESSED; |
| 5168 if (GetOwner()->HasState(ui::AX_STATE_PROTECTED)) | 5152 if (owner()->HasState(ui::AX_STATE_PROTECTED)) |
| 5169 ia_state |= STATE_SYSTEM_PROTECTED; | 5153 ia_state |= STATE_SYSTEM_PROTECTED; |
| 5170 if (GetOwner()->HasState(ui::AX_STATE_REQUIRED)) | 5154 if (owner()->HasState(ui::AX_STATE_REQUIRED)) |
| 5171 ia2_state |= IA2_STATE_REQUIRED; | 5155 ia2_state |= IA2_STATE_REQUIRED; |
| 5172 if (GetOwner()->HasState(ui::AX_STATE_SELECTABLE)) | 5156 if (owner()->HasState(ui::AX_STATE_SELECTABLE)) |
| 5173 ia_state |= STATE_SYSTEM_SELECTABLE; | 5157 ia_state |= STATE_SYSTEM_SELECTABLE; |
| 5174 if (GetOwner()->HasState(ui::AX_STATE_SELECTED)) | 5158 if (owner()->HasState(ui::AX_STATE_SELECTED)) |
| 5175 ia_state |= STATE_SYSTEM_SELECTED; | 5159 ia_state |= STATE_SYSTEM_SELECTED; |
| 5176 if (GetOwner()->HasState(ui::AX_STATE_VISITED)) | 5160 if (owner()->HasState(ui::AX_STATE_VISITED)) |
| 5177 ia_state |= STATE_SYSTEM_TRAVERSED; | 5161 ia_state |= STATE_SYSTEM_TRAVERSED; |
| 5178 if (GetOwner()->HasState(ui::AX_STATE_DISABLED)) | 5162 if (owner()->HasState(ui::AX_STATE_DISABLED)) |
| 5179 ia_state |= STATE_SYSTEM_UNAVAILABLE; | 5163 ia_state |= STATE_SYSTEM_UNAVAILABLE; |
| 5180 if (GetOwner()->HasState(ui::AX_STATE_VERTICAL)) | 5164 if (owner()->HasState(ui::AX_STATE_VERTICAL)) |
| 5181 ia2_state |= IA2_STATE_VERTICAL; | 5165 ia2_state |= IA2_STATE_VERTICAL; |
| 5182 if (GetOwner()->HasState(ui::AX_STATE_HORIZONTAL)) | 5166 if (owner()->HasState(ui::AX_STATE_HORIZONTAL)) |
| 5183 ia2_state |= IA2_STATE_HORIZONTAL; | 5167 ia2_state |= IA2_STATE_HORIZONTAL; |
| 5184 if (GetOwner()->HasState(ui::AX_STATE_VISITED)) | 5168 if (owner()->HasState(ui::AX_STATE_VISITED)) |
| 5185 ia_state |= STATE_SYSTEM_TRAVERSED; | 5169 ia_state |= STATE_SYSTEM_TRAVERSED; |
| 5186 | 5170 |
| 5187 // Expose whether or not the mouse is over an element, but suppress | 5171 // Expose whether or not the mouse is over an element, but suppress |
| 5188 // this for tests because it can make the test results flaky depending | 5172 // this for tests because it can make the test results flaky depending |
| 5189 // on the position of the mouse. | 5173 // on the position of the mouse. |
| 5190 BrowserAccessibilityStateImpl* accessibility_state = | 5174 BrowserAccessibilityStateImpl* accessibility_state = |
| 5191 BrowserAccessibilityStateImpl::GetInstance(); | 5175 BrowserAccessibilityStateImpl::GetInstance(); |
| 5192 if (!accessibility_state->disable_hot_tracking_for_testing()) { | 5176 if (!accessibility_state->disable_hot_tracking_for_testing()) { |
| 5193 if (GetOwner()->HasState(ui::AX_STATE_HOVERED)) | 5177 if (owner()->HasState(ui::AX_STATE_HOVERED)) |
| 5194 ia_state |= STATE_SYSTEM_HOTTRACKED; | 5178 ia_state |= STATE_SYSTEM_HOTTRACKED; |
| 5195 } | 5179 } |
| 5196 | 5180 |
| 5197 if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) | 5181 if (owner()->HasState(ui::AX_STATE_EDITABLE)) |
| 5198 ia2_state |= IA2_STATE_EDITABLE; | 5182 ia2_state |= IA2_STATE_EDITABLE; |
| 5199 | 5183 |
| 5200 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) | 5184 if (owner()->GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) |
| 5201 ia2_state |= IA2_STATE_EDITABLE; | 5185 ia2_state |= IA2_STATE_EDITABLE; |
| 5202 | 5186 |
| 5203 if (!GetOwner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) | 5187 if (!owner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
| 5204 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; | 5188 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; |
| 5205 | 5189 |
| 5206 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) | 5190 if (owner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) |
| 5207 ia2_state |= IA2_STATE_MODAL; | 5191 ia2_state |= IA2_STATE_MODAL; |
| 5208 | 5192 |
| 5209 base::string16 html_tag = | 5193 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| 5210 GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); | 5194 switch (owner()->GetRole()) { |
| 5211 switch (GetOwner()->GetRole()) { | |
| 5212 case ui::AX_ROLE_ALERT: | 5195 case ui::AX_ROLE_ALERT: |
| 5213 ia_role = ROLE_SYSTEM_ALERT; | 5196 ia_role = ROLE_SYSTEM_ALERT; |
| 5214 break; | 5197 break; |
| 5215 case ui::AX_ROLE_ALERT_DIALOG: | 5198 case ui::AX_ROLE_ALERT_DIALOG: |
| 5216 ia_role = ROLE_SYSTEM_DIALOG; | 5199 ia_role = ROLE_SYSTEM_DIALOG; |
| 5217 break; | 5200 break; |
| 5218 case ui::AX_ROLE_ANCHOR: | 5201 case ui::AX_ROLE_ANCHOR: |
| 5219 ia_role = ROLE_SYSTEM_LINK; | 5202 ia_role = ROLE_SYSTEM_LINK; |
| 5220 break; | 5203 break; |
| 5221 case ui::AX_ROLE_APPLICATION: | 5204 case ui::AX_ROLE_APPLICATION: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5237 ia2_role = IA2_ROLE_SECTION; | 5220 ia2_role = IA2_ROLE_SECTION; |
| 5238 break; | 5221 break; |
| 5239 case ui::AX_ROLE_BUSY_INDICATOR: | 5222 case ui::AX_ROLE_BUSY_INDICATOR: |
| 5240 ia_role = ROLE_SYSTEM_ANIMATION; | 5223 ia_role = ROLE_SYSTEM_ANIMATION; |
| 5241 ia_state |= STATE_SYSTEM_READONLY; | 5224 ia_state |= STATE_SYSTEM_READONLY; |
| 5242 break; | 5225 break; |
| 5243 case ui::AX_ROLE_BUTTON: | 5226 case ui::AX_ROLE_BUTTON: |
| 5244 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5227 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| 5245 break; | 5228 break; |
| 5246 case ui::AX_ROLE_CANVAS: | 5229 case ui::AX_ROLE_CANVAS: |
| 5247 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { | 5230 if (owner()->GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
| 5248 role_name = L"canvas"; | 5231 role_name = L"canvas"; |
| 5249 ia2_role = IA2_ROLE_CANVAS; | 5232 ia2_role = IA2_ROLE_CANVAS; |
| 5250 } else { | 5233 } else { |
| 5251 ia_role = ROLE_SYSTEM_GRAPHIC; | 5234 ia_role = ROLE_SYSTEM_GRAPHIC; |
| 5252 } | 5235 } |
| 5253 break; | 5236 break; |
| 5254 case ui::AX_ROLE_CAPTION: | 5237 case ui::AX_ROLE_CAPTION: |
| 5255 ia_role = ROLE_SYSTEM_TEXT; | 5238 ia_role = ROLE_SYSTEM_TEXT; |
| 5256 ia2_role = IA2_ROLE_CAPTION; | 5239 ia2_role = IA2_ROLE_CAPTION; |
| 5257 break; | 5240 break; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5323 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5306 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| 5324 break; | 5307 break; |
| 5325 case ui::AX_ROLE_DOCUMENT: | 5308 case ui::AX_ROLE_DOCUMENT: |
| 5326 case ui::AX_ROLE_ROOT_WEB_AREA: | 5309 case ui::AX_ROLE_ROOT_WEB_AREA: |
| 5327 case ui::AX_ROLE_WEB_AREA: | 5310 case ui::AX_ROLE_WEB_AREA: |
| 5328 ia_role = ROLE_SYSTEM_DOCUMENT; | 5311 ia_role = ROLE_SYSTEM_DOCUMENT; |
| 5329 ia_state |= STATE_SYSTEM_READONLY; | 5312 ia_state |= STATE_SYSTEM_READONLY; |
| 5330 ia_state |= STATE_SYSTEM_FOCUSABLE; | 5313 ia_state |= STATE_SYSTEM_FOCUSABLE; |
| 5331 break; | 5314 break; |
| 5332 case ui::AX_ROLE_EMBEDDED_OBJECT: | 5315 case ui::AX_ROLE_EMBEDDED_OBJECT: |
| 5333 if (GetOwner()->PlatformChildCount()) { | 5316 if (owner()->PlatformChildCount()) { |
| 5334 // Windows screen readers assume that IA2_ROLE_EMBEDDED_OBJECT | 5317 // Windows screen readers assume that IA2_ROLE_EMBEDDED_OBJECT |
| 5335 // doesn't have any children, but it may be something like a | 5318 // doesn't have any children, but it may be something like a |
| 5336 // browser plugin that has a document inside. | 5319 // browser plugin that has a document inside. |
| 5337 ia_role = ROLE_SYSTEM_GROUPING; | 5320 ia_role = ROLE_SYSTEM_GROUPING; |
| 5338 } else { | 5321 } else { |
| 5339 ia_role = ROLE_SYSTEM_CLIENT; | 5322 ia_role = ROLE_SYSTEM_CLIENT; |
| 5340 ia2_role = IA2_ROLE_EMBEDDED_OBJECT; | 5323 ia2_role = IA2_ROLE_EMBEDDED_OBJECT; |
| 5341 } | 5324 } |
| 5342 break; | 5325 break; |
| 5343 case ui::AX_ROLE_FIGCAPTION: | 5326 case ui::AX_ROLE_FIGCAPTION: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5360 break; | 5343 break; |
| 5361 case ui::AX_ROLE_GRID: | 5344 case ui::AX_ROLE_GRID: |
| 5362 ia_role = ROLE_SYSTEM_TABLE; | 5345 ia_role = ROLE_SYSTEM_TABLE; |
| 5363 // TODO(aleventhal) this changed between ARIA 1.0 and 1.1, | 5346 // TODO(aleventhal) this changed between ARIA 1.0 and 1.1, |
| 5364 // need to determine whether grids/treegrids should really be readonly | 5347 // need to determine whether grids/treegrids should really be readonly |
| 5365 // or editable by default | 5348 // or editable by default |
| 5366 // ia_state |= STATE_SYSTEM_READONLY; | 5349 // ia_state |= STATE_SYSTEM_READONLY; |
| 5367 break; | 5350 break; |
| 5368 case ui::AX_ROLE_GROUP: { | 5351 case ui::AX_ROLE_GROUP: { |
| 5369 base::string16 aria_role = | 5352 base::string16 aria_role = |
| 5370 GetOwner()->GetString16Attribute(ui::AX_ATTR_ROLE); | 5353 owner()->GetString16Attribute(ui::AX_ATTR_ROLE); |
| 5371 if (aria_role == L"group" || html_tag == L"fieldset") { | 5354 if (aria_role == L"group" || html_tag == L"fieldset") { |
| 5372 ia_role = ROLE_SYSTEM_GROUPING; | 5355 ia_role = ROLE_SYSTEM_GROUPING; |
| 5373 } else if (html_tag == L"li") { | 5356 } else if (html_tag == L"li") { |
| 5374 ia_role = ROLE_SYSTEM_LISTITEM; | 5357 ia_role = ROLE_SYSTEM_LISTITEM; |
| 5375 ia_state |= STATE_SYSTEM_READONLY; | 5358 ia_state |= STATE_SYSTEM_READONLY; |
| 5376 } else { | 5359 } else { |
| 5377 if (html_tag.empty()) | 5360 if (html_tag.empty()) |
| 5378 role_name = L"div"; | 5361 role_name = L"div"; |
| 5379 else | 5362 else |
| 5380 role_name = html_tag; | 5363 role_name = html_tag; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5530 ia_role = ROLE_SYSTEM_GROUPING; | 5513 ia_role = ROLE_SYSTEM_GROUPING; |
| 5531 ia2_role = IA2_ROLE_SECTION; | 5514 ia2_role = IA2_ROLE_SECTION; |
| 5532 } else { | 5515 } else { |
| 5533 ia_role = ROLE_SYSTEM_PANE; | 5516 ia_role = ROLE_SYSTEM_PANE; |
| 5534 } | 5517 } |
| 5535 break; | 5518 break; |
| 5536 case ui::AX_ROLE_ROW: { | 5519 case ui::AX_ROLE_ROW: { |
| 5537 // Role changes depending on whether row is inside a treegrid | 5520 // Role changes depending on whether row is inside a treegrid |
| 5538 // https://www.w3.org/TR/core-aam-1.1/#role-map-row | 5521 // https://www.w3.org/TR/core-aam-1.1/#role-map-row |
| 5539 ia_role = | 5522 ia_role = |
| 5540 IsInTreeGrid(GetOwner()) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; | 5523 IsInTreeGrid(owner()) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; |
| 5541 break; | 5524 break; |
| 5542 } | 5525 } |
| 5543 case ui::AX_ROLE_ROW_HEADER: | 5526 case ui::AX_ROLE_ROW_HEADER: |
| 5544 ia_role = ROLE_SYSTEM_ROWHEADER; | 5527 ia_role = ROLE_SYSTEM_ROWHEADER; |
| 5545 break; | 5528 break; |
| 5546 case ui::AX_ROLE_RUBY: | 5529 case ui::AX_ROLE_RUBY: |
| 5547 ia_role = ROLE_SYSTEM_TEXT; | 5530 ia_role = ROLE_SYSTEM_TEXT; |
| 5548 ia2_role = IA2_ROLE_TEXT_FRAME; | 5531 ia2_role = IA2_ROLE_TEXT_FRAME; |
| 5549 break; | 5532 break; |
| 5550 case ui::AX_ROLE_RULER: | 5533 case ui::AX_ROLE_RULER: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5613 ia_role = ROLE_SYSTEM_LISTITEM; | 5596 ia_role = ROLE_SYSTEM_LISTITEM; |
| 5614 ia_state |= STATE_SYSTEM_READONLY; | 5597 ia_state |= STATE_SYSTEM_READONLY; |
| 5615 break; | 5598 break; |
| 5616 case ui::AX_ROLE_TOGGLE_BUTTON: | 5599 case ui::AX_ROLE_TOGGLE_BUTTON: |
| 5617 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5600 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| 5618 ia2_role = IA2_ROLE_TOGGLE_BUTTON; | 5601 ia2_role = IA2_ROLE_TOGGLE_BUTTON; |
| 5619 break; | 5602 break; |
| 5620 case ui::AX_ROLE_TEXT_FIELD: | 5603 case ui::AX_ROLE_TEXT_FIELD: |
| 5621 case ui::AX_ROLE_SEARCH_BOX: | 5604 case ui::AX_ROLE_SEARCH_BOX: |
| 5622 ia_role = ROLE_SYSTEM_TEXT; | 5605 ia_role = ROLE_SYSTEM_TEXT; |
| 5623 if (GetOwner()->HasState(ui::AX_STATE_MULTILINE)) { | 5606 if (owner()->HasState(ui::AX_STATE_MULTILINE)) { |
| 5624 ia2_state |= IA2_STATE_MULTI_LINE; | 5607 ia2_state |= IA2_STATE_MULTI_LINE; |
| 5625 } else { | 5608 } else { |
| 5626 ia2_state |= IA2_STATE_SINGLE_LINE; | 5609 ia2_state |= IA2_STATE_SINGLE_LINE; |
| 5627 } | 5610 } |
| 5628 if (GetOwner()->HasState(ui::AX_STATE_READ_ONLY)) | 5611 if (owner()->HasState(ui::AX_STATE_READ_ONLY)) |
| 5629 ia_state |= STATE_SYSTEM_READONLY; | 5612 ia_state |= STATE_SYSTEM_READONLY; |
| 5630 ia2_state |= IA2_STATE_SELECTABLE_TEXT; | 5613 ia2_state |= IA2_STATE_SELECTABLE_TEXT; |
| 5631 break; | 5614 break; |
| 5632 case ui::AX_ROLE_ABBR: | 5615 case ui::AX_ROLE_ABBR: |
| 5633 case ui::AX_ROLE_TIME: | 5616 case ui::AX_ROLE_TIME: |
| 5634 role_name = html_tag; | 5617 role_name = html_tag; |
| 5635 ia_role = ROLE_SYSTEM_TEXT; | 5618 ia_role = ROLE_SYSTEM_TEXT; |
| 5636 ia2_role = IA2_ROLE_TEXT_FRAME; | 5619 ia2_role = IA2_ROLE_TEXT_FRAME; |
| 5637 break; | 5620 break; |
| 5638 case ui::AX_ROLE_TIMER: | 5621 case ui::AX_ROLE_TIMER: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5677 ia_role = ROLE_SYSTEM_CLIENT; | 5660 ia_role = ROLE_SYSTEM_CLIENT; |
| 5678 break; | 5661 break; |
| 5679 } | 5662 } |
| 5680 | 5663 |
| 5681 // Compute the final value of READONLY for MSAA. | 5664 // Compute the final value of READONLY for MSAA. |
| 5682 // | 5665 // |
| 5683 // We always set the READONLY state for elements that have the | 5666 // We always set the READONLY state for elements that have the |
| 5684 // aria-readonly attribute and for a few roles (in the switch above), | 5667 // aria-readonly attribute and for a few roles (in the switch above), |
| 5685 // including read-only text fields. | 5668 // including read-only text fields. |
| 5686 // The majority of focusable controls should not have the read-only state set. | 5669 // The majority of focusable controls should not have the read-only state set. |
| 5687 if (GetOwner()->HasState(ui::AX_STATE_FOCUSABLE) && | 5670 if (owner()->HasState(ui::AX_STATE_FOCUSABLE) && |
| 5688 ia_role != ROLE_SYSTEM_DOCUMENT && ia_role != ROLE_SYSTEM_TEXT) { | 5671 ia_role != ROLE_SYSTEM_DOCUMENT && ia_role != ROLE_SYSTEM_TEXT) { |
| 5689 ia_state &= ~(STATE_SYSTEM_READONLY); | 5672 ia_state &= ~(STATE_SYSTEM_READONLY); |
| 5690 } | 5673 } |
| 5691 if (!GetOwner()->HasState(ui::AX_STATE_READ_ONLY)) | 5674 if (!owner()->HasState(ui::AX_STATE_READ_ONLY)) |
| 5692 ia_state &= ~(STATE_SYSTEM_READONLY); | 5675 ia_state &= ~(STATE_SYSTEM_READONLY); |
| 5693 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) | 5676 if (owner()->GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) |
| 5694 ia_state |= STATE_SYSTEM_READONLY; | 5677 ia_state |= STATE_SYSTEM_READONLY; |
| 5695 | 5678 |
| 5696 // The role should always be set. | 5679 // The role should always be set. |
| 5697 DCHECK(!role_name.empty() || ia_role); | 5680 DCHECK(!role_name.empty() || ia_role); |
| 5698 | 5681 |
| 5699 // If we didn't explicitly set the IAccessible2 role, make it the same | 5682 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 5700 // as the MSAA role. | 5683 // as the MSAA role. |
| 5701 if (!ia2_role) | 5684 if (!ia2_role) |
| 5702 ia2_role = ia_role; | 5685 ia2_role = ia_role; |
| 5703 | 5686 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5725 | 5708 |
| 5726 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( | 5709 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
| 5727 BrowserAccessibility* obj) { | 5710 BrowserAccessibility* obj) { |
| 5728 if (!obj || !obj->IsNative()) | 5711 if (!obj || !obj->IsNative()) |
| 5729 return nullptr; | 5712 return nullptr; |
| 5730 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); | 5713 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
| 5731 return result; | 5714 return result; |
| 5732 } | 5715 } |
| 5733 | 5716 |
| 5734 } // namespace content | 5717 } // namespace content |
| OLD | NEW |