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

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

Issue 1240943002: Mac: Fix Korean input on OSX 10.11 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ElCapitan
Patch Set: Rebase Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 DCHECK(!handlingKeyDown_); 2094 DCHECK(!handlingKeyDown_);
2095 2095
2096 // Tells insertText: and doCommandBySelector: that we are handling a key 2096 // Tells insertText: and doCommandBySelector: that we are handling a key
2097 // down event. 2097 // down event.
2098 handlingKeyDown_ = YES; 2098 handlingKeyDown_ = YES;
2099 2099
2100 // These variables might be set when handling the keyboard event. 2100 // These variables might be set when handling the keyboard event.
2101 // Clear them here so that we can know whether they have changed afterwards. 2101 // Clear them here so that we can know whether they have changed afterwards.
2102 textToBeInserted_.clear(); 2102 textToBeInserted_.clear();
2103 markedText_.clear(); 2103 markedText_.clear();
2104 markedTextSelectedRange_ = NSMakeRange(NSNotFound, 0);
2104 underlines_.clear(); 2105 underlines_.clear();
2105 unmarkTextCalled_ = NO; 2106 unmarkTextCalled_ = NO;
2106 hasEditCommands_ = NO; 2107 hasEditCommands_ = NO;
2107 editCommands_.clear(); 2108 editCommands_.clear();
2108 2109
2109 // Before doing anything with a key down, check to see if plugin IME has been 2110 // Before doing anything with a key down, check to see if plugin IME has been
2110 // cancelled, since the plugin host needs to be informed of that before 2111 // cancelled, since the plugin host needs to be informed of that before
2111 // receiving the keydown. 2112 // receiving the keydown.
2112 if ([theEvent type] == NSKeyDown) 2113 if ([theEvent type] == NSKeyDown)
2113 [self checkForPluginImeCancellation]; 2114 [self checkForPluginImeCancellation];
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 widgetHost->ImeConfirmComposition( 2178 widgetHost->ImeConfirmComposition(
2178 textToBeInserted_, gfx::Range::InvalidRange(), false); 2179 textToBeInserted_, gfx::Range::InvalidRange(), false);
2179 textInserted = YES; 2180 textInserted = YES;
2180 } 2181 }
2181 2182
2182 // Updates or cancels the composition. If some text has been inserted, then 2183 // Updates or cancels the composition. If some text has been inserted, then
2183 // we don't need to cancel the composition explicitly. 2184 // we don't need to cancel the composition explicitly.
2184 if (hasMarkedText_ && markedText_.length()) { 2185 if (hasMarkedText_ && markedText_.length()) {
2185 // Sends the updated marked text to the renderer so it can update the 2186 // Sends the updated marked text to the renderer so it can update the
2186 // composition node in WebKit. 2187 // composition node in WebKit.
2187 // When marked text is available, |selectedRange_| will be the range being 2188 // When marked text is available, |markedTextSelectedRange_| will be the
2188 // selected inside the marked text. 2189 // range being selected inside the marked text.
2189 widgetHost->ImeSetComposition(markedText_, underlines_, 2190 widgetHost->ImeSetComposition(markedText_, underlines_,
2190 selectedRange_.location, 2191 markedTextSelectedRange_.location,
2191 NSMaxRange(selectedRange_)); 2192 NSMaxRange(markedTextSelectedRange_));
2192 } else if (oldHasMarkedText && !hasMarkedText_ && !textInserted) { 2193 } else if (oldHasMarkedText && !hasMarkedText_ && !textInserted) {
2193 if (unmarkTextCalled_) { 2194 if (unmarkTextCalled_) {
2194 widgetHost->ImeConfirmComposition( 2195 widgetHost->ImeConfirmComposition(
2195 base::string16(), gfx::Range::InvalidRange(), false); 2196 base::string16(), gfx::Range::InvalidRange(), false);
2196 } else { 2197 } else {
2197 widgetHost->ImeCancelComposition(); 2198 widgetHost->ImeCancelComposition();
2198 } 2199 }
2199 } 2200 }
2200 2201
2201 // If the key event was handled by the input method but it also generated some 2202 // If the key event was handled by the input method but it also generated some
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2913 } 2914 }
2914 2915
2915 - (void)unmarkText { 2916 - (void)unmarkText {
2916 // Delete the composition node of the renderer and finish an ongoing 2917 // Delete the composition node of the renderer and finish an ongoing
2917 // composition. 2918 // composition.
2918 // It seems an input method calls the setMarkedText method and set an empty 2919 // It seems an input method calls the setMarkedText method and set an empty
2919 // text when it cancels an ongoing composition, i.e. I have never seen an 2920 // text when it cancels an ongoing composition, i.e. I have never seen an
2920 // input method calls this method. 2921 // input method calls this method.
2921 hasMarkedText_ = NO; 2922 hasMarkedText_ = NO;
2922 markedText_.clear(); 2923 markedText_.clear();
2924 markedTextSelectedRange_ = NSMakeRange(NSNotFound, 0);
2923 underlines_.clear(); 2925 underlines_.clear();
2924 2926
2925 // If we are handling a key down event, then ConfirmComposition() will be 2927 // If we are handling a key down event, then ConfirmComposition() will be
2926 // called in keyEvent: method. 2928 // called in keyEvent: method.
2927 if (!handlingKeyDown_) { 2929 if (!handlingKeyDown_) {
2928 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( 2930 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition(
2929 base::string16(), gfx::Range::InvalidRange(), false); 2931 base::string16(), gfx::Range::InvalidRange(), false);
2930 } else { 2932 } else {
2931 unmarkTextCalled_ = YES; 2933 unmarkTextCalled_ = YES;
2932 } 2934 }
2933 } 2935 }
2934 2936
2935 - (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange 2937 - (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange
2936 replacementRange:(NSRange)replacementRange { 2938 replacementRange:(NSRange)replacementRange {
2937 // An input method updates the composition string. 2939 // An input method updates the composition string.
2938 // We send the given text and range to the renderer so it can update the 2940 // We send the given text and range to the renderer so it can update the
2939 // composition node of WebKit. 2941 // composition node of WebKit.
2940 // TODO(suzhe): It's hard for us to support replacementRange without accessing 2942 // TODO(suzhe): It's hard for us to support replacementRange without accessing
2941 // the full web content. 2943 // the full web content.
2942 BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; 2944 BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
2943 NSString* im_text = isAttributedString ? [string string] : string; 2945 NSString* im_text = isAttributedString ? [string string] : string;
2944 int length = [im_text length]; 2946 int length = [im_text length];
2945 2947
2946 // |markedRange_| will get set on a callback from ImeSetComposition(). 2948 // |markedRange_| will get set on a callback from ImeSetComposition().
2947 selectedRange_ = newSelRange; 2949 markedTextSelectedRange_ = newSelRange;
2948 markedText_ = base::SysNSStringToUTF16(im_text); 2950 markedText_ = base::SysNSStringToUTF16(im_text);
2949 hasMarkedText_ = (length > 0); 2951 hasMarkedText_ = (length > 0);
2950 2952
2951 underlines_.clear(); 2953 underlines_.clear();
2952 if (isAttributedString) { 2954 if (isAttributedString) {
2953 ExtractUnderlines(string, &underlines_); 2955 ExtractUnderlines(string, &underlines_);
2954 } else { 2956 } else {
2955 // Use a thin black underline by default. 2957 // Use a thin black underline by default.
2956 underlines_.push_back(blink::WebCompositionUnderline( 2958 underlines_.push_back(blink::WebCompositionUnderline(
2957 0, length, SK_ColorBLACK, false, SK_ColorTRANSPARENT)); 2959 0, length, SK_ColorBLACK, false, SK_ColorTRANSPARENT));
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 3305
3304 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3306 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3305 // regions that are not draggable. (See ControlRegionView in 3307 // regions that are not draggable. (See ControlRegionView in
3306 // native_app_window_cocoa.mm). This requires the render host view to be 3308 // native_app_window_cocoa.mm). This requires the render host view to be
3307 // draggable by default. 3309 // draggable by default.
3308 - (BOOL)mouseDownCanMoveWindow { 3310 - (BOOL)mouseDownCanMoveWindow {
3309 return YES; 3311 return YES;
3310 } 3312 }
3311 3313
3312 @end 3314 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698