OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains the definition for EventSendingController. | 5 // This file contains the definition for EventSendingController. |
6 // | 6 // |
7 // Some notes about drag and drop handling: | 7 // Some notes about drag and drop handling: |
8 // Windows drag and drop goes through a system call to DoDragDrop. At that | 8 // Windows drag and drop goes through a system call to DoDragDrop. At that |
9 // point, program control is given to Windows which then periodically makes | 9 // point, program control is given to Windows which then periodically makes |
10 // callbacks into the webview. This won't work for layout tests, so instead, | 10 // callbacks into the webview. This won't work for layout tests, so instead, |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
833 result->SetNull(); | 833 result->SetNull(); |
834 } | 834 } |
835 | 835 |
836 void EventSendingController::addTouchPoint( | 836 void EventSendingController::addTouchPoint( |
837 const CppArgumentList& args, CppVariant* result) { | 837 const CppArgumentList& args, CppVariant* result) { |
838 result->SetNull(); | 838 result->SetNull(); |
839 | 839 |
840 WebTouchPoint touch_point; | 840 WebTouchPoint touch_point; |
841 touch_point.state = WebTouchPoint::StatePressed; | 841 touch_point.state = WebTouchPoint::StatePressed; |
842 touch_point.position = WebPoint(args[0].ToInt32(), args[1].ToInt32()); | 842 touch_point.position = WebPoint(args[0].ToInt32(), args[1].ToInt32()); |
843 touch_point.screenPosition = touch_point.position; | |
843 touch_point.id = touch_points.size(); | 844 touch_point.id = touch_points.size(); |
844 touch_points.push_back(touch_point); | 845 touch_points.push_back(touch_point); |
845 } | 846 } |
846 | 847 |
847 void EventSendingController::clearTouchPoints( | 848 void EventSendingController::clearTouchPoints( |
848 const CppArgumentList& args, CppVariant* result) { | 849 const CppArgumentList& args, CppVariant* result) { |
849 result->SetNull(); | 850 result->SetNull(); |
850 | 851 |
851 touch_points.clear(); | 852 touch_points.clear(); |
852 } | 853 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
894 const unsigned int index = args[0].ToInt32(); | 895 const unsigned int index = args[0].ToInt32(); |
895 if (index >= touch_points.size()) { | 896 if (index >= touch_points.size()) { |
896 NOTREACHED() << "Invalid touch point index"; | 897 NOTREACHED() << "Invalid touch point index"; |
897 } | 898 } |
898 | 899 |
899 WebPoint position(args[1].ToInt32(), args[2].ToInt32()); | 900 WebPoint position(args[1].ToInt32(), args[2].ToInt32()); |
900 | 901 |
901 WebTouchPoint* touch_point = &touch_points[index]; | 902 WebTouchPoint* touch_point = &touch_points[index]; |
902 touch_point->state = WebTouchPoint::StateMoved; | 903 touch_point->state = WebTouchPoint::StateMoved; |
903 touch_point->position = position; | 904 touch_point->position = position; |
905 touch_point->screenPosition = position; | |
904 } | 906 } |
905 | 907 |
906 void EventSendingController::cancelTouchPoint( | 908 void EventSendingController::cancelTouchPoint( |
907 const CppArgumentList& args, CppVariant* result) { | 909 const CppArgumentList& args, CppVariant* result) { |
908 result->SetNull(); | 910 result->SetNull(); |
909 | 911 |
910 const unsigned int index = args[0].ToInt32(); | 912 const unsigned int index = args[0].ToInt32(); |
911 if (index >= touch_points.size()) { | 913 if (index >= touch_points.size()) { |
912 NOTREACHED() << "Invalid touch point index"; | 914 NOTREACHED() << "Invalid touch point index"; |
913 } | 915 } |
914 | 916 |
915 WebTouchPoint* touch_point = &touch_points[index]; | 917 WebTouchPoint* touch_point = &touch_points[index]; |
916 touch_point->state = WebTouchPoint::StateCancelled; | 918 touch_point->state = WebTouchPoint::StateCancelled; |
917 } | 919 } |
918 | 920 |
919 void EventSendingController::SendCurrentTouchEvent( | 921 void EventSendingController::SendCurrentTouchEvent( |
920 const WebInputEvent::Type type) { | 922 const WebInputEvent::Type type) { |
923 | |
924 // Force a layout here just to make sure every position has been | |
925 // determined before we send events (as well as all the other methods | |
926 // that send an event do). | |
jamesr
2010/11/10 19:59:58
Comment isn't very helpful here, recommend removin
| |
927 webview()->layout(); | |
928 | |
921 if (static_cast<unsigned int>(WebTouchEvent::touchPointsLengthCap) <= | 929 if (static_cast<unsigned int>(WebTouchEvent::touchPointsLengthCap) <= |
922 touch_points.size()) { | 930 touch_points.size()) { |
923 NOTREACHED() << "Too many touch points for event"; | 931 NOTREACHED() << "Too many touch points for event"; |
924 } | 932 } |
925 | 933 |
926 WebTouchEvent touch_event; | 934 WebTouchEvent touch_event; |
927 touch_event.type = type; | 935 touch_event.type = type; |
928 touch_event.modifiers = touch_modifiers; | 936 touch_event.modifiers = touch_modifiers; |
929 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); | 937 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); |
930 touch_event.touchPointsLength = touch_points.size(); | 938 touch_event.touchPointsLength = touch_points.size(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 | 1021 |
1014 void EventSendingController::fireKeyboardEventsToElement( | 1022 void EventSendingController::fireKeyboardEventsToElement( |
1015 const CppArgumentList& args, CppVariant* result) { | 1023 const CppArgumentList& args, CppVariant* result) { |
1016 result->SetNull(); | 1024 result->SetNull(); |
1017 } | 1025 } |
1018 | 1026 |
1019 void EventSendingController::clearKillRing( | 1027 void EventSendingController::clearKillRing( |
1020 const CppArgumentList& args, CppVariant* result) { | 1028 const CppArgumentList& args, CppVariant* result) { |
1021 result->SetNull(); | 1029 result->SetNull(); |
1022 } | 1030 } |
OLD | NEW |