Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility.cc |
| diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc |
| index fe71fef965aa95dfdd32a16d0c22d738e9430e99..a813713b0cfae9fcb952c372a34fb26ac5f6a8eb 100644 |
| --- a/content/browser/accessibility/browser_accessibility.cc |
| +++ b/content/browser/accessibility/browser_accessibility.cc |
| @@ -26,7 +26,8 @@ BrowserAccessibility* BrowserAccessibility::Create() { |
| BrowserAccessibility::BrowserAccessibility() |
| : manager_(NULL), |
| - node_(NULL) { |
| + node_(NULL), |
| + child_frame_id_(kNoFrameId) { |
| } |
| BrowserAccessibility::~BrowserAccessibility() { |
| @@ -63,7 +64,11 @@ bool BrowserAccessibility::PlatformIsLeaf() const { |
| } |
| uint32 BrowserAccessibility::PlatformChildCount() const { |
| - return PlatformIsLeaf() ? 0 : InternalChildCount(); |
| + if (child_frame_id_ == kNoFrameId || !manager_ || !manager_->delegate()) |
| + return PlatformIsLeaf() ? 0 : InternalChildCount(); |
| + BrowserAccessibilityManager* child_manager = |
| + manager_->delegate()->AccessibilityGetChildFrame(child_frame_id_); |
| + return child_manager ? 1 : 0; |
| } |
| bool BrowserAccessibility::IsNative() const { |
| @@ -83,6 +88,17 @@ bool BrowserAccessibility::IsDescendantOf( |
| BrowserAccessibility* BrowserAccessibility::PlatformGetChild( |
| uint32 child_index) const { |
| + if (child_index == 0 && child_frame_id_ != kNoFrameId && manager_ && |
| + manager_->delegate()) { |
| + BrowserAccessibilityManager* child_manager = |
| + manager_->delegate()->AccessibilityGetChildFrame(child_frame_id_); |
| + if (!child_manager) |
| + return NULL; |
| + |
| + child_manager->SetNodeIdInParentFrame(GetId()); |
|
Charlie Reis
2014/08/21 19:23:27
Seems odd to be doing a modification to the child_
dmazzoni
2014/08/25 06:49:36
I agree this is ugly.
Maybe this is premature opt
|
| + return child_manager->GetRoot(); |
| + } |
| + |
| DCHECK(child_index < InternalChildCount()); |
| return InternalGetChild(child_index); |
| } |
| @@ -122,7 +138,9 @@ BrowserAccessibility* BrowserAccessibility::GetParent() const { |
| if (!node_ || !manager_) |
| return NULL; |
| ui::AXNode* parent = node_->parent(); |
| - return parent ? manager_->GetFromAXNode(parent) : NULL; |
| + if (parent) |
| + return manager_->GetFromAXNode(parent); |
| + return manager_->GetCrossFrameParent(); |
| } |
| int32 BrowserAccessibility::GetIndexInParent() const { |
| @@ -680,4 +698,9 @@ int BrowserAccessibility::GetStaticTextLenRecursive() const { |
| return len; |
| } |
| +void BrowserAccessibility::SetChildFrameId(int64 child_frame_id) { |
| + child_frame_id_ = child_frame_id; |
| + manager_->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, this); |
| +} |
| + |
| } // namespace content |