Skip to content

Commit

Permalink
Revert of Cross-process iframe accessibility. (patchset chromium#19 i…
Browse files Browse the repository at this point in the history
…d:360001 of https://codereview.chromium.org/268543008/)

Reason for revert:
Broke Mac tests:

http://build.chromium.org/p/chromium.mac/builders/Mac10.7%20Tests%20%281%29/builds/26131

http://build.chromium.org/p/chromium.mac/builders/Mac%2010.6%20Tests%20%28dbg%29%281%29/builds/52684

http://build.chromium.org/p/chromium.mac/builders/Mac%2010.7%20Tests%20%28dbg%29%281%29/builds/26975

http://build.chromium.org/p/chromium.mac/builders/Mac%2010.7%20Tests%20%28dbg%29%281%29/builds/26976

and so on.

Original issue's description:
> Cross-process iframe accessibility.
>
> This change completes the plumbing to join cross-process iframes into a single composed accessibility tree on platforms that implement native accessibility APIs (Windows, Mac, Android).
>
> Further work will be needed to update some accessibility API implementations to be multi-frame-aware.
>
> BUG=368298
>
> Committed: https://crrev.com/387942c041da17ea6337bc0a81e96619e67e4ac4
> Cr-Commit-Position: refs/heads/master@{#294118}

TBR=creis@chromium.org,dtseng@chromium.org,aboxhall@chromium.org,nick@chromium.org,nasko@chromium.org,dmazzoni@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=368298

Review URL: https://codereview.chromium.org/558943002

Cr-Commit-Position: refs/heads/master@{#294135}
  • Loading branch information
dconnelly authored and Commit bot committed Sep 10, 2014
1 parent 38204f5 commit 1dcb3ab
Show file tree
Hide file tree
Showing 28 changed files with 115 additions and 554 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree(
dict->Set(kChildrenDictAttr, children);

for (size_t i = 0; i < node.PlatformChildCount(); ++i) {
BrowserAccessibility* child_node = node.PlatformGetChild(i);
BrowserAccessibility* child_node = node.InternalGetChild(i);
base::DictionaryValue* child_dict = new base::DictionaryValue;
children->Append(child_dict);
RecursiveBuildAccessibilityTree(*child_node, child_dict);
Expand Down
32 changes: 2 additions & 30 deletions content/browser/accessibility/browser_accessibility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ BrowserAccessibility* BrowserAccessibility::Create() {

BrowserAccessibility::BrowserAccessibility()
: manager_(NULL),
node_(NULL),
child_frame_tree_node_id_(0) {
node_(NULL) {
}

BrowserAccessibility::~BrowserAccessibility() {
Expand Down Expand Up @@ -64,15 +63,6 @@ bool BrowserAccessibility::PlatformIsLeaf() const {
}

uint32 BrowserAccessibility::PlatformChildCount() const {
if (child_frame_tree_node_id_ &&
manager_ && manager_->delegate()) {
BrowserAccessibilityManager* child_manager =
manager_->delegate()->AccessibilityGetChildFrame(
child_frame_tree_node_id_);
if (child_manager)
return 1;
}

return PlatformIsLeaf() ? 0 : InternalChildCount();
}

Expand All @@ -93,16 +83,6 @@ bool BrowserAccessibility::IsDescendantOf(

BrowserAccessibility* BrowserAccessibility::PlatformGetChild(
uint32 child_index) const {
if (child_index == 0 && child_frame_tree_node_id_ &&
manager_ &&
manager_->delegate()) {
BrowserAccessibilityManager* child_manager =
manager_->delegate()->AccessibilityGetChildFrame(
child_frame_tree_node_id_);
if (child_manager)
return child_manager->GetRoot();
}

DCHECK(child_index < InternalChildCount());
return InternalGetChild(child_index);
}
Expand Down Expand Up @@ -142,9 +122,7 @@ BrowserAccessibility* BrowserAccessibility::GetParent() const {
if (!node_ || !manager_)
return NULL;
ui::AXNode* parent = node_->parent();
if (parent)
return manager_->GetFromAXNode(parent);
return manager_->GetCrossFrameParent();
return parent ? manager_->GetFromAXNode(parent) : NULL;
}

int32 BrowserAccessibility::GetIndexInParent() const {
Expand Down Expand Up @@ -702,10 +680,4 @@ int BrowserAccessibility::GetStaticTextLenRecursive() const {
return len;
}

void BrowserAccessibility::SetChildFrameTreeNodeId(
int64 child_frame_tree_node_id) {
child_frame_tree_node_id_ = child_frame_tree_node_id;
manager_->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, this);
}

} // namespace content
24 changes: 6 additions & 18 deletions content/browser/accessibility/browser_accessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ class BrowserAccessibilityWin;
//
// BrowserAccessibility
//
// A BrowserAccessibility object represents one node in the accessibility
// tree on the browser side. It exactly corresponds to one WebAXObject from
// Blink. It's owned by a BrowserAccessibilityManager.
// Class implementing the cross platform interface for the Browser-Renderer
// communication of accessibility information, providing accessibility
// to be used by screen readers and other assistive technology (AT).
//
// There are subclasses of BrowserAccessibility for each platform where
// we implement native accessibility APIs. This base class is used occasionally
// for tests.
// An implementation for each platform handles platform specific accessibility
// APIs.
//
////////////////////////////////////////////////////////////////////////////////
class CONTENT_EXPORT BrowserAccessibility {
Expand Down Expand Up @@ -246,15 +245,6 @@ class CONTENT_EXPORT BrowserAccessibility {
// Append the text from this node and its children.
std::string GetTextRecursive() const;

// Identifies the given frame tree node id as the only child of this node,
// so any call to PlatformChildCount/PlatformGetChild will use
// BrowserAccessibilityDelegate::AccessibilityGetChildFrame to retrieve
// the BrowserAccessibilityManager of the child frame and return its root
// node as this node's child.
void SetChildFrameTreeNodeId(int64 child_frame_tree_node_id);

int64 child_frame_tree_node_id() const { return child_frame_tree_node_id_; }

protected:
BrowserAccessibility();

Expand All @@ -272,9 +262,7 @@ class CONTENT_EXPORT BrowserAccessibility {
std::string name_;
std::string value_;

// If nonzero, the frame tree node id of the child frame of this node.
int64 child_frame_tree_node_id_;

private:
DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility);
};

Expand Down
69 changes: 2 additions & 67 deletions content/browser/accessibility/browser_accessibility_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,9 @@
#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 {

namespace {

// 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).
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;
}

} // namespace.

ui::AXTreeUpdate MakeAXTreeUpdate(
const ui::AXNodeData& node1,
const ui::AXNodeData& node2 /* = ui::AXNodeData() */,
Expand Down Expand Up @@ -96,7 +67,7 @@ BrowserAccessibilityManager::BrowserAccessibilityManager(
BrowserAccessibilityFactory* factory)
: delegate_(delegate),
factory_(factory),
tree_(new ui::AXSerializableTree()),
tree_(new ui::AXTree()),
focus_(NULL),
osk_state_(OSK_ALLOWED) {
tree_->SetDelegate(this);
Expand All @@ -108,7 +79,7 @@ BrowserAccessibilityManager::BrowserAccessibilityManager(
BrowserAccessibilityFactory* factory)
: delegate_(delegate),
factory_(factory),
tree_(new ui::AXSerializableTree()),
tree_(new ui::AXTree()),
focus_(NULL),
osk_state_(OSK_ALLOWED) {
tree_->SetDelegate(this);
Expand Down Expand Up @@ -392,40 +363,4 @@ 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);
}
}

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
36 changes: 17 additions & 19 deletions content/browser/accessibility/browser_accessibility_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "content/common/content_export.h"
#include "third_party/WebKit/public/web/WebAXEnums.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_serializable_tree.h"
#include "ui/accessibility/ax_tree.h"
#include "ui/accessibility/ax_tree_update.h"
#include "ui/gfx/native_widget_types.h"

Expand All @@ -22,7 +22,6 @@ struct AccessibilityHostMsg_LocationChangeParams;

namespace content {
class BrowserAccessibility;
class BrowserAccessibilityManager;
#if defined(OS_ANDROID)
class BrowserAccessibilityManagerAndroid;
#endif
Expand All @@ -43,12 +42,6 @@ CONTENT_EXPORT ui::AXTreeUpdate MakeAXTreeUpdate(
const ui::AXNodeData& node9 = ui::AXNodeData());

// Class that can perform actions on behalf of the BrowserAccessibilityManager.
// Note: BrowserAccessibilityManager should never cache any of the return
// values from any of these interfaces, especially those that return pointers.
// They may only be valid within this call stack. That policy eliminates any
// concerns about ownership and lifecycle issues; none of these interfaces
// transfer ownership and no return values are guaranteed to be valid outside
// of the current call stack.
class CONTENT_EXPORT BrowserAccessibilityDelegate {
public:
virtual ~BrowserAccessibilityDelegate() {}
Expand All @@ -70,9 +63,6 @@ class CONTENT_EXPORT BrowserAccessibilityDelegate {
virtual void AccessibilityFatalError() = 0;
virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() = 0;
virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() = 0;
virtual BrowserAccessibilityManager* AccessibilityGetChildFrame(
int64 frame_tree_node_id) = 0;
virtual BrowserAccessibilityManager* AccessibilityGetParentFrame() = 0;
};

class CONTENT_EXPORT BrowserAccessibilityFactory {
Expand Down Expand Up @@ -199,13 +189,6 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeDelegate {
delegate_ = delegate;
}

// Get a snapshot of the current tree as an AXTreeUpdate.
ui::AXTreeUpdate SnapshotAXTreeForTesting();

// Frame tree support.
void SetChildFrameTreeNodeId(int32 node_id, int64 child_frame_tree_node_id);
BrowserAccessibility* GetCrossFrameParent();

protected:
BrowserAccessibilityManager(
BrowserAccessibilityDelegate* delegate,
Expand Down Expand Up @@ -242,6 +225,21 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeDelegate {
OSK_ALLOWED
};

// Update a set of nodes using data received from the renderer
// process.
bool UpdateNodes(const std::vector<ui::AXNodeData>& nodes);

// Update one node from the tree using data received from the renderer
// process. Returns true on success, false on fatal error.
bool UpdateNode(const ui::AXNodeData& src);

void SetRoot(BrowserAccessibility* root);

BrowserAccessibility* CreateNode(
BrowserAccessibility* parent,
int32 id,
int32 index_in_parent);

protected:
// The object that can perform actions on our behalf.
BrowserAccessibilityDelegate* delegate_;
Expand All @@ -250,7 +248,7 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeDelegate {
scoped_ptr<BrowserAccessibilityFactory> factory_;

// The underlying tree of accessibility objects.
scoped_ptr<ui::AXSerializableTree> tree_;
scoped_ptr<ui::AXTree> tree_;

// The node that currently has focus.
ui::AXNode* focus_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ class TestBrowserAccessibilityDelegate
OVERRIDE {
return NULL;
}
virtual BrowserAccessibilityManager* AccessibilityGetChildFrame(
int64 frame_tree_node_id) OVERRIDE {
return NULL;
}
virtual BrowserAccessibilityManager* AccessibilityGetParentFrame() OVERRIDE {
return NULL;
}

bool got_fatal_error() const { return got_fatal_error_; }
void reset_got_fatal_error() { got_fatal_error_ = false; }
Expand Down
Loading

0 comments on commit 1dcb3ab

Please sign in to comment.