| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "core/platform/Widget.h" | 47 #include "core/platform/Widget.h" |
| 48 #include "core/platform/chromium/KeyboardCodes.h" | 48 #include "core/platform/chromium/KeyboardCodes.h" |
| 49 #include "core/rendering/RenderObject.h" | 49 #include "core/rendering/RenderObject.h" |
| 50 | 50 |
| 51 using namespace WebCore; | 51 using namespace WebCore; |
| 52 | 52 |
| 53 namespace WebKit { | 53 namespace WebKit { |
| 54 | 54 |
| 55 static const double millisPerSecond = 1000.0; | 55 static const double millisPerSecond = 1000.0; |
| 56 | 56 |
| 57 static float widgetScaleFactor(const Widget* widget) | 57 static float widgetInputEventsScaleFactor(const Widget* widget) |
| 58 { | 58 { |
| 59 if (!widget) | 59 if (!widget) |
| 60 return 1; | 60 return 1; |
| 61 | 61 |
| 62 ScrollView* rootView = widget->root(); | 62 ScrollView* rootView = widget->root(); |
| 63 if (!rootView) | 63 if (!rootView) |
| 64 return 1; | 64 return 1; |
| 65 | 65 |
| 66 return rootView->visibleContentScaleFactor(); | 66 return rootView->inputEventsScaleFactor(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // MakePlatformMouseEvent ----------------------------------------------------- | 69 // MakePlatformMouseEvent ----------------------------------------------------- |
| 70 | 70 |
| 71 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) | 71 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) |
| 72 { | 72 { |
| 73 float scale = widgetScaleFactor(widget); | 73 float scale = widgetInputEventsScaleFactor(widget); |
| 74 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 74 // FIXME: Widget is always toplevel, unless it's a popup. We may be able |
| 75 // to get rid of this once we abstract popups into a WebKit API. | 75 // to get rid of this once we abstract popups into a WebKit API. |
| 76 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y /
scale)); | 76 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y /
scale)); |
| 77 m_globalPosition = IntPoint(e.globalX, e.globalY); | 77 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 78 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale); | 78 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale); |
| 79 m_button = static_cast<MouseButton>(e.button); | 79 m_button = static_cast<MouseButton>(e.button); |
| 80 | 80 |
| 81 m_modifiers = 0; | 81 m_modifiers = 0; |
| 82 if (e.modifiers & WebInputEvent::ShiftKey) | 82 if (e.modifiers & WebInputEvent::ShiftKey) |
| 83 m_modifiers |= PlatformEvent::ShiftKey; | 83 m_modifiers |= PlatformEvent::ShiftKey; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 108 | 108 |
| 109 default: | 109 default: |
| 110 ASSERT_NOT_REACHED(); | 110 ASSERT_NOT_REACHED(); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 // PlatformWheelEventBuilder -------------------------------------------------- | 114 // PlatformWheelEventBuilder -------------------------------------------------- |
| 115 | 115 |
| 116 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) | 116 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) |
| 117 { | 117 { |
| 118 float scale = widgetScaleFactor(widget); | 118 float scale = widgetInputEventsScaleFactor(widget); |
| 119 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y /
scale)); | 119 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y /
scale)); |
| 120 m_globalPosition = IntPoint(e.globalX, e.globalY); | 120 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 121 m_deltaX = e.deltaX; | 121 m_deltaX = e.deltaX; |
| 122 m_deltaY = e.deltaY; | 122 m_deltaY = e.deltaY; |
| 123 m_wheelTicksX = e.wheelTicksX; | 123 m_wheelTicksX = e.wheelTicksX; |
| 124 m_wheelTicksY = e.wheelTicksY; | 124 m_wheelTicksY = e.wheelTicksY; |
| 125 m_granularity = e.scrollByPage ? | 125 m_granularity = e.scrollByPage ? |
| 126 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; | 126 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; |
| 127 | 127 |
| 128 m_type = PlatformEvent::Wheel; | 128 m_type = PlatformEvent::Wheel; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 145 m_scrollCount = 0; | 145 m_scrollCount = 0; |
| 146 m_unacceleratedScrollingDeltaX = e.deltaX; | 146 m_unacceleratedScrollingDeltaX = e.deltaX; |
| 147 m_unacceleratedScrollingDeltaY = e.deltaY; | 147 m_unacceleratedScrollingDeltaY = e.deltaY; |
| 148 #endif | 148 #endif |
| 149 } | 149 } |
| 150 | 150 |
| 151 // PlatformGestureEventBuilder -------------------------------------------------
- | 151 // PlatformGestureEventBuilder -------------------------------------------------
- |
| 152 | 152 |
| 153 PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
ebGestureEvent& e) | 153 PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
ebGestureEvent& e) |
| 154 { | 154 { |
| 155 float scale = widgetScaleFactor(widget); | 155 float scale = widgetInputEventsScaleFactor(widget); |
| 156 switch (e.type) { | 156 switch (e.type) { |
| 157 case WebInputEvent::GestureScrollBegin: | 157 case WebInputEvent::GestureScrollBegin: |
| 158 m_type = PlatformEvent::GestureScrollBegin; | 158 m_type = PlatformEvent::GestureScrollBegin; |
| 159 break; | 159 break; |
| 160 case WebInputEvent::GestureScrollEnd: | 160 case WebInputEvent::GestureScrollEnd: |
| 161 m_type = PlatformEvent::GestureScrollEnd; | 161 m_type = PlatformEvent::GestureScrollEnd; |
| 162 break; | 162 break; |
| 163 case WebInputEvent::GestureScrollUpdate: | 163 case WebInputEvent::GestureScrollUpdate: |
| 164 m_type = PlatformEvent::GestureScrollUpdate; | 164 m_type = PlatformEvent::GestureScrollUpdate; |
| 165 m_deltaX = e.data.scrollUpdate.deltaX / scale; | 165 m_deltaX = e.data.scrollUpdate.deltaX / scale; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 return WebTouchPoint::StateCancelled; | 376 return WebTouchPoint::StateCancelled; |
| 377 if (type == eventNames().touchstartEvent) | 377 if (type == eventNames().touchstartEvent) |
| 378 return WebTouchPoint::StatePressed; | 378 return WebTouchPoint::StatePressed; |
| 379 if (type == eventNames().touchmoveEvent) | 379 if (type == eventNames().touchmoveEvent) |
| 380 return WebTouchPoint::StateMoved; | 380 return WebTouchPoint::StateMoved; |
| 381 return WebTouchPoint::StateUndefined; | 381 return WebTouchPoint::StateUndefined; |
| 382 } | 382 } |
| 383 | 383 |
| 384 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) | 384 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) |
| 385 { | 385 { |
| 386 float scale = widgetScaleFactor(widget); | 386 float scale = widgetInputEventsScaleFactor(widget); |
| 387 m_id = point.id; | 387 m_id = point.id; |
| 388 m_state = toPlatformTouchPointState(point.state); | 388 m_state = toPlatformTouchPointState(point.state); |
| 389 m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scal
e, point.position.y / scale)); | 389 m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scal
e, point.position.y / scale)); |
| 390 m_screenPos = point.screenPosition; | 390 m_screenPos = point.screenPosition; |
| 391 m_radiusY = point.radiusY / scale; | 391 m_radiusY = point.radiusY / scale; |
| 392 m_radiusX = point.radiusX / scale; | 392 m_radiusX = point.radiusX / scale; |
| 393 m_rotationAngle = point.rotationAngle; | 393 m_rotationAngle = point.rotationAngle; |
| 394 m_force = point.force; | 394 m_force = point.force; |
| 395 } | 395 } |
| 396 | 396 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 if (event.modifiers() & PlatformEvent::AltKey) | 559 if (event.modifiers() & PlatformEvent::AltKey) |
| 560 modifiers |= AltKey; | 560 modifiers |= AltKey; |
| 561 if (event.modifiers() & PlatformEvent::MetaKey) | 561 if (event.modifiers() & PlatformEvent::MetaKey) |
| 562 modifiers |= MetaKey; | 562 modifiers |= MetaKey; |
| 563 | 563 |
| 564 timeStampSeconds = event.timestamp(); | 564 timeStampSeconds = event.timestamp(); |
| 565 | 565 |
| 566 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 566 // FIXME: Widget is always toplevel, unless it's a popup. We may be able |
| 567 // to get rid of this once we abstract popups into a WebKit API. | 567 // to get rid of this once we abstract popups into a WebKit API. |
| 568 IntPoint position = widget->convertToContainingWindow(event.position()); | 568 IntPoint position = widget->convertToContainingWindow(event.position()); |
| 569 float scale = widgetScaleFactor(widget); | 569 float scale = widgetInputEventsScaleFactor(widget); |
| 570 position.scale(scale, scale); | 570 position.scale(scale, scale); |
| 571 x = position.x(); | 571 x = position.x(); |
| 572 y = position.y(); | 572 y = position.y(); |
| 573 globalX = event.globalPosition().x(); | 573 globalX = event.globalPosition().x(); |
| 574 globalY = event.globalPosition().y(); | 574 globalY = event.globalPosition().y(); |
| 575 movementX = event.movementDelta().x() * scale; | 575 movementX = event.movementDelta().x() * scale; |
| 576 movementY = event.movementDelta().y() * scale; | 576 movementY = event.movementDelta().y() * scale; |
| 577 | 577 |
| 578 button = static_cast<Button>(event.button()); | 578 button = static_cast<Button>(event.button()); |
| 579 clickCount = event.clickCount(); | 579 clickCount = event.clickCount(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 modifiers = getWebInputModifiers(event); | 743 modifiers = getWebInputModifiers(event); |
| 744 | 744 |
| 745 globalX = event.screenX(); | 745 globalX = event.screenX(); |
| 746 globalY = event.screenY(); | 746 globalY = event.screenY(); |
| 747 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 747 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
| 748 x = localPoint.x(); | 748 x = localPoint.x(); |
| 749 y = localPoint.y(); | 749 y = localPoint.y(); |
| 750 } | 750 } |
| 751 | 751 |
| 752 } // namespace WebKit | 752 } // namespace WebKit |
| OLD | NEW |