| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/accessibility/browser_accessibility.h" | 5 #include "content/browser/accessibility/browser_accessibility.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "content/browser/accessibility/browser_accessibility_manager.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 void BrowserAccessibility::DetachTree( | 42 void BrowserAccessibility::DetachTree( |
| 43 std::vector<BrowserAccessibility*>* nodes) { | 43 std::vector<BrowserAccessibility*>* nodes) { |
| 44 nodes->push_back(this); | 44 nodes->push_back(this); |
| 45 for (size_t i = 0; i < children_.size(); i++) | 45 for (size_t i = 0; i < children_.size(); i++) |
| 46 children_[i]->DetachTree(nodes); | 46 children_[i]->DetachTree(nodes); |
| 47 children_.clear(); | 47 children_.clear(); |
| 48 parent_ = NULL; | 48 parent_ = NULL; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void BrowserAccessibility::Initialize( | 51 void BrowserAccessibility::PreInitialize( |
| 52 BrowserAccessibilityManager* manager, | 52 BrowserAccessibilityManager* manager, |
| 53 BrowserAccessibility* parent, | 53 BrowserAccessibility* parent, |
| 54 int32 child_id, | 54 int32 child_id, |
| 55 int32 index_in_parent, | 55 int32 index_in_parent, |
| 56 const webkit_glue::WebAccessibility& src) { | 56 const webkit_glue::WebAccessibility& src) { |
| 57 manager_ = manager; | 57 manager_ = manager; |
| 58 parent_ = parent; | 58 parent_ = parent; |
| 59 child_id_ = child_id; | 59 child_id_ = child_id; |
| 60 index_in_parent_ = index_in_parent; | 60 index_in_parent_ = index_in_parent; |
| 61 | 61 |
| 62 // Update all of the rest of the attributes. | 62 // Update all of the rest of the attributes. |
| 63 name_ = src.name; | 63 name_ = src.name; |
| 64 value_ = src.value; | 64 value_ = src.value; |
| 65 role_ = src.role; | 65 role_ = src.role; |
| 66 state_ = src.state; | 66 state_ = src.state; |
| 67 renderer_id_ = src.id; | 67 renderer_id_ = src.id; |
| 68 string_attributes_ = src.string_attributes; | 68 string_attributes_ = src.string_attributes; |
| 69 int_attributes_ = src.int_attributes; | 69 int_attributes_ = src.int_attributes; |
| 70 float_attributes_ = src.float_attributes; | 70 float_attributes_ = src.float_attributes; |
| 71 bool_attributes_ = src.bool_attributes; | 71 bool_attributes_ = src.bool_attributes; |
| 72 html_attributes_ = src.html_attributes; | 72 html_attributes_ = src.html_attributes; |
| 73 location_ = src.location; | 73 location_ = src.location; |
| 74 indirect_child_ids_ = src.indirect_child_ids; | 74 indirect_child_ids_ = src.indirect_child_ids; |
| 75 line_breaks_ = src.line_breaks; | 75 line_breaks_ = src.line_breaks; |
| 76 cell_ids_ = src.cell_ids; | 76 cell_ids_ = src.cell_ids; |
| 77 unique_cell_ids_ = src.unique_cell_ids; | 77 unique_cell_ids_ = src.unique_cell_ids; |
| 78 | 78 |
| 79 Initialize(); | 79 PreInitialize(); |
| 80 } | |
| 81 | |
| 82 void BrowserAccessibility::Initialize() { | |
| 83 instance_active_ = true; | |
| 84 } | 80 } |
| 85 | 81 |
| 86 void BrowserAccessibility::AddChild(BrowserAccessibility* child) { | 82 void BrowserAccessibility::AddChild(BrowserAccessibility* child) { |
| 87 children_.push_back(child); | 83 children_.push_back(child); |
| 88 } | 84 } |
| 89 | 85 |
| 90 void BrowserAccessibility::UpdateParent(BrowserAccessibility* parent, | 86 void BrowserAccessibility::UpdateParent(BrowserAccessibility* parent, |
| 91 int index_in_parent) { | 87 int index_in_parent) { |
| 92 parent_ = parent; | 88 parent_ = parent; |
| 93 index_in_parent_ = index_in_parent; | 89 index_in_parent_ = index_in_parent; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 ++iter) { | 166 ++iter) { |
| 171 (*iter)->InternalReleaseReference(true); | 167 (*iter)->InternalReleaseReference(true); |
| 172 } | 168 } |
| 173 } | 169 } |
| 174 | 170 |
| 175 ref_count_--; | 171 ref_count_--; |
| 176 if (ref_count_ == 0) { | 172 if (ref_count_ == 0) { |
| 177 // Allow the object to fire a TEXT_REMOVED notification. | 173 // Allow the object to fire a TEXT_REMOVED notification. |
| 178 name_.clear(); | 174 name_.clear(); |
| 179 value_.clear(); | 175 value_.clear(); |
| 180 SendNodeUpdateEvents(); | 176 PostInitialize(); |
| 181 | 177 |
| 182 manager_->NotifyAccessibilityEvent( | 178 manager_->NotifyAccessibilityEvent( |
| 183 ViewHostMsg_AccEvent::OBJECT_HIDE, this); | 179 ViewHostMsg_AccEvent::OBJECT_HIDE, this); |
| 184 | 180 |
| 185 instance_active_ = false; | 181 instance_active_ = false; |
| 186 children_.clear(); | 182 children_.clear(); |
| 187 manager_->Remove(child_id_, renderer_id_); | 183 manager_->Remove(child_id_, renderer_id_); |
| 188 NativeReleaseReference(); | 184 NativeReleaseReference(); |
| 189 } | 185 } |
| 190 } | 186 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 if (!name_.empty()) { | 256 if (!name_.empty()) { |
| 261 return name_; | 257 return name_; |
| 262 } | 258 } |
| 263 | 259 |
| 264 string16 result; | 260 string16 result; |
| 265 for (size_t i = 0; i < children_.size(); ++i) | 261 for (size_t i = 0; i < children_.size(); ++i) |
| 266 result += children_[i]->GetTextRecursive(); | 262 result += children_[i]->GetTextRecursive(); |
| 267 return result; | 263 return result; |
| 268 } | 264 } |
| 269 | 265 |
| 266 void BrowserAccessibility::PreInitialize() { |
| 267 instance_active_ = true; |
| 268 } |
| OLD | NEW |