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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 8227018: mac: Almost fix Lion accented character bubble input in web contents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whoopsies Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
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 "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include <QuartzCore/QuartzCore.h> 7 #include <QuartzCore/QuartzCore.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 // * when we type an ASCII character (without using input methods). 2463 // * when we type an ASCII character (without using input methods).
2464 // When we aren't using input methods, we should send the given character as 2464 // When we aren't using input methods, we should send the given character as
2465 // a Char event so it is dispatched to an onkeypress() event handler of 2465 // a Char event so it is dispatched to an onkeypress() event handler of
2466 // JavaScript. 2466 // JavaScript.
2467 // On the other hand, when we are using input methods, we should send the 2467 // On the other hand, when we are using input methods, we should send the
2468 // given characters as an input method event and prevent the characters from 2468 // given characters as an input method event and prevent the characters from
2469 // being dispatched to onkeypress() event handlers. 2469 // being dispatched to onkeypress() event handlers.
2470 // Text inserting might be initiated by other source instead of keyboard 2470 // Text inserting might be initiated by other source instead of keyboard
2471 // events, such as the Characters dialog. In this case the text should be 2471 // events, such as the Characters dialog. In this case the text should be
2472 // sent as an input method event as well. 2472 // sent as an input method event as well.
2473 // TODO(suzhe): It's hard for us to support replacementRange without accessing 2473 // TODO(suzhe): It's hard for us to support replacementRange without accessing
Avi (use Gerrit) 2011/10/12 00:22:09 Is this comment meaningful?
Nico 2011/10/12 00:23:18 I don't know what it means. Maybe it makes sense f
Avi (use Gerrit) 2011/10/12 00:29:27 Well, this patch _does_ implement replacementRange
Nico 2011/10/12 00:34:30 Only in the IME case, though.
2474 // the full web content. NOTE: If someone adds support for this, make sure 2474 // the full web content.
2475 // it works with the default range passed in by -insertText: below.
2476 BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; 2475 BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
2477 NSString* im_text = isAttributedString ? [string string] : string; 2476 NSString* im_text = isAttributedString ? [string string] : string;
2478 if (handlingKeyDown_) { 2477 if (handlingKeyDown_) {
2479 textToBeInserted_.append(base::SysNSStringToUTF16(im_text)); 2478 textToBeInserted_.append(base::SysNSStringToUTF16(im_text));
2480 } else { 2479 } else {
2480 ui::Range replacement_range(replacementRange);
2481 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( 2481 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition(
2482 base::SysNSStringToUTF16(im_text)); 2482 base::SysNSStringToUTF16(im_text), replacement_range);
2483 } 2483 }
2484 2484
2485 // Inserting text will delete all marked text automatically. 2485 // Inserting text will delete all marked text automatically.
2486 hasMarkedText_ = NO; 2486 hasMarkedText_ = NO;
2487 } 2487 }
2488 2488
2489 - (void)insertText:(id)string { 2489 - (void)insertText:(id)string {
2490 // This is a method on NSTextInput, not NSTextInputClient. But on 10.5, this 2490 // This is a method on NSTextInput, not NSTextInputClient. But on 10.5, this
2491 // gets called anyway. Forward to the right method. http://crbug.com/47890 2491 // gets called anyway. Forward to the right method. http://crbug.com/47890
2492 [self insertText:string replacementRange:NSMakeRange(0, 0)]; 2492 [self insertText:string replacementRange:NSMakeRange(NSNotFound, 0)];
2493 } 2493 }
2494 2494
2495 - (void)viewDidMoveToWindow { 2495 - (void)viewDidMoveToWindow {
2496 if (canBeKeyView_) { 2496 if (canBeKeyView_) {
2497 NSWindow* newWindow = [self window]; 2497 NSWindow* newWindow = [self window];
2498 // Pointer comparison only, since we don't know if lastWindow_ is still 2498 // Pointer comparison only, since we don't know if lastWindow_ is still
2499 // valid. 2499 // valid.
2500 if (newWindow) { 2500 if (newWindow) {
2501 // If we move into a new window, refresh the frame information. We 2501 // If we move into a new window, refresh the frame information. We
2502 // don't need to do it if it was the same window as it used to be in, 2502 // don't need to do it if it was the same window as it used to be in,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 if (!string) return NO; 2709 if (!string) return NO;
2710 2710
2711 // If the user is currently using an IME, confirm the IME input, 2711 // If the user is currently using an IME, confirm the IME input,
2712 // and then insert the text from the service, the same as TextEdit and Safari. 2712 // and then insert the text from the service, the same as TextEdit and Safari.
2713 [self confirmComposition]; 2713 [self confirmComposition];
2714 [self insertText:string]; 2714 [self insertText:string];
2715 return YES; 2715 return YES;
2716 } 2716 }
2717 2717
2718 @end 2718 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698