| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // Set coordinates by translating event coordinates from screen to client. | 128 // Set coordinates by translating event coordinates from screen to client. |
| 129 NSPoint location = [NSEvent mouseLocation]; // global coordinates | 129 NSPoint location = [NSEvent mouseLocation]; // global coordinates |
| 130 global_x = location.x; | 130 global_x = location.x; |
| 131 global_y = location.y; | 131 global_y = location.y; |
| 132 NSPoint windowLocal = [event locationInWindow]; | 132 NSPoint windowLocal = [event locationInWindow]; |
| 133 location = [view convertPoint:windowLocal fromView:nil]; | 133 location = [view convertPoint:windowLocal fromView:nil]; |
| 134 x = location.x; | 134 x = location.x; |
| 135 y = [view frame].size.height - location.y; // flip y | 135 y = [view frame].size.height - location.y; // flip y |
| 136 | 136 |
| 137 // Convert wheel delta amount to a number of pixels to scroll. | 137 // Convert wheel delta amount to a number of pixels to scroll. |
| 138 // Cocoa sets deltaX instead of deltaY if shift is pressed when scrolling |
| 139 // with a scroll wheel, no need to do that ourselves. |
| 138 static const float kScrollbarPixelsPerTick = 40.0f; | 140 static const float kScrollbarPixelsPerTick = 40.0f; |
| 139 float wheel_delta = [event deltaY]; | |
| 140 const float delta_lines = wheel_delta * kScrollbarPixelsPerTick; | |
| 141 | 141 |
| 142 // Set scroll amount based on above calculations. | 142 wheel_ticks_x = [event deltaX]; |
| 143 if ([event modifierFlags] & NSShiftKeyMask) { | 143 delta_x = wheel_ticks_x * kScrollbarPixelsPerTick; |
| 144 delta_x = delta_lines; | 144 |
| 145 delta_y = 0; | 145 wheel_ticks_y = [event deltaY]; |
| 146 wheel_ticks_x = wheel_delta; | 146 delta_y = wheel_ticks_y * kScrollbarPixelsPerTick; |
| 147 wheel_ticks_y = 0; | 147 |
| 148 } else { | |
| 149 delta_x = 0; | |
| 150 delta_y = delta_lines; | |
| 151 wheel_ticks_x = 0; | |
| 152 wheel_ticks_y = wheel_delta; | |
| 153 } | |
| 154 scroll_by_page = false; | 148 scroll_by_page = false; |
| 155 } | 149 } |
| 156 | 150 |
| 157 // WebKeyboardEvent ----------------------------------------------------------- | 151 // WebKeyboardEvent ----------------------------------------------------------- |
| 158 | 152 |
| 159 // ---------------------------------------------------------------------- | 153 // ---------------------------------------------------------------------- |
| 160 // Begin Apple code, copied from KeyEventMac.mm | 154 // Begin Apple code, copied from KeyEventMac.mm |
| 161 // | 155 // |
| 162 // We can share some of this code if we factored it out of KeyEventMac, but | 156 // We can share some of this code if we factored it out of KeyEventMac, but |
| 163 // the main problem is that it relies on the NSString ctor on String for | 157 // the main problem is that it relies on the NSString ctor on String for |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 [unmodified_str length] < kTextLengthCap) { | 1001 [unmodified_str length] < kTextLengthCap) { |
| 1008 [text_str getCharacters:&text[0]]; | 1002 [text_str getCharacters:&text[0]]; |
| 1009 [unmodified_str getCharacters:&unmodified_text[0]]; | 1003 [unmodified_str getCharacters:&unmodified_text[0]]; |
| 1010 } else { | 1004 } else { |
| 1011 LOG(ERROR) << "Event had text too long; dropped"; | 1005 LOG(ERROR) << "Event had text too long; dropped"; |
| 1012 } | 1006 } |
| 1013 [identifier_str getCString:&key_identifier[0] | 1007 [identifier_str getCString:&key_identifier[0] |
| 1014 maxLength:kIdentifierLengthCap | 1008 maxLength:kIdentifierLengthCap |
| 1015 encoding:NSASCIIStringEncoding]; | 1009 encoding:NSASCIIStringEncoding]; |
| 1016 } | 1010 } |
| OLD | NEW |