diff options
16 files changed, 425 insertions, 405 deletions
diff --git a/content/browser/accessibility/accessibility_tree_formatter.cc b/content/browser/accessibility/accessibility_tree_formatter.cc index edd366d..999476f 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.InternalGetChild(i); + BrowserAccessibility* child_node = node.children()[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.GetId()); + dict->SetInteger("id", node.renderer_id()); } 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 748dabe..3891182 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_gtk.cc +++ b/content/browser/accessibility/accessibility_tree_formatter_gtk.cc @@ -25,28 +25,26 @@ void AccessibilityTreeFormatter::AddProperties(const BrowserAccessibility& node, dict->SetString("role", atk_role_get_name(role)); dict->SetString("name", atk_object_get_name(atk_object)); dict->SetString("description", atk_object_get_description(atk_object)); - AtkStateSet* GetState()set = + AtkStateSet* state_set = atk_object_ref_state_set(atk_object); base::ListValue* states = new base::ListValue; for (int i = ATK_STATE_INVALID; i < ATK_STATE_LAST_DEFINED; i++) { - AtkStateType GetState()type = static_cast<AtkStateType>(i); + AtkStateType state_type = static_cast<AtkStateType>(i); if (atk_state_set_contains_state(state_set, state_type)) states->AppendString(atk_state_type_get_name(state_type)); } dict->Set("states", states); - dict->SetInteger("id", node.GetId()); + dict->SetInteger("id", node.renderer_id()); } base::string16 AccessibilityTreeFormatter::ToString( const base::DictionaryValue& node, const base::string16& indent) { base::string16 line; - std::string GetRole()value; + std::string role_value; node.GetString("role", &role_value); - if (!role_value.empty()) { - WriteAttribute(true, - base::StringPrintf("[%s]", GetRole()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); @@ -65,9 +63,9 @@ base::string16 AccessibilityTreeFormatter::ToString( for (base::ListValue::const_iterator it = states_value->begin(); it != states_value->end(); ++it) { - std::string GetState()value; + std::string state_value; if ((*it)->GetAsString(&state_value)) - WriteAttribute(true, GetState()value, &line); + WriteAttribute(true, state_value, &line); } int id_value; diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc index f2f7e7f..18a24b4 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), - deprecated_parent_(NULL), - deprecated_index_in_parent_(0), + parent_(NULL), + index_in_parent_(0), + renderer_id_(0), + role_(0), + state_(0), instance_active_(false) { - data_.id = 0; - data_.role = ui::AX_ROLE_UNKNOWN; - data_.state = 0; } BrowserAccessibility::~BrowserAccessibility() { } bool BrowserAccessibility::PlatformIsLeaf() const { - if (InternalChildCount() == 0) + if (child_count() == 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 (GetRole()) { + switch (role_) { case ui::AX_ROLE_EDITABLE_TEXT: case ui::AX_ROLE_SLIDER: case ui::AX_ROLE_STATIC_TEXT: @@ -58,32 +58,40 @@ bool BrowserAccessibility::PlatformIsLeaf() const { } uint32 BrowserAccessibility::PlatformChildCount() const { - return PlatformIsLeaf() ? 0 : InternalChildCount(); + return PlatformIsLeaf() ? 0 : children_.size(); } void BrowserAccessibility::DetachTree( std::vector<BrowserAccessibility*>* nodes) { nodes->push_back(this); - for (size_t i = 0; i < InternalChildCount(); ++i) - InternalGetChild(i)->DetachTree(nodes); - deprecated_children_.clear(); - deprecated_parent_ = NULL; + for (size_t i = 0; i < children_.size(); ++i) + children_[i]->DetachTree(nodes); + children_.clear(); + parent_ = NULL; } void BrowserAccessibility::InitializeTreeStructure( BrowserAccessibilityManager* manager, BrowserAccessibility* parent, - int32 id, + int32 renderer_id, int32 index_in_parent) { manager_ = manager; - deprecated_parent_ = parent; - data_.id = id; - deprecated_index_in_parent_ = index_in_parent; + parent_ = parent; + renderer_id_ = renderer_id; + index_in_parent_ = index_in_parent; } void BrowserAccessibility::InitializeData(const ui::AXNodeData& src) { - DCHECK_EQ(data_.id, src.id); - data_ = 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; instance_active_ = true; GetStringAttribute(ui::AX_ATTR_NAME, &name_); @@ -98,25 +106,25 @@ bool BrowserAccessibility::IsNative() const { void BrowserAccessibility::SwapChildren( std::vector<BrowserAccessibility*>& children) { - children.swap(deprecated_children_); + children.swap(children_); } void BrowserAccessibility::UpdateParent(BrowserAccessibility* parent, int index_in_parent) { - deprecated_parent_ = parent; - deprecated_index_in_parent_ = index_in_parent; + parent_ = parent; + index_in_parent_ = index_in_parent; } void BrowserAccessibility::SetLocation(const gfx::Rect& new_location) { - data_.location = new_location; + location_ = new_location; } bool BrowserAccessibility::IsDescendantOf( BrowserAccessibility* ancestor) { if (this == ancestor) { return true; - } else if (GetParent()) { - return GetParent()->IsDescendantOf(ancestor); + } else if (parent_) { + return parent_->IsDescendantOf(ancestor); } return false; @@ -124,55 +132,54 @@ bool BrowserAccessibility::IsDescendantOf( BrowserAccessibility* BrowserAccessibility::PlatformGetChild( uint32 child_index) const { - DCHECK(child_index < InternalChildCount()); - return InternalGetChild(child_index); + DCHECK(child_index < children_.size()); + return children_[child_index]; } BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() { - if (GetParent() && GetIndexInParent() > 0) - return GetParent()->InternalGetChild(GetIndexInParent() - 1); + if (parent_ && index_in_parent_ > 0) + return parent_->children_[index_in_parent_ - 1]; return NULL; } BrowserAccessibility* BrowserAccessibility::GetNextSibling() { - if (GetParent() && - GetIndexInParent() >= 0 && - GetIndexInParent() < static_cast<int>( - GetParent()->InternalChildCount() - 1)) { - return GetParent()->InternalGetChild(GetIndexInParent() + 1); + if (parent_ && + index_in_parent_ >= 0 && + index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { + return parent_->children_[index_in_parent_ + 1]; } return NULL; } gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { - gfx::Rect bounds = GetLocation(); + gfx::Rect bounds = location_; // 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 = GetParent(); + BrowserAccessibility* parent = parent_; bool need_to_offset_web_area = - (GetRole() == ui::AX_ROLE_WEB_AREA || - GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); + (role_ == ui::AX_ROLE_WEB_AREA || + role_ == ui::AX_ROLE_ROOT_WEB_AREA); while (parent) { if (need_to_offset_web_area && - parent->GetLocation().width() > 0 && - parent->GetLocation().height() > 0) { - bounds.Offset(parent->GetLocation().x(), parent->GetLocation().y()); + parent->location().width() > 0 && + parent->location().height() > 0) { + bounds.Offset(parent->location().x(), parent->location().y()); need_to_offset_web_area = false; } // On some platforms, we don't want to take the root scroll offsets // into account. - if (parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && + if (parent->role() == ui::AX_ROLE_ROOT_WEB_AREA && !manager()->UseRootScrollOffsetsWhenComputingBounds()) { break; } - if (parent->GetRole() == ui::AX_ROLE_WEB_AREA || - parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) { + if (parent->role() == ui::AX_ROLE_WEB_AREA || + parent->role() == ui::AX_ROLE_ROOT_WEB_AREA) { int sx = 0; int sy = 0; if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && @@ -181,7 +188,7 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { } need_to_offset_web_area = true; } - parent = parent->GetParent(); + parent = parent->parent(); } return bounds; @@ -199,14 +206,14 @@ gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const { gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) const { - if (GetRole() != ui::AX_ROLE_STATIC_TEXT) { + if (role() != 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 < InternalChildCount(); ++i) { - BrowserAccessibility* child = InternalGetChild(i); + for (size_t i = 0; i < children_.size(); ++i) { + BrowserAccessibility* child = children_[i]; int child_len = child->GetStaticTextLenRecursive(); if (start < child_len && start + len > 0) { gfx::Rect child_rect = child->GetLocalBoundsForRange(start, len); @@ -222,9 +229,9 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) int child_end = 0; gfx::Rect bounds; - 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); + 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); std::string child_text; child->GetStringAttribute(ui::AX_ATTR_VALUE, &child_text); int child_len = static_cast<int>(child_text.size()); @@ -240,7 +247,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->GetLocation(); + gfx::Rect child_rect = child->location(); int text_direction = child->GetIntAttribute( ui::AX_ATTR_TEXT_DIRECTION); const std::vector<int32>& character_offsets = child->GetIntListAttribute( @@ -321,7 +328,7 @@ BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( // Skip table columns because cells are only contained in rows, // not columns. - if (child->GetRole() == ui::AX_ROLE_COLUMN) + if (child->role() == ui::AX_ROLE_COLUMN) continue; if (child->GetGlobalBoundsRect().Contains(point)) { @@ -351,9 +358,12 @@ BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( } void BrowserAccessibility::Destroy() { - for (uint32 i = 0; i < InternalChildCount(); i++) - InternalGetChild(i)->Destroy(); - deprecated_children_.clear(); + for (std::vector<BrowserAccessibility*>::iterator iter = children_.begin(); + iter != children_.end(); + ++iter) { + (*iter)->Destroy(); + } + children_.clear(); // Allow the object to fire a TextRemoved notification. name_.clear(); @@ -373,8 +383,8 @@ void BrowserAccessibility::NativeReleaseReference() { bool BrowserAccessibility::HasBoolAttribute( ui::AXBoolAttribute attribute) const { - for (size_t i = 0; i < data_.bool_attributes.size(); ++i) { - if (data_.bool_attributes[i].first == attribute) + for (size_t i = 0; i < bool_attributes_.size(); ++i) { + if (bool_attributes_[i].first == attribute) return true; } @@ -384,9 +394,9 @@ bool BrowserAccessibility::HasBoolAttribute( bool BrowserAccessibility::GetBoolAttribute( ui::AXBoolAttribute attribute) const { - for (size_t i = 0; i < data_.bool_attributes.size(); ++i) { - if (data_.bool_attributes[i].first == attribute) - return data_.bool_attributes[i].second; + for (size_t i = 0; i < bool_attributes_.size(); ++i) { + if (bool_attributes_[i].first == attribute) + return bool_attributes_[i].second; } return false; @@ -394,9 +404,9 @@ bool BrowserAccessibility::GetBoolAttribute( bool BrowserAccessibility::GetBoolAttribute( ui::AXBoolAttribute attribute, bool* value) const { - for (size_t i = 0; i < data_.bool_attributes.size(); ++i) { - if (data_.bool_attributes[i].first == attribute) { - *value = data_.bool_attributes[i].second; + for (size_t i = 0; i < bool_attributes_.size(); ++i) { + if (bool_attributes_[i].first == attribute) { + *value = bool_attributes_[i].second; return true; } } @@ -406,8 +416,8 @@ bool BrowserAccessibility::GetBoolAttribute( bool BrowserAccessibility::HasFloatAttribute( ui::AXFloatAttribute attribute) const { - for (size_t i = 0; i < data_.float_attributes.size(); ++i) { - if (data_.float_attributes[i].first == attribute) + for (size_t i = 0; i < float_attributes_.size(); ++i) { + if (float_attributes_[i].first == attribute) return true; } @@ -416,9 +426,9 @@ bool BrowserAccessibility::HasFloatAttribute( float BrowserAccessibility::GetFloatAttribute( ui::AXFloatAttribute attribute) const { - for (size_t i = 0; i < data_.float_attributes.size(); ++i) { - if (data_.float_attributes[i].first == attribute) - return data_.float_attributes[i].second; + for (size_t i = 0; i < float_attributes_.size(); ++i) { + if (float_attributes_[i].first == attribute) + return float_attributes_[i].second; } return 0.0; @@ -426,9 +436,9 @@ float BrowserAccessibility::GetFloatAttribute( bool BrowserAccessibility::GetFloatAttribute( ui::AXFloatAttribute attribute, float* value) const { - for (size_t i = 0; i < data_.float_attributes.size(); ++i) { - if (data_.float_attributes[i].first == attribute) { - *value = data_.float_attributes[i].second; + for (size_t i = 0; i < float_attributes_.size(); ++i) { + if (float_attributes_[i].first == attribute) { + *value = float_attributes_[i].second; return true; } } @@ -438,8 +448,8 @@ bool BrowserAccessibility::GetFloatAttribute( bool BrowserAccessibility::HasIntAttribute( ui::AXIntAttribute attribute) const { - for (size_t i = 0; i < data_.int_attributes.size(); ++i) { - if (data_.int_attributes[i].first == attribute) + for (size_t i = 0; i < int_attributes_.size(); ++i) { + if (int_attributes_[i].first == attribute) return true; } @@ -447,9 +457,9 @@ bool BrowserAccessibility::HasIntAttribute( } int BrowserAccessibility::GetIntAttribute(ui::AXIntAttribute attribute) const { - for (size_t i = 0; i < data_.int_attributes.size(); ++i) { - if (data_.int_attributes[i].first == attribute) - return data_.int_attributes[i].second; + for (size_t i = 0; i < int_attributes_.size(); ++i) { + if (int_attributes_[i].first == attribute) + return int_attributes_[i].second; } return 0; @@ -457,9 +467,9 @@ int BrowserAccessibility::GetIntAttribute(ui::AXIntAttribute attribute) const { bool BrowserAccessibility::GetIntAttribute( ui::AXIntAttribute attribute, int* value) const { - for (size_t i = 0; i < data_.int_attributes.size(); ++i) { - if (data_.int_attributes[i].first == attribute) { - *value = data_.int_attributes[i].second; + for (size_t i = 0; i < int_attributes_.size(); ++i) { + if (int_attributes_[i].first == attribute) { + *value = int_attributes_[i].second; return true; } } @@ -469,8 +479,8 @@ bool BrowserAccessibility::GetIntAttribute( bool BrowserAccessibility::HasStringAttribute( ui::AXStringAttribute attribute) const { - for (size_t i = 0; i < data_.string_attributes.size(); ++i) { - if (data_.string_attributes[i].first == attribute) + for (size_t i = 0; i < string_attributes_.size(); ++i) { + if (string_attributes_[i].first == attribute) return true; } @@ -480,9 +490,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 < data_.string_attributes.size(); ++i) { - if (data_.string_attributes[i].first == attribute) - return data_.string_attributes[i].second; + for (size_t i = 0; i < string_attributes_.size(); ++i) { + if (string_attributes_[i].first == attribute) + return string_attributes_[i].second; } return empty_string; @@ -490,9 +500,9 @@ const std::string& BrowserAccessibility::GetStringAttribute( bool BrowserAccessibility::GetStringAttribute( ui::AXStringAttribute attribute, std::string* value) const { - for (size_t i = 0; i < data_.string_attributes.size(); ++i) { - if (data_.string_attributes[i].first == attribute) { - *value = data_.string_attributes[i].second; + for (size_t i = 0; i < string_attributes_.size(); ++i) { + if (string_attributes_[i].first == attribute) { + *value = string_attributes_[i].second; return true; } } @@ -520,20 +530,20 @@ bool BrowserAccessibility::GetString16Attribute( void BrowserAccessibility::SetStringAttribute( ui::AXStringAttribute attribute, const std::string& 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; + for (size_t i = 0; i < string_attributes_.size(); ++i) { + if (string_attributes_[i].first == attribute) { + string_attributes_[i].second = value; return; } } if (!value.empty()) - data_.string_attributes.push_back(std::make_pair(attribute, value)); + string_attributes_.push_back(std::make_pair(attribute, value)); } bool BrowserAccessibility::HasIntListAttribute( ui::AXIntListAttribute attribute) const { - for (size_t i = 0; i < data_.intlist_attributes.size(); ++i) { - if (data_.intlist_attributes[i].first == attribute) + for (size_t i = 0; i < intlist_attributes_.size(); ++i) { + if (intlist_attributes_[i].first == attribute) return true; } @@ -543,9 +553,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 < data_.intlist_attributes.size(); ++i) { - if (data_.intlist_attributes[i].first == attribute) - return data_.intlist_attributes[i].second; + for (size_t i = 0; i < intlist_attributes_.size(); ++i) { + if (intlist_attributes_[i].first == attribute) + return intlist_attributes_[i].second; } return empty_vector; @@ -554,9 +564,9 @@ const std::vector<int32>& BrowserAccessibility::GetIntListAttribute( bool BrowserAccessibility::GetIntListAttribute( ui::AXIntListAttribute attribute, std::vector<int32>* value) const { - for (size_t i = 0; i < data_.intlist_attributes.size(); ++i) { - if (data_.intlist_attributes[i].first == attribute) { - *value = data_.intlist_attributes[i].second; + for (size_t i = 0; i < intlist_attributes_.size(); ++i) { + if (intlist_attributes_[i].first == attribute) { + *value = intlist_attributes_[i].second; return true; } } @@ -566,10 +576,10 @@ bool BrowserAccessibility::GetIntListAttribute( bool BrowserAccessibility::GetHtmlAttribute( const char* html_attr, std::string* value) const { - for (size_t i = 0; i < GetHtmlAttributes().size(); ++i) { - const std::string& attr = GetHtmlAttributes()[i].first; + for (size_t i = 0; i < html_attributes_.size(); ++i) { + const std::string& attr = html_attributes_[i].first; if (LowerCaseEqualsASCII(attr, html_attr)) { - *value = GetHtmlAttributes()[i].second; + *value = html_attributes_[i].second; return true; } } @@ -612,14 +622,14 @@ bool BrowserAccessibility::GetAriaTristate( } bool BrowserAccessibility::HasState(ui::AXState state_enum) const { - return (GetState() >> state_enum) & 1; + return (state_ >> state_enum) & 1; } bool BrowserAccessibility::IsEditableText() const { // These roles don't have readonly set, but they're not editable text. - if (GetRole() == ui::AX_ROLE_SCROLL_AREA || - GetRole() == ui::AX_ROLE_COLUMN || - GetRole() == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { + if (role_ == ui::AX_ROLE_SCROLL_AREA || + role_ == ui::AX_ROLE_COLUMN || + role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { return false; } @@ -627,8 +637,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) || - GetRole() == ui::AX_ROLE_TEXT_FIELD || - GetRole() == ui::AX_ROLE_TEXT_AREA); + role_ == ui::AX_ROLE_TEXT_FIELD || + role_ == ui::AX_ROLE_TEXT_AREA); } std::string BrowserAccessibility::GetTextRecursive() const { @@ -643,12 +653,12 @@ std::string BrowserAccessibility::GetTextRecursive() const { } int BrowserAccessibility::GetStaticTextLenRecursive() const { - if (GetRole() == ui::AX_ROLE_STATIC_TEXT) + if (role_ == ui::AX_ROLE_STATIC_TEXT) return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); int len = 0; - for (size_t i = 0; i < InternalChildCount(); ++i) - len += InternalGetChild(i)->GetStaticTextLenRecursive(); + for (size_t i = 0; i < children_.size(); ++i) + len += children_[i]->GetStaticTextLenRecursive(); return len; } diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index d72a2ad..d1df6b9 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 id, + int32 renderer_id, int32 index_in_parent); // Initialize this object's data. @@ -83,6 +83,12 @@ 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. @@ -148,38 +154,26 @@ 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) @@ -279,7 +273,7 @@ class CONTENT_EXPORT BrowserAccessibility { BrowserAccessibilityManager* manager_; // The parent of this object, may be NULL if we're the root object. - BrowserAccessibility* deprecated_parent_; + BrowserAccessibility* parent_; private: // Return the sum of the lengths of all static text descendants, @@ -287,15 +281,32 @@ class CONTENT_EXPORT BrowserAccessibility { int GetStaticTextLenRecursive() const; // The index of this within its parent object. - int32 deprecated_index_in_parent_; + int32 index_in_parent_; + + // The ID of this object in the renderer process. + int32 renderer_id_; // The children of this object. - std::vector<BrowserAccessibility*> deprecated_children_; + std::vector<BrowserAccessibility*> children_; // Accessibility metadata from the renderer std::string name_; std::string value_; - ui::AXNodeData data_; + 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_; // 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 6e26ef9..f286c85 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 (InternalChildCount() == 0) + if (child_count() == 0) return true; // Iframes are always allowed to contain children. if (IsIframe() || - GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || - GetRole() == ui::AX_ROLE_WEB_AREA) { + role() == ui::AX_ROLE_ROOT_WEB_AREA || + role() == 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 (GetRole() == ui::AX_ROLE_HEADING && !name.empty()) + if (role() == 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 (GetRole() == ui::AX_ROLE_CHECK_BOX || - GetRole() == ui::AX_ROLE_RADIO_BUTTON || + if (role() == ui::AX_ROLE_CHECK_BOX || + role() == ui::AX_ROLE_RADIO_BUTTON || is_aria_pressed_defined) { checkable = true; } @@ -110,21 +110,21 @@ bool BrowserAccessibilityAndroid::IsClickable() const { } bool BrowserAccessibilityAndroid::IsCollection() const { - 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); + 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); } bool BrowserAccessibilityAndroid::IsCollectionItem() const { - 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); + 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); } 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() || - GetRole() == ui::AX_ROLE_WEB_AREA) { + role() == ui::AX_ROLE_WEB_AREA) { focusable = false; } return focusable; @@ -154,23 +154,22 @@ bool BrowserAccessibilityAndroid::IsFocused() const { } bool BrowserAccessibilityAndroid::IsHeading() const { - return (GetRole() == ui::AX_ROLE_COLUMN_HEADER || - GetRole() == ui::AX_ROLE_HEADING || - GetRole() == ui::AX_ROLE_ROW_HEADER); + return (role() == ui::AX_ROLE_COLUMN_HEADER || + role() == ui::AX_ROLE_HEADING || + role() == ui::AX_ROLE_ROW_HEADER); } bool BrowserAccessibilityAndroid::IsHierarchical() const { - return (GetRole() == ui::AX_ROLE_LIST || - GetRole() == ui::AX_ROLE_TREE); + return (role() == ui::AX_ROLE_LIST || + role() == ui::AX_ROLE_TREE); } bool BrowserAccessibilityAndroid::IsLink() const { - return GetRole() == ui::AX_ROLE_LINK || - GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK; + return role() == ui::AX_ROLE_LINK || role() == ui::AX_ROLE_IMAGE_MAP_LINK; } bool BrowserAccessibilityAndroid::IsMultiLine() const { - return GetRole() == ui::AX_ROLE_TEXT_AREA; + return role() == ui::AX_ROLE_TEXT_AREA; } bool BrowserAccessibilityAndroid::IsPassword() const { @@ -178,9 +177,9 @@ bool BrowserAccessibilityAndroid::IsPassword() const { } bool BrowserAccessibilityAndroid::IsRangeType() const { - return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR || - GetRole() == ui::AX_ROLE_SCROLL_BAR || - GetRole() == ui::AX_ROLE_SLIDER); + return (role() == ui::AX_ROLE_PROGRESS_INDICATOR || + role() == ui::AX_ROLE_SCROLL_BAR || + role() == ui::AX_ROLE_SLIDER); } bool BrowserAccessibilityAndroid::IsScrollable() const { @@ -203,7 +202,7 @@ bool BrowserAccessibilityAndroid::CanOpenPopup() const { const char* BrowserAccessibilityAndroid::GetClassName() const { const char* class_name = NULL; - switch(GetRole()) { + switch(role()) { case ui::AX_ROLE_EDITABLE_TEXT: case ui::AX_ROLE_SPIN_BUTTON: case ui::AX_ROLE_TEXT_AREA: @@ -264,7 +263,7 @@ const char* BrowserAccessibilityAndroid::GetClassName() const { base::string16 BrowserAccessibilityAndroid::GetText() const { if (IsIframe() || - GetRole() == ui::AX_ROLE_WEB_AREA) { + role() == ui::AX_ROLE_WEB_AREA) { return base::string16(); } @@ -281,13 +280,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 < InternalChildCount(); i++) { - BrowserAccessibility* child = InternalGetChild(i); + for (uint32 i = 0; i < child_count(); i++) { + BrowserAccessibility* child = children()[i]; text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText(); } } - switch(GetRole()) { + switch(role()) { case ui::AX_ROLE_HEADING: // Only append "heading" if this node already has text. if (!text.empty()) @@ -300,11 +299,11 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { int BrowserAccessibilityAndroid::GetItemIndex() const { int index = 0; - switch(GetRole()) { + switch(role()) { case ui::AX_ROLE_LIST_ITEM: case ui::AX_ROLE_LIST_BOX_OPTION: case ui::AX_ROLE_TREE_ITEM: - index = GetIndexInParent(); + index = index_in_parent(); break; case ui::AX_ROLE_SLIDER: case ui::AX_ROLE_PROGRESS_INDICATOR: { @@ -321,7 +320,7 @@ int BrowserAccessibilityAndroid::GetItemIndex() const { int BrowserAccessibilityAndroid::GetItemCount() const { int count = 0; - switch(GetRole()) { + switch(role()) { case ui::AX_ROLE_LIST: case ui::AX_ROLE_LIST_BOX: count = PlatformChildCount(); @@ -480,14 +479,14 @@ int BrowserAccessibilityAndroid::AndroidRangeType() const { } int BrowserAccessibilityAndroid::RowCount() const { - if (GetRole() == ui::AX_ROLE_GRID || - GetRole() == ui::AX_ROLE_TABLE) { + if (role() == ui::AX_ROLE_GRID || + role() == ui::AX_ROLE_TABLE) { return CountChildrenWithRole(ui::AX_ROLE_ROW); } - if (GetRole() == ui::AX_ROLE_LIST || - GetRole() == ui::AX_ROLE_LIST_BOX || - GetRole() == ui::AX_ROLE_TREE) { + if (role() == ui::AX_ROLE_LIST || + role() == ui::AX_ROLE_LIST_BOX || + role() == ui::AX_ROLE_TREE) { return PlatformChildCount(); } @@ -495,18 +494,18 @@ int BrowserAccessibilityAndroid::RowCount() const { } int BrowserAccessibilityAndroid::ColumnCount() const { - if (GetRole() == ui::AX_ROLE_GRID || - GetRole() == ui::AX_ROLE_TABLE) { + if (role() == ui::AX_ROLE_GRID || + role() == ui::AX_ROLE_TABLE) { return CountChildrenWithRole(ui::AX_ROLE_COLUMN); } return 0; } int BrowserAccessibilityAndroid::RowIndex() const { - if (GetRole() == ui::AX_ROLE_LIST_ITEM || - GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || - GetRole() == ui::AX_ROLE_TREE_ITEM) { - return GetIndexInParent(); + if (role() == ui::AX_ROLE_LIST_ITEM || + role() == ui::AX_ROLE_LIST_BOX_OPTION || + role() == ui::AX_ROLE_TREE_ITEM) { + return index_in_parent(); } return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX); @@ -539,8 +538,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 < InternalChildCount(); i++) { - BrowserAccessibility* child = InternalGetChild(i); + for (uint32 i = 0; i < child_count(); i++) { + BrowserAccessibility* child = children()[i]; if (child->HasState(ui::AX_STATE_FOCUSABLE)) return true; if (static_cast<BrowserAccessibilityAndroid*>(child)->HasFocusableChild()) @@ -552,9 +551,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 < InternalChildCount(); i++) { - BrowserAccessibility* child = InternalGetChild(i); - if (child->GetRole() != ui::AX_ROLE_STATIC_TEXT) + for (uint32 i = 0; i < child_count(); i++) { + BrowserAccessibility* child = children()[i]; + if (child->role() != ui::AX_ROLE_STATIC_TEXT) return false; } return true; @@ -576,7 +575,7 @@ void BrowserAccessibilityAndroid::PostInitialize() { } } - if (GetRole() == ui::AX_ROLE_ALERT && first_time_) + if (role() == ui::AX_ROLE_ALERT && first_time_) manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); base::string16 live; @@ -607,7 +606,7 @@ void BrowserAccessibilityAndroid::NotifyLiveRegionUpdate( int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { int count = 0; for (uint32 i = 0; i < PlatformChildCount(); i++) { - if (PlatformGetChild(i)->GetRole() == role) + if (PlatformGetChild(i)->role() == role) count++; } return count; diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm index 7a3a44b..fdfdd2c 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->GetState() >> state) & 1); + return ((accessibility->state() >> state) & 1); } RoleMap BuildRoleMap() { @@ -391,7 +391,7 @@ NSDictionary* attributeToMethodNameMap = nil; if (![self isIgnored]) { children_.reset(); } else { - [browserAccessibility_->GetParent()->ToBrowserAccessibilityCocoa() + [browserAccessibility_->parent()->ToBrowserAccessibilityCocoa() childrenChanged]; } } @@ -410,7 +410,7 @@ NSDictionary* attributeToMethodNameMap = nil; int id = uniqueCellIds[i]; BrowserAccessibility* cell = browserAccessibility_->manager()->GetFromRendererID(id); - if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) + if (cell && cell->role() == 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_->GetParent()) { + if (browserAccessibility_->parent()) { return NSAccessibilityUnignoredAncestor( - browserAccessibility_->GetParent()->ToBrowserAccessibilityCocoa()); + browserAccessibility_->parent()->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_->GetRole()); + return static_cast<ui::AXRole>(browserAccessibility_->role()); } // 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->GetRole() == ui::AX_ROLE_ROW_HEADER) + if (cell && cell->role() == 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->GetRole() != ui::AX_ROLE_ROW) + if (child->role() != 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->GetRole() != ui::AX_ROLE_CELL) + if (cell->role() != 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_->GetParent()) { + if (browserAccessibility_->parent()) { base::string16 parentRole; - browserAccessibility_->GetParent()->GetHtmlAttribute( + browserAccessibility_->parent()->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_->GetId()]; + [delegate_ doDefaultAction:browserAccessibility_->renderer_id()]; 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_->GetId()]; + accessibilityId:browserAccessibility_->renderer_id()]; } if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { NSRange range = [(NSValue*)value rangeValue]; [delegate_ - accessibilitySetTextSelection:browserAccessibility_->GetId() + accessibilitySetTextSelection:browserAccessibility_->renderer_id() 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_->GetId(); + return browserAccessibility_->renderer_id(); } - (BOOL)accessibilityShouldUseUniqueId { diff --git a/content/browser/accessibility/browser_accessibility_gtk.cc b/content/browser/accessibility/browser_accessibility_gtk.cc index d15dcc7..eb015eb 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->GetParent()) - return obj->GetParent()->ToBrowserAccessibilityGtk()->GetAtkObject(); + if (obj->parent()) + return obj->parent()->ToBrowserAccessibilityGtk()->GetAtkObject(); BrowserAccessibilityManagerGtk* manager = static_cast<BrowserAccessibilityManagerGtk*>(obj->manager()); @@ -222,7 +222,7 @@ static AtkObject* browser_accessibility_ref_child( return NULL; AtkObject* result = - obj->InternalGetChild(index)->ToBrowserAccessibilityGtk()->GetAtkObject(); + obj->children()[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->GetIndexInParent(); + return obj->index_in_parent(); } static AtkAttributeSet* browser_accessibility_get_attributes( @@ -243,17 +243,17 @@ static AtkRole browser_accessibility_get_role(AtkObject* atk_object) { BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); if (!obj) return ATK_ROLE_INVALID; - return obj->atk_GetRole(); + return obj->atk_role(); } static AtkStateSet* browser_accessibility_ref_state_set(AtkObject* atk_object) { BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); if (!obj) return NULL; - AtkStateSet* GetState()set = + AtkStateSet* state_set = ATK_OBJECT_CLASS(browser_accessibility_parent_class)-> ref_state_set(atk_object); - int32 state = obj->GetState(); + int32 state = obj->state(); if (state & (1 << ui::AX_STATE_FOCUSABLE)) atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE); @@ -262,7 +262,7 @@ static AtkStateSet* browser_accessibility_ref_state_set(AtkObject* atk_object) { if (state & (1 << ui::AX_STATE_ENABLED)) atk_state_set_add_state(state_set, ATK_STATE_ENABLED); - return GetState()set; + return state_set; } static AtkRelationSet* browser_accessibility_ref_relation_set( @@ -363,7 +363,7 @@ static int GetInterfaceMaskFromObject(BrowserAccessibilityGtk* obj) { // Component interface is always supported. interface_mask |= 1 << ATK_COMPONENT_INTERFACE; - int role = obj->GetRole(); + int role = obj->role(); 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->GetParent()) { + if (this->parent()) { atk_object_set_parent( atk_object_, - this->GetParent()->ToBrowserAccessibilityGtk()->GetAtkObject()); + this->parent()->ToBrowserAccessibilityGtk()->GetAtkObject()); } } } @@ -475,7 +475,7 @@ bool BrowserAccessibilityGtk::IsNative() const { } void BrowserAccessibilityGtk::InitRoleAndState() { - switch(GetRole()) { + switch(role()) { 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 a9fda6b..a28f690 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->GetId(); + int renderer_id = node->renderer_id(); renderer_id_map_.erase(renderer_id); } @@ -198,7 +198,7 @@ void BrowserAccessibilityManager::SetFocus( focus_ = node; if (notify && node && delegate_) - delegate_->SetAccessibilityFocus(node->GetId()); + delegate_->SetAccessibilityFocus(node->renderer_id()); } 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.GetId()); + delegate_->AccessibilityDoDefaultAction(node.renderer_id()); } void BrowserAccessibilityManager::ScrollToMakeVisible( const BrowserAccessibility& node, gfx::Rect subfocus) { if (delegate_) { - delegate_->AccessibilityScrollToMakeVisible(node.GetId(), subfocus); + delegate_->AccessibilityScrollToMakeVisible(node.renderer_id(), subfocus); } } void BrowserAccessibilityManager::ScrollToPoint( const BrowserAccessibility& node, gfx::Point point) { if (delegate_) { - delegate_->AccessibilityScrollToPoint(node.GetId(), point); + delegate_->AccessibilityScrollToPoint(node.renderer_id(), point); } } @@ -230,7 +230,7 @@ void BrowserAccessibilityManager::SetTextSelection( const BrowserAccessibility& node, int start_offset, int end_offset) { if (delegate_) { delegate_->AccessibilitySetTextSelection( - node.GetId(), start_offset, end_offset); + node.renderer_id(), start_offset, end_offset); } } @@ -248,12 +248,12 @@ BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder( if (node->PlatformChildCount() > 0) return node->PlatformGetChild(0); while (node) { - if (node->GetParent() && - node->GetIndexInParent() < - static_cast<int>(node->GetParent()->PlatformChildCount()) - 1) { - return node->GetParent()->PlatformGetChild(node->GetIndexInParent() + 1); + if (node->parent() && + node->index_in_parent() < + static_cast<int>(node->parent()->PlatformChildCount()) - 1) { + return node->parent()->PlatformGetChild(node->index_in_parent() + 1); } - node = node->GetParent(); + node = node->parent(); } return NULL; @@ -264,14 +264,14 @@ BrowserAccessibility* BrowserAccessibilityManager::PreviousInTreeOrder( if (!node) return NULL; - if (node->GetParent() && node->GetIndexInParent() > 0) { - node = node->GetParent()->PlatformGetChild(node->GetIndexInParent() - 1); + if (node->parent() && node->index_in_parent() > 0) { + node = node->parent()->PlatformGetChild(node->index_in_parent() - 1); while (node->PlatformChildCount() > 0) node = node->PlatformGetChild(node->PlatformChildCount() - 1); return node; } - return node->GetParent(); + return node->parent(); } void BrowserAccessibilityManager::UpdateNodesForTesting( @@ -363,7 +363,7 @@ BrowserAccessibility* BrowserAccessibilityManager::CreateNode( } void BrowserAccessibilityManager::AddNodeToMap(BrowserAccessibility* node) { - renderer_id_map_[node->GetId()] = node; + renderer_id_map_[node->renderer_id()] = node; } bool BrowserAccessibilityManager::UpdateNode(const ui::AXNodeData& src) { @@ -408,10 +408,9 @@ 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->deprecated_children(); + const std::vector<BrowserAccessibility*>& old_children = instance->children(); for (size_t i = 0; i < old_children.size(); ++i) { - int old_id = old_children[i]->GetId(); + int old_id = old_children[i]->renderer_id(); if (new_child_ids.find(old_id) == new_child_ids.end()) old_children[i]->Destroy(); } @@ -425,7 +424,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->GetParent() != instance) { + if (child->parent() != 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. @@ -444,7 +443,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_->GetId() != src.id)) { + (!root_ || root_->renderer_id() != 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 3d349e4..ef816e5 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->GetId()); + env, obj.obj(), node->renderer_id()); switch (event_type) { case ui::AX_EVENT_LOAD_COMPLETE: Java_BrowserAccessibilityManager_handlePageLoaded( - env, obj.obj(), focus_->GetId()); + env, obj.obj(), focus_->renderer_id()); break; case ui::AX_EVENT_FOCUS: Java_BrowserAccessibilityManager_handleFocusChanged( - env, obj.obj(), node->GetId()); + env, obj.obj(), node->renderer_id()); break; case ui::AX_EVENT_CHECKED_STATE_CHANGED: Java_BrowserAccessibilityManager_handleCheckStateChanged( - env, obj.obj(), node->GetId()); + env, obj.obj(), node->renderer_id()); break; case ui::AX_EVENT_SCROLL_POSITION_CHANGED: Java_BrowserAccessibilityManager_handleScrollPositionChanged( - env, obj.obj(), node->GetId()); + env, obj.obj(), node->renderer_id()); break; case ui::AX_EVENT_SCROLLED_TO_ANCHOR: Java_BrowserAccessibilityManager_handleScrolledToAnchor( - env, obj.obj(), node->GetId()); + env, obj.obj(), node->renderer_id()); 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->GetId()); + env, obj.obj(), node->renderer_id()); 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->GetId()); + env, obj.obj(), node->renderer_id()); } break; default: @@ -185,7 +185,7 @@ void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent( } jint BrowserAccessibilityManagerAndroid::GetRootId(JNIEnv* env, jobject obj) { - return static_cast<jint>(root_->GetId()); + return static_cast<jint>(root_->renderer_id()); } jboolean BrowserAccessibilityManagerAndroid::IsNodeValid( @@ -200,18 +200,18 @@ jint BrowserAccessibilityManagerAndroid::HitTest( root_->BrowserAccessibilityForPoint(gfx::Point(x, y))); if (!result) - return root_->GetId(); + return root_->renderer_id(); if (result->IsFocusable()) - return result->GetId(); + return result->renderer_id(); // 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->GetId(); + return nearest_node->renderer_id(); - return root_->GetId(); + return root_->renderer_id(); } jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityNodeInfo( @@ -221,13 +221,13 @@ jboolean BrowserAccessibilityManagerAndroid::PopulateAccessibilityNodeInfo( if (!node) return false; - if (node->GetParent()) { + if (node->parent()) { Java_BrowserAccessibilityManager_setAccessibilityNodeInfoParent( - env, obj, info, node->GetParent()->GetId()); + env, obj, info, node->parent()->renderer_id()); } for (unsigned i = 0; i < node->PlatformChildCount(); ++i) { Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild( - env, obj, info, node->InternalGetChild(i)->GetId()); + env, obj, info, node->children()[i]->renderer_id()); } 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->GetParent()) { - gfx::Rect parent_rect = node->GetParent()->GetLocalBoundsRect(); + if (node->parent()) { + gfx::Rect parent_rect = node->parent()->GetLocalBoundsRect(); parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin()); } - bool is_root = node->GetParent() == NULL; + bool is_root = node->parent() == 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->GetLocation().size())); + ScrollToMakeVisible(*node, gfx::Rect(node->location().size())); } BrowserAccessibility* BrowserAccessibilityManagerAndroid::FuzzyHitTest( @@ -478,30 +478,30 @@ jint BrowserAccessibilityManagerAndroid::FindElementType( while (node) { switch(element_type) { case HTML_ELEMENT_TYPE_SECTION: - 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(); + 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(); } break; case HTML_ELEMENT_TYPE_LIST: - 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(); + 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(); } break; case HTML_ELEMENT_TYPE_CONTROL: if (static_cast<BrowserAccessibilityAndroid*>(node)->IsFocusable()) - return node->GetId(); + return node->renderer_id(); 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->GetId(); + return node->renderer_id(); break; } diff --git a/content/browser/accessibility/browser_accessibility_manager_gtk.cc b/content/browser/accessibility/browser_accessibility_manager_gtk.cc index a493cfa..3d7a976 100644 --- a/content/browser/accessibility/browser_accessibility_manager_gtk.cc +++ b/content/browser/accessibility/browser_accessibility_manager_gtk.cc @@ -22,12 +22,12 @@ BrowserAccessibilityManager* BrowserAccessibilityManager::Create( } BrowserAccessibilityManagerGtk::BrowserAccessibilityManagerGtk( - GtkWidget* GetParent()widget, + GtkWidget* parent_widget, const ui::AXNodeData& src, BrowserAccessibilityDelegate* delegate, BrowserAccessibilityFactory* factory) : BrowserAccessibilityManager(delegate, factory), - GetParent()widget_(GetParent()widget) { + parent_widget_(parent_widget) { Initialize(src); } @@ -68,9 +68,9 @@ void BrowserAccessibilityManagerGtk::NotifyAccessibilityEvent( void BrowserAccessibilityManagerGtk::RecursivelySendChildrenChanged( BrowserAccessibilityGtk* node) { AtkObject* atkObject = node->ToBrowserAccessibilityGtk()->GetAtkObject(); - for (unsigned int i = 0; i < node->InternalChildCount(); ++i) { + for (unsigned int i = 0; i < node->children().size(); ++i) { BrowserAccessibilityGtk* child = - node->InternalGetChild(i)->ToBrowserAccessibilityGtk(); + node->children()[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 2a2f331..834799c 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->GetRole() == ui::AX_ROLE_TREE) + if (node->role() == 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 3cfeb55..5e238a0 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->GetIndexInParent()); - EXPECT_EQ(1, child2_accessible->GetIndexInParent()); - EXPECT_EQ(2, child3_accessible->GetIndexInParent()); + EXPECT_EQ(0, child1_accessible->index_in_parent()); + EXPECT_EQ(1, child2_accessible->index_in_parent()); + EXPECT_EQ(2, child3_accessible->index_in_parent()); // 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->GetIndexInParent()); - EXPECT_EQ(2, child2_accessible->GetIndexInParent()); + EXPECT_EQ(1, child1_accessible->index_in_parent()); + EXPECT_EQ(2, child2_accessible->index_in_parent()); // 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->GetIndexInParent()); - EXPECT_EQ(2, child3_accessible->GetIndexInParent()); + EXPECT_EQ(1, child2_accessible->index_in_parent()); + EXPECT_EQ(2, child3_accessible->index_in_parent()); // 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->GetParent()); - EXPECT_EQ(0, container_accessible->GetIndexInParent()); + EXPECT_EQ(root_accessible, container_accessible->parent()); + EXPECT_EQ(0, container_accessible->index_in_parent()); // Check that the index in parent has been updated. - EXPECT_EQ(2, child2_accessible->GetIndexInParent()); + EXPECT_EQ(2, child2_accessible->index_in_parent()); // 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 795fe04..ab896d2 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->GetId(); + unique_id_to_renderer_id_map_[unique_id_win] = node->renderer_id(); } void BrowserAccessibilityManagerWin::RemoveNode(BrowserAccessibility* node) { @@ -114,7 +114,7 @@ void BrowserAccessibilityManagerWin::OnWindowBlurred() { void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( ui::AXEvent event_type, BrowserAccessibility* node) { - if (node->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) + if (node->role() == 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 c96c785..5d35f25 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 = GetParent()->ToBrowserAccessibilityWin(); + 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. @@ -611,12 +611,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { if (!instance_active()) return E_FAIL; - if (GetRole() != ui::AX_ROLE_LIST_BOX) + if (blink_role() != ui::AX_ROLE_LIST_BOX) return E_NOTIMPL; unsigned long selected_count = 0; - for (size_t i = 0; i < InternalChildCount(); ++i) { - if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) + for (size_t i = 0; i < children().size(); ++i) { + if (children()[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 < InternalChildCount(); ++i) { - if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { + for (size_t i = 0; i < children().size(); ++i) { + if (children()[i]->HasState(ui::AX_STATE_SELECTED)) { selected->vt = VT_DISPATCH; selected->pdispVal = - InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference(); + children()[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 < InternalChildCount(); ++i) { - if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { + for (size_t i = 0; i < children().size(); ++i) { + if (children()[i]->HasState(ui::AX_STATE_SELECTED)) { enum_variant->ItemAt(index)->vt = VT_DISPATCH; enum_variant->ItemAt(index)->pdispVal = - InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference(); + children()[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->GetIndexInParent(); + *index_in_parent = this->index_in_parent(); return S_OK; } @@ -810,7 +810,7 @@ STDMETHODIMP BrowserAccessibilityWin::scrollTo(enum IA2ScrollType scroll_type) { if (!instance_active()) return E_FAIL; - gfx::Rect r = GetLocation(); + gfx::Rect r = location(); 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 (GetParent()) - scroll_to += GetParent()->GetLocation().OffsetFromOrigin(); + if (parent()) + scroll_to += parent()->location().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 (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && - GetParent() && - GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { + if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && + parent() && + parent()->role() == ui::AX_ROLE_LIST_BOX) { *group_level = 0; - *similar_items_in_group = GetParent()->PlatformChildCount(); - *position_in_group = GetIndexInParent() + 1; + *similar_items_in_group = parent()->PlatformChildCount(); + *position_in_group = index_in_parent() + 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 = GetLocation().x() + top_left.x; - *y = GetLocation().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 = GetLocation().x(); - *y = GetLocation().y(); - if (GetParent()) { - *x -= GetParent()->GetLocation().x(); - *y -= GetParent()->GetLocation().y(); + *x = location().x(); + *y = location().y(); + if (parent()) { + *x -= parent()->location().x(); + *y -= parent()->location().y(); } } else { return E_INVALIDARG; @@ -1017,8 +1017,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { if (!height || !width) return E_INVALIDARG; - *height = GetLocation().height(); - *width = GetLocation().width(); + *height = location().height(); + *width = location().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->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { + if (cell && cell->blink_role() == 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->GetRole() == ui::AX_ROLE_ROW_HEADER) { + if (cell && cell->blink_role() == 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 = GetParent(); - while (table && table->GetRole() != ui::AX_ROLE_TABLE) - table = table->GetParent(); + BrowserAccessibility* table = parent(); + while (table && table->role() != ui::AX_ROLE_TABLE) + table = table->parent(); 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->GetRole() == ui::AX_ROLE_COLUMN_HEADER) + if (cell && cell->blink_role() == 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->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { + if (cell && cell->role() == 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 = GetParent(); - while (table && table->GetRole() != ui::AX_ROLE_TABLE) - table = table->GetParent(); + BrowserAccessibility* table = parent(); + while (table && table->role() != ui::AX_ROLE_TABLE) + table = table->parent(); 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->GetRole() == ui::AX_ROLE_ROW_HEADER) + if (cell && cell->role() == 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->GetRole() == ui::AX_ROLE_ROW_HEADER) { + if (cell && cell->role() == 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 = GetParent(); - while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE) - find_table = find_table->GetParent(); + BrowserAccessibility* find_table = parent(); + while (find_table && find_table->role() != ui::AX_ROLE_TABLE) + find_table = find_table->parent(); if (!find_table) { NOTREACHED(); return S_FALSE; @@ -1909,8 +1909,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { return E_INVALIDARG; *offset = 0; - if (GetRole() == ui::AX_ROLE_TEXT_FIELD || - GetRole() == ui::AX_ROLE_TEXT_AREA) { + if (blink_role() == ui::AX_ROLE_TEXT_FIELD || + blink_role() == 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 -= GetLocation().OffsetFromOrigin(); + character_bounds -= location().OffsetFromOrigin(); } else { return E_INVALIDARG; } @@ -1965,8 +1965,8 @@ STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { return E_INVALIDARG; *n_selections = 0; - if (GetRole() == ui::AX_ROLE_TEXT_FIELD || - GetRole() == ui::AX_ROLE_TEXT_AREA) { + if (blink_role() == ui::AX_ROLE_TEXT_FIELD || + blink_role() == 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 (GetRole() == ui::AX_ROLE_TEXT_FIELD || - GetRole() == ui::AX_ROLE_TEXT_AREA) { + if (blink_role() == ui::AX_ROLE_TEXT_FIELD || + blink_role() == 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 = - InternalGetChild(hyperlinks_[index])->ToBrowserAccessibilityWin(); + children()[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 > GetHtmlAttributes().size()) - *num_attribs = GetHtmlAttributes().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( - base::UTF8ToUTF16(GetHtmlAttributes()[i].first).c_str()); + base::UTF8ToUTF16(html_attributes()[i].first).c_str()); name_space_id[i] = 0; attrib_values[i] = SysAllocString( - base::UTF8ToUTF16(GetHtmlAttributes()[i].second).c_str()); + base::UTF8ToUTF16(html_attributes()[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 < GetHtmlAttributes().size(); ++j) { - if (GetHtmlAttributes()[j].first == name) { + for (unsigned int j = 0; j < html_attributes().size(); ++j) { + if (html_attributes()[j].first == name) { attrib_values[i] = SysAllocString( - base::UTF8ToUTF16(GetHtmlAttributes()[j].second).c_str()); + base::UTF8ToUTF16(html_attributes()[j].second).c_str()); found = true; break; } @@ -2581,7 +2581,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { if (!node) return E_INVALIDARG; - *node = GetParent()->ToBrowserAccessibilityWin()->NewReference(); + *node = parent()->ToBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2626,12 +2626,12 @@ STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( if (!node) return E_INVALIDARG; - if (!GetParent() || GetIndexInParent() <= 0) { + if (!parent() || index_in_parent() <= 0) { *node = NULL; return S_FALSE; } - *node = GetParent()->InternalGetChild(GetIndexInParent() - 1)-> + *node = parent()->children()[index_in_parent() - 1]-> ToBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2643,15 +2643,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { if (!node) return E_INVALIDARG; - if (!GetParent() || - GetIndexInParent() < 0 || - GetIndexInParent() >= static_cast<int>( - GetParent()->InternalChildCount()) - 1) { + if (!parent() || + index_in_parent() < 0 || + index_in_parent() >= static_cast<int>(parent()->children().size()) - 1) { *node = NULL; return S_FALSE; } - *node = GetParent()->InternalGetChild(GetIndexInParent() + 1)-> + *node = parent()->children()[index_in_parent() + 1]-> ToBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2912,13 +2911,13 @@ void BrowserAccessibilityWin::PreInitialize() { IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level"); // Expose the set size and position in set for listbox options. - if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && - GetParent() && - GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { + if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && + parent() && + parent()->role() == ui::AX_ROLE_LIST_BOX) { ia2_attributes_.push_back( - L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount())); + L"setsize:" + base::IntToString16(parent()->PlatformChildCount())); ia2_attributes_.push_back( - L"setsize:" + base::IntToString16(GetIndexInParent() + 1)); + L"setsize:" + base::IntToString16(index_in_parent() + 1)); } if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || @@ -2952,14 +2951,14 @@ void BrowserAccessibilityWin::PreInitialize() { // Expose table cell index. if (ia_role_ == ROLE_SYSTEM_CELL) { - BrowserAccessibility* table = GetParent(); - while (table && table->GetRole() != ui::AX_ROLE_TABLE) - table = table->GetParent(); + BrowserAccessibility* table = parent(); + while (table && table->role() != ui::AX_ROLE_TABLE) + table = table->parent(); 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] == GetId()) { + if (unique_cell_ids[i] == renderer_id()) { ia2_attributes_.push_back( base::string16(L"table-cell-index:") + base::IntToString16(i)); } @@ -3023,7 +3022,7 @@ void BrowserAccessibilityWin::PreInitialize() { // If it's a text field, also consider the placeholder. std::string placeholder; - if (GetRole() == ui::AX_ROLE_TEXT_FIELD && + if (blink_role() == ui::AX_ROLE_TEXT_FIELD && HasState(ui::AX_STATE_FOCUSABLE) && GetHtmlAttribute("placeholder", &placeholder)) { if (name().empty() && !title_elem_id) { @@ -3037,8 +3036,8 @@ void BrowserAccessibilityWin::PreInitialize() { SetStringAttribute(ui::AX_ATTR_HELP, help); // On Windows, the value of a document should be its url. - if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || - GetRole() == ui::AX_ROLE_WEB_AREA) { + if (blink_role() == ui::AX_ROLE_ROOT_WEB_AREA || + blink_role() == ui::AX_ROLE_WEB_AREA) { set_value(GetStringAttribute(ui::AX_ATTR_DOC_URL)); } @@ -3046,9 +3045,9 @@ void BrowserAccessibilityWin::PreInitialize() { // WebKit stores the main accessible text in the "value" - swap it so // that it's the "name". if (name().empty() && - (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || - GetRole() == ui::AX_ROLE_STATIC_TEXT || - GetRole() == ui::AX_ROLE_LIST_MARKER)) { + (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION || + blink_role() == ui::AX_ROLE_STATIC_TEXT || + blink_role() == ui::AX_ROLE_LIST_MARKER)) { std::string tmp = value(); set_value(name()); set_name(tmp); @@ -3087,7 +3086,7 @@ void BrowserAccessibilityWin::PostInitialize() { hypertext_.clear(); for (unsigned int i = 0; i < PlatformChildCount(); ++i) { BrowserAccessibility* child = PlatformGetChild(i); - if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) { + if (child->role() == ui::AX_ROLE_STATIC_TEXT) { hypertext_ += base::UTF8ToUTF16(child->name()); } else { hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); @@ -3098,7 +3097,7 @@ void BrowserAccessibilityWin::PostInitialize() { DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); // Fire an event when an alert first appears. - if (GetRole() == ui::AX_ROLE_ALERT && first_time_) + if (blink_role() == ui::AX_ROLE_ALERT && first_time_) manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); // Fire events if text has changed. @@ -3124,7 +3123,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 (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && + if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && (ia_state_ & STATE_SYSTEM_FOCUSABLE) && (ia_state_ & STATE_SYSTEM_SELECTABLE) && (ia_state_ & STATE_SYSTEM_FOCUSED) && @@ -3260,7 +3259,7 @@ base::string16 BrowserAccessibilityWin::GetValueText() { base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { if (IsEditableText()) return base::UTF8ToUTF16(value()); - return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? + return (blink_role() == ui::AX_ROLE_STATIC_TEXT) ? base::UTF8ToUTF16(name()) : hypertext_; } @@ -3380,7 +3379,7 @@ void BrowserAccessibilityWin::InitRoleAndState() { ui::AX_ATTR_HTML_TAG); ia_role_ = 0; ia2_role_ = 0; - switch (GetRole()) { + switch (blink_role()) { 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 137f8b9..713960a 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 diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index 09704ea..42b211b 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->GetId()); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->GetRole()); - EXPECT_EQ(busy_state | readonly_state | enabled_state, root->GetState()); + 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()); // 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->GetRole()); - EXPECT_EQ(2, acc1_2->GetId()); + EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, acc1_2->role()); + EXPECT_EQ(2, acc1_2->renderer_id()); // 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->GetRole()); - EXPECT_EQ(3, acc2_2->GetId()); + EXPECT_EQ(ui::AX_ROLE_BUTTON, acc2_2->role()); + EXPECT_EQ(3, acc2_2->renderer_id()); // Ensure we properly cleaned up. manager.reset(); |