diff options
author | pauljensen <pauljensen@chromium.org> | 2015-01-26 06:58:24 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-26 14:59:22 +0000 |
commit | 9ddab275f9681cfdef2aa1ed5b8c3d9431b58468 (patch) | |
tree | 8f9853eb5c97a010c46603c074a68350ebdf30cb /content/browser/accessibility/browser_accessibility_win.cc | |
parent | 576f7d5d4c42bbf8bc7f07e20f1882bc4fd0c7cb (diff) | |
download | chromium_src-9ddab275f9681cfdef2aa1ed5b8c3d9431b58468.zip chromium_src-9ddab275f9681cfdef2aa1ed5b8c3d9431b58468.tar.gz chromium_src-9ddab275f9681cfdef2aa1ed5b8c3d9431b58468.tar.bz2 |
Revert of Send Windows accessibility events based on tree updates. (patchset #9 id:160001 of https://codereview.chromium.org/848653002/)
Reason for revert:
DumpAccessibilityEventsTest.AccessibilityEventsTextChanged failing frequently on Windows bots. Fails most of the time on Win8 Aura.
Original issue's description:
> Send Windows accessibility events based on tree updates.
>
> The idea of this change is to fire Win AX events
> based on the AX tree changing, rather than based
> on Blink firing the right event and mapping it to a
> Win event.
>
> Store the Win-specific AX attributes (ia role,
> ia state, name, value, etc.) in a struct, and when a
> node is updated, compare the old value of each attribute
> to the new value and fire an appropriate event for each
> one (name changed, state changed, etc.).
>
> Handle hypertext_ similarly, and properly diff the old and new hypertext in get_oldText and get_newText.
>
> This enables all of the "event" tests that were
> previously added to pass now, and it makes live regions
> work correctly in NVDA and JAWS.
>
> BUG=447962
>
> Committed: https://crrev.com/eb691a960bef3c2aefa38627baa7cbdde480b81e
> Cr-Commit-Position: refs/heads/master@{#313052}
TBR=dtseng@chromium.org,aboxhall@chromium.org,dmazzoni@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=447962
Review URL: https://codereview.chromium.org/880523002
Cr-Commit-Position: refs/heads/master@{#313067}
Diffstat (limited to 'content/browser/accessibility/browser_accessibility_win.cc')
-rw-r--r-- | content/browser/accessibility/browser_accessibility_win.cc | 921 |
1 files changed, 388 insertions, 533 deletions
diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc index eab9196..248d20e 100644 --- a/content/browser/accessibility/browser_accessibility_win.cc +++ b/content/browser/accessibility/browser_accessibility_win.cc @@ -175,17 +175,6 @@ STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, } // -// BrowserAccessibilityWin::WinAttributes -// - -BrowserAccessibilityWin::WinAttributes::WinAttributes() - : ia_role(0), - ia_state(0), - ia2_role(0), - ia2_state(0) { -} - -// // BrowserAccessibilityWin // @@ -203,7 +192,12 @@ BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() { } BrowserAccessibilityWin::BrowserAccessibilityWin() - : win_attributes_(new WinAttributes()), + : ia_role_(0), + ia_state_(0), + ia2_role_(0), + ia2_state_(0), + first_time_(true), + old_ia_state_(0), previous_scroll_x_(0), previous_scroll_y_(0) { // Start unique IDs at -1 and decrement each time, because get_accChild @@ -403,14 +397,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, if (!target) return E_INVALIDARG; - base::string16 description_str = target->description(); - if (description_str.empty()) - return S_FALSE; - - *desc = SysAllocString(description_str.c_str()); - - DCHECK(*desc); - return S_OK; + return target->GetStringAttributeAsBstr( + ui::AX_ATTR_DESCRIPTION, desc); } STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { @@ -446,14 +434,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { if (!target) return E_INVALIDARG; - base::string16 help_str = target->help(); - if (help_str.empty()) - return S_FALSE; - - *help = SysAllocString(help_str.c_str()); - - DCHECK(*help); - return S_OK; + return target->GetStringAttributeAsBstr( + ui::AX_ATTR_HELP, help); } STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, @@ -483,24 +465,24 @@ STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { if (!target) return E_INVALIDARG; - base::string16 name_str = target->name(); + std::string name_str = target->name(); // If the name is empty, see if it's labeled by another element. if (name_str.empty()) { int title_elem_id; if (target->GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT, &title_elem_id)) { - BrowserAccessibilityWin* title_elem = - manager()->GetFromID(title_elem_id)->ToBrowserAccessibilityWin(); + BrowserAccessibility* title_elem = + manager()->GetFromID(title_elem_id); if (title_elem) - name_str = title_elem->GetNameRecursive(); + name_str = title_elem->GetTextRecursive(); } } if (name_str.empty()) return S_FALSE; - *name = SysAllocString(name_str.c_str()); + *name = SysAllocString(base::UTF8ToUTF16(name_str).c_str()); DCHECK(*name); return S_OK; @@ -548,12 +530,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, if (!target) return E_INVALIDARG; - if (!target->role_name().empty()) { + if (!target->role_name_.empty()) { role->vt = VT_BSTR; - role->bstrVal = SysAllocString(target->role_name().c_str()); + role->bstrVal = SysAllocString(target->role_name_.c_str()); } else { role->vt = VT_I4; - role->lVal = target->ia_role(); + role->lVal = target->ia_role_; } return S_OK; } @@ -571,7 +553,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, return E_INVALIDARG; state->vt = VT_I4; - state->lVal = target->ia_state(); + state->lVal = target->ia_state_; if (manager()->GetFocus(NULL) == this) state->lVal |= STATE_SYSTEM_FOCUSED; @@ -616,7 +598,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, return S_OK; } - *value = SysAllocString(target->value().c_str()); + *value = SysAllocString(base::UTF8ToUTF16(target->value()).c_str()); DCHECK(*value); return S_OK; } @@ -699,7 +681,7 @@ STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { if (!role) return E_INVALIDARG; - *role = ia2_role(); + *role = ia2_role_; return S_OK; } @@ -734,7 +716,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { if (!states) return E_INVALIDARG; - *states = ia2_state(); + *states = ia2_state_; return S_OK; } @@ -998,13 +980,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { if (!desc) return E_INVALIDARG; - if (description().empty()) - return S_FALSE; - - *desc = SysAllocString(description().c_str()); - - DCHECK(*desc); - return S_OK; + return GetStringAttributeAsBstr( + ui::AX_ATTR_DESCRIPTION, desc); } STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( @@ -1180,10 +1157,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, return S_OK; } - if (cell->description().size() > 0) { - *description = SysAllocString(cell->description().c_str()); - return S_OK; - } + return cell->GetStringAttributeAsBstr( + ui::AX_ATTR_DESCRIPTION, description); } } @@ -1369,10 +1344,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, return S_OK; } - if (cell->description().size() > 0) { - *description = SysAllocString(cell->description().c_str()); - return S_OK; - } + return cell->GetStringAttributeAsBstr( + ui::AX_ATTR_DESCRIPTION, description); } } @@ -2174,15 +2147,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { if (!new_text) return E_INVALIDARG; - int start, old_len, new_len; - ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); - if (new_len == 0) - return E_FAIL; + base::string16 text = TextForIAccessibleText(); - base::string16 substr = hypertext_.substr(start, new_len); - new_text->text = SysAllocString(substr.c_str()); - new_text->start = static_cast<long>(start); - new_text->end = static_cast<long>(start + new_len); + new_text->text = SysAllocString(text.c_str()); + new_text->start = 0; + new_text->end = static_cast<long>(text.size()); return S_OK; } @@ -2193,15 +2162,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { if (!old_text) return E_INVALIDARG; - int start, old_len, new_len; - ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); - if (old_len == 0) - return E_FAIL; - - base::string16 substr = old_hypertext_.substr(start, old_len); - old_text->text = SysAllocString(substr.c_str()); - old_text->start = static_cast<long>(start); - old_text->end = static_cast<long>(start + old_len); + old_text->text = SysAllocString(old_text_.c_str()); + old_text->start = 0; + old_text->end = static_cast<long>(old_text_.size()); return S_OK; } @@ -2335,10 +2298,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( *hyperlink_index = -1; - if (char_index < 0 || - char_index >= static_cast<long>(hypertext_.size())) { + if (char_index < 0 || char_index >= static_cast<long>(hypertext_.size())) return E_INVALIDARG; - } std::map<int32, int32>::iterator it = hyperlink_offset_to_index_.find(char_index); @@ -2487,14 +2448,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( *node_name = NULL; *name_space_id = 0; - *node_value = SysAllocString(value().c_str()); + *node_value = SysAllocString(base::UTF8ToUTF16(value()).c_str()); *num_children = PlatformChildCount(); *unique_id = unique_id_win_; - if (ia_role() == ROLE_SYSTEM_DOCUMENT) { + if (ia_role_ == ROLE_SYSTEM_DOCUMENT) { *node_type = NODETYPE_DOCUMENT; - } else if (ia_role() == ROLE_SYSTEM_TEXT && - ((ia2_state() & IA2_STATE_EDITABLE) == 0)) { + } else if (ia_role_ == ROLE_SYSTEM_TEXT && + ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { *node_type = NODETYPE_TEXT; } else { *node_type = NODETYPE_ELEMENT; @@ -2905,7 +2866,7 @@ HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( void** object) { BrowserAccessibilityWin* accessibility = reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); - int32 ia_role = accessibility->ia_role(); + int32 ia_role = accessibility->ia_role_; if (iid == IID_IAccessibleImage) { if (ia_role != ROLE_SYSTEM_GRAPHIC) { *object = NULL; @@ -2943,28 +2904,12 @@ HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( // Private methods. // -// Called every time this node's data changes, while the tree update is -// still in progress. +// Called every time this node's data changes. void BrowserAccessibilityWin::OnDataChanged() { BrowserAccessibility::OnDataChanged(); -} - -// Called every time this node's data changes, after an atomic tree update. -void BrowserAccessibilityWin::OnUpdateFinished() { - BrowserAccessibility::OnUpdateFinished(); - - if (PlatformIsChildOfLeaf()) - return; - - bool is_new_object = ia_role() == 0 && role_name().empty(); - - old_win_attributes_.swap(win_attributes_); - win_attributes_.reset(new WinAttributes()); InitRoleAndState(); - win_attributes_->ia2_attributes.clear(); - // Expose autocomplete attribute for combobox and textbox. StringAttributeToIA2(ui::AX_ATTR_AUTO_COMPLETE, "autocomplete"); @@ -2981,18 +2926,18 @@ void BrowserAccessibilityWin::OnUpdateFinished() { if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && GetParent() && GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { - win_attributes_->ia2_attributes.push_back( + ia2_attributes_.push_back( L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount())); - win_attributes_->ia2_attributes.push_back( + ia2_attributes_.push_back( L"setsize:" + base::IntToString16(GetIndexInParent() + 1)); } - if (ia_role() == ROLE_SYSTEM_CHECKBUTTON || - ia_role() == ROLE_SYSTEM_RADIOBUTTON || - ia2_role() == IA2_ROLE_CHECK_MENU_ITEM || - ia2_role() == IA2_ROLE_RADIO_MENU_ITEM || - ia2_role() == IA2_ROLE_TOGGLE_BUTTON) { - win_attributes_->ia2_attributes.push_back(L"checkable:true"); + if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || + ia_role_ == ROLE_SYSTEM_RADIOBUTTON || + ia2_role_ == IA2_ROLE_CHECK_MENU_ITEM || + ia2_role_ == IA2_ROLE_RADIO_MENU_ITEM || + ia2_role_ == IA2_ROLE_TOGGLE_BUTTON) { + ia2_attributes_.push_back(L"checkable:true"); } // Expose live region attributes. @@ -3011,6 +2956,13 @@ void BrowserAccessibilityWin::OnUpdateFinished() { BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy"); + // Expose slider value. + if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || + ia_role_ == ROLE_SYSTEM_SCROLLBAR || + ia_role_ == ROLE_SYSTEM_SLIDER) { + ia2_attributes_.push_back(L"valuetext:" + GetValueText()); + } + // Expose table cell index. if (IsCellOrTableHeaderRole()) { BrowserAccessibility* table = GetParent(); @@ -3021,7 +2973,7 @@ void BrowserAccessibilityWin::OnUpdateFinished() { ui::AX_ATTR_UNIQUE_CELL_IDS); for (size_t i = 0; i < unique_cell_ids.size(); ++i) { if (unique_cell_ids[i] == GetId()) { - win_attributes_->ia2_attributes.push_back( + ia2_attributes_.push_back( base::string16(L"table-cell-index:") + base::IntToString16(i)); } } @@ -3037,27 +2989,26 @@ void BrowserAccessibilityWin::OnUpdateFinished() { case ui::AX_INVALID_STATE_NONE: break; case ui::AX_INVALID_STATE_FALSE: - win_attributes_->ia2_attributes.push_back(L"invalid:false"); + ia2_attributes_.push_back(L"invalid:false"); break; case ui::AX_INVALID_STATE_TRUE: - win_attributes_->ia2_attributes.push_back(L"invalid:true"); + ia2_attributes_.push_back(L"invalid:true"); break; case ui::AX_INVALID_STATE_SPELLING: - win_attributes_->ia2_attributes.push_back(L"invalid:spelling"); + ia2_attributes_.push_back(L"invalid:spelling"); break; case ui::AX_INVALID_STATE_GRAMMAR: - win_attributes_->ia2_attributes.push_back(L"invalid:grammar"); + ia2_attributes_.push_back(L"invalid:grammar"); break; case ui::AX_INVALID_STATE_OTHER: { base::string16 aria_invalid_value; if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, &aria_invalid_value)) { - win_attributes_->ia2_attributes.push_back( - L"invalid:" + aria_invalid_value); + ia2_attributes_.push_back(L"invalid:" + aria_invalid_value); } else { // Set the attribute to L"true", since we cannot be more specific. - win_attributes_->ia2_attributes.push_back(L"invalid:true"); + ia2_attributes_.push_back(L"invalid:true"); } } break; @@ -3087,16 +3038,16 @@ void BrowserAccessibilityWin::OnUpdateFinished() { // always returns the primary name in "name" and the secondary name, // if any, in "description". - int title_elem_id = GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT); - base::string16 name = GetString16Attribute(ui::AX_ATTR_NAME); - base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); - base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP); - base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); + int title_elem_id = GetIntAttribute( + ui::AX_ATTR_TITLE_UI_ELEMENT); + std::string help = GetStringAttribute(ui::AX_ATTR_HELP); + std::string description = GetStringAttribute( + ui::AX_ATTR_DESCRIPTION); // WebKit annoyingly puts the title in the description if there's no other // description, which just confuses the rest of the logic. Put it back. // Now "help" is always the value of the "title" attribute, if present. - base::string16 title_attr; + std::string title_attr; if (GetHtmlAttribute("title", &title_attr) && description == title_attr && help.empty()) { @@ -3108,57 +3059,55 @@ void BrowserAccessibilityWin::OnUpdateFinished() { // it's nonempty, and the help should become the description if // there's no description - or the name if there's no name or description. if (!description.empty()) { - name = description; + set_name(description); description.clear(); } if (!help.empty() && description.empty()) { description = help; help.clear(); } - if (!description.empty() && name.empty() && !title_elem_id) { - name = description; + if (!description.empty() && name().empty() && !title_elem_id) { + set_name(description); description.clear(); } // If it's a text field, also consider the placeholder. - base::string16 placeholder; + std::string placeholder; if (GetRole() == ui::AX_ROLE_TEXT_FIELD && HasState(ui::AX_STATE_FOCUSABLE) && GetHtmlAttribute("placeholder", &placeholder)) { - if (name.empty() && !title_elem_id) { - name = placeholder; + if (name().empty() && !title_elem_id) { + set_name(placeholder); } else if (description.empty()) { description = placeholder; } } + SetStringAttribute(ui::AX_ATTR_DESCRIPTION, description); + SetStringAttribute(ui::AX_ATTR_HELP, help); + // On Windows, the value of a document should be its url. if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || GetRole() == ui::AX_ROLE_WEB_AREA) { - value = GetString16Attribute(ui::AX_ATTR_DOC_URL); + set_value(GetStringAttribute(ui::AX_ATTR_DOC_URL)); } // For certain roles (listbox option, static text, and list marker) // WebKit stores the main accessible text in the "value" - swap it so // that it's the "name". - if (name.empty() && + if (name().empty() && (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || GetRole() == ui::AX_ROLE_STATIC_TEXT || GetRole() == ui::AX_ROLE_LIST_MARKER)) { - base::string16 tmp = value; - value = name; - name = tmp; + std::string tmp = value(); + set_value(name()); + set_name(tmp); } // If this doesn't have a value and is linked then set its value to the url // attribute. This allows screen readers to read an empty link's destination. - if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) - value = GetString16Attribute(ui::AX_ATTR_URL); - - win_attributes_->name = name; - win_attributes_->description = description; - win_attributes_->help = help; - win_attributes_->value = value; + if (value().empty() && (ia_state_ & STATE_SYSTEM_LINKED)) + set_value(GetStringAttribute(ui::AX_ATTR_URL)); // Clear any old relationships between this node and other nodes. for (size_t i = 0; i < relations_.size(); ++i) @@ -3178,138 +3127,95 @@ void BrowserAccessibilityWin::OnUpdateFinished() { relations_.push_back(relation); } - // Expose slider value. - if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || - ia_role() == ROLE_SYSTEM_SCROLLBAR || - ia_role() == ROLE_SYSTEM_SLIDER) { - win_attributes_->ia2_attributes.push_back(L"valuetext:" + GetValueText()); - } - // If this is a web area for a presentational iframe, give it a role of // something other than DOCUMENT so that the fact that it's a separate doc // is not exposed to AT. if (IsWebAreaForPresentationalIframe()) { - win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; - win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = ROLE_SYSTEM_GROUPING; } - - BrowserAccessibilityManagerWin* manager = - this->manager()->ToBrowserAccessibilityManagerWin(); - - // Fire an event when an alert first appears. - if (ia_role() == ROLE_SYSTEM_ALERT && - old_win_attributes_->ia_role != ROLE_SYSTEM_ALERT) { - manager->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); - } - - // Fire an event if the name, description, help, or value changes. - if (!is_new_object) { - if (name != old_win_attributes_->name) - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, this); - if (description != old_win_attributes_->description) - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_DESCRIPTIONCHANGE, this); - if (help != old_win_attributes_->help) - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_HELPCHANGE, this); - if (value != old_win_attributes_->value) - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_VALUECHANGE, this); - if (ia_state() != old_win_attributes_->ia_state) - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_STATECHANGE, this); - - // Normally focus events are handled elsewhere, however - // focus for managed descendants is platform-specific. - // Fire a focus event if the focused descendant in a multi-select - // list box changes. - if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && - (ia_state() & STATE_SYSTEM_FOCUSABLE) && - (ia_state() & STATE_SYSTEM_SELECTABLE) && - (ia_state() & STATE_SYSTEM_FOCUSED) && - !(old_win_attributes_->ia_state & STATE_SYSTEM_FOCUSED)) { - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, this); - } - - // Handle selection being added or removed. - bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0; - bool was_selected_before = - (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; - if (is_selected_now && !was_selected_before) { - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, this); - } else if (!is_selected_now && was_selected_before) { - manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, this); - } - - // Fire an event if this container object has scrolled. - int sx = 0; - int sy = 0; - if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && - GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { - if (sx != previous_scroll_x_ || sy != previous_scroll_y_) - manager->MaybeCallNotifyWinEvent(EVENT_SYSTEM_SCROLLINGEND, this); - previous_scroll_x_ = sx; - previous_scroll_y_ = sy; - } - - // Changing a static text node can affect the IAccessibleText hypertext - // of the parent node, so force it to be recomputed here. - if (GetParent() && - GetRole() == ui::AX_ROLE_STATIC_TEXT && - name != old_win_attributes_->name) { - GetParent()->ToBrowserAccessibilityWin()->UpdateIAccessibleText(); - } - } - - old_win_attributes_.reset(nullptr); } -void BrowserAccessibilityWin::UpdateIAccessibleText() { - old_hypertext_ = hypertext_; - hypertext_.clear(); - +void BrowserAccessibilityWin::OnUpdateFinished() { // Construct the hypertext for this node. hyperlink_offset_to_index_.clear(); hyperlinks_.clear(); + hypertext_.clear(); for (unsigned int i = 0; i < PlatformChildCount(); ++i) { - BrowserAccessibilityWin* child = - PlatformGetChild(i)->ToBrowserAccessibilityWin(); + BrowserAccessibility* child = PlatformGetChild(i); if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) { - hypertext_ += child->name(); + hypertext_ += base::UTF8ToUTF16(child->name()); } else { - hyperlink_offset_to_index_[hypertext_.size()] = - hyperlinks_.size(); + hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); hypertext_ += kEmbeddedCharacter; hyperlinks_.push_back(i); } } DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); - if (hypertext_ != old_hypertext_) { - BrowserAccessibilityManagerWin* manager = - this->manager()->ToBrowserAccessibilityManagerWin(); + // Fire an event when an alert first appears. + if (GetRole() == ui::AX_ROLE_ALERT && first_time_) + manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); + + // Fire events if text has changed. + base::string16 text = TextForIAccessibleText(); + if (previous_text_ != text) { + if (!previous_text_.empty() && !text.empty()) { + manager()->NotifyAccessibilityEvent( + ui::AX_EVENT_SHOW, this); + } + + // TODO(dmazzoni): Look into HIDE events, too. + + old_text_ = previous_text_; + previous_text_ = text; + } - int start, old_len, new_len; - ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); - if (old_len) { - // In-process screen readers may call IAccessibleText::get_oldText - // to retrieve the text that was removed. - manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_REMOVED, this); + BrowserAccessibilityManagerWin* manager = + this->manager()->ToBrowserAccessibilityManagerWin(); + + // Fire events if the state has changed. + if (!first_time_ && ia_state_ != old_ia_state_) { + // Normally focus events are handled elsewhere, however + // focus for managed descendants is platform-specific. + // Fire a focus event if the focused descendant in a multi-select + // list box changes. + if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && + (ia_state_ & STATE_SYSTEM_FOCUSABLE) && + (ia_state_ & STATE_SYSTEM_SELECTABLE) && + (ia_state_ & STATE_SYSTEM_FOCUSED) && + !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) { + manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, unique_id_win()); } - if (new_len) { - // In-process screen readers may call IAccessibleText::get_newText - // to retrieve the text that was inserted. - manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_INSERTED, this); + + if ((ia_state_ & STATE_SYSTEM_SELECTED) && + !(old_ia_state_ & STATE_SYSTEM_SELECTED)) { + manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, + unique_id_win()); + } else if (!(ia_state_ & STATE_SYSTEM_SELECTED) && + (old_ia_state_ & STATE_SYSTEM_SELECTED)) { + manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, + unique_id_win()); } - } - old_hypertext_.clear(); -} + old_ia_state_ = ia_state_; + } -void BrowserAccessibilityWin::OnSubtreeWillBeDeleted() { - manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( - EVENT_OBJECT_HIDE, this); -} + // Fire an event if this container object has scrolled. + int sx = 0; + int sy = 0; + if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && + GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { + if (!first_time_ && + (sx != previous_scroll_x_ || sy != previous_scroll_y_)) { + manager->MaybeCallNotifyWinEvent(EVENT_SYSTEM_SCROLLINGEND, + unique_id_win()); + } + previous_scroll_x_ = sx; + previous_scroll_y_ = sy; + } -void BrowserAccessibilityWin::OnSubtreeCreationFinished() { - manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( - EVENT_OBJECT_SHOW, this); + first_time_ = false; } void BrowserAccessibilityWin::NativeAddReference() { @@ -3326,7 +3232,7 @@ bool BrowserAccessibilityWin::IsNative() const { void BrowserAccessibilityWin::OnLocationChanged() { manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( - EVENT_OBJECT_LOCATIONCHANGE, this); + EVENT_OBJECT_LOCATIONCHANGE, unique_id_win()); } BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { @@ -3371,10 +3277,8 @@ void BrowserAccessibilityWin::StringAttributeToIA2( ui::AXStringAttribute attribute, const char* ia2_attr) { base::string16 value; - if (GetString16Attribute(attribute, &value)) { - win_attributes_->ia2_attributes.push_back( - base::ASCIIToUTF16(ia2_attr) + L":" + value); - } + if (GetString16Attribute(attribute, &value)) + ia2_attributes_.push_back(base::ASCIIToUTF16(ia2_attr) + L":" + value); } void BrowserAccessibilityWin::BoolAttributeToIA2( @@ -3382,9 +3286,8 @@ void BrowserAccessibilityWin::BoolAttributeToIA2( const char* ia2_attr) { bool value; if (GetBoolAttribute(attribute, &value)) { - win_attributes_->ia2_attributes.push_back( - (base::ASCIIToUTF16(ia2_attr) + L":") + - (value ? L"true" : L"false")); + ia2_attributes_.push_back((base::ASCIIToUTF16(ia2_attr) + L":") + + (value ? L"true" : L"false")); } } @@ -3393,28 +3296,14 @@ void BrowserAccessibilityWin::IntAttributeToIA2( const char* ia2_attr) { int value; if (GetIntAttribute(attribute, &value)) { - win_attributes_->ia2_attributes.push_back( - base::ASCIIToUTF16(ia2_attr) + L":" + - base::IntToString16(value)); + ia2_attributes_.push_back(base::ASCIIToUTF16(ia2_attr) + L":" + + base::IntToString16(value)); } } -base::string16 BrowserAccessibilityWin::GetNameRecursive() const { - if (!name().empty()) { - return name(); - } - - base::string16 result; - for (uint32 i = 0; i < PlatformChildCount(); ++i) { - result += PlatformGetChild(i)->ToBrowserAccessibilityWin()-> - GetNameRecursive(); - } - return result; -} - base::string16 BrowserAccessibilityWin::GetValueText() { float fval; - base::string16 value = this->value(); + base::string16 value = base::UTF8ToUTF16(this->value()); if (value.empty() && GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { @@ -3425,37 +3314,9 @@ base::string16 BrowserAccessibilityWin::GetValueText() { base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { if (IsEditableText()) - return value(); - return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? name() : hypertext_; -} - -void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( - int* start, int* old_len, int* new_len) { - *start = 0; - *old_len = 0; - *new_len = 0; - - const base::string16& old_text = old_hypertext_; - const base::string16& new_text = hypertext_; - - size_t common_prefix = 0; - while (common_prefix < old_text.size() && - common_prefix < new_text.size() && - old_text[common_prefix] == new_text[common_prefix]) { - ++common_prefix; - } - - size_t common_suffix = 0; - while (common_prefix + common_suffix < old_text.size() && - common_prefix + common_suffix < new_text.size() && - old_text[old_text.size() - common_suffix - 1] == - new_text[new_text.size() - common_suffix - 1]) { - ++common_suffix; - } - - *start = common_prefix; - *old_len = old_text.size() - common_prefix - common_suffix; - *new_len = new_text.size() - common_prefix - common_suffix; + return base::UTF8ToUTF16(value()); + return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? + base::UTF8ToUTF16(name()) : hypertext_; } void BrowserAccessibilityWin::HandleSpecialTextOffset( @@ -3506,499 +3367,499 @@ BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) { } void BrowserAccessibilityWin::InitRoleAndState() { - int32 ia_role = 0; - int32 ia_state = 0; - base::string16 role_name; - int32 ia2_role = 0; - int32 ia2_state = IA2_STATE_OPAQUE; + ia_state_ = 0; + ia2_state_ = IA2_STATE_OPAQUE; + ia2_attributes_.clear(); if (HasState(ui::AX_STATE_BUSY)) - ia_state |= STATE_SYSTEM_BUSY; + ia_state_ |= STATE_SYSTEM_BUSY; if (HasState(ui::AX_STATE_CHECKED)) - ia_state |= STATE_SYSTEM_CHECKED; + ia_state_ |= STATE_SYSTEM_CHECKED; if (HasState(ui::AX_STATE_COLLAPSED)) - ia_state |= STATE_SYSTEM_COLLAPSED; + ia_state_ |= STATE_SYSTEM_COLLAPSED; if (HasState(ui::AX_STATE_EXPANDED)) - ia_state |= STATE_SYSTEM_EXPANDED; + ia_state_ |= STATE_SYSTEM_EXPANDED; if (HasState(ui::AX_STATE_FOCUSABLE)) - ia_state |= STATE_SYSTEM_FOCUSABLE; + ia_state_ |= STATE_SYSTEM_FOCUSABLE; if (HasState(ui::AX_STATE_HASPOPUP)) - ia_state |= STATE_SYSTEM_HASPOPUP; + ia_state_ |= STATE_SYSTEM_HASPOPUP; if (HasState(ui::AX_STATE_HOVERED)) - ia_state |= STATE_SYSTEM_HOTTRACKED; + ia_state_ |= STATE_SYSTEM_HOTTRACKED; if (HasState(ui::AX_STATE_INDETERMINATE)) - ia_state |= STATE_SYSTEM_INDETERMINATE; + ia_state_ |= STATE_SYSTEM_INDETERMINATE; if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE) - ia2_state |= IA2_STATE_INVALID_ENTRY; + ia2_state_ |= IA2_STATE_INVALID_ENTRY; if (HasState(ui::AX_STATE_INVISIBLE)) - ia_state |= STATE_SYSTEM_INVISIBLE; + ia_state_ |= STATE_SYSTEM_INVISIBLE; if (HasState(ui::AX_STATE_LINKED)) - ia_state |= STATE_SYSTEM_LINKED; + ia_state_ |= STATE_SYSTEM_LINKED; if (HasState(ui::AX_STATE_MULTISELECTABLE)) { - ia_state |= STATE_SYSTEM_EXTSELECTABLE; - ia_state |= STATE_SYSTEM_MULTISELECTABLE; + ia_state_ |= STATE_SYSTEM_EXTSELECTABLE; + ia_state_ |= STATE_SYSTEM_MULTISELECTABLE; } // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. if (HasState(ui::AX_STATE_OFFSCREEN)) - ia_state |= STATE_SYSTEM_OFFSCREEN; + ia_state_ |= STATE_SYSTEM_OFFSCREEN; if (HasState(ui::AX_STATE_PRESSED)) - ia_state |= STATE_SYSTEM_PRESSED; + ia_state_ |= STATE_SYSTEM_PRESSED; if (HasState(ui::AX_STATE_PROTECTED)) - ia_state |= STATE_SYSTEM_PROTECTED; + ia_state_ |= STATE_SYSTEM_PROTECTED; if (HasState(ui::AX_STATE_REQUIRED)) - ia2_state |= IA2_STATE_REQUIRED; + ia2_state_ |= IA2_STATE_REQUIRED; if (HasState(ui::AX_STATE_SELECTABLE)) - ia_state |= STATE_SYSTEM_SELECTABLE; + ia_state_ |= STATE_SYSTEM_SELECTABLE; if (HasState(ui::AX_STATE_SELECTED)) - ia_state |= STATE_SYSTEM_SELECTED; + ia_state_ |= STATE_SYSTEM_SELECTED; if (HasState(ui::AX_STATE_VISITED)) - ia_state |= STATE_SYSTEM_TRAVERSED; + ia_state_ |= STATE_SYSTEM_TRAVERSED; if (!HasState(ui::AX_STATE_ENABLED)) - ia_state |= STATE_SYSTEM_UNAVAILABLE; + ia_state_ |= STATE_SYSTEM_UNAVAILABLE; if (HasState(ui::AX_STATE_VERTICAL)) - ia2_state |= IA2_STATE_VERTICAL; + ia2_state_ |= IA2_STATE_VERTICAL; if (HasState(ui::AX_STATE_HORIZONTAL)) - ia2_state |= IA2_STATE_HORIZONTAL; + ia2_state_ |= IA2_STATE_HORIZONTAL; if (HasState(ui::AX_STATE_VISITED)) - ia_state |= STATE_SYSTEM_TRAVERSED; + ia_state_ |= STATE_SYSTEM_TRAVERSED; // WebKit marks everything as readonly unless it's editable text, so if it's // not readonly, mark it as editable now. The final computation of the // READONLY state for MSAA is below, after the switch. if (!HasState(ui::AX_STATE_READ_ONLY)) - ia2_state |= IA2_STATE_EDITABLE; + ia2_state_ |= IA2_STATE_EDITABLE; if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED)) - ia_state |= STATE_SYSTEM_MIXED; + ia_state_ |= STATE_SYSTEM_MIXED; if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) - ia2_state |= IA2_STATE_EDITABLE; + ia2_state_ |= IA2_STATE_EDITABLE; if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) - ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; + ia2_state_ |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; base::string16 html_tag = GetString16Attribute( ui::AX_ATTR_HTML_TAG); + ia_role_ = 0; + ia2_role_ = 0; switch (GetRole()) { case ui::AX_ROLE_ALERT: - ia_role = ROLE_SYSTEM_ALERT; + ia_role_ = ROLE_SYSTEM_ALERT; break; case ui::AX_ROLE_ALERT_DIALOG: - ia_role = ROLE_SYSTEM_DIALOG; + ia_role_ = ROLE_SYSTEM_DIALOG; break; case ui::AX_ROLE_APPLICATION: - ia_role = ROLE_SYSTEM_APPLICATION; + ia_role_ = ROLE_SYSTEM_APPLICATION; break; case ui::AX_ROLE_ARTICLE: - ia_role = ROLE_SYSTEM_DOCUMENT; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_DOCUMENT; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_BANNER: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_HEADER; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_HEADER; break; case ui::AX_ROLE_BLOCKQUOTE: - role_name = html_tag; - ia2_role = IA2_ROLE_SECTION; + role_name_ = html_tag; + ia2_role_ = IA2_ROLE_SECTION; break; case ui::AX_ROLE_BUSY_INDICATOR: - ia_role = ROLE_SYSTEM_ANIMATION; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_ANIMATION; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_BUTTON: - ia_role = ROLE_SYSTEM_PUSHBUTTON; + ia_role_ = ROLE_SYSTEM_PUSHBUTTON; break; case ui::AX_ROLE_CANVAS: if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { - role_name = L"canvas"; - ia2_role = IA2_ROLE_CANVAS; + role_name_ = L"canvas"; + ia2_role_ = IA2_ROLE_CANVAS; } else { - ia_role = ROLE_SYSTEM_GRAPHIC; + ia_role_ = ROLE_SYSTEM_GRAPHIC; } break; case ui::AX_ROLE_CAPTION: - ia_role = ROLE_SYSTEM_TEXT; - ia2_role = IA2_ROLE_CAPTION; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_role_ = IA2_ROLE_CAPTION; break; case ui::AX_ROLE_CELL: - ia_role = ROLE_SYSTEM_CELL; + ia_role_ = ROLE_SYSTEM_CELL; break; case ui::AX_ROLE_CHECK_BOX: - ia_role = ROLE_SYSTEM_CHECKBUTTON; - ia2_state |= IA2_STATE_CHECKABLE; + ia_role_ = ROLE_SYSTEM_CHECKBUTTON; + ia2_state_ |= IA2_STATE_CHECKABLE; break; case ui::AX_ROLE_COLOR_WELL: - ia_role = ROLE_SYSTEM_TEXT; - ia2_role = IA2_ROLE_COLOR_CHOOSER; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_role_ = IA2_ROLE_COLOR_CHOOSER; break; case ui::AX_ROLE_COLUMN: - ia_role = ROLE_SYSTEM_COLUMN; + ia_role_ = ROLE_SYSTEM_COLUMN; break; case ui::AX_ROLE_COLUMN_HEADER: - ia_role = ROLE_SYSTEM_COLUMNHEADER; + ia_role_ = ROLE_SYSTEM_COLUMNHEADER; break; case ui::AX_ROLE_COMBO_BOX: - ia_role = ROLE_SYSTEM_COMBOBOX; + ia_role_ = ROLE_SYSTEM_COMBOBOX; break; case ui::AX_ROLE_COMPLEMENTARY: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_NOTE; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_NOTE; break; case ui::AX_ROLE_CONTENT_INFO: - ia_role = ROLE_SYSTEM_TEXT; - ia2_role = IA2_ROLE_PARAGRAPH; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_role_ = IA2_ROLE_PARAGRAPH; break; case ui::AX_ROLE_DATE: case ui::AX_ROLE_DATE_TIME: - ia_role = ROLE_SYSTEM_DROPLIST; - ia2_role = IA2_ROLE_DATE_EDITOR; + ia_role_ = ROLE_SYSTEM_DROPLIST; + ia2_role_ = IA2_ROLE_DATE_EDITOR; break; case ui::AX_ROLE_DIV: - role_name = L"div"; - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_SECTION; + role_name_ = L"div"; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_SECTION; break; case ui::AX_ROLE_DEFINITION: - role_name = html_tag; - ia2_role = IA2_ROLE_PARAGRAPH; - ia_state |= STATE_SYSTEM_READONLY; + role_name_ = html_tag; + ia2_role_ = IA2_ROLE_PARAGRAPH; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL: - role_name = html_tag; - ia_role = ROLE_SYSTEM_TEXT; - ia2_role = IA2_ROLE_PARAGRAPH; + role_name_ = html_tag; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_role_ = IA2_ROLE_PARAGRAPH; break; case ui::AX_ROLE_DESCRIPTION_LIST: - role_name = html_tag; - ia_role = ROLE_SYSTEM_LIST; - ia_state |= STATE_SYSTEM_READONLY; + role_name_ = html_tag; + ia_role_ = ROLE_SYSTEM_LIST; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_DESCRIPTION_LIST_TERM: - ia_role = ROLE_SYSTEM_LISTITEM; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_LISTITEM; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_DETAILS: - role_name = html_tag; - ia_role = ROLE_SYSTEM_GROUPING; + role_name_ = html_tag; + ia_role_ = ROLE_SYSTEM_GROUPING; break; case ui::AX_ROLE_DIALOG: - ia_role = ROLE_SYSTEM_DIALOG; + ia_role_ = ROLE_SYSTEM_DIALOG; break; case ui::AX_ROLE_DISCLOSURE_TRIANGLE: - ia_role = ROLE_SYSTEM_PUSHBUTTON; + ia_role_ = ROLE_SYSTEM_PUSHBUTTON; break; case ui::AX_ROLE_DOCUMENT: case ui::AX_ROLE_ROOT_WEB_AREA: case ui::AX_ROLE_WEB_AREA: - ia_role = ROLE_SYSTEM_DOCUMENT; - ia_state |= STATE_SYSTEM_READONLY; - ia_state |= STATE_SYSTEM_FOCUSABLE; + ia_role_ = ROLE_SYSTEM_DOCUMENT; + ia_state_ |= STATE_SYSTEM_READONLY; + ia_state_ |= STATE_SYSTEM_FOCUSABLE; break; case ui::AX_ROLE_EMBEDDED_OBJECT: - ia_role = ROLE_SYSTEM_CLIENT; - ia2_role = IA2_ROLE_EMBEDDED_OBJECT; + ia_role_ = ROLE_SYSTEM_CLIENT; + ia2_role_ = IA2_ROLE_EMBEDDED_OBJECT; break; case ui::AX_ROLE_FIGCAPTION: - role_name = html_tag; - ia2_role = IA2_ROLE_CAPTION; + role_name_ = html_tag; + ia2_role_ = IA2_ROLE_CAPTION; break; case ui::AX_ROLE_FIGURE: - ia_role = ROLE_SYSTEM_GROUPING; + ia_role_ = ROLE_SYSTEM_GROUPING; break; case ui::AX_ROLE_FORM: - role_name = L"form"; - ia2_role = IA2_ROLE_FORM; + role_name_ = L"form"; + ia2_role_ = IA2_ROLE_FORM; break; case ui::AX_ROLE_FOOTER: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_FOOTER; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_FOOTER; break; case ui::AX_ROLE_GRID: - ia_role = ROLE_SYSTEM_TABLE; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_TABLE; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_GROUP: { base::string16 aria_role = GetString16Attribute( ui::AX_ATTR_ROLE); if (aria_role == L"group" || html_tag == L"fieldset") { - ia_role = ROLE_SYSTEM_GROUPING; + ia_role_ = ROLE_SYSTEM_GROUPING; } else if (html_tag == L"li") { - ia_role = ROLE_SYSTEM_LISTITEM; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_LISTITEM; + ia_state_ |= STATE_SYSTEM_READONLY; } else { if (html_tag.empty()) - role_name = L"div"; + role_name_ = L"div"; else - role_name = html_tag; - ia2_role = IA2_ROLE_SECTION; + role_name_ = html_tag; + ia2_role_ = IA2_ROLE_SECTION; } break; } case ui::AX_ROLE_HEADING: - role_name = html_tag; - ia2_role = IA2_ROLE_HEADING; + role_name_ = html_tag; + ia2_role_ = IA2_ROLE_HEADING; break; case ui::AX_ROLE_IFRAME: - ia_role = ROLE_SYSTEM_DOCUMENT; - ia2_role = IA2_ROLE_INTERNAL_FRAME; - ia_state = STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_DOCUMENT; + ia2_role_ = IA2_ROLE_INTERNAL_FRAME; + ia_state_ = STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_IFRAME_PRESENTATIONAL: - ia_role = ROLE_SYSTEM_GROUPING; + ia_role_ = ROLE_SYSTEM_GROUPING; break; case ui::AX_ROLE_IMAGE: - ia_role = ROLE_SYSTEM_GRAPHIC; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_GRAPHIC; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_IMAGE_MAP: - role_name = html_tag; - ia2_role = IA2_ROLE_IMAGE_MAP; - ia_state |= STATE_SYSTEM_READONLY; + role_name_ = html_tag; + ia2_role_ = IA2_ROLE_IMAGE_MAP; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_IMAGE_MAP_LINK: - ia_role = ROLE_SYSTEM_LINK; - ia_state |= STATE_SYSTEM_LINKED; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_LINK; + ia_state_ |= STATE_SYSTEM_LINKED; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_LABEL_TEXT: case ui::AX_ROLE_LEGEND: - ia_role = ROLE_SYSTEM_TEXT; - ia2_role = IA2_ROLE_LABEL; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_role_ = IA2_ROLE_LABEL; break; case ui::AX_ROLE_SEARCH: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_SECTION; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_SECTION; break; case ui::AX_ROLE_LINK: - ia_role = ROLE_SYSTEM_LINK; - ia_state |= STATE_SYSTEM_LINKED; + ia_role_ = ROLE_SYSTEM_LINK; + ia_state_ |= STATE_SYSTEM_LINKED; break; case ui::AX_ROLE_LIST: - ia_role = ROLE_SYSTEM_LIST; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_LIST; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_LIST_BOX: - ia_role = ROLE_SYSTEM_LIST; + ia_role_ = ROLE_SYSTEM_LIST; break; case ui::AX_ROLE_LIST_BOX_OPTION: - ia_role = ROLE_SYSTEM_LISTITEM; - if (ia_state & STATE_SYSTEM_SELECTABLE) { - ia_state |= STATE_SYSTEM_FOCUSABLE; + ia_role_ = ROLE_SYSTEM_LISTITEM; + if (ia_state_ & STATE_SYSTEM_SELECTABLE) { + ia_state_ |= STATE_SYSTEM_FOCUSABLE; if (HasState(ui::AX_STATE_FOCUSED)) - ia_state |= STATE_SYSTEM_FOCUSED; + ia_state_ |= STATE_SYSTEM_FOCUSED; } break; case ui::AX_ROLE_LIST_ITEM: - ia_role = ROLE_SYSTEM_LISTITEM; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_LISTITEM; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_MAIN: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_PARAGRAPH; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_PARAGRAPH; break; case ui::AX_ROLE_MARQUEE: - ia_role = ROLE_SYSTEM_ANIMATION; + ia_role_ = ROLE_SYSTEM_ANIMATION; break; case ui::AX_ROLE_MATH: - ia_role = ROLE_SYSTEM_EQUATION; + ia_role_ = ROLE_SYSTEM_EQUATION; break; case ui::AX_ROLE_MENU: case ui::AX_ROLE_MENU_BUTTON: - ia_role = ROLE_SYSTEM_MENUPOPUP; + ia_role_ = ROLE_SYSTEM_MENUPOPUP; break; case ui::AX_ROLE_MENU_BAR: - ia_role = ROLE_SYSTEM_MENUBAR; + ia_role_ = ROLE_SYSTEM_MENUBAR; break; case ui::AX_ROLE_MENU_ITEM: - ia_role = ROLE_SYSTEM_MENUITEM; + ia_role_ = ROLE_SYSTEM_MENUITEM; break; case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: - ia_role = ROLE_SYSTEM_MENUITEM; - ia2_role = IA2_ROLE_CHECK_MENU_ITEM; - ia2_state |= IA2_STATE_CHECKABLE; + ia_role_ = ROLE_SYSTEM_MENUITEM; + ia2_role_ = IA2_ROLE_CHECK_MENU_ITEM; + ia2_state_ |= IA2_STATE_CHECKABLE; break; case ui::AX_ROLE_MENU_ITEM_RADIO: - ia_role = ROLE_SYSTEM_MENUITEM; - ia2_role = IA2_ROLE_RADIO_MENU_ITEM; + ia_role_ = ROLE_SYSTEM_MENUITEM; + ia2_role_ = IA2_ROLE_RADIO_MENU_ITEM; break; case ui::AX_ROLE_MENU_LIST_POPUP: - ia_role = ROLE_SYSTEM_CLIENT; + ia_role_ = ROLE_SYSTEM_CLIENT; break; case ui::AX_ROLE_MENU_LIST_OPTION: - ia_role = ROLE_SYSTEM_LISTITEM; - if (ia_state & STATE_SYSTEM_SELECTABLE) { - ia_state |= STATE_SYSTEM_FOCUSABLE; + ia_role_ = ROLE_SYSTEM_LISTITEM; + if (ia_state_ & STATE_SYSTEM_SELECTABLE) { + ia_state_ |= STATE_SYSTEM_FOCUSABLE; if (HasState(ui::AX_STATE_FOCUSED)) - ia_state |= STATE_SYSTEM_FOCUSED; + ia_state_ |= STATE_SYSTEM_FOCUSED; } break; case ui::AX_ROLE_METER: - role_name = html_tag; - ia_role = ROLE_SYSTEM_PROGRESSBAR; + role_name_ = html_tag; + ia_role_ = ROLE_SYSTEM_PROGRESSBAR; break; case ui::AX_ROLE_NAVIGATION: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_SECTION; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_SECTION; break; case ui::AX_ROLE_NOTE: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_NOTE; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_NOTE; break; case ui::AX_ROLE_OUTLINE: - ia_role = ROLE_SYSTEM_OUTLINE; + ia_role_ = ROLE_SYSTEM_OUTLINE; break; case ui::AX_ROLE_PARAGRAPH: - role_name = L"P"; - ia2_role = IA2_ROLE_PARAGRAPH; + role_name_ = L"P"; + ia2_role_ = IA2_ROLE_PARAGRAPH; break; case ui::AX_ROLE_POP_UP_BUTTON: if (html_tag == L"select") { - ia_role = ROLE_SYSTEM_COMBOBOX; + ia_role_ = ROLE_SYSTEM_COMBOBOX; } else { - ia_role = ROLE_SYSTEM_BUTTONMENU; + ia_role_ = ROLE_SYSTEM_BUTTONMENU; } break; case ui::AX_ROLE_PRE: - role_name = html_tag; - ia_role = ROLE_SYSTEM_TEXT; - ia2_role = IA2_ROLE_PARAGRAPH; + role_name_ = html_tag; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_role_ = IA2_ROLE_PARAGRAPH; break; case ui::AX_ROLE_PROGRESS_INDICATOR: - ia_role = ROLE_SYSTEM_PROGRESSBAR; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_PROGRESSBAR; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_RADIO_BUTTON: - ia_role = ROLE_SYSTEM_RADIOBUTTON; - ia2_state = IA2_STATE_CHECKABLE; + ia_role_ = ROLE_SYSTEM_RADIOBUTTON; + ia2_state_ = IA2_STATE_CHECKABLE; break; case ui::AX_ROLE_RADIO_GROUP: - ia_role = ROLE_SYSTEM_GROUPING; + ia_role_ = ROLE_SYSTEM_GROUPING; break; case ui::AX_ROLE_REGION: if (html_tag == L"section") { - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_SECTION; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_SECTION; } else { - ia_role = ROLE_SYSTEM_PANE; + ia_role_ = ROLE_SYSTEM_PANE; } break; case ui::AX_ROLE_ROW: - ia_role = ROLE_SYSTEM_ROW; + ia_role_ = ROLE_SYSTEM_ROW; break; case ui::AX_ROLE_ROW_HEADER: - ia_role = ROLE_SYSTEM_ROWHEADER; + ia_role_ = ROLE_SYSTEM_ROWHEADER; break; case ui::AX_ROLE_RUBY: - ia_role = ROLE_SYSTEM_TEXT; - ia2_role = IA2_ROLE_TEXT_FRAME; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_role_ = IA2_ROLE_TEXT_FRAME; break; case ui::AX_ROLE_RULER: - ia_role = ROLE_SYSTEM_CLIENT; - ia2_role = IA2_ROLE_RULER; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_CLIENT; + ia2_role_ = IA2_ROLE_RULER; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_SCROLL_AREA: - ia_role = ROLE_SYSTEM_CLIENT; - ia2_role = IA2_ROLE_SCROLL_PANE; - ia_state |= STATE_SYSTEM_READONLY; - ia2_state &= ~(IA2_STATE_EDITABLE); + ia_role_ = ROLE_SYSTEM_CLIENT; + ia2_role_ = IA2_ROLE_SCROLL_PANE; + ia_state_ |= STATE_SYSTEM_READONLY; + ia2_state_ &= ~(IA2_STATE_EDITABLE); break; case ui::AX_ROLE_SCROLL_BAR: - ia_role = ROLE_SYSTEM_SCROLLBAR; + ia_role_ = ROLE_SYSTEM_SCROLLBAR; break; case ui::AX_ROLE_SLIDER: - ia_role = ROLE_SYSTEM_SLIDER; + ia_role_ = ROLE_SYSTEM_SLIDER; break; case ui::AX_ROLE_SPIN_BUTTON: - ia_role = ROLE_SYSTEM_SPINBUTTON; + ia_role_ = ROLE_SYSTEM_SPINBUTTON; break; case ui::AX_ROLE_SPIN_BUTTON_PART: - ia_role = ROLE_SYSTEM_PUSHBUTTON; + ia_role_ = ROLE_SYSTEM_PUSHBUTTON; break; case ui::AX_ROLE_ANNOTATION: case ui::AX_ROLE_LIST_MARKER: case ui::AX_ROLE_STATIC_TEXT: - ia_role = ROLE_SYSTEM_STATICTEXT; + ia_role_ = ROLE_SYSTEM_STATICTEXT; break; case ui::AX_ROLE_STATUS: - ia_role = ROLE_SYSTEM_STATUSBAR; + ia_role_ = ROLE_SYSTEM_STATUSBAR; break; case ui::AX_ROLE_SPLITTER: - ia_role = ROLE_SYSTEM_SEPARATOR; + ia_role_ = ROLE_SYSTEM_SEPARATOR; break; case ui::AX_ROLE_SVG_ROOT: - ia_role = ROLE_SYSTEM_GRAPHIC; + ia_role_ = ROLE_SYSTEM_GRAPHIC; break; case ui::AX_ROLE_TAB: - ia_role = ROLE_SYSTEM_PAGETAB; + ia_role_ = ROLE_SYSTEM_PAGETAB; break; case ui::AX_ROLE_TABLE: { base::string16 aria_role = GetString16Attribute( ui::AX_ATTR_ROLE); if (aria_role == L"treegrid") { - ia_role = ROLE_SYSTEM_OUTLINE; + ia_role_ = ROLE_SYSTEM_OUTLINE; } else { - ia_role = ROLE_SYSTEM_TABLE; + ia_role_ = ROLE_SYSTEM_TABLE; } break; } case ui::AX_ROLE_TABLE_HEADER_CONTAINER: - ia_role = ROLE_SYSTEM_GROUPING; - ia2_role = IA2_ROLE_SECTION; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_GROUPING; + ia2_role_ = IA2_ROLE_SECTION; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_TAB_LIST: - ia_role = ROLE_SYSTEM_PAGETABLIST; + ia_role_ = ROLE_SYSTEM_PAGETABLIST; break; case ui::AX_ROLE_TAB_PANEL: - ia_role = ROLE_SYSTEM_PROPERTYPAGE; + ia_role_ = ROLE_SYSTEM_PROPERTYPAGE; break; case ui::AX_ROLE_TOGGLE_BUTTON: - ia_role = ROLE_SYSTEM_PUSHBUTTON; - ia2_role = IA2_ROLE_TOGGLE_BUTTON; + ia_role_ = ROLE_SYSTEM_PUSHBUTTON; + ia2_role_ = IA2_ROLE_TOGGLE_BUTTON; break; case ui::AX_ROLE_TEXT_AREA: - ia_role = ROLE_SYSTEM_TEXT; - ia2_state |= IA2_STATE_MULTI_LINE; - ia2_state |= IA2_STATE_EDITABLE; - ia2_state |= IA2_STATE_SELECTABLE_TEXT; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_state_ |= IA2_STATE_MULTI_LINE; + ia2_state_ |= IA2_STATE_EDITABLE; + ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; break; case ui::AX_ROLE_TEXT_FIELD: - ia_role = ROLE_SYSTEM_TEXT; - ia2_state |= IA2_STATE_SINGLE_LINE; - ia2_state |= IA2_STATE_EDITABLE; - ia2_state |= IA2_STATE_SELECTABLE_TEXT; + ia_role_ = ROLE_SYSTEM_TEXT; + ia2_state_ |= IA2_STATE_SINGLE_LINE; + ia2_state_ |= IA2_STATE_EDITABLE; + ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; break; case ui::AX_ROLE_TIME: - ia_role = ROLE_SYSTEM_SPINBUTTON; + ia_role_ = ROLE_SYSTEM_SPINBUTTON; break; case ui::AX_ROLE_TIMER: - ia_role = ROLE_SYSTEM_CLOCK; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_CLOCK; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_TOOLBAR: - ia_role = ROLE_SYSTEM_TOOLBAR; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_TOOLBAR; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_TOOLTIP: - ia_role = ROLE_SYSTEM_TOOLTIP; - ia_state |= STATE_SYSTEM_READONLY; + ia_role_ = ROLE_SYSTEM_TOOLTIP; + ia_state_ |= STATE_SYSTEM_READONLY; break; case ui::AX_ROLE_TREE: - ia_role = ROLE_SYSTEM_OUTLINE; + ia_role_ = ROLE_SYSTEM_OUTLINE; break; case ui::AX_ROLE_TREE_GRID: - ia_role = ROLE_SYSTEM_OUTLINE; + ia_role_ = ROLE_SYSTEM_OUTLINE; break; case ui::AX_ROLE_TREE_ITEM: - ia_role = ROLE_SYSTEM_OUTLINEITEM; + ia_role_ = ROLE_SYSTEM_OUTLINEITEM; break; case ui::AX_ROLE_LINE_BREAK: - ia_role = ROLE_SYSTEM_WHITESPACE; + ia_role_ = ROLE_SYSTEM_WHITESPACE; break; case ui::AX_ROLE_WINDOW: - ia_role = ROLE_SYSTEM_WINDOW; + ia_role_ = ROLE_SYSTEM_WINDOW; break; // TODO(dmazzoni): figure out the proper MSAA role for all of these. @@ -4009,7 +3870,7 @@ void BrowserAccessibilityWin::InitRoleAndState() { case ui::AX_ROLE_PRESENTATIONAL: case ui::AX_ROLE_SLIDER_THUMB: default: - ia_role = ROLE_SYSTEM_CLIENT; + ia_role_ = ROLE_SYSTEM_CLIENT; break; } @@ -4020,27 +3881,21 @@ void BrowserAccessibilityWin::InitRoleAndState() { // We clear the READONLY state on focusable controls and on a document. // Everything else, the majority of objects, do not have this state set. if (HasState(ui::AX_STATE_FOCUSABLE) && - ia_role != ROLE_SYSTEM_DOCUMENT) { - ia_state &= ~(STATE_SYSTEM_READONLY); + ia_role_ != ROLE_SYSTEM_DOCUMENT) { + ia_state_ &= ~(STATE_SYSTEM_READONLY); } if (!HasState(ui::AX_STATE_READ_ONLY)) - ia_state &= ~(STATE_SYSTEM_READONLY); + ia_state_ &= ~(STATE_SYSTEM_READONLY); if (GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) - ia_state |= STATE_SYSTEM_READONLY; + ia_state_ |= STATE_SYSTEM_READONLY; // The role should always be set. - DCHECK(!role_name.empty() || ia_role); + DCHECK(!role_name_.empty() || ia_role_); // If we didn't explicitly set the IAccessible2 role, make it the same // as the MSAA role. - if (!ia2_role) - ia2_role = ia_role; - - win_attributes_->ia_role = ia_role; - win_attributes_->ia_state = ia_state; - win_attributes_->role_name = role_name; - win_attributes_->ia2_role = ia2_role; - win_attributes_->ia2_state = ia2_state; + if (!ia2_role_) + ia2_role_ = ia_role_; } } // namespace content |