Index: content/browser/accessibility/browser_accessibility_manager.cc |
diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc |
index 6bdce2d907a503186a04788d2ba7731723866923..48076265a57e3dceb4003ac6d47a735f863f3f85 100644 |
--- a/content/browser/accessibility/browser_accessibility_manager.cc |
+++ b/content/browser/accessibility/browser_accessibility_manager.cc |
@@ -7,6 +7,7 @@ |
#include "base/logging.h" |
#include "content/browser/accessibility/browser_accessibility.h" |
#include "content/common/accessibility_messages.h" |
+#include "ui/accessibility/ax_tree_serializer.h" |
namespace content { |
@@ -67,7 +68,7 @@ BrowserAccessibilityManager::BrowserAccessibilityManager( |
BrowserAccessibilityFactory* factory) |
: delegate_(delegate), |
factory_(factory), |
- tree_(new ui::AXTree()), |
+ tree_(new ui::AXSerializableTree()), |
focus_(NULL), |
osk_state_(OSK_ALLOWED) { |
tree_->SetDelegate(this); |
@@ -79,7 +80,7 @@ BrowserAccessibilityManager::BrowserAccessibilityManager( |
BrowserAccessibilityFactory* factory) |
: delegate_(delegate), |
factory_(factory), |
- tree_(new ui::AXTree()), |
+ tree_(new ui::AXSerializableTree()), |
focus_(NULL), |
osk_state_(OSK_ALLOWED) { |
tree_->SetDelegate(this); |
@@ -363,4 +364,64 @@ void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { |
GetFromAXNode(node)->OnUpdateFinished(); |
} |
+ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { |
+ scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( |
+ tree_->CreateTreeSource()); |
+ ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); |
+ ui::AXTreeUpdate update; |
+ serializer.SerializeChanges(tree_->GetRoot(), &update); |
+ return update; |
+} |
+ |
+void BrowserAccessibilityManager::SetChildFrameTreeNodeId( |
+ int32 node_id, int64 child_frame_tree_node_id) { |
+ BrowserAccessibility* node = GetFromID(node_id); |
+ if (node) { |
+ // The node id passed to us is the web area for the proxy frame. |
+ // In order to replace this node with the child frame, set the |
+ // child frame id on its parent. |
+ BrowserAccessibility* node_parent = node->GetParent(); |
+ if (node_parent) |
+ node_parent->SetChildFrameTreeNodeId(child_frame_tree_node_id); |
+ } |
+} |
+ |
+// Recursively searches |ancestor_node| and its descendants for a |
+// BrowserAccessibility with |child| as its immediate and only child. |
+// Searches only the frame that |ancestor_node| belongs to, does not descend |
+// into child frames (but |child| can be the root of another frame). |
+static BrowserAccessibility* FindParentOfNode( |
Charlie Reis
2014/08/27 17:28:34
If this is a nonmember function, it should probabl
dmazzoni
2014/08/28 05:40:14
Done.
|
+ BrowserAccessibility* ancestor_node, BrowserAccessibility* child) { |
+ if (ancestor_node->PlatformChildCount() == 1 && |
+ ancestor_node->PlatformGetChild(0) == child) { |
+ return ancestor_node; |
+ } |
+ |
+ if (ancestor_node->InternalChildCount() == 0) |
+ return NULL; |
+ |
+ for (uint32 i = 0; i < ancestor_node->PlatformChildCount(); ++i) { |
+ BrowserAccessibility* result = FindParentOfNode( |
+ ancestor_node->PlatformGetChild(i), child); |
+ if (result) |
+ return result; |
+ } |
+ |
+ return NULL; |
+} |
+ |
+BrowserAccessibility* BrowserAccessibilityManager::GetCrossFrameParent() { |
+ if (!delegate_) |
+ return NULL; |
+ |
+ BrowserAccessibilityManager* parent_frame = |
+ delegate_->AccessibilityGetParentFrame(); |
+ if (!parent_frame) |
+ return NULL; |
+ |
+ // Recursively search the parent frame to find the node that has this |
+ // frame as its child. |
+ return FindParentOfNode(parent_frame->GetRoot(), GetRoot()); |
+} |
+ |
} // namespace content |