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

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

Issue 2568093003: Support parsing BackgroundSpans and UnderlineSpans in Android IME's commitText() (Closed)
Patch Set: Fix header include Created 4 years 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 <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 // can just send a keypress event which is fabricated by changing the type of 2180 // can just send a keypress event which is fabricated by changing the type of
2181 // the keydown event, so that we can retain all necessary informations, such 2181 // the keydown event, so that we can retain all necessary informations, such
2182 // as unmodifiedText, etc. And we need to set event.skip_in_browser to true to 2182 // as unmodifiedText, etc. And we need to set event.skip_in_browser to true to
2183 // prevent the browser from handling it again. 2183 // prevent the browser from handling it again.
2184 // Note that, |textToBeInserted_| is a UTF-16 string, but it's fine to only 2184 // Note that, |textToBeInserted_| is a UTF-16 string, but it's fine to only
2185 // handle BMP characters here, as we can always insert non-BMP characters as 2185 // handle BMP characters here, as we can always insert non-BMP characters as
2186 // text. 2186 // text.
2187 BOOL textInserted = NO; 2187 BOOL textInserted = NO;
2188 if (textToBeInserted_.length() > 2188 if (textToBeInserted_.length() >
2189 ((hasMarkedText_ || oldHasMarkedText) ? 0u : 1u)) { 2189 ((hasMarkedText_ || oldHasMarkedText) ? 0u : 1u)) {
2190 widgetHost->ImeCommitText(textToBeInserted_, gfx::Range::InvalidRange(), 0); 2190 widgetHost->ImeCommitText(textToBeInserted_,
2191 std::vector<blink::WebCompositionUnderline>(),
2192 gfx::Range::InvalidRange(), 0);
2191 textInserted = YES; 2193 textInserted = YES;
2192 } 2194 }
2193 2195
2194 // Updates or cancels the composition. If some text has been inserted, then 2196 // Updates or cancels the composition. If some text has been inserted, then
2195 // we don't need to cancel the composition explicitly. 2197 // we don't need to cancel the composition explicitly.
2196 if (hasMarkedText_ && markedText_.length()) { 2198 if (hasMarkedText_ && markedText_.length()) {
2197 // Sends the updated marked text to the renderer so it can update the 2199 // Sends the updated marked text to the renderer so it can update the
2198 // composition node in WebKit. 2200 // composition node in WebKit.
2199 // When marked text is available, |markedTextSelectedRange_| will be the 2201 // When marked text is available, |markedTextSelectedRange_| will be the
2200 // range being selected inside the marked text. 2202 // range being selected inside the marked text.
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 // TODO(suzhe): It's hard for us to support replacementRange without accessing 3235 // TODO(suzhe): It's hard for us to support replacementRange without accessing
3234 // the full web content. 3236 // the full web content.
3235 BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; 3237 BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
3236 NSString* im_text = isAttributedString ? [string string] : string; 3238 NSString* im_text = isAttributedString ? [string string] : string;
3237 if (handlingKeyDown_) { 3239 if (handlingKeyDown_) {
3238 textToBeInserted_.append(base::SysNSStringToUTF16(im_text)); 3240 textToBeInserted_.append(base::SysNSStringToUTF16(im_text));
3239 } else { 3241 } else {
3240 gfx::Range replacement_range(replacementRange); 3242 gfx::Range replacement_range(replacementRange);
3241 if (renderWidgetHostView_->GetActiveWidget()) { 3243 if (renderWidgetHostView_->GetActiveWidget()) {
3242 renderWidgetHostView_->GetActiveWidget()->ImeCommitText( 3244 renderWidgetHostView_->GetActiveWidget()->ImeCommitText(
3243 base::SysNSStringToUTF16(im_text), replacement_range, 0); 3245 base::SysNSStringToUTF16(im_text),
3246 std::vector<blink::WebCompositionUnderline>(), replacement_range, 0);
3244 } 3247 }
3245 } 3248 }
3246 3249
3247 // Inserting text will delete all marked text automatically. 3250 // Inserting text will delete all marked text automatically.
3248 hasMarkedText_ = NO; 3251 hasMarkedText_ = NO;
3249 } 3252 }
3250 3253
3251 - (void)insertText:(id)string { 3254 - (void)insertText:(id)string {
3252 [self insertText:string replacementRange:NSMakeRange(NSNotFound, 0)]; 3255 [self insertText:string replacementRange:NSMakeRange(NSNotFound, 0)];
3253 } 3256 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 3451
3449 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3452 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3450 // regions that are not draggable. (See ControlRegionView in 3453 // regions that are not draggable. (See ControlRegionView in
3451 // native_app_window_cocoa.mm). This requires the render host view to be 3454 // native_app_window_cocoa.mm). This requires the render host view to be
3452 // draggable by default. 3455 // draggable by default.
3453 - (BOOL)mouseDownCanMoveWindow { 3456 - (BOOL)mouseDownCanMoveWindow {
3454 return YES; 3457 return YES;
3455 } 3458 }
3456 3459
3457 @end 3460 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698