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/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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 - (void)updateTextDirection { | 550 - (void)updateTextDirection { |
| 550 // Setting the empty field to Natural seems to let iOS update the cursor | 551 // Setting the empty field to Natural seems to let iOS update the cursor |
| 551 // position when the keyboard language is changed. | 552 // position when the keyboard language is changed. |
| 552 if (![self text].length) { | 553 if (![self text].length) { |
| 553 [self setTextAlignment:NSTextAlignmentNatural]; | 554 [self setTextAlignment:NSTextAlignmentNatural]; |
| 554 return; | 555 return; |
| 555 } | 556 } |
| 556 | 557 |
| 557 NSTextAlignment alignment = [self bestTextAlignment]; | 558 NSTextAlignment alignment = [self bestTextAlignment]; |
| 558 [self setTextAlignment:alignment]; | 559 [self setTextAlignment:alignment]; |
| 559 UITextWritingDirection writingDirection = | 560 if (!base::ios::IsRunningOnIOS11OrLater()) { |
| 560 alignment == NSTextAlignmentLeft ? UITextWritingDirectionLeftToRight | 561 // TODO(crbug.com/730461): Remove this entire block once it's been tested |
|
rohitrao (ping after 24h)
2017/06/14 14:54:11
Can you please update the bug with a detailed desc
justincohen
2017/06/14 16:44:08
Done.
| |
| 561 : UITextWritingDirectionRightToLeft; | 562 // on trunk. |
| 562 [self | 563 UITextWritingDirection writingDirection = |
| 563 setBaseWritingDirection:writingDirection | 564 alignment == NSTextAlignmentLeft ? UITextWritingDirectionLeftToRight |
| 564 forRange:[self | 565 : UITextWritingDirectionRightToLeft; |
| 565 textRangeFromPosition:[self | 566 [self |
| 566 beginningOfDocument] | 567 setBaseWritingDirection:writingDirection |
| 567 toPosition:[self endOfDocument]]]; | 568 forRange: |
| 569 [self | |
| 570 textRangeFromPosition:[self beginningOfDocument] | |
| 571 toPosition:[self endOfDocument]]]; | |
| 572 } | |
| 568 } | 573 } |
| 569 | 574 |
| 570 - (void)setPlaceholder:(NSString*)placeholder { | 575 - (void)setPlaceholder:(NSString*)placeholder { |
| 571 if (placeholder && _placeholderTextColor) { | 576 if (placeholder && _placeholderTextColor) { |
| 572 NSDictionary* attributes = | 577 NSDictionary* attributes = |
| 573 @{NSForegroundColorAttributeName : _placeholderTextColor}; | 578 @{NSForegroundColorAttributeName : _placeholderTextColor}; |
| 574 self.attributedPlaceholder = | 579 self.attributedPlaceholder = |
| 575 [[NSAttributedString alloc] initWithString:placeholder | 580 [[NSAttributedString alloc] initWithString:placeholder |
| 576 attributes:attributes]; | 581 attributes:attributes]; |
| 577 } else { | 582 } else { |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 // Disable the RTL arrow menu item. The omnibox sets alignment based on the | 1020 // Disable the RTL arrow menu item. The omnibox sets alignment based on the |
| 1016 // text in the field, and should not be overridden. | 1021 // text in the field, and should not be overridden. |
| 1017 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { | 1022 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { |
| 1018 return NO; | 1023 return NO; |
| 1019 } | 1024 } |
| 1020 | 1025 |
| 1021 return [super canPerformAction:action withSender:sender]; | 1026 return [super canPerformAction:action withSender:sender]; |
| 1022 } | 1027 } |
| 1023 | 1028 |
| 1024 @end | 1029 @end |
| OLD | NEW |