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