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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.h

Issue 273423004: Migrate accessibility from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 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) 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <queue> 11 #include <queue>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/process/kill.h" 21 #include "base/process/kill.h"
22 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
23 #include "base/time/time.h" 23 #include "base/time/time.h"
24 #include "base/timer/timer.h" 24 #include "base/timer/timer.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "cc/resources/shared_bitmap.h" 26 #include "cc/resources/shared_bitmap.h"
27 #include "content/browser/accessibility/browser_accessibility_manager.h"
28 #include "content/browser/renderer_host/event_with_latency_info.h" 27 #include "content/browser/renderer_host/event_with_latency_info.h"
29 #include "content/browser/renderer_host/input/input_ack_handler.h" 28 #include "content/browser/renderer_host/input/input_ack_handler.h"
30 #include "content/browser/renderer_host/input/input_router_client.h" 29 #include "content/browser/renderer_host/input/input_router_client.h"
31 #include "content/browser/renderer_host/input/synthetic_gesture.h" 30 #include "content/browser/renderer_host/input/synthetic_gesture.h"
32 #include "content/browser/renderer_host/input/touch_emulator_client.h" 31 #include "content/browser/renderer_host/input/touch_emulator_client.h"
33 #include "content/common/input/input_event_ack_state.h" 32 #include "content/common/input/input_event_ack_state.h"
34 #include "content/common/input/synthetic_gesture_packet.h" 33 #include "content/common/input/synthetic_gesture_packet.h"
35 #include "content/common/view_message_enums.h" 34 #include "content/common/view_message_enums.h"
36 #include "content/public/browser/render_widget_host.h" 35 #include "content/public/browser/render_widget_host.h"
37 #include "content/public/common/page_zoom.h" 36 #include "content/public/common/page_zoom.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 struct WebScreenInfo; 71 struct WebScreenInfo;
73 } 72 }
74 73
75 #if defined(OS_ANDROID) 74 #if defined(OS_ANDROID)
76 namespace blink { 75 namespace blink {
77 class WebLayer; 76 class WebLayer;
78 } 77 }
79 #endif 78 #endif
80 79
81 namespace content { 80 namespace content {
81 class BrowserAccessibilityManager;
82 class InputRouter; 82 class InputRouter;
83 class MockRenderWidgetHost; 83 class MockRenderWidgetHost;
84 class RenderWidgetHostDelegate; 84 class RenderWidgetHostDelegate;
85 class RenderWidgetHostViewBase; 85 class RenderWidgetHostViewBase;
86 class SyntheticGestureController; 86 class SyntheticGestureController;
87 class TimeoutMonitor; 87 class TimeoutMonitor;
88 class TouchEmulator; 88 class TouchEmulator;
89 class WebCursor; 89 class WebCursor;
90 struct EditCommand; 90 struct EditCommand;
91 91
92 // This implements the RenderWidgetHost interface that is exposed to 92 // This implements the RenderWidgetHost interface that is exposed to
93 // embedders of content, and adds things only visible to content. 93 // embedders of content, and adds things only visible to content.
94 class CONTENT_EXPORT RenderWidgetHostImpl 94 class CONTENT_EXPORT RenderWidgetHostImpl
95 : virtual public RenderWidgetHost, 95 : virtual public RenderWidgetHost,
96 public InputRouterClient, 96 public InputRouterClient,
97 public InputAckHandler, 97 public InputAckHandler,
98 public TouchEmulatorClient, 98 public TouchEmulatorClient,
99 public IPC::Listener, 99 public IPC::Listener {
100 public BrowserAccessibilityDelegate {
101 public: 100 public:
102 // routing_id can be MSG_ROUTING_NONE, in which case the next available 101 // routing_id can be MSG_ROUTING_NONE, in which case the next available
103 // routing id is taken from the RenderProcessHost. 102 // routing id is taken from the RenderProcessHost.
104 // If this object outlives |delegate|, DetachDelegate() must be called when 103 // If this object outlives |delegate|, DetachDelegate() must be called when
105 // |delegate| goes away. 104 // |delegate| goes away.
106 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, 105 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
107 RenderProcessHost* process, 106 RenderProcessHost* process,
108 int routing_id, 107 int routing_id,
109 bool hidden); 108 bool hidden);
110 virtual ~RenderWidgetHostImpl(); 109 virtual ~RenderWidgetHostImpl();
(...skipping 24 matching lines...) Expand all
135 virtual void CopyFromBackingStore( 134 virtual void CopyFromBackingStore(
136 const gfx::Rect& src_rect, 135 const gfx::Rect& src_rect,
137 const gfx::Size& accelerated_dst_size, 136 const gfx::Size& accelerated_dst_size,
138 const base::Callback<void(bool, const SkBitmap&)>& callback, 137 const base::Callback<void(bool, const SkBitmap&)>& callback,
139 const SkColorType color_type) OVERRIDE; 138 const SkColorType color_type) OVERRIDE;
140 virtual bool CanCopyFromBackingStore() OVERRIDE; 139 virtual bool CanCopyFromBackingStore() OVERRIDE;
141 #if defined(OS_ANDROID) 140 #if defined(OS_ANDROID)
142 virtual void LockBackingStore() OVERRIDE; 141 virtual void LockBackingStore() OVERRIDE;
143 virtual void UnlockBackingStore() OVERRIDE; 142 virtual void UnlockBackingStore() OVERRIDE;
144 #endif 143 #endif
145 virtual void EnableFullAccessibilityMode() OVERRIDE;
146 virtual bool IsFullAccessibilityModeForTesting() OVERRIDE;
147 virtual void EnableTreeOnlyAccessibilityMode() OVERRIDE;
148 virtual bool IsTreeOnlyAccessibilityModeForTesting() OVERRIDE;
149 virtual void ForwardMouseEvent( 144 virtual void ForwardMouseEvent(
150 const blink::WebMouseEvent& mouse_event) OVERRIDE; 145 const blink::WebMouseEvent& mouse_event) OVERRIDE;
151 virtual void ForwardWheelEvent( 146 virtual void ForwardWheelEvent(
152 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE; 147 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE;
153 virtual void ForwardKeyboardEvent( 148 virtual void ForwardKeyboardEvent(
154 const NativeWebKeyboardEvent& key_event) OVERRIDE; 149 const NativeWebKeyboardEvent& key_event) OVERRIDE;
155 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE; 150 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE;
156 virtual RenderProcessHost* GetProcess() const OVERRIDE; 151 virtual RenderProcessHost* GetProcess() const OVERRIDE;
157 virtual int GetRoutingID() const OVERRIDE; 152 virtual int GetRoutingID() const OVERRIDE;
158 virtual RenderWidgetHostView* GetView() const OVERRIDE; 153 virtual RenderWidgetHostView* GetView() const OVERRIDE;
159 virtual bool IsLoading() const OVERRIDE; 154 virtual bool IsLoading() const OVERRIDE;
160 virtual bool IsRenderView() const OVERRIDE; 155 virtual bool IsRenderView() const OVERRIDE;
161 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; 156 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE;
162 virtual void RestartHangMonitorTimeout() OVERRIDE; 157 virtual void RestartHangMonitorTimeout() OVERRIDE;
163 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; 158 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE;
164 virtual void Stop() OVERRIDE; 159 virtual void Stop() OVERRIDE;
165 virtual void WasResized() OVERRIDE; 160 virtual void WasResized() OVERRIDE;
166 virtual void AddKeyPressEventCallback( 161 virtual void AddKeyPressEventCallback(
167 const KeyPressEventCallback& callback) OVERRIDE; 162 const KeyPressEventCallback& callback) OVERRIDE;
168 virtual void RemoveKeyPressEventCallback( 163 virtual void RemoveKeyPressEventCallback(
169 const KeyPressEventCallback& callback) OVERRIDE; 164 const KeyPressEventCallback& callback) OVERRIDE;
170 virtual void AddMouseEventCallback( 165 virtual void AddMouseEventCallback(
171 const MouseEventCallback& callback) OVERRIDE; 166 const MouseEventCallback& callback) OVERRIDE;
172 virtual void RemoveMouseEventCallback( 167 virtual void RemoveMouseEventCallback(
173 const MouseEventCallback& callback) OVERRIDE; 168 const MouseEventCallback& callback) OVERRIDE;
174 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE; 169 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE;
175 170
176 virtual SkColorType PreferredReadbackFormat() OVERRIDE; 171 virtual SkColorType PreferredReadbackFormat() OVERRIDE;
177 172
178 // BrowserAccessibilityDelegate
179 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE;
180 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE;
181 virtual void AccessibilityShowMenu(int acc_obj_id) OVERRIDE;
182 virtual void AccessibilityScrollToMakeVisible(
183 int acc_obj_id, gfx::Rect subfocus) OVERRIDE;
184 virtual void AccessibilityScrollToPoint(
185 int acc_obj_id, gfx::Point point) OVERRIDE;
186 virtual void AccessibilitySetTextSelection(
187 int acc_obj_id, int start_offset, int end_offset) OVERRIDE;
188 virtual bool AccessibilityViewHasFocus() const OVERRIDE;
189 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE;
190 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds)
191 const OVERRIDE;
192 virtual void AccessibilityHitTest(const gfx::Point& point) OVERRIDE;
193 virtual void AccessibilityFatalError() OVERRIDE;
194
195 // Forces redraw in the renderer and when the update reaches the browser 173 // Forces redraw in the renderer and when the update reaches the browser
196 // grabs snapshot from the compositor. Returns PNG-encoded snapshot. 174 // grabs snapshot from the compositor. Returns PNG-encoded snapshot.
197 void GetSnapshotFromBrowser( 175 void GetSnapshotFromBrowser(
198 const base::Callback<void(const unsigned char*,size_t)> callback); 176 const base::Callback<void(const unsigned char*,size_t)> callback);
199 177
200 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const; 178 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const;
201 179
202 // Notification that the screen info has changed. 180 // Notification that the screen info has changed.
203 void NotifyScreenInfoChanged(); 181 void NotifyScreenInfoChanged();
204 182
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 void StartUserGesture(); 365 void StartUserGesture();
388 366
389 // Set the RenderView background transparency. 367 // Set the RenderView background transparency.
390 void SetBackgroundOpaque(bool opaque); 368 void SetBackgroundOpaque(bool opaque);
391 369
392 // Notifies the renderer that the next key event is bound to one or more 370 // Notifies the renderer that the next key event is bound to one or more
393 // pre-defined edit commands 371 // pre-defined edit commands
394 void SetEditCommandsForNextKeyEvent( 372 void SetEditCommandsForNextKeyEvent(
395 const std::vector<EditCommand>& commands); 373 const std::vector<EditCommand>& commands);
396 374
397 // Gets the accessibility mode.
398 AccessibilityMode accessibility_mode() const {
399 return accessibility_mode_;
400 }
401
402 // Adds the given accessibility mode to the current accessibility mode bitmap.
403 void AddAccessibilityMode(AccessibilityMode mode);
404
405 // Removes the given accessibility mode from the current accessibility mode
406 // bitmap, managing the bits that are shared with other modes such that a
407 // bit will only be turned off when all modes that depend on it have been
408 // removed.
409 void RemoveAccessibilityMode(AccessibilityMode mode);
410
411 // Resets the accessibility mode to the default setting in
412 // BrowserStateAccessibilityImpl.
413 void ResetAccessibilityMode();
414
415 #if defined(OS_WIN)
416 void SetParentNativeViewAccessible(
417 gfx::NativeViewAccessible accessible_parent);
418 gfx::NativeViewAccessible GetParentNativeViewAccessible() const;
419 #endif
420
421 // Executes the edit command on the RenderView. 375 // Executes the edit command on the RenderView.
422 void ExecuteEditCommand(const std::string& command, 376 void ExecuteEditCommand(const std::string& command,
423 const std::string& value); 377 const std::string& value);
424 378
425 // Tells the renderer to scroll the currently focused node into rect only if 379 // Tells the renderer to scroll the currently focused node into rect only if
426 // the currently focused node is a Text node (textfield, text area or content 380 // the currently focused node is a Text node (textfield, text area or content
427 // editable divs). 381 // editable divs).
428 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); 382 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
429 383
430 // Requests the renderer to move the caret selection towards the point. 384 // Requests the renderer to move the caret selection towards the point.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 gfx::Size snapshot_size, 466 gfx::Size snapshot_size,
513 scoped_refptr<base::RefCountedBytes> png_data); 467 scoped_refptr<base::RefCountedBytes> png_data);
514 468
515 // LatencyComponents generated in the renderer must have component IDs 469 // LatencyComponents generated in the renderer must have component IDs
516 // provided to them by the browser process. This function adds the correct 470 // provided to them by the browser process. This function adds the correct
517 // component ID where necessary. 471 // component ID where necessary.
518 void AddLatencyInfoComponentIds(ui::LatencyInfo* latency_info); 472 void AddLatencyInfoComponentIds(ui::LatencyInfo* latency_info);
519 473
520 InputRouter* input_router() { return input_router_.get(); } 474 InputRouter* input_router() { return input_router_.get(); }
521 475
476 // Get the BrowserAccessibilityManager for the root of the frame tree,
477 BrowserAccessibilityManager* GetRootBrowserAccessibilityManager();
478
479 // Get the BrowserAccessibilityManager for the root of the frame tree,
480 // or create it if it doesn't already exist.
481 BrowserAccessibilityManager* GetOrCreateRootBrowserAccessibilityManager();
482
483 #if defined(OS_WIN)
484 gfx::NativeViewAccessible GetParentNativeViewAccessible();
485 #endif
486
522 protected: 487 protected:
523 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE; 488 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE;
524 489
525 // Create a LatencyInfo struct with INPUT_EVENT_LATENCY_RWH_COMPONENT 490 // Create a LatencyInfo struct with INPUT_EVENT_LATENCY_RWH_COMPONENT
526 // component if it is not already in |original|. And if |original| is 491 // component if it is not already in |original|. And if |original| is
527 // not NULL, it is also merged into the resulting LatencyInfo. 492 // not NULL, it is also merged into the resulting LatencyInfo.
528 ui::LatencyInfo CreateRWHLatencyInfoIfNotExist( 493 ui::LatencyInfo CreateRWHLatencyInfoIfNotExist(
529 const ui::LatencyInfo* original, blink::WebInputEvent::Type type); 494 const ui::LatencyInfo* original, blink::WebInputEvent::Type type);
530 495
531 // Called when we receive a notification indicating that the renderer 496 // Called when we receive a notification indicating that the renderer
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 void WindowSnapshotReachedScreen(int snapshot_id); 670 void WindowSnapshotReachedScreen(int snapshot_id);
706 671
707 void OnSnapshotDataReceived(int snapshot_id, 672 void OnSnapshotDataReceived(int snapshot_id,
708 const unsigned char* png, 673 const unsigned char* png,
709 size_t size); 674 size_t size);
710 675
711 void OnSnapshotDataReceivedAsync( 676 void OnSnapshotDataReceivedAsync(
712 int snapshot_id, 677 int snapshot_id,
713 scoped_refptr<base::RefCountedBytes> png_data); 678 scoped_refptr<base::RefCountedBytes> png_data);
714 679
715 // Send a message to the renderer process to change the accessibility mode.
716 void SetAccessibilityMode(AccessibilityMode AccessibilityMode);
717
718 // Our delegate, which wants to know mainly about keyboard events. 680 // Our delegate, which wants to know mainly about keyboard events.
719 // It will remain non-NULL until DetachDelegate() is called. 681 // It will remain non-NULL until DetachDelegate() is called.
720 RenderWidgetHostDelegate* delegate_; 682 RenderWidgetHostDelegate* delegate_;
721 683
722 // Created during construction but initialized during Init*(). Therefore, it 684 // Created during construction but initialized during Init*(). Therefore, it
723 // is guaranteed never to be NULL, but its channel may be NULL if the 685 // is guaranteed never to be NULL, but its channel may be NULL if the
724 // renderer crashed, so you must always check that. 686 // renderer crashed, so you must always check that.
725 RenderProcessHost* process_; 687 RenderProcessHost* process_;
726 688
727 // The ID of the corresponding object in the Renderer Instance. 689 // The ID of the corresponding object in the Renderer Instance.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 gfx::Size new_auto_size_; 741 gfx::Size new_auto_size_;
780 742
781 // True if the render widget host should track the render widget's size as 743 // True if the render widget host should track the render widget's size as
782 // opposed to visa versa. 744 // opposed to visa versa.
783 bool should_auto_resize_; 745 bool should_auto_resize_;
784 746
785 bool waiting_for_screen_rects_ack_; 747 bool waiting_for_screen_rects_ack_;
786 gfx::Rect last_view_screen_rect_; 748 gfx::Rect last_view_screen_rect_;
787 gfx::Rect last_window_screen_rect_; 749 gfx::Rect last_window_screen_rect_;
788 750
789 AccessibilityMode accessibility_mode_;
790
791 // Keyboard event listeners. 751 // Keyboard event listeners.
792 std::vector<KeyPressEventCallback> key_press_event_callbacks_; 752 std::vector<KeyPressEventCallback> key_press_event_callbacks_;
793 753
794 // Mouse event callbacks. 754 // Mouse event callbacks.
795 std::vector<MouseEventCallback> mouse_event_callbacks_; 755 std::vector<MouseEventCallback> mouse_event_callbacks_;
796 756
797 // If true, then we should repaint when restoring even if we have a 757 // If true, then we should repaint when restoring even if we have a
798 // backingstore. This flag is set to true if we receive a paint message 758 // backingstore. This flag is set to true if we receive a paint message
799 // while is_hidden_ to true. Even though we tell the render widget to hide 759 // while is_hidden_ to true. Even though we tell the render widget to hide
800 // itself, a paint message could already be in flight at that point. 760 // itself, a paint message could already be in flight at that point.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 typedef std::map<int, 843 typedef std::map<int,
884 base::Callback<void(const unsigned char*, size_t)> > PendingSnapshotMap; 844 base::Callback<void(const unsigned char*, size_t)> > PendingSnapshotMap;
885 PendingSnapshotMap pending_browser_snapshots_; 845 PendingSnapshotMap pending_browser_snapshots_;
886 846
887 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); 847 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl);
888 }; 848 };
889 849
890 } // namespace content 850 } // namespace content
891 851
892 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ 852 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698