| 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/events/MouseEvent.h" | 38 #include "core/events/MouseEvent.h" |
| 39 #include "core/events/TouchEvent.h" | 39 #include "core/events/TouchEvent.h" |
| 40 #include "core/events/WheelEvent.h" | 40 #include "core/events/WheelEvent.h" |
| 41 #include "core/frame/FrameHost.h" | 41 #include "core/frame/FrameHost.h" |
| 42 #include "core/frame/FrameView.h" | 42 #include "core/frame/FrameView.h" |
| 43 #include "core/frame/PinchViewport.h" | 43 #include "core/frame/PinchViewport.h" |
| 44 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
| 45 #include "core/rendering/RenderObject.h" | 45 #include "core/rendering/RenderObject.h" |
| 46 #include "platform/KeyboardCodes.h" | 46 #include "platform/KeyboardCodes.h" |
| 47 #include "platform/Widget.h" | 47 #include "platform/Widget.h" |
| 48 #include "platform/scroll/ScrollView.h" | |
| 49 | 48 |
| 50 namespace blink { | 49 namespace blink { |
| 51 | 50 |
| 52 static const double millisPerSecond = 1000.0; | 51 static const double millisPerSecond = 1000.0; |
| 53 | 52 |
| 54 static float widgetInputEventsScaleFactor(const Widget* widget) | 53 static float widgetInputEventsScaleFactor(const Widget* widget) |
| 55 { | 54 { |
| 56 if (!widget) | 55 if (!widget) |
| 57 return 1; | 56 return 1; |
| 58 | 57 |
| 59 ScrollView* rootView = toScrollView(widget->root()); | 58 FrameView* rootView = toFrameView(widget->root()); |
| 60 if (!rootView) | 59 if (!rootView) |
| 61 return 1; | 60 return 1; |
| 62 | 61 |
| 63 return rootView->inputEventsScaleFactor(); | 62 return rootView->inputEventsScaleFactor(); |
| 64 } | 63 } |
| 65 | 64 |
| 66 static IntSize widgetInputEventsOffset(const Widget* widget) | 65 static IntSize widgetInputEventsOffset(const Widget* widget) |
| 67 { | 66 { |
| 68 if (!widget) | 67 if (!widget) |
| 69 return IntSize(); | 68 return IntSize(); |
| 70 ScrollView* rootView = toScrollView(widget->root()); | 69 FrameView* rootView = toFrameView(widget->root()); |
| 71 if (!rootView) | 70 if (!rootView) |
| 72 return IntSize(); | 71 return IntSize(); |
| 73 | 72 |
| 74 return rootView->inputEventsOffsetForEmulation(); | 73 return rootView->inputEventsOffsetForEmulation(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 static IntPoint pinchViewportOffset(const Widget* widget) | 76 static IntPoint pinchViewportOffset(const Widget* widget) |
| 78 { | 77 { |
| 79 // Event position needs to be adjusted by the pinch viewport's offset within
the | 78 // Event position needs to be adjusted by the pinch viewport's offset within
the |
| 80 // main frame before being passed into the widget's convertFromContainingWin
dow. | 79 // main frame before being passed into the widget's convertFromContainingWin
dow. |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const RenderObject& renderObject) | 481 static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
on, const RenderObject& renderObject) |
| 483 { | 482 { |
| 484 return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location,
renderObject)); | 483 return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location,
renderObject)); |
| 485 } | 484 } |
| 486 | 485 |
| 487 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget& widget, const RenderObject& renderObject, WebMouseEvent& webEven
t) | 486 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget& widget, const RenderObject& renderObject, WebMouseEvent& webEven
t) |
| 488 { | 487 { |
| 489 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; | 488 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; |
| 490 webEvent.modifiers = getWebInputModifiers(event); | 489 webEvent.modifiers = getWebInputModifiers(event); |
| 491 | 490 |
| 492 ScrollView* view = toScrollView(widget.parent()); | 491 FrameView* view = toFrameView(widget.parent()); |
| 493 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); | 492 IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absolute
Location().y()); |
| 494 if (view) | 493 if (view) |
| 495 windowPoint = view->contentsToWindow(windowPoint); | 494 windowPoint = view->contentsToWindow(windowPoint); |
| 496 webEvent.globalX = event.screenX(); | 495 webEvent.globalX = event.screenX(); |
| 497 webEvent.globalY = event.screenY(); | 496 webEvent.globalY = event.screenY(); |
| 498 webEvent.windowX = windowPoint.x(); | 497 webEvent.windowX = windowPoint.x(); |
| 499 webEvent.windowY = windowPoint.y(); | 498 webEvent.windowY = windowPoint.y(); |
| 500 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); | 499 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), renderObject); |
| 501 webEvent.x = localPoint.x(); | 500 webEvent.x = localPoint.x(); |
| 502 webEvent.y = localPoint.y(); | 501 webEvent.y = localPoint.y(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 type = MouseMove; | 571 type = MouseMove; |
| 573 else if (event.type() == EventTypeNames::touchend) | 572 else if (event.type() == EventTypeNames::touchend) |
| 574 type = MouseUp; | 573 type = MouseUp; |
| 575 else | 574 else |
| 576 return; | 575 return; |
| 577 | 576 |
| 578 timeStampSeconds = event.timeStamp() / millisPerSecond; | 577 timeStampSeconds = event.timeStamp() / millisPerSecond; |
| 579 modifiers = getWebInputModifiers(event); | 578 modifiers = getWebInputModifiers(event); |
| 580 | 579 |
| 581 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. | 580 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. |
| 582 ScrollView* view = toScrollView(widget->parent()); | 581 FrameView* view = toFrameView(widget->parent()); |
| 583 IntPoint windowPoint = roundedIntPoint(touch->absoluteLocation()); | 582 IntPoint windowPoint = roundedIntPoint(touch->absoluteLocation()); |
| 584 if (view) | 583 if (view) |
| 585 windowPoint = view->contentsToWindow(windowPoint); | 584 windowPoint = view->contentsToWindow(windowPoint); |
| 586 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); | 585 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); |
| 587 globalX = screenPoint.x(); | 586 globalX = screenPoint.x(); |
| 588 globalY = screenPoint.y(); | 587 globalY = screenPoint.y(); |
| 589 windowX = windowPoint.x(); | 588 windowX = windowPoint.x(); |
| 590 windowY = windowPoint.y(); | 589 windowY = windowPoint.y(); |
| 591 | 590 |
| 592 button = WebMouseEvent::ButtonLeft; | 591 button = WebMouseEvent::ButtonLeft; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 modifiers = getWebInputModifiers(event); | 827 modifiers = getWebInputModifiers(event); |
| 829 | 828 |
| 830 globalX = event.screenX(); | 829 globalX = event.screenX(); |
| 831 globalY = event.screenY(); | 830 globalY = event.screenY(); |
| 832 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 831 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
| 833 x = localPoint.x(); | 832 x = localPoint.x(); |
| 834 y = localPoint.y(); | 833 y = localPoint.y(); |
| 835 } | 834 } |
| 836 | 835 |
| 837 } // namespace blink | 836 } // namespace blink |
| OLD | NEW |