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

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

Issue 1308153012: Uses isEditable and isRichlyEditable to determine which attributes to expose on Mac and how to repr… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit test by adding EDITABLE role manually. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/accessibility/browser_accessibility_win.h" 5 #include "content/browser/accessibility/browser_accessibility_win.h"
6 6
7 #include <UIAutomationClient.h> 7 #include <UIAutomationClient.h>
8 #include <UIAutomationCoreApi.h> 8 #include <UIAutomationCoreApi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) 2641 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag))
2642 *node_name = SysAllocString(tag.c_str()); 2642 *node_name = SysAllocString(tag.c_str());
2643 else 2643 else
2644 *node_name = NULL; 2644 *node_name = NULL;
2645 2645
2646 *name_space_id = 0; 2646 *name_space_id = 0;
2647 *node_value = SysAllocString(value().c_str()); 2647 *node_value = SysAllocString(value().c_str());
2648 *num_children = PlatformChildCount(); 2648 *num_children = PlatformChildCount();
2649 *unique_id = unique_id_win_; 2649 *unique_id = unique_id_win_;
2650 2650
2651 if (ia_role() == ROLE_SYSTEM_DOCUMENT) { 2651 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
2652 GetRole() == ui::AX_ROLE_WEB_AREA) {
2652 *node_type = NODETYPE_DOCUMENT; 2653 *node_type = NODETYPE_DOCUMENT;
2653 } else if (ia_role() == ROLE_SYSTEM_TEXT && 2654 } else if (IsTextOnlyObject()) {
2654 ((ia2_state() & IA2_STATE_EDITABLE) == 0)) {
2655 *node_type = NODETYPE_TEXT; 2655 *node_type = NODETYPE_TEXT;
2656 } else { 2656 } else {
2657 *node_type = NODETYPE_ELEMENT; 2657 *node_type = NODETYPE_ELEMENT;
2658 } 2658 }
2659 2659
2660 return S_OK; 2660 return S_OK;
2661 } 2661 }
2662 2662
2663 STDMETHODIMP BrowserAccessibilityWin::get_attributes( 2663 STDMETHODIMP BrowserAccessibilityWin::get_attributes(
2664 unsigned short max_attribs, 2664 unsigned short max_attribs,
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
3746 if (focus_object->IsDescendantOf(this)) 3746 if (focus_object->IsDescendantOf(this))
3747 return GetHypertextOffsetFromDescendant(*focus_object); 3747 return GetHypertextOffsetFromDescendant(*focus_object);
3748 3748
3749 return -1; 3749 return -1;
3750 } 3750 }
3751 3751
3752 void BrowserAccessibilityWin::GetSelectionOffsets( 3752 void BrowserAccessibilityWin::GetSelectionOffsets(
3753 int* selection_start, int* selection_end) const { 3753 int* selection_start, int* selection_end) const {
3754 DCHECK(selection_start && selection_end); 3754 DCHECK(selection_start && selection_end);
3755 3755
3756 if (GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) && 3756 if (IsEditableText() && !HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
3757 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) &&
3757 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { 3758 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) {
3758 return; 3759 return;
3759 } 3760 }
3760 3761
3761 *selection_start = GetSelectionAnchor(); 3762 *selection_start = GetSelectionAnchor();
3762 *selection_end = GetSelectionFocus(); 3763 *selection_end = GetSelectionFocus();
3763 if (*selection_start < 0 || *selection_end < 0) 3764 if (*selection_start < 0 || *selection_end < 0)
3764 return; 3765 return;
3765 3766
3766 if (*selection_end < *selection_start) 3767 if (*selection_end < *selection_start)
3767 std::swap(*selection_start, *selection_end); 3768 std::swap(*selection_start, *selection_end);
3768 3769
3769 // IA2 Spec says that the end of the selection should be after the last 3770 // IA2 Spec says that the end of the selection should be after the last
3770 // embedded object character that is part of the selection. 3771 // embedded object character that is part of the selection, if there is one.
3771 ++(*selection_end); 3772 if (hyperlink_offset_to_index().find(*selection_end) !=
3773 hyperlink_offset_to_index().end()) {
3774 ++(*selection_end);
3775 }
3772 } 3776 }
3773 3777
3774 base::string16 BrowserAccessibilityWin::GetNameRecursive() const { 3778 base::string16 BrowserAccessibilityWin::GetNameRecursive() const {
3775 if (!name().empty()) { 3779 if (!name().empty()) {
3776 return name(); 3780 return name();
3777 } 3781 }
3778 3782
3779 base::string16 result; 3783 base::string16 result;
3780 for (uint32 i = 0; i < PlatformChildCount(); ++i) { 3784 for (uint32 i = 0; i < PlatformChildCount(); ++i) {
3781 result += PlatformGetChild(i)->ToBrowserAccessibilityWin()-> 3785 result += PlatformGetChild(i)->ToBrowserAccessibilityWin()->
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
4005 // Expose whether or not the mouse is over an element, but suppress 4009 // Expose whether or not the mouse is over an element, but suppress
4006 // this for tests because it can make the test results flaky depending 4010 // this for tests because it can make the test results flaky depending
4007 // on the position of the mouse. 4011 // on the position of the mouse.
4008 BrowserAccessibilityStateImpl* accessibility_state = 4012 BrowserAccessibilityStateImpl* accessibility_state =
4009 BrowserAccessibilityStateImpl::GetInstance(); 4013 BrowserAccessibilityStateImpl::GetInstance();
4010 if (!accessibility_state->disable_hot_tracking_for_testing()) { 4014 if (!accessibility_state->disable_hot_tracking_for_testing()) {
4011 if (HasState(ui::AX_STATE_HOVERED)) 4015 if (HasState(ui::AX_STATE_HOVERED))
4012 ia_state |= STATE_SYSTEM_HOTTRACKED; 4016 ia_state |= STATE_SYSTEM_HOTTRACKED;
4013 } 4017 }
4014 4018
4015 // WebKit marks everything as readonly unless it's editable text, so if it's 4019 if (IsEditableText())
4016 // not readonly, mark it as editable now. The final computation of the
4017 // READONLY state for MSAA is below, after the switch.
4018 if (!HasState(ui::AX_STATE_READ_ONLY))
4019 ia2_state |= IA2_STATE_EDITABLE; 4020 ia2_state |= IA2_STATE_EDITABLE;
4020 4021
4021 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED)) 4022 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED))
4022 ia_state |= STATE_SYSTEM_MIXED; 4023 ia_state |= STATE_SYSTEM_MIXED;
4023 4024
4024 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) 4025 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE))
4025 ia2_state |= IA2_STATE_EDITABLE; 4026 ia2_state |= IA2_STATE_EDITABLE;
4026 4027
4027 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) 4028 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty())
4028 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; 4029 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
4420 ia_role = ROLE_SYSTEM_PUSHBUTTON; 4421 ia_role = ROLE_SYSTEM_PUSHBUTTON;
4421 ia2_role = IA2_ROLE_TOGGLE_BUTTON; 4422 ia2_role = IA2_ROLE_TOGGLE_BUTTON;
4422 break; 4423 break;
4423 case ui::AX_ROLE_TEXT_FIELD: 4424 case ui::AX_ROLE_TEXT_FIELD:
4424 case ui::AX_ROLE_SEARCH_BOX: 4425 case ui::AX_ROLE_SEARCH_BOX:
4425 ia_role = ROLE_SYSTEM_TEXT; 4426 ia_role = ROLE_SYSTEM_TEXT;
4426 if (HasState(ui::AX_STATE_MULTILINE)) 4427 if (HasState(ui::AX_STATE_MULTILINE))
4427 ia2_state |= IA2_STATE_MULTI_LINE; 4428 ia2_state |= IA2_STATE_MULTI_LINE;
4428 else 4429 else
4429 ia2_state |= IA2_STATE_SINGLE_LINE; 4430 ia2_state |= IA2_STATE_SINGLE_LINE;
4430 ia2_state |= IA2_STATE_EDITABLE;
4431 ia2_state |= IA2_STATE_SELECTABLE_TEXT; 4431 ia2_state |= IA2_STATE_SELECTABLE_TEXT;
4432 break; 4432 break;
4433 case ui::AX_ROLE_TIME: 4433 case ui::AX_ROLE_TIME:
4434 role_name = html_tag; 4434 role_name = html_tag;
4435 ia_role = ROLE_SYSTEM_TEXT; 4435 ia_role = ROLE_SYSTEM_TEXT;
4436 ia2_role = IA2_ROLE_TEXT_FRAME; 4436 ia2_role = IA2_ROLE_TEXT_FRAME;
4437 break; 4437 break;
4438 case ui::AX_ROLE_TIMER: 4438 case ui::AX_ROLE_TIMER:
4439 ia_role = ROLE_SYSTEM_CLOCK; 4439 ia_role = ROLE_SYSTEM_CLOCK;
4440 ia_state |= STATE_SYSTEM_READONLY; 4440 ia_state |= STATE_SYSTEM_READONLY;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4499 ia2_role = ia_role; 4499 ia2_role = ia_role;
4500 4500
4501 win_attributes_->ia_role = ia_role; 4501 win_attributes_->ia_role = ia_role;
4502 win_attributes_->ia_state = ia_state; 4502 win_attributes_->ia_state = ia_state;
4503 win_attributes_->role_name = role_name; 4503 win_attributes_->role_name = role_name;
4504 win_attributes_->ia2_role = ia2_role; 4504 win_attributes_->ia2_role = ia2_role;
4505 win_attributes_->ia2_state = ia2_state; 4505 win_attributes_->ia2_state = ia2_state;
4506 } 4506 }
4507 4507
4508 } // namespace content 4508 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698