Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/renderer_host/backing_store_skia.h" | 8 #include "content/browser/renderer_host/backing_store_skia.h" |
| 9 #include "content/browser/renderer_host/web_input_event_aura.h" | 9 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 10 #include "content/browser/renderer_host/render_widget_host.h" | 10 #include "content/browser/renderer_host/render_widget_host.h" |
| 11 #include "content/public/browser/native_web_keyboard_event.h" | 11 #include "content/public/browser/native_web_keyboard_event.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 13 #include "ui/aura/desktop.h" | 13 #include "ui/aura/desktop.h" |
| 14 #include "ui/aura/event.h" | 14 #include "ui/aura/event.h" |
| 15 #include "ui/aura/hit_test.h" | 15 #include "ui/aura/hit_test.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 18 #include "ui/gfx/compositor/layer.h" | 18 #include "ui/gfx/compositor/layer.h" |
| 19 | 19 |
| 20 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 20 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
| 21 #include "base/bind.h" | 21 #include "base/bind.h" |
| 22 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 22 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 23 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" | 23 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" |
| 24 #include "content/common/gpu/gpu_messages.h" | 24 #include "content/common/gpu/gpu_messages.h" |
| 25 #include "ui/gfx/gl/gl_bindings.h" | 25 #include "ui/gfx/gl/gl_bindings.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 using WebKit::WebTouchEvent; | |
| 29 | |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 32 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
| 31 void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) { | 33 void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) { |
| 32 // It's possible that gpu_host_id is no longer valid at this point (like if | 34 // It's possible that gpu_host_id is no longer valid at this point (like if |
| 33 // gpu process was restarted after a crash). SendToGpuHost handles this. | 35 // gpu process was restarted after a crash). SendToGpuHost handles this. |
| 34 GpuProcessHostUIShim::SendToGpuHost(gpu_host_id, | 36 GpuProcessHostUIShim::SendToGpuHost(gpu_host_id, |
| 35 new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); | 37 new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); |
| 36 } | 38 } |
| 37 #endif | 39 #endif |
| 38 | 40 |
| 41 ui::TouchStatus DecideTouchStatus(const WebKit::WebTouchEvent& event, | |
| 42 WebKit::WebTouchPoint* point) { | |
| 43 if (event.type == WebKit::WebInputEvent::TouchStart && | |
| 44 event.touchesLength == 1) | |
| 45 return ui::TOUCH_STATUS_START; | |
| 46 | |
| 47 if (event.type == WebKit::WebInputEvent::TouchMove && point == NULL) | |
| 48 return ui::TOUCH_STATUS_CONTINUE; | |
| 49 | |
| 50 if (event.type == WebKit::WebInputEvent::TouchEnd && | |
| 51 event.touchesLength == 0) | |
| 52 return ui::TOUCH_STATUS_END; | |
| 53 | |
| 54 if (event.type == WebKit::WebInputEvent::TouchCancel) | |
| 55 return ui::TOUCH_STATUS_CANCEL; | |
| 56 | |
| 57 return point ? ui::TOUCH_STATUS_CONTINUE : ui::TOUCH_STATUS_UNKNOWN; | |
| 58 } | |
| 59 | |
| 60 void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, | |
| 61 WebKit::WebTouchPoint* point) { | |
| 62 if (point->state != WebKit::WebTouchPoint::StateReleased) | |
|
sadrul
2011/10/25 19:09:55
I kept this here, and didn't move to content:: sin
| |
| 63 return; | |
| 64 --event->touchesLength; | |
| 65 for (unsigned i = point - event->touches; | |
| 66 i < event->touchesLength; | |
| 67 ++i) { | |
| 68 event->touches[i] = event->touches[i + 1]; | |
| 69 } | |
| 70 } | |
| 71 | |
| 39 } // namespace | 72 } // namespace |
| 40 | 73 |
| 41 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
| 42 // RenderWidgetHostViewAura, public: | 75 // RenderWidgetHostViewAura, public: |
| 43 | 76 |
| 44 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 77 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
| 45 : host_(host), | 78 : host_(host), |
| 46 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 79 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| 47 is_loading_(false) { | 80 is_loading_(false) { |
| 48 host_->SetView(this); | 81 host_->SetView(this); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 host_->ForwardWheelEvent(content::MakeWebMouseWheelEvent(event)); | 386 host_->ForwardWheelEvent(content::MakeWebMouseWheelEvent(event)); |
| 354 else | 387 else |
| 355 host_->ForwardMouseEvent(content::MakeWebMouseEvent(event)); | 388 host_->ForwardMouseEvent(content::MakeWebMouseEvent(event)); |
| 356 | 389 |
| 357 // Return true so that we receive released/drag events. | 390 // Return true so that we receive released/drag events. |
| 358 return true; | 391 return true; |
| 359 } | 392 } |
| 360 | 393 |
| 361 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( | 394 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( |
| 362 aura::TouchEvent* event) { | 395 aura::TouchEvent* event) { |
| 363 NOTIMPLEMENTED(); | 396 // Update the touch event first. |
| 364 return ui::TOUCH_STATUS_UNKNOWN; | 397 WebKit::WebTouchPoint* point = content::UpdateWebTouchEvent(event, |
| 398 &touch_event_); | |
| 399 | |
| 400 // Forward the touch event only if a touch point was updated. | |
| 401 if (point) { | |
| 402 host_->ForwardTouchEvent(touch_event_); | |
| 403 UpdateWebTouchEventAfterDispatch(&touch_event_, point); | |
| 404 } | |
| 405 | |
| 406 return DecideTouchStatus(touch_event_, point); | |
| 365 } | 407 } |
| 366 | 408 |
| 367 bool RenderWidgetHostViewAura::ShouldActivate(aura::Event* event) { | 409 bool RenderWidgetHostViewAura::ShouldActivate(aura::Event* event) { |
| 368 return false; | 410 return false; |
| 369 } | 411 } |
| 370 | 412 |
| 371 void RenderWidgetHostViewAura::OnActivated() { | 413 void RenderWidgetHostViewAura::OnActivated() { |
| 372 } | 414 } |
| 373 | 415 |
| 374 void RenderWidgetHostViewAura::OnLostActive() { | 416 void RenderWidgetHostViewAura::OnLostActive() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 | 461 |
| 420 #if !defined(TOUCH_UI) | 462 #if !defined(TOUCH_UI) |
| 421 //////////////////////////////////////////////////////////////////////////////// | 463 //////////////////////////////////////////////////////////////////////////////// |
| 422 // RenderWidgetHostViewAura, private: | 464 // RenderWidgetHostViewAura, private: |
| 423 | 465 |
| 424 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 466 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
| 425 //NOTIMPLEMENTED(); | 467 //NOTIMPLEMENTED(); |
| 426 // TODO(beng): See RenderWidgetHostViewWin. | 468 // TODO(beng): See RenderWidgetHostViewWin. |
| 427 } | 469 } |
| 428 #endif | 470 #endif |
| OLD | NEW |