| 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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 reinterpret_cast<RenderWidgetHostViewAura*>(param); | 103 reinterpret_cast<RenderWidgetHostViewAura*>(param); |
| 104 | 104 |
| 105 HWND parent = | 105 HWND parent = |
| 106 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget(); | 106 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget(); |
| 107 if (GetProp(window, kWidgetOwnerProperty) == widget) | 107 if (GetProp(window, kWidgetOwnerProperty) == widget) |
| 108 SetParent(window, parent); | 108 SetParent(window, parent); |
| 109 return TRUE; | 109 return TRUE; |
| 110 } | 110 } |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 ui::TouchStatus DecideTouchStatus(const WebKit::WebTouchEvent& event, | |
| 114 WebKit::WebTouchPoint* point) { | |
| 115 if (event.type == WebKit::WebInputEvent::TouchEnd && | |
| 116 event.touchesLength == 0) | |
| 117 return ui::TOUCH_STATUS_QUEUED_END; | |
| 118 | |
| 119 return ui::TOUCH_STATUS_QUEUED; | |
| 120 } | |
| 121 | |
| 122 void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, | 113 void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, |
| 123 WebKit::WebTouchPoint* point) { | 114 WebKit::WebTouchPoint* point) { |
| 124 if (point->state != WebKit::WebTouchPoint::StateReleased) | 115 if (point->state != WebKit::WebTouchPoint::StateReleased) |
| 125 return; | 116 return; |
| 126 --event->touchesLength; | 117 --event->touchesLength; |
| 127 for (unsigned i = point - event->touches; | 118 for (unsigned i = point - event->touches; |
| 128 i < event->touchesLength; | 119 i < event->touchesLength; |
| 129 ++i) { | 120 ++i) { |
| 130 event->touches[i] = event->touches[i + 1]; | 121 event->touches[i] = event->touches[i + 1]; |
| 131 } | 122 } |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 | 1509 |
| 1519 // Needed to propagate mouse event to native_tab_contents_view_aura. | 1510 // Needed to propagate mouse event to native_tab_contents_view_aura. |
| 1520 // TODO(pkotwicz): Find a better way of doing this. | 1511 // TODO(pkotwicz): Find a better way of doing this. |
| 1521 if (window_->parent()->delegate()) | 1512 if (window_->parent()->delegate()) |
| 1522 window_->parent()->delegate()->OnMouseEvent(event); | 1513 window_->parent()->delegate()->OnMouseEvent(event); |
| 1523 | 1514 |
| 1524 // Return true so that we receive released/drag events. | 1515 // Return true so that we receive released/drag events. |
| 1525 return ui::ER_HANDLED; | 1516 return ui::ER_HANDLED; |
| 1526 } | 1517 } |
| 1527 | 1518 |
| 1528 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( | 1519 ui::EventResult RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { |
| 1529 ui::TouchEvent* event) { | |
| 1530 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent"); | 1520 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnTouchEvent"); |
| 1531 // Update the touch event first. | 1521 // Update the touch event first. |
| 1532 WebKit::WebTouchPoint* point = UpdateWebTouchEvent(event, | 1522 WebKit::WebTouchPoint* point = UpdateWebTouchEvent(event, |
| 1533 &touch_event_); | 1523 &touch_event_); |
| 1534 | 1524 |
| 1535 // Forward the touch event only if a touch point was updated, and there's a | 1525 // Forward the touch event only if a touch point was updated, and there's a |
| 1536 // touch-event handler in the page. | 1526 // touch-event handler in the page. |
| 1537 if (point && host_->has_touch_handler()) { | 1527 if (point && host_->has_touch_handler()) { |
| 1538 host_->ForwardTouchEvent(touch_event_); | 1528 host_->ForwardTouchEvent(touch_event_); |
| 1539 UpdateWebTouchEventAfterDispatch(&touch_event_, point); | 1529 UpdateWebTouchEventAfterDispatch(&touch_event_, point); |
| 1540 return DecideTouchStatus(touch_event_, point); | 1530 return ui::ER_ASYNC; |
| 1541 } | 1531 } |
| 1542 | 1532 |
| 1543 return ui::TOUCH_STATUS_UNKNOWN; | 1533 return ui::ER_UNHANDLED; |
| 1544 } | 1534 } |
| 1545 | 1535 |
| 1546 ui::EventResult RenderWidgetHostViewAura::OnGestureEvent( | 1536 ui::EventResult RenderWidgetHostViewAura::OnGestureEvent( |
| 1547 ui::GestureEvent* event) { | 1537 ui::GestureEvent* event) { |
| 1548 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); | 1538 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); |
| 1549 // Pinch gestures are currently disabled by default. See crbug.com/128477. | 1539 // Pinch gestures are currently disabled by default. See crbug.com/128477. |
| 1550 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 1540 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
| 1551 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 1541 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
| 1552 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { | 1542 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { |
| 1553 return ui::ER_CONSUMED; | 1543 return ui::ER_CONSUMED; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 RenderWidgetHost* widget) { | 1850 RenderWidgetHost* widget) { |
| 1861 return new RenderWidgetHostViewAura(widget); | 1851 return new RenderWidgetHostViewAura(widget); |
| 1862 } | 1852 } |
| 1863 | 1853 |
| 1864 // static | 1854 // static |
| 1865 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1855 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 1866 GetScreenInfoForWindow(results, NULL); | 1856 GetScreenInfoForWindow(results, NULL); |
| 1867 } | 1857 } |
| 1868 | 1858 |
| 1869 } // namespace content | 1859 } // namespace content |
| OLD | NEW |