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/logging.h" | 11 #include "base/logging.h" |
11 #include "base/mac/foundation_util.h" | 12 #include "base/mac/foundation_util.h" |
12 | 13 |
13 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
14 #include "components/grit/components_scaled_resources.h" | 15 #include "components/grit/components_scaled_resources.h" |
15 #include "components/omnibox/browser/autocomplete_input.h" | 16 #include "components/omnibox/browser/autocomplete_input.h" |
16 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" | 17 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" |
17 #import "ios/chrome/browser/ui/animation_util.h" | 18 #import "ios/chrome/browser/ui/animation_util.h" |
18 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" | 19 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" |
19 #import "ios/chrome/browser/ui/reversed_animation.h" | 20 #import "ios/chrome/browser/ui/reversed_animation.h" |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 - (void)updateTextDirection { | 548 - (void)updateTextDirection { |
548 // Setting the empty field to Natural seems to let iOS update the cursor | 549 // Setting the empty field to Natural seems to let iOS update the cursor |
549 // position when the keyboard language is changed. | 550 // position when the keyboard language is changed. |
550 if (![self text].length) { | 551 if (![self text].length) { |
551 [self setTextAlignment:NSTextAlignmentNatural]; | 552 [self setTextAlignment:NSTextAlignmentNatural]; |
552 return; | 553 return; |
553 } | 554 } |
554 | 555 |
555 NSTextAlignment alignment = [self bestTextAlignment]; | 556 NSTextAlignment alignment = [self bestTextAlignment]; |
556 [self setTextAlignment:alignment]; | 557 [self setTextAlignment:alignment]; |
557 UITextWritingDirection writingDirection = | 558 if (!base::ios::IsRunningOnIOS11OrLater()) { |
558 alignment == NSTextAlignmentLeft ? UITextWritingDirectionLeftToRight | 559 // TODO(crbug.com/730461): Remove this entire block once it's been tested |
559 : UITextWritingDirectionRightToLeft; | 560 // on trunk. |
560 [self | 561 UITextWritingDirection writingDirection = |
561 setBaseWritingDirection:writingDirection | 562 alignment == NSTextAlignmentLeft ? UITextWritingDirectionLeftToRight |
562 forRange:[self | 563 : UITextWritingDirectionRightToLeft; |
563 textRangeFromPosition:[self | 564 [self |
564 beginningOfDocument] | 565 setBaseWritingDirection:writingDirection |
565 toPosition:[self endOfDocument]]]; | 566 forRange: |
| 567 [self |
| 568 textRangeFromPosition:[self beginningOfDocument] |
| 569 toPosition:[self endOfDocument]]]; |
| 570 } |
566 } | 571 } |
567 | 572 |
568 - (void)setPlaceholder:(NSString*)placeholder { | 573 - (void)setPlaceholder:(NSString*)placeholder { |
569 if (placeholder && _placeholderTextColor) { | 574 if (placeholder && _placeholderTextColor) { |
570 NSDictionary* attributes = | 575 NSDictionary* attributes = |
571 @{NSForegroundColorAttributeName : _placeholderTextColor}; | 576 @{NSForegroundColorAttributeName : _placeholderTextColor}; |
572 self.attributedPlaceholder = | 577 self.attributedPlaceholder = |
573 [[NSAttributedString alloc] initWithString:placeholder | 578 [[NSAttributedString alloc] initWithString:placeholder |
574 attributes:attributes]; | 579 attributes:attributes]; |
575 } else { | 580 } else { |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 // Disable the RTL arrow menu item. The omnibox sets alignment based on the | 1008 // Disable the RTL arrow menu item. The omnibox sets alignment based on the |
1004 // text in the field, and should not be overridden. | 1009 // text in the field, and should not be overridden. |
1005 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { | 1010 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { |
1006 return NO; | 1011 return NO; |
1007 } | 1012 } |
1008 | 1013 |
1009 return [super canPerformAction:action withSender:sender]; | 1014 return [super canPerformAction:action withSender:sender]; |
1010 } | 1015 } |
1011 | 1016 |
1012 @end | 1017 @end |
OLD | NEW |