| 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 "ui/base/ime/input_method.h" | 10 #include "ui/base/ime/input_method.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 - (void)handleKeyEvent:(NSEvent*)theEvent { | 166 - (void)handleKeyEvent:(NSEvent*)theEvent { |
| 167 if (!hostedView_) | 167 if (!hostedView_) |
| 168 return; | 168 return; |
| 169 | 169 |
| 170 DCHECK(theEvent); | 170 DCHECK(theEvent); |
| 171 ui::KeyEvent event(theEvent); | 171 ui::KeyEvent event(theEvent); |
| 172 if (DispatchEventToMenu(hostedView_->GetWidget(), event.key_code())) | 172 if (DispatchEventToMenu(hostedView_->GetWidget(), event.key_code())) |
| 173 return; | 173 return; |
| 174 | 174 |
| 175 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(event); | 175 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event); |
| 176 } | 176 } |
| 177 | 177 |
| 178 - (void)handleAction:(int)commandId | 178 - (void)handleAction:(int)commandId |
| 179 keyCode:(ui::KeyboardCode)keyCode | 179 keyCode:(ui::KeyboardCode)keyCode |
| 180 domCode:(ui::DomCode)domCode | 180 domCode:(ui::DomCode)domCode |
| 181 eventFlags:(int)eventFlags { | 181 eventFlags:(int)eventFlags { |
| 182 if (!hostedView_) | 182 if (!hostedView_) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 if (DispatchEventToMenu(hostedView_->GetWidget(), keyCode)) | 185 if (DispatchEventToMenu(hostedView_->GetWidget(), keyCode)) |
| 186 return; | 186 return; |
| 187 | 187 |
| 188 // If there's an active TextInputClient, schedule the editing command to be | 188 // If there's an active TextInputClient, schedule the editing command to be |
| 189 // performed. | 189 // performed. |
| 190 if (commandId && textInputClient_ && | 190 if (commandId && textInputClient_ && |
| 191 textInputClient_->IsEditCommandEnabled(commandId)) | 191 textInputClient_->IsEditCommandEnabled(commandId)) |
| 192 textInputClient_->SetEditCommandForNextKeyEvent(commandId); | 192 textInputClient_->SetEditCommandForNextKeyEvent(commandId); |
| 193 | 193 |
| 194 // Generate a synthetic event with the keycode toolkit-views expects. | 194 // Generate a synthetic event with the keycode toolkit-views expects. |
| 195 ui::KeyEvent event(ui::ET_KEY_PRESSED, keyCode, domCode, eventFlags); | 195 ui::KeyEvent event(ui::ET_KEY_PRESSED, keyCode, domCode, eventFlags); |
| 196 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(event); | 196 hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event); |
| 197 } | 197 } |
| 198 | 198 |
| 199 - (void)undo:(id)sender { | 199 - (void)undo:(id)sender { |
| 200 // This DCHECK is more strict than a similar check in handleAction:. It can be | 200 // This DCHECK is more strict than a similar check in handleAction:. It can be |
| 201 // done here because the actors sending these actions should be calling | 201 // done here because the actors sending these actions should be calling |
| 202 // validateUserInterfaceItem: before enabling UI that allows these messages to | 202 // validateUserInterfaceItem: before enabling UI that allows these messages to |
| 203 // be sent. Checking it here would be too late to provide correct UI feedback | 203 // be sent. Checking it here would be too late to provide correct UI feedback |
| 204 // (e.g. there will be no "beep"). | 204 // (e.g. there will be no "beep"). |
| 205 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_UNDO)); | 205 DCHECK(textInputClient_->IsEditCommandEnabled(IDS_APP_UNDO)); |
| 206 [self handleAction:IDS_APP_UNDO | 206 [self handleAction:IDS_APP_UNDO |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 } | 707 } |
| 708 | 708 |
| 709 return [super accessibilityAttributeValue:attribute]; | 709 return [super accessibilityAttributeValue:attribute]; |
| 710 } | 710 } |
| 711 | 711 |
| 712 - (id)accessibilityHitTest:(NSPoint)point { | 712 - (id)accessibilityHitTest:(NSPoint)point { |
| 713 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 713 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
| 714 } | 714 } |
| 715 | 715 |
| 716 @end | 716 @end |
| OLD | NEW |