| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 offset = rootView->inputEventsOffsetForEmulation(); | 80 offset = rootView->inputEventsOffsetForEmulation(); |
| 81 pinchViewport = flooredIntPoint(rootView->page()->frameHost().pinchV
iewport().visibleRect().location()); | 81 pinchViewport = flooredIntPoint(rootView->page()->frameHost().pinchV
iewport().visibleRect().location()); |
| 82 overscrollOffset = rootView->elasticOverscroll(); | 82 overscrollOffset = rootView->elasticOverscroll(); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 return FloatPoint( | 85 return FloatPoint( |
| 86 (point.x() - offset.width()) / scale + pinchViewport.x() + overscrollOff
set.width(), | 86 (point.x() - offset.width()) / scale + pinchViewport.x() + overscrollOff
set.width(), |
| 87 (point.y() - offset.height()) / scale + pinchViewport.y() + overscrollOf
fset.height()); | 87 (point.y() - offset.height()) / scale + pinchViewport.y() + overscrollOf
fset.height()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 static int toWebEventModifiers(unsigned platformModifiers) | |
| 91 { | |
| 92 int newModifiers = 0; | |
| 93 if (platformModifiers & PlatformEvent::ShiftKey) | |
| 94 newModifiers |= WebInputEvent::ShiftKey; | |
| 95 if (platformModifiers & PlatformEvent::CtrlKey) | |
| 96 newModifiers |= WebInputEvent::ControlKey; | |
| 97 if (platformModifiers & PlatformEvent::AltKey) | |
| 98 newModifiers |= WebInputEvent::AltKey; | |
| 99 if (platformModifiers & PlatformEvent::MetaKey) | |
| 100 newModifiers |= WebInputEvent::MetaKey; | |
| 101 return newModifiers; | |
| 102 } | |
| 103 | |
| 104 static unsigned toPlatformEventModifiers(int webModifiers) | 90 static unsigned toPlatformEventModifiers(int webModifiers) |
| 105 { | 91 { |
| 106 unsigned newModifiers = 0; | 92 unsigned newModifiers = 0; |
| 107 if (webModifiers & WebInputEvent::ShiftKey) | 93 if (webModifiers & WebInputEvent::ShiftKey) |
| 108 newModifiers |= PlatformEvent::ShiftKey; | 94 newModifiers |= PlatformEvent::ShiftKey; |
| 109 if (webModifiers & WebInputEvent::ControlKey) | 95 if (webModifiers & WebInputEvent::ControlKey) |
| 110 newModifiers |= PlatformEvent::CtrlKey; | 96 newModifiers |= PlatformEvent::CtrlKey; |
| 111 if (webModifiers & WebInputEvent::AltKey) | 97 if (webModifiers & WebInputEvent::AltKey) |
| 112 newModifiers |= PlatformEvent::AltKey; | 98 newModifiers |= PlatformEvent::AltKey; |
| 113 if (webModifiers & WebInputEvent::MetaKey) | 99 if (webModifiers & WebInputEvent::MetaKey) |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 577 |
| 592 button = WebMouseEvent::ButtonLeft; | 578 button = WebMouseEvent::ButtonLeft; |
| 593 modifiers |= WebInputEvent::LeftButtonDown; | 579 modifiers |= WebInputEvent::LeftButtonDown; |
| 594 clickCount = (type == MouseDown || type == MouseUp); | 580 clickCount = (type == MouseDown || type == MouseUp); |
| 595 | 581 |
| 596 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(touch->absolute
Location(), *layoutObject); | 582 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(touch->absolute
Location(), *layoutObject); |
| 597 x = localPoint.x(); | 583 x = localPoint.x(); |
| 598 y = localPoint.y(); | 584 y = localPoint.y(); |
| 599 } | 585 } |
| 600 | 586 |
| 601 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const PlatformM
ouseEvent& event) | |
| 602 { | |
| 603 switch (event.type()) { | |
| 604 case PlatformEvent::MouseMoved: | |
| 605 type = MouseMove; | |
| 606 break; | |
| 607 case PlatformEvent::MousePressed: | |
| 608 type = MouseDown; | |
| 609 break; | |
| 610 case PlatformEvent::MouseReleased: | |
| 611 type = MouseUp; | |
| 612 break; | |
| 613 default: | |
| 614 ASSERT_NOT_REACHED(); | |
| 615 type = Undefined; | |
| 616 return; | |
| 617 } | |
| 618 | |
| 619 modifiers = toWebEventModifiers(event.modifiers()); | |
| 620 timeStampSeconds = event.timestamp(); | |
| 621 | |
| 622 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | |
| 623 // to get rid of this once we abstract popups into a WebKit API. | |
| 624 IntPoint position = widget->convertToContainingWindow(event.position()); | |
| 625 float scale = 1; | |
| 626 if (widget) { | |
| 627 FrameView* rootView = toFrameView(widget->root()); | |
| 628 if (rootView) | |
| 629 scale = rootView->inputEventsScaleFactor(); | |
| 630 } | |
| 631 position.scale(scale, scale); | |
| 632 x = position.x(); | |
| 633 y = position.y(); | |
| 634 globalX = event.globalPosition().x(); | |
| 635 globalY = event.globalPosition().y(); | |
| 636 movementX = event.movementDelta().x() * scale; | |
| 637 movementY = event.movementDelta().y() * scale; | |
| 638 | |
| 639 button = static_cast<Button>(event.button()); | |
| 640 clickCount = event.clickCount(); | |
| 641 } | |
| 642 | |
| 643 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const
LayoutObject* layoutObject, const WheelEvent& event) | 587 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const
LayoutObject* layoutObject, const WheelEvent& event) |
| 644 { | 588 { |
| 645 if (event.type() != EventTypeNames::wheel && event.type() != EventTypeNames:
:mousewheel) | 589 if (event.type() != EventTypeNames::wheel && event.type() != EventTypeNames:
:mousewheel) |
| 646 return; | 590 return; |
| 647 type = WebInputEvent::MouseWheel; | 591 type = WebInputEvent::MouseWheel; |
| 648 updateWebMouseEventFromCoreMouseEvent(event, widget, *layoutObject, *this); | 592 updateWebMouseEventFromCoreMouseEvent(event, widget, *layoutObject, *this); |
| 649 deltaX = -event.deltaX(); | 593 deltaX = -event.deltaX(); |
| 650 deltaY = -event.deltaY(); | 594 deltaY = -event.deltaY(); |
| 651 wheelTicksX = event.ticksX(); | 595 wheelTicksX = event.ticksX(); |
| 652 wheelTicksY = event.ticksY(); | 596 wheelTicksY = event.ticksY(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 return WebInputEvent::KeyDown; | 644 return WebInputEvent::KeyDown; |
| 701 case PlatformEvent::RawKeyDown: | 645 case PlatformEvent::RawKeyDown: |
| 702 return WebInputEvent::RawKeyDown; | 646 return WebInputEvent::RawKeyDown; |
| 703 case PlatformEvent::Char: | 647 case PlatformEvent::Char: |
| 704 return WebInputEvent::Char; | 648 return WebInputEvent::Char; |
| 705 default: | 649 default: |
| 706 return WebInputEvent::Undefined; | 650 return WebInputEvent::Undefined; |
| 707 } | 651 } |
| 708 } | 652 } |
| 709 | 653 |
| 710 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev
ent) | |
| 711 { | |
| 712 type = toWebKeyboardEventType(event.type()); | |
| 713 modifiers = toWebEventModifiers(event.modifiers()); | |
| 714 if (event.isAutoRepeat()) | |
| 715 modifiers |= WebInputEvent::IsAutoRepeat; | |
| 716 if (event.isKeypad()) | |
| 717 modifiers |= WebInputEvent::IsKeyPad; | |
| 718 isSystemKey = event.isSystemKey(); | |
| 719 nativeKeyCode = event.nativeVirtualKeyCode(); | |
| 720 domCode = Platform::current()->domEnumFromCodeString(event.code()); | |
| 721 | |
| 722 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode()
); | |
| 723 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode
()); | |
| 724 | |
| 725 event.text().copyTo(text, 0, textLengthCap); | |
| 726 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap); | |
| 727 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_
cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length())); | |
| 728 } | |
| 729 | |
| 730 static WebTouchPoint toWebTouchPoint(const Touch* touch, const LayoutObject* lay
outObject, WebTouchPoint::State state) | 654 static WebTouchPoint toWebTouchPoint(const Touch* touch, const LayoutObject* lay
outObject, WebTouchPoint::State state) |
| 731 { | 655 { |
| 732 WebTouchPoint point; | 656 WebTouchPoint point; |
| 733 point.id = touch->identifier(); | 657 point.id = touch->identifier(); |
| 734 point.screenPosition = touch->screenLocation(); | 658 point.screenPosition = touch->screenLocation(); |
| 735 point.position = convertAbsoluteLocationForLayoutObjectFloat(touch->absolute
Location(), *layoutObject); | 659 point.position = convertAbsoluteLocationForLayoutObjectFloat(touch->absolute
Location(), *layoutObject); |
| 736 point.radiusX = touch->radiusX(); | 660 point.radiusX = touch->radiusX(); |
| 737 point.radiusY = touch->radiusY(); | 661 point.radiusY = touch->radiusY(); |
| 738 point.rotationAngle = touch->webkitRotationAngle(); | 662 point.rotationAngle = touch->webkitRotationAngle(); |
| 739 point.force = touch->force(); | 663 point.force = touch->force(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 modifiers = getWebInputModifiers(event); | 739 modifiers = getWebInputModifiers(event); |
| 816 | 740 |
| 817 globalX = event.screenX(); | 741 globalX = event.screenX(); |
| 818 globalY = event.screenY(); | 742 globalY = event.screenY(); |
| 819 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL
ocation(), *layoutObject); | 743 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL
ocation(), *layoutObject); |
| 820 x = localPoint.x(); | 744 x = localPoint.x(); |
| 821 y = localPoint.y(); | 745 y = localPoint.y(); |
| 822 } | 746 } |
| 823 | 747 |
| 824 } // namespace blink | 748 } // namespace blink |
| OLD | NEW |