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

Side by Side Diff: chrome/browser/render_widget_host_hwnd.cc

Issue 4057: Adds MSAA/IAccessible exposure of web content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/render_widget_host_hwnd.h" 5 #include "chrome/browser/render_widget_host_hwnd.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/gfx/bitmap_header.h" 8 #include "base/gfx/bitmap_header.h"
9 #include "base/gfx/rect.h" 9 #include "base/gfx/rect.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
11 #include "base/win_util.h" 11 #include "base/win_util.h"
12 #include "chrome/browser/browser_accessibility.h"
13 #include "chrome/browser/browser_accessibility_manager.h"
12 #include "chrome/browser/render_process_host.h" 14 #include "chrome/browser/render_process_host.h"
13 // TODO(beng): (Cleanup) we should not need to include this file... see comment 15 // TODO(beng): (Cleanup) we should not need to include this file... see comment
14 // in |DidBecomeSelected|. 16 // in |DidBecomeSelected|.
15 #include "chrome/browser/render_view_host.h" 17 #include "chrome/browser/render_view_host.h"
16 #include "chrome/browser/render_widget_host.h" 18 #include "chrome/browser/render_widget_host.h"
17 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/l10n_util.h" 21 #include "chrome/common/l10n_util.h"
20 #include "chrome/common/plugin_messages.h" 22 #include "chrome/common/plugin_messages.h"
21 #include "chrome/common/win_util.h" 23 #include "chrome/common/win_util.h"
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 HWND child_window = ::RealChildWindowFromPoint(m_hWnd, cursor_pos); 742 HWND child_window = ::RealChildWindowFromPoint(m_hWnd, cursor_pos);
741 if (::IsWindow(child_window)) { 743 if (::IsWindow(child_window)) {
742 ::SetFocus(child_window); 744 ::SetFocus(child_window);
743 return MA_NOACTIVATE; 745 return MA_NOACTIVATE;
744 } else { 746 } else {
745 handled = FALSE; 747 handled = FALSE;
746 return MA_ACTIVATE; 748 return MA_ACTIVATE;
747 } 749 }
748 } 750 }
749 751
752 LRESULT RenderWidgetHostHWND::OnGetObject(UINT message, WPARAM wparam,
753 LPARAM lparam, BOOL& handled) {
754 LRESULT reference_result = static_cast<LRESULT>(0L);
755
756 // Accessibility readers will send an OBJID_CLIENT message.
757 if (OBJID_CLIENT == lparam) {
758 // If our MSAA DOM root is already created, reuse that pointer. Otherwise,
759 // create a new one.
760 if (!browser_accessibility_root_) {
761 CComObject<BrowserAccessibility>* accessibility = NULL;
762
763 if (!SUCCEEDED(CComObject<BrowserAccessibility>::CreateInstance(
764 &accessibility)) || !accessibility) {
765 // Return with failure.
766 return static_cast<LRESULT>(0L);
767 }
768
769 CComPtr<IAccessible> accessibility_comptr(accessibility);
770
771 // Root id is always 0, to distinguish this particular instance when
772 // mapping to the render-side IAccessible.
773 accessibility->set_iaccessible_id(0);
774
775 // Set the unique member variables of this particular process.
776 accessibility->set_instance_id(BrowserAccessibilityManager::Instance()->
777 SetMembers(accessibility, m_hWnd, render_widget_host_));
778
779 // All is well, assign the temp instance to the class smart pointer.
780 browser_accessibility_root_.Attach(accessibility_comptr.Detach());
781
782 if (!browser_accessibility_root_) {
783 // Paranoia check. Return with failure.
784 NOTREACHED();
785 return static_cast<LRESULT>(0L);
786 }
787
788 // Notify that an instance of IAccessible was allocated for m_hWnd.
789 ::NotifyWinEvent(EVENT_OBJECT_CREATE, m_hWnd, OBJID_CLIENT,
790 CHILDID_SELF);
791 }
792
793 // Create a reference to ViewAccessibility that MSAA will marshall
794 // to the client.
795 reference_result = LresultFromObject(IID_IAccessible, wparam,
796 static_cast<IAccessible*>(browser_accessibility_root_));
797 }
798 return reference_result;
799 }
800
750 void RenderWidgetHostHWND::OnFinalMessage(HWND window) { 801 void RenderWidgetHostHWND::OnFinalMessage(HWND window) {
751 render_widget_host_->ViewDestroyed(); 802 render_widget_host_->ViewDestroyed();
752 delete this; 803 delete this;
753 } 804 }
754 805
755 void RenderWidgetHostHWND::TrackMouseLeave(bool track) { 806 void RenderWidgetHostHWND::TrackMouseLeave(bool track) {
756 if (track == track_mouse_leave_) 807 if (track == track_mouse_leave_)
757 return; 808 return;
758 track_mouse_leave_ = track; 809 track_mouse_leave_ = track;
759 810
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 865
815 return TRUE; 866 return TRUE;
816 } 867 }
817 868
818 void RenderWidgetHostHWND::ShutdownHost() { 869 void RenderWidgetHostHWND::ShutdownHost() {
819 shutdown_factory_.RevokeAll(); 870 shutdown_factory_.RevokeAll();
820 render_widget_host_->Shutdown(); 871 render_widget_host_->Shutdown();
821 // Do not touch any members at this point, |this| has been deleted. 872 // Do not touch any members at this point, |this| has been deleted.
822 } 873 }
823 874
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698