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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 // but there are numerous edge case issues with it, so it's simpler to just | 547 // but there are numerous edge case issues with it, so it's simpler to just |
| 548 // manually update the text alignment and writing direction of the UITextField. | 548 // manually update the text alignment and writing direction of the UITextField. |
| 549 - (void)updateTextDirection { | 549 - (void)updateTextDirection { |
| 550 // Setting the empty field to Natural seems to let iOS update the cursor | 550 // Setting the empty field to Natural seems to let iOS update the cursor |
| 551 // position when the keyboard language is changed. | 551 // position when the keyboard language is changed. |
| 552 if (![self text].length) { | 552 if (![self text].length) { |
| 553 [self setTextAlignment:NSTextAlignmentNatural]; | 553 [self setTextAlignment:NSTextAlignmentNatural]; |
| 554 return; | 554 return; |
| 555 } | 555 } |
| 556 | 556 |
| 557 NSTextAlignment alignment = [self bestTextAlignment]; | 557 NSTextAlignment alignment = [self bestAlignmentForText:[self text]]; |
|
rohitrao (ping after 24h)
2017/06/12 22:08:52
Why is it ok to always use [self text] here?
Is t
| |
| 558 [self setTextAlignment:alignment]; | 558 [self setTextAlignment:alignment]; |
| 559 UITextWritingDirection writingDirection = | 559 UITextWritingDirection writingDirection = |
| 560 alignment == NSTextAlignmentLeft ? UITextWritingDirectionLeftToRight | 560 alignment == NSTextAlignmentLeft ? UITextWritingDirectionLeftToRight |
| 561 : UITextWritingDirectionRightToLeft; | 561 : UITextWritingDirectionRightToLeft; |
| 562 [self | 562 [self |
| 563 setBaseWritingDirection:writingDirection | 563 setBaseWritingDirection:writingDirection |
| 564 forRange:[self | 564 forRange:[self |
| 565 textRangeFromPosition:[self | 565 textRangeFromPosition:[self |
| 566 beginningOfDocument] | 566 beginningOfDocument] |
| 567 toPosition:[self endOfDocument]]]; | 567 toPosition:[self endOfDocument]]]; |
| (...skipping 447 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 | 1015 // Disable the RTL arrow menu item. The omnibox sets alignment based on the |
| 1016 // text in the field, and should not be overridden. | 1016 // text in the field, and should not be overridden. |
| 1017 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { | 1017 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { |
| 1018 return NO; | 1018 return NO; |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 return [super canPerformAction:action withSender:sender]; | 1021 return [super canPerformAction:action withSender:sender]; |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 @end | 1024 @end |
| OLD | NEW |