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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager.cc

Issue 558073002: Hook up guest browser plugins to the accessibility tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cross_process_iframes_plugins_3
Patch Set: Rebase Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_manager.h" 5 #include "content/browser/accessibility/browser_accessibility_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/accessibility/browser_accessibility.h" 8 #include "content/browser/accessibility/browser_accessibility.h"
9 #include "content/common/accessibility_messages.h" 9 #include "content/common/accessibility_messages.h"
10 #include "ui/accessibility/ax_tree_serializer.h" 10 #include "ui/accessibility/ax_tree_serializer.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 namespace {
15
16 // Recursively searches |ancestor_node| and its descendants for a
17 // BrowserAccessibility with |child| as its immediate and only child.
18 // Searches only the frame that |ancestor_node| belongs to, does not descend
19 // into child frames (but |child| can be the root of another frame).
20 BrowserAccessibility* FindParentOfNode(
21 BrowserAccessibility* ancestor_node, BrowserAccessibility* child) {
22 if (ancestor_node->PlatformChildCount() == 1 &&
23 ancestor_node->PlatformGetChild(0) == child) {
24 return ancestor_node;
25 }
26
27 if (ancestor_node->InternalChildCount() == 0)
28 return NULL;
29
30 for (uint32 i = 0; i < ancestor_node->PlatformChildCount(); ++i) {
31 BrowserAccessibility* result = FindParentOfNode(
32 ancestor_node->PlatformGetChild(i), child);
33 if (result)
34 return result;
35 }
36
37 return NULL;
38 }
39
40 } // namespace.
41
42 ui::AXTreeUpdate MakeAXTreeUpdate( 14 ui::AXTreeUpdate MakeAXTreeUpdate(
43 const ui::AXNodeData& node1, 15 const ui::AXNodeData& node1,
44 const ui::AXNodeData& node2 /* = ui::AXNodeData() */, 16 const ui::AXNodeData& node2 /* = ui::AXNodeData() */,
45 const ui::AXNodeData& node3 /* = ui::AXNodeData() */, 17 const ui::AXNodeData& node3 /* = ui::AXNodeData() */,
46 const ui::AXNodeData& node4 /* = ui::AXNodeData() */, 18 const ui::AXNodeData& node4 /* = ui::AXNodeData() */,
47 const ui::AXNodeData& node5 /* = ui::AXNodeData() */, 19 const ui::AXNodeData& node5 /* = ui::AXNodeData() */,
48 const ui::AXNodeData& node6 /* = ui::AXNodeData() */, 20 const ui::AXNodeData& node6 /* = ui::AXNodeData() */,
49 const ui::AXNodeData& node7 /* = ui::AXNodeData() */, 21 const ui::AXNodeData& node7 /* = ui::AXNodeData() */,
50 const ui::AXNodeData& node8 /* = ui::AXNodeData() */, 22 const ui::AXNodeData& node8 /* = ui::AXNodeData() */,
51 const ui::AXNodeData& node9 /* = ui::AXNodeData() */) { 23 const ui::AXNodeData& node9 /* = ui::AXNodeData() */) {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 366
395 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { 367 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() {
396 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( 368 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source(
397 tree_->CreateTreeSource()); 369 tree_->CreateTreeSource());
398 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); 370 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get());
399 ui::AXTreeUpdate update; 371 ui::AXTreeUpdate update;
400 serializer.SerializeChanges(tree_->GetRoot(), &update); 372 serializer.SerializeChanges(tree_->GetRoot(), &update);
401 return update; 373 return update;
402 } 374 }
403 375
404 void BrowserAccessibilityManager::SetChildFrameTreeNodeId(
405 int32 node_id, int64 child_frame_tree_node_id) {
406 BrowserAccessibility* node = GetFromID(node_id);
407 if (node) {
408 // The node id passed to us is the web area for the proxy frame.
409 // In order to replace this node with the child frame, set the
410 // child frame id on its parent.
411 BrowserAccessibility* node_parent = node->GetParent();
412 if (node_parent)
413 node_parent->SetChildFrameTreeNodeId(child_frame_tree_node_id);
414 }
415 }
416
417 BrowserAccessibility* BrowserAccessibilityManager::GetCrossFrameParent() {
418 if (!delegate_)
419 return NULL;
420
421 BrowserAccessibilityManager* parent_frame =
422 delegate_->AccessibilityGetParentFrame();
423 if (!parent_frame)
424 return NULL;
425
426 // Recursively search the parent frame to find the node that has this
427 // frame as its child.
428 return FindParentOfNode(parent_frame->GetRoot(), GetRoot());
429 }
430
431 } // namespace content 376 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698