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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host.h

Issue 6532073: Move core pieces of browser\renderer_host to src\content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <deque> 9 // TODO(jam): remove this file when all files have been converted.
10 #include <string> 10 #include "content/browser/renderer_host/render_widget_host.h"
11 #include <vector>
12
13 #include "app/surface/transport_dib.h"
14 #include "base/gtest_prod_util.h"
15 #include "base/process_util.h"
16 #include "base/scoped_ptr.h"
17 #include "base/string16.h"
18 #include "base/timer.h"
19 #include "chrome/common/edit_command.h"
20 #include "chrome/common/native_web_keyboard_event.h"
21 #include "chrome/common/property_bag.h"
22 #include "ipc/ipc_channel.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h"
26 #include "ui/gfx/native_widget_types.h"
27 #include "ui/gfx/rect.h"
28 #include "ui/gfx/size.h"
29
30 namespace gfx {
31 class Rect;
32 }
33
34 namespace WebKit {
35 class WebInputEvent;
36 class WebMouseEvent;
37 struct WebCompositionUnderline;
38 struct WebScreenInfo;
39 }
40
41 class BackingStore;
42 class PaintObserver;
43 class RenderProcessHost;
44 class RenderWidgetHostView;
45 class TransportDIB;
46 class WebCursor;
47 struct ViewHostMsg_UpdateRect_Params;
48
49 // This class manages the browser side of a browser<->renderer HWND connection.
50 // The HWND lives in the browser process, and windows events are sent over
51 // IPC to the corresponding object in the renderer. The renderer paints into
52 // shared memory, which we transfer to a backing store and blit to the screen
53 // when Windows sends us a WM_PAINT message.
54 //
55 // How Shutdown Works
56 //
57 // There are two situations in which this object, a RenderWidgetHost, can be
58 // instantiated:
59 //
60 // 1. By a TabContents as the communication conduit for a rendered web page.
61 // The TabContents instantiates a derived class: RenderViewHost.
62 // 2. By a TabContents as the communication conduit for a select widget. The
63 // TabContents instantiates the RenderWidgetHost directly.
64 //
65 // For every TabContents there are several objects in play that need to be
66 // properly destroyed or cleaned up when certain events occur.
67 //
68 // - TabContents - the TabContents itself, and its associated HWND.
69 // - RenderViewHost - representing the communication conduit with the child
70 // process.
71 // - RenderWidgetHostView - the view of the web page content, message handler,
72 // and plugin root.
73 //
74 // Normally, the TabContents contains a child RenderWidgetHostView that renders
75 // the contents of the loaded page. It has a WS_CLIPCHILDREN style so that it
76 // does no painting of its own.
77 //
78 // The lifetime of the RenderWidgetHostView is tied to the render process. If
79 // the render process dies, the RenderWidgetHostView goes away and all
80 // references to it must become NULL. If the TabContents finds itself without a
81 // RenderWidgetHostView, it paints Sad Tab instead.
82 //
83 // RenderViewHost (a RenderWidgetHost subclass) is the conduit used to
84 // communicate with the RenderView and is owned by the TabContents. If the
85 // render process crashes, the RenderViewHost remains and restarts the render
86 // process if needed to continue navigation.
87 //
88 // The TabContents is itself owned by the NavigationController in which it
89 // resides.
90 //
91 // Some examples of how shutdown works:
92 //
93 // When a tab is closed (either by the user, the web page calling window.close,
94 // etc) the TabStrip destroys the associated NavigationController, which calls
95 // Destroy on each TabContents it owns.
96 //
97 // For a TabContents, its Destroy method tells the RenderViewHost to
98 // shut down the render process and die.
99 //
100 // When the render process is destroyed it destroys the View: the
101 // RenderWidgetHostView, which destroys its HWND and deletes that object.
102 //
103 // For select popups, the situation is a little different. The RenderWidgetHost
104 // associated with the select popup owns the view and itself (is responsible
105 // for destroying itself when the view is closed). The TabContents's only
106 // responsibility is to select popups is to create them when it is told to. When
107 // the View is destroyed via an IPC message (for when WebCore destroys the
108 // popup, e.g. if the user selects one of the options), or because
109 // WM_CANCELMODE is received by the view, the View schedules the destruction of
110 // the render process. However in this case since there's no TabContents
111 // container, when the render process is destroyed, the RenderWidgetHost just
112 // deletes itself, which is safe because no one else should have any references
113 // to it (the TabContents does not).
114 //
115 // It should be noted that the RenderViewHost, not the RenderWidgetHost,
116 // handles IPC messages relating to the render process going away, since the
117 // way a RenderViewHost (TabContents) handles the process dying is different to
118 // the way a select popup does. As such the RenderWidgetHostView handles these
119 // messages for select popups. This placement is more out of convenience than
120 // anything else. When the view is live, these messages are forwarded to it by
121 // the RenderWidgetHost's IPC message map.
122 //
123 class RenderWidgetHost : public IPC::Channel::Listener,
124 public IPC::Channel::Sender {
125 public:
126 // Used as the details object for a
127 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification.
128 struct PaintAtSizeAckDetails {
129 // The tag that was passed to the PaintAtSize() call that triggered this
130 // ack.
131 int tag;
132 gfx::Size size;
133 };
134
135 // routing_id can be MSG_ROUTING_NONE, in which case the next available
136 // routing id is taken from the RenderProcessHost.
137 RenderWidgetHost(RenderProcessHost* process, int routing_id);
138 virtual ~RenderWidgetHost();
139
140 // Gets/Sets the View of this RenderWidgetHost. Can be NULL, e.g. if the
141 // RenderWidget is being destroyed or the render process crashed. You should
142 // never cache this pointer since it can become NULL if the renderer crashes,
143 // instead you should always ask for it using the accessor.
144 void set_view(RenderWidgetHostView* view) { view_ = view; }
145 RenderWidgetHostView* view() const { return view_; }
146
147 RenderProcessHost* process() const { return process_; }
148 int routing_id() const { return routing_id_; }
149 bool renderer_accessible() { return renderer_accessible_; }
150
151 // Returns the property bag for this widget, where callers can add extra data
152 // they may wish to associate with it. Returns a pointer rather than a
153 // reference since the PropertyAccessors expect this.
154 const PropertyBag* property_bag() const { return &property_bag_; }
155 PropertyBag* property_bag() { return &property_bag_; }
156
157 // Called when a renderer object already been created for this host, and we
158 // just need to be attached to it. Used for window.open, <select> dropdown
159 // menus, and other times when the renderer initiates creating an object.
160 void Init();
161
162 // Tells the renderer to die and then calls Destroy().
163 virtual void Shutdown();
164
165 // Manual RTTI FTW. We are not hosting a web page.
166 virtual bool IsRenderView() const;
167
168 // IPC::Channel::Listener
169 virtual bool OnMessageReceived(const IPC::Message& msg);
170
171 // Sends a message to the corresponding object in the renderer.
172 virtual bool Send(IPC::Message* msg);
173
174 // Called to notify the RenderWidget that it has been hidden or restored from
175 // having been hidden.
176 void WasHidden();
177 void WasRestored();
178
179 // Called to notify the RenderWidget that it has been resized.
180 void WasResized();
181
182 // Called to notify the RenderWidget that its associated native window got
183 // focused.
184 virtual void GotFocus();
185
186 // Tells the renderer it got/lost focus.
187 void Focus();
188 void Blur();
189 virtual void LostCapture();
190
191 // Tells us whether the page is rendered directly via the GPU process.
192 bool is_accelerated_compositing_active() {
193 return is_accelerated_compositing_active_;
194 }
195
196 // Notifies the RenderWidgetHost that the View was destroyed.
197 void ViewDestroyed();
198
199 // Indicates if the page has finished loading.
200 void SetIsLoading(bool is_loading);
201
202 // This tells the renderer to paint into a bitmap and return it,
203 // regardless of whether the tab is hidden or not. It resizes the
204 // web widget to match the |page_size| and then returns the bitmap
205 // scaled so it matches the |desired_size|, so that the scaling
206 // happens on the rendering thread. When the bitmap is ready, the
207 // renderer sends a PaintAtSizeACK to this host, and a
208 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification is issued.
209 // Note that this bypasses most of the update logic that is normally invoked,
210 // and doesn't put the results into the backing store.
211 void PaintAtSize(TransportDIB::Handle dib_handle,
212 int tag,
213 const gfx::Size& page_size,
214 const gfx::Size& desired_size);
215
216 // Get access to the widget's backing store. If a resize is in progress,
217 // then the current size of the backing store may be less than the size of
218 // the widget's view. If you pass |force_create| as true, then the backing
219 // store will be created if it doesn't exist. Otherwise, NULL will be returned
220 // if the backing store doesn't already exist. It will also return NULL if the
221 // backing store could not be created.
222 BackingStore* GetBackingStore(bool force_create);
223
224 // Allocate a new backing store of the given size. Returns NULL on failure
225 // (for example, if we don't currently have a RenderWidgetHostView.)
226 BackingStore* AllocBackingStore(const gfx::Size& size);
227
228 // When a backing store does asynchronous painting, it will call this function
229 // when it is done with the DIB. We will then forward a message to the
230 // renderer to send another paint.
231 void DonePaintingToBackingStore();
232
233 // GPU accelerated version of GetBackingStore function. This will
234 // trigger a re-composite to the view. If a resize is pending, it will
235 // block briefly waiting for an ack from the renderer.
236 void ScheduleComposite();
237
238 // Starts a hang monitor timeout. If there's already a hang monitor timeout
239 // the new one will only fire if it has a shorter delay than the time
240 // left on the existing timeouts.
241 void StartHangMonitorTimeout(base::TimeDelta delay);
242
243 // Restart the active hang monitor timeout. Clears all existing timeouts and
244 // starts with a new one. This can be because the renderer has become
245 // active, the tab is being hidden, or the user has chosen to wait some more
246 // to give the tab a chance to become active and we don't want to display a
247 // warning too soon.
248 void RestartHangMonitorTimeout();
249
250 // Stops all existing hang monitor timeouts and assumes the renderer is
251 // responsive.
252 void StopHangMonitorTimeout();
253
254 // Called when the system theme changes. At this time all existing native
255 // theme handles are invalid and the renderer must obtain new ones and
256 // repaint.
257 void SystemThemeChanged();
258
259 // Forwards the given message to the renderer. These are called by the view
260 // when it has received a message.
261 virtual void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event);
262 // Called when a mouse click activates the renderer.
263 virtual void OnMouseActivate();
264 void ForwardWheelEvent(const WebKit::WebMouseWheelEvent& wheel_event);
265 virtual void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event);
266 virtual void ForwardEditCommand(const std::string& name,
267 const std::string& value);
268 virtual void ForwardEditCommandsForNextKeyEvent(
269 const EditCommands& edit_commands);
270 #if defined(TOUCH_UI)
271 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event);
272 #endif
273
274
275 // Update the text direction of the focused input element and notify it to a
276 // renderer process.
277 // These functions have two usage scenarios: changing the text direction
278 // from a menu (as Safari does), and; changing the text direction when a user
279 // presses a set of keys (as IE and Firefox do).
280 // 1. Change the text direction from a menu.
281 // In this scenario, we receive a menu event only once and we should update
282 // the text direction immediately when a user chooses a menu item. So, we
283 // should call both functions at once as listed in the following snippet.
284 // void RenderViewHost::SetTextDirection(WebTextDirection direction) {
285 // UpdateTextDirection(direction);
286 // NotifyTextDirection();
287 // }
288 // 2. Change the text direction when pressing a set of keys.
289 // Because of auto-repeat, we may receive the same key-press event many
290 // times while we presses the keys and it is nonsense to send the same IPC
291 // message every time when we receive a key-press event.
292 // To suppress the number of IPC messages, we just update the text direction
293 // when receiving a key-press event and send an IPC message when we release
294 // the keys as listed in the following snippet.
295 // if (key_event.type == WebKeyboardEvent::KEY_DOWN) {
296 // if (key_event.windows_key_code == 'A' &&
297 // key_event.modifiers == WebKeyboardEvent::CTRL_KEY) {
298 // UpdateTextDirection(dir);
299 // } else {
300 // CancelUpdateTextDirection();
301 // }
302 // } else if (key_event.type == WebKeyboardEvent::KEY_UP) {
303 // NotifyTextDirection();
304 // }
305 // Once we cancel updating the text direction, we have to ignore all
306 // succeeding UpdateTextDirection() requests until calling
307 // NotifyTextDirection(). (We may receive keydown events even after we
308 // canceled updating the text direction because of auto-repeat.)
309 // Note: we cannot undo this change for compatibility with Firefox and IE.
310 void UpdateTextDirection(WebKit::WebTextDirection direction);
311 void CancelUpdateTextDirection();
312 void NotifyTextDirection();
313
314 // Notifies the renderer whether or not the input method attached to this
315 // process is activated.
316 // When the input method is activated, a renderer process sends IPC messages
317 // to notify the status of its composition node. (This message is mainly used
318 // for notifying the position of the input cursor so that the browser can
319 // display input method windows under the cursor.)
320 void SetInputMethodActive(bool activate);
321
322 // Update the composition node of the renderer (or WebKit).
323 // WebKit has a special node (a composition node) for input method to change
324 // its text without affecting any other DOM nodes. When the input method
325 // (attached to the browser) updates its text, the browser sends IPC messages
326 // to update the composition node of the renderer.
327 // (Read the comments of each function for its detail.)
328
329 // Sets the text of the composition node.
330 // This function can also update the cursor position and mark the specified
331 // range in the composition node.
332 // A browser should call this function:
333 // * when it receives a WM_IME_COMPOSITION message with a GCS_COMPSTR flag
334 // (on Windows);
335 // * when it receives a "preedit_changed" signal of GtkIMContext (on Linux);
336 // * when markedText of NSTextInput is called (on Mac).
337 void ImeSetComposition(
338 const string16& text,
339 const std::vector<WebKit::WebCompositionUnderline>& underlines,
340 int selection_start,
341 int selection_end);
342
343 // Finishes an ongoing composition with the specified text.
344 // A browser should call this function:
345 // * when it receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR flag
346 // (on Windows);
347 // * when it receives a "commit" signal of GtkIMContext (on Linux);
348 // * when insertText of NSTextInput is called (on Mac).
349 void ImeConfirmComposition(const string16& text);
350
351 // Finishes an ongoing composition with the composition text set by last
352 // SetComposition() call.
353 void ImeConfirmComposition();
354
355 // Cancels an ongoing composition.
356 void ImeCancelComposition();
357
358 // Makes an IPC call to toggle the spelling panel.
359 void ToggleSpellPanel(bool is_currently_visible);
360
361 // Makes an IPC call to tell webkit to replace the currently selected word
362 // or a word around the cursor.
363 void Replace(const string16& word);
364
365 // Makes an IPC call to tell webkit to advance to the next misspelling.
366 void AdvanceToNextMisspelling();
367
368 // Enable renderer accessibility. This should only be called when a
369 // screenreader is detected.
370 void EnableRendererAccessibility();
371
372 // Relays a request from assistive technology to set focus to the
373 // node with this accessibility object id.
374 void SetAccessibilityFocus(int acc_obj_id);
375
376 // Relays a request from assistive technology to perform the default action
377 // on a node with this accessibility object id.
378 void AccessibilityDoDefaultAction(int acc_obj_id);
379
380 // Acknowledges a ViewHostMsg_AccessibilityNotifications message.
381 void AccessibilityNotificationsAck();
382
383 // Sets the active state (i.e., control tints).
384 virtual void SetActive(bool active);
385
386 void set_ignore_input_events(bool ignore_input_events) {
387 ignore_input_events_ = ignore_input_events;
388 }
389 bool ignore_input_events() const {
390 return ignore_input_events_;
391 }
392
393 // Activate deferred plugin handles.
394 void ActivateDeferredPluginHandles();
395
396 const gfx::Point& last_scroll_offset() const { return last_scroll_offset_; }
397
398 protected:
399 // Internal implementation of the public Forward*Event() methods.
400 void ForwardInputEvent(const WebKit::WebInputEvent& input_event,
401 int event_size, bool is_keyboard_shortcut);
402
403 // Called when we receive a notification indicating that the renderer
404 // process has gone. This will reset our state so that our state will be
405 // consistent if a new renderer is created.
406 void RendererExited(base::TerminationStatus status, int exit_code);
407
408 // Retrieves an id the renderer can use to refer to its view.
409 // This is used for various IPC messages, including plugins.
410 gfx::NativeViewId GetNativeViewId();
411
412 // Called to handled a keyboard event before sending it to the renderer.
413 // This is overridden by RenderView to send upwards to its delegate.
414 // Returns true if the event was handled, and then the keyboard event will
415 // not be sent to the renderer anymore. Otherwise, if the |event| would
416 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut,
417 // |*is_keyboard_shortcut| should be set to true.
418 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
419 bool* is_keyboard_shortcut);
420
421 // Called when a keyboard event was not processed by the renderer. This is
422 // overridden by RenderView to send upwards to its delegate.
423 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {}
424
425 // Notification that the user has made some kind of input that could
426 // perform an action. The render view host overrides this to forward the
427 // information to its delegate (see corresponding function in
428 // RenderViewHostDelegate). The gestures that count are 1) any mouse down
429 // event and 2) enter or space key presses.
430 virtual void OnUserGesture() {}
431
432 // Callbacks for notification when the renderer becomes unresponsive to user
433 // input events, and subsequently responsive again. RenderViewHost overrides
434 // these to tell its delegate to show the user a warning.
435 virtual void NotifyRendererUnresponsive() {}
436 virtual void NotifyRendererResponsive() {}
437
438 protected:
439 // true if a renderer has once been valid. We use this flag to display a sad
440 // tab only when we lose our renderer and not if a paint occurs during
441 // initialization.
442 bool renderer_initialized_;
443
444 private:
445 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, Resize);
446 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, ResizeThenCrash);
447 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, HiddenPaint);
448 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, PaintAtSize);
449
450 // Tell this object to destroy itself.
451 void Destroy();
452
453 // Checks whether the renderer is hung and calls NotifyRendererUnresponsive
454 // if it is.
455 void CheckRendererIsUnresponsive();
456
457 // Called if we know the renderer is responsive. When we currently think the
458 // renderer is unresponsive, this will clear that state and call
459 // NotifyRendererResponsive.
460 void RendererIsResponsive();
461
462 // IPC message handlers
463 void OnMsgRenderViewReady();
464 void OnMsgRenderViewGone(int status, int error_code);
465 void OnMsgClose();
466 void OnMsgRequestMove(const gfx::Rect& pos);
467 void OnMsgPaintAtSizeAck(int tag, const gfx::Size& size);
468 void OnMsgUpdateRect(const ViewHostMsg_UpdateRect_Params& params);
469 void OnMsgInputEventAck(const IPC::Message& message);
470 virtual void OnMsgFocus();
471 virtual void OnMsgBlur();
472
473 void OnMsgSetCursor(const WebCursor& cursor);
474 void OnMsgImeUpdateTextInputState(WebKit::WebTextInputType type,
475 const gfx::Rect& caret_rect);
476 void OnMsgImeCancelComposition();
477
478 void OnMsgDidActivateAcceleratedCompositing(bool activated);
479
480 #if defined(OS_MACOSX)
481 void OnMsgGetScreenInfo(gfx::NativeViewId view,
482 WebKit::WebScreenInfo* results);
483 void OnMsgGetWindowRect(gfx::NativeViewId window_id, gfx::Rect* results);
484 void OnMsgGetRootWindowRect(gfx::NativeViewId window_id, gfx::Rect* results);
485 void OnMsgPluginFocusChanged(bool focused, int plugin_id);
486 void OnMsgStartPluginIme();
487 void OnAllocateFakePluginWindowHandle(bool opaque,
488 bool root,
489 gfx::PluginWindowHandle* id);
490 void OnDestroyFakePluginWindowHandle(gfx::PluginWindowHandle id);
491 void OnAcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
492 int32 width,
493 int32 height,
494 uint64 mach_port);
495 void OnAcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
496 int32 width,
497 int32 height,
498 TransportDIB::Handle transport_dib);
499 void OnAcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
500 uint64 surface_id);
501 #elif defined(OS_POSIX)
502 void OnMsgCreatePluginContainer(gfx::PluginWindowHandle id);
503 void OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id);
504 #endif
505
506 // Paints the given bitmap to the current backing store at the given location.
507 void PaintBackingStoreRect(TransportDIB::Id bitmap,
508 const gfx::Rect& bitmap_rect,
509 const std::vector<gfx::Rect>& copy_rects,
510 const gfx::Size& view_size);
511
512 // Scrolls the given |clip_rect| in the backing by the given dx/dy amount. The
513 // |dib| and its corresponding location |bitmap_rect| in the backing store
514 // is the newly painted pixels by the renderer.
515 void ScrollBackingStoreRect(int dx, int dy, const gfx::Rect& clip_rect,
516 const gfx::Size& view_size);
517
518 // Called by OnMsgInputEventAck() to process a keyboard event ack message.
519 void ProcessKeyboardEventAck(int type, bool processed);
520
521 // Called by OnMsgInputEventAck() to process a wheel event ack message.
522 // This could result in a task being posted to allow additional wheel
523 // input messages to be coalesced.
524 void ProcessWheelAck();
525
526 // True if renderer accessibility is enabled. This should only be set when a
527 // screenreader is detected as it can potentially slow down Chrome.
528 bool renderer_accessible_;
529
530 // The View associated with the RenderViewHost. The lifetime of this object
531 // is associated with the lifetime of the Render process. If the Renderer
532 // crashes, its View is destroyed and this pointer becomes NULL, even though
533 // render_view_host_ lives on to load another URL (creating a new View while
534 // doing so).
535 RenderWidgetHostView* view_;
536
537 // Created during construction but initialized during Init*(). Therefore, it
538 // is guaranteed never to be NULL, but its channel may be NULL if the
539 // renderer crashed, so you must always check that.
540 RenderProcessHost* process_;
541
542 // Stores random bits of data for others to associate with this object.
543 PropertyBag property_bag_;
544
545 // The ID of the corresponding object in the Renderer Instance.
546 int routing_id_;
547
548 // Indicates whether a page is loading or not.
549 bool is_loading_;
550
551 // Indicates whether a page is hidden or not.
552 bool is_hidden_;
553
554 // True when a page is rendered directly via the GPU process.
555 bool is_accelerated_compositing_active_;
556
557 // Set if we are waiting for a repaint ack for the view.
558 bool repaint_ack_pending_;
559
560 // True when waiting for RESIZE_ACK.
561 bool resize_ack_pending_;
562
563 // The current size of the RenderWidget.
564 gfx::Size current_size_;
565
566 // The current reserved area of the RenderWidget where contents should not be
567 // rendered to draw the resize corner, sidebar mini tabs etc.
568 gfx::Rect current_reserved_rect_;
569
570 // The size we last sent as requested size to the renderer. |current_size_|
571 // is only updated once the resize message has been ack'd. This on the other
572 // hand is updated when the resize message is sent. This is very similar to
573 // |resize_ack_pending_|, but the latter is not set if the new size has width
574 // or height zero, which is why we need this too.
575 gfx::Size in_flight_size_;
576
577 // The reserved area we last sent to the renderer. |current_reserved_rect_|
578 // is only updated once the resize message has been ack'd. This on the other
579 // hand is updated when the resize message is sent.
580 gfx::Rect in_flight_reserved_rect_;
581
582 // True if a mouse move event was sent to the render view and we are waiting
583 // for a corresponding ViewHostMsg_HandleInputEvent_ACK message.
584 bool mouse_move_pending_;
585
586 // The next mouse move event to send (only non-null while mouse_move_pending_
587 // is true).
588 scoped_ptr<WebKit::WebMouseEvent> next_mouse_move_;
589
590 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent
591 // and we are waiting for a corresponding ack.
592 bool mouse_wheel_pending_;
593
594 typedef std::deque<WebKit::WebMouseWheelEvent> WheelEventQueue;
595
596 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send.
597 // Unlike mouse moves, mouse wheel events received while one is pending are
598 // coalesced (by accumulating deltas) if they match the previous event in
599 // modifiers. On the Mac, in particular, mouse wheel events are received at a
600 // high rate; not waiting for the ack results in jankiness, and using the same
601 // mechanism as for mouse moves (just dropping old events when multiple ones
602 // would be queued) results in very slow scrolling.
603 WheelEventQueue coalesced_mouse_wheel_events_;
604
605 // The time when an input event was sent to the RenderWidget.
606 base::TimeTicks input_event_start_time_;
607
608 // If true, then we should repaint when restoring even if we have a
609 // backingstore. This flag is set to true if we receive a paint message
610 // while is_hidden_ to true. Even though we tell the render widget to hide
611 // itself, a paint message could already be in flight at that point.
612 bool needs_repainting_on_restore_;
613
614 // This is true if the renderer is currently unresponsive.
615 bool is_unresponsive_;
616
617 // The following value indicates a time in the future when we would consider
618 // the renderer hung if it does not generate an appropriate response message.
619 base::Time time_when_considered_hung_;
620
621 // This timer runs to check if time_when_considered_hung_ has past.
622 base::OneShotTimer<RenderWidgetHost> hung_renderer_timer_;
623
624 // Flag to detect recursive calls to GetBackingStore().
625 bool in_get_backing_store_;
626
627 // Set when we call DidPaintRect/DidScrollRect on the view.
628 bool view_being_painted_;
629
630 // Used for UMA histogram logging to measure the time for a repaint view
631 // operation to finish.
632 base::TimeTicks repaint_start_time_;
633
634 // Queue of keyboard events that we need to track.
635 typedef std::deque<NativeWebKeyboardEvent> KeyQueue;
636
637 // A queue of keyboard events. We can't trust data from the renderer so we
638 // stuff key events into a queue and pop them out on ACK, feeding our copy
639 // back to whatever unhandled handler instead of the returned version.
640 KeyQueue key_queue_;
641
642 // Set to true if we shouldn't send input events from the render widget.
643 bool ignore_input_events_;
644
645 // Set when we update the text direction of the selected input element.
646 bool text_direction_updated_;
647 WebKit::WebTextDirection text_direction_;
648
649 // Set when we cancel updating the text direction.
650 // This flag also ignores succeeding update requests until we call
651 // NotifyTextDirection().
652 bool text_direction_canceled_;
653
654 // Indicates if the next sequence of Char events should be suppressed or not.
655 // System may translate a RawKeyDown event into zero or more Char events,
656 // usually we send them to the renderer directly in sequence. However, If a
657 // RawKeyDown event was not handled by the renderer but was handled by
658 // our UnhandledKeyboardEvent() method, e.g. as an accelerator key, then we
659 // shall not send the following sequence of Char events, which was generated
660 // by this RawKeyDown event, to the renderer. Otherwise the renderer may
661 // handle the Char events and cause unexpected behavior.
662 // For example, pressing alt-2 may let the browser switch to the second tab,
663 // but the Char event generated by alt-2 may also activate a HTML element
664 // if its accesskey happens to be "2", then the user may get confused when
665 // switching back to the original tab, because the content may already be
666 // changed.
667 bool suppress_next_char_events_;
668
669 std::vector<gfx::PluginWindowHandle> deferred_plugin_handles_;
670
671 // The last scroll offset of the render widget.
672 gfx::Point last_scroll_offset_;
673
674 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost);
675 };
676 11
677 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ 12 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698