| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 PlatformEvent::LeftButtonDown, | 95 PlatformEvent::LeftButtonDown, |
| 96 PlatformEvent::MiddleButtonDown, | 96 PlatformEvent::MiddleButtonDown, |
| 97 PlatformEvent::RightButtonDown | 97 PlatformEvent::RightButtonDown |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 return webMouseButtonToPlatformModifier[button]; | 100 return webMouseButtonToPlatformModifier[button]; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // MakePlatformMouseEvent ----------------------------------------------------- | 103 // MakePlatformMouseEvent ----------------------------------------------------- |
| 104 | 104 |
| 105 // TODO(mustaq): Add tests for this. |
| 105 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) | 106 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) |
| 106 { | 107 { |
| 107 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 108 // FIXME: Widget is always toplevel, unless it's a popup. We may be able |
| 108 // to get rid of this once we abstract popups into a WebKit API. | 109 // to get rid of this once we abstract popups into a WebKit API. |
| 109 m_position = widget->convertFromContainingWindow(flooredIntPoint(convertHitP
ointToWindow(widget, IntPoint(e.x, e.y)))); | 110 m_position = widget->convertFromContainingWindow(flooredIntPoint(convertHitP
ointToWindow(widget, IntPoint(e.x, e.y)))); |
| 110 m_globalPosition = IntPoint(e.globalX, e.globalY); | 111 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 111 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), scaleDel
taToWindow(widget, e.movementY)); | 112 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), scaleDel
taToWindow(widget, e.movementY)); |
| 112 m_button = static_cast<MouseButton>(e.button); | 113 m_button = static_cast<MouseButton>(e.button); |
| 113 m_modifiers = e.modifiers; | 114 m_modifiers = e.modifiers; |
| 114 | 115 |
| 115 m_timestamp = e.timeStampSeconds; | 116 m_timestamp = e.timeStampSeconds; |
| 116 m_clickCount = e.clickCount; | 117 m_clickCount = e.clickCount; |
| 117 | 118 |
| 119 m_pointerProperties = static_cast<WebPointerProperties>(e); |
| 120 |
| 118 switch (e.type) { | 121 switch (e.type) { |
| 119 case WebInputEvent::MouseMove: | 122 case WebInputEvent::MouseMove: |
| 120 case WebInputEvent::MouseLeave: // synthesize a move event | 123 case WebInputEvent::MouseLeave: // synthesize a move event |
| 121 m_type = PlatformEvent::MouseMoved; | 124 m_type = PlatformEvent::MouseMoved; |
| 122 break; | 125 break; |
| 123 | 126 |
| 124 case WebInputEvent::MouseDown: | 127 case WebInputEvent::MouseDown: |
| 125 m_type = PlatformEvent::MousePressed; | 128 m_type = PlatformEvent::MousePressed; |
| 126 break; | 129 break; |
| 127 | 130 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 return WebTouchPoint::StateReleased; | 378 return WebTouchPoint::StateReleased; |
| 376 if (type == EventTypeNames::touchcancel) | 379 if (type == EventTypeNames::touchcancel) |
| 377 return WebTouchPoint::StateCancelled; | 380 return WebTouchPoint::StateCancelled; |
| 378 if (type == EventTypeNames::touchstart) | 381 if (type == EventTypeNames::touchstart) |
| 379 return WebTouchPoint::StatePressed; | 382 return WebTouchPoint::StatePressed; |
| 380 if (type == EventTypeNames::touchmove) | 383 if (type == EventTypeNames::touchmove) |
| 381 return WebTouchPoint::StateMoved; | 384 return WebTouchPoint::StateMoved; |
| 382 return WebTouchPoint::StateUndefined; | 385 return WebTouchPoint::StateUndefined; |
| 383 } | 386 } |
| 384 | 387 |
| 388 // TODO(mustaq): Add tests for this. |
| 385 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) | 389 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) |
| 386 { | 390 { |
| 387 m_pointerProperties = point; | 391 m_pointerProperties = point; |
| 388 m_state = toPlatformTouchPointState(point.state); | 392 m_state = toPlatformTouchPointState(point.state); |
| 389 | 393 |
| 390 // This assumes convertFromContainingWindow does only translations, not scal
es. | 394 // This assumes convertFromContainingWindow does only translations, not scal
es. |
| 391 FloatPoint floatPos = convertHitPointToWindow(widget, point.position); | 395 FloatPoint floatPos = convertHitPointToWindow(widget, point.position); |
| 392 IntPoint flooredPoint = flooredIntPoint(floatPos); | 396 IntPoint flooredPoint = flooredIntPoint(floatPos); |
| 393 m_pos = widget->convertFromContainingWindow(flooredPoint) + (floatPos - floo
redPoint); | 397 m_pos = widget->convertFromContainingWindow(flooredPoint) + (floatPos - floo
redPoint); |
| 394 | 398 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 break; | 725 break; |
| 722 case GestureSourceTouchscreen: | 726 case GestureSourceTouchscreen: |
| 723 sourceDevice = WebGestureDeviceTouchscreen; | 727 sourceDevice = WebGestureDeviceTouchscreen; |
| 724 break; | 728 break; |
| 725 case GestureSourceUninitialized: | 729 case GestureSourceUninitialized: |
| 726 ASSERT_NOT_REACHED(); | 730 ASSERT_NOT_REACHED(); |
| 727 } | 731 } |
| 728 } | 732 } |
| 729 | 733 |
| 730 } // namespace blink | 734 } // namespace blink |
| OLD | NEW |