OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2006-2009 Google Inc. | 3 * Copyright (C) 2006-2009 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 [unmodifiedStr getCharacters:&result.unmodifiedText[0]]; | 912 [unmodifiedStr getCharacters:&result.unmodifiedText[0]]; |
913 } else | 913 } else |
914 ASSERT_NOT_REACHED(); | 914 ASSERT_NOT_REACHED(); |
915 | 915 |
916 [identifierStr getCString:&result.keyIdentifier[0] | 916 [identifierStr getCString:&result.keyIdentifier[0] |
917 maxLength:sizeof(result.keyIdentifier) | 917 maxLength:sizeof(result.keyIdentifier) |
918 encoding:NSASCIIStringEncoding]; | 918 encoding:NSASCIIStringEncoding]; |
919 | 919 |
920 result.timeStampSeconds = [event timestamp]; | 920 result.timeStampSeconds = [event timestamp]; |
921 | 921 |
922 // Windows and Linux set that if alt is down. WebKit looks at this to decide | |
923 // if it should handle a key or not. E.g. alt-left/right shouldn't be used | |
924 // by webkit to scroll the current page, because we want to get that key | |
925 // back for it to do history navigation. Hence, the corresponding situation | |
926 // on OS X is to set this for cmd key presses. | |
927 if (result.modifiers & WebInputEvent::MetaKey) | |
928 result.isSystemKey = true; | |
929 | |
930 return result; | 922 return result; |
931 } | 923 } |
932 | 924 |
933 WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, | 925 WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, |
934 int modifiers, | 926 int modifiers, |
935 double timeStampSeconds) | 927 double timeStampSeconds) |
936 { | 928 { |
937 // keyboardEvent(NSEvent*) depends on the NSEvent object and | 929 // keyboardEvent(NSEvent*) depends on the NSEvent object and |
938 // it is hard to use it from methods of the NSTextInput protocol. For | 930 // it is hard to use it from methods of the NSTextInput protocol. For |
939 // such methods, this function creates a WebInputEvent::Char event without | 931 // such methods, this function creates a WebInputEvent::Char event without |
940 // using a NSEvent object. | 932 // using a NSEvent object. |
941 WebKeyboardEvent result; | 933 WebKeyboardEvent result; |
942 result.type = WebKit::WebInputEvent::Char; | 934 result.type = WebKit::WebInputEvent::Char; |
943 result.timeStampSeconds = timeStampSeconds; | 935 result.timeStampSeconds = timeStampSeconds; |
944 result.modifiers = modifiers; | 936 result.modifiers = modifiers; |
945 result.windowsKeyCode = character; | 937 result.windowsKeyCode = character; |
946 result.nativeKeyCode = character; | 938 result.nativeKeyCode = character; |
947 result.text[0] = character; | 939 result.text[0] = character; |
948 result.unmodifiedText[0] = character; | 940 result.unmodifiedText[0] = character; |
949 | |
950 // Windows and Linux set that if alt is down. WebKit looks at this to decide | |
951 // if it should handle a key or not. E.g. alt-left/right shouldn't be used | |
952 // by webkit to scroll the current page, because we want to get that key | |
953 // back for it to do history navigation. Hence, the corresponding situation | |
954 // on OS X is to set this for cmd key presses. | |
955 if (result.modifiers & WebInputEvent::MetaKey) | |
956 result.isSystemKey = true; | |
957 | |
958 return result; | 941 return result; |
959 } | 942 } |
960 | 943 |
961 // WebMouseEvent -------------------------------------------------------------- | 944 // WebMouseEvent -------------------------------------------------------------- |
962 | 945 |
963 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view) | 946 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view) |
964 { | 947 { |
965 WebMouseEvent result; | 948 WebMouseEvent result; |
966 | 949 |
967 result.clickCount = 0; | 950 result.clickCount = 0; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick; | 1170 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick; |
1188 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick; | 1171 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick; |
1189 } | 1172 } |
1190 | 1173 |
1191 result.timeStampSeconds = [event timestamp]; | 1174 result.timeStampSeconds = [event timestamp]; |
1192 | 1175 |
1193 return result; | 1176 return result; |
1194 } | 1177 } |
1195 | 1178 |
1196 } // namespace WebKit | 1179 } // namespace WebKit |
OLD | NEW |