| 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::PreInitialize( | 51 void BrowserAccessibility::Initialize( |
| 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 PreInitialize(); | 79 Initialize(); |
| 80 } |
| 81 |
| 82 void BrowserAccessibility::Initialize() { |
| 83 instance_active_ = true; |
| 80 } | 84 } |
| 81 | 85 |
| 82 void BrowserAccessibility::AddChild(BrowserAccessibility* child) { | 86 void BrowserAccessibility::AddChild(BrowserAccessibility* child) { |
| 83 children_.push_back(child); | 87 children_.push_back(child); |
| 84 } | 88 } |
| 85 | 89 |
| 86 void BrowserAccessibility::UpdateParent(BrowserAccessibility* parent, | 90 void BrowserAccessibility::UpdateParent(BrowserAccessibility* parent, |
| 87 int index_in_parent) { | 91 int index_in_parent) { |
| 88 parent_ = parent; | 92 parent_ = parent; |
| 89 index_in_parent_ = index_in_parent; | 93 index_in_parent_ = index_in_parent; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 ++iter) { | 262 ++iter) { |
| 259 (*iter)->InternalReleaseReference(true); | 263 (*iter)->InternalReleaseReference(true); |
| 260 } | 264 } |
| 261 } | 265 } |
| 262 | 266 |
| 263 ref_count_--; | 267 ref_count_--; |
| 264 if (ref_count_ == 0) { | 268 if (ref_count_ == 0) { |
| 265 // Allow the object to fire a TEXT_REMOVED notification. | 269 // Allow the object to fire a TEXT_REMOVED notification. |
| 266 name_.clear(); | 270 name_.clear(); |
| 267 value_.clear(); | 271 value_.clear(); |
| 268 PostInitialize(); | 272 SendNodeUpdateEvents(); |
| 269 | 273 |
| 270 manager_->NotifyAccessibilityEvent( | 274 manager_->NotifyAccessibilityEvent( |
| 271 ViewHostMsg_AccEvent::OBJECT_HIDE, this); | 275 ViewHostMsg_AccEvent::OBJECT_HIDE, this); |
| 272 | 276 |
| 273 instance_active_ = false; | 277 instance_active_ = false; |
| 274 children_.clear(); | 278 children_.clear(); |
| 275 manager_->Remove(child_id_, renderer_id_); | 279 manager_->Remove(child_id_, renderer_id_); |
| 276 NativeReleaseReference(); | 280 NativeReleaseReference(); |
| 277 } | 281 } |
| 278 } | 282 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 string16 BrowserAccessibility::GetTextRecursive() const { | 355 string16 BrowserAccessibility::GetTextRecursive() const { |
| 352 if (!name_.empty()) { | 356 if (!name_.empty()) { |
| 353 return name_; | 357 return name_; |
| 354 } | 358 } |
| 355 | 359 |
| 356 string16 result; | 360 string16 result; |
| 357 for (size_t i = 0; i < children_.size(); ++i) | 361 for (size_t i = 0; i < children_.size(); ++i) |
| 358 result += children_[i]->GetTextRecursive(); | 362 result += children_[i]->GetTextRecursive(); |
| 359 return result; | 363 return result; |
| 360 } | 364 } |
| 361 | |
| 362 void BrowserAccessibility::PreInitialize() { | |
| 363 instance_active_ = true; | |
| 364 } | |
| OLD | NEW |