diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 07:19:43 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 07:19:43 +0000 |
commit | 99d408fcb81c8ed37dba37f01d2ebd7f43ccd1cc (patch) | |
tree | 2a72038fca958c780b7069277cc81b77324607e6 | |
parent | 2c5019c643e3b5b07aaf13f3967463a6d7dc4b00 (diff) | |
download | chromium_src-99d408fcb81c8ed37dba37f01d2ebd7f43ccd1cc.zip chromium_src-99d408fcb81c8ed37dba37f01d2ebd7f43ccd1cc.tar.gz chromium_src-99d408fcb81c8ed37dba37f01d2ebd7f43ccd1cc.tar.bz2 |
Make browser_accessibility fields private.
This will help with future refactoring so that we
can move data out of BrowserAccessibility and into
AXNode.
BUG=316726
Review URL: https://codereview.chromium.org/97813002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238625 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 271 insertions, 261 deletions
diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index 701010f..1258803 100644 --- a/content/browser/accessibility/browser_accessibility.h +++ b/content/browser/accessibility/browser_accessibility.h @@ -165,12 +165,15 @@ class CONTENT_EXPORT BrowserAccessibility { gfx::Rect location() const { return location_; } BrowserAccessibilityManager* manager() const { return manager_; } const std::string& name() const { return name_; } + const std::string& value() const { return value_; } int32 renderer_id() const { return renderer_id_; } int32 role() const { return role_; } int32 state() const { return state_; } - const std::string& value() const { return value_; } bool instance_active() const { return instance_active_; } + void set_name(const std::string& name) { name_ = name; } + void set_value(const std::string& value) { value_ = value; } + #if defined(OS_MACOSX) && __OBJC__ BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); #elif defined(OS_WIN) @@ -278,6 +281,7 @@ class CONTENT_EXPORT BrowserAccessibility { // The parent of this object, may be NULL if we're the root object. BrowserAccessibility* parent_; + private: // The index of this within its parent object. int32 index_in_parent_; diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc index d5920be..6e677cb 100644 --- a/content/browser/accessibility/browser_accessibility_android.cc +++ b/content/browser/accessibility/browser_accessibility_android.cc @@ -374,14 +374,14 @@ void BrowserAccessibilityAndroid::PostInitialize() { BrowserAccessibility::PostInitialize(); if (IsEditableText()) { - if (base::UTF8ToUTF16(value_) != new_value_) { + if (base::UTF8ToUTF16(value()) != new_value_) { old_value_ = new_value_; - new_value_ = base::UTF8ToUTF16(value_); + new_value_ = base::UTF8ToUTF16(value()); } } - if (role_ == blink::WebAXRoleAlert && first_time_) - manager_->NotifyAccessibilityEvent(blink::WebAXEventAlert, this); + if (role() == blink::WebAXRoleAlert && first_time_) + manager()->NotifyAccessibilityEvent(blink::WebAXEventAlert, this); base::string16 live; if (GetString16Attribute( @@ -401,7 +401,7 @@ void BrowserAccessibilityAndroid::NotifyLiveRegionUpdate( base::string16 text = GetText(); if (cached_text_ != text) { if (!text.empty()) { - manager_->NotifyAccessibilityEvent(blink::WebAXEventShow, + manager()->NotifyAccessibilityEvent(blink::WebAXEventShow, this); } cached_text_ = text; diff --git a/content/browser/accessibility/browser_accessibility_gtk.cc b/content/browser/accessibility/browser_accessibility_gtk.cc index c89aa2b..06a164c 100644 --- a/content/browser/accessibility/browser_accessibility_gtk.cc +++ b/content/browser/accessibility/browser_accessibility_gtk.cc @@ -475,7 +475,7 @@ bool BrowserAccessibilityGtk::IsNative() const { } void BrowserAccessibilityGtk::InitRoleAndState() { - switch(role_) { + switch(role()) { case blink::WebAXRoleDocument: case blink::WebAXRoleRootWebArea: case blink::WebAXRoleWebArea: diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc index fe21c82..b43154a 100644 --- a/content/browser/accessibility/browser_accessibility_win.cc +++ b/content/browser/accessibility/browser_accessibility_win.cc @@ -217,27 +217,27 @@ BrowserAccessibilityWin::~BrowserAccessibilityWin() { // IAccessible methods. // // Conventions: -// * Always test for instance_active_ first and return E_FAIL if it's false. +// * Always test for instance_active() first and return E_FAIL if it's false. // * Always check for invalid arguments first, even if they're unused. // * Return S_FALSE if the only output is a string argument and it's empty. // HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); if (!target) return E_INVALIDARG; - manager_->DoDefaultAction(*target); + manager()->DoDefaultAction(*target); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, LONG y_top, VARIANT* child) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!child) @@ -267,7 +267,7 @@ STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, LONG* width, LONG* height, VARIANT var_id) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!x_left || !y_top || !width || !height) @@ -337,7 +337,7 @@ STDMETHODIMP BrowserAccessibilityWin::accNavigate(LONG nav_dir, STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, IDispatch** disp_child) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!disp_child) @@ -354,7 +354,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, } STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!child_count) @@ -367,7 +367,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, BSTR* def_action) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!def_action) @@ -383,7 +383,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, BSTR* desc) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!desc) @@ -398,14 +398,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, } STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!focus_child) return E_INVALIDARG; BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>( - manager_->GetFocus(this)); + manager()->GetFocus(this)); if (focus == this) { focus_child->vt = VT_I4; focus_child->lVal = CHILDID_SELF; @@ -420,7 +420,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { } STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!help) @@ -436,7 +436,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, BSTR* acc_key) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!acc_key) @@ -451,7 +451,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, } STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!name) @@ -469,7 +469,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { if (target->GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT, &title_elem_id)) { BrowserAccessibility* title_elem = - manager_->GetFromRendererID(title_elem_id); + manager()->GetFromRendererID(title_elem_id); if (title_elem) name_str = title_elem->GetTextRecursive(); } @@ -485,31 +485,33 @@ STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { } STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!disp_parent) return E_INVALIDARG; - IAccessible* parent = parent_->ToBrowserAccessibilityWin(); - if (parent == NULL) { + IAccessible* parent_obj = parent()->ToBrowserAccessibilityWin(); + if (parent_obj == NULL) { // This happens if we're the root of the tree; // return the IAccessible for the window. - parent = manager_->ToBrowserAccessibilityManagerWin()->parent_iaccessible(); + parent_obj = + manager()->ToBrowserAccessibilityManagerWin()->parent_iaccessible(); + // |parent| can only be NULL if the manager was created before the parent // IAccessible was known and it wasn't subsequently set before a client // requested it. Crash hard if this happens so that we get crash reports. - CHECK(parent); + CHECK(parent_obj); } - parent->AddRef(); - *disp_parent = parent; + parent_obj->AddRef(); + *disp_parent = parent_obj; return S_OK; } STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, VARIANT* role) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!role) @@ -531,7 +533,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, VARIANT* state) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!state) @@ -543,7 +545,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, state->vt = VT_I4; state->lVal = target->ia_state_; - if (manager_->GetFocus(NULL) == this) + if (manager()->GetFocus(NULL) == this) state->lVal |= STATE_SYSTEM_FOCUSED; return S_OK; @@ -551,7 +553,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, BSTR* value) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!value) @@ -599,15 +601,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, } STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; - if (role_ != blink::WebAXRoleListBox) + if (blink_role() != blink::WebAXRoleListBox) return E_NOTIMPL; unsigned long selected_count = 0; - for (size_t i = 0; i < children_.size(); ++i) { - if (children_[i]->HasState(blink::WebAXStateSelected)) + for (size_t i = 0; i < children().size(); ++i) { + if (children()[i]->HasState(blink::WebAXStateSelected)) ++selected_count; } @@ -617,11 +619,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { } if (selected_count == 1) { - for (size_t i = 0; i < children_.size(); ++i) { - if (children_[i]->HasState(blink::WebAXStateSelected)) { + for (size_t i = 0; i < children().size(); ++i) { + if (children()[i]->HasState(blink::WebAXStateSelected)) { selected->vt = VT_DISPATCH; selected->pdispVal = - children_[i]->ToBrowserAccessibilityWin()->NewReference(); + children()[i]->ToBrowserAccessibilityWin()->NewReference(); return S_OK; } } @@ -632,11 +634,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { new base::win::EnumVariant(selected_count); enum_variant->AddRef(); unsigned long index = 0; - for (size_t i = 0; i < children_.size(); ++i) { - if (children_[i]->HasState(blink::WebAXStateSelected)) { + for (size_t i = 0; i < children().size(); ++i) { + if (children()[i]->HasState(blink::WebAXStateSelected)) { enum_variant->ItemAt(index)->vt = VT_DISPATCH; enum_variant->ItemAt(index)->pdispVal = - children_[i]->ToBrowserAccessibilityWin()->NewReference(); + children()[i]->ToBrowserAccessibilityWin()->NewReference(); ++index; } } @@ -648,11 +650,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { STDMETHODIMP BrowserAccessibilityWin::accSelect( LONG flags_sel, VARIANT var_id) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (flags_sel & SELFLAG_TAKEFOCUS) { - manager_->SetFocus(this, true); + manager()->SetFocus(this, true); return S_OK; } @@ -664,7 +666,7 @@ STDMETHODIMP BrowserAccessibilityWin::accSelect( // STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!role) @@ -676,7 +678,7 @@ STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { } STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!attributes) @@ -700,7 +702,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { } STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!states) @@ -712,7 +714,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { } STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!unique_id) @@ -723,29 +725,29 @@ STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { } STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!window_handle) return E_INVALIDARG; - *window_handle = manager_->ToBrowserAccessibilityManagerWin()->parent_hwnd(); + *window_handle = manager()->ToBrowserAccessibilityManagerWin()->parent_hwnd(); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!index_in_parent) return E_INVALIDARG; - *index_in_parent = index_in_parent_; + *index_in_parent = this->index_in_parent(); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!n_relations) @@ -758,7 +760,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) { STDMETHODIMP BrowserAccessibilityWin::get_relation( LONG relation_index, IAccessibleRelation** relation) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (relation_index < 0 || @@ -778,7 +780,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_relations( LONG max_relations, IAccessibleRelation** relations, LONG* n_relations) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!relations || !n_relations) @@ -798,41 +800,41 @@ STDMETHODIMP BrowserAccessibilityWin::get_relations( } STDMETHODIMP BrowserAccessibilityWin::scrollTo(enum IA2ScrollType scroll_type) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; - gfx::Rect r = location_; + gfx::Rect r = location(); switch(scroll_type) { case IA2_SCROLL_TYPE_TOP_LEFT: - manager_->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); + manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); break; case IA2_SCROLL_TYPE_BOTTOM_RIGHT: - manager_->ScrollToMakeVisible( + manager()->ScrollToMakeVisible( *this, gfx::Rect(r.right(), r.bottom(), 0, 0)); break; case IA2_SCROLL_TYPE_TOP_EDGE: - manager_->ScrollToMakeVisible( + manager()->ScrollToMakeVisible( *this, gfx::Rect(r.x(), r.y(), r.width(), 0)); break; case IA2_SCROLL_TYPE_BOTTOM_EDGE: - manager_->ScrollToMakeVisible( + manager()->ScrollToMakeVisible( *this, gfx::Rect(r.x(), r.bottom(), r.width(), 0)); break; case IA2_SCROLL_TYPE_LEFT_EDGE: - manager_->ScrollToMakeVisible( + manager()->ScrollToMakeVisible( *this, gfx::Rect(r.x(), r.y(), 0, r.height())); break; case IA2_SCROLL_TYPE_RIGHT_EDGE: - manager_->ScrollToMakeVisible( + manager()->ScrollToMakeVisible( *this, gfx::Rect(r.right(), r.y(), 0, r.height())); break; case IA2_SCROLL_TYPE_ANYWHERE: default: - manager_->ScrollToMakeVisible(*this, r); + manager()->ScrollToMakeVisible(*this, r); break; } - manager_->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); + manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); return S_OK; } @@ -841,22 +843,22 @@ STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( enum IA2CoordinateType coordinate_type, LONG x, LONG y) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; gfx::Point scroll_to(x, y); if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { - scroll_to -= manager_->GetViewBounds().OffsetFromOrigin(); + scroll_to -= manager()->GetViewBounds().OffsetFromOrigin(); } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { - if (parent_) - scroll_to += parent_->location().OffsetFromOrigin(); + if (parent()) + scroll_to += parent()->location().OffsetFromOrigin(); } else { return E_INVALIDARG; } - manager_->ScrollToPoint(*this, scroll_to); - manager_->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); + manager()->ScrollToPoint(*this, scroll_to); + manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); return S_OK; } @@ -865,18 +867,18 @@ STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( LONG* group_level, LONG* similar_items_in_group, LONG* position_in_group) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!group_level || !similar_items_in_group || !position_in_group) return E_INVALIDARG; - if (role_ == blink::WebAXRoleListBoxOption && - parent_ && - parent_->role() == blink::WebAXRoleListBox) { + if (blink_role() == blink::WebAXRoleListBoxOption && + parent() && + parent()->role() == blink::WebAXRoleListBox) { *group_level = 0; - *similar_items_in_group = parent_->PlatformChildCount(); - *position_in_group = index_in_parent_ + 1; + *similar_items_in_group = parent()->PlatformChildCount(); + *position_in_group = index_in_parent() + 1; return S_OK; } @@ -888,7 +890,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( // STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { - // No need to check |instance_active_| because this interface is + // No need to check |instance_active()| because this interface is // global, and doesn't depend on any local state. if (!app_name) @@ -907,7 +909,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { } STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { - // No need to check |instance_active_| because this interface is + // No need to check |instance_active()| because this interface is // global, and doesn't depend on any local state. if (!app_version) @@ -926,7 +928,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { } STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { - // No need to check |instance_active_| because this interface is + // No need to check |instance_active()| because this interface is // global, and doesn't depend on any local state. if (!toolkit_name) @@ -942,7 +944,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { STDMETHODIMP BrowserAccessibilityWin::get_toolkitVersion( BSTR* toolkit_version) { - // No need to check |instance_active_| because this interface is + // No need to check |instance_active()| because this interface is // global, and doesn't depend on any local state. if (!toolkit_version) @@ -959,7 +961,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_toolkitVersion( // STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!desc) @@ -973,7 +975,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( enum IA2CoordinateType coordinate_type, LONG* x, LONG* y) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!x || !y) @@ -981,17 +983,17 @@ STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { HWND parent_hwnd = - manager_->ToBrowserAccessibilityManagerWin()->parent_hwnd(); + manager()->ToBrowserAccessibilityManagerWin()->parent_hwnd(); POINT top_left = {0, 0}; ::ClientToScreen(parent_hwnd, &top_left); - *x = location_.x() + top_left.x; - *y = location_.y() + top_left.y; + *x = location().x() + top_left.x; + *y = location().y() + top_left.y; } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { - *x = location_.x(); - *y = location_.y(); - if (parent_) { - *x -= parent_->location().x(); - *y -= parent_->location().y(); + *x = location().x(); + *y = location().y(); + if (parent()) { + *x -= parent()->location().x(); + *y -= parent()->location().y(); } } else { return E_INVALIDARG; @@ -1001,14 +1003,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( } STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!height || !width) return E_INVALIDARG; - *height = location_.height(); - *width = location_.width(); + *height = location().height(); + *width = location().width(); return S_OK; } @@ -1020,7 +1022,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt( long row, long column, IUnknown** accessible) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!accessible) @@ -1056,7 +1058,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt( } STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!accessible) @@ -1069,7 +1071,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row, long column, long* cell_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!cell_index) @@ -1107,7 +1109,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row, STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, BSTR* description) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!description) @@ -1131,8 +1133,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, for (int i = 0; i < rows; ++i) { int cell_id = cell_ids[i * columns + column]; BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( - manager_->GetFromRendererID(cell_id)); - if (cell && cell->role_ == blink::WebAXRoleColumnHeader) { + manager()->GetFromRendererID(cell_id)); + if (cell && cell->blink_role() == blink::WebAXRoleColumnHeader) { base::string16 cell_name = cell->GetString16Attribute( AccessibilityNodeData::ATTR_NAME); if (cell_name.size() > 0) { @@ -1152,7 +1154,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( long row, long column, long* n_columns_spanned) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!n_columns_spanned) @@ -1175,7 +1177,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( AccessibilityNodeData::ATTR_CELL_IDS); int cell_id = cell_ids[row * columns + column]; BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( - manager_->GetFromRendererID(cell_id)); + manager()->GetFromRendererID(cell_id)); int colspan; if (cell && cell->GetIntAttribute( @@ -1197,7 +1199,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, long* column_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!column_index) @@ -1213,7 +1215,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, int cell_id = unique_cell_ids[cell_index]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); int col_index; if (cell && cell->GetIntAttribute( @@ -1226,7 +1228,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, } STDMETHODIMP BrowserAccessibilityWin::get_nColumns(long* column_count) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!column_count) @@ -1243,7 +1245,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nColumns(long* column_count) { } STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!row_count) @@ -1259,7 +1261,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) { } STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!cell_count) @@ -1271,7 +1273,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) { } STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!column_count) @@ -1282,7 +1284,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) { } STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!row_count) @@ -1294,7 +1296,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) { STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, BSTR* description) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!description) @@ -1318,8 +1320,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, for (int i = 0; i < columns; ++i) { int cell_id = cell_ids[row * columns + i]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); - if (cell && cell->role_ == blink::WebAXRoleRowHeader) { + manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + if (cell && cell->blink_role() == blink::WebAXRoleRowHeader) { base::string16 cell_name = cell->GetString16Attribute( AccessibilityNodeData::ATTR_NAME); if (cell_name.size() > 0) { @@ -1338,7 +1340,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, long column, long* n_rows_spanned) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!n_rows_spanned) @@ -1361,7 +1363,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, AccessibilityNodeData::ATTR_CELL_IDS); int cell_id = cell_ids[row * columns + column]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); int rowspan; if (cell && cell->GetIntAttribute( @@ -1383,7 +1385,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, long* row_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!row_index) @@ -1399,7 +1401,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, int cell_id = unique_cell_ids[cell_index]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); int cell_row_index; if (cell && cell->GetIntAttribute( @@ -1414,7 +1416,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children, long** children, long* n_children) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!children || !n_children) @@ -1428,7 +1430,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children, STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns, long** columns, long* n_columns) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!columns || !n_columns) @@ -1442,7 +1444,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns, STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows, long** rows, long* n_rows) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!rows || !n_rows) @@ -1454,7 +1456,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows, } STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!accessible) @@ -1467,7 +1469,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) { STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( long column, boolean* is_selected) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!is_selected) @@ -1480,7 +1482,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row, boolean* is_selected) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!is_selected) @@ -1494,7 +1496,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row, STDMETHODIMP BrowserAccessibilityWin::get_isSelected(long row, long column, boolean* is_selected) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!is_selected) @@ -1512,7 +1514,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( long* row_extents, long* column_extents, boolean* is_selected) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!row || !column || !row_extents || !column_extents || !is_selected) @@ -1528,7 +1530,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( int cell_id = unique_cell_ids[index]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); int rowspan; int colspan; if (cell && @@ -1563,7 +1565,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( IUnknown*** cells, long* n_selected_cells) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!cells || !n_selected_cells) @@ -1576,7 +1578,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns, long* n_columns) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!columns || !n_columns) @@ -1589,7 +1591,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns, STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows, long* n_rows) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!rows || !n_rows) @@ -1607,7 +1609,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows, STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( long* n_columns_spanned) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!n_columns_spanned) @@ -1627,7 +1629,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( IUnknown*** cell_accessibles, long* n_column_header_cells) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!cell_accessibles || !n_column_header_cells) @@ -1666,8 +1668,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( for (int i = 0; i < rows; ++i) { int cell_id = cell_ids[i * columns + column]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); - if (cell && cell->role_ == blink::WebAXRoleColumnHeader) + manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + if (cell && cell->blink_role() == blink::WebAXRoleColumnHeader) (*n_column_header_cells)++; } @@ -1676,11 +1678,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( int index = 0; for (int i = 0; i < rows; ++i) { int cell_id = cell_ids[i * columns + column]; - BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); - if (cell && cell->role_ == blink::WebAXRoleColumnHeader) { - (*cell_accessibles)[index] = - static_cast<IAccessible*>(cell->NewReference()); + BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); + if (cell && cell->role() == blink::WebAXRoleColumnHeader) { + (*cell_accessibles)[index] = static_cast<IAccessible*>( + cell->ToBrowserAccessibilityWin()->NewReference()); ++index; } } @@ -1689,7 +1690,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( } STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!column_index) @@ -1706,7 +1707,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { } STDMETHODIMP BrowserAccessibilityWin::get_rowExtent(long* n_rows_spanned) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!n_rows_spanned) @@ -1726,7 +1727,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowExtent(long* n_rows_spanned) { STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( IUnknown*** cell_accessibles, long* n_row_header_cells) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!cell_accessibles || !n_row_header_cells) @@ -1764,9 +1765,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( for (int i = 0; i < columns; ++i) { int cell_id = cell_ids[row * columns + i]; - BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); - if (cell && cell->role_ == blink::WebAXRoleRowHeader) + BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); + if (cell && cell->role() == blink::WebAXRoleRowHeader) (*n_row_header_cells)++; } @@ -1775,11 +1775,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( int index = 0; for (int i = 0; i < columns; ++i) { int cell_id = cell_ids[row * columns + i]; - BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); - if (cell && cell->role_ == blink::WebAXRoleRowHeader) { - (*cell_accessibles)[index] = - static_cast<IAccessible*>(cell->NewReference()); + BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); + if (cell && cell->role() == blink::WebAXRoleRowHeader) { + (*cell_accessibles)[index] = static_cast<IAccessible*>( + cell->ToBrowserAccessibilityWin()->NewReference()); ++index; } } @@ -1788,7 +1787,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( } STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!row_index) @@ -1803,7 +1802,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { } STDMETHODIMP BrowserAccessibilityWin::get_isSelected(boolean* is_selected) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!is_selected) @@ -1819,7 +1818,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtents( long* row_extents, long* column_extents, boolean* is_selected) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!row_index || @@ -1853,7 +1852,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtents( } STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!table) @@ -1884,7 +1883,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { // STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!n_characters) @@ -1895,15 +1894,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { } STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!offset) return E_INVALIDARG; *offset = 0; - if (role_ == blink::WebAXRoleTextField || - role_ == blink::WebAXRoleTextArea) { + if (blink_role() == blink::WebAXRoleTextField || + blink_role() == blink::WebAXRoleTextArea) { int sel_start = 0; if (GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_START, &sel_start)) @@ -1920,7 +1919,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( LONG* out_y, LONG* out_width, LONG* out_height) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!out_x || !out_y || !out_width || !out_height) @@ -1932,7 +1931,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( if (offset < 0 || offset > static_cast<LONG>(text_str.size())) return E_INVALIDARG; - if (role_ != blink::WebAXRoleStaticText) + if (blink_role() != blink::WebAXRoleStaticText) return E_FAIL; gfx::Rect character_bounds; @@ -1954,15 +1953,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( } STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!n_selections) return E_INVALIDARG; *n_selections = 0; - if (role_ == blink::WebAXRoleTextField || - role_ == blink::WebAXRoleTextArea) { + if (blink_role() == blink::WebAXRoleTextField || + blink_role() == blink::WebAXRoleTextArea) { int sel_start = 0; int sel_end = 0; if (GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_START, @@ -1978,7 +1977,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, LONG* start_offset, LONG* end_offset) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!start_offset || !end_offset || selection_index != 0) @@ -1986,8 +1985,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, *start_offset = 0; *end_offset = 0; - if (role_ == blink::WebAXRoleTextField || - role_ == blink::WebAXRoleTextArea) { + if (blink_role() == blink::WebAXRoleTextField || + blink_role() == blink::WebAXRoleTextArea) { int sel_start = 0; int sel_end = 0; if (GetIntAttribute( @@ -2004,7 +2003,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, LONG end_offset, BSTR* text) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!text) @@ -2047,7 +2046,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( LONG* start_offset, LONG* end_offset, BSTR* text) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!start_offset || !end_offset || !text) @@ -2077,7 +2076,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( LONG* start_offset, LONG* end_offset, BSTR* text) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!start_offset || !end_offset || !text) @@ -2106,7 +2105,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( LONG* start_offset, LONG* end_offset, BSTR* text) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!start_offset || !end_offset || !text) @@ -2130,7 +2129,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( } STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!new_text) @@ -2145,7 +2144,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { } STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!old_text) @@ -2162,7 +2161,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( LONG y, enum IA2CoordinateType coord_type, LONG* offset) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!offset) @@ -2194,42 +2193,42 @@ STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, LONG end_offset) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; const base::string16& text_str = TextForIAccessibleText(); HandleSpecialTextOffset(text_str, &start_offset); HandleSpecialTextOffset(text_str, &end_offset); - manager_->SetTextSelection(*this, start_offset, end_offset); + manager()->SetTextSelection(*this, start_offset, end_offset); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (selection_index != 0) return E_INVALIDARG; - manager_->SetTextSelection(*this, 0, 0); + manager()->SetTextSelection(*this, 0, 0); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; const base::string16& text_str = TextForIAccessibleText(); HandleSpecialTextOffset(text_str, &offset); - manager_->SetTextSelection(*this, offset, offset); + manager()->SetTextSelection(*this, offset, offset); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, LONG start_offset, LONG end_offset) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (selection_index != 0) @@ -2239,7 +2238,7 @@ STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, HandleSpecialTextOffset(text_str, &start_offset); HandleSpecialTextOffset(text_str, &end_offset); - manager_->SetTextSelection(*this, start_offset, end_offset); + manager()->SetTextSelection(*this, start_offset, end_offset); return S_OK; } @@ -2248,7 +2247,7 @@ STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, // STDMETHODIMP BrowserAccessibilityWin::get_nHyperlinks(long* hyperlink_count) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!hyperlink_count) @@ -2261,7 +2260,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nHyperlinks(long* hyperlink_count) { STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( long index, IAccessibleHyperlink** hyperlink) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!hyperlink || @@ -2271,7 +2270,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( } BrowserAccessibilityWin* child = - children_[hyperlinks_[index]]->ToBrowserAccessibilityWin(); + children()[hyperlinks_[index]]->ToBrowserAccessibilityWin(); *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); return S_OK; } @@ -2279,7 +2278,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( long char_index, long* hyperlink_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!hyperlink_index) @@ -2304,7 +2303,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( // STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!value) @@ -2323,7 +2322,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { } STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!value) @@ -2342,7 +2341,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { } STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!value) @@ -2370,7 +2369,7 @@ STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) { // STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!url) @@ -2380,7 +2379,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { } STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!title) @@ -2390,7 +2389,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) { } STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!mime_type) @@ -2401,7 +2400,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) { } STDMETHODIMP BrowserAccessibilityWin::get_docType(BSTR* doc_type) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!doc_type) @@ -2422,7 +2421,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( unsigned int* num_children, unsigned int* unique_id, unsigned short* node_type) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!node_name || !name_space_id || !node_value || !num_children || @@ -2437,7 +2436,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( *node_name = NULL; *name_space_id = 0; - *node_value = SysAllocString(UTF8ToUTF16(value_).c_str()); + *node_value = SysAllocString(UTF8ToUTF16(value()).c_str()); *num_children = PlatformChildCount(); *unique_id = unique_id_win_; @@ -2459,22 +2458,22 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributes( short* name_space_id, BSTR* attrib_values, unsigned short* num_attribs) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) return E_INVALIDARG; *num_attribs = max_attribs; - if (*num_attribs > html_attributes_.size()) - *num_attribs = html_attributes_.size(); + if (*num_attribs > html_attributes().size()) + *num_attribs = html_attributes().size(); for (unsigned short i = 0; i < *num_attribs; ++i) { attrib_names[i] = SysAllocString( - UTF8ToUTF16(html_attributes_[i].first).c_str()); + UTF8ToUTF16(html_attributes()[i].first).c_str()); name_space_id[i] = 0; attrib_values[i] = SysAllocString( - UTF8ToUTF16(html_attributes_[i].second).c_str()); + UTF8ToUTF16(html_attributes()[i].second).c_str()); } return S_OK; } @@ -2484,7 +2483,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( BSTR* attrib_names, short* name_space_id, BSTR* attrib_values) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!attrib_names || !name_space_id || !attrib_values) @@ -2494,10 +2493,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( name_space_id[i] = 0; bool found = false; std::string name = UTF16ToUTF8((LPCWSTR)attrib_names[i]); - for (unsigned int j = 0; j < html_attributes_.size(); ++j) { - if (html_attributes_[j].first == name) { + for (unsigned int j = 0; j < html_attributes().size(); ++j) { + if (html_attributes()[j].first == name) { attrib_values[i] = SysAllocString( - UTF8ToUTF16(html_attributes_[j].second).c_str()); + UTF8ToUTF16(html_attributes()[j].second).c_str()); found = true; break; } @@ -2515,7 +2514,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( BSTR* style_properties, BSTR* style_values, unsigned short *num_style_properties) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!style_properties || !style_values) @@ -2542,7 +2541,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( boolean use_alternate_view, BSTR* style_properties, BSTR* style_values) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!style_properties || !style_values) @@ -2571,18 +2570,18 @@ STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { } STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!node) return E_INVALIDARG; - *node = parent_->ToBrowserAccessibilityWin()->NewReference(); + *node = parent()->ToBrowserAccessibilityWin()->NewReference(); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!node) @@ -2598,7 +2597,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { } STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!node) @@ -2616,37 +2615,37 @@ STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( ISimpleDOMNode** node) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!node) return E_INVALIDARG; - if (!parent_ || index_in_parent_ <= 0) { + if (!parent() || index_in_parent() <= 0) { *node = NULL; return S_FALSE; } - *node = parent_->children()[index_in_parent_ - 1]-> + *node = parent()->children()[index_in_parent() - 1]-> ToBrowserAccessibilityWin()->NewReference(); return S_OK; } STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!node) return E_INVALIDARG; - if (!parent_ || - index_in_parent_ < 0 || - index_in_parent_ >= static_cast<int>(parent_->children().size()) - 1) { + if (!parent() || + index_in_parent() < 0 || + index_in_parent() >= static_cast<int>(parent()->children().size()) - 1) { *node = NULL; return S_FALSE; } - *node = parent_->children()[index_in_parent_ + 1]-> + *node = parent()->children()[index_in_parent() + 1]-> ToBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2654,7 +2653,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { STDMETHODIMP BrowserAccessibilityWin::get_childAt( unsigned int child_index, ISimpleDOMNode** node) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!node) @@ -2678,7 +2677,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_childAt( // STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!dom_text) @@ -2708,7 +2707,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( int* out_y, int* out_width, int* out_height) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; if (!out_x || !out_y || !out_width || !out_height) @@ -2721,7 +2720,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( return E_INVALIDARG; } - if (role_ != blink::WebAXRoleStaticText) + if (blink_role() != blink::WebAXRoleStaticText) return E_FAIL; gfx::Rect bounds = GetGlobalBoundsForRange( @@ -2736,7 +2735,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( unsigned int start_index, unsigned int end_index) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; const base::string16& text_str = TextForIAccessibleText(); @@ -2746,9 +2745,9 @@ STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( return E_INVALIDARG; } - manager_->ScrollToMakeVisible(*this, GetLocalBoundsForRange( + manager()->ScrollToMakeVisible(*this, GetLocalBoundsForRange( start_index, end_index - start_index)); - manager_->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); + manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); return S_OK; } @@ -2760,7 +2759,7 @@ STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guidService, REFIID riid, void** object) { - if (!instance_active_) + if (!instance_active()) return E_FAIL; // The system uses IAccessible APIs for many purposes, but only @@ -2773,7 +2772,7 @@ STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guidService, // Special Mozilla extension: return the accessible for the root document. // Screen readers use this to distinguish between a document loaded event // on the root document vs on an iframe. - return manager_->GetRoot()->ToBrowserAccessibilityWin()->QueryInterface( + return manager()->GetRoot()->ToBrowserAccessibilityWin()->QueryInterface( IID_IAccessible2, object); } @@ -2819,7 +2818,7 @@ STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, if (IsEditableText()) { // The BrowserAccessibilityManager keeps track of instances when // we don't want to show the on-screen keyboard. - if (!manager_->IsOSKAllowed(GetGlobalBoundsRect())) + if (!manager()->IsOSKAllowed(GetGlobalBoundsRect())) return E_NOTIMPL; DVLOG(1) << "Returning UIA text provider"; @@ -2910,13 +2909,13 @@ void BrowserAccessibilityWin::PreInitialize() { IntAttributeToIA2(AccessibilityNodeData::ATTR_HIERARCHICAL_LEVEL, "level"); // Expose the set size and position in set for listbox options. - if (role_ == blink::WebAXRoleListBoxOption && - parent_ && - parent_->role() == blink::WebAXRoleListBox) { + if (blink_role() == blink::WebAXRoleListBoxOption && + parent() && + parent()->role() == blink::WebAXRoleListBox) { ia2_attributes_.push_back( - L"setsize:" + base::IntToString16(parent_->PlatformChildCount())); + L"setsize:" + base::IntToString16(parent()->PlatformChildCount())); ia2_attributes_.push_back( - L"setsize:" + base::IntToString16(index_in_parent_ + 1)); + L"setsize:" + base::IntToString16(index_in_parent() + 1)); } if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || @@ -2957,7 +2956,7 @@ void BrowserAccessibilityWin::PreInitialize() { const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); for (size_t i = 0; i < unique_cell_ids.size(); ++i) { - if (unique_cell_ids[i] == renderer_id_) { + if (unique_cell_ids[i] == renderer_id()) { ia2_attributes_.push_back( base::string16(L"table-cell-index:") + base::IntToString16(i)); } @@ -3007,25 +3006,25 @@ void BrowserAccessibilityWin::PreInitialize() { // 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. std::string placeholder; - if (role_ == blink::WebAXRoleTextField && + if (blink_role() == blink::WebAXRoleTextField && HasState(blink::WebAXStateFocusable) && 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; } @@ -3035,25 +3034,27 @@ void BrowserAccessibilityWin::PreInitialize() { SetStringAttribute(AccessibilityNodeData::ATTR_HELP, help); // On Windows, the value of a document should be its url. - if (role_ == blink::WebAXRoleRootWebArea || - role_ == blink::WebAXRoleWebArea) { - GetStringAttribute(AccessibilityNodeData::ATTR_DOC_URL, &value_); + if (blink_role() == blink::WebAXRoleRootWebArea || + blink_role() == blink::WebAXRoleWebArea) { + set_value(GetStringAttribute(AccessibilityNodeData::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() && - (role_ == blink::WebAXRoleListBoxOption || - role_ == blink::WebAXRoleStaticText || - role_ == blink::WebAXRoleListMarker)) { - name_.swap(value_); + if (name().empty() && + (blink_role() == blink::WebAXRoleListBoxOption || + blink_role() == blink::WebAXRoleStaticText || + blink_role() == blink::WebAXRoleListMarker)) { + 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)) - GetStringAttribute(AccessibilityNodeData::ATTR_URL, &value_); + if (value().empty() && (ia_state_ & STATE_SYSTEM_LINKED)) + set_value(GetStringAttribute(AccessibilityNodeData::ATTR_URL)); // Clear any old relationships between this node and other nodes. for (size_t i = 0; i < relations_.size(); ++i) @@ -3094,14 +3095,14 @@ void BrowserAccessibilityWin::PostInitialize() { DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); // Fire an event when an alert first appears. - if (role_ == blink::WebAXRoleAlert && first_time_) - manager_->NotifyAccessibilityEvent(blink::WebAXEventAlert, this); + if (blink_role() == blink::WebAXRoleAlert && first_time_) + manager()->NotifyAccessibilityEvent(blink::WebAXEventAlert, this); // Fire events if text has changed. base::string16 text = TextForIAccessibleText(); if (previous_text_ != text) { if (!previous_text_.empty() && !text.empty()) { - manager_->NotifyAccessibilityEvent( + manager()->NotifyAccessibilityEvent( blink::WebAXEventShow, this); } @@ -3114,13 +3115,13 @@ void BrowserAccessibilityWin::PostInitialize() { // Fire events if the state has changed. if (!first_time_ && ia_state_ != old_ia_state_) { BrowserAccessibilityManagerWin* manager = - manager_->ToBrowserAccessibilityManagerWin(); + this->manager()->ToBrowserAccessibilityManagerWin(); // 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 (role_ == blink::WebAXRoleListBoxOption && + if (blink_role() == blink::WebAXRoleListBoxOption && (ia_state_ & STATE_SYSTEM_FOCUSABLE) && (ia_state_ & STATE_SYSTEM_SELECTABLE) && (ia_state_ & STATE_SYSTEM_FOCUSED) && @@ -3158,7 +3159,7 @@ bool BrowserAccessibilityWin::IsNative() const { void BrowserAccessibilityWin::SetLocation(const gfx::Rect& new_location) { BrowserAccessibility::SetLocation(new_location); - manager_->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( + manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( EVENT_OBJECT_LOCATIONCHANGE, unique_id_win()); } @@ -3179,7 +3180,7 @@ BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) return PlatformGetChild(child_id - 1)->ToBrowserAccessibilityWin(); - return manager_->ToBrowserAccessibilityManagerWin()-> + return manager()->ToBrowserAccessibilityManagerWin()-> GetFromUniqueIdWin(child_id); } @@ -3230,7 +3231,8 @@ void BrowserAccessibilityWin::IntAttributeToIA2( base::string16 BrowserAccessibilityWin::GetValueText() { float fval; - base::string16 value = UTF8ToUTF16(value_); + base::string16 value = UTF8ToUTF16(this->value()); + if (value.empty() && GetFloatAttribute(AccessibilityNodeData::ATTR_VALUE_FOR_RANGE, &fval)) { value = UTF8ToUTF16(base::DoubleToString(fval)); @@ -3240,9 +3242,9 @@ base::string16 BrowserAccessibilityWin::GetValueText() { base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { if (IsEditableText()) - return UTF8ToUTF16(value_); - return (role_ == blink::WebAXRoleStaticText) ? - UTF8ToUTF16(name_) : hypertext_; + return UTF8ToUTF16(value()); + return (blink_role() == blink::WebAXRoleStaticText) ? + UTF8ToUTF16(name()) : hypertext_; } void BrowserAccessibilityWin::HandleSpecialTextOffset( @@ -3284,7 +3286,7 @@ LONG BrowserAccessibilityWin::FindBoundary( BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( int32 renderer_id) { - return manager_->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin(); + return manager()->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin(); } void BrowserAccessibilityWin::InitRoleAndState() { @@ -3361,7 +3363,7 @@ void BrowserAccessibilityWin::InitRoleAndState() { AccessibilityNodeData::ATTR_HTML_TAG); ia_role_ = 0; ia2_role_ = 0; - switch (role_) { + switch (blink_role()) { case blink::WebAXRoleAlert: ia_role_ = ROLE_SYSTEM_ALERT; break; diff --git a/content/browser/accessibility/browser_accessibility_win.h b/content/browser/accessibility/browser_accessibility_win.h index 992b3d1..a1a36247 100644 --- a/content/browser/accessibility/browser_accessibility_win.h +++ b/content/browser/accessibility/browser_accessibility_win.h @@ -772,6 +772,10 @@ BrowserAccessibilityWin return ia2_attributes_; } + // BrowserAccessibility::role is shadowed by IAccessible2::role, so + // we provide an alias for it. + int32 blink_role() const { return BrowserAccessibility::role(); } + private: // Add one to the reference count and return the same object. Always // use this method when returning a BrowserAccessibilityWin object as |