Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/cocoa/base_view.h" | 5 #include "ui/base/cocoa/base_view.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 | 8 |
| 9 NSString* kViewDidBecomeFirstResponder = | 9 NSString* kViewDidBecomeFirstResponder = |
| 10 @"Chromium.kViewDidBecomeFirstResponder"; | 10 @"Chromium.kViewDidBecomeFirstResponder"; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 - (void)keyDown:(NSEvent*)theEvent { | 163 - (void)keyDown:(NSEvent*)theEvent { |
| 164 if ([self keyEvent:theEvent] != kEventHandled) | 164 if ([self keyEvent:theEvent] != kEventHandled) |
| 165 [super keyDown:theEvent]; | 165 [super keyDown:theEvent]; |
| 166 } | 166 } |
| 167 | 167 |
| 168 - (void)keyUp:(NSEvent*)theEvent { | 168 - (void)keyUp:(NSEvent*)theEvent { |
| 169 if ([self keyEvent:theEvent] != kEventHandled) | 169 if ([self keyEvent:theEvent] != kEventHandled) |
| 170 [super keyUp:theEvent]; | 170 [super keyUp:theEvent]; |
| 171 } | 171 } |
| 172 | 172 |
| 173 - (void)pressureChangeWithEvent:(NSEvent*)theEvent { | |
| 174 NSInteger newStage = [theEvent stage]; | |
| 175 if (pressureEventStage_ == newStage) | |
| 176 return; | |
| 177 | |
| 178 // Call the force touch event when the stage reaches 2, which is the value | |
| 179 // for force touch. | |
| 180 if (newStage == 2) { | |
| 181 [self forceTouchEvent:theEvent]; | |
|
Avi (use Gerrit)
2016/03/08 20:07:54
I'm rather uncomfortable here. While it seems like
Avi (use Gerrit)
2016/03/08 20:13:08
OK, I'm really unsure about this. -pressureChangeW
erikchen
2016/03/08 20:57:41
Whoops! Good catch.
| |
| 182 } | |
| 183 pressureEventStage_ = newStage; | |
|
Avi (use Gerrit)
2016/03/08 20:07:54
pressureEventStage_ is only used in this method; i
| |
| 184 } | |
| 185 | |
| 186 - (void)flagsChanged:(NSEvent*)theEvent { | 173 - (void)flagsChanged:(NSEvent*)theEvent { |
| 187 if ([self keyEvent:theEvent] != kEventHandled) | 174 if ([self keyEvent:theEvent] != kEventHandled) |
| 188 [super flagsChanged:theEvent]; | 175 [super flagsChanged:theEvent]; |
| 189 } | 176 } |
| 190 | 177 |
| 191 - (gfx::Rect)flipNSRectToRect:(NSRect)rect { | 178 - (gfx::Rect)flipNSRectToRect:(NSRect)rect { |
| 192 gfx::Rect new_rect(NSRectToCGRect(rect)); | 179 gfx::Rect new_rect(NSRectToCGRect(rect)); |
| 193 new_rect.set_y(NSHeight([self bounds]) - new_rect.bottom()); | 180 new_rect.set_y(NSHeight([self bounds]) - new_rect.bottom()); |
| 194 return new_rect; | 181 return new_rect; |
| 195 } | 182 } |
| 196 | 183 |
| 197 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { | 184 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { |
| 198 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); | 185 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); |
| 199 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); | 186 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); |
| 200 return new_rect; | 187 return new_rect; |
| 201 } | 188 } |
| 202 | 189 |
| 203 @end | 190 @end |
| OLD | NEW |