| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // http://crbug.com/176725 / http://openradar.appspot.com/radar?id=2773401 . | 60 // http://crbug.com/176725 / http://openradar.appspot.com/radar?id=2773401 . |
| 61 // Work around it by reinstalling the tracking area after window resize. | 61 // Work around it by reinstalling the tracking area after window resize. |
| 62 // This AppKit bug is fixed on Yosemite, so we only apply this workaround on | 62 // This AppKit bug is fixed on Yosemite, so we only apply this workaround on |
| 63 // 10.9. | 63 // 10.9. |
| 64 if (base::mac::IsOS10_9()) { | 64 if (base::mac::IsOS10_9()) { |
| 65 [self disableTracking]; | 65 [self disableTracking]; |
| 66 [self enableTracking]; | 66 [self enableTracking]; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 - (void)passMouseEventToSuperview:(NSEvent*)theEvent { |
| 71 // NSView doesn't implement the generic mouseEvent:, so we have to send |
| 72 // events using proper method. |
| 73 switch ([theEvent type]) { |
| 74 case NSLeftMouseDown: |
| 75 [super mouseDown:theEvent]; |
| 76 break; |
| 77 case NSLeftMouseUp: |
| 78 [super mouseUp:theEvent]; |
| 79 break; |
| 80 case NSRightMouseDown: |
| 81 [super rightMouseDown:theEvent]; |
| 82 break; |
| 83 case NSRightMouseUp: |
| 84 [super rightMouseUp:theEvent]; |
| 85 break; |
| 86 case NSOtherMouseDown: |
| 87 [super otherMouseDown:theEvent]; |
| 88 break; |
| 89 case NSOtherMouseUp: |
| 90 [super otherMouseUp:theEvent]; |
| 91 break; |
| 92 case NSMouseMoved: |
| 93 [super mouseMoved:theEvent]; |
| 94 break; |
| 95 case NSLeftMouseDragged: |
| 96 [super mouseDragged:theEvent]; |
| 97 break; |
| 98 case NSRightMouseDragged: |
| 99 [super rightMouseDragged:theEvent]; |
| 100 break; |
| 101 case NSOtherMouseDragged: |
| 102 [super otherMouseDragged:theEvent]; |
| 103 break; |
| 104 case NSMouseEntered: |
| 105 [super mouseEntered:theEvent]; |
| 106 break; |
| 107 case NSMouseExited: |
| 108 [super mouseExited:theEvent]; |
| 109 break; |
| 110 default: |
| 111 NOTREACHED(); |
| 112 break; |
| 113 } |
| 114 } |
| 115 |
| 70 - (void)mouseEvent:(NSEvent*)theEvent { | 116 - (void)mouseEvent:(NSEvent*)theEvent { |
| 71 // This method left intentionally blank. | 117 // This method left intentionally blank. |
| 72 } | 118 } |
| 73 | 119 |
| 74 - (EventHandled)keyEvent:(NSEvent*)theEvent { | 120 - (EventHandled)keyEvent:(NSEvent*)theEvent { |
| 75 // The default implementation of this method does not handle any key events. | 121 // The default implementation of this method does not handle any key events. |
| 76 // Derived classes should return kEventHandled if they handled an event, | 122 // Derived classes should return kEventHandled if they handled an event, |
| 77 // otherwise it will be forwarded on to |super|. | 123 // otherwise it will be forwarded on to |super|. |
| 78 return kEventNotHandled; | 124 return kEventNotHandled; |
| 79 } | 125 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return new_rect; | 240 return new_rect; |
| 195 } | 241 } |
| 196 | 242 |
| 197 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { | 243 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { |
| 198 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); | 244 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); |
| 199 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); | 245 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); |
| 200 return new_rect; | 246 return new_rect; |
| 201 } | 247 } |
| 202 | 248 |
| 203 @end | 249 @end |
| OLD | NEW |