| 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 #include "content/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <peninputpanel_i.c> | 8 #include <peninputpanel_i.c> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 inline void SetTouchType(TOUCHINPUT* point, int type) { | 300 inline void SetTouchType(TOUCHINPUT* point, int type) { |
| 301 point->dwFlags = (point->dwFlags & kTouchMask) | type; | 301 point->dwFlags = (point->dwFlags & kTouchMask) | type; |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace | 304 } // namespace |
| 305 | 305 |
| 306 /////////////////////////////////////////////////////////////////////////////// | 306 /////////////////////////////////////////////////////////////////////////////// |
| 307 // RenderWidgetHostViewWin, public: | 307 // RenderWidgetHostViewWin, public: |
| 308 | 308 |
| 309 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) | 309 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) |
| 310 : compositor_host_window_(NULL), | 310 : render_widget_host_(widget->AsRWHImpl()), |
| 311 compositor_host_window_(NULL), |
| 311 hide_compositor_window_at_next_paint_(false), | 312 hide_compositor_window_at_next_paint_(false), |
| 312 track_mouse_leave_(false), | 313 track_mouse_leave_(false), |
| 313 ime_notification_(false), | 314 ime_notification_(false), |
| 314 capture_enter_key_(false), | 315 capture_enter_key_(false), |
| 315 is_hidden_(false), | 316 is_hidden_(false), |
| 316 about_to_validate_and_paint_(false), | 317 about_to_validate_and_paint_(false), |
| 317 close_on_deactivate_(false), | 318 close_on_deactivate_(false), |
| 318 being_destroyed_(false), | 319 being_destroyed_(false), |
| 319 tooltip_hwnd_(NULL), | 320 tooltip_hwnd_(NULL), |
| 320 tooltip_showing_(false), | 321 tooltip_showing_(false), |
| 321 weak_factory_(this), | 322 weak_factory_(this), |
| 322 parent_hwnd_(NULL), | 323 parent_hwnd_(NULL), |
| 323 is_loading_(false), | 324 is_loading_(false), |
| 324 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 325 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 325 is_fullscreen_(false), | 326 is_fullscreen_(false), |
| 326 ignore_mouse_movement_(true), | 327 ignore_mouse_movement_(true), |
| 327 composition_range_(ui::Range::InvalidRange()), | 328 composition_range_(ui::Range::InvalidRange()), |
| 328 touch_state_(this), | 329 touch_state_(this), |
| 329 pointer_down_context_(false), | 330 pointer_down_context_(false), |
| 330 focus_on_editable_field_(false), | 331 focus_on_editable_field_(false), |
| 331 received_focus_change_after_pointer_down_(false), | 332 received_focus_change_after_pointer_down_(false), |
| 332 transparent_region_(0) { | 333 transparent_region_(0) { |
| 333 render_widget_host_ = static_cast<RenderWidgetHostImpl*>(widget); | |
| 334 render_widget_host_->SetView(this); | 334 render_widget_host_->SetView(this); |
| 335 registrar_.Add(this, | 335 registrar_.Add(this, |
| 336 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 336 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 337 content::NotificationService::AllBrowserContextsAndSources()); | 337 content::NotificationService::AllBrowserContextsAndSources()); |
| 338 registrar_.Add(this, | 338 registrar_.Add(this, |
| 339 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, | 339 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, |
| 340 content::NotificationService::AllBrowserContextsAndSources()); | 340 content::NotificationService::AllBrowserContextsAndSources()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 343 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 CleanupCompositorWindow(); | 993 CleanupCompositorWindow(); |
| 994 | 994 |
| 995 ResetTooltip(); | 995 ResetTooltip(); |
| 996 TrackMouseLeave(false); | 996 TrackMouseLeave(false); |
| 997 } | 997 } |
| 998 | 998 |
| 999 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { | 999 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { |
| 1000 if (!render_widget_host_) | 1000 if (!render_widget_host_) |
| 1001 return; | 1001 return; |
| 1002 | 1002 |
| 1003 DCHECK(render_widget_host_->process()->HasConnection()); | 1003 DCHECK(render_widget_host_->GetProcess()->HasConnection()); |
| 1004 | 1004 |
| 1005 // If the GPU process is rendering directly into the View, compositing is | 1005 // If the GPU process is rendering directly into the View, compositing is |
| 1006 // already triggered by damage to compositor_host_window_, so all we need to | 1006 // already triggered by damage to compositor_host_window_, so all we need to |
| 1007 // do here is clear borders during resize. | 1007 // do here is clear borders during resize. |
| 1008 if (render_widget_host_->is_accelerated_compositing_active()) { | 1008 if (render_widget_host_->is_accelerated_compositing_active()) { |
| 1009 // We initialize paint_dc here so that BeginPaint()/EndPaint() | 1009 // We initialize paint_dc here so that BeginPaint()/EndPaint() |
| 1010 // get called to validate the region. | 1010 // get called to validate the region. |
| 1011 CPaintDC paint_dc(m_hWnd); | 1011 CPaintDC paint_dc(m_hWnd); |
| 1012 RECT host_rect, child_rect; | 1012 RECT host_rect, child_rect; |
| 1013 GetClientRect(&host_rect); | 1013 GetClientRect(&host_rect); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 render_widget_host_->SetInputMethodActive(ime_status); | 1270 render_widget_host_->SetInputMethodActive(ime_status); |
| 1271 ime_notification_ = ime_status; | 1271 ime_notification_ = ime_status; |
| 1272 } | 1272 } |
| 1273 } | 1273 } |
| 1274 } | 1274 } |
| 1275 | 1275 |
| 1276 void RenderWidgetHostViewWin::OnThemeChanged() { | 1276 void RenderWidgetHostViewWin::OnThemeChanged() { |
| 1277 if (!render_widget_host_) | 1277 if (!render_widget_host_) |
| 1278 return; | 1278 return; |
| 1279 render_widget_host_->Send(new ViewMsg_ThemeChanged( | 1279 render_widget_host_->Send(new ViewMsg_ThemeChanged( |
| 1280 render_widget_host_->routing_id())); | 1280 render_widget_host_->GetRoutingID())); |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 LRESULT RenderWidgetHostViewWin::OnNotify(int w_param, NMHDR* header) { | 1283 LRESULT RenderWidgetHostViewWin::OnNotify(int w_param, NMHDR* header) { |
| 1284 if (tooltip_hwnd_ == NULL) | 1284 if (tooltip_hwnd_ == NULL) |
| 1285 return 0; | 1285 return 0; |
| 1286 | 1286 |
| 1287 switch (header->code) { | 1287 switch (header->code) { |
| 1288 case TTN_GETDISPINFO: { | 1288 case TTN_GETDISPINFO: { |
| 1289 NMTTDISPINFOW* tooltip_info = reinterpret_cast<NMTTDISPINFOW*>(header); | 1289 NMTTDISPINFOW* tooltip_info = reinterpret_cast<NMTTDISPINFOW*>(header); |
| 1290 tooltip_info->szText[0] = L'\0'; | 1290 tooltip_info->szText[0] = L'\0'; |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 DWORD error = GetLastError(); | 1887 DWORD error = GetLastError(); |
| 1888 NOTREACHED() << "Unable to get gesture info. Error : " << error; | 1888 NOTREACHED() << "Unable to get gesture info. Error : " << error; |
| 1889 return 0; | 1889 return 0; |
| 1890 } | 1890 } |
| 1891 | 1891 |
| 1892 if (gi.dwID == GID_ZOOM) { | 1892 if (gi.dwID == GID_ZOOM) { |
| 1893 content::PageZoom zoom = content::PAGE_ZOOM_RESET; | 1893 content::PageZoom zoom = content::PAGE_ZOOM_RESET; |
| 1894 POINT zoom_center = {0}; | 1894 POINT zoom_center = {0}; |
| 1895 if (DecodeZoomGesture(m_hWnd, gi, &zoom, &zoom_center)) { | 1895 if (DecodeZoomGesture(m_hWnd, gi, &zoom, &zoom_center)) { |
| 1896 handled = TRUE; | 1896 handled = TRUE; |
| 1897 Send(new ViewMsg_ZoomFactor(render_widget_host_->routing_id(), | 1897 Send(new ViewMsg_ZoomFactor(render_widget_host_->GetRoutingID(), |
| 1898 zoom, zoom_center.x, zoom_center.y)); | 1898 zoom, zoom_center.x, zoom_center.y)); |
| 1899 } | 1899 } |
| 1900 } else if (gi.dwID == GID_PAN) { | 1900 } else if (gi.dwID == GID_PAN) { |
| 1901 // Right now we only decode scroll gestures and we forward to the page | 1901 // Right now we only decode scroll gestures and we forward to the page |
| 1902 // as scroll events. | 1902 // as scroll events. |
| 1903 POINT start; | 1903 POINT start; |
| 1904 POINT delta; | 1904 POINT delta; |
| 1905 if (DecodeScrollGesture(gi, &start, &delta)) { | 1905 if (DecodeScrollGesture(gi, &start, &delta)) { |
| 1906 handled = TRUE; | 1906 handled = TRUE; |
| 1907 render_widget_host_->ForwardWheelEvent( | 1907 render_widget_host_->ForwardWheelEvent( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 focus_on_editable_field_ = *content::Details<bool>(details).ptr(); | 1982 focus_on_editable_field_ = *content::Details<bool>(details).ptr(); |
| 1983 if (virtual_keyboard_) | 1983 if (virtual_keyboard_) |
| 1984 DisplayOnScreenKeyboardIfNeeded(); | 1984 DisplayOnScreenKeyboardIfNeeded(); |
| 1985 } else { | 1985 } else { |
| 1986 // Get the RenderProcessHost that posted this notification, and exit | 1986 // Get the RenderProcessHost that posted this notification, and exit |
| 1987 // if it's not the one associated with this host view. | 1987 // if it's not the one associated with this host view. |
| 1988 content::RenderProcessHost* render_process_host = | 1988 content::RenderProcessHost* render_process_host = |
| 1989 content::Source<content::RenderProcessHost>(source).ptr(); | 1989 content::Source<content::RenderProcessHost>(source).ptr(); |
| 1990 DCHECK(render_process_host); | 1990 DCHECK(render_process_host); |
| 1991 if (!render_widget_host_ || | 1991 if (!render_widget_host_ || |
| 1992 render_process_host != render_widget_host_->process()) | 1992 render_process_host != render_widget_host_->GetProcess()) |
| 1993 return; | 1993 return; |
| 1994 | 1994 |
| 1995 // If it was our RenderProcessHost that posted the notification, | 1995 // If it was our RenderProcessHost that posted the notification, |
| 1996 // clear the BrowserAccessibilityManager, because the renderer is | 1996 // clear the BrowserAccessibilityManager, because the renderer is |
| 1997 // dead and any accessibility information we have is now stale. | 1997 // dead and any accessibility information we have is now stale. |
| 1998 SetBrowserAccessibilityManager(NULL); | 1998 SetBrowserAccessibilityManager(NULL); |
| 1999 } | 1999 } |
| 2000 } | 2000 } |
| 2001 | 2001 |
| 2002 static void PaintCompositorHostWindow(HWND hWnd) { | 2002 static void PaintCompositorHostWindow(HWND hWnd) { |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2599 void RenderWidgetHostViewWin::ResetPointerDownContext() { | 2599 void RenderWidgetHostViewWin::ResetPointerDownContext() { |
| 2600 // If the default focus on the page is on an edit field and we did not | 2600 // If the default focus on the page is on an edit field and we did not |
| 2601 // receive a focus change in the context of a pointer down message, it means | 2601 // receive a focus change in the context of a pointer down message, it means |
| 2602 // that the pointer down message occurred on the edit field and we should | 2602 // that the pointer down message occurred on the edit field and we should |
| 2603 // display the on screen keyboard | 2603 // display the on screen keyboard |
| 2604 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 2604 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
| 2605 DisplayOnScreenKeyboardIfNeeded(); | 2605 DisplayOnScreenKeyboardIfNeeded(); |
| 2606 received_focus_change_after_pointer_down_ = false; | 2606 received_focus_change_after_pointer_down_ = false; |
| 2607 pointer_down_context_ = false; | 2607 pointer_down_context_ = false; |
| 2608 } | 2608 } |
| OLD | NEW |