Chromium Code Reviews| 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/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 | 430 |
| 431 if ([text isKindOfClass:[NSAttributedString class]]) | 431 if ([text isKindOfClass:[NSAttributedString class]]) |
| 432 text = [text string]; | 432 text = [text string]; |
| 433 | 433 |
| 434 bool isCharacterEvent = keyDownEvent_ && [text length] == 1; | 434 bool isCharacterEvent = keyDownEvent_ && [text length] == 1; |
| 435 | 435 |
| 436 // Forward the |text| to |textInputClient_| if no menu is active. | 436 // Forward the |text| to |textInputClient_| if no menu is active. |
| 437 if (textInputClient_ && ![self activeMenuController]) { | 437 if (textInputClient_ && ![self activeMenuController]) { |
| 438 // If a single character is inserted by keyDown's call to | 438 // If a single character is inserted by keyDown's call to |
| 439 // interpretKeyEvents: then use InsertChar() to allow editing events to be | 439 // interpretKeyEvents: then use InsertChar() to allow editing events to be |
| 440 // merged. | 440 // merged. We use ui::VKEY_UNKOWN as the key code since it's not feasible to |
| 441 if (isCharacterEvent) | 441 // determine the correct key code for each unicode character. Also a correct |
| 442 textInputClient_->InsertChar(GetCharacterEventFromNSEvent(keyDownEvent_)); | 442 // keycode is not needed in the current context. Send ui::EF_NONE as the key |
| 443 else | 443 // modifier since |text| already accounts for the pressed key modifiers. |
|
tapted
2016/07/28 02:01:06
It might be worth raising a bug with the IME folks
| |
| 444 | |
| 445 // Also, note we don't use |keyDownEvent_| to generate the synthetic | |
| 446 // ui::KeyEvent since for text inserted using an IME, [keyDownEvent_ | |
| 447 // characters] might not be the same as |text|. This is because | |
| 448 // |keyDownEvent_| will correspond to the event that caused the composition | |
| 449 // text to be confirmed, say, Return key press. | |
| 450 if (isCharacterEvent) { | |
| 451 textInputClient_->InsertChar(ui::KeyEvent([text characterAtIndex:0], | |
| 452 ui::VKEY_UNKNOWN, ui::EF_NONE)); | |
| 453 } else { | |
| 444 textInputClient_->InsertText(base::SysNSStringToUTF16(text)); | 454 textInputClient_->InsertText(base::SysNSStringToUTF16(text)); |
| 455 } | |
| 445 return; | 456 return; |
| 446 } | 457 } |
| 447 | 458 |
| 448 // Only handle the case where no. of characters is 1. Cases not handled (not | 459 // Only handle the case where no. of characters is 1. Cases not handled (not |
| 449 // an exhaustive list): | 460 // an exhaustive list): |
| 450 // - |text| contains a unicode surrogate pair, i.e. a single grapheme which | 461 // - |text| contains a unicode surrogate pair, i.e. a single grapheme which |
| 451 // requires two 16 bit characters. Currently Views menu only supports | 462 // requires two 16 bit characters. Currently Views menu only supports |
| 452 // mnemonics using a single 16 bit character, so it is ok to ignore this | 463 // mnemonics using a single 16 bit character, so it is ok to ignore this |
| 453 // case. | 464 // case. |
| 454 // - Programmatically created events. | 465 // - Programmatically created events. |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 } | 1294 } |
| 1284 | 1295 |
| 1285 return [super accessibilityAttributeValue:attribute]; | 1296 return [super accessibilityAttributeValue:attribute]; |
| 1286 } | 1297 } |
| 1287 | 1298 |
| 1288 - (id)accessibilityHitTest:(NSPoint)point { | 1299 - (id)accessibilityHitTest:(NSPoint)point { |
| 1289 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 1300 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
| 1290 } | 1301 } |
| 1291 | 1302 |
| 1292 @end | 1303 @end |
| OLD | NEW |