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

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: Fix win & android compile Created 6 years, 7 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 OverscrollController; 84 class OverscrollController;
85 class RenderWidgetHostDelegate; 85 class RenderWidgetHostDelegate;
86 class RenderWidgetHostViewBase; 86 class RenderWidgetHostViewBase;
87 class SyntheticGestureController; 87 class SyntheticGestureController;
88 class TimeoutMonitor; 88 class TimeoutMonitor;
89 class TouchEmulator; 89 class TouchEmulator;
90 class WebCursor; 90 class WebCursor;
91 struct EditCommand; 91 struct EditCommand;
92 92
93 // This implements the RenderWidgetHost interface that is exposed to 93 // This implements the RenderWidgetHost interface that is exposed to
94 // embedders of content, and adds things only visible to content. 94 // embedders of content, and adds things only visible to content.
95 class CONTENT_EXPORT RenderWidgetHostImpl 95 class CONTENT_EXPORT RenderWidgetHostImpl
96 : virtual public RenderWidgetHost, 96 : virtual public RenderWidgetHost,
97 public InputRouterClient, 97 public InputRouterClient,
98 public InputAckHandler, 98 public InputAckHandler,
99 public TouchEmulatorClient, 99 public TouchEmulatorClient,
100 public IPC::Listener, 100 public IPC::Listener {
101 public BrowserAccessibilityDelegate {
102 public: 101 public:
103 // routing_id can be MSG_ROUTING_NONE, in which case the next available 102 // routing_id can be MSG_ROUTING_NONE, in which case the next available
104 // routing id is taken from the RenderProcessHost. 103 // routing id is taken from the RenderProcessHost.
105 // If this object outlives |delegate|, DetachDelegate() must be called when 104 // If this object outlives |delegate|, DetachDelegate() must be called when
106 // |delegate| goes away. 105 // |delegate| goes away.
107 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, 106 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
108 RenderProcessHost* process, 107 RenderProcessHost* process,
109 int routing_id, 108 int routing_id,
110 bool hidden); 109 bool hidden);
111 virtual ~RenderWidgetHostImpl(); 110 virtual ~RenderWidgetHostImpl();
(...skipping 24 matching lines...) Expand all
136 virtual void CopyFromBackingStore( 135 virtual void CopyFromBackingStore(
137 const gfx::Rect& src_rect, 136 const gfx::Rect& src_rect,
138 const gfx::Size& accelerated_dst_size, 137 const gfx::Size& accelerated_dst_size,
139 const base::Callback<void(bool, const SkBitmap&)>& callback, 138 const base::Callback<void(bool, const SkBitmap&)>& callback,
140 const SkBitmap::Config& bitmap_config) OVERRIDE; 139 const SkBitmap::Config& bitmap_config) OVERRIDE;
141 virtual bool CanCopyFromBackingStore() OVERRIDE; 140 virtual bool CanCopyFromBackingStore() OVERRIDE;
142 #if defined(OS_ANDROID) 141 #if defined(OS_ANDROID)
143 virtual void LockBackingStore() OVERRIDE; 142 virtual void LockBackingStore() OVERRIDE;
144 virtual void UnlockBackingStore() OVERRIDE; 143 virtual void UnlockBackingStore() OVERRIDE;
145 #endif 144 #endif
146 virtual void EnableFullAccessibilityMode() OVERRIDE;
147 virtual bool IsFullAccessibilityModeForTesting() OVERRIDE;
148 virtual void EnableTreeOnlyAccessibilityMode() OVERRIDE;
149 virtual bool IsTreeOnlyAccessibilityModeForTesting() OVERRIDE;
150 virtual void ForwardMouseEvent( 145 virtual void ForwardMouseEvent(
151 const blink::WebMouseEvent& mouse_event) OVERRIDE; 146 const blink::WebMouseEvent& mouse_event) OVERRIDE;
152 virtual void ForwardWheelEvent( 147 virtual void ForwardWheelEvent(
153 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE; 148 const blink::WebMouseWheelEvent& wheel_event) OVERRIDE;
154 virtual void ForwardKeyboardEvent( 149 virtual void ForwardKeyboardEvent(
155 const NativeWebKeyboardEvent& key_event) OVERRIDE; 150 const NativeWebKeyboardEvent& key_event) OVERRIDE;
156 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE; 151 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE;
157 virtual RenderProcessHost* GetProcess() const OVERRIDE; 152 virtual RenderProcessHost* GetProcess() const OVERRIDE;
158 virtual int GetRoutingID() const OVERRIDE; 153 virtual int GetRoutingID() const OVERRIDE;
159 virtual RenderWidgetHostView* GetView() const OVERRIDE; 154 virtual RenderWidgetHostView* GetView() const OVERRIDE;
160 virtual bool IsLoading() const OVERRIDE; 155 virtual bool IsLoading() const OVERRIDE;
161 virtual bool IsRenderView() const OVERRIDE; 156 virtual bool IsRenderView() const OVERRIDE;
162 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; 157 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE;
163 virtual void RestartHangMonitorTimeout() OVERRIDE; 158 virtual void RestartHangMonitorTimeout() OVERRIDE;
164 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; 159 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE;
165 virtual void Stop() OVERRIDE; 160 virtual void Stop() OVERRIDE;
166 virtual void WasResized() OVERRIDE; 161 virtual void WasResized() OVERRIDE;
167 virtual void AddKeyPressEventCallback( 162 virtual void AddKeyPressEventCallback(
168 const KeyPressEventCallback& callback) OVERRIDE; 163 const KeyPressEventCallback& callback) OVERRIDE;
169 virtual void RemoveKeyPressEventCallback( 164 virtual void RemoveKeyPressEventCallback(
170 const KeyPressEventCallback& callback) OVERRIDE; 165 const KeyPressEventCallback& callback) OVERRIDE;
171 virtual void AddMouseEventCallback( 166 virtual void AddMouseEventCallback(
172 const MouseEventCallback& callback) OVERRIDE; 167 const MouseEventCallback& callback) OVERRIDE;
173 virtual void RemoveMouseEventCallback( 168 virtual void RemoveMouseEventCallback(
174 const MouseEventCallback& callback) OVERRIDE; 169 const MouseEventCallback& callback) OVERRIDE;
175 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE; 170 virtual void GetWebScreenInfo(blink::WebScreenInfo* result) OVERRIDE;
176 171
177 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE; 172 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE;
178 173
179 // BrowserAccessibilityDelegate
180 virtual void AccessibilitySetFocus(int acc_obj_id) OVERRIDE;
181 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE;
182 virtual void AccessibilityShowMenu(int acc_obj_id) OVERRIDE;
183 virtual void AccessibilityScrollToMakeVisible(
184 int acc_obj_id, gfx::Rect subfocus) OVERRIDE;
185 virtual void AccessibilityScrollToPoint(
186 int acc_obj_id, gfx::Point point) OVERRIDE;
187 virtual void AccessibilitySetTextSelection(
188 int acc_obj_id, int start_offset, int end_offset) OVERRIDE;
189 virtual bool AccessibilityViewHasFocus() const OVERRIDE;
190 virtual gfx::Rect AccessibilityGetViewBounds() const OVERRIDE;
191 virtual gfx::Point AccessibilityOriginInScreen(const gfx::Rect& bounds)
192 const OVERRIDE;
193 virtual void AccessibilityFatalError() OVERRIDE;
194
195 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const; 174 const NativeWebKeyboardEvent* GetLastKeyboardEvent() const;
196 175
197 // Notification that the screen info has changed. 176 // Notification that the screen info has changed.
198 void NotifyScreenInfoChanged(); 177 void NotifyScreenInfoChanged();
199 178
200 // Invalidates the cached screen info so that next resize request 179 // Invalidates the cached screen info so that next resize request
201 // will carry the up to date screen info. Unlike 180 // will carry the up to date screen info. Unlike
202 // |NotifyScreenInfoChanged|, this doesn't send a message to the renderer. 181 // |NotifyScreenInfoChanged|, this doesn't send a message to the renderer.
203 void InvalidateScreenInfo(); 182 void InvalidateScreenInfo();
204 183
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 void StartUserGesture(); 359 void StartUserGesture();
381 360
382 // Set the RenderView background transparency. 361 // Set the RenderView background transparency.
383 void SetBackgroundOpaque(bool opaque); 362 void SetBackgroundOpaque(bool opaque);
384 363
385 // Notifies the renderer that the next key event is bound to one or more 364 // Notifies the renderer that the next key event is bound to one or more
386 // pre-defined edit commands 365 // pre-defined edit commands
387 void SetEditCommandsForNextKeyEvent( 366 void SetEditCommandsForNextKeyEvent(
388 const std::vector<EditCommand>& commands); 367 const std::vector<EditCommand>& commands);
389 368
390 // Gets the accessibility mode.
391 AccessibilityMode accessibility_mode() const {
392 return accessibility_mode_;
393 }
394
395 // Adds the given accessibility mode to the current accessibility mode bitmap.
396 void AddAccessibilityMode(AccessibilityMode mode);
397
398 // Removes the given accessibility mode from the current accessibility mode
399 // bitmap, managing the bits that are shared with other modes such that a
400 // bit will only be turned off when all modes that depend on it have been
401 // removed.
402 void RemoveAccessibilityMode(AccessibilityMode mode);
403
404 // Resets the accessibility mode to the default setting in
405 // BrowserStateAccessibilityImpl.
406 void ResetAccessibilityMode();
407
408 #if defined(OS_WIN)
409 void SetParentNativeViewAccessible(
410 gfx::NativeViewAccessible accessible_parent);
411 gfx::NativeViewAccessible GetParentNativeViewAccessible() const;
412 #endif
413
414 // Executes the edit command on the RenderView. 369 // Executes the edit command on the RenderView.
415 void ExecuteEditCommand(const std::string& command, 370 void ExecuteEditCommand(const std::string& command,
416 const std::string& value); 371 const std::string& value);
417 372
418 // Tells the renderer to scroll the currently focused node into rect only if 373 // Tells the renderer to scroll the currently focused node into rect only if
419 // the currently focused node is a Text node (textfield, text area or content 374 // the currently focused node is a Text node (textfield, text area or content
420 // editable divs). 375 // editable divs).
421 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); 376 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
422 377
423 // Requests the renderer to move the caret selection towards the point. 378 // Requests the renderer to move the caret selection towards the point.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 gfx::Size snapshot_size, 467 gfx::Size snapshot_size,
513 scoped_refptr<base::RefCountedBytes> png_data); 468 scoped_refptr<base::RefCountedBytes> png_data);
514 469
515 // LatencyComponents generated in the renderer must have component IDs 470 // LatencyComponents generated in the renderer must have component IDs
516 // provided to them by the browser process. This function adds the correct 471 // provided to them by the browser process. This function adds the correct
517 // component ID where necessary. 472 // component ID where necessary.
518 void AddLatencyInfoComponentIds(ui::LatencyInfo* latency_info); 473 void AddLatencyInfoComponentIds(ui::LatencyInfo* latency_info);
519 474
520 InputRouter* input_router() { return input_router_.get(); } 475 InputRouter* input_router() { return input_router_.get(); }
521 476
477 // Get the BrowserAccessibilityManager for the root of the frame tree.
478 BrowserAccessibilityManager* GetRootBrowserAccessibilityManager();
479
522 protected: 480 protected:
523 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE; 481 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE;
524 482
525 // Create a LatencyInfo struct with INPUT_EVENT_LATENCY_RWH_COMPONENT 483 // Create a LatencyInfo struct with INPUT_EVENT_LATENCY_RWH_COMPONENT
526 // component if it is not already in |original|. And if |original| is 484 // component if it is not already in |original|. And if |original| is
527 // not NULL, it is also merged into the resulting LatencyInfo. 485 // not NULL, it is also merged into the resulting LatencyInfo.
528 ui::LatencyInfo CreateRWHLatencyInfoIfNotExist( 486 ui::LatencyInfo CreateRWHLatencyInfoIfNotExist(
529 const ui::LatencyInfo* original, blink::WebInputEvent::Type type); 487 const ui::LatencyInfo* original, blink::WebInputEvent::Type type);
530 488
531 // Called when we receive a notification indicating that the renderer 489 // Called when we receive a notification indicating that the renderer
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 virtual void OnUnexpectedEventAck(UnexpectedEventAckType type) OVERRIDE; 656 virtual void OnUnexpectedEventAck(UnexpectedEventAckType type) OVERRIDE;
699 657
700 void OnSyntheticGestureCompleted(SyntheticGesture::Result result); 658 void OnSyntheticGestureCompleted(SyntheticGesture::Result result);
701 659
702 // Called when there is a new auto resize (using a post to avoid a stack 660 // Called when there is a new auto resize (using a post to avoid a stack
703 // which may get in recursive loops). 661 // which may get in recursive loops).
704 void DelayedAutoResized(); 662 void DelayedAutoResized();
705 663
706 void WindowSnapshotReachedScreen(int snapshot_id); 664 void WindowSnapshotReachedScreen(int snapshot_id);
707 665
708 // Send a message to the renderer process to change the accessibility mode.
709 void SetAccessibilityMode(AccessibilityMode AccessibilityMode);
710
711 // Our delegate, which wants to know mainly about keyboard events. 666 // Our delegate, which wants to know mainly about keyboard events.
712 // It will remain non-NULL until DetachDelegate() is called. 667 // It will remain non-NULL until DetachDelegate() is called.
713 RenderWidgetHostDelegate* delegate_; 668 RenderWidgetHostDelegate* delegate_;
714 669
715 // Created during construction but initialized during Init*(). Therefore, it 670 // Created during construction but initialized during Init*(). Therefore, it
716 // is guaranteed never to be NULL, but its channel may be NULL if the 671 // is guaranteed never to be NULL, but its channel may be NULL if the
717 // renderer crashed, so you must always check that. 672 // renderer crashed, so you must always check that.
718 RenderProcessHost* process_; 673 RenderProcessHost* process_;
719 674
720 // The ID of the corresponding object in the Renderer Instance. 675 // The ID of the corresponding object in the Renderer Instance.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 gfx::Size new_auto_size_; 727 gfx::Size new_auto_size_;
773 728
774 // True if the render widget host should track the render widget's size as 729 // True if the render widget host should track the render widget's size as
775 // opposed to visa versa. 730 // opposed to visa versa.
776 bool should_auto_resize_; 731 bool should_auto_resize_;
777 732
778 bool waiting_for_screen_rects_ack_; 733 bool waiting_for_screen_rects_ack_;
779 gfx::Rect last_view_screen_rect_; 734 gfx::Rect last_view_screen_rect_;
780 gfx::Rect last_window_screen_rect_; 735 gfx::Rect last_window_screen_rect_;
781 736
782 AccessibilityMode accessibility_mode_;
783
784 // Keyboard event listeners. 737 // Keyboard event listeners.
785 std::vector<KeyPressEventCallback> key_press_event_callbacks_; 738 std::vector<KeyPressEventCallback> key_press_event_callbacks_;
786 739
787 // Mouse event callbacks. 740 // Mouse event callbacks.
788 std::vector<MouseEventCallback> mouse_event_callbacks_; 741 std::vector<MouseEventCallback> mouse_event_callbacks_;
789 742
790 // If true, then we should repaint when restoring even if we have a 743 // If true, then we should repaint when restoring even if we have a
791 // backingstore. This flag is set to true if we receive a paint message 744 // backingstore. This flag is set to true if we receive a paint message
792 // while is_hidden_ to true. Even though we tell the render widget to hide 745 // while is_hidden_ to true. Even though we tell the render widget to hide
793 // itself, a paint message could already be in flight at that point. 746 // itself, a paint message could already be in flight at that point.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 #endif 826 #endif
874 827
875 int64 last_input_number_; 828 int64 last_input_number_;
876 829
877 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); 830 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl);
878 }; 831 };
879 832
880 } // namespace content 833 } // namespace content
881 834
882 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ 835 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698