OLD | NEW |
---|---|
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_RENDERER_RENDER_WIDGET_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ |
6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ | 6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <map> | 12 #include <map> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
23 #include "content/common/cursors/webcursor.h" | 23 #include "content/common/cursors/webcursor.h" |
24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
25 #include "content/common/input/synthetic_gesture_params.h" | 25 #include "content/common/input/synthetic_gesture_params.h" |
26 #include "content/renderer/gpu/render_widget_compositor_delegate.h" | |
26 #include "content/renderer/input/render_widget_input_handler.h" | 27 #include "content/renderer/input/render_widget_input_handler.h" |
27 #include "content/renderer/input/render_widget_input_handler_delegate.h" | 28 #include "content/renderer/input/render_widget_input_handler_delegate.h" |
28 #include "content/renderer/message_delivery_policy.h" | 29 #include "content/renderer/message_delivery_policy.h" |
29 #include "ipc/ipc_listener.h" | 30 #include "ipc/ipc_listener.h" |
30 #include "ipc/ipc_sender.h" | 31 #include "ipc/ipc_sender.h" |
31 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 32 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
32 #include "third_party/WebKit/public/platform/WebRect.h" | 33 #include "third_party/WebKit/public/platform/WebRect.h" |
33 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 34 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
34 #include "third_party/WebKit/public/web/WebInputEvent.h" | 35 #include "third_party/WebKit/public/web/WebInputEvent.h" |
35 #include "third_party/WebKit/public/web/WebPopupType.h" | 36 #include "third_party/WebKit/public/web/WebPopupType.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 // | 97 // |
97 // RenderWidget is used to implement: | 98 // RenderWidget is used to implement: |
98 // - RenderViewImpl (deprecated) | 99 // - RenderViewImpl (deprecated) |
99 // - Fullscreen mode (RenderWidgetFullScreen) | 100 // - Fullscreen mode (RenderWidgetFullScreen) |
100 // - Popup "menus" (like the color chooser and date picker) | 101 // - Popup "menus" (like the color chooser and date picker) |
101 // - Widgets for frames (for out-of-process iframe support) | 102 // - Widgets for frames (for out-of-process iframe support) |
102 class CONTENT_EXPORT RenderWidget | 103 class CONTENT_EXPORT RenderWidget |
103 : public IPC::Listener, | 104 : public IPC::Listener, |
104 public IPC::Sender, | 105 public IPC::Sender, |
105 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), | 106 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), |
107 public RenderWidgetCompositorDelegate, | |
106 public RenderWidgetInputHandlerDelegate, | 108 public RenderWidgetInputHandlerDelegate, |
107 public base::RefCounted<RenderWidget> { | 109 public base::RefCounted<RenderWidget> { |
108 public: | 110 public: |
109 // Creates a new RenderWidget. The opener_id is the routing ID of the | 111 // Creates a new RenderWidget. The opener_id is the routing ID of the |
110 // RenderView that this widget lives inside. | 112 // RenderView that this widget lives inside. |
111 static RenderWidget* Create(int32_t opener_id, | 113 static RenderWidget* Create(int32_t opener_id, |
112 CompositorDependencies* compositor_deps, | 114 CompositorDependencies* compositor_deps, |
113 blink::WebPopupType popup_type, | 115 blink::WebPopupType popup_type, |
114 const blink::WebScreenInfo& screen_info); | 116 const blink::WebScreenInfo& screen_info); |
115 | 117 |
(...skipping 14 matching lines...) Expand all Loading... | |
130 | 132 |
131 CompositorDependencies* compositor_deps() const { return compositor_deps_; } | 133 CompositorDependencies* compositor_deps() const { return compositor_deps_; } |
132 blink::WebWidget* webwidget() const { return webwidget_; } | 134 blink::WebWidget* webwidget() const { return webwidget_; } |
133 gfx::Size size() const { return size_; } | 135 gfx::Size size() const { return size_; } |
134 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } | 136 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } |
135 blink::WebDisplayMode display_mode() const { return display_mode_; } | 137 blink::WebDisplayMode display_mode() const { return display_mode_; } |
136 bool is_hidden() const { return is_hidden_; } | 138 bool is_hidden() const { return is_hidden_; } |
137 // Temporary for debugging purposes... | 139 // Temporary for debugging purposes... |
138 bool closing() const { return closing_; } | 140 bool closing() const { return closing_; } |
139 bool is_swapped_out() { return is_swapped_out_; } | 141 bool is_swapped_out() { return is_swapped_out_; } |
140 bool for_oopif() { return for_oopif_; } | |
141 bool has_host_context_menu_location() { | 142 bool has_host_context_menu_location() { |
142 return has_host_context_menu_location_; | 143 return has_host_context_menu_location_; |
143 } | 144 } |
144 gfx::Point host_context_menu_location() { | 145 gfx::Point host_context_menu_location() { |
145 return host_context_menu_location_; | 146 return host_context_menu_location_; |
146 } | 147 } |
147 | 148 |
148 // ScreenInfo exposed so it can be passed to subframe RenderWidgets. | 149 // ScreenInfo exposed so it can be passed to subframe RenderWidgets. |
149 blink::WebScreenInfo screen_info() const { return screen_info_; } | 150 blink::WebScreenInfo screen_info() const { return screen_info_; } |
150 | 151 |
(...skipping 10 matching lines...) Expand all Loading... | |
161 void RegisterVideoHoleFrame(RenderFrameImpl* frame); | 162 void RegisterVideoHoleFrame(RenderFrameImpl* frame); |
162 void UnregisterVideoHoleFrame(RenderFrameImpl* frame); | 163 void UnregisterVideoHoleFrame(RenderFrameImpl* frame); |
163 #endif // defined(VIDEO_HOLE) | 164 #endif // defined(VIDEO_HOLE) |
164 | 165 |
165 // IPC::Listener | 166 // IPC::Listener |
166 bool OnMessageReceived(const IPC::Message& msg) override; | 167 bool OnMessageReceived(const IPC::Message& msg) override; |
167 | 168 |
168 // IPC::Sender | 169 // IPC::Sender |
169 bool Send(IPC::Message* msg) override; | 170 bool Send(IPC::Message* msg) override; |
170 | 171 |
172 // RenderWidgetCompositorDelegate | |
173 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | |
174 const gfx::Vector2dF& outer_delta, | |
175 const gfx::Vector2dF& elastic_overscroll_delta, | |
176 float page_scale, | |
177 float top_controls_delta) override; | |
178 void BeginMainFrame(double frame_time_sec) override; | |
179 scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) override; | |
180 scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource() override; | |
181 void DidCommitAndDrawCompositorFrame() override; | |
182 void DidCommitCompositorFrame() override; | |
183 void DidCompletePageScaleAnimation() override; | |
184 void DidCompleteSwapBuffers() override; | |
185 bool ForOOPIF() const override; | |
186 void ForwardCompositorProto(const std::vector<uint8_t>& proto) override; | |
187 void OnSwapBuffersAborted() override; | |
188 void OnSwapBuffersComplete() override; | |
189 void OnSwapBuffersPosted() override; | |
190 void RecordFrameTimingEvents( | |
191 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, | |
192 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) | |
193 override; | |
194 void ScheduleAnimation() override; | |
195 void WillBeginCompositorFrame() override; | |
196 | |
171 // RenderWidgetInputHandlerDelegate | 197 // RenderWidgetInputHandlerDelegate |
172 void FocusChangeComplete() override; | 198 void FocusChangeComplete() override; |
173 bool HasTouchEventHandlersAt(const gfx::Point& point) const override; | 199 bool HasTouchEventHandlersAt(const gfx::Point& point) const override; |
174 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event, | 200 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event, |
175 const gfx::Vector2dF& wheel_unused_delta, | 201 const gfx::Vector2dF& wheel_unused_delta, |
176 bool event_processed) override; | 202 bool event_processed) override; |
177 void OnDidHandleKeyEvent() override; | 203 void OnDidHandleKeyEvent() override; |
178 void OnDidOverscroll(const DidOverscrollParams& params) override; | 204 void OnDidOverscroll(const DidOverscrollParams& params) override; |
179 void OnInputEventAck(scoped_ptr<InputEventAck> input_event_ack) override; | 205 void OnInputEventAck(scoped_ptr<InputEventAck> input_event_ack) override; |
180 void SetInputHandler(RenderWidgetInputHandler* input_handler) override; | 206 void SetInputHandler(RenderWidgetInputHandler* input_handler) override; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 | 275 |
250 // When paused in debugger, we send ack for mouse event early. This ensures | 276 // When paused in debugger, we send ack for mouse event early. This ensures |
251 // that we continue receiving mouse moves and pass them to debugger. Returns | 277 // that we continue receiving mouse moves and pass them to debugger. Returns |
252 // whether we are paused in mouse move event and have sent the ack. | 278 // whether we are paused in mouse move event and have sent the ack. |
253 bool SendAckForMouseMoveFromDebugger(); | 279 bool SendAckForMouseMoveFromDebugger(); |
254 | 280 |
255 // When resumed from pause in debugger while handling mouse move, | 281 // When resumed from pause in debugger while handling mouse move, |
256 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger). | 282 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger). |
257 void IgnoreAckForMouseMoveFromDebugger(); | 283 void IgnoreAckForMouseMoveFromDebugger(); |
258 | 284 |
259 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback); | |
260 | |
261 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll). | 285 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll). |
262 typedef base::Callback<void()> SyntheticGestureCompletionCallback; | 286 typedef base::Callback<void()> SyntheticGestureCompletionCallback; |
263 | 287 |
264 // Send a synthetic gesture to the browser to be queued to the synthetic | 288 // Send a synthetic gesture to the browser to be queued to the synthetic |
265 // gesture controller. | 289 // gesture controller. |
266 void QueueSyntheticGesture( | 290 void QueueSyntheticGesture( |
267 scoped_ptr<SyntheticGestureParams> gesture_params, | 291 scoped_ptr<SyntheticGestureParams> gesture_params, |
268 const SyntheticGestureCompletionCallback& callback); | 292 const SyntheticGestureCompletionCallback& callback); |
269 | 293 |
270 // Deliveres |message| together with compositor state change updates. The | 294 // Deliveres |message| together with compositor state change updates. The |
271 // exact behavior depends on |policy|. | 295 // exact behavior depends on |policy|. |
272 // This mechanism is not a drop-in replacement for IPC: messages sent this way | 296 // This mechanism is not a drop-in replacement for IPC: messages sent this way |
273 // will not be automatically available to BrowserMessageFilter, for example. | 297 // will not be automatically available to BrowserMessageFilter, for example. |
274 // FIFO ordering is preserved between messages enqueued with the same | 298 // FIFO ordering is preserved between messages enqueued with the same |
275 // |policy|, the ordering between messages enqueued for different policies is | 299 // |policy|, the ordering between messages enqueued for different policies is |
276 // undefined. | 300 // undefined. |
277 // | 301 // |
278 // |msg| message to send, ownership of |msg| is transferred. | 302 // |msg| message to send, ownership of |msg| is transferred. |
279 // |policy| see the comment on MessageDeliveryPolicy. | 303 // |policy| see the comment on MessageDeliveryPolicy. |
280 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy); | 304 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy); |
281 | 305 |
282 // Handle start and finish of IME event guard. | 306 // Handle start and finish of IME event guard. |
283 void OnImeEventGuardStart(ImeEventGuard* guard); | 307 void OnImeEventGuardStart(ImeEventGuard* guard); |
284 void OnImeEventGuardFinish(ImeEventGuard* guard); | 308 void OnImeEventGuardFinish(ImeEventGuard* guard); |
285 | 309 |
286 // Returns whether we currently should handle an IME event. | 310 // Returns whether we currently should handle an IME event. |
287 bool ShouldHandleImeEvent(); | 311 bool ShouldHandleImeEvent(); |
288 | 312 |
289 // Called by the compositor when page scale animation completed. | |
290 virtual void DidCompletePageScaleAnimation() {} | |
291 | |
292 // ScreenMetricsEmulator class manages screen emulation inside a render | 313 // ScreenMetricsEmulator class manages screen emulation inside a render |
293 // widget. This includes resizing, placing view on the screen at desired | 314 // widget. This includes resizing, placing view on the screen at desired |
294 // position, changing device scale factor, and scaling down the whole | 315 // position, changing device scale factor, and scaling down the whole |
295 // widget if required to fit into the browser window. | 316 // widget if required to fit into the browser window. |
296 class ScreenMetricsEmulator; | 317 class ScreenMetricsEmulator; |
297 | 318 |
298 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator); | 319 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator); |
299 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor); | 320 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor); |
300 | 321 |
301 // Indicates that the compositor is about to begin a frame. This is primarily | |
302 // to signal to flow control mechanisms that a frame is beginning, not to | |
303 // perform actual painting work. | |
304 void WillBeginCompositorFrame(); | |
305 | |
306 // Notifies about a compositor frame commit operation having finished. | |
307 virtual void DidCommitCompositorFrame(); | |
308 | |
309 // Notifies that the draw commands for a committed frame have been issued. | |
310 void DidCommitAndDrawCompositorFrame(); | |
311 | |
312 // Notifies that the compositor has posted a swapbuffers operation to the GPU | |
313 // process. | |
314 void DidCompleteSwapBuffers(); | |
315 | 322 |
316 void ScheduleComposite(); | 323 void ScheduleComposite(); |
317 void ScheduleCompositeWithForcedRedraw(); | 324 void ScheduleCompositeWithForcedRedraw(); |
318 | 325 |
319 // Called by the compositor in single-threaded mode when a swap is posted, | |
320 // completes or is aborted. | |
321 void OnSwapBuffersPosted(); | |
322 void OnSwapBuffersComplete(); | |
323 void OnSwapBuffersAborted(); | |
324 | |
325 // Checks if the selection bounds have been changed. If they are changed, | 326 // Checks if the selection bounds have been changed. If they are changed, |
326 // the new value will be sent to the browser process. | 327 // the new value will be sent to the browser process. |
327 void UpdateSelectionBounds(); | 328 void UpdateSelectionBounds(); |
328 | 329 |
329 // Called by the compositor to forward a proto that represents serialized | 330 // Called by the compositor to forward a proto that represents serialized |
330 // compositor state. | 331 // compositor state. |
331 void ForwardCompositorProto(const std::vector<uint8_t>& proto); | |
332 | 332 |
333 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); | 333 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); |
334 | 334 |
335 void OnShowHostContextMenu(ContextMenuParams* params); | 335 void OnShowHostContextMenu(ContextMenuParams* params); |
336 | 336 |
337 // Checks if the composition range or composition character bounds have been | 337 // Checks if the composition range or composition character bounds have been |
338 // changed. If they are changed, the new value will be sent to the browser | 338 // changed. If they are changed, the new value will be sent to the browser |
339 // process. This method does nothing when the browser process is not able to | 339 // process. This method does nothing when the browser process is not able to |
340 // handle composition range and composition character bounds. | 340 // handle composition range and composition character bounds. |
341 void UpdateCompositionInfo(bool should_update_range); | 341 void UpdateCompositionInfo(bool should_update_range); |
342 | 342 |
343 bool host_closing() const { return host_closing_; } | 343 bool host_closing() const { return host_closing_; } |
piman
2016/01/13 22:09:30
nit: I think this can now be made private.
Fady Samuel
2016/01/13 23:48:13
Done.
| |
344 | 344 |
345 protected: | 345 protected: |
346 // Friend RefCounted so that the dtor can be non-public. Using this class | 346 // Friend RefCounted so that the dtor can be non-public. Using this class |
347 // without ref-counting is an error. | 347 // without ref-counting is an error. |
348 friend class base::RefCounted<RenderWidget>; | 348 friend class base::RefCounted<RenderWidget>; |
349 | 349 |
350 // For unit tests. | 350 // For unit tests. |
351 friend class RenderWidgetTest; | 351 friend class RenderWidgetTest; |
352 | 352 |
353 enum ResizeAck { | 353 enum ResizeAck { |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 | 754 |
755 scoped_ptr<scheduler::RenderWidgetSchedulingState> | 755 scoped_ptr<scheduler::RenderWidgetSchedulingState> |
756 render_widget_scheduling_state_; | 756 render_widget_scheduling_state_; |
757 | 757 |
758 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 758 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
759 }; | 759 }; |
760 | 760 |
761 } // namespace content | 761 } // namespace content |
762 | 762 |
763 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 763 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
OLD | NEW |