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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "core/frame/VisualViewport.h" | 43 #include "core/frame/VisualViewport.h" |
44 #include "core/layout/LayoutObject.h" | 44 #include "core/layout/LayoutObject.h" |
45 #include "core/page/ChromeClient.h" | 45 #include "core/page/ChromeClient.h" |
46 #include "core/page/Page.h" | 46 #include "core/page/Page.h" |
47 #include "platform/KeyboardCodes.h" | 47 #include "platform/KeyboardCodes.h" |
48 #include "platform/Widget.h" | 48 #include "platform/Widget.h" |
49 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
50 | 50 |
51 namespace blink { | 51 namespace blink { |
52 | 52 |
53 static const double millisPerSecond = 1000.0; | |
54 | |
55 static float scaleDeltaToWindow(const Widget* widget, float delta) | 53 static float scaleDeltaToWindow(const Widget* widget, float delta) |
56 { | 54 { |
57 float scale = 1; | 55 float scale = 1; |
58 if (widget) { | 56 if (widget) { |
59 FrameView* rootView = toFrameView(widget->root()); | 57 FrameView* rootView = toFrameView(widget->root()); |
60 if (rootView) | 58 if (rootView) |
61 scale = rootView->inputEventsScaleFactor(); | 59 scale = rootView->inputEventsScaleFactor(); |
62 } | 60 } |
63 return delta / scale; | 61 return delta / scale; |
64 } | 62 } |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 m_text = String(e.text); | 321 m_text = String(e.text); |
324 m_unmodifiedText = String(e.unmodifiedText); | 322 m_unmodifiedText = String(e.unmodifiedText); |
325 m_keyIdentifier = String(e.keyIdentifier); | 323 m_keyIdentifier = String(e.keyIdentifier); |
326 m_nativeVirtualKeyCode = e.nativeKeyCode; | 324 m_nativeVirtualKeyCode = e.nativeKeyCode; |
327 m_isSystemKey = e.isSystemKey; | 325 m_isSystemKey = e.isSystemKey; |
328 // TODO: BUG482880 Fix this initialization to lazy initialization. | 326 // TODO: BUG482880 Fix this initialization to lazy initialization. |
329 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); | 327 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); |
330 m_key = Platform::current()->domKeyStringFromEnum(e.domKey); | 328 m_key = Platform::current()->domKeyStringFromEnum(e.domKey); |
331 | 329 |
332 m_modifiers = toPlatformKeyboardEventModifiers(e.modifiers); | 330 m_modifiers = toPlatformKeyboardEventModifiers(e.modifiers); |
| 331 m_timestamp = e.timeStampSeconds; |
333 m_windowsVirtualKeyCode = e.windowsKeyCode; | 332 m_windowsVirtualKeyCode = e.windowsKeyCode; |
334 } | 333 } |
335 | 334 |
336 void PlatformKeyboardEventBuilder::setKeyType(Type type) | 335 void PlatformKeyboardEventBuilder::setKeyType(Type type) |
337 { | 336 { |
338 // According to the behavior of Webkit in Windows platform, | 337 // According to the behavior of Webkit in Windows platform, |
339 // we need to convert KeyDown to RawKeydown and Char events | 338 // we need to convert KeyDown to RawKeydown and Char events |
340 // See WebKit/WebKit/Win/WebView.cpp | 339 // See WebKit/WebKit/Win/WebView.cpp |
341 ASSERT(m_type == KeyDown); | 340 ASSERT(m_type == KeyDown); |
342 ASSERT(type == RawKeyDown || type == Char); | 341 ASSERT(type == RawKeyDown || type == Char); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 461 |
463 static IntPoint convertAbsoluteLocationForLayoutObject(const LayoutPoint& locati
on, const LayoutObject& layoutObject) | 462 static IntPoint convertAbsoluteLocationForLayoutObject(const LayoutPoint& locati
on, const LayoutObject& layoutObject) |
464 { | 463 { |
465 return roundedIntPoint(convertAbsoluteLocationForLayoutObjectFloat(location,
layoutObject)); | 464 return roundedIntPoint(convertAbsoluteLocationForLayoutObjectFloat(location,
layoutObject)); |
466 } | 465 } |
467 | 466 |
468 // FIXME: Change |widget| to const Widget& after RemoteFrames get | 467 // FIXME: Change |widget| to const Widget& after RemoteFrames get |
469 // RemoteFrameViews. | 468 // RemoteFrameViews. |
470 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget* widget, const LayoutObject& layoutObject, WebMouseEvent& webEven
t) | 469 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget* widget, const LayoutObject& layoutObject, WebMouseEvent& webEven
t) |
471 { | 470 { |
472 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; | 471 webEvent.timeStampSeconds = event.platformTimeStamp(); |
473 webEvent.modifiers = getWebInputModifiers(event); | 472 webEvent.modifiers = getWebInputModifiers(event); |
474 | 473 |
475 FrameView* view = widget ? toFrameView(widget->parent()) : 0; | 474 FrameView* view = widget ? toFrameView(widget->parent()) : 0; |
476 // FIXME: If view == nullptr, pointInRootFrame will really be pointInRootCon
tent. | 475 // FIXME: If view == nullptr, pointInRootFrame will really be pointInRootCon
tent. |
477 IntPoint pointInRootFrame = IntPoint(event.absoluteLocation().x(), event.abs
oluteLocation().y()); | 476 IntPoint pointInRootFrame = IntPoint(event.absoluteLocation().x(), event.abs
oluteLocation().y()); |
478 if (view) | 477 if (view) |
479 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); | 478 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); |
480 webEvent.globalX = event.screenX(); | 479 webEvent.globalX = event.screenX(); |
481 webEvent.globalY = event.screenY(); | 480 webEvent.globalY = event.screenY(); |
482 webEvent.windowX = pointInRootFrame.x(); | 481 webEvent.windowX = pointInRootFrame.x(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 | 551 |
553 if (event.type() == EventTypeNames::touchstart) | 552 if (event.type() == EventTypeNames::touchstart) |
554 type = MouseDown; | 553 type = MouseDown; |
555 else if (event.type() == EventTypeNames::touchmove) | 554 else if (event.type() == EventTypeNames::touchmove) |
556 type = MouseMove; | 555 type = MouseMove; |
557 else if (event.type() == EventTypeNames::touchend) | 556 else if (event.type() == EventTypeNames::touchend) |
558 type = MouseUp; | 557 type = MouseUp; |
559 else | 558 else |
560 return; | 559 return; |
561 | 560 |
562 timeStampSeconds = event.timeStamp() / millisPerSecond; | 561 timeStampSeconds = event.platformTimeStamp(); |
563 modifiers = getWebInputModifiers(event); | 562 modifiers = getWebInputModifiers(event); |
564 | 563 |
565 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. | 564 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. |
566 FrameView* view = toFrameView(widget->parent()); | 565 FrameView* view = toFrameView(widget->parent()); |
567 // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootCon
tent. | 566 // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootCon
tent. |
568 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); | 567 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); |
569 if (view) | 568 if (view) |
570 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); | 569 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); |
571 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); | 570 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); |
572 globalX = screenPoint.x(); | 571 globalX = screenPoint.x(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 return; // Skip all other keyboard events. | 610 return; // Skip all other keyboard events. |
612 | 611 |
613 modifiers = getWebInputModifiers(event); | 612 modifiers = getWebInputModifiers(event); |
614 if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_NUMPAD) | 613 if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_NUMPAD) |
615 modifiers |= WebInputEvent::IsKeyPad; | 614 modifiers |= WebInputEvent::IsKeyPad; |
616 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_LEFT) | 615 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_LEFT) |
617 modifiers |= WebInputEvent::IsLeft; | 616 modifiers |= WebInputEvent::IsLeft; |
618 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_RIGHT) | 617 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_RIGHT) |
619 modifiers |= WebInputEvent::IsRight; | 618 modifiers |= WebInputEvent::IsRight; |
620 | 619 |
621 timeStampSeconds = event.timeStamp() / millisPerSecond; | 620 timeStampSeconds = event.platformTimeStamp(); |
622 windowsKeyCode = event.keyCode(); | 621 windowsKeyCode = event.keyCode(); |
623 | 622 |
624 // The platform keyevent does not exist if the event was created using | 623 // The platform keyevent does not exist if the event was created using |
625 // initKeyboardEvent. | 624 // initKeyboardEvent. |
626 if (!event.keyEvent()) | 625 if (!event.keyEvent()) |
627 return; | 626 return; |
628 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); | 627 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); |
629 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code(
)); | 628 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code(
)); |
630 domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key()); | 629 domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key()); |
631 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); | 630 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 type = TouchEnd; | 703 type = TouchEnd; |
705 else if (event.type() == EventTypeNames::touchcancel) | 704 else if (event.type() == EventTypeNames::touchcancel) |
706 type = TouchCancel; | 705 type = TouchCancel; |
707 else { | 706 else { |
708 ASSERT_NOT_REACHED(); | 707 ASSERT_NOT_REACHED(); |
709 type = Undefined; | 708 type = Undefined; |
710 return; | 709 return; |
711 } | 710 } |
712 | 711 |
713 modifiers = getWebInputModifiers(event); | 712 modifiers = getWebInputModifiers(event); |
714 timeStampSeconds = event.timeStamp() / millisPerSecond; | 713 timeStampSeconds = event.platformTimeStamp(); |
715 cancelable = event.cancelable(); | 714 cancelable = event.cancelable(); |
716 causesScrollingIfUncanceled = event.causesScrollingIfUncanceled(); | 715 causesScrollingIfUncanceled = event.causesScrollingIfUncanceled(); |
717 | 716 |
718 // Currently touches[] is empty, add stationary points as-is. | 717 // Currently touches[] is empty, add stationary points as-is. |
719 for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsign
ed>(WebTouchEvent::touchesLengthCap); ++i) { | 718 for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsign
ed>(WebTouchEvent::touchesLengthCap); ++i) { |
720 touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, Web
TouchPoint::StateStationary); | 719 touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, Web
TouchPoint::StateStationary); |
721 ++touchesLength; | 720 ++touchesLength; |
722 } | 721 } |
723 // If any existing points are also in the change list, we should update | 722 // If any existing points are also in the change list, we should update |
724 // their state, otherwise just add the new points. | 723 // their state, otherwise just add the new points. |
(...skipping 22 matching lines...) Expand all Loading... |
747 resendingPluginId = event.resendingPluginId(); | 746 resendingPluginId = event.resendingPluginId(); |
748 } else if (event.type() == EventTypeNames::gestureflingstart) { | 747 } else if (event.type() == EventTypeNames::gestureflingstart) { |
749 type = GestureFlingStart; | 748 type = GestureFlingStart; |
750 data.flingStart.velocityX = event.velocityX(); | 749 data.flingStart.velocityX = event.velocityX(); |
751 data.flingStart.velocityY = event.velocityY(); | 750 data.flingStart.velocityY = event.velocityY(); |
752 } else if (event.type() == EventTypeNames::gesturetap) { | 751 } else if (event.type() == EventTypeNames::gesturetap) { |
753 type = GestureTap; | 752 type = GestureTap; |
754 data.tap.tapCount = 1; | 753 data.tap.tapCount = 1; |
755 } | 754 } |
756 | 755 |
757 timeStampSeconds = event.timeStamp() / millisPerSecond; | 756 timeStampSeconds = event.platformTimeStamp(); |
758 modifiers = getWebInputModifiers(event); | 757 modifiers = getWebInputModifiers(event); |
759 | 758 |
760 globalX = event.screenX(); | 759 globalX = event.screenX(); |
761 globalY = event.screenY(); | 760 globalY = event.screenY(); |
762 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL
ocation(), *layoutObject); | 761 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL
ocation(), *layoutObject); |
763 x = localPoint.x(); | 762 x = localPoint.x(); |
764 y = localPoint.y(); | 763 y = localPoint.y(); |
765 } | 764 } |
766 | 765 |
767 } // namespace blink | 766 } // namespace blink |
OLD | NEW |