| 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" | |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 13 #include "base/mac/objc_property_releaser.h" | 12 #include "base/mac/objc_property_releaser.h" |
| 14 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 16 #include "components/grit/components_scaled_resources.h" | 15 #include "components/grit/components_scaled_resources.h" |
| 17 #include "components/omnibox/browser/autocomplete_input.h" | 16 #include "components/omnibox/browser/autocomplete_input.h" |
| 18 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" | 17 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" |
| 19 #import "ios/chrome/browser/ui/animation_util.h" | 18 #import "ios/chrome/browser/ui/animation_util.h" |
| 20 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" | 19 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 270 |
| 272 if ([NSLocale characterDirectionForLanguage:lang] == | 271 if ([NSLocale characterDirectionForLanguage:lang] == |
| 273 NSLocaleLanguageDirectionRightToLeft) { | 272 NSLocaleLanguageDirectionRightToLeft) { |
| 274 return NSTextAlignmentRight; | 273 return NSTextAlignmentRight; |
| 275 } | 274 } |
| 276 } | 275 } |
| 277 return NSTextAlignmentLeft; | 276 return NSTextAlignmentLeft; |
| 278 } | 277 } |
| 279 | 278 |
| 280 - (NSTextAlignment)bestTextAlignment { | 279 - (NSTextAlignment)bestTextAlignment { |
| 281 if (!base::ios::IsRunningOnIOS9OrLater() || [self isFirstResponder]) { | 280 if ([self isFirstResponder]) { |
| 282 return [self bestAlignmentForText:[self text]]; | 281 return [self bestAlignmentForText:[self text]]; |
| 283 } | 282 } |
| 284 return NSTextAlignmentNatural; | 283 return NSTextAlignmentNatural; |
| 285 } | 284 } |
| 286 | 285 |
| 287 - (NSTextAlignment)preEditTextAlignment { | 286 - (NSTextAlignment)preEditTextAlignment { |
| 288 // If the pre-edit text is wider than the omnibox, right-align the text so it | 287 // If the pre-edit text is wider than the omnibox, right-align the text so it |
| 289 // ends at the same x coord as the blue selection box. | 288 // ends at the same x coord as the blue selection box. |
| 290 CGSize textSize = | 289 CGSize textSize = |
| 291 [_preEditStaticLabel.get().text cr_pixelAlignedSizeWithFont:_font]; | 290 [_preEditStaticLabel.get().text cr_pixelAlignedSizeWithFont:_font]; |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 // Disable the RTL arrow menu item. The omnibox sets alignment based on the | 1042 // Disable the RTL arrow menu item. The omnibox sets alignment based on the |
| 1044 // text in the field, and should not be overridden. | 1043 // text in the field, and should not be overridden. |
| 1045 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { | 1044 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { |
| 1046 return NO; | 1045 return NO; |
| 1047 } | 1046 } |
| 1048 | 1047 |
| 1049 return [super canPerformAction:action withSender:sender]; | 1048 return [super canPerformAction:action withSender:sender]; |
| 1050 } | 1049 } |
| 1051 | 1050 |
| 1052 @end | 1051 @end |
| OLD | NEW |