| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_content_view.h" | 5 #import "ui/views/cocoa/bridged_content_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "skia/ext/skia_utils_mac.h" | 10 #include "skia/ext/skia_utils_mac.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 // BridgedContentView private implementation. | 167 // BridgedContentView private implementation. |
| 168 | 168 |
| 169 - (void)handleKeyEvent:(NSEvent*)theEvent { | 169 - (void)handleKeyEvent:(NSEvent*)theEvent { |
| 170 if (!hostedView_) | 170 if (!hostedView_) |
| 171 return; | 171 return; |
| 172 | 172 |
| 173 DCHECK(theEvent); | 173 DCHECK(theEvent); |
| 174 DCHECK_NE(NSApplicationDefined, [theEvent type]); |
| 175 |
| 174 ui::KeyEvent event(theEvent); | 176 ui::KeyEvent event(theEvent); |
| 175 if (DispatchEventToMenu(hostedView_->GetWidget(), event.key_code())) | 177 if (DispatchEventToMenu(hostedView_->GetWidget(), event.key_code())) |
| 176 return; | 178 return; |
| 177 | 179 |
| 178 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event); | 180 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event); |
| 179 } | 181 } |
| 180 | 182 |
| 181 - (void)handleAction:(int)commandId | 183 - (void)handleAction:(int)commandId |
| 182 keyCode:(ui::KeyboardCode)keyCode | 184 keyCode:(ui::KeyboardCode)keyCode |
| 183 domCode:(ui::DomCode)domCode | 185 domCode:(ui::DomCode)domCode |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 if (menuController && menuController->owner() == hostedView_->GetWidget()) | 341 if (menuController && menuController->owner() == hostedView_->GetWidget()) |
| 340 return nil; | 342 return nil; |
| 341 | 343 |
| 342 return [super inputContext]; | 344 return [super inputContext]; |
| 343 } | 345 } |
| 344 | 346 |
| 345 // NSResponder implementation. | 347 // NSResponder implementation. |
| 346 | 348 |
| 347 - (void)keyDown:(NSEvent*)theEvent { | 349 - (void)keyDown:(NSEvent*)theEvent { |
| 348 // Convert the event into an action message, according to OSX key mappings. | 350 // Convert the event into an action message, according to OSX key mappings. |
| 349 inKeyDown_ = YES; | 351 inKeyDown_.reset([theEvent retain]); |
| 350 [self interpretKeyEvents:@[ theEvent ]]; | 352 [self interpretKeyEvents:@[ theEvent ]]; |
| 351 inKeyDown_ = NO; | 353 inKeyDown_.reset(); |
| 352 } | 354 } |
| 353 | 355 |
| 354 - (void)scrollWheel:(NSEvent*)theEvent { | 356 - (void)scrollWheel:(NSEvent*)theEvent { |
| 355 if (!hostedView_) | 357 if (!hostedView_) |
| 356 return; | 358 return; |
| 357 | 359 |
| 358 ui::MouseWheelEvent event(theEvent); | 360 ui::MouseWheelEvent event(theEvent); |
| 359 hostedView_->GetWidget()->OnMouseEvent(&event); | 361 hostedView_->GetWidget()->OnMouseEvent(&event); |
| 360 } | 362 } |
| 361 | 363 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 | 575 |
| 574 - (NSUInteger)characterIndexForPoint:(NSPoint)aPoint { | 576 - (NSUInteger)characterIndexForPoint:(NSPoint)aPoint { |
| 575 NOTIMPLEMENTED(); | 577 NOTIMPLEMENTED(); |
| 576 return 0; | 578 return 0; |
| 577 } | 579 } |
| 578 | 580 |
| 579 - (void)doCommandBySelector:(SEL)selector { | 581 - (void)doCommandBySelector:(SEL)selector { |
| 580 // Like the renderer, handle insert action messages as a regular key dispatch. | 582 // Like the renderer, handle insert action messages as a regular key dispatch. |
| 581 // This ensures, e.g., insertTab correctly changes focus between fields. | 583 // This ensures, e.g., insertTab correctly changes focus between fields. |
| 582 if (inKeyDown_ && [NSStringFromSelector(selector) hasPrefix:@"insert"]) { | 584 if (inKeyDown_ && [NSStringFromSelector(selector) hasPrefix:@"insert"]) { |
| 583 [self handleKeyEvent:[NSApp currentEvent]]; | 585 [self handleKeyEvent:inKeyDown_]; |
| 584 return; | 586 return; |
| 585 } | 587 } |
| 586 | 588 |
| 587 if ([self respondsToSelector:selector]) | 589 if ([self respondsToSelector:selector]) |
| 588 [self performSelector:selector withObject:nil]; | 590 [self performSelector:selector withObject:nil]; |
| 589 else | 591 else |
| 590 [[self nextResponder] doCommandBySelector:selector]; | 592 [[self nextResponder] doCommandBySelector:selector]; |
| 591 } | 593 } |
| 592 | 594 |
| 593 - (NSRect)firstRectForCharacterRange:(NSRange)range | 595 - (NSRect)firstRectForCharacterRange:(NSRange)range |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 } | 720 } |
| 719 | 721 |
| 720 return [super accessibilityAttributeValue:attribute]; | 722 return [super accessibilityAttributeValue:attribute]; |
| 721 } | 723 } |
| 722 | 724 |
| 723 - (id)accessibilityHitTest:(NSPoint)point { | 725 - (id)accessibilityHitTest:(NSPoint)point { |
| 724 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 726 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
| 725 } | 727 } |
| 726 | 728 |
| 727 @end | 729 @end |
| OLD | NEW |