Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" | 5 #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" |
| 6 | 6 |
| 7 #import <CoreText/CoreText.h> | 7 #import <CoreText/CoreText.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/mac/foundation_util.h" | 12 #include "base/mac/foundation_util.h" |
| 13 | 13 |
| 14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 15 #include "components/grit/components_scaled_resources.h" | 15 #include "components/grit/components_scaled_resources.h" |
| 16 #include "components/omnibox/browser/autocomplete_input.h" | 16 #include "components/omnibox/browser/autocomplete_input.h" |
| 17 #include "ios/chrome/browser/application_context.h" | |
| 17 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" | 18 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" |
| 19 #include "ios/chrome/browser/experimental_flags.h" | |
| 18 #import "ios/chrome/browser/ui/animation_util.h" | 20 #import "ios/chrome/browser/ui/animation_util.h" |
| 19 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" | 21 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" |
| 20 #import "ios/chrome/browser/ui/reversed_animation.h" | 22 #import "ios/chrome/browser/ui/reversed_animation.h" |
| 21 #include "ios/chrome/browser/ui/rtl_geometry.h" | 23 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 22 #include "ios/chrome/browser/ui/ui_util.h" | 24 #include "ios/chrome/browser/ui/ui_util.h" |
| 23 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 25 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 24 #import "ios/chrome/common/material_timing.h" | 26 #import "ios/chrome/common/material_timing.h" |
| 25 #include "ios/chrome/grit/ios_strings.h" | 27 #include "ios/chrome/grit/ios_strings.h" |
| 26 #include "ios/chrome/grit/ios_theme_resources.h" | 28 #include "ios/chrome/grit/ios_theme_resources.h" |
| 27 #include "skia/ext/skia_utils_ios.h" | 29 #include "skia/ext/skia_utils_ios.h" |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 [autocompleteText | 453 [autocompleteText |
| 452 addAttribute:NSBackgroundColorAttributeName | 454 addAttribute:NSBackgroundColorAttributeName |
| 453 value:[self selectedTextBackgroundColor] | 455 value:[self selectedTextBackgroundColor] |
| 454 range:NSMakeRange([fieldText length], autocompleteLength)]; | 456 range:NSMakeRange([fieldText length], autocompleteLength)]; |
| 455 [_selection setAttributedText:autocompleteText]; | 457 [_selection setAttributedText:autocompleteText]; |
| 456 [_selection setTextAlignment:[self bestTextAlignment]]; | 458 [_selection setTextAlignment:[self bestTextAlignment]]; |
| 457 } else { | 459 } else { |
| 458 [self clearAutocompleteText]; | 460 [self clearAutocompleteText]; |
| 459 } | 461 } |
| 460 | 462 |
| 461 self.attributedText = fieldText; | 463 BOOL updateText = YES; |
| 464 if (experimental_flags::IsThirdPartyKeyboardWorkaroundEnabled() && | |
| 465 GetApplicationContext()->GetApplicationLocale() == "ja") { | |
|
rohitrao (ping after 24h)
2017/06/27 13:48:47
This should check the primaryLanguage of the curre
| |
| 466 updateText = | |
| 467 (!self.editing || ![self.text isEqualToString:fieldText.string]); | |
|
rohitrao (ping after 24h)
2017/06/27 13:48:47
I think I'm ok with this, for two reasons:
1) We s
| |
| 468 } | |
| 469 if (updateText) { | |
| 470 self.attributedText = fieldText; | |
| 471 } | |
| 462 | 472 |
| 463 // iOS changes the font to .LastResort when some unexpected unicode strings | 473 // iOS changes the font to .LastResort when some unexpected unicode strings |
| 464 // are used (e.g. 𝗲𝗺𝗽𝗵𝗮𝘀𝗶𝘀). Setting the NSFontAttributeName in the | 474 // are used (e.g. 𝗲𝗺𝗽𝗵𝗮𝘀𝗶𝘀). Setting the NSFontAttributeName in the |
| 465 // attributed string to -systemFontOfSize fixes part of the problem, but the | 475 // attributed string to -systemFontOfSize fixes part of the problem, but the |
| 466 // baseline changes so text is out of alignment. | 476 // baseline changes so text is out of alignment. |
| 467 [self setFont:_font]; | 477 [self setFont:_font]; |
| 468 // TODO(justincohen): Find a better place to put this, and consolidate it with | 478 // TODO(justincohen): Find a better place to put this, and consolidate it with |
| 469 // the same call in omniboxViewIOS. | 479 // the same call in omniboxViewIOS. |
| 470 [self updateTextDirection]; | 480 [self updateTextDirection]; |
| 471 } | 481 } |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 // Disable the RTL arrow menu item. The omnibox sets alignment based on the | 947 // Disable the RTL arrow menu item. The omnibox sets alignment based on the |
| 938 // text in the field, and should not be overridden. | 948 // text in the field, and should not be overridden. |
| 939 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { | 949 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { |
| 940 return NO; | 950 return NO; |
| 941 } | 951 } |
| 942 | 952 |
| 943 return [super canPerformAction:action withSender:sender]; | 953 return [super canPerformAction:action withSender:sender]; |
| 944 } | 954 } |
| 945 | 955 |
| 946 @end | 956 @end |
| OLD | NEW |