PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e) { m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y)))); m_globalPosition = IntPoint(e.globalX, e.globalY); m_deltaX = scaleDeltaToWindow(widget, e.deltaX); m_deltaY = scaleDeltaToWindow(widget, e.deltaY); m_wheelTicksX = e.wheelTicksX; m_wheelTicksY = e.wheelTicksY; m_granularity = e.scrollByPage ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent; m_type = PlatformEvent::Wheel; m_timestamp = e.timeStampSeconds; m_modifiers = e.modifiers; m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; m_canScroll = e.canScroll; m_resendingPluginId = e.resendingPluginId; m_railsMode = static_cast<PlatformEvent::RailsMode>(e.railsMode); #if OS(MACOSX) m_phase = static_cast<PlatformWheelEventPhase>(e.phase); m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); m_canRubberbandLeft = e.canRubberbandLeft; m_canRubberbandRight = e.canRubberbandRight; #endif }
// TODO(mustaq): Add tests for this. PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e) { // FIXME: Widget is always toplevel, unless it's a popup. We may be able // to get rid of this once we abstract popups into a WebKit API. m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToRootFrame(widget, IntPoint(e.x, e.y)))); m_globalPosition = IntPoint(e.globalX, e.globalY); m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), scaleDeltaToWindow(widget, e.movementY)); m_button = static_cast<MouseButton>(e.button); m_modifiers = e.modifiers; m_timestamp = e.timeStampSeconds; m_clickCount = e.clickCount; m_pointerProperties = static_cast<WebPointerProperties>(e); switch (e.type) { case WebInputEvent::MouseMove: case WebInputEvent::MouseLeave: // synthesize a move event m_type = PlatformEvent::MouseMoved; break; case WebInputEvent::MouseDown: m_type = PlatformEvent::MousePressed; break; case WebInputEvent::MouseUp: m_type = PlatformEvent::MouseReleased; // The MouseEvent spec requires that buttons indicates the state // immediately after the event takes place. To ensure consistency // between platforms here, we explicitly clear the button that is // in the process of being released. m_modifiers &= ~toPlatformModifierFrom(e.button); break; default: ASSERT_NOT_REACHED(); } }
static FloatSize scaleSizeToWindow(const Widget* widget, FloatSize size) { return FloatSize(scaleDeltaToWindow(widget, size.width()), scaleDeltaToWindow(widget, size.height())); }
PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const WebGestureEvent& e) { switch (e.type) { case WebInputEvent::GestureScrollBegin: m_type = PlatformEvent::GestureScrollBegin; m_data.m_scroll.m_resendingPluginId = e.resendingPluginId; break; case WebInputEvent::GestureScrollEnd: m_type = PlatformEvent::GestureScrollEnd; m_data.m_scroll.m_resendingPluginId = e.resendingPluginId; break; case WebInputEvent::GestureFlingStart: m_type = PlatformEvent::GestureFlingStart; m_data.m_scroll.m_velocityX = e.data.flingStart.velocityX; m_data.m_scroll.m_velocityY = e.data.flingStart.velocityY; break; case WebInputEvent::GestureScrollUpdate: m_type = PlatformEvent::GestureScrollUpdate; m_data.m_scroll.m_resendingPluginId = e.resendingPluginId; m_data.m_scroll.m_deltaX = scaleDeltaToWindow(widget, e.data.scrollUpdate.deltaX); m_data.m_scroll.m_deltaY = scaleDeltaToWindow(widget, e.data.scrollUpdate.deltaY); m_data.m_scroll.m_velocityX = e.data.scrollUpdate.velocityX; m_data.m_scroll.m_velocityY = e.data.scrollUpdate.velocityY; m_data.m_scroll.m_preventPropagation = e.data.scrollUpdate.preventPropagation; m_data.m_scroll.m_inertial = e.data.scrollUpdate.inertial; break; case WebInputEvent::GestureTap: m_type = PlatformEvent::GestureTap; m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.tap.width, e.data.tap.height))); m_data.m_tap.m_tapCount = e.data.tap.tapCount; break; case WebInputEvent::GestureTapUnconfirmed: m_type = PlatformEvent::GestureTapUnconfirmed; m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.tap.width, e.data.tap.height))); break; case WebInputEvent::GestureTapDown: m_type = PlatformEvent::GestureTapDown; m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.tapDown.width, e.data.tapDown.height))); break; case WebInputEvent::GestureShowPress: m_type = PlatformEvent::GestureShowPress; m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.showPress.width, e.data.showPress.height))); break; case WebInputEvent::GestureTapCancel: m_type = PlatformEvent::GestureTapDownCancel; break; case WebInputEvent::GestureDoubleTap: // DoubleTap gesture is now handled as PlatformEvent::GestureTap with tap_count = 2. So no // need to convert to a Platfrom DoubleTap gesture. But in WebViewImpl::handleGestureEvent // all WebGestureEvent are converted to PlatformGestureEvent, for completeness and not reach // the ASSERT_NOT_REACHED() at the end, convert the DoubleTap to a NoType. m_type = PlatformEvent::NoType; break; case WebInputEvent::GestureTwoFingerTap: m_type = PlatformEvent::GestureTwoFingerTap; m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.twoFingerTap.firstFingerWidth, e.data.twoFingerTap.firstFingerHeight))); break; case WebInputEvent::GestureLongPress: m_type = PlatformEvent::GestureLongPress; m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.longPress.width, e.data.longPress.height))); break; case WebInputEvent::GestureLongTap: m_type = PlatformEvent::GestureLongTap; m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.longPress.width, e.data.longPress.height))); break; case WebInputEvent::GesturePinchBegin: m_type = PlatformEvent::GesturePinchBegin; break; case WebInputEvent::GesturePinchEnd: m_type = PlatformEvent::GesturePinchEnd; break; case WebInputEvent::GesturePinchUpdate: m_type = PlatformEvent::GesturePinchUpdate; m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; break; default: ASSERT_NOT_REACHED(); } m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y)))); m_globalPosition = IntPoint(e.globalX, e.globalY); m_timestamp = e.timeStampSeconds; m_modifiers = e.modifiers; switch (e.sourceDevice) { case WebGestureDeviceTouchpad: m_source = PlatformGestureSourceTouchpad; break; case WebGestureDeviceTouchscreen: m_source = PlatformGestureSourceTouchscreen; break; case WebGestureDeviceUninitialized: ASSERT_NOT_REACHED(); } }