Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: webkit/api/src/mac/WebInputEventFactory.mm

Issue 347022: [mac] Mark keys with cmd pressed as isSystemKeys. (Closed)
Patch Set: rebase tot Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
922 return result; 930 return result;
923 } 931 }
924 932
925 WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, 933 WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character,
926 int modifiers, 934 int modifiers,
927 double timeStampSeconds) 935 double timeStampSeconds)
928 { 936 {
929 // keyboardEvent(NSEvent*) depends on the NSEvent object and 937 // keyboardEvent(NSEvent*) depends on the NSEvent object and
930 // it is hard to use it from methods of the NSTextInput protocol. For 938 // it is hard to use it from methods of the NSTextInput protocol. For
931 // such methods, this function creates a WebInputEvent::Char event without 939 // such methods, this function creates a WebInputEvent::Char event without
932 // using a NSEvent object. 940 // using a NSEvent object.
933 WebKeyboardEvent result; 941 WebKeyboardEvent result;
934 result.type = WebKit::WebInputEvent::Char; 942 result.type = WebKit::WebInputEvent::Char;
935 result.timeStampSeconds = timeStampSeconds; 943 result.timeStampSeconds = timeStampSeconds;
936 result.modifiers = modifiers; 944 result.modifiers = modifiers;
937 result.windowsKeyCode = character; 945 result.windowsKeyCode = character;
938 result.nativeKeyCode = character; 946 result.nativeKeyCode = character;
939 result.text[0] = character; 947 result.text[0] = character;
940 result.unmodifiedText[0] = character; 948 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
941 return result; 958 return result;
942 } 959 }
943 960
944 // WebMouseEvent -------------------------------------------------------------- 961 // WebMouseEvent --------------------------------------------------------------
945 962
946 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view) 963 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view)
947 { 964 {
948 WebMouseEvent result; 965 WebMouseEvent result;
949 966
950 result.clickCount = 0; 967 result.clickCount = 0;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick; 1187 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick;
1171 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick; 1188 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick;
1172 } 1189 }
1173 1190
1174 result.timeStampSeconds = [event timestamp]; 1191 result.timeStampSeconds = [event timestamp];
1175 1192
1176 return result; 1193 return result;
1177 } 1194 }
1178 1195
1179 } // namespace WebKit 1196 } // namespace WebKit
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698