OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved........... | 1 // Copyright (c) 2006-2008 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 "webkit/tools/test_shell/webwidget_host.h" | 5 #include "webkit/tools/test_shell/webwidget_host.h" |
6 | 6 |
7 #include "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 WebMouseEvent event(view_, message, wparam, lparam); | 276 WebMouseEvent event(view_, message, wparam, lparam); |
277 switch (event.type) { | 277 switch (event.type) { |
278 case WebInputEvent::MOUSE_MOVE: | 278 case WebInputEvent::MOUSE_MOVE: |
279 TrackMouseLeave(true); | 279 TrackMouseLeave(true); |
280 break; | 280 break; |
281 case WebInputEvent::MOUSE_LEAVE: | 281 case WebInputEvent::MOUSE_LEAVE: |
282 TrackMouseLeave(false); | 282 TrackMouseLeave(false); |
283 break; | 283 break; |
284 case WebInputEvent::MOUSE_DOWN: | 284 case WebInputEvent::MOUSE_DOWN: |
285 SetCapture(view_); | 285 SetCapture(view_); |
| 286 // This mimics a temporary workaround in RenderWidgetHostViewWin |
| 287 // for bug 765011 to get focus when the mouse is clicked. This |
| 288 // happens after the mouse down event is sent to the renderer |
| 289 // because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN. |
| 290 ::SetFocus(view_); |
286 break; | 291 break; |
287 case WebInputEvent::MOUSE_UP: | 292 case WebInputEvent::MOUSE_UP: |
288 if (GetCapture() == view_) | 293 if (GetCapture() == view_) |
289 ReleaseCapture(); | 294 ReleaseCapture(); |
290 break; | 295 break; |
291 } | 296 } |
292 webwidget_->HandleInputEvent(&event); | 297 webwidget_->HandleInputEvent(&event); |
293 | |
294 if (event.type == WebInputEvent::MOUSE_DOWN) { | |
295 // This mimics a temporary workaround in RenderWidgetHostViewWin | |
296 // for bug 765011 to get focus when the mouse is clicked. This | |
297 // happens after the mouse down event is sent to the renderer | |
298 // because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN. | |
299 ::SetFocus(view_); | |
300 } | |
301 } | 298 } |
302 | 299 |
303 void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) { | 300 void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) { |
304 WebMouseWheelEvent event(view_, WM_MOUSEWHEEL, wparam, lparam); | 301 WebMouseWheelEvent event(view_, WM_MOUSEWHEEL, wparam, lparam); |
305 webwidget_->HandleInputEvent(&event); | 302 webwidget_->HandleInputEvent(&event); |
306 } | 303 } |
307 | 304 |
308 void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) { | 305 void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) { |
309 WebKeyboardEvent event(view_, message, wparam, lparam); | 306 WebKeyboardEvent event(view_, message, wparam, lparam); |
310 webwidget_->HandleInputEvent(&event); | 307 webwidget_->HandleInputEvent(&event); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 341 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
345 #ifndef NDEBUG | 342 #ifndef NDEBUG |
346 DCHECK(!painting_); | 343 DCHECK(!painting_); |
347 #endif | 344 #endif |
348 DCHECK(canvas_.get()); | 345 DCHECK(canvas_.get()); |
349 | 346 |
350 set_painting(true); | 347 set_painting(true); |
351 webwidget_->Paint(canvas_.get(), rect); | 348 webwidget_->Paint(canvas_.get(), rect); |
352 set_painting(false); | 349 set_painting(false); |
353 } | 350 } |
OLD | NEW |