diff options
Diffstat (limited to 'content/browser')
12 files changed, 81 insertions, 23 deletions
diff --git a/content/browser/accessibility/browser_accessibility_manager_win.cc b/content/browser/accessibility/browser_accessibility_manager_win.cc index 33e4614..b956d21 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.cc +++ b/content/browser/accessibility/browser_accessibility_manager_win.cc @@ -53,6 +53,12 @@ AccessibilityNodeData BrowserAccessibilityManagerWin::GetEmptyDocument() { return empty_document; } +void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, + LONG child_id) { + if (parent_iaccessible()) + ::NotifyWinEvent(event, parent_hwnd(), OBJID_CLIENT, child_id); +} + void BrowserAccessibilityManagerWin::AddNodeToMap(BrowserAccessibility* node) { BrowserAccessibilityManager::AddNodeToMap(node); LONG unique_id_win = node->ToBrowserAccessibilityWin()->unique_id_win(); @@ -151,14 +157,14 @@ void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( break; } - // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; - // the AT client will then call get_accChild on the HWND's accessibility - // object and pass it that same id, which we can use to retrieve the - // IAccessible for this node. - LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); - - if (event_id != EVENT_MIN) - NotifyWinEvent(event_id, parent_hwnd(), OBJID_CLIENT, child_id); + if (event_id != EVENT_MIN) { + // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; + // the AT client will then call get_accChild on the HWND's accessibility + // object and pass it that same id, which we can use to retrieve the + // IAccessible for this node. + LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); + MaybeCallNotifyWinEvent(event_id, child_id); + } // If this is a layout complete notification (sent when a container scrolls) // and there is a descendant tracked object, send a notification on it. @@ -166,10 +172,8 @@ void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( if (type == AccessibilityNotificationLayoutComplete && tracked_scroll_object_ && tracked_scroll_object_->IsDescendantOf(node)) { - NotifyWinEvent( + MaybeCallNotifyWinEvent( IA2_EVENT_VISIBLE_DATA_CHANGED, - parent_hwnd(), - OBJID_CLIENT, tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); tracked_scroll_object_->Release(); tracked_scroll_object_ = NULL; diff --git a/content/browser/accessibility/browser_accessibility_manager_win.h b/content/browser/accessibility/browser_accessibility_manager_win.h index e82f065..7aec2e1 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.h +++ b/content/browser/accessibility/browser_accessibility_manager_win.h @@ -37,6 +37,9 @@ class CONTENT_EXPORT BrowserAccessibilityManagerWin parent_iaccessible_ = parent_iaccessible; } + // Calls NotifyWinEvent if the parent window's IAccessible pointer is known. + void MaybeCallNotifyWinEvent(DWORD event, LONG child_id); + // BrowserAccessibilityManager methods virtual void AddNodeToMap(BrowserAccessibility* node); virtual void RemoveNode(BrowserAccessibility* node) OVERRIDE; diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc index 7f5bc01..263c094 100644 --- a/content/browser/accessibility/browser_accessibility_win.cc +++ b/content/browser/accessibility/browser_accessibility_win.cc @@ -491,6 +491,10 @@ STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { // This happens if we're the root of the tree; // return the IAccessible for the window. parent = manager_->ToBrowserAccessibilityManagerWin()->parent_iaccessible(); + // |parent| can only be NULL if the manager was created before the parent + // IAccessible was known and it wasn't subsequently set before a client + // requested it. Crash hard if this happens so that we get crash reports. + CHECK(parent); } parent->AddRef(); @@ -2941,10 +2945,11 @@ void BrowserAccessibilityWin::PostInitialize() { previous_text_ = text; } - HWND hwnd = manager_->ToBrowserAccessibilityManagerWin()->parent_hwnd(); - // Fire events if the state has changed. if (!first_time_ && ia_state_ != old_ia_state_) { + BrowserAccessibilityManagerWin* manager = + manager_->ToBrowserAccessibilityManagerWin(); + // Normally focus events are handled elsewhere, however // focus for managed descendants is platform-specific. // Fire a focus event if the focused descendant in a multi-select @@ -2954,18 +2959,17 @@ void BrowserAccessibilityWin::PostInitialize() { (ia_state_ & STATE_SYSTEM_SELECTABLE) && (ia_state_ & STATE_SYSTEM_FOCUSED) && !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) { - ::NotifyWinEvent(EVENT_OBJECT_FOCUS, hwnd, - OBJID_CLIENT, unique_id_win()); + manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, unique_id_win()); } if ((ia_state_ & STATE_SYSTEM_SELECTED) && !(old_ia_state_ & STATE_SYSTEM_SELECTED)) { - ::NotifyWinEvent(EVENT_OBJECT_SELECTIONADD, hwnd, - OBJID_CLIENT, unique_id_win()); + manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, + unique_id_win()); } else if (!(ia_state_ & STATE_SYSTEM_SELECTED) && (old_ia_state_ & STATE_SYSTEM_SELECTED)) { - ::NotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, hwnd, - OBJID_CLIENT, unique_id_win()); + manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, + unique_id_win()); } old_ia_state_ = ia_state_; @@ -2988,9 +2992,8 @@ bool BrowserAccessibilityWin::IsNative() const { void BrowserAccessibilityWin::SetLocation(const gfx::Rect& new_location) { BrowserAccessibility::SetLocation(new_location); - HWND hwnd = manager_->ToBrowserAccessibilityManagerWin()->parent_hwnd(); - ::NotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, - OBJID_CLIENT, unique_id_win()); + manager_->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( + EVENT_OBJECT_LOCATIONCHANGE, unique_id_win()); } BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 81833d1..2f76e81 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -2316,6 +2316,12 @@ void RenderWidgetHostImpl::FatalAccessibilityTreeError() { } #if defined(OS_WIN) && defined(USE_AURA) +void RenderWidgetHostImpl::SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) { + if (view_) + view_->SetParentNativeViewAccessible(accessible_parent); +} + gfx::NativeViewAccessible RenderWidgetHostImpl::GetParentNativeViewAccessible() const { return delegate_->GetParentNativeViewAccessible(); diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 5da9332..c023464 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -382,6 +382,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, void FatalAccessibilityTreeError(); #if defined(OS_WIN) && defined(USE_AURA) + void SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent); gfx::NativeViewAccessible GetParentNativeViewAccessible() const; #endif diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 0da5853..5224eb8 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -862,9 +862,12 @@ RenderWidgetHostViewAura::GetOrCreateBrowserAccessibilityManager() { return NULL; HWND hwnd = root_window->GetAcceleratedWidget(); + // The accessible_parent may be NULL at this point. The WebContents will pass + // it down to this instance (by way of the RenderViewHost and + // RenderWidgetHost) when it is known. This instance will then set it on its + // BrowserAccessibilityManager. gfx::NativeViewAccessible accessible_parent = host_->GetParentNativeViewAccessible(); - DCHECK(accessible_parent); manager = new BrowserAccessibilityManagerWin( hwnd, accessible_parent, @@ -1571,6 +1574,16 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame( frame->gl_frame_data->size, mailbox_name, ack_callback); } +#if defined(OS_WIN) +void RenderWidgetHostViewAura::SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) { + if (GetBrowserAccessibilityManager()) { + GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() + ->set_parent_iaccessible(accessible_parent); + } +} +#endif + void RenderWidgetHostViewAura::BuffersSwapped( const gfx::Size& size, const std::string& mailbox_name, diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index c7987dc..10b1a71 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -237,6 +237,10 @@ class RenderWidgetHostViewAura virtual void UnlockMouse() OVERRIDE; virtual void OnSwapCompositorFrame( scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; +#if defined(OS_WIN) + virtual void SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) OVERRIDE; +#endif // Overridden from ui::TextInputClient: virtual void SetCompositionText( diff --git a/content/browser/renderer_host/render_widget_host_view_guest.cc b/content/browser/renderer_host/render_widget_host_view_guest.cc index 2e00453..a706d25 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.cc +++ b/content/browser/renderer_host/render_widget_host_view_guest.cc @@ -439,6 +439,12 @@ void RenderWidgetHostViewGuest::WillWmDestroy() { } #endif +#if defined(OS_WIN) && defined(USE_AURA) +void RenderWidgetHostViewGuest::SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) { +} +#endif + void RenderWidgetHostViewGuest::DestroyGuestView() { host_ = NULL; base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); diff --git a/content/browser/renderer_host/render_widget_host_view_guest.h b/content/browser/renderer_host/render_widget_host_view_guest.h index b1c2816..84900b7 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.h +++ b/content/browser/renderer_host/render_widget_host_view_guest.h @@ -175,6 +175,11 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest virtual void WillWmDestroy() OVERRIDE; #endif // defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) && defined(USE_AURA) + virtual void SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) OVERRIDE; +#endif + // Overridden from ui::GestureEventHelper. virtual bool DispatchLongPressGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual bool DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index 315927c..be2fab9 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -229,6 +229,12 @@ bool TestRenderWidgetHostView::LockMouse() { void TestRenderWidgetHostView::UnlockMouse() { } +#if defined(OS_WIN) && defined(USE_AURA) +void TestRenderWidgetHostView::SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) { +} +#endif + TestRenderViewHost::TestRenderViewHost( SiteInstance* instance, RenderViewHostDelegate* delegate, diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 68634d4..9fb3cfc 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -164,6 +164,10 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { #endif virtual bool LockMouse() OVERRIDE; virtual void UnlockMouse() OVERRIDE; +#if defined(OS_WIN) && defined(USE_AURA) + virtual void SetParentNativeViewAccessible( + gfx::NativeViewAccessible accessible_parent) OVERRIDE; +#endif bool is_showing() const { return is_showing_; } diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 4d9f4cc..8cf86dc 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -893,6 +893,8 @@ const std::string& WebContentsImpl::GetUserAgentOverride() const { void WebContentsImpl::SetParentNativeViewAccessible( gfx::NativeViewAccessible accessible_parent) { accessible_parent_ = accessible_parent; + if (GetRenderViewHost()) + GetRenderViewHostImpl()->SetParentNativeViewAccessible(accessible_parent); } #endif |