diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-10 13:15:46 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-10 13:15:46 +0000 |
commit | c1f9be74a4e9d01125fa6f6ae97385e6f6e04a05 (patch) | |
tree | f0003ff0af08ef2b6bfe73a76da7e4c4b09caca1 /content/browser/accessibility | |
parent | 507fd76064b601491556ec91e6945a981a7ded7e (diff) | |
download | chromium_src-c1f9be74a4e9d01125fa6f6ae97385e6f6e04a05.zip chromium_src-c1f9be74a4e9d01125fa6f6ae97385e6f6e04a05.tar.gz chromium_src-c1f9be74a4e9d01125fa6f6ae97385e6f6e04a05.tar.bz2 |
Refactor BrowserAccessibility to prepare for AXNode (re-land)
The only purpose of this change is to rename some member
variables and accessors in BrowserAccessibility so that in the
subsequent change we can repurpose BrowserAccessibility to
make use of AXNode instead.
There should be no code logic changes here - just look at
browser_accessibility.h, everything else just follows from
that.
BUG=316726
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=262673
Review URL: https://codereview.chromium.org/224803005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/accessibility')
16 files changed, 395 insertions, 415 deletions
diff --git a/content/browser/accessibility/accessibility_tree_formatter.cc b/content/browser/accessibility/accessibility_tree_formatter.cc index 999476f..edd366d 100644 --- a/content/browser/accessibility/accessibility_tree_formatter.cc +++ b/content/browser/accessibility/accessibility_tree_formatter.cc @@ -68,7 +68,7 @@ void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree( dict->Set(kChildrenDictAttr, children); for (size_t i = 0; i < node.PlatformChildCount(); ++i) { - BrowserAccessibility* child_node = node.children()[i]; + BrowserAccessibility* child_node = node.InternalGetChild(i); base::DictionaryValue* child_dict = new base::DictionaryValue; children->Append(child_dict); RecursiveBuildAccessibilityTree(*child_node, child_dict); @@ -96,7 +96,7 @@ void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( !defined(TOOLKIT_GTK)) void AccessibilityTreeFormatter::AddProperties(const BrowserAccessibility& node, base::DictionaryValue* dict) { - dict->SetInteger("id", node.renderer_id()); + dict->SetInteger("id", node.GetId()); } base::string16 AccessibilityTreeFormatter::ToString( diff --git a/content/browser/accessibility/accessibility_tree_formatter_gtk.cc b/content/browser/accessibility/accessibility_tree_formatter_gtk.cc index 3891182..d244667 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_gtk.cc +++ b/content/browser/accessibility/accessibility_tree_formatter_gtk.cc @@ -34,7 +34,7 @@ void AccessibilityTreeFormatter::AddProperties(const BrowserAccessibility& node, states->AppendString(atk_state_type_get_name(state_type)); } dict->Set("states", states); - dict->SetInteger("id", node.renderer_id()); + dict->SetInteger("id", node.GetId()); } base::string16 AccessibilityTreeFormatter::ToString( @@ -43,8 +43,10 @@ base::string16 AccessibilityTreeFormatter::ToString( base::string16 line; std::string role_value; node.GetString("role", &role_value); - if (!role_value.empty()) - WriteAttribute(true, base::StringPrintf("[%s]", role_value.c_str()), &line); + if (!role_value.empty()) { + WriteAttribute(true, + base::StringPrintf("[%s]", role_value.c_str()), &line); + } std::string name_value; node.GetString("name", &name_value); diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc index 18a24b4..f2f7e7f 100644 --- a/content/browser/accessibility/browser_accessibility.cc +++ b/content/browser/accessibility/browser_accessibility.cc @@ -27,25 +27,25 @@ BrowserAccessibility* BrowserAccessibility::Create() { BrowserAccessibility::BrowserAccessibility() : manager_(NULL), - parent_(NULL), - index_in_parent_(0), - renderer_id_(0), - role_(0), - state_(0), + deprecated_parent_(NULL), + deprecated_index_in_parent_(0), instance_active_(false) { + data_.id = 0; + data_.role = ui::AX_ROLE_UNKNOWN; + data_.state = 0; } BrowserAccessibility::~BrowserAccessibility() { } bool BrowserAccessibility::PlatformIsLeaf() const { - if (child_count() == 0) + if (InternalChildCount() == 0) return true; // All of these roles may have children that we use as internal // implementation details, but we want to expose them as leaves // to platform accessibility APIs. - switch (role_) { + switch (GetRole()) { case ui::AX_ROLE_EDITABLE_TEXT: case ui::AX_ROLE_SLIDER: case ui::AX_ROLE_STATIC_TEXT: @@ -58,40 +58,32 @@ bool BrowserAccessibility::PlatformIsLeaf() const { } uint32 BrowserAccessibility::PlatformChildCount() const { - return PlatformIsLeaf() ? 0 : children_.size(); + return PlatformIsLeaf() ? 0 : InternalChildCount(); } void BrowserAccessibility::DetachTree( std::vector<BrowserAccessibility*>* nodes) { nodes->push_back(this); - for (size_t i = 0; i < children_.size(); ++i) - children_[i]->DetachTree(nodes); - children_.clear(); - parent_ = NULL; + for (size_t i = 0; i < InternalChildCount(); ++i) + InternalGetChild(i)->DetachTree(nodes); + deprecated_children_.clear(); + deprecated_parent_ = NULL; } void BrowserAccessibility::InitializeTreeStructure( BrowserAccessibilityManager* manager, BrowserAccessibility* parent, - int32 renderer_id, + int32 id, int32 index_in_parent) { manager_ = manager; - parent_ = parent; - renderer_id_ = renderer_id; - index_in_parent_ = index_in_parent; + deprecated_parent_ = parent; + data_.id = id; + deprecated_index_in_parent_ = index_in_parent; } void BrowserAccessibility::InitializeData(const ui::AXNodeData& src) { - DCHECK_EQ(renderer_id_, src.id); - role_ = src.role; - state_ = src.state; - string_attributes_ = src.string_attributes; - int_attributes_ = src.int_attributes; - float_attributes_ = src.float_attributes; - bool_attributes_ = src.bool_attributes; - intlist_attributes_ = src.intlist_attributes; - html_attributes_ = src.html_attributes; - location_ = src.location; + DCHECK_EQ(data_.id, src.id); + data_ = src; instance_active_ = true; GetStringAttribute(ui::AX_ATTR_NAME, &name_); @@ -106,25 +98,25 @@ bool BrowserAccessibility::IsNative() const { void BrowserAccessibility::SwapChildren( std::vector<BrowserAccessibility*>& children) { - children.swap(children_); + children.swap(deprecated_children_); } void BrowserAccessibility::UpdateParent(BrowserAccessibility* parent, int index_in_parent) { - parent_ = parent; - index_in_parent_ = index_in_parent; + deprecated_parent_ = parent; + deprecated_index_in_parent_ = index_in_parent; } void BrowserAccessibility::SetLocation(const gfx::Rect& new_location) { - location_ = new_location; + data_.location = new_location; } bool BrowserAccessibility::IsDescendantOf( BrowserAccessibility* ancestor) { if (this == ancestor) { return true; - } else if (parent_) { - return parent_->IsDescendantOf(ancestor); + } else if (GetParent()) { + return GetParent()->IsDescendantOf(ancestor); } return false; @@ -132,54 +124,55 @@ bool BrowserAccessibility::IsDescendantOf( BrowserAccessibility* BrowserAccessibility::PlatformGetChild( uint32 child_index) const { - DCHECK(child_index < children_.size()); - return children_[child_index]; + DCHECK(child_index < InternalChildCount()); + return InternalGetChild(child_index); } BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() { - if (parent_ && index_in_parent_ > 0) - return parent_->children_[index_in_parent_ - 1]; + if (GetParent() && GetIndexInParent() > 0) + return GetParent()->InternalGetChild(GetIndexInParent() - 1); return NULL; } BrowserAccessibility* BrowserAccessibility::GetNextSibling() { - if (parent_ && - index_in_parent_ >= 0 && - index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { - return parent_->children_[index_in_parent_ + 1]; + if (GetParent() && + GetIndexInParent() >= 0 && + GetIndexInParent() < static_cast<int>( + GetParent()->InternalChildCount() - 1)) { + return GetParent()->InternalGetChild(GetIndexInParent() + 1); } return NULL; } gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { - gfx::Rect bounds = location_; + gfx::Rect bounds = GetLocation(); // Walk up the parent chain. Every time we encounter a Web Area, offset // based on the scroll bars and then offset based on the origin of that // nested web area. - BrowserAccessibility* parent = parent_; + BrowserAccessibility* parent = GetParent(); bool need_to_offset_web_area = - (role_ == ui::AX_ROLE_WEB_AREA || - role_ == ui::AX_ROLE_ROOT_WEB_AREA); + (GetRole() == ui::AX_ROLE_WEB_AREA || + GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); while (parent) { if (need_to_offset_web_area && - parent->location().width() > 0 && - parent->location().height() > 0) { - bounds.Offset(parent->location().x(), parent->location().y()); + parent->GetLocation().width() > 0 && + parent->GetLocation().height() > 0) { + bounds.Offset(parent->GetLocation().x(), parent->GetLocation().y()); need_to_offset_web_area = false; } // On some platforms, we don't want to take the root scroll offsets // into account. - if (parent->role() == ui::AX_ROLE_ROOT_WEB_AREA && + if (parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && !manager()->UseRootScrollOffsetsWhenComputingBounds()) { break; } - if (parent->role() == ui::AX_ROLE_WEB_AREA || - parent->role() == ui::AX_ROLE_ROOT_WEB_AREA) { + if (parent->GetRole() == ui::AX_ROLE_WEB_AREA || + parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) { int sx = 0; int sy = 0; if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && @@ -188,7 +181,7 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { } need_to_offset_web_area = true; } - parent = parent->parent(); + parent = parent->GetParent(); } return bounds; @@ -206,14 +199,14 @@ gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const { gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) const { - if (role() != ui::AX_ROLE_STATIC_TEXT) { + if (GetRole() != ui::AX_ROLE_STATIC_TEXT) { // Apply recursively to all static text descendants. For example, if // you call it on a div with two text node children, it just calls // GetLocalBoundsForRange on each of the two children (adjusting // |start| for each one) and unions the resulting rects. gfx::Rect bounds; - for (size_t i = 0; i < children_.size(); ++i) { - BrowserAccessibility* child = children_[i]; + for (size_t i = 0; i < InternalChildCount(); ++i) { + BrowserAccessibility* child = InternalGetChild(i); int child_len = child->GetStaticTextLenRecursive(); if (start < child_len && start + len > 0) { gfx::Rect child_rect = child->GetLocalBoundsForRange(start, len); @@ -229,9 +222,9 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) int child_end = 0; gfx::Rect bounds; - for (size_t i = 0; i < children_.size() && child_end < start + len; ++i) { - BrowserAccessibility* child = children_[i]; - DCHECK_EQ(child->role(), ui::AX_ROLE_INLINE_TEXT_BOX); + for (size_t i = 0; i < InternalChildCount() && child_end < start + len; ++i) { + BrowserAccessibility* child = InternalGetChild(i); + DCHECK_EQ(child->GetRole(), ui::AX_ROLE_INLINE_TEXT_BOX); std::string child_text; child->GetStringAttribute(ui::AX_ATTR_VALUE, &child_text); int child_len = static_cast<int>(child_text.size()); @@ -247,7 +240,7 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) int local_start = overlap_start - child_start; int local_end = overlap_end - child_start; - gfx::Rect child_rect = child->location(); + gfx::Rect child_rect = child->GetLocation(); int text_direction = child->GetIntAttribute( ui::AX_ATTR_TEXT_DIRECTION); const std::vector<int32>& character_offsets = child->GetIntListAttribute( @@ -328,7 +321,7 @@ BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( // Skip table columns because cells are only contained in rows, // not columns. - if (child->role() == ui::AX_ROLE_COLUMN) + if (child->GetRole() == ui::AX_ROLE_COLUMN) continue; if (child->GetGlobalBoundsRect().Contains(point)) { @@ -358,12 +351,9 @@ BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( } void BrowserAccessibility::Destroy() { - for (std::vector<BrowserAccessibility*>::iterator iter = children_.begin(); - iter != children_.end(); - ++iter) { - (*iter)->Destroy(); - } - children_.clear(); + for (uint32 i = 0; i < InternalChildCount(); i++) + InternalGetChild(i)->Destroy(); + deprecated_children_.clear(); // Allow the object to fire a TextRemoved notification. name_.clear(); @@ -383,8 +373,8 @@ void BrowserAccessibility::NativeReleaseReference() { bool BrowserAccessibility::HasBoolAttribute( ui::AXBoolAttribute attribute) const { - for (size_t i = 0; i < bool_attributes_.size(); ++i) { - if (bool_attributes_[i].first == attribute) + for (size_t i = 0; i < data_.bool_attributes.size(); ++i) { + if (data_.bool_attributes[i].first == attribute) return true; } @@ -394,9 +384,9 @@ bool BrowserAccessibility::HasBoolAttribute( bool BrowserAccessibility::GetBoolAttribute( ui::AXBoolAttribute attribute) const { - for (size_t i = 0; i < bool_attributes_.size(); ++i) { - if (bool_attributes_[i].first == attribute) - return bool_attributes_[i].second; + for (size_t i = 0; i < data_.bool_attributes.size(); ++i) { + if (data_.bool_attributes[i].first == attribute) + return data_.bool_attributes[i].second; } return false; @@ -404,9 +394,9 @@ bool BrowserAccessibility::GetBoolAttribute( bool BrowserAccessibility::GetBoolAttribute( ui::AXBoolAttribute attribute, bool* value) const { - for (size_t i = 0; i < bool_attributes_.size(); ++i) { - if (bool_attributes_[i].first == attribute) { - *value = bool_attributes_[i].second; + for (size_t i = 0; i < data_.bool_attributes.size(); ++i) { + if (data_.bool_attributes[i].first == attribute) { + *value = data_.bool_attributes[i].second; return true; } } @@ -416,8 +406,8 @@ bool BrowserAccessibility::GetBoolAttribute( bool BrowserAccessibility::HasFloatAttribute( ui::AXFloatAttribute attribute) const { - for (size_t i = 0; i < float_attributes_.size(); ++i) { - if (float_attributes_[i].first == attribute) + for (size_t i = 0; i < data_.float_attributes.size(); ++i) { + if (data_.float_attributes[i].first == attribute) return true; } @@ -426,9 +416,9 @@ bool BrowserAccessibility::HasFloatAttribute( float BrowserAccessibility::GetFloatAttribute( ui::AXFloatAttribute attribute) const { - for (size_t i = 0; i < float_attributes_.size(); ++i) { - if (float_attributes_[i].first == attribute) - return float_attributes_[i].second; + for (size_t i = 0; i < data_.float_attributes.size(); ++i) { + if (data_.float_attributes[i].first == attribute) + return data_.float_attributes[i].second; } return 0.0; @@ -436,9 +426,9 @@ float BrowserAccessibility::GetFloatAttribute( bool BrowserAccessibility::GetFloatAttribute( ui::AXFloatAttribute attribute, float* value) const { - for (size_t i = 0; i < float_attributes_.size(); ++i) { - if (float_attributes_[i].first == attribute) { - *value = float_attributes_[i].second; + for (size_t i = 0; i < data_.float_attributes.size(); ++i) { + if (data_.float_attributes[i].first == attribute) { + *value = data_.float_attributes[i].second; return true; } } @@ -448,8 +438,8 @@ bool BrowserAccessibility::GetFloatAttribute( bool BrowserAccessibility::HasIntAttribute( ui::AXIntAttribute attribute) const { - for (size_t i = 0; i < int_attributes_.size(); ++i) { - if (int_attributes_[i].first == attribute) + for (size_t i = 0; i < data_.int_attributes.size(); ++i) { + if (data_.int_attributes[i].first == attribute) return true; } @@ -457,9 +447,9 @@ bool BrowserAccessibility::HasIntAttribute( } int BrowserAccessibility::GetIntAttribute(ui::AXIntAttribute attribute) const { - for (size_t i = 0; i < int_attributes_.size(); ++i) { - if (int_attributes_[i].first == attribute) - return int_attributes_[i].second; + for (size_t i = 0; i < data_.int_attributes.size(); ++i) { + if (data_.int_attributes[i].first == attribute) + return data_.int_attributes[i].second; } return 0; @@ -467,9 +457,9 @@ int BrowserAccessibility::GetIntAttribute(ui::AXIntAttribute attribute) const { bool BrowserAccessibility::GetIntAttribute( ui::AXIntAttribute attribute, int* value) const { - for (size_t i = 0; i < int_attributes_.size(); ++i) { - if (int_attributes_[i].first == attribute) { - *value = int_attributes_[i].second; + for (size_t i = 0; i < data_.int_attributes.size(); ++i) { + if (data_.int_attributes[i].first == attribute) { + *value = data_.int_attributes[i].second; return true; } } @@ -479,8 +469,8 @@ bool BrowserAccessibility::GetIntAttribute( bool BrowserAccessibility::HasStringAttribute( ui::AXStringAttribute attribute) const { - for (size_t i = 0; i < string_attributes_.size(); ++i) { - if (string_attributes_[i].first == attribute) + for (size_t i = 0; i < data_.string_attributes.size(); ++i) { + if (data_.string_attributes[i].first == attribute) return true; } @@ -490,9 +480,9 @@ bool BrowserAccessibility::HasStringAttribute( const std::string& BrowserAccessibility::GetStringAttribute( ui::AXStringAttribute attribute) const { CR_DEFINE_STATIC_LOCAL(std::string, empty_string, ()); - for (size_t i = 0; i < string_attributes_.size(); ++i) { - if (string_attributes_[i].first == attribute) - return string_attributes_[i].second; + for (size_t i = 0; i < data_.string_attributes.size(); ++i) { + if (data_.string_attributes[i].first == attribute) + return data_.string_attributes[i].second; } return empty_string; @@ -500,9 +490,9 @@ const std::string& BrowserAccessibility::GetStringAttribute( bool BrowserAccessibility::GetStringAttribute( ui::AXStringAttribute attribute, std::string* value) const { - for (size_t i = 0; i < string_attributes_.size(); ++i) { - if (string_attributes_[i].first == attribute) { - *value = string_attributes_[i].second; + for (size_t i = 0; i < data_.string_attributes.size(); ++i) { + if (data_.string_attributes[i].first == attribute) { + *value = data_.string_attributes[i].second; return true; } } @@ -530,20 +520,20 @@ bool BrowserAccessibility::GetString16Attribute( void BrowserAccessibility::SetStringAttribute( ui::AXStringAttribute attribute, const std::string& value) { - for (size_t i = 0; i < string_attributes_.size(); ++i) { - if (string_attributes_[i].first == attribute) { - string_attributes_[i].second = value; + for (size_t i = 0; i < data_.string_attributes.size(); ++i) { + if (data_.string_attributes[i].first == attribute) { + data_.string_attributes[i].second = value; return; } } if (!value.empty()) - string_attributes_.push_back(std::make_pair(attribute, value)); + data_.string_attributes.push_back(std::make_pair(attribute, value)); } bool BrowserAccessibility::HasIntListAttribute( ui::AXIntListAttribute attribute) const { - for (size_t i = 0; i < intlist_attributes_.size(); ++i) { - if (intlist_attributes_[i].first == attribute) + for (size_t i = 0; i < data_.intlist_attributes.size(); ++i) { + if (data_.intlist_attributes[i].first == attribute) return true; } @@ -553,9 +543,9 @@ bool BrowserAccessibility::HasIntListAttribute( const std::vector<int32>& BrowserAccessibility::GetIntListAttribute( ui::AXIntListAttribute attribute) const { CR_DEFINE_STATIC_LOCAL(std::vector<int32>, empty_vector, ()); - for (size_t i = 0; i < intlist_attributes_.size(); ++i) { - if (intlist_attributes_[i].first == attribute) - return intlist_attributes_[i].second; + for (size_t i = 0; i < data_.intlist_attributes.size(); ++i) { + if (data_.intlist_attributes[i].first == attribute) + return data_.intlist_attributes[i].second; } return empty_vector; @@ -564,9 +554,9 @@ const std::vector<int32>& BrowserAccessibility::GetIntListAttribute( bool BrowserAccessibility::GetIntListAttribute( ui::AXIntListAttribute attribute, std::vector<int32>* value) const { - for (size_t i = 0; i < intlist_attributes_.size(); ++i) { - if (intlist_attributes_[i].first == attribute) { - *value = intlist_attributes_[i].second; + for (size_t i = 0; i < data_.intlist_attributes.size(); ++i) { + if (data_.intlist_attributes[i].first == attribute) { + *value = data_.intlist_attributes[i].second; return true; } } @@ -576,10 +566,10 @@ bool BrowserAccessibility::GetIntListAttribute( bool BrowserAccessibility::GetHtmlAttribute( const char* html_attr, std::string* value) const { - for (size_t i = 0; i < html_attributes_.size(); ++i) { - const std::string& attr = html_attributes_[i].first; + for (size_t i = 0; i < GetHtmlAttributes().size(); ++i) { + const std::string& attr = GetHtmlAttributes()[i].first; if (LowerCaseEqualsASCII(attr, html_attr)) { - *value = html_attributes_[i].second; + *value = GetHtmlAttributes()[i].second; return true; } } @@ -622,14 +612,14 @@ bool BrowserAccessibility::GetAriaTristate( } bool BrowserAccessibility::HasState(ui::AXState state_enum) const { - return (state_ >> state_enum) & 1; + return (GetState() >> state_enum) & 1; } bool BrowserAccessibility::IsEditableText() const { // These roles don't have readonly set, but they're not editable text. - if (role_ == ui::AX_ROLE_SCROLL_AREA || - role_ == ui::AX_ROLE_COLUMN || - role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { + if (GetRole() == ui::AX_ROLE_SCROLL_AREA || + GetRole() == ui::AX_ROLE_COLUMN || + GetRole() == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { return false; } @@ -637,8 +627,8 @@ bool BrowserAccessibility::IsEditableText() const { // or contenteditable. We also check for editable text roles to cover // another element that has role=textbox set on it. return (!HasState(ui::AX_STATE_READ_ONLY) || - role_ == ui::AX_ROLE_TEXT_FIELD || - role_ == ui::AX_ROLE_TEXT_AREA); + GetRole() == ui::AX_ROLE_TEXT_FIELD || + GetRole() == ui::AX_ROLE_TEXT_AREA); } std::string BrowserAccessibility::GetTextRecursive() const { @@ -653,12 +643,12 @@ std::string BrowserAccessibility::GetTextRecursive() const { } int BrowserAccessibility::GetStaticTextLenRecursive() const { - if (role_ == ui::AX_ROLE_STATIC_TEXT) + if (GetRole() == ui::AX_ROLE_STATIC_TEXT) return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); int len = 0; - for (size_t i = 0; i < children_.size(); ++i) - len += children_[i]->GetStaticTextLenRecursive(); + for (size_t i = 0; i < InternalChildCount(); ++i) + len += InternalGetChild(i)->GetStaticTextLenRecursive(); return len; } diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index d1df6b9..d72a2ad 100644 --- a/content/browser/accessibility/browser_accessibility.h +++ b/content/browser/accessibility/browser_accessibility.h @@ -66,7 +66,7 @@ class CONTENT_EXPORT BrowserAccessibility { void InitializeTreeStructure( BrowserAccessibilityManager* manager, BrowserAccessibility* parent, - int32 renderer_id, + int32 id, int32 index_in_parent); // Initialize this object's data. @@ -83,12 +83,6 @@ class CONTENT_EXPORT BrowserAccessibility { // Return true if this object is equal to or a descendant of |ancestor|. bool IsDescendantOf(BrowserAccessibility* ancestor); - // Returns the parent of this object, or NULL if it's the root. - BrowserAccessibility* parent() const { return parent_; } - - // Returns the number of children of this object. - uint32 child_count() const { return children_.size(); } - // Returns true if this is a leaf node on this platform, meaning any // children should not be exposed to this platform's native accessibility // layer. Each platform subclass should implement this itself. @@ -154,26 +148,38 @@ class CONTENT_EXPORT BrowserAccessibility { // Accessors // - const std::vector<BrowserAccessibility*>& children() const { - return children_; - } - const std::vector<std::pair<std::string, std::string> >& - html_attributes() const { - return html_attributes_; - } - int32 index_in_parent() const { return index_in_parent_; } - gfx::Rect location() const { return location_; } BrowserAccessibilityManager* manager() const { return manager_; } + bool instance_active() const { return instance_active_; } 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_; } - 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; } + std::vector<BrowserAccessibility*>& deprecated_children() { + return deprecated_children_; + } + + // These access the internal accessibility tree, which doesn't necessarily + // reflect the accessibility tree that should be exposed on each platform. + // Use PlatformChildCount and PlatformGetChild to implement platform + // accessibility APIs. + uint32 InternalChildCount() const { return deprecated_children_.size(); } + BrowserAccessibility* InternalGetChild(uint32 child_index) const { + return deprecated_children_[child_index]; + } + + BrowserAccessibility* GetParent() const { return deprecated_parent_; } + int32 GetIndexInParent() const { return deprecated_index_in_parent_; } + + int32 GetId() const { return data_.id; } + gfx::Rect GetLocation() const { return data_.location; } + int32 GetRole() const { return data_.role; } + int32 GetState() const { return data_.state; } + const std::vector<std::pair<std::string, std::string> >& GetHtmlAttributes() + const { + return data_.html_attributes; + } + #if defined(OS_MACOSX) && __OBJC__ BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); #elif defined(OS_WIN) @@ -273,7 +279,7 @@ class CONTENT_EXPORT BrowserAccessibility { BrowserAccessibilityManager* manager_; // The parent of this object, may be NULL if we're the root object. - BrowserAccessibility* parent_; + BrowserAccessibility* deprecated_parent_; private: // Return the sum of the lengths of all static text descendants, @@ -281,32 +287,15 @@ class CONTENT_EXPORT BrowserAccessibility { int GetStaticTextLenRecursive() const; // The index of this within its parent object. - int32 index_in_parent_; - - // The ID of this object in the renderer process. - int32 renderer_id_; + int32 deprecated_index_in_parent_; // The children of this object. - std::vector<BrowserAccessibility*> children_; + std::vector<BrowserAccessibility*> deprecated_children_; // Accessibility metadata from the renderer std::string name_; std::string value_; - std::vector<std::pair< - ui::AXBoolAttribute, bool> > bool_attributes_; - std::vector<std::pair< - ui::AXFloatAttribute, float> > float_attributes_; - std::vector<std::pair< - ui::AXIntAttribute, int> > int_attributes_; - std::vector<std::pair< - ui::AXStringAttribute, std::string> > string_attributes_; - std::vector<std::pair< - ui::AXIntListAttribute, std::vector<int32> > > - intlist_attributes_; - std::vector<std::pair<std::string, std::string> > html_attributes_; - int32 role_; - int32 state_; - gfx::Rect location_; + ui::AXNodeData data_; // BrowserAccessibility objects are reference-counted on some platforms. // When we're done with this object and it's removed from our accessibility diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc index f286c85..6e26ef9 100644 --- a/content/browser/accessibility/browser_accessibility_android.cc +++ b/content/browser/accessibility/browser_accessibility_android.cc @@ -56,13 +56,13 @@ bool BrowserAccessibilityAndroid::IsNative() const { } bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { - if (child_count() == 0) + if (InternalChildCount() == 0) return true; // Iframes are always allowed to contain children. if (IsIframe() || - role() == ui::AX_ROLE_ROOT_WEB_AREA || - role() == ui::AX_ROLE_WEB_AREA) { + GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || + GetRole() == ui::AX_ROLE_WEB_AREA) { return false; } @@ -72,7 +72,7 @@ bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { // Headings with text can drop their children. base::string16 name = GetText(); - if (role() == ui::AX_ROLE_HEADING && !name.empty()) + if (GetRole() == ui::AX_ROLE_HEADING && !name.empty()) return true; // Focusable nodes with text can drop their children. @@ -91,8 +91,8 @@ bool BrowserAccessibilityAndroid::IsCheckable() const { bool is_aria_pressed_defined; bool is_mixed; GetAriaTristate("aria-pressed", &is_aria_pressed_defined, &is_mixed); - if (role() == ui::AX_ROLE_CHECK_BOX || - role() == ui::AX_ROLE_RADIO_BUTTON || + if (GetRole() == ui::AX_ROLE_CHECK_BOX || + GetRole() == ui::AX_ROLE_RADIO_BUTTON || is_aria_pressed_defined) { checkable = true; } @@ -110,21 +110,21 @@ bool BrowserAccessibilityAndroid::IsClickable() const { } bool BrowserAccessibilityAndroid::IsCollection() const { - return (role() == ui::AX_ROLE_GRID || - role() == ui::AX_ROLE_LIST || - role() == ui::AX_ROLE_LIST_BOX || - role() == ui::AX_ROLE_TABLE || - role() == ui::AX_ROLE_TREE); + return (GetRole() == ui::AX_ROLE_GRID || + GetRole() == ui::AX_ROLE_LIST || + GetRole() == ui::AX_ROLE_LIST_BOX || + GetRole() == ui::AX_ROLE_TABLE || + GetRole() == ui::AX_ROLE_TREE); } bool BrowserAccessibilityAndroid::IsCollectionItem() const { - return (role() == ui::AX_ROLE_CELL || - role() == ui::AX_ROLE_COLUMN_HEADER || - role() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || - role() == ui::AX_ROLE_LIST_BOX_OPTION || - role() == ui::AX_ROLE_LIST_ITEM || - role() == ui::AX_ROLE_ROW_HEADER || - role() == ui::AX_ROLE_TREE_ITEM); + return (GetRole() == ui::AX_ROLE_CELL || + GetRole() == ui::AX_ROLE_COLUMN_HEADER || + GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || + GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || + GetRole() == ui::AX_ROLE_LIST_ITEM || + GetRole() == ui::AX_ROLE_ROW_HEADER || + GetRole() == ui::AX_ROLE_TREE_ITEM); } bool BrowserAccessibilityAndroid::IsContentInvalid() const { @@ -143,7 +143,7 @@ bool BrowserAccessibilityAndroid::IsEnabled() const { bool BrowserAccessibilityAndroid::IsFocusable() const { bool focusable = HasState(ui::AX_STATE_FOCUSABLE); if (IsIframe() || - role() == ui::AX_ROLE_WEB_AREA) { + GetRole() == ui::AX_ROLE_WEB_AREA) { focusable = false; } return focusable; @@ -154,22 +154,23 @@ bool BrowserAccessibilityAndroid::IsFocused() const { } bool BrowserAccessibilityAndroid::IsHeading() const { - return (role() == ui::AX_ROLE_COLUMN_HEADER || - role() == ui::AX_ROLE_HEADING || - role() == ui::AX_ROLE_ROW_HEADER); + return (GetRole() == ui::AX_ROLE_COLUMN_HEADER || + GetRole() == ui::AX_ROLE_HEADING || + GetRole() == ui::AX_ROLE_ROW_HEADER); } bool BrowserAccessibilityAndroid::IsHierarchical() const { - return (role() == ui::AX_ROLE_LIST || - role() == ui::AX_ROLE_TREE); + return (GetRole() == ui::AX_ROLE_LIST || + GetRole() == ui::AX_ROLE_TREE); } bool BrowserAccessibilityAndroid::IsLink() const { - return role() == ui::AX_ROLE_LINK || role() == ui::AX_ROLE_IMAGE_MAP_LINK; + return GetRole() == ui::AX_ROLE_LINK || + GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK; } bool BrowserAccessibilityAndroid::IsMultiLine() const { - return role() == ui::AX_ROLE_TEXT_AREA; + return GetRole() == ui::AX_ROLE_TEXT_AREA; } bool BrowserAccessibilityAndroid::IsPassword() const { @@ -177,9 +178,9 @@ bool BrowserAccessibilityAndroid::IsPassword() const { } bool BrowserAccessibilityAndroid::IsRangeType() const { - return (role() == ui::AX_ROLE_PROGRESS_INDICATOR || - role() == ui::AX_ROLE_SCROLL_BAR || - role() == ui::AX_ROLE_SLIDER); + return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR || + GetRole() == ui::AX_ROLE_SCROLL_BAR || + GetRole() == ui::AX_ROLE_SLIDER); } bool BrowserAccessibilityAndroid::IsScrollable() const { @@ -202,7 +203,7 @@ bool BrowserAccessibilityAndroid::CanOpenPopup() const { const char* BrowserAccessibilityAndroid::GetClassName() const { const char* class_name = NULL; - switch(role()) { + switch(GetRole()) { case ui::AX_ROLE_EDITABLE_TEXT: case ui::AX_ROLE_SPIN_BUTTON: case ui::AX_ROLE_TEXT_AREA: @@ -263,7 +264,7 @@ const char* BrowserAccessibilityAndroid::GetClassName() const { base::string16 BrowserAccessibilityAndroid::GetText() const { if (IsIframe() || - role() == ui::AX_ROLE_WEB_AREA) { + GetRole() == ui::AX_ROLE_WEB_AREA) { return base::string16(); } @@ -280,13 +281,13 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { // This is called from PlatformIsLeaf, so don't call PlatformChildCount // from within this! if (text.empty() && HasOnlyStaticTextChildren()) { - for (uint32 i = 0; i < child_count(); i++) { - BrowserAccessibility* child = children()[i]; + for (uint32 i = 0; i < InternalChildCount(); i++) { + BrowserAccessibility* child = InternalGetChild(i); text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText(); } } - switch(role()) { + switch(GetRole()) { case ui::AX_ROLE_HEADING: // Only append "heading" if this node already has text. if (!text.empty()) @@ -299,11 +300,11 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { int BrowserAccessibilityAndroid::GetItemIndex() const { int index = 0; - switch(role()) { + switch(GetRole()) { case ui::AX_ROLE_LIST_ITEM: case ui::AX_ROLE_LIST_BOX_OPTION: case ui::AX_ROLE_TREE_ITEM: - index = index_in_parent(); + index = GetIndexInParent(); break; case ui::AX_ROLE_SLIDER: case ui::AX_ROLE_PROGRESS_INDICATOR: { @@ -320,7 +321,7 @@ int BrowserAccessibilityAndroid::GetItemIndex() const { int BrowserAccessibilityAndroid::GetItemCount() const { int count = 0; - switch(role()) { + switch(GetRole()) { case ui::AX_ROLE_LIST: case ui::AX_ROLE_LIST_BOX: count = PlatformChildCount(); @@ -479,14 +480,14 @@ int BrowserAccessibilityAndroid::AndroidRangeType() const { } int BrowserAccessibilityAndroid::RowCount() const { - if (role() == ui::AX_ROLE_GRID || - role() == ui::AX_ROLE_TABLE) { + if (GetRole() == ui::AX_ROLE_GRID || + GetRole() == ui::AX_ROLE_TABLE) { return CountChildrenWithRole(ui::AX_ROLE_ROW); } - if (role() == ui::AX_ROLE_LIST || - role() == ui::AX_ROLE_LIST_BOX || - role() == ui::AX_ROLE_TREE) { + if (GetRole() == ui::AX_ROLE_LIST || + GetRole() == ui::AX_ROLE_LIST_BOX || + GetRole() == ui::AX_ROLE_TREE) { return PlatformChildCount(); } @@ -494,18 +495,18 @@ int BrowserAccessibilityAndroid::RowCount() const { } int BrowserAccessibilityAndroid::ColumnCount() const { - if (role() == ui::AX_ROLE_GRID || - role() == ui::AX_ROLE_TABLE) { + if (GetRole() == ui::AX_ROLE_GRID || + GetRole() == ui::AX_ROLE_TABLE) { return CountChildrenWithRole(ui::AX_ROLE_COLUMN); } return 0; } int BrowserAccessibilityAndroid::RowIndex() const { - if (role() == ui::AX_ROLE_LIST_ITEM || - role() == ui::AX_ROLE_LIST_BOX_OPTION || - role() == ui::AX_ROLE_TREE_ITEM) { - return index_in_parent(); + if (GetRole() == ui::AX_ROLE_LIST_ITEM || + GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || + GetRole() == ui::AX_ROLE_TREE_ITEM) { + return GetIndexInParent(); } return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX); @@ -538,8 +539,8 @@ float BrowserAccessibilityAndroid::RangeCurrentValue() const { bool BrowserAccessibilityAndroid::HasFocusableChild() const { // This is called from PlatformIsLeaf, so don't call PlatformChildCount // from within this! - for (uint32 i = 0; i < child_count(); i++) { - BrowserAccessibility* child = children()[i]; + for (uint32 i = 0; i < InternalChildCount(); i++) { + BrowserAccessibility* child = InternalGetChild(i); if (child->HasState(ui::AX_STATE_FOCUSABLE)) return true; if (static_cast<BrowserAccessibilityAndroid*>(child)->HasFocusableChild()) @@ -551,9 +552,9 @@ bool BrowserAccessibilityAndroid::HasFocusableChild() const { bool BrowserAccessibilityAndroid::HasOnlyStaticTextChildren() const { // This is called from PlatformIsLeaf, so don't call PlatformChildCount // from within this! - for (uint32 i = 0; i < child_count(); i++) { - BrowserAccessibility* child = children()[i]; - if (child->role() != ui::AX_ROLE_STATIC_TEXT) + for (uint32 i = 0; i < InternalChildCount(); i++) { + BrowserAccessibility* child = InternalGetChild(i); + if (child->GetRole() != ui::AX_ROLE_STATIC_TEXT) return false; } return true; @@ -575,7 +576,7 @@ void BrowserAccessibilityAndroid::PostInitialize() { } } - if (role() == ui::AX_ROLE_ALERT && first_time_) + if (GetRole() == ui::AX_ROLE_ALERT && first_time_) manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); base::string16 live; @@ -606,7 +607,7 @@ void BrowserAccessibilityAndroid::NotifyLiveRegionUpdate( int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { int count = 0; for (uint32 i = 0; i < PlatformChildCount(); i++) { - if (PlatformGetChild(i)->role() == role) + if (PlatformGetChild(i)->GetRole() == role) count++; } return count; diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm index fdfdd2c..7a3a44b 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa.mm @@ -49,7 +49,7 @@ typedef std::map<ui::AXRole, NSString*> RoleMap; // GetState checks the bitmask used in AXNodeData to check // if the given state was set on the accessibility object. bool GetState(BrowserAccessibility* accessibility, ui::AXState state) { - return ((accessibility->state() >> state) & 1); + return ((accessibility->GetState() >> state) & 1); } RoleMap BuildRoleMap() { @@ -391,7 +391,7 @@ NSDictionary* attributeToMethodNameMap = nil; if (![self isIgnored]) { children_.reset(); } else { - [browserAccessibility_->parent()->ToBrowserAccessibilityCocoa() + [browserAccessibility_->GetParent()->ToBrowserAccessibilityCocoa() childrenChanged]; } } @@ -410,7 +410,7 @@ NSDictionary* attributeToMethodNameMap = nil; int id = uniqueCellIds[i]; BrowserAccessibility* cell = browserAccessibility_->manager()->GetFromRendererID(id); - if (cell && cell->role() == ui::AX_ROLE_COLUMN_HEADER) + if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) [ret addObject:cell->ToBrowserAccessibilityCocoa()]; } return ret; @@ -651,9 +651,9 @@ NSDictionary* attributeToMethodNameMap = nil; - (id)parent { // A nil parent means we're the root. - if (browserAccessibility_->parent()) { + if (browserAccessibility_->GetParent()) { return NSAccessibilityUnignoredAncestor( - browserAccessibility_->parent()->ToBrowserAccessibilityCocoa()); + browserAccessibility_->GetParent()->ToBrowserAccessibilityCocoa()); } else { // Hook back up to RenderWidgetHostViewCocoa. BrowserAccessibilityManagerMac* manager = @@ -678,7 +678,7 @@ NSDictionary* attributeToMethodNameMap = nil; // Returns an enum indicating the role from browserAccessibility_. - (ui::AXRole)internalRole { - return static_cast<ui::AXRole>(browserAccessibility_->role()); + return static_cast<ui::AXRole>(browserAccessibility_->GetRole()); } // Returns a string indicating the NSAccessibility role of this object. @@ -771,7 +771,7 @@ NSDictionary* attributeToMethodNameMap = nil; int id = uniqueCellIds[i]; BrowserAccessibility* cell = browserAccessibility_->manager()->GetFromRendererID(id); - if (cell && cell->role() == ui::AX_ROLE_ROW_HEADER) + if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) [ret addObject:cell->ToBrowserAccessibilityCocoa()]; } return ret; @@ -1115,7 +1115,7 @@ NSDictionary* attributeToMethodNameMap = nil; i < browserAccessibility_->PlatformChildCount(); ++i) { BrowserAccessibility* child = browserAccessibility_->PlatformGetChild(i); - if (child->role() != ui::AX_ROLE_ROW) + if (child->GetRole() != ui::AX_ROLE_ROW) continue; int rowIndex; if (!child->GetIntAttribute( @@ -1130,7 +1130,7 @@ NSDictionary* attributeToMethodNameMap = nil; j < child->PlatformChildCount(); ++j) { BrowserAccessibility* cell = child->PlatformGetChild(j); - if (cell->role() != ui::AX_ROLE_CELL) + if (cell->GetRole() != ui::AX_ROLE_CELL) continue; int colIndex; if (!cell->GetIntAttribute( @@ -1354,9 +1354,9 @@ NSDictionary* attributeToMethodNameMap = nil; NSAccessibilityDisclosedRowsAttribute, nil]]; } else if ([role isEqualToString:NSAccessibilityRowRole]) { - if (browserAccessibility_->parent()) { + if (browserAccessibility_->GetParent()) { base::string16 parentRole; - browserAccessibility_->parent()->GetHtmlAttribute( + browserAccessibility_->GetParent()->GetHtmlAttribute( "role", &parentRole); const base::string16 treegridRole(base::ASCIIToUTF16("treegrid")); if (parentRole == treegridRole) { @@ -1457,7 +1457,7 @@ NSDictionary* attributeToMethodNameMap = nil; // TODO(feldstein): Support more actions. if ([action isEqualToString:NSAccessibilityPressAction]) - [delegate_ doDefaultAction:browserAccessibility_->renderer_id()]; + [delegate_ doDefaultAction:browserAccessibility_->GetId()]; else if ([action isEqualToString:NSAccessibilityShowMenuAction]) [delegate_ performShowMenuAction:self]; } @@ -1486,12 +1486,12 @@ NSDictionary* attributeToMethodNameMap = nil; NSNumber* focusedNumber = value; BOOL focused = [focusedNumber intValue]; [delegate_ setAccessibilityFocus:focused - accessibilityId:browserAccessibility_->renderer_id()]; + accessibilityId:browserAccessibility_->GetId()]; } if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { NSRange range = [(NSValue*)value rangeValue]; [delegate_ - accessibilitySetTextSelection:browserAccessibility_->renderer_id() + accessibilitySetTextSelection:browserAccessibility_->GetId() startOffset:range.location endOffset:range.location + range.length]; } @@ -1536,7 +1536,7 @@ NSDictionary* attributeToMethodNameMap = nil; // Potentially called during dealloc. if (!browserAccessibility_) return [super hash]; - return browserAccessibility_->renderer_id(); + return browserAccessibility_->GetId(); } - (BOOL)accessibilityShouldUseUniqueId { diff --git a/content/browser/accessibility/browser_accessibility_gtk.cc b/content/browser/accessibility/browser_accessibility_gtk.cc index eb015eb..4ec1b89 100644 --- a/content/browser/accessibility/browser_accessibility_gtk.cc +++ b/content/browser/accessibility/browser_accessibility_gtk.cc @@ -196,8 +196,8 @@ static AtkObject* browser_accessibility_get_parent(AtkObject* atk_object) { BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); if (!obj) return NULL; - if (obj->parent()) - return obj->parent()->ToBrowserAccessibilityGtk()->GetAtkObject(); + if (obj->GetParent()) + return obj->GetParent()->ToBrowserAccessibilityGtk()->GetAtkObject(); BrowserAccessibilityManagerGtk* manager = static_cast<BrowserAccessibilityManagerGtk*>(obj->manager()); @@ -222,7 +222,7 @@ static AtkObject* browser_accessibility_ref_child( return NULL; AtkObject* result = - obj->children()[index]->ToBrowserAccessibilityGtk()->GetAtkObject(); + obj->InternalGetChild(index)->ToBrowserAccessibilityGtk()->GetAtkObject(); g_object_ref(result); return result; } @@ -231,7 +231,7 @@ static gint browser_accessibility_get_index_in_parent(AtkObject* atk_object) { BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); if (!obj) return 0; - return obj->index_in_parent(); + return obj->GetIndexInParent(); } static AtkAttributeSet* browser_accessibility_get_attributes( @@ -253,7 +253,7 @@ static AtkStateSet* browser_accessibility_ref_state_set(AtkObject* atk_object) { AtkStateSet* state_set = ATK_OBJECT_CLASS(browser_accessibility_parent_class)-> ref_state_set(atk_object); - int32 state = obj->state(); + int32 state = obj->GetState(); if (state & (1 << ui::AX_STATE_FOCUSABLE)) atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE); @@ -363,7 +363,7 @@ static int GetInterfaceMaskFromObject(BrowserAccessibilityGtk* obj) { // Component interface is always supported. interface_mask |= 1 << ATK_COMPONENT_INTERFACE; - int role = obj->role(); + int role = obj->GetRole(); if (role == ui::AX_ROLE_PROGRESS_INDICATOR || role == ui::AX_ROLE_SCROLL_BAR || role == ui::AX_ROLE_SLIDER) { @@ -462,10 +462,10 @@ void BrowserAccessibilityGtk::PreInitialize() { if (!atk_object_) { interface_mask_ = GetInterfaceMaskFromObject(this); atk_object_ = ATK_OBJECT(browser_accessibility_new(this)); - if (this->parent()) { + if (this->GetParent()) { atk_object_set_parent( atk_object_, - this->parent()->ToBrowserAccessibilityGtk()->GetAtkObject()); + this->GetParent()->ToBrowserAccessibilityGtk()->GetAtkObject()); } } } @@ -475,7 +475,7 @@ bool BrowserAccessibilityGtk::IsNative() const { } void BrowserAccessibilityGtk::InitRoleAndState() { - switch(role()) { + switch(GetRole()) { case ui::AX_ROLE_DOCUMENT: case ui::AX_ROLE_ROOT_WEB_AREA: case ui::AX_ROLE_WEB_AREA: diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc index a28f690..a9fda6b 100644 --- a/content/browser/accessibility/browser_accessibility_manager.cc +++ b/content/browser/accessibility/browser_accessibility_manager.cc @@ -116,7 +116,7 @@ bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() { void BrowserAccessibilityManager::RemoveNode(BrowserAccessibility* node) { if (node == focus_) SetFocus(root_, false); - int renderer_id = node->renderer_id(); + int renderer_id = node->GetId(); renderer_id_map_.erase(renderer_id); } @@ -198,7 +198,7 @@ void BrowserAccessibilityManager::SetFocus( focus_ = node; if (notify && node && delegate_) - delegate_->SetAccessibilityFocus(node->renderer_id()); + delegate_->SetAccessibilityFocus(node->GetId()); } void BrowserAccessibilityManager::SetRoot(BrowserAccessibility* node) { @@ -209,20 +209,20 @@ void BrowserAccessibilityManager::SetRoot(BrowserAccessibility* node) { void BrowserAccessibilityManager::DoDefaultAction( const BrowserAccessibility& node) { if (delegate_) - delegate_->AccessibilityDoDefaultAction(node.renderer_id()); + delegate_->AccessibilityDoDefaultAction(node.GetId()); } void BrowserAccessibilityManager::ScrollToMakeVisible( const BrowserAccessibility& node, gfx::Rect subfocus) { if (delegate_) { - delegate_->AccessibilityScrollToMakeVisible(node.renderer_id(), subfocus); + delegate_->AccessibilityScrollToMakeVisible(node.GetId(), subfocus); } } void BrowserAccessibilityManager::ScrollToPoint( const BrowserAccessibility& node, gfx::Point point) { if (delegate_) { - delegate_->AccessibilityScrollToPoint(node.renderer_id(), point); + delegate_->AccessibilityScrollToPoint(node.GetId(), point); } } @@ -230,7 +230,7 @@ void BrowserAccessibilityManager::SetTextSelection( const BrowserAccessibility& node, int start_offset, int end_offset) { if (delegate_) { delegate_->AccessibilitySetTextSelection( - node.renderer_id(), start_offset, end_offset); + node.GetId(), start_offset, end_offset); } } @@ -248,12 +248,12 @@ BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder( if (node->PlatformChildCount() > 0) return node->PlatformGetChild(0); while (node) { - if (node->parent() && - node->index_in_parent() < - static_cast<int>(node->parent()->PlatformChildCount()) - 1) { - return node->parent()->PlatformGetChild(node->index_in_parent() + 1); + if (node->GetParent() && + node->GetIndexInParent() < + static_cast<int>(node->GetParent()->PlatformChildCount()) - 1) { + return node->GetParent()->PlatformGetChild(node->GetIndexInParent() + 1); } - node = node->parent(); + node = node->GetParent(); } return NULL; @@ -264,14 +264,14 @@ BrowserAccessibility* BrowserAccessibilityManager::PreviousInTreeOrder( if (!node) return NULL; - if (node->parent() && node->index_in_parent() > 0) { - node = node->parent()->PlatformGetChild(node->index_in_parent() - 1); + if (node->GetParent() && node->GetIndexInParent() > 0) { + node = node->GetParent()->PlatformGetChild(node->GetIndexInParent() - 1); while (node->PlatformChildCount() > 0) node = node->PlatformGetChild(node->PlatformChildCount() - 1); return node; } - return node->parent(); + return node->GetParent(); } void BrowserAccessibilityManager::UpdateNodesForTesting( @@ -363,7 +363,7 @@ BrowserAccessibility* BrowserAccessibilityManager::CreateNode( } void BrowserAccessibilityManager::AddNodeToMap(BrowserAccessibility* node) { - renderer_id_map_[node->renderer_id()] = node; + renderer_id_map_[node->GetId()] = node; } bool BrowserAccessibilityManager::UpdateNode(const ui::AXNodeData& src) { @@ -408,9 +408,10 @@ bool BrowserAccessibilityManager::UpdateNode(const ui::AXNodeData& src) { // parent and new parent, which could lead to a double-free. // If a node is reparented, the renderer will always send us a fresh // copy of the node. - const std::vector<BrowserAccessibility*>& old_children = instance->children(); + const std::vector<BrowserAccessibility*>& old_children = + instance->deprecated_children(); for (size_t i = 0; i < old_children.size(); ++i) { - int old_id = old_children[i]->renderer_id(); + int old_id = old_children[i]->GetId(); if (new_child_ids.find(old_id) == new_child_ids.end()) old_children[i]->Destroy(); } @@ -424,7 +425,7 @@ bool BrowserAccessibilityManager::UpdateNode(const ui::AXNodeData& src) { int32 index_in_parent = static_cast<int32>(i); BrowserAccessibility* child = GetFromRendererID(child_renderer_id); if (child) { - if (child->parent() != instance) { + if (child->GetParent() != instance) { // This is a serious error - nodes should never be reparented. // If this case occurs, continue so this node isn't left in an // inconsistent state, but return failure at the end. @@ -443,7 +444,7 @@ bool BrowserAccessibilityManager::UpdateNode(const ui::AXNodeData& src) { // Handle the case where this node is the new root of the tree. if (src.role == ui::AX_ROLE_ROOT_WEB_AREA && - (!root_ || root_->renderer_id() != src.id)) { + (!root_ || root_->GetId() != src.id)) { if (root_) root_->Destroy(); if (focus_ == root_) diff --git a/content/browser/accessibility/browser_accessibility_manager_android.cc b/content/browser/accessibility/browser_accessibility_manager_android.cc index ef816e5..3d349e4 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.cc +++ b/content/browser/accessibility/browser_accessibility_manager_android.cc @@ -128,28 +128,28 @@ void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent( // the Android system that the accessibility hierarchy rooted at this // node has changed. Java_BrowserAccessibilityManager_handleContentChanged( - env, obj.obj(), node->renderer_id()); + env, obj.obj(), node->GetId()); switch (event_type) { case ui::AX_EVENT_LOAD_COMPLETE: Java_BrowserAccessibilityManager_handlePageLoaded( - env, obj.obj(), focus_->renderer_id()); + env, obj.obj(), focus_->GetId()); break; case ui::AX_EVENT_FOCUS: Java_BrowserAccessibilityManager_handleFocusChanged( - env, obj.obj(), node->renderer_id()); + env, obj.obj(), node->GetId()); break; case ui::AX_EVENT_CHECKED_STATE_CHANGED: Java_BrowserAccessibilityManager_handleCheckStateChanged( - env, obj.obj(), node->renderer_id()); + env, obj.obj(), node->GetId()); break; case ui::AX_EVENT_SCROLL_POSITION_CHANGED: Java_BrowserAccessibilityManager_handleScrollPositionChanged( - env, obj.obj(), node->renderer_id()); + env, obj.obj(), node->GetId()); break; case ui::AX_EVENT_SCROLLED_TO_ANCHOR: Java_BrowserAccessibilityManager_handleScrolledToAnchor( - env, obj.obj(), node->renderer_id()); + env, obj.obj(), node->GetId()); break; case ui::AX_EVENT_ALERT: // An alert is a special case of live region. Fall through to the @@ -167,14 +167,14 @@ void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent( } case ui::AX_EVENT_SELECTED_TEXT_CHANGED: Java_BrowserAccessibilityManager_handleTextSelectionChanged( - env, obj.obj(), node->renderer_id()); + env, obj.obj(), node->GetId()); break; case ui::AX_EVENT_CHILDREN_CHANGED: case ui::AX_EVENT_TEXT_CHANGED: case ui::AX_EVENT_VALUE_CHANGED: if (node->IsEditableText()) { Java_BrowserAccessibilityManager_handleEditableTextChanged( - env, obj.obj(), node->renderer_id()); + env, obj.obj(), node->GetId()); } break; default: @@ -185,7 +185,7 @@ void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent( } jint BrowserAccessibilityManagerAndroid::GetRootId(JNIEnv* env, jobject obj) { - return static_cast<jint>(root_->renderer_id()); + return static_cast<jint>(root_->GetId()); } jboolean BrowserAccessibilityManagerAndroid::IsNodeValid( @@ -200,18 +200,18 @@ jint BrowserAccessibilityManagerAndroid::HitTest( root_->BrowserAccessibilityForPoint(gfx::Point(x, y))); if (!result) - return root_->renderer_id(); + return root_->GetId(); if (result->IsFocusable()) - return result->renderer_id(); + return result->GetId(); // Examine the children of |result| to find the nearest accessibility focus // candidate BrowserAccessibility* nearest_node = FuzzyHitTest(x, y, result); if (nearest_node) - return nearest_node->renderer_id(); + return nearest_node->GetId(); - return root_->renderer_id(); + return root_->GetId(); } jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityNodeInfo( @@ -221,13 +221,13 @@ jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityNodeInfo( if (!node) return false; - if (node->parent()) { + if (node->GetParent()) { Java_BrowserAccessibilityManager_setAccessibilityNodeInfoParent( - env, obj, info, node->parent()->renderer_id()); + env, obj, info, node->GetParent()->GetId()); } for (unsigned i = 0; i < node->PlatformChildCount(); ++i) { Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild( - env, obj, info, node->children()[i]->renderer_id()); + env, obj, info, node->InternalGetChild(i)->GetId()); } Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes( env, obj, info, @@ -252,11 +252,11 @@ jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityNodeInfo( gfx::Rect absolute_rect = node->GetLocalBoundsRect(); gfx::Rect parent_relative_rect = absolute_rect; - if (node->parent()) { - gfx::Rect parent_rect = node->parent()->GetLocalBoundsRect(); + if (node->GetParent()) { + gfx::Rect parent_rect = node->GetParent()->GetLocalBoundsRect(); parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin()); } - bool is_root = node->parent() == NULL; + bool is_root = node->GetParent() == NULL; Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation( env, obj, info, absolute_rect.x(), absolute_rect.y(), @@ -410,7 +410,7 @@ void BrowserAccessibilityManagerAndroid::ScrollToMakeNodeVisible( JNIEnv* env, jobject obj, jint id) { BrowserAccessibility* node = GetFromRendererID(id); if (node) - ScrollToMakeVisible(*node, gfx::Rect(node->location().size())); + ScrollToMakeVisible(*node, gfx::Rect(node->GetLocation().size())); } BrowserAccessibility* BrowserAccessibilityManagerAndroid::FuzzyHitTest( @@ -478,30 +478,30 @@ jint BrowserAccessibilityManagerAndroid::FindElementType( while (node) { switch(element_type) { case HTML_ELEMENT_TYPE_SECTION: - if (node->role() == ui::AX_ROLE_ARTICLE || - node->role() == ui::AX_ROLE_APPLICATION || - node->role() == ui::AX_ROLE_BANNER || - node->role() == ui::AX_ROLE_COMPLEMENTARY || - node->role() == ui::AX_ROLE_CONTENT_INFO || - node->role() == ui::AX_ROLE_HEADING || - node->role() == ui::AX_ROLE_MAIN || - node->role() == ui::AX_ROLE_NAVIGATION || - node->role() == ui::AX_ROLE_SEARCH || - node->role() == ui::AX_ROLE_REGION) { - return node->renderer_id(); + if (node->GetRole() == ui::AX_ROLE_ARTICLE || + node->GetRole() == ui::AX_ROLE_APPLICATION || + node->GetRole() == ui::AX_ROLE_BANNER || + node->GetRole() == ui::AX_ROLE_COMPLEMENTARY || + node->GetRole() == ui::AX_ROLE_CONTENT_INFO || + node->GetRole() == ui::AX_ROLE_HEADING || + node->GetRole() == ui::AX_ROLE_MAIN || + node->GetRole() == ui::AX_ROLE_NAVIGATION || + node->GetRole() == ui::AX_ROLE_SEARCH || + node->GetRole() == ui::AX_ROLE_REGION) { + return node->GetId(); } break; case HTML_ELEMENT_TYPE_LIST: - if (node->role() == ui::AX_ROLE_LIST || - node->role() == ui::AX_ROLE_GRID || - node->role() == ui::AX_ROLE_TABLE || - node->role() == ui::AX_ROLE_TREE) { - return node->renderer_id(); + if (node->GetRole() == ui::AX_ROLE_LIST || + node->GetRole() == ui::AX_ROLE_GRID || + node->GetRole() == ui::AX_ROLE_TABLE || + node->GetRole() == ui::AX_ROLE_TREE) { + return node->GetId(); } break; case HTML_ELEMENT_TYPE_CONTROL: if (static_cast<BrowserAccessibilityAndroid*>(node)->IsFocusable()) - return node->renderer_id(); + return node->GetId(); break; case HTML_ELEMENT_TYPE_ANY: // In theory, the API says that an accessibility service could @@ -511,7 +511,7 @@ jint BrowserAccessibilityManagerAndroid::FindElementType( // just fall back on linear navigation when we don't recognize the // element type. if (static_cast<BrowserAccessibilityAndroid*>(node)->IsClickable()) - return node->renderer_id(); + return node->GetId(); break; } diff --git a/content/browser/accessibility/browser_accessibility_manager_gtk.cc b/content/browser/accessibility/browser_accessibility_manager_gtk.cc index 3d7a976..8748de5 100644 --- a/content/browser/accessibility/browser_accessibility_manager_gtk.cc +++ b/content/browser/accessibility/browser_accessibility_manager_gtk.cc @@ -68,9 +68,9 @@ void BrowserAccessibilityManagerGtk::NotifyAccessibilityEvent( void BrowserAccessibilityManagerGtk::RecursivelySendChildrenChanged( BrowserAccessibilityGtk* node) { AtkObject* atkObject = node->ToBrowserAccessibilityGtk()->GetAtkObject(); - for (unsigned int i = 0; i < node->children().size(); ++i) { + for (unsigned int i = 0; i < node->InternalChildCount(); ++i) { BrowserAccessibilityGtk* child = - node->children()[i]->ToBrowserAccessibilityGtk(); + node->InternalGetChild(i)->ToBrowserAccessibilityGtk(); g_signal_emit_by_name(atkObject, "children-changed::add", i, diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm index 834799c..2a2f331 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.mm +++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm @@ -47,7 +47,7 @@ void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( NSString* event_id = @""; switch (event_type) { case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: - if (node->role() == ui::AX_ROLE_TREE) + if (node->GetRole() == ui::AX_ROLE_TREE) event_id = NSAccessibilitySelectedRowsChangedNotification; else event_id = NSAccessibilityFocusedUIElementChangedNotification; diff --git a/content/browser/accessibility/browser_accessibility_manager_unittest.cc b/content/browser/accessibility/browser_accessibility_manager_unittest.cc index 5e238a0..3cfeb55 100644 --- a/content/browser/accessibility/browser_accessibility_manager_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_manager_unittest.cc @@ -258,9 +258,9 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects) { child3_accessible->NativeAddReference(); // Check the index in parent. - EXPECT_EQ(0, child1_accessible->index_in_parent()); - EXPECT_EQ(1, child2_accessible->index_in_parent()); - EXPECT_EQ(2, child3_accessible->index_in_parent()); + EXPECT_EQ(0, child1_accessible->GetIndexInParent()); + EXPECT_EQ(1, child2_accessible->GetIndexInParent()); + EXPECT_EQ(2, child3_accessible->GetIndexInParent()); // Process a notification containing the changed subtree. std::vector<AccessibilityHostMsg_EventParams> params; @@ -284,8 +284,8 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects) { EXPECT_FALSE(child3_accessible->instance_active()); // Check that the index in parent has been updated. - EXPECT_EQ(1, child1_accessible->index_in_parent()); - EXPECT_EQ(2, child2_accessible->index_in_parent()); + EXPECT_EQ(1, child1_accessible->GetIndexInParent()); + EXPECT_EQ(2, child2_accessible->GetIndexInParent()); // Release our references. The object count should only decrease by 1 // for child3. @@ -435,8 +435,8 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects2) { child3_accessible->NativeAddReference(); // Check the index in parent. - EXPECT_EQ(1, child2_accessible->index_in_parent()); - EXPECT_EQ(2, child3_accessible->index_in_parent()); + EXPECT_EQ(1, child2_accessible->GetIndexInParent()); + EXPECT_EQ(2, child3_accessible->GetIndexInParent()); // Process a notification containing the changed subtree rooted at // the container. @@ -462,11 +462,11 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects2) { EXPECT_FALSE(child3_accessible->instance_active()); // Ensure that we retain the parent of the detached subtree. - EXPECT_EQ(root_accessible, container_accessible->parent()); - EXPECT_EQ(0, container_accessible->index_in_parent()); + EXPECT_EQ(root_accessible, container_accessible->GetParent()); + EXPECT_EQ(0, container_accessible->GetIndexInParent()); // Check that the index in parent has been updated. - EXPECT_EQ(2, child2_accessible->index_in_parent()); + EXPECT_EQ(2, child2_accessible->GetIndexInParent()); // Release our references. The object count should only decrease by 1 // for child3. diff --git a/content/browser/accessibility/browser_accessibility_manager_win.cc b/content/browser/accessibility/browser_accessibility_manager_win.cc index ab896d2..795fe04 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.cc +++ b/content/browser/accessibility/browser_accessibility_manager_win.cc @@ -84,7 +84,7 @@ void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, void BrowserAccessibilityManagerWin::AddNodeToMap(BrowserAccessibility* node) { BrowserAccessibilityManager::AddNodeToMap(node); LONG unique_id_win = node->ToBrowserAccessibilityWin()->unique_id_win(); - unique_id_to_renderer_id_map_[unique_id_win] = node->renderer_id(); + unique_id_to_renderer_id_map_[unique_id_win] = node->GetId(); } void BrowserAccessibilityManagerWin::RemoveNode(BrowserAccessibility* node) { @@ -114,7 +114,7 @@ void BrowserAccessibilityManagerWin::OnWindowBlurred() { void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( ui::AXEvent event_type, BrowserAccessibility* node) { - if (node->role() == ui::AX_ROLE_INLINE_TEXT_BOX) + if (node->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) return; LONG event_id = EVENT_MIN; diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc index 5d35f25..c96c785 100644 --- a/content/browser/accessibility/browser_accessibility_win.cc +++ b/content/browser/accessibility/browser_accessibility_win.cc @@ -493,7 +493,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { if (!disp_parent) return E_INVALIDARG; - IAccessible* parent_obj = parent()->ToBrowserAccessibilityWin(); + IAccessible* parent_obj = GetParent()->ToBrowserAccessibilityWin(); if (parent_obj == NULL) { // This happens if we're the root of the tree; // return the IAccessible for the window. @@ -611,12 +611,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { if (!instance_active()) return E_FAIL; - if (blink_role() != ui::AX_ROLE_LIST_BOX) + if (GetRole() != ui::AX_ROLE_LIST_BOX) return E_NOTIMPL; unsigned long selected_count = 0; - for (size_t i = 0; i < children().size(); ++i) { - if (children()[i]->HasState(ui::AX_STATE_SELECTED)) + for (size_t i = 0; i < InternalChildCount(); ++i) { + if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) ++selected_count; } @@ -626,11 +626,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { } if (selected_count == 1) { - for (size_t i = 0; i < children().size(); ++i) { - if (children()[i]->HasState(ui::AX_STATE_SELECTED)) { + for (size_t i = 0; i < InternalChildCount(); ++i) { + if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { selected->vt = VT_DISPATCH; selected->pdispVal = - children()[i]->ToBrowserAccessibilityWin()->NewReference(); + InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference(); return S_OK; } } @@ -641,11 +641,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(ui::AX_STATE_SELECTED)) { + for (size_t i = 0; i < InternalChildCount(); ++i) { + if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { enum_variant->ItemAt(index)->vt = VT_DISPATCH; enum_variant->ItemAt(index)->pdispVal = - children()[i]->ToBrowserAccessibilityWin()->NewReference(); + InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference(); ++index; } } @@ -749,7 +749,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { if (!index_in_parent) return E_INVALIDARG; - *index_in_parent = this->index_in_parent(); + *index_in_parent = this->GetIndexInParent(); return S_OK; } @@ -810,7 +810,7 @@ STDMETHODIMP BrowserAccessibilityWin::scrollTo(enum IA2ScrollType scroll_type) { if (!instance_active()) return E_FAIL; - gfx::Rect r = location(); + gfx::Rect r = GetLocation(); switch(scroll_type) { case IA2_SCROLL_TYPE_TOP_LEFT: manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); @@ -858,8 +858,8 @@ STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { scroll_to -= manager()->GetViewBounds().OffsetFromOrigin(); } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { - if (parent()) - scroll_to += parent()->location().OffsetFromOrigin(); + if (GetParent()) + scroll_to += GetParent()->GetLocation().OffsetFromOrigin(); } else { return E_INVALIDARG; } @@ -880,12 +880,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( if (!group_level || !similar_items_in_group || !position_in_group) return E_INVALIDARG; - if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && - parent() && - parent()->role() == ui::AX_ROLE_LIST_BOX) { + if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && + GetParent() && + GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { *group_level = 0; - *similar_items_in_group = parent()->PlatformChildCount(); - *position_in_group = index_in_parent() + 1; + *similar_items_in_group = GetParent()->PlatformChildCount(); + *position_in_group = GetIndexInParent() + 1; return S_OK; } @@ -994,14 +994,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( 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 = GetLocation().x() + top_left.x; + *y = GetLocation().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 = GetLocation().x(); + *y = GetLocation().y(); + if (GetParent()) { + *x -= GetParent()->GetLocation().x(); + *y -= GetParent()->GetLocation().y(); } } else { return E_INVALIDARG; @@ -1017,8 +1017,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { if (!height || !width) return E_INVALIDARG; - *height = location().height(); - *width = location().width(); + *height = GetLocation().height(); + *width = GetLocation().width(); return S_OK; } @@ -1142,7 +1142,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, int cell_id = cell_ids[i * columns + column]; BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( manager()->GetFromRendererID(cell_id)); - if (cell && cell->blink_role() == ui::AX_ROLE_COLUMN_HEADER) { + if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { base::string16 cell_name = cell->GetString16Attribute( ui::AX_ATTR_NAME); if (cell_name.size() > 0) { @@ -1329,7 +1329,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, int cell_id = cell_ids[row * columns + i]; BrowserAccessibilityWin* cell = manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); - if (cell && cell->blink_role() == ui::AX_ROLE_ROW_HEADER) { + if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { base::string16 cell_name = cell->GetString16Attribute( ui::AX_ATTR_NAME); if (cell_name.size() > 0) { @@ -1651,9 +1651,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( return S_FALSE; } - BrowserAccessibility* table = parent(); - while (table && table->role() != ui::AX_ROLE_TABLE) - table = table->parent(); + BrowserAccessibility* table = GetParent(); + while (table && table->GetRole() != ui::AX_ROLE_TABLE) + table = table->GetParent(); if (!table) { NOTREACHED(); return S_FALSE; @@ -1677,7 +1677,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( int cell_id = cell_ids[i * columns + column]; BrowserAccessibilityWin* cell = manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); - if (cell && cell->blink_role() == ui::AX_ROLE_COLUMN_HEADER) + if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) (*n_column_header_cells)++; } @@ -1687,7 +1687,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( for (int i = 0; i < rows; ++i) { int cell_id = cell_ids[i * columns + column]; BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); - if (cell && cell->role() == ui::AX_ROLE_COLUMN_HEADER) { + if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { (*cell_accessibles)[index] = static_cast<IAccessible*>( cell->ToBrowserAccessibilityWin()->NewReference()); ++index; @@ -1749,9 +1749,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( return S_FALSE; } - BrowserAccessibility* table = parent(); - while (table && table->role() != ui::AX_ROLE_TABLE) - table = table->parent(); + BrowserAccessibility* table = GetParent(); + while (table && table->GetRole() != ui::AX_ROLE_TABLE) + table = table->GetParent(); if (!table) { NOTREACHED(); return S_FALSE; @@ -1774,7 +1774,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( for (int i = 0; i < columns; ++i) { int cell_id = cell_ids[row * columns + i]; BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); - if (cell && cell->role() == ui::AX_ROLE_ROW_HEADER) + if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) (*n_row_header_cells)++; } @@ -1784,7 +1784,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( for (int i = 0; i < columns; ++i) { int cell_id = cell_ids[row * columns + i]; BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); - if (cell && cell->role() == ui::AX_ROLE_ROW_HEADER) { + if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { (*cell_accessibles)[index] = static_cast<IAccessible*>( cell->ToBrowserAccessibilityWin()->NewReference()); ++index; @@ -1872,9 +1872,9 @@ STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row); GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column); - BrowserAccessibility* find_table = parent(); - while (find_table && find_table->role() != ui::AX_ROLE_TABLE) - find_table = find_table->parent(); + BrowserAccessibility* find_table = GetParent(); + while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE) + find_table = find_table->GetParent(); if (!find_table) { NOTREACHED(); return S_FALSE; @@ -1909,8 +1909,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { return E_INVALIDARG; *offset = 0; - if (blink_role() == ui::AX_ROLE_TEXT_FIELD || - blink_role() == ui::AX_ROLE_TEXT_AREA) { + if (GetRole() == ui::AX_ROLE_TEXT_FIELD || + GetRole() == ui::AX_ROLE_TEXT_AREA) { int sel_start = 0; if (GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, &sel_start)) @@ -1944,7 +1944,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( character_bounds = GetGlobalBoundsForRange(offset, 1); } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { character_bounds = GetLocalBoundsForRange(offset, 1); - character_bounds -= location().OffsetFromOrigin(); + character_bounds -= GetLocation().OffsetFromOrigin(); } else { return E_INVALIDARG; } @@ -1965,8 +1965,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { return E_INVALIDARG; *n_selections = 0; - if (blink_role() == ui::AX_ROLE_TEXT_FIELD || - blink_role() == ui::AX_ROLE_TEXT_AREA) { + if (GetRole() == ui::AX_ROLE_TEXT_FIELD || + GetRole() == ui::AX_ROLE_TEXT_AREA) { int sel_start = 0; int sel_end = 0; if (GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, @@ -1990,8 +1990,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, *start_offset = 0; *end_offset = 0; - if (blink_role() == ui::AX_ROLE_TEXT_FIELD || - blink_role() == ui::AX_ROLE_TEXT_AREA) { + if (GetRole() == ui::AX_ROLE_TEXT_FIELD || + GetRole() == ui::AX_ROLE_TEXT_AREA) { int sel_start = 0; int sel_end = 0; if (GetIntAttribute( @@ -2275,7 +2275,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( } BrowserAccessibilityWin* child = - children()[hyperlinks_[index]]->ToBrowserAccessibilityWin(); + InternalGetChild(hyperlinks_[index])->ToBrowserAccessibilityWin(); *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); return S_OK; } @@ -2470,15 +2470,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributes( return E_INVALIDARG; *num_attribs = max_attribs; - if (*num_attribs > html_attributes().size()) - *num_attribs = html_attributes().size(); + if (*num_attribs > GetHtmlAttributes().size()) + *num_attribs = GetHtmlAttributes().size(); for (unsigned short i = 0; i < *num_attribs; ++i) { attrib_names[i] = SysAllocString( - base::UTF8ToUTF16(html_attributes()[i].first).c_str()); + base::UTF8ToUTF16(GetHtmlAttributes()[i].first).c_str()); name_space_id[i] = 0; attrib_values[i] = SysAllocString( - base::UTF8ToUTF16(html_attributes()[i].second).c_str()); + base::UTF8ToUTF16(GetHtmlAttributes()[i].second).c_str()); } return S_OK; } @@ -2498,10 +2498,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( name_space_id[i] = 0; bool found = false; std::string name = base::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 < GetHtmlAttributes().size(); ++j) { + if (GetHtmlAttributes()[j].first == name) { attrib_values[i] = SysAllocString( - base::UTF8ToUTF16(html_attributes()[j].second).c_str()); + base::UTF8ToUTF16(GetHtmlAttributes()[j].second).c_str()); found = true; break; } @@ -2581,7 +2581,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { if (!node) return E_INVALIDARG; - *node = parent()->ToBrowserAccessibilityWin()->NewReference(); + *node = GetParent()->ToBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2626,12 +2626,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( if (!node) return E_INVALIDARG; - if (!parent() || index_in_parent() <= 0) { + if (!GetParent() || GetIndexInParent() <= 0) { *node = NULL; return S_FALSE; } - *node = parent()->children()[index_in_parent() - 1]-> + *node = GetParent()->InternalGetChild(GetIndexInParent() - 1)-> ToBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2643,14 +2643,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { if (!node) return E_INVALIDARG; - if (!parent() || - index_in_parent() < 0 || - index_in_parent() >= static_cast<int>(parent()->children().size()) - 1) { + if (!GetParent() || + GetIndexInParent() < 0 || + GetIndexInParent() >= static_cast<int>( + GetParent()->InternalChildCount()) - 1) { *node = NULL; return S_FALSE; } - *node = parent()->children()[index_in_parent() + 1]-> + *node = GetParent()->InternalGetChild(GetIndexInParent() + 1)-> ToBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2911,13 +2912,13 @@ void BrowserAccessibilityWin::PreInitialize() { IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level"); // Expose the set size and position in set for listbox options. - if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && - parent() && - parent()->role() == ui::AX_ROLE_LIST_BOX) { + if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && + GetParent() && + GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { ia2_attributes_.push_back( - L"setsize:" + base::IntToString16(parent()->PlatformChildCount())); + L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount())); ia2_attributes_.push_back( - L"setsize:" + base::IntToString16(index_in_parent() + 1)); + L"setsize:" + base::IntToString16(GetIndexInParent() + 1)); } if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || @@ -2951,14 +2952,14 @@ void BrowserAccessibilityWin::PreInitialize() { // Expose table cell index. if (ia_role_ == ROLE_SYSTEM_CELL) { - BrowserAccessibility* table = parent(); - while (table && table->role() != ui::AX_ROLE_TABLE) - table = table->parent(); + BrowserAccessibility* table = GetParent(); + while (table && table->GetRole() != ui::AX_ROLE_TABLE) + table = table->GetParent(); if (table) { const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( ui::AX_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] == GetId()) { ia2_attributes_.push_back( base::string16(L"table-cell-index:") + base::IntToString16(i)); } @@ -3022,7 +3023,7 @@ void BrowserAccessibilityWin::PreInitialize() { // If it's a text field, also consider the placeholder. std::string placeholder; - if (blink_role() == ui::AX_ROLE_TEXT_FIELD && + if (GetRole() == ui::AX_ROLE_TEXT_FIELD && HasState(ui::AX_STATE_FOCUSABLE) && GetHtmlAttribute("placeholder", &placeholder)) { if (name().empty() && !title_elem_id) { @@ -3036,8 +3037,8 @@ void BrowserAccessibilityWin::PreInitialize() { SetStringAttribute(ui::AX_ATTR_HELP, help); // On Windows, the value of a document should be its url. - if (blink_role() == ui::AX_ROLE_ROOT_WEB_AREA || - blink_role() == ui::AX_ROLE_WEB_AREA) { + if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || + GetRole() == ui::AX_ROLE_WEB_AREA) { set_value(GetStringAttribute(ui::AX_ATTR_DOC_URL)); } @@ -3045,9 +3046,9 @@ void BrowserAccessibilityWin::PreInitialize() { // WebKit stores the main accessible text in the "value" - swap it so // that it's the "name". if (name().empty() && - (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION || - blink_role() == ui::AX_ROLE_STATIC_TEXT || - blink_role() == ui::AX_ROLE_LIST_MARKER)) { + (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || + GetRole() == ui::AX_ROLE_STATIC_TEXT || + GetRole() == ui::AX_ROLE_LIST_MARKER)) { std::string tmp = value(); set_value(name()); set_name(tmp); @@ -3086,7 +3087,7 @@ void BrowserAccessibilityWin::PostInitialize() { hypertext_.clear(); for (unsigned int i = 0; i < PlatformChildCount(); ++i) { BrowserAccessibility* child = PlatformGetChild(i); - if (child->role() == ui::AX_ROLE_STATIC_TEXT) { + if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) { hypertext_ += base::UTF8ToUTF16(child->name()); } else { hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); @@ -3097,7 +3098,7 @@ void BrowserAccessibilityWin::PostInitialize() { DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); // Fire an event when an alert first appears. - if (blink_role() == ui::AX_ROLE_ALERT && first_time_) + if (GetRole() == ui::AX_ROLE_ALERT && first_time_) manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); // Fire events if text has changed. @@ -3123,7 +3124,7 @@ void BrowserAccessibilityWin::PostInitialize() { // focus for managed descendants is platform-specific. // Fire a focus event if the focused descendant in a multi-select // list box changes. - if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && + if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && (ia_state_ & STATE_SYSTEM_FOCUSABLE) && (ia_state_ & STATE_SYSTEM_SELECTABLE) && (ia_state_ & STATE_SYSTEM_FOCUSED) && @@ -3259,7 +3260,7 @@ base::string16 BrowserAccessibilityWin::GetValueText() { base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { if (IsEditableText()) return base::UTF8ToUTF16(value()); - return (blink_role() == ui::AX_ROLE_STATIC_TEXT) ? + return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? base::UTF8ToUTF16(name()) : hypertext_; } @@ -3379,7 +3380,7 @@ void BrowserAccessibilityWin::InitRoleAndState() { ui::AX_ATTR_HTML_TAG); ia_role_ = 0; ia2_role_ = 0; - switch (blink_role()) { + switch (GetRole()) { case ui::AX_ROLE_ALERT: 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 713960a..137f8b9 100644 --- a/content/browser/accessibility/browser_accessibility_win.h +++ b/content/browser/accessibility/browser_accessibility_win.h @@ -772,10 +772,6 @@ 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 diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index 42b211b..09704ea 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc @@ -618,9 +618,9 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { // Verify the root is as we expect by default. BrowserAccessibility* root = manager->GetRoot(); - EXPECT_EQ(0, root->renderer_id()); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->role()); - EXPECT_EQ(busy_state | readonly_state | enabled_state, root->state()); + EXPECT_EQ(0, root->GetId()); + EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->GetRole()); + EXPECT_EQ(busy_state | readonly_state | enabled_state, root->GetState()); // Tree with a child textfield. ui::AXNodeData tree1_1; @@ -649,8 +649,8 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { EXPECT_NE(root, manager->GetRoot()); // And the proper child remains. - EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, acc1_2->role()); - EXPECT_EQ(2, acc1_2->renderer_id()); + EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, acc1_2->GetRole()); + EXPECT_EQ(2, acc1_2->GetId()); // Tree with a child button. ui::AXNodeData tree2_1; @@ -676,8 +676,8 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { EXPECT_NE(root, manager->GetRoot()); // And the new child exists. - EXPECT_EQ(ui::AX_ROLE_BUTTON, acc2_2->role()); - EXPECT_EQ(3, acc2_2->renderer_id()); + EXPECT_EQ(ui::AX_ROLE_BUTTON, acc2_2->GetRole()); + EXPECT_EQ(3, acc2_2->GetId()); // Ensure we properly cleaned up. manager.reset(); |