Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: ui/views/cocoa/bridged_content_view.mm

Issue 1257603006: Refactoring for the InputMethod & InputMethodDelegate interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Sadrul's comment. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/keyboard/keyboard_util.cc ('k') | ui/views/cocoa/bridged_native_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_util.cc ('k') | ui/views/cocoa/bridged_native_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698