| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 | 30 |
| 31 #include "wtf/ASCIICType.h" | 31 #include "wtf/ASCIICType.h" |
| 32 #include "webkit/glue/webinputevent.h" | 32 #include "webkit/glue/webinputevent.h" |
| 33 #include "webkit/glue/event_conversion.h" | 33 #include "webkit/glue/event_conversion.h" |
| 34 | 34 |
| 35 #undef LOG | 35 #undef LOG |
| 36 #include "base/logging.h" | 36 #include "base/logging.h" |
| 37 | 37 |
| 38 static const unsigned long kDefaultScrollLinesPerWheelDelta = 3; | |
| 39 | |
| 40 // WebMouseEvent -------------------------------------------------------------- | 38 // WebMouseEvent -------------------------------------------------------------- |
| 41 | 39 |
| 42 WebMouseEvent::WebMouseEvent(NSEvent *event, NSView* view) { | 40 WebMouseEvent::WebMouseEvent(NSEvent *event, NSView* view) { |
| 43 switch ([event type]) { | 41 switch ([event type]) { |
| 44 case NSMouseExited: | 42 case NSMouseExited: |
| 45 type = MOUSE_LEAVE; | 43 type = MOUSE_LEAVE; |
| 46 button = BUTTON_NONE; | 44 button = BUTTON_NONE; |
| 47 break; | 45 break; |
| 48 case NSLeftMouseDown: | 46 case NSLeftMouseDown: |
| 49 type = [event clickCount] == 2 ? MOUSE_DOUBLE_CLICK : MOUSE_DOWN; | 47 type = [event clickCount] == 2 ? MOUSE_DOUBLE_CLICK : MOUSE_DOWN; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 127 |
| 130 // Set coordinates by translating event coordinates from screen to client. | 128 // Set coordinates by translating event coordinates from screen to client. |
| 131 NSPoint location = [NSEvent mouseLocation]; // global coordinates | 129 NSPoint location = [NSEvent mouseLocation]; // global coordinates |
| 132 global_x = location.x; | 130 global_x = location.x; |
| 133 global_y = location.y; | 131 global_y = location.y; |
| 134 NSPoint windowLocal = [event locationInWindow]; | 132 NSPoint windowLocal = [event locationInWindow]; |
| 135 location = [view convertPoint:windowLocal fromView:nil]; | 133 location = [view convertPoint:windowLocal fromView:nil]; |
| 136 x = location.x; | 134 x = location.x; |
| 137 y = [view frame].size.height - location.y; // flip y | 135 y = [view frame].size.height - location.y; // flip y |
| 138 | 136 |
| 139 // Convert wheel delta amount to a number of lines to scroll. | 137 // Convert wheel delta amount to a number of pixels to scroll. |
| 138 static const float kScrollbarPixelsPerTick = 40.0f; |
| 140 float wheel_delta = [event deltaY]; | 139 float wheel_delta = [event deltaY]; |
| 141 const float delta_lines = wheel_delta * kDefaultScrollLinesPerWheelDelta; | 140 const float delta_lines = wheel_delta * kScrollbarPixelsPerTick; |
| 142 | 141 |
| 143 // Set scroll amount based on above calculations. | 142 // Set scroll amount based on above calculations. |
| 144 if ([event modifierFlags] & NSShiftKeyMask) { | 143 if ([event modifierFlags] & NSShiftKeyMask) { |
| 145 // Scrolling up should move left, scrolling down should move right. This is | |
| 146 // opposite Safari, but seems more consistent with vertical scrolling. | |
| 147 delta_x = delta_lines; | 144 delta_x = delta_lines; |
| 148 delta_y = 0; | 145 delta_y = 0; |
| 149 } else { | 146 } else { |
| 150 delta_x = 0; | 147 delta_x = 0; |
| 151 delta_y = delta_lines; | 148 delta_y = delta_lines; |
| 152 } | 149 } |
| 153 scroll_by_page = false; | 150 scroll_by_page = false; |
| 154 } | 151 } |
| 155 | 152 |
| 156 // WebKeyboardEvent ----------------------------------------------------------- | 153 // WebKeyboardEvent ----------------------------------------------------------- |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 [unmodified_str length] < kTextLengthCap) { | 1003 [unmodified_str length] < kTextLengthCap) { |
| 1007 [text_str getCharacters:&text[0]]; | 1004 [text_str getCharacters:&text[0]]; |
| 1008 [unmodified_str getCharacters:&unmodified_text[0]]; | 1005 [unmodified_str getCharacters:&unmodified_text[0]]; |
| 1009 } else { | 1006 } else { |
| 1010 LOG(ERROR) << "Event had text too long; dropped"; | 1007 LOG(ERROR) << "Event had text too long; dropped"; |
| 1011 } | 1008 } |
| 1012 [identifier_str getCString:&key_identifier[0] | 1009 [identifier_str getCString:&key_identifier[0] |
| 1013 maxLength:kIdentifierLengthCap | 1010 maxLength:kIdentifierLengthCap |
| 1014 encoding:NSASCIIStringEncoding]; | 1011 encoding:NSASCIIStringEncoding]; |
| 1015 } | 1012 } |
| OLD | NEW |