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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // TODO(port): Set mouse button states | 839 // TODO(port): Set mouse button states |
840 | 840 |
841 return modifiers; | 841 return modifiers; |
842 } | 842 } |
843 | 843 |
844 WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event) | 844 WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event) |
845 { | 845 { |
846 WebKeyboardEvent result; | 846 WebKeyboardEvent result; |
847 | 847 |
848 result.type = | 848 result.type = |
849 isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::KeyDown; | 849 isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::RawKeyDown; |
850 | 850 |
851 result.modifiers = modifiersFromEvent(event); | 851 result.modifiers = modifiersFromEvent(event); |
852 | 852 |
853 if (isKeypadEvent(event)) | 853 if (isKeypadEvent(event)) |
854 result.modifiers |= WebInputEvent::IsKeyPad; | 854 result.modifiers |= WebInputEvent::IsKeyPad; |
855 | 855 |
856 if (([event type] != NSFlagsChanged) && [event isARepeat]) | 856 if (([event type] != NSFlagsChanged) && [event isARepeat]) |
857 result.modifiers |= WebInputEvent::IsAutoRepeat; | 857 result.modifiers |= WebInputEvent::IsAutoRepeat; |
858 | 858 |
859 result.windowsKeyCode = windowsKeyCodeForKeyEvent(event); | 859 result.windowsKeyCode = windowsKeyCodeForKeyEvent(event); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 | 898 |
899 [identifierStr getCString:&result.keyIdentifier[0] | 899 [identifierStr getCString:&result.keyIdentifier[0] |
900 maxLength:sizeof(result.keyIdentifier) | 900 maxLength:sizeof(result.keyIdentifier) |
901 encoding:NSASCIIStringEncoding]; | 901 encoding:NSASCIIStringEncoding]; |
902 | 902 |
903 result.timeStampSeconds = [event timestamp]; | 903 result.timeStampSeconds = [event timestamp]; |
904 | 904 |
905 return result; | 905 return result; |
906 } | 906 } |
907 | 907 |
| 908 WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, |
| 909 int modifiers, |
| 910 double timeStampSeconds) |
| 911 { |
| 912 // keyboardEvent(NSEvent*) depends on the NSEvent object and |
| 913 // it is hard to use it from methods of the NSTextInput protocol. For |
| 914 // such methods, this function creates a WebInputEvent::Char event without |
| 915 // using a NSEvent object. |
| 916 WebKeyboardEvent result; |
| 917 result.type = WebKit::WebInputEvent::Char; |
| 918 result.timeStampSeconds = timeStampSeconds; |
| 919 result.modifiers = modifiers; |
| 920 result.windowsKeyCode = character; |
| 921 result.nativeKeyCode = character; |
| 922 result.text[0] = character; |
| 923 result.unmodifiedText[0] = character; |
| 924 return result; |
| 925 } |
| 926 |
908 // WebMouseEvent -------------------------------------------------------------- | 927 // WebMouseEvent -------------------------------------------------------------- |
909 | 928 |
910 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view) | 929 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view) |
911 { | 930 { |
912 WebMouseEvent result; | 931 WebMouseEvent result; |
913 | 932 |
914 result.clickCount = 0; | 933 result.clickCount = 0; |
915 | 934 |
916 switch ([event type]) { | 935 switch ([event type]) { |
917 case NSMouseExited: | 936 case NSMouseExited: |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick; | 1153 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick; |
1135 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick; | 1154 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick; |
1136 } | 1155 } |
1137 | 1156 |
1138 result.timeStampSeconds = [event timestamp]; | 1157 result.timeStampSeconds = [event timestamp]; |
1139 | 1158 |
1140 return result; | 1159 return result; |
1141 } | 1160 } |
1142 | 1161 |
1143 } // namespace WebKit | 1162 } // namespace WebKit |
OLD | NEW |