OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/win/enum_variant.h" |
10 #include "base/win/scoped_comptr.h" | 11 #include "base/win/scoped_comptr.h" |
11 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 12 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
12 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
14 #include "ui/base/accessibility/accessible_text_utils.h" | 15 #include "ui/base/accessibility/accessible_text_utils.h" |
15 | 16 |
16 using webkit_glue::WebAccessibility; | 17 using webkit_glue::WebAccessibility; |
17 | 18 |
18 // The GUID for the ISimpleDOM service is not defined in the IDL files. | 19 // The GUID for the ISimpleDOM service is not defined in the IDL files. |
19 // This is taken directly from the Mozilla sources | 20 // This is taken directly from the Mozilla sources |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 162 |
162 BrowserAccessibilityWin* BrowserAccessibility::toBrowserAccessibilityWin() { | 163 BrowserAccessibilityWin* BrowserAccessibility::toBrowserAccessibilityWin() { |
163 return static_cast<BrowserAccessibilityWin*>(this); | 164 return static_cast<BrowserAccessibilityWin*>(this); |
164 } | 165 } |
165 | 166 |
166 BrowserAccessibilityWin::BrowserAccessibilityWin() | 167 BrowserAccessibilityWin::BrowserAccessibilityWin() |
167 : ia_role_(0), | 168 : ia_role_(0), |
168 ia_state_(0), | 169 ia_state_(0), |
169 ia2_role_(0), | 170 ia2_role_(0), |
170 ia2_state_(0), | 171 ia2_state_(0), |
171 first_time_(true) { | 172 first_time_(true), |
| 173 old_ia_state_(0) { |
172 } | 174 } |
173 | 175 |
174 BrowserAccessibilityWin::~BrowserAccessibilityWin() { | 176 BrowserAccessibilityWin::~BrowserAccessibilityWin() { |
175 for (size_t i = 0; i < relations_.size(); ++i) | 177 for (size_t i = 0; i < relations_.size(); ++i) |
176 relations_[i]->Release(); | 178 relations_[i]->Release(); |
177 } | 179 } |
178 | 180 |
179 // | 181 // |
180 // IAccessible methods. | 182 // IAccessible methods. |
181 // | 183 // |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 524 |
523 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic( | 525 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic( |
524 BSTR* help_file, VARIANT var_id, LONG* topic_id) { | 526 BSTR* help_file, VARIANT var_id, LONG* topic_id) { |
525 return E_NOTIMPL; | 527 return E_NOTIMPL; |
526 } | 528 } |
527 | 529 |
528 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { | 530 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
529 if (!instance_active_) | 531 if (!instance_active_) |
530 return E_FAIL; | 532 return E_FAIL; |
531 | 533 |
532 return E_NOTIMPL; | 534 if (role_ != WebAccessibility::ROLE_LISTBOX) |
| 535 return E_NOTIMPL; |
| 536 |
| 537 unsigned long selected_count = 0; |
| 538 for (size_t i = 0; i < children_.size(); ++i) { |
| 539 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) |
| 540 ++selected_count; |
| 541 } |
| 542 |
| 543 if (selected_count == 0) { |
| 544 selected->vt = VT_EMPTY; |
| 545 return S_OK; |
| 546 } |
| 547 |
| 548 if (selected_count == 1) { |
| 549 for (size_t i = 0; i < children_.size(); ++i) { |
| 550 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { |
| 551 selected->vt = VT_DISPATCH; |
| 552 selected->pdispVal = |
| 553 children_[i]->toBrowserAccessibilityWin()->NewReference(); |
| 554 return S_OK; |
| 555 } |
| 556 } |
| 557 } |
| 558 |
| 559 // Multiple items are selected. |
| 560 base::win::EnumVariant* enum_variant = |
| 561 new base::win::EnumVariant(selected_count); |
| 562 enum_variant->AddRef(); |
| 563 unsigned long index = 0; |
| 564 for (size_t i = 0; i < children_.size(); ++i) { |
| 565 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { |
| 566 enum_variant->ItemAt(index)->vt = VT_DISPATCH; |
| 567 enum_variant->ItemAt(index)->pdispVal = |
| 568 children_[i]->toBrowserAccessibilityWin()->NewReference(); |
| 569 ++index; |
| 570 } |
| 571 } |
| 572 selected->vt = VT_UNKNOWN; |
| 573 selected->punkVal = static_cast<IUnknown*>( |
| 574 static_cast<base::win::IUnknownImpl*>(enum_variant)); |
| 575 return S_OK; |
533 } | 576 } |
534 | 577 |
535 STDMETHODIMP BrowserAccessibilityWin::accSelect( | 578 STDMETHODIMP BrowserAccessibilityWin::accSelect( |
536 LONG flags_sel, VARIANT var_id) { | 579 LONG flags_sel, VARIANT var_id) { |
537 if (!instance_active_) | 580 if (!instance_active_) |
538 return E_FAIL; | 581 return E_FAIL; |
539 | 582 |
540 if (flags_sel & SELFLAG_TAKEFOCUS) { | 583 if (flags_sel & SELFLAG_TAKEFOCUS) { |
541 manager_->SetFocus(this, true); | 584 manager_->SetFocus(this, true); |
542 return S_OK; | 585 return S_OK; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 return S_FALSE; | 719 return S_FALSE; |
677 | 720 |
678 for (long i = 0; i < count; ++i) { | 721 for (long i = 0; i < count; ++i) { |
679 relations_[i]->AddRef(); | 722 relations_[i]->AddRef(); |
680 relations[i] = relations_[i]; | 723 relations[i] = relations_[i]; |
681 } | 724 } |
682 | 725 |
683 return S_OK; | 726 return S_OK; |
684 } | 727 } |
685 | 728 |
| 729 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( |
| 730 LONG* group_level, |
| 731 LONG* similar_items_in_group, |
| 732 LONG* position_in_group) { |
| 733 if (!instance_active_) |
| 734 return E_FAIL; |
| 735 |
| 736 if (!group_level || !similar_items_in_group || !position_in_group) |
| 737 return E_INVALIDARG; |
| 738 |
| 739 if (role_ == WebAccessibility::ROLE_LISTBOX_OPTION && |
| 740 parent_ && |
| 741 parent_->role() == WebAccessibility::ROLE_LISTBOX) { |
| 742 *group_level = 0; |
| 743 *similar_items_in_group = parent_->child_count(); |
| 744 *position_in_group = index_in_parent_ + 1; |
| 745 return S_OK; |
| 746 } |
| 747 |
| 748 return E_NOTIMPL; |
| 749 } |
| 750 |
686 // | 751 // |
687 // IAccessibleImage methods. | 752 // IAccessibleImage methods. |
688 // | 753 // |
689 | 754 |
690 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { | 755 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { |
691 if (!instance_active_) | 756 if (!instance_active_) |
692 return E_FAIL; | 757 return E_FAIL; |
693 | 758 |
694 if (!desc) | 759 if (!desc) |
695 return E_INVALIDARG; | 760 return E_INVALIDARG; |
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 } | 2393 } |
2329 | 2394 |
2330 // Expose the "display" and "tag" attributes. | 2395 // Expose the "display" and "tag" attributes. |
2331 StringAttributeToIA2(WebAccessibility::ATTR_DISPLAY, "display"); | 2396 StringAttributeToIA2(WebAccessibility::ATTR_DISPLAY, "display"); |
2332 StringAttributeToIA2(WebAccessibility::ATTR_HTML_TAG, "tag"); | 2397 StringAttributeToIA2(WebAccessibility::ATTR_HTML_TAG, "tag"); |
2333 StringAttributeToIA2(WebAccessibility::ATTR_ROLE, "xml-roles"); | 2398 StringAttributeToIA2(WebAccessibility::ATTR_ROLE, "xml-roles"); |
2334 | 2399 |
2335 // Expose "level" attribute for tree nodes. | 2400 // Expose "level" attribute for tree nodes. |
2336 IntAttributeToIA2(WebAccessibility::ATTR_HIERARCHICAL_LEVEL, "level"); | 2401 IntAttributeToIA2(WebAccessibility::ATTR_HIERARCHICAL_LEVEL, "level"); |
2337 | 2402 |
| 2403 // Expose the set size and position in set for listbox options. |
| 2404 if (role_ == WebAccessibility::ROLE_LISTBOX_OPTION && |
| 2405 parent_ && |
| 2406 parent_->role() == WebAccessibility::ROLE_LISTBOX) { |
| 2407 ia2_attributes_.push_back( |
| 2408 L"setsize:" + base::IntToString16(parent_->child_count())); |
| 2409 ia2_attributes_.push_back( |
| 2410 L"setsize:" + base::IntToString16(index_in_parent_ + 1)); |
| 2411 } |
| 2412 |
2338 // Expose live region attributes. | 2413 // Expose live region attributes. |
2339 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_STATUS, "live"); | 2414 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_STATUS, "live"); |
2340 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_RELEVANT, "relevant"); | 2415 StringAttributeToIA2(WebAccessibility::ATTR_LIVE_RELEVANT, "relevant"); |
2341 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_ATOMIC, "atomic"); | 2416 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_ATOMIC, "atomic"); |
2342 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_BUSY, "busy"); | 2417 BoolAttributeToIA2(WebAccessibility::ATTR_LIVE_BUSY, "busy"); |
2343 | 2418 |
2344 // Expose container live region attributes. | 2419 // Expose container live region attributes. |
2345 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_STATUS, | 2420 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_STATUS, |
2346 "container-live"); | 2421 "container-live"); |
2347 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_RELEVANT, | 2422 StringAttributeToIA2(WebAccessibility::ATTR_CONTAINER_LIVE_RELEVANT, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2380 } | 2455 } |
2381 if (index >= 0) { | 2456 if (index >= 0) { |
2382 ia2_attributes_.push_back(string16(L"table-cell-index:") + | 2457 ia2_attributes_.push_back(string16(L"table-cell-index:") + |
2383 base::IntToString16(index)); | 2458 base::IntToString16(index)); |
2384 } | 2459 } |
2385 } else { | 2460 } else { |
2386 NOTREACHED(); | 2461 NOTREACHED(); |
2387 } | 2462 } |
2388 } | 2463 } |
2389 | 2464 |
2390 // If this is static text, put the text in the name rather than the value. | 2465 if (name_.empty() && |
2391 if (role_ == WebAccessibility::ROLE_STATIC_TEXT && name_.empty()) | 2466 (role_ == WebAccessibility::ROLE_LISTBOX_OPTION || |
| 2467 role_ == WebAccessibility::ROLE_STATIC_TEXT)) { |
2392 name_.swap(value_); | 2468 name_.swap(value_); |
| 2469 } |
2393 | 2470 |
2394 // If this object doesn't have a name but it does have a description, | 2471 // If this object doesn't have a name but it does have a description, |
2395 // use the description as its name - because some screen readers only | 2472 // use the description as its name - because some screen readers only |
2396 // announce the name. | 2473 // announce the name. |
2397 if (name_.empty()) | 2474 if (name_.empty()) |
2398 GetStringAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); | 2475 GetStringAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); |
2399 | 2476 |
2400 // If this doesn't have a value and is linked then set its value to the url | 2477 // If this doesn't have a value and is linked then set its value to the url |
2401 // attribute. This allows screen readers to read an empty link's destination. | 2478 // attribute. This allows screen readers to read an empty link's destination. |
2402 string16 url; | 2479 string16 url; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2436 manager_->NotifyAccessibilityEvent( | 2513 manager_->NotifyAccessibilityEvent( |
2437 ViewHostMsg_AccEvent::OBJECT_SHOW, this); | 2514 ViewHostMsg_AccEvent::OBJECT_SHOW, this); |
2438 } | 2515 } |
2439 | 2516 |
2440 // TODO(dmazzoni): Look into HIDE events, too. | 2517 // TODO(dmazzoni): Look into HIDE events, too. |
2441 | 2518 |
2442 old_text_ = previous_text_; | 2519 old_text_ = previous_text_; |
2443 previous_text_ = text; | 2520 previous_text_ = text; |
2444 } | 2521 } |
2445 | 2522 |
| 2523 // Fire events if the state has changed. |
| 2524 if (!first_time_ && ia_state_ != old_ia_state_) { |
| 2525 // Normally focus events are handled elsewhere, however |
| 2526 // focus for managed descendants is platform-specific. |
| 2527 // Fire a focus event if the focused descendant in a multi-select |
| 2528 // list box changes. |
| 2529 if (role_ == WebAccessibility::ROLE_LISTBOX_OPTION && |
| 2530 (ia_state_ & STATE_SYSTEM_FOCUSABLE) && |
| 2531 (ia_state_ & STATE_SYSTEM_SELECTABLE) && |
| 2532 (ia_state_ & STATE_SYSTEM_FOCUSED) && |
| 2533 !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) { |
| 2534 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, |
| 2535 manager_->GetParentView(), |
| 2536 OBJID_CLIENT, |
| 2537 child_id()); |
| 2538 } |
| 2539 |
| 2540 if ((ia_state_ & STATE_SYSTEM_SELECTED) && |
| 2541 !(old_ia_state_ & STATE_SYSTEM_SELECTED)) { |
| 2542 ::NotifyWinEvent(EVENT_OBJECT_SELECTIONADD, |
| 2543 manager_->GetParentView(), |
| 2544 OBJID_CLIENT, |
| 2545 child_id()); |
| 2546 } else if (!(ia_state_ & STATE_SYSTEM_SELECTED) && |
| 2547 (old_ia_state_ & STATE_SYSTEM_SELECTED)) { |
| 2548 ::NotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, |
| 2549 manager_->GetParentView(), |
| 2550 OBJID_CLIENT, |
| 2551 child_id()); |
| 2552 } |
| 2553 |
| 2554 old_ia_state_ = ia_state_; |
| 2555 } |
| 2556 |
2446 first_time_ = false; | 2557 first_time_ = false; |
2447 } | 2558 } |
2448 | 2559 |
2449 void BrowserAccessibilityWin::NativeAddReference() { | 2560 void BrowserAccessibilityWin::NativeAddReference() { |
2450 AddRef(); | 2561 AddRef(); |
2451 } | 2562 } |
2452 | 2563 |
2453 void BrowserAccessibilityWin::NativeReleaseReference() { | 2564 void BrowserAccessibilityWin::NativeReleaseReference() { |
2454 Release(); | 2565 Release(); |
2455 } | 2566 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2564 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( | 2675 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( |
2565 int32 renderer_id) { | 2676 int32 renderer_id) { |
2566 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); | 2677 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); |
2567 } | 2678 } |
2568 | 2679 |
2569 void BrowserAccessibilityWin::InitRoleAndState() { | 2680 void BrowserAccessibilityWin::InitRoleAndState() { |
2570 ia_state_ = 0; | 2681 ia_state_ = 0; |
2571 ia2_state_ = IA2_STATE_OPAQUE; | 2682 ia2_state_ = IA2_STATE_OPAQUE; |
2572 ia2_attributes_.clear(); | 2683 ia2_attributes_.clear(); |
2573 | 2684 |
2574 if ((state_ >> WebAccessibility::STATE_BUSY) & 1) | 2685 if (HasState(WebAccessibility::STATE_BUSY)) |
2575 ia_state_|= STATE_SYSTEM_BUSY; | 2686 ia_state_|= STATE_SYSTEM_BUSY; |
2576 if ((state_ >> WebAccessibility::STATE_CHECKED) & 1) | 2687 if (HasState(WebAccessibility::STATE_CHECKED)) |
2577 ia_state_ |= STATE_SYSTEM_CHECKED; | 2688 ia_state_ |= STATE_SYSTEM_CHECKED; |
2578 if ((state_ >> WebAccessibility::STATE_COLLAPSED) & 1) | 2689 if (HasState(WebAccessibility::STATE_COLLAPSED)) |
2579 ia_state_|= STATE_SYSTEM_COLLAPSED; | 2690 ia_state_|= STATE_SYSTEM_COLLAPSED; |
2580 if ((state_ >> WebAccessibility::STATE_EXPANDED) & 1) | 2691 if (HasState(WebAccessibility::STATE_EXPANDED)) |
2581 ia_state_|= STATE_SYSTEM_EXPANDED; | 2692 ia_state_|= STATE_SYSTEM_EXPANDED; |
2582 if ((state_ >> WebAccessibility::STATE_FOCUSABLE) & 1) | 2693 if (HasState(WebAccessibility::STATE_FOCUSABLE)) |
2583 ia_state_|= STATE_SYSTEM_FOCUSABLE; | 2694 ia_state_|= STATE_SYSTEM_FOCUSABLE; |
2584 if ((state_ >> WebAccessibility::STATE_HASPOPUP) & 1) | 2695 if (HasState(WebAccessibility::STATE_HASPOPUP)) |
2585 ia_state_|= STATE_SYSTEM_HASPOPUP; | 2696 ia_state_|= STATE_SYSTEM_HASPOPUP; |
2586 if ((state_ >> WebAccessibility::STATE_HOTTRACKED) & 1) | 2697 if (HasState(WebAccessibility::STATE_HOTTRACKED)) |
2587 ia_state_|= STATE_SYSTEM_HOTTRACKED; | 2698 ia_state_|= STATE_SYSTEM_HOTTRACKED; |
2588 if ((state_ >> WebAccessibility::STATE_INDETERMINATE) & 1) | 2699 if (HasState(WebAccessibility::STATE_INDETERMINATE)) |
2589 ia_state_|= STATE_SYSTEM_INDETERMINATE; | 2700 ia_state_|= STATE_SYSTEM_INDETERMINATE; |
2590 if ((state_ >> WebAccessibility::STATE_INVISIBLE) & 1) | 2701 if (HasState(WebAccessibility::STATE_INVISIBLE)) |
2591 ia_state_|= STATE_SYSTEM_INVISIBLE; | 2702 ia_state_|= STATE_SYSTEM_INVISIBLE; |
2592 if ((state_ >> WebAccessibility::STATE_LINKED) & 1) | 2703 if (HasState(WebAccessibility::STATE_LINKED)) |
2593 ia_state_|= STATE_SYSTEM_LINKED; | 2704 ia_state_|= STATE_SYSTEM_LINKED; |
2594 if ((state_ >> WebAccessibility::STATE_MULTISELECTABLE) & 1) | 2705 if (HasState(WebAccessibility::STATE_MULTISELECTABLE)) { |
| 2706 ia_state_|= STATE_SYSTEM_EXTSELECTABLE; |
2595 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; | 2707 ia_state_|= STATE_SYSTEM_MULTISELECTABLE; |
| 2708 } |
2596 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. | 2709 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
2597 if ((state_ >> WebAccessibility::STATE_OFFSCREEN) & 1) | 2710 if (HasState(WebAccessibility::STATE_OFFSCREEN)) |
2598 ia_state_|= STATE_SYSTEM_OFFSCREEN; | 2711 ia_state_|= STATE_SYSTEM_OFFSCREEN; |
2599 if ((state_ >> WebAccessibility::STATE_PRESSED) & 1) | 2712 if (HasState(WebAccessibility::STATE_PRESSED)) |
2600 ia_state_|= STATE_SYSTEM_PRESSED; | 2713 ia_state_|= STATE_SYSTEM_PRESSED; |
2601 if ((state_ >> WebAccessibility::STATE_PROTECTED) & 1) | 2714 if (HasState(WebAccessibility::STATE_PROTECTED)) |
2602 ia_state_|= STATE_SYSTEM_PROTECTED; | 2715 ia_state_|= STATE_SYSTEM_PROTECTED; |
2603 if ((state_ >> WebAccessibility::STATE_REQUIRED) & 1) | 2716 if (HasState(WebAccessibility::STATE_REQUIRED)) |
2604 ia2_state_|= IA2_STATE_REQUIRED; | 2717 ia2_state_|= IA2_STATE_REQUIRED; |
2605 if ((state_ >> WebAccessibility::STATE_SELECTABLE) & 1) | 2718 if (HasState(WebAccessibility::STATE_SELECTABLE)) |
2606 ia_state_|= STATE_SYSTEM_SELECTABLE; | 2719 ia_state_|= STATE_SYSTEM_SELECTABLE; |
2607 if ((state_ >> WebAccessibility::STATE_SELECTED) & 1) | 2720 if (HasState(WebAccessibility::STATE_SELECTED)) |
2608 ia_state_|= STATE_SYSTEM_SELECTED; | 2721 ia_state_|= STATE_SYSTEM_SELECTED; |
2609 if ((state_ >> WebAccessibility::STATE_TRAVERSED) & 1) | 2722 if (HasState(WebAccessibility::STATE_TRAVERSED)) |
2610 ia_state_|= STATE_SYSTEM_TRAVERSED; | 2723 ia_state_|= STATE_SYSTEM_TRAVERSED; |
2611 if ((state_ >> WebAccessibility::STATE_UNAVAILABLE) & 1) | 2724 if (HasState(WebAccessibility::STATE_UNAVAILABLE)) |
2612 ia_state_|= STATE_SYSTEM_UNAVAILABLE; | 2725 ia_state_|= STATE_SYSTEM_UNAVAILABLE; |
2613 if ((state_ >> WebAccessibility::STATE_VERTICAL) & 1) { | 2726 if (HasState(WebAccessibility::STATE_VERTICAL)) { |
2614 ia2_state_|= IA2_STATE_VERTICAL; | 2727 ia2_state_|= IA2_STATE_VERTICAL; |
2615 } else { | 2728 } else { |
2616 ia2_state_|= IA2_STATE_HORIZONTAL; | 2729 ia2_state_|= IA2_STATE_HORIZONTAL; |
2617 } | 2730 } |
2618 if ((state_ >> WebAccessibility::STATE_VISITED) & 1) | 2731 if (HasState(WebAccessibility::STATE_VISITED)) |
2619 ia_state_|= STATE_SYSTEM_TRAVERSED; | 2732 ia_state_|= STATE_SYSTEM_TRAVERSED; |
2620 | 2733 |
2621 // The meaning of the readonly state on Windows is very different from | 2734 // The meaning of the readonly state on Windows is very different from |
2622 // the meaning of the readonly state in WebKit, so we ignore | 2735 // the meaning of the readonly state in WebKit, so we ignore |
2623 // WebAccessibility::STATE_READONLY, and instead just check the | 2736 // WebAccessibility::STATE_READONLY, and instead just check the |
2624 // aria readonly value, then there's additional logic below to set | 2737 // aria readonly value, then there's additional logic below to set |
2625 // the readonly state based on other criteria. | 2738 // the readonly state based on other criteria. |
2626 bool aria_readonly = false; | 2739 bool aria_readonly = false; |
2627 GetBoolAttribute(WebAccessibility::ATTR_ARIA_READONLY, &aria_readonly); | 2740 GetBoolAttribute(WebAccessibility::ATTR_ARIA_READONLY, &aria_readonly); |
2628 if (aria_readonly) | 2741 if (aria_readonly) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 break; | 2894 break; |
2782 case WebAccessibility::ROLE_LIST: | 2895 case WebAccessibility::ROLE_LIST: |
2783 ia_role_ = ROLE_SYSTEM_LIST; | 2896 ia_role_ = ROLE_SYSTEM_LIST; |
2784 ia_state_|= STATE_SYSTEM_READONLY; | 2897 ia_state_|= STATE_SYSTEM_READONLY; |
2785 break; | 2898 break; |
2786 case WebAccessibility::ROLE_LISTBOX: | 2899 case WebAccessibility::ROLE_LISTBOX: |
2787 ia_role_ = ROLE_SYSTEM_LIST; | 2900 ia_role_ = ROLE_SYSTEM_LIST; |
2788 break; | 2901 break; |
2789 case WebAccessibility::ROLE_LISTBOX_OPTION: | 2902 case WebAccessibility::ROLE_LISTBOX_OPTION: |
2790 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2903 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 2904 if (ia_state_ & STATE_SYSTEM_SELECTABLE) { |
| 2905 ia_state_ |= STATE_SYSTEM_FOCUSABLE; |
| 2906 if (HasState(WebAccessibility::STATE_FOCUSED)) |
| 2907 ia_state_|= STATE_SYSTEM_FOCUSED; |
| 2908 } |
2791 break; | 2909 break; |
2792 case WebAccessibility::ROLE_LIST_ITEM: | 2910 case WebAccessibility::ROLE_LIST_ITEM: |
2793 ia_role_ = ROLE_SYSTEM_LISTITEM; | 2911 ia_role_ = ROLE_SYSTEM_LISTITEM; |
2794 ia_state_|= STATE_SYSTEM_READONLY; | 2912 ia_state_|= STATE_SYSTEM_READONLY; |
2795 break; | 2913 break; |
2796 case WebAccessibility::ROLE_LIST_MARKER: | 2914 case WebAccessibility::ROLE_LIST_MARKER: |
2797 ia_role_ = ROLE_SYSTEM_TEXT; | 2915 ia_role_ = ROLE_SYSTEM_TEXT; |
2798 ia_state_|= STATE_SYSTEM_READONLY; | 2916 ia_state_|= STATE_SYSTEM_READONLY; |
2799 break; | 2917 break; |
2800 case WebAccessibility::ROLE_MATH: | 2918 case WebAccessibility::ROLE_MATH: |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 } | 3084 } |
2967 | 3085 |
2968 // The role should always be set. | 3086 // The role should always be set. |
2969 DCHECK(!role_name_.empty() || ia_role_); | 3087 DCHECK(!role_name_.empty() || ia_role_); |
2970 | 3088 |
2971 // If we didn't explicitly set the IAccessible2 role, make it the same | 3089 // If we didn't explicitly set the IAccessible2 role, make it the same |
2972 // as the MSAA role. | 3090 // as the MSAA role. |
2973 if (!ia2_role_) | 3091 if (!ia2_role_) |
2974 ia2_role_ = ia_role_; | 3092 ia2_role_ = ia_role_; |
2975 } | 3093 } |
OLD | NEW |