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 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 if (!textInputClient_) | 1230 if (!textInputClient_) |
| 1231 return; | 1231 return; |
| 1232 | 1232 |
| 1233 if ([text isKindOfClass:[NSAttributedString class]]) | 1233 if ([text isKindOfClass:[NSAttributedString class]]) |
| 1234 text = [text string]; | 1234 text = [text string]; |
| 1235 | 1235 |
| 1236 textInputClient_->DeleteRange(gfx::Range(replacementRange)); | 1236 textInputClient_->DeleteRange(gfx::Range(replacementRange)); |
| 1237 ui::CompositionText composition; | 1237 ui::CompositionText composition; |
| 1238 composition.text = base::SysNSStringToUTF16(text); | 1238 composition.text = base::SysNSStringToUTF16(text); |
| 1239 composition.selection = gfx::Range(selectedRange); | 1239 composition.selection = gfx::Range(selectedRange); |
| 1240 | |
| 1241 // Add a black underline with a transparent background to the composition | |
| 1242 // text. TODO(karandeepb): On Cocoa textfields, the target clause of the | |
| 1243 // composition has a thick underlines. The composition text also has | |
| 1244 // discontinous underlines for different clauses. This is also supported in | |
| 1245 // the Chrome renderer. Add code to extract underlines from |text| once our | |
| 1246 // render text implementation supports thick underlines and discontinous | |
| 1247 // underlines for consecutive characters. | |
|
tapted
2016/08/05 05:46:50
nit: The TODO should cite a bug. You can probably
karandeepb
2016/08/05 06:16:05
Done.
| |
| 1248 composition.underlines.push_back(ui::CompositionUnderline( | |
| 1249 0, [text length], SK_ColorBLACK, false, SK_ColorTRANSPARENT)); | |
| 1240 textInputClient_->SetCompositionText(composition); | 1250 textInputClient_->SetCompositionText(composition); |
| 1241 } | 1251 } |
| 1242 | 1252 |
| 1243 - (void)unmarkText { | 1253 - (void)unmarkText { |
| 1244 if (textInputClient_) | 1254 if (textInputClient_) |
| 1245 textInputClient_->ConfirmCompositionText(); | 1255 textInputClient_->ConfirmCompositionText(); |
| 1246 } | 1256 } |
| 1247 | 1257 |
| 1248 - (NSArray*)validAttributesForMarkedText { | 1258 - (NSArray*)validAttributesForMarkedText { |
| 1249 return @[]; | 1259 return @[]; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1301 } | 1311 } |
| 1302 | 1312 |
| 1303 return [super accessibilityAttributeValue:attribute]; | 1313 return [super accessibilityAttributeValue:attribute]; |
| 1304 } | 1314 } |
| 1305 | 1315 |
| 1306 - (id)accessibilityHitTest:(NSPoint)point { | 1316 - (id)accessibilityHitTest:(NSPoint)point { |
| 1307 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 1317 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
| 1308 } | 1318 } |
| 1309 | 1319 |
| 1310 @end | 1320 @end |
| OLD | NEW |