| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // MakePlatformMouseEvent ----------------------------------------------------- | 75 // MakePlatformMouseEvent ----------------------------------------------------- |
| 76 | 76 |
| 77 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) | 77 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) |
| 78 { | 78 { |
| 79 float scale = widgetInputEventsScaleFactor(widget); | 79 float scale = widgetInputEventsScaleFactor(widget); |
| 80 IntSize offset = widgetInputEventsOffset(widget); | 80 IntSize offset = widgetInputEventsOffset(widget); |
| 81 | 81 |
| 82 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 82 // FIXME: Widget is always toplevel, unless it's a popup. We may be able |
| 83 // to get rid of this once we abstract popups into a WebKit API. | 83 // to get rid of this once we abstract popups into a WebKit API. |
| 84 m_position = widget->convertFromContainingWindow( | 84 m_position = widget->convertFromContainingView( |
| 85 IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale
)); | 85 IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale
)); |
| 86 m_globalPosition = IntPoint(e.globalX, e.globalY); | 86 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 87 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale); | 87 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale); |
| 88 m_button = static_cast<MouseButton>(e.button); | 88 m_button = static_cast<MouseButton>(e.button); |
| 89 | 89 |
| 90 m_modifiers = 0; | 90 m_modifiers = 0; |
| 91 if (e.modifiers & WebInputEvent::ShiftKey) | 91 if (e.modifiers & WebInputEvent::ShiftKey) |
| 92 m_modifiers |= PlatformEvent::ShiftKey; | 92 m_modifiers |= PlatformEvent::ShiftKey; |
| 93 if (e.modifiers & WebInputEvent::ControlKey) | 93 if (e.modifiers & WebInputEvent::ControlKey) |
| 94 m_modifiers |= PlatformEvent::CtrlKey; | 94 m_modifiers |= PlatformEvent::CtrlKey; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 // PlatformWheelEventBuilder -------------------------------------------------- | 123 // PlatformWheelEventBuilder -------------------------------------------------- |
| 124 | 124 |
| 125 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) | 125 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) |
| 126 { | 126 { |
| 127 float scale = widgetInputEventsScaleFactor(widget); | 127 float scale = widgetInputEventsScaleFactor(widget); |
| 128 IntSize offset = widgetInputEventsOffset(widget); | 128 IntSize offset = widgetInputEventsOffset(widget); |
| 129 | 129 |
| 130 m_position = widget->convertFromContainingWindow( | 130 m_position = widget->convertFromContainingView( |
| 131 IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale
)); | 131 IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale
)); |
| 132 m_globalPosition = IntPoint(e.globalX, e.globalY); | 132 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 133 m_deltaX = e.deltaX; | 133 m_deltaX = e.deltaX; |
| 134 m_deltaY = e.deltaY; | 134 m_deltaY = e.deltaY; |
| 135 m_wheelTicksX = e.wheelTicksX; | 135 m_wheelTicksX = e.wheelTicksX; |
| 136 m_wheelTicksY = e.wheelTicksY; | 136 m_wheelTicksY = e.wheelTicksY; |
| 137 m_granularity = e.scrollByPage ? | 137 m_granularity = e.scrollByPage ? |
| 138 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; | 138 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; |
| 139 | 139 |
| 140 m_type = PlatformEvent::Wheel; | 140 m_type = PlatformEvent::Wheel; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 case WebInputEvent::GesturePinchEnd: | 238 case WebInputEvent::GesturePinchEnd: |
| 239 m_type = PlatformEvent::GesturePinchEnd; | 239 m_type = PlatformEvent::GesturePinchEnd; |
| 240 break; | 240 break; |
| 241 case WebInputEvent::GesturePinchUpdate: | 241 case WebInputEvent::GesturePinchUpdate: |
| 242 m_type = PlatformEvent::GesturePinchUpdate; | 242 m_type = PlatformEvent::GesturePinchUpdate; |
| 243 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; | 243 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; |
| 244 break; | 244 break; |
| 245 default: | 245 default: |
| 246 ASSERT_NOT_REACHED(); | 246 ASSERT_NOT_REACHED(); |
| 247 } | 247 } |
| 248 m_position = widget->convertFromContainingWindow( | 248 m_position = widget->convertFromContainingView( |
| 249 IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale
)); | 249 IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale
)); |
| 250 m_globalPosition = IntPoint(e.globalX, e.globalY); | 250 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 251 m_timestamp = e.timeStampSeconds; | 251 m_timestamp = e.timeStampSeconds; |
| 252 | 252 |
| 253 m_modifiers = 0; | 253 m_modifiers = 0; |
| 254 if (e.modifiers & WebInputEvent::ShiftKey) | 254 if (e.modifiers & WebInputEvent::ShiftKey) |
| 255 m_modifiers |= PlatformEvent::ShiftKey; | 255 m_modifiers |= PlatformEvent::ShiftKey; |
| 256 if (e.modifiers & WebInputEvent::ControlKey) | 256 if (e.modifiers & WebInputEvent::ControlKey) |
| 257 m_modifiers |= PlatformEvent::CtrlKey; | 257 m_modifiers |= PlatformEvent::CtrlKey; |
| 258 if (e.modifiers & WebInputEvent::AltKey) | 258 if (e.modifiers & WebInputEvent::AltKey) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 | 406 |
| 407 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) | 407 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) |
| 408 { | 408 { |
| 409 float scale = 1.0f / widgetInputEventsScaleFactor(widget); | 409 float scale = 1.0f / widgetInputEventsScaleFactor(widget); |
| 410 IntSize offset = widgetInputEventsOffset(widget); | 410 IntSize offset = widgetInputEventsOffset(widget); |
| 411 m_id = point.id; | 411 m_id = point.id; |
| 412 m_state = toPlatformTouchPointState(point.state); | 412 m_state = toPlatformTouchPointState(point.state); |
| 413 FloatPoint pos = (point.position - offset).scaledBy(scale); | 413 FloatPoint pos = (point.position - offset).scaledBy(scale); |
| 414 IntPoint flooredPoint = flooredIntPoint(pos); | 414 IntPoint flooredPoint = flooredIntPoint(pos); |
| 415 // This assumes convertFromContainingWindow does only translations, not scal
es. | 415 // This assumes convertFromContainingView does only translations, not scales
. |
| 416 m_pos = widget->convertFromContainingWindow(flooredPoint) + (pos - flooredPo
int); | 416 m_pos = widget->convertFromContainingView(flooredPoint) + (pos - flooredPoin
t); |
| 417 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y); | 417 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y); |
| 418 m_radius = FloatSize(point.radiusX, point.radiusY).scaledBy(scale); | 418 m_radius = FloatSize(point.radiusX, point.radiusY).scaledBy(scale); |
| 419 m_rotationAngle = point.rotationAngle; | 419 m_rotationAngle = point.rotationAngle; |
| 420 m_force = point.force; | 420 m_force = point.force; |
| 421 } | 421 } |
| 422 | 422 |
| 423 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo
uchEvent& event) | 423 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo
uchEvent& event) |
| 424 { | 424 { |
| 425 m_type = toPlatformTouchEventType(event.type); | 425 m_type = toPlatformTouchEventType(event.type); |
| 426 | 426 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const RenderObject& renderObject) | 464 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const RenderObject& renderObject) |
| 465 { | 465 { |
| 466 return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location,
renderObject)); | 466 return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location,
renderObject)); |
| 467 } | 467 } |
| 468 | 468 |
| 469 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget& widget, const RenderObject& renderObject, WebMouseEvent& webEven
t) | 469 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget& widget, const RenderObject& renderObject, WebMouseEvent& webEven
t) |
| 470 { | 470 { |
| 471 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; | 471 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; |
| 472 webEvent.modifiers = getWebInputModifiers(event); | 472 webEvent.modifiers = getWebInputModifiers(event); |
| 473 | 473 |
| 474 FrameView* view = toFrameView(widget.parent()); | |
| 475 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); | 474 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); |
| 476 if (view) | 475 windowPoint = widget.convertToContainingView(windowPoint); |
| 477 windowPoint = view->contentsToWindow(windowPoint); | |
| 478 webEvent.globalX = event.screenX(); | 476 webEvent.globalX = event.screenX(); |
| 479 webEvent.globalY = event.screenY(); | 477 webEvent.globalY = event.screenY(); |
| 480 webEvent.windowX = windowPoint.x(); | 478 webEvent.windowX = windowPoint.x(); |
| 481 webEvent.windowY = windowPoint.y(); | 479 webEvent.windowY = windowPoint.y(); |
| 482 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); | 480 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); |
| 483 webEvent.x = localPoint.x(); | 481 webEvent.x = localPoint.x(); |
| 484 webEvent.y = localPoint.y(); | 482 webEvent.y = localPoint.y(); |
| 485 } | 483 } |
| 486 | 484 |
| 487 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const RenderObj
ect* renderObject, const MouseEvent& event) | 485 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const RenderObj
ect* renderObject, const MouseEvent& event) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 type = MouseMove; | 550 type = MouseMove; |
| 553 else if (event.type() == EventTypeNames::touchend) | 551 else if (event.type() == EventTypeNames::touchend) |
| 554 type = MouseUp; | 552 type = MouseUp; |
| 555 else | 553 else |
| 556 return; | 554 return; |
| 557 | 555 |
| 558 timeStampSeconds = event.timeStamp() / millisPerSecond; | 556 timeStampSeconds = event.timeStamp() / millisPerSecond; |
| 559 modifiers = getWebInputModifiers(event); | 557 modifiers = getWebInputModifiers(event); |
| 560 | 558 |
| 561 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. | 559 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. |
| 562 FrameView* view = toFrameView(widget->parent()); | |
| 563 IntPoint windowPoint = roundedIntPoint(touch->absoluteLocation()); | 560 IntPoint windowPoint = roundedIntPoint(touch->absoluteLocation()); |
| 564 if (view) | 561 windowPoint = widget->convertToContainingView(windowPoint); |
| 565 windowPoint = view->contentsToWindow(windowPoint); | |
| 566 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); | 562 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); |
| 567 globalX = screenPoint.x(); | 563 globalX = screenPoint.x(); |
| 568 globalY = screenPoint.y(); | 564 globalY = screenPoint.y(); |
| 569 windowX = windowPoint.x(); | 565 windowX = windowPoint.x(); |
| 570 windowY = windowPoint.y(); | 566 windowY = windowPoint.y(); |
| 571 | 567 |
| 572 button = WebMouseEvent::ButtonLeft; | 568 button = WebMouseEvent::ButtonLeft; |
| 573 modifiers |= WebInputEvent::LeftButtonDown; | 569 modifiers |= WebInputEvent::LeftButtonDown; |
| 574 clickCount = (type == MouseDown || type == MouseUp); | 570 clickCount = (type == MouseDown || type == MouseUp); |
| 575 | 571 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 601 modifiers |= ShiftKey; | 597 modifiers |= ShiftKey; |
| 602 if (event.modifiers() & PlatformEvent::CtrlKey) | 598 if (event.modifiers() & PlatformEvent::CtrlKey) |
| 603 modifiers |= ControlKey; | 599 modifiers |= ControlKey; |
| 604 if (event.modifiers() & PlatformEvent::AltKey) | 600 if (event.modifiers() & PlatformEvent::AltKey) |
| 605 modifiers |= AltKey; | 601 modifiers |= AltKey; |
| 606 if (event.modifiers() & PlatformEvent::MetaKey) | 602 if (event.modifiers() & PlatformEvent::MetaKey) |
| 607 modifiers |= MetaKey; | 603 modifiers |= MetaKey; |
| 608 | 604 |
| 609 timeStampSeconds = event.timestamp(); | 605 timeStampSeconds = event.timestamp(); |
| 610 | 606 |
| 611 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 607 IntPoint position = event.position(); |
| 612 // to get rid of this once we abstract popups into a WebKit API. | |
| 613 IntPoint position = widget->convertToContainingWindow(event.position()); | |
| 614 float scale = widgetInputEventsScaleFactor(widget); | 608 float scale = widgetInputEventsScaleFactor(widget); |
| 615 position.scale(scale, scale); | 609 position.scale(scale, scale); |
| 616 x = position.x(); | 610 x = position.x(); |
| 617 y = position.y(); | 611 y = position.y(); |
| 618 globalX = event.globalPosition().x(); | 612 globalX = event.globalPosition().x(); |
| 619 globalY = event.globalPosition().y(); | 613 globalY = event.globalPosition().y(); |
| 620 movementX = event.movementDelta().x() * scale; | 614 movementX = event.movementDelta().x() * scale; |
| 621 movementY = event.movementDelta().y() * scale; | 615 movementY = event.movementDelta().y() * scale; |
| 622 | 616 |
| 623 button = static_cast<Button>(event.button()); | 617 button = static_cast<Button>(event.button()); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 modifiers = getWebInputModifiers(event); | 784 modifiers = getWebInputModifiers(event); |
| 791 | 785 |
| 792 globalX = event.screenX(); | 786 globalX = event.screenX(); |
| 793 globalY = event.screenY(); | 787 globalY = event.screenY(); |
| 794 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 788 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
| 795 x = localPoint.x(); | 789 x = localPoint.x(); |
| 796 y = localPoint.y(); | 790 y = localPoint.y(); |
| 797 } | 791 } |
| 798 | 792 |
| 799 } // namespace blink | 793 } // namespace blink |
| OLD | NEW |