| 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 // apply an image mask to fade out beginning and/or end of the URL. | 783 // apply an image mask to fade out beginning and/or end of the URL. |
| 784 gfx::ScopedCGContextSaveGState saver(UIGraphicsGetCurrentContext()); | 784 gfx::ScopedCGContextSaveGState saver(UIGraphicsGetCurrentContext()); |
| 785 [super drawTextInRect:[self rectForDrawTextInRect:rect]]; | 785 [super drawTextInRect:[self rectForDrawTextInRect:rect]]; |
| 786 } | 786 } |
| 787 | 787 |
| 788 - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event { | 788 - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event { |
| 789 // Anything in the narrow bar above OmniboxTextFieldIOS view | 789 // Anything in the narrow bar above OmniboxTextFieldIOS view |
| 790 // will also activate the text field. | 790 // will also activate the text field. |
| 791 if (point.y < 0) | 791 if (point.y < 0) |
| 792 point.y = 0; | 792 point.y = 0; |
| 793 UIView* view = [super hitTest:point withEvent:event]; | 793 return [super hitTest:point withEvent:event]; |
| 794 | |
| 795 // For some reason when the |leftView| has interaction enabled, hitTest | |
| 796 // returns the leftView even when |point| is 50 pixels to the right. Tapping | |
| 797 // the hint text will fire the leftView, causing b/6281652. Fails especially | |
| 798 // on iPad and iPhone devices in landscape mode. | |
| 799 // TODO(crbug.com/546295): Check to see if this UIKit bug is fixed, and remove | |
| 800 // this workaround. | |
| 801 UIView* leftView = [self leftView]; | |
| 802 if (leftView) { | |
| 803 if (leftView == view && !CGRectContainsPoint([leftView frame], point)) { | |
| 804 return self; | |
| 805 } else if ([self leftViewMode] == UITextFieldViewModeAlways) { | |
| 806 CGRect targetFrame = CGRectInset([leftView frame], -5, -5); | |
| 807 if (CGRectContainsPoint(targetFrame, point)) { | |
| 808 return leftView; | |
| 809 } | |
| 810 } | |
| 811 } | |
| 812 return view; | |
| 813 } | 794 } |
| 814 | 795 |
| 815 - (BOOL)isTextFieldLTR { | 796 - (BOOL)isTextFieldLTR { |
| 816 return [[self class] userInterfaceLayoutDirectionForSemanticContentAttribute: | 797 return [[self class] userInterfaceLayoutDirectionForSemanticContentAttribute: |
| 817 self.semanticContentAttribute] == | 798 self.semanticContentAttribute] == |
| 818 UIUserInterfaceLayoutDirectionLeftToRight; | 799 UIUserInterfaceLayoutDirectionLeftToRight; |
| 819 } | 800 } |
| 820 | 801 |
| 821 // Overriding this method to offset the rightView property | 802 // Overriding this method to offset the rightView property |
| 822 // (containing a clear text button). | 803 // (containing a clear text button). |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 // 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 |
| 1035 // text in the field, and should not be overridden. | 1016 // text in the field, and should not be overridden. |
| 1036 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { | 1017 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { |
| 1037 return NO; | 1018 return NO; |
| 1038 } | 1019 } |
| 1039 | 1020 |
| 1040 return [super canPerformAction:action withSender:sender]; | 1021 return [super canPerformAction:action withSender:sender]; |
| 1041 } | 1022 } |
| 1042 | 1023 |
| 1043 @end | 1024 @end |
| OLD | NEW |