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 3// found in the LICENSE file. 4 5#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ 6#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ 7 8#include <atlbase.h> 9#include <atlapp.h> 10#include <atlcrack.h> 11#include <atlmisc.h> 12#include <vector> 13 14#include "base/compiler_specific.h" 15#include "base/gtest_prod_util.h" 16#include "base/memory/scoped_ptr.h" 17#include "base/memory/scoped_vector.h" 18#include "base/memory/weak_ptr.h" 19#include "base/time/time.h" 20#include "base/win/scoped_comptr.h" 21#include "content/browser/accessibility/browser_accessibility_manager.h" 22#include "content/browser/renderer_host/render_widget_host_view_base.h" 23#include "content/common/content_export.h" 24#include "content/public/browser/notification_observer.h" 25#include "content/public/browser/notification_registrar.h" 26#include "ui/base/gestures/gesture_recognizer.h" 27#include "ui/base/gestures/gesture_types.h" 28#include "ui/base/ime/text_input_client.h" 29#include "ui/base/ime/win/tsf_bridge.h" 30#include "ui/base/win/extra_sdk_defines.h" 31#include "ui/gfx/native_widget_types.h" 32#include "ui/gfx/point.h" 33#include "ui/surface/accelerated_surface_win.h" 34#include "webkit/common/cursors/webcursor.h" 35 36class SkRegion; 37 38namespace gfx { 39class Size; 40class Rect; 41} 42 43namespace IPC { 44class Message; 45} 46 47namespace ui { 48class IMM32Manager; 49class ViewProp; 50} 51 52namespace WebKit { 53struct WebScreenInfo; 54} 55 56namespace content { 57class BackingStore; 58class RenderWidgetHost; 59class WebTouchState; 60 61typedef CWinTraits<WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> 62 RenderWidgetHostHWNDTraits; 63 64CONTENT_EXPORT extern const wchar_t kRenderWidgetHostHWNDClass[]; 65 66/////////////////////////////////////////////////////////////////////////////// 67// RenderWidgetHostViewWin 68// 69// An object representing the "View" of a rendered web page. This object is 70// responsible for displaying the content of the web page, receiving windows 71// messages, and containing plugins HWNDs. It is the implementation of the 72// RenderWidgetHostView that the cross-platform RenderWidgetHost object uses 73// to display the data. 74// 75// Comment excerpted from render_widget_host.h: 76// 77// "The lifetime of the RenderWidgetHostHWND is tied to the render process. 78// If the render process dies, the RenderWidgetHostHWND goes away and all 79// references to it must become NULL." 80// 81// RenderWidgetHostView class hierarchy described in render_widget_host_view.h. 82class RenderWidgetHostViewWin 83 : public CWindowImpl<RenderWidgetHostViewWin, 84 CWindow, 85 RenderWidgetHostHWNDTraits>, 86 public RenderWidgetHostViewBase, 87 public NotificationObserver, 88 public BrowserAccessibilityDelegate, 89 public ui::GestureConsumer, 90 public ui::GestureEventHelper, 91 public ui::TextInputClient { // for Win8/metro TSF support. 92 public: 93 virtual ~RenderWidgetHostViewWin(); 94 95 CONTENT_EXPORT void CreateWnd(HWND parent); 96 97 void AcceleratedPaint(HDC dc); 98 99 DECLARE_WND_CLASS_EX(kRenderWidgetHostHWNDClass, CS_DBLCLKS, 0); 100 101 BEGIN_MSG_MAP(RenderWidgetHostHWND) 102 MSG_WM_CREATE(OnCreate) 103 MSG_WM_ACTIVATE(OnActivate) 104 MSG_WM_DESTROY(OnDestroy) 105 MSG_WM_PAINT(OnPaint) 106 MSG_WM_NCPAINT(OnNCPaint) 107 MSG_WM_NCHITTEST(OnNCHitTest) 108 MSG_WM_ERASEBKGND(OnEraseBkgnd) 109 MSG_WM_SETCURSOR(OnSetCursor) 110 MSG_WM_SETFOCUS(OnSetFocus) 111 MSG_WM_KILLFOCUS(OnKillFocus) 112 MSG_WM_CAPTURECHANGED(OnCaptureChanged) 113 MSG_WM_CANCELMODE(OnCancelMode) 114 MSG_WM_INPUTLANGCHANGE(OnInputLangChange) 115 MSG_WM_THEMECHANGED(OnThemeChanged) 116 MSG_WM_NOTIFY(OnNotify) 117 MESSAGE_HANDLER(WM_IME_SETCONTEXT, OnImeSetContext) 118 MESSAGE_HANDLER(WM_IME_STARTCOMPOSITION, OnImeStartComposition) 119 MESSAGE_HANDLER(WM_IME_COMPOSITION, OnImeComposition) 120 MESSAGE_HANDLER(WM_IME_ENDCOMPOSITION, OnImeEndComposition) 121 MESSAGE_HANDLER(WM_IME_REQUEST, OnImeRequest) 122 MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseEvent) 123 MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseEvent) 124 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnMouseEvent) 125 MESSAGE_HANDLER(WM_MBUTTONDOWN, OnMouseEvent) 126 MESSAGE_HANDLER(WM_RBUTTONDOWN, OnMouseEvent) 127 MESSAGE_HANDLER(WM_LBUTTONUP, OnMouseEvent) 128 MESSAGE_HANDLER(WM_MBUTTONUP, OnMouseEvent) 129 MESSAGE_HANDLER(WM_RBUTTONUP, OnMouseEvent) 130 MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnMouseEvent) 131 MESSAGE_HANDLER(WM_MBUTTONDBLCLK, OnMouseEvent) 132 MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnMouseEvent) 133 MESSAGE_HANDLER(WM_SYSKEYDOWN, OnKeyEvent) 134 MESSAGE_HANDLER(WM_SYSKEYUP, OnKeyEvent) 135 MESSAGE_HANDLER(WM_KEYDOWN, OnKeyEvent) 136 MESSAGE_HANDLER(WM_KEYUP, OnKeyEvent) 137 MESSAGE_HANDLER(WM_MOUSEWHEEL, OnWheelEvent) 138 MESSAGE_HANDLER(WM_MOUSEHWHEEL, OnWheelEvent) 139 MESSAGE_HANDLER(WM_HSCROLL, OnWheelEvent) 140 MESSAGE_HANDLER(WM_VSCROLL, OnWheelEvent) 141 MESSAGE_HANDLER(WM_CHAR, OnKeyEvent) 142 MESSAGE_HANDLER(WM_SYSCHAR, OnKeyEvent) 143 MESSAGE_HANDLER(WM_TOUCH, OnTouchEvent) 144 MESSAGE_HANDLER(WM_IME_CHAR, OnKeyEvent) 145 MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) 146 MESSAGE_HANDLER(WM_GETOBJECT, OnGetObject) 147 MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) 148 MESSAGE_HANDLER(WM_GESTURE, OnGestureEvent) 149 MESSAGE_HANDLER(WM_MOVE, OnMoveOrSize) 150 MESSAGE_HANDLER(WM_SIZE, OnMoveOrSize) 151 MESSAGE_HANDLER(WM_WTSSESSION_CHANGE, OnSessionChange) 152 END_MSG_MAP() 153 154 // RenderWidgetHostView implementation. 155 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; 156 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; 157 virtual void SetSize(const gfx::Size& size) OVERRIDE; 158 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; 159 virtual gfx::NativeView GetNativeView() const OVERRIDE; 160 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; 161 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; 162 virtual bool HasFocus() const OVERRIDE; 163 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; 164 virtual void Show() OVERRIDE; 165 virtual void Hide() OVERRIDE; 166 virtual bool IsShowing() OVERRIDE; 167 virtual gfx::Rect GetViewBounds() const OVERRIDE; 168 virtual void SetBackground(const SkBitmap& background) OVERRIDE; 169 170 // Implementation of RenderWidgetHostViewPort. 171 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, 172 const gfx::Rect& pos) OVERRIDE; 173 virtual void InitAsFullscreen( 174 RenderWidgetHostView* reference_host_view) OVERRIDE; 175 virtual void WasShown() OVERRIDE; 176 virtual void WasHidden() OVERRIDE; 177 virtual void MovePluginWindows( 178 const gfx::Vector2d& scroll_offset, 179 const std::vector<WebPluginGeometry>& moves) OVERRIDE; 180 virtual void Focus() OVERRIDE; 181 virtual void Blur() OVERRIDE; 182 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; 183 virtual void SetIsLoading(bool is_loading) OVERRIDE; 184 virtual void TextInputTypeChanged(ui::TextInputType type, 185 bool can_compose_inline, 186 ui::TextInputMode input_mode) OVERRIDE; 187 virtual void SelectionBoundsChanged( 188 const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; 189 virtual void ScrollOffsetChanged() OVERRIDE; 190 virtual void ImeCancelComposition() OVERRIDE; 191 virtual void ImeCompositionRangeChanged( 192 const ui::Range& range, 193 const std::vector<gfx::Rect>& character_bounds) OVERRIDE; 194 virtual void DidUpdateBackingStore( 195 const gfx::Rect& scroll_rect, 196 const gfx::Vector2d& scroll_delta, 197 const std::vector<gfx::Rect>& copy_rects, 198 const ui::LatencyInfo& latency_info) OVERRIDE; 199 virtual void RenderProcessGone(base::TerminationStatus status, 200 int error_code) OVERRIDE; 201 virtual bool CanSubscribeFrame() const OVERRIDE; 202 203 // called by WebContentsImpl before DestroyWindow 204 virtual void WillWmDestroy() OVERRIDE; 205 virtual void Destroy() OVERRIDE; 206 virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; 207 virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; 208 virtual void CopyFromCompositingSurface( 209 const gfx::Rect& src_subrect, 210 const gfx::Size& dst_size, 211 const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE; 212 virtual void CopyFromCompositingSurfaceToVideoFrame( 213 const gfx::Rect& src_subrect, 214 const scoped_refptr<media::VideoFrame>& target, 215 const base::Callback<void(bool)>& callback) OVERRIDE; 216 virtual bool CanCopyToVideoFrame() const OVERRIDE; 217 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; 218 virtual void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch, 219 InputEventAckState ack_result) OVERRIDE; 220 virtual void SetHasHorizontalScrollbar( 221 bool has_horizontal_scrollbar) OVERRIDE; 222 virtual void SetScrollOffsetPinning( 223 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; 224 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; 225 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; 226 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; 227 virtual void AcceleratedSurfaceBuffersSwapped( 228 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 229 int gpu_host_id) OVERRIDE; 230 virtual void AcceleratedSurfacePostSubBuffer( 231 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 232 int gpu_host_id) OVERRIDE; 233 virtual void AcceleratedSurfaceSuspend() OVERRIDE; 234 virtual void AcceleratedSurfaceRelease() OVERRIDE; 235 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; 236 virtual void OnAccessibilityNotifications( 237 const std::vector<AccessibilityHostMsg_NotificationParams>& params 238 ) OVERRIDE; 239 virtual bool LockMouse() OVERRIDE; 240 virtual void UnlockMouse() OVERRIDE; 241 virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE; 242 243 // Implementation of NotificationObserver: 244 virtual void Observe(int type, 245 const NotificationSource& source, 246 const NotificationDetails& details) OVERRIDE; 247 248 // Implementation of BrowserAccessibilityDelegate: 249 virtual void SetAccessibilityFocus(int acc_obj_id) OVERRIDE; 250 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; 251 virtual void AccessibilityScrollToMakeVisible( 252 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; 253 virtual void AccessibilityScrollToPoint( 254 int acc_obj_id, gfx::Point point) OVERRIDE; 255 virtual void AccessibilitySetTextSelection( 256 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; 257 virtual gfx::Point GetLastTouchEventLocation() const OVERRIDE; 258 virtual void FatalAccessibilityTreeError() OVERRIDE; 259 260 // Overridden from ui::GestureEventHelper. 261 virtual bool DispatchLongPressGestureEvent(ui::GestureEvent* event) OVERRIDE; 262 virtual bool DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; 263 264 // Overridden from ui::TextInputClient for Win8/metro TSF support. 265 // Following methods are not used in existing IMM32 related implementation. 266 virtual void SetCompositionText( 267 const ui::CompositionText& composition) OVERRIDE; 268 virtual void ConfirmCompositionText() OVERRIDE; 269 virtual void ClearCompositionText() OVERRIDE; 270 virtual void InsertText(const string16& text) OVERRIDE; 271 virtual void InsertChar(char16 ch, int flags) OVERRIDE; 272 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE; 273 virtual ui::TextInputType GetTextInputType() const OVERRIDE; 274 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE; 275 virtual bool CanComposeInline() const OVERRIDE; 276 virtual gfx::Rect GetCaretBounds() OVERRIDE; 277 virtual bool GetCompositionCharacterBounds(uint32 index, 278 gfx::Rect* rect) OVERRIDE; 279 virtual bool HasCompositionText() OVERRIDE; 280 virtual bool GetTextRange(ui::Range* range) OVERRIDE; 281 virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE; 282 virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; 283 virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; 284 virtual bool DeleteRange(const ui::Range& range) OVERRIDE; 285 virtual bool GetTextFromRange(const ui::Range& range, 286 string16* text) OVERRIDE; 287 virtual void OnInputMethodChanged() OVERRIDE; 288 virtual bool ChangeTextDirectionAndLayoutAlignment( 289 base::i18n::TextDirection direction) OVERRIDE; 290 virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE; 291 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE; 292 293 protected: 294 friend class RenderWidgetHostView; 295 296 // Should construct only via RenderWidgetHostView::CreateViewForWidget. 297 // 298 // The view will associate itself with the given widget. 299 explicit RenderWidgetHostViewWin(RenderWidgetHost* widget); 300 301 // Windows Message Handlers 302 LRESULT OnCreate(CREATESTRUCT* create_struct); 303 void OnActivate(UINT, BOOL, HWND); 304 void OnDestroy(); 305 void OnPaint(HDC unused_dc); 306 void OnNCPaint(HRGN update_region); 307 LRESULT OnNCHitTest(const CPoint& pt); 308 LRESULT OnEraseBkgnd(HDC dc); 309 LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT mouse_message_id); 310 void OnSetFocus(HWND window); 311 void OnKillFocus(HWND window); 312 void OnCaptureChanged(HWND window); 313 void OnCancelMode(); 314 void OnInputLangChange(DWORD character_set, HKL input_language_id); 315 void OnThemeChanged(); 316 LRESULT OnNotify(int w_param, NMHDR* header); 317 LRESULT OnImeSetContext( 318 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 319 LRESULT OnImeStartComposition( 320 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 321 LRESULT OnImeComposition( 322 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 323 LRESULT OnImeEndComposition( 324 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 325 LRESULT OnImeRequest( 326 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 327 LRESULT OnMouseEvent( 328 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 329 LRESULT OnKeyEvent( 330 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 331 LRESULT OnWheelEvent( 332 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 333 LRESULT OnTouchEvent( 334 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); 335 LRESULT OnMouseActivate(UINT message, 336 WPARAM wparam, 337 LPARAM lparam, 338 BOOL& handled); 339 // Handle MSAA requests for accessibility information. 340 LRESULT OnGetObject(UINT message, WPARAM wparam, LPARAM lparam, 341 BOOL& handled); 342 // Handle vertical scrolling. 343 LRESULT OnVScroll(int code, short position, HWND scrollbar_control); 344 // Handle horizontal scrolling. 345 LRESULT OnHScroll(int code, short position, HWND scrollbar_control); 346 347 LRESULT OnParentNotify(UINT message, WPARAM wparam, LPARAM lparam, 348 BOOL& handled); 349 350 // Handle high-level touch events. 351 LRESULT OnGestureEvent(UINT message, WPARAM wparam, LPARAM lparam, 352 BOOL& handled); 353 LRESULT OnMoveOrSize(UINT message, WPARAM wparam, LPARAM lparam, 354 BOOL& handled); 355 356 // Handle transitioning in and out of screensaver mode. 357 LRESULT OnSessionChange(UINT message, 358 WPARAM wparam, 359 LPARAM lparam, 360 BOOL& handled); 361 362 void OnFinalMessage(HWND window); 363 364 private: 365 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewWinBrowserTest, 366 TextInputTypeChanged); 367 368 // Updates the display cursor to the current cursor if the cursor is over this 369 // render view. 370 void UpdateCursorIfOverSelf(); 371 372 // Tells Windows that we want to hear about mouse exit messages. 373 void TrackMouseLeave(bool start_tracking); 374 375 // Sends a message to the RenderView in the renderer process. 376 bool Send(IPC::Message* message); 377 378 // Set the tooltip region to the size of the window, creating the tooltip 379 // hwnd if it has not been created yet. 380 void EnsureTooltip(); 381 382 // Tooltips become invalid when the root ancestor changes. When the View 383 // becomes hidden, this method is called to reset the tooltip. 384 void ResetTooltip(); 385 386 // Builds and forwards a WebKitGestureEvent to the renderer. 387 bool ForwardGestureEventToRenderer( 388 ui::GestureEvent* gesture); 389 390 // Process all of the given gestures (passes them on to renderer) 391 void ProcessGestures(ui::GestureRecognizer::Gestures* gestures); 392 393 // Sends the specified mouse event to the renderer. 394 void ForwardMouseEventToRenderer(UINT message, WPARAM wparam, LPARAM lparam); 395 396 // Synthesize mouse wheel event. 397 LRESULT SynthesizeMouseWheel(bool is_vertical, int scroll_code, 398 short scroll_position); 399 400 // Shuts down the render_widget_host_. This is a separate function so we can 401 // invoke it from the message loop. 402 void ShutdownHost(); 403 404 // Redraws the window synchronously, and any child windows (i.e. plugins) 405 // asynchronously. 406 void Redraw(); 407 408 // Draw our background over the given HDC in the given |rect|. The background 409 // will be tiled such that it lines up with existing tiles starting from the 410 // origin of |dc|. 411 void DrawBackground(const RECT& rect, CPaintDC* dc); 412 413 // Clean up the compositor window, if needed. 414 void CleanupCompositorWindow(); 415 416 // Whether the window should be activated. 417 bool IsActivatable() const; 418 419 // Do initialization needed by both InitAsPopup() and InitAsFullscreen(). 420 void DoPopupOrFullscreenInit(HWND parent_hwnd, 421 const gfx::Rect& pos, 422 DWORD ex_style); 423 424 CPoint GetClientCenter() const; 425 // In mouse lock mode, moves the mouse cursor to the center of the view if it 426 // is too close to the border. 427 void MoveCursorToCenterIfNecessary(); 428 429 void HandleLockedMouseEvent(UINT message, WPARAM wparam, LPARAM lparam); 430 431 LRESULT OnDocumentFeed(RECONVERTSTRING* reconv); 432 LRESULT OnReconvertString(RECONVERTSTRING* reconv); 433 LRESULT OnQueryCharPosition(IMECHARPOSITION* position); 434 435 // Sets the appropriate mode for raw-touches or gestures. Currently touch mode 436 // will only take effect on Win7+. 437 void UpdateDesiredTouchMode(); 438 439 // Configures the enable/disable state of |ime_input_| to match with the 440 // current |text_input_type_|. 441 void UpdateIMEState(); 442 443 // Returns bounds of the view in pixels. 444 gfx::Rect GetPixelBounds() const; 445 446 // Sets the appropriate input scope for given |text_input_type| if TSF-aware 447 // is not required. Does nothing if TSF-aware is required (and TSF text store 448 // is responsible for managing input scope). Currently input scope will only 449 // take effect on Vista+. 450 void UpdateInputScopeIfNecessary(ui::TextInputType text_input_type); 451 452 // Create a BrowserAccessibilityManager with an empty document if it 453 // doesn't already exist. 454 void CreateBrowserAccessibilityManagerIfNeeded(); 455 456 // The associated Model. While |this| is being Destroyed, 457 // |render_widget_host_| is NULL and the Windows message loop is run one last 458 // time. Message handlers must check for a NULL |render_widget_host_|. 459 RenderWidgetHostImpl* render_widget_host_; 460 461 // When we are doing accelerated compositing 462 HWND compositor_host_window_; 463 464 // Presents a texture received from another process to the compositing 465 // window. 466 scoped_ptr<AcceleratedSurface> accelerated_surface_; 467 468 // true if the compositor host window must be hidden after the 469 // software renderered view is updated. 470 bool hide_compositor_window_at_next_paint_; 471 472 // The cursor for the page. This is passed up from the renderer. 473 WebCursor current_cursor_; 474 475 // Indicates if the page is loading. 476 bool is_loading_; 477 478 // true if we are currently tracking WM_MOUSEEXIT messages. 479 bool track_mouse_leave_; 480 481 // Wrapper class for IMM32 APIs. 482 // (See "ui/base/ime/win/imm32_manager.h" for its details.) 483 scoped_ptr<ui::IMM32Manager> imm32_manager_; 484 485 // Represents whether or not this browser process is receiving status 486 // messages about the focused edit control from a renderer process. 487 bool ime_notification_; 488 489 // true if Enter was hit when render widget host was in focus. 490 bool capture_enter_key_; 491 492 // true if the View is not visible. 493 bool is_hidden_; 494 495 // The touch-state. Its touch-points are updated as necessary. A new 496 // touch-point is added from an TOUCHEVENTF_DOWN message, and a touch-point 497 // is removed from the list on an TOUCHEVENTF_UP message. 498 scoped_ptr<WebTouchState> touch_state_; 499 500 // True if we're in the midst of a paint operation and should respond to 501 // DidPaintRect() notifications by merely invalidating. See comments on 502 // render_widget_host_view.h:DidPaintRect(). 503 bool about_to_validate_and_paint_; 504 505 // true if the View should be closed when its HWND is deactivated (used to 506 // support SELECT popups which are closed when they are deactivated). 507 bool close_on_deactivate_; 508 509 // Whether Destroy() has been called. Used to detect a crasher 510 // (http://crbug.com/24248) where render_view_host_ has been deleted when 511 // OnFinalMessage is called. 512 bool being_destroyed_; 513 514 // Tooltips 515 // The text to be shown in the tooltip, supplied by the renderer. 516 string16 tooltip_text_; 517 // The tooltip control hwnd 518 HWND tooltip_hwnd_; 519 // Whether or not a tooltip is currently visible. We use this to track 520 // whether or not we want to force-close the tooltip when we receive mouse 521 // move notifications from the renderer. See comment in OnMsgSetTooltipText. 522 bool tooltip_showing_; 523 524 // Factory used to safely scope delayed calls to ShutdownHost(). 525 base::WeakPtrFactory<RenderWidgetHostViewWin> weak_factory_; 526 527 // The time at which this view started displaying white pixels as a result of 528 // not having anything to paint (empty backing store from renderer). This 529 // value returns true for is_null() if we are not recording whiteout times. 530 base::TimeTicks whiteout_start_time_; 531 532 // The time it took after this view was selected for it to be fully painted. 533 base::TimeTicks web_contents_switch_paint_time_; 534 535 // Registrar so we can listen to RENDERER_PROCESS_TERMINATED events. 536 NotificationRegistrar registrar_; 537 538 // Stores the current text input type received by TextInputStateChanged() 539 // method. 540 ui::TextInputType text_input_type_; 541 ui::TextInputMode text_input_mode_; 542 bool can_compose_inline_; 543 544 ScopedVector<ui::ViewProp> props_; 545 546 // Is the widget fullscreen? 547 bool is_fullscreen_; 548 549 // Used to record the last position of the mouse. 550 struct { 551 // While the mouse is locked, |unlocked| and |unlocked_global| store the 552 // last known position just as mouse lock was entered. 553 // Relative to the upper-left corner of the view. 554 gfx::Point unlocked; 555 // Relative to the upper-left corner of the screen. 556 gfx::Point unlocked_global; 557 558 // Only valid while the mouse is locked. 559 gfx::Point locked_global; 560 } last_mouse_position_; 561 562 // When the mouse cursor is moved to the center of the view by 563 // MoveCursorToCenterIfNecessary(), we ignore the resulting WM_MOUSEMOVE 564 // message. 565 struct { 566 bool pending; 567 // Relative to the upper-left corner of the screen. 568 gfx::Point target; 569 } move_to_center_request_; 570 571 // In the case of the mouse being moved away from the view and then moved 572 // back, we regard the mouse movement as (0, 0). 573 bool ignore_mouse_movement_; 574 575 ui::Range composition_range_; 576 577 // The current composition character bounds. 578 std::vector<gfx::Rect> composition_character_bounds_; 579 580 // A cached latest caret rectangle sent from renderer. 581 gfx::Rect caret_rect_; 582 583 // TODO(ananta) 584 // The WM_POINTERDOWN and touch related members should be moved to an 585 // independent class to reduce the clutter. This includes members 586 // pointer_down_context_ and last_touch_location_; 587 588 // Set to true if we are in the context of a WM_POINTERDOWN message 589 bool pointer_down_context_; 590 591 // The global x, y coordinates of the last point a touch event was 592 // received, used to determine if it's okay to open the on-screen 593 // keyboard. Reset when the window loses focus. 594 gfx::Point last_touch_location_; 595 596 // Region in which the view will be transparent to clicks. 597 scoped_ptr<SkRegion> transparent_region_; 598 599 // Are touch events currently enabled? 600 bool touch_events_enabled_; 601 602 scoped_ptr<ui::GestureRecognizer> gesture_recognizer_; 603 604 // The OS-provided default IAccessible instance for our hwnd. 605 base::win::ScopedComPtr<IAccessible> window_iaccessible_; 606 607 ui::LatencyInfo software_latency_info_; 608 609 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewWin); 610}; 611 612} // namespace content 613 614#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_WIN_H_ 615