Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility.cc |
| diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc |
| index 1fa15e09fe911c4776412826f700ead5ed82d4e6..731910deeb2d5735f94515d7be9d1f6ed6bcbddd 100644 |
| --- a/content/browser/accessibility/browser_accessibility.cc |
| +++ b/content/browser/accessibility/browser_accessibility.cc |
| @@ -13,10 +13,10 @@ |
| namespace content { |
| -typedef AccessibilityNodeData::BoolAttribute BoolAttribute; |
| -typedef AccessibilityNodeData::FloatAttribute FloatAttribute; |
| -typedef AccessibilityNodeData::IntAttribute IntAttribute; |
| -typedef AccessibilityNodeData::StringAttribute StringAttribute; |
| +typedef ui::AXBoolAttribute BoolAttribute; |
| +typedef ui::AXFloatAttribute FloatAttribute; |
|
David Tseng
2014/01/06 18:13:55
Optional: I wonder if it wouldn't be easier to hav
dmazzoni
2014/01/06 19:19:58
I got rid of the typedefs. It's only saving 6 char
|
| +typedef ui::AXIntAttribute IntAttribute; |
| +typedef ui::AXStringAttribute StringAttribute; |
| #if !defined(OS_MACOSX) && \ |
| !defined(OS_WIN) && \ |
| @@ -51,11 +51,11 @@ bool BrowserAccessibility::PlatformIsLeaf() const { |
| // implementation details, but we want to expose them as leaves |
| // to platform accessibility APIs. |
| switch (role_) { |
| - case blink::WebAXRoleEditableText: |
| - case blink::WebAXRoleSlider: |
| - case blink::WebAXRoleStaticText: |
| - case blink::WebAXRoleTextArea: |
| - case blink::WebAXRoleTextField: |
| + case ui::AX_ROLE_EDITABLE_TEXT: |
| + case ui::AX_ROLE_SLIDER: |
| + case ui::AX_ROLE_STATIC_TEXT: |
| + case ui::AX_ROLE_TEXT_AREA: |
| + case ui::AX_ROLE_TEXT_FIELD: |
| return true; |
| default: |
| return false; |
| @@ -86,7 +86,7 @@ void BrowserAccessibility::InitializeTreeStructure( |
| index_in_parent_ = index_in_parent; |
| } |
| -void BrowserAccessibility::InitializeData(const AccessibilityNodeData& src) { |
| +void BrowserAccessibility::InitializeData(const ui::AXNodeData& src) { |
| DCHECK_EQ(renderer_id_, src.id); |
| role_ = src.role; |
| state_ = src.state; |
| @@ -99,8 +99,8 @@ void BrowserAccessibility::InitializeData(const AccessibilityNodeData& src) { |
| location_ = src.location; |
| instance_active_ = true; |
| - GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &name_); |
| - GetStringAttribute(AccessibilityNodeData::ATTR_VALUE, &value_); |
| + GetStringAttribute(ui::AX_ATTR_NAME, &name_); |
| + GetStringAttribute(ui::AX_ATTR_VALUE, &value_); |
| PreInitialize(); |
| } |
| @@ -166,8 +166,8 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { |
| // nested web area. |
| BrowserAccessibility* parent = parent_; |
| bool need_to_offset_web_area = |
| - (role_ == blink::WebAXRoleWebArea || |
| - role_ == blink::WebAXRoleRootWebArea); |
| + (role_ == ui::AX_ROLE_WEB_AREA || |
| + role_ == ui::AX_ROLE_ROOT_WEB_AREA); |
| while (parent) { |
| if (need_to_offset_web_area && |
| parent->location().width() > 0 && |
| @@ -178,17 +178,17 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { |
| // On some platforms, we don't want to take the root scroll offsets |
| // into account. |
| - if (parent->role() == blink::WebAXRoleRootWebArea && |
| + if (parent->role() == ui::AX_ROLE_ROOT_WEB_AREA && |
| !manager()->UseRootScrollOffsetsWhenComputingBounds()) { |
| break; |
| } |
| - if (parent->role() == blink::WebAXRoleWebArea || |
| - parent->role() == blink::WebAXRoleRootWebArea) { |
| + 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(AccessibilityNodeData::ATTR_SCROLL_X, &sx) && |
| - parent->GetIntAttribute(AccessibilityNodeData::ATTR_SCROLL_Y, &sy)) { |
| + if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && |
| + parent->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { |
| bounds.Offset(-sx, -sy); |
| } |
| need_to_offset_web_area = true; |
| @@ -211,7 +211,7 @@ gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const { |
| gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) |
| const { |
| - if (role_ != blink::WebAXRoleStaticText) { |
| + 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 |
| @@ -236,9 +236,9 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) |
| gfx::Rect bounds; |
| for (size_t i = 0; i < children_.size() && child_end < start + len; ++i) { |
| BrowserAccessibility* child = children_[i]; |
| - DCHECK_EQ(child->role(), blink::WebAXRoleInlineTextBox); |
| + DCHECK_EQ(child->role(), ui::AX_ROLE_INLINE_TEXT_BOX); |
| std::string child_text; |
| - child->GetStringAttribute(AccessibilityNodeData::ATTR_VALUE, &child_text); |
| + child->GetStringAttribute(ui::AX_ATTR_VALUE, &child_text); |
| int child_len = static_cast<int>(child_text.size()); |
| child_start = child_end; |
| child_end += child_len; |
| @@ -254,9 +254,9 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) |
| gfx::Rect child_rect = child->location(); |
| int text_direction = child->GetIntAttribute( |
| - AccessibilityNodeData::ATTR_TEXT_DIRECTION); |
| + ui::AX_ATTR_TEXT_DIRECTION); |
| const std::vector<int32>& character_offsets = child->GetIntListAttribute( |
| - AccessibilityNodeData::ATTR_CHARACTER_OFFSETS); |
| + ui::AX_ATTR_CHARACTER_OFFSETS); |
| int start_pixel_offset = |
| local_start > 0 ? character_offsets[local_start - 1] : 0; |
| int end_pixel_offset = |
| @@ -264,28 +264,28 @@ gfx::Rect BrowserAccessibility::GetLocalBoundsForRange(int start, int len) |
| gfx::Rect child_overlap_rect; |
| switch (text_direction) { |
| - case blink::WebAXTextDirectionLR: { |
| + case ui::AX_TEXT_DIRECTION_LR: { |
| int left = child_rect.x() + start_pixel_offset; |
| int right = child_rect.x() + end_pixel_offset; |
| child_overlap_rect = gfx::Rect(left, child_rect.y(), |
| right - left, child_rect.height()); |
| break; |
| } |
| - case blink::WebAXTextDirectionRL: { |
| + case ui::AX_TEXT_DIRECTION_RL: { |
| int right = child_rect.right() - start_pixel_offset; |
| int left = child_rect.right() - end_pixel_offset; |
| child_overlap_rect = gfx::Rect(left, child_rect.y(), |
| right - left, child_rect.height()); |
| break; |
| } |
| - case blink::WebAXTextDirectionTB: { |
| + case ui::AX_TEXT_DIRECTION_TB: { |
| int top = child_rect.y() + start_pixel_offset; |
| int bottom = child_rect.y() + end_pixel_offset; |
| child_overlap_rect = gfx::Rect(child_rect.x(), top, |
| child_rect.width(), bottom - top); |
| break; |
| } |
| - case blink::WebAXTextDirectionBT: { |
| + case ui::AX_TEXT_DIRECTION_BT: { |
| int bottom = child_rect.bottom() - start_pixel_offset; |
| int top = child_rect.bottom() - end_pixel_offset; |
| child_overlap_rect = gfx::Rect(child_rect.x(), top, |
| @@ -341,8 +341,7 @@ void BrowserAccessibility::Destroy() { |
| value_.clear(); |
| PostInitialize(); |
| - manager_->NotifyAccessibilityEvent( |
| - blink::WebAXEventHide, this); |
| + manager_->NotifyAccessibilityEvent(ui::AX_EVENT_HIDE, this); |
| instance_active_ = false; |
| manager_->RemoveNode(this); |
| @@ -507,7 +506,7 @@ void BrowserAccessibility::SetStringAttribute( |
| } |
| bool BrowserAccessibility::HasIntListAttribute( |
| - AccessibilityNodeData::IntListAttribute attribute) const { |
| + ui::AXIntListAttribute attribute) const { |
| for (size_t i = 0; i < intlist_attributes_.size(); ++i) { |
| if (intlist_attributes_[i].first == attribute) |
| return true; |
| @@ -517,7 +516,7 @@ bool BrowserAccessibility::HasIntListAttribute( |
| } |
| const std::vector<int32>& BrowserAccessibility::GetIntListAttribute( |
| - AccessibilityNodeData::IntListAttribute attribute) const { |
| + 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) |
| @@ -528,7 +527,7 @@ const std::vector<int32>& BrowserAccessibility::GetIntListAttribute( |
| } |
| bool BrowserAccessibility::GetIntListAttribute( |
| - AccessibilityNodeData::IntListAttribute attribute, |
| + ui::AXIntListAttribute attribute, |
| std::vector<int32>* value) const { |
| for (size_t i = 0; i < intlist_attributes_.size(); ++i) { |
| if (intlist_attributes_[i].first == attribute) { |
| @@ -587,24 +586,24 @@ bool BrowserAccessibility::GetAriaTristate( |
| return false; // Not set |
| } |
| -bool BrowserAccessibility::HasState(blink::WebAXState state_enum) const { |
| +bool BrowserAccessibility::HasState(ui::AXState state_enum) const { |
| return (state_ >> state_enum) & 1; |
| } |
| bool BrowserAccessibility::IsEditableText() const { |
| // These roles don't have readonly set, but they're not editable text. |
| - if (role_ == blink::WebAXRoleScrollArea || |
| - role_ == blink::WebAXRoleColumn || |
| - role_ == blink::WebAXRoleTableHeaderContainer) { |
| + if (role_ == ui::AX_ROLE_SCROLL_AREA || |
| + role_ == ui::AX_ROLE_COLUMN || |
| + role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { |
| return false; |
| } |
| // Note: WebAXStateReadonly being false means it's either a text control, |
| // or contenteditable. We also check for editable text roles to cover |
| // another element that has role=textbox set on it. |
| - return (!HasState(blink::WebAXStateReadonly) || |
| - role_ == blink::WebAXRoleTextField || |
| - role_ == blink::WebAXRoleTextArea); |
| + return (!HasState(ui::AX_STATE_READONLY) || |
| + role_ == ui::AX_ROLE_TEXT_FIELD || |
| + role_ == ui::AX_ROLE_TEXT_AREA); |
| } |
| std::string BrowserAccessibility::GetTextRecursive() const { |
| @@ -619,10 +618,8 @@ std::string BrowserAccessibility::GetTextRecursive() const { |
| } |
| int BrowserAccessibility::GetStaticTextLenRecursive() const { |
| - if (role_ == blink::WebAXRoleStaticText) { |
| - return static_cast<int>( |
| - GetStringAttribute(AccessibilityNodeData::ATTR_VALUE).size()); |
| - } |
| + if (role_ == blink::WebAXRoleStaticText) |
| + return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); |
| int len = 0; |
| for (size_t i = 0; i < children_.size(); ++i) |