Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/gdi_util.h" | 8 #include "app/gfx/gdi_util.h" |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
| (...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, | 1552 void RenderWidgetHostViewWin::ForwardMouseEventToRenderer(UINT message, |
| 1553 WPARAM wparam, | 1553 WPARAM wparam, |
| 1554 LPARAM lparam) { | 1554 LPARAM lparam) { |
| 1555 if (!render_widget_host_) | 1555 if (!render_widget_host_) |
| 1556 return; | 1556 return; |
| 1557 | 1557 |
| 1558 WebMouseEvent event( | 1558 WebMouseEvent event( |
| 1559 WebInputEventFactory::mouseEvent(m_hWnd, message, wparam, lparam)); | 1559 WebInputEventFactory::mouseEvent(m_hWnd, message, wparam, lparam)); |
| 1560 | |
| 1561 // Send the event to the renderer before changing mouse capture, so that the | |
| 1562 // capturelost event arrives after mouseup. | |
| 1563 render_widget_host_->ForwardMouseEvent(event); | |
|
darin (slow to review)
2010/03/10 00:14:06
LGTM
I think you should make a similar change to
jam
2010/03/10 01:51:19
good idea, thanks. will add it and commit.
| |
| 1564 | |
| 1560 switch (event.type) { | 1565 switch (event.type) { |
| 1561 case WebInputEvent::MouseMove: | 1566 case WebInputEvent::MouseMove: |
| 1562 TrackMouseLeave(true); | 1567 TrackMouseLeave(true); |
| 1563 break; | 1568 break; |
| 1564 case WebInputEvent::MouseLeave: | 1569 case WebInputEvent::MouseLeave: |
| 1565 TrackMouseLeave(false); | 1570 TrackMouseLeave(false); |
| 1566 break; | 1571 break; |
| 1567 case WebInputEvent::MouseDown: | 1572 case WebInputEvent::MouseDown: |
| 1568 SetCapture(); | 1573 SetCapture(); |
| 1569 break; | 1574 break; |
| 1570 case WebInputEvent::MouseUp: | 1575 case WebInputEvent::MouseUp: |
| 1571 if (GetCapture() == m_hWnd) | 1576 if (GetCapture() == m_hWnd) |
| 1572 ReleaseCapture(); | 1577 ReleaseCapture(); |
| 1573 break; | 1578 break; |
| 1574 } | 1579 } |
| 1575 | 1580 |
| 1576 render_widget_host_->ForwardMouseEvent(event); | |
| 1577 | |
| 1578 if (activatable_ && event.type == WebInputEvent::MouseDown) { | 1581 if (activatable_ && event.type == WebInputEvent::MouseDown) { |
| 1579 // This is a temporary workaround for bug 765011 to get focus when the | 1582 // This is a temporary workaround for bug 765011 to get focus when the |
| 1580 // mouse is clicked. This happens after the mouse down event is sent to | 1583 // mouse is clicked. This happens after the mouse down event is sent to |
| 1581 // the renderer because normally Windows does a WM_SETFOCUS after | 1584 // the renderer because normally Windows does a WM_SETFOCUS after |
| 1582 // WM_LBUTTONDOWN. | 1585 // WM_LBUTTONDOWN. |
| 1583 SetFocus(); | 1586 SetFocus(); |
| 1584 } | 1587 } |
| 1585 } | 1588 } |
| 1586 | 1589 |
| 1587 void RenderWidgetHostViewWin::ShutdownHost() { | 1590 void RenderWidgetHostViewWin::ShutdownHost() { |
| 1588 shutdown_factory_.RevokeAll(); | 1591 shutdown_factory_.RevokeAll(); |
| 1589 if (render_widget_host_) | 1592 if (render_widget_host_) |
| 1590 render_widget_host_->Shutdown(); | 1593 render_widget_host_->Shutdown(); |
| 1591 // Do not touch any members at this point, |this| has been deleted. | 1594 // Do not touch any members at this point, |this| has been deleted. |
| 1592 } | 1595 } |
| 1593 | 1596 |
| 1594 // static | 1597 // static |
| 1595 RenderWidgetHostView* | 1598 RenderWidgetHostView* |
| 1596 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1599 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
| 1597 gfx::NativeView native_view) { | 1600 gfx::NativeView native_view) { |
| 1598 if (::IsWindow(native_view)) { | 1601 if (::IsWindow(native_view)) { |
| 1599 HANDLE raw_render_host_view = ::GetProp(native_view, | 1602 HANDLE raw_render_host_view = ::GetProp(native_view, |
| 1600 kRenderWidgetHostViewKey); | 1603 kRenderWidgetHostViewKey); |
| 1601 if (raw_render_host_view) | 1604 if (raw_render_host_view) |
| 1602 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); | 1605 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); |
| 1603 } | 1606 } |
| 1604 return NULL; | 1607 return NULL; |
| 1605 } | 1608 } |
| OLD | NEW |