Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: content/browser/accessibility/browser_accessibility_manager.cc

Issue 268543008: Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(
+ 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

Powered by Google App Engine
This is Rietveld 408576698