Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2944)

Unified Diff: ios/chrome/browser/ui/find_bar/find_bar_text_field.mm

Issue 2590473002: Upstream Chrome on iOS source code [5/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/find_bar/find_bar_text_field.mm
diff --git a/ios/chrome/browser/ui/find_bar/find_bar_text_field.mm b/ios/chrome/browser/ui/find_bar/find_bar_text_field.mm
new file mode 100644
index 0000000000000000000000000000000000000000..b75df133f918c5f1eb3c322fb79ae3b9738ffc59
--- /dev/null
+++ b/ios/chrome/browser/ui/find_bar/find_bar_text_field.mm
@@ -0,0 +1,58 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/find_bar/find_bar_text_field.h"
+
+#include "base/i18n/rtl.h"
+#import "ios/chrome/browser/find_in_page/find_in_page_controller.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ui/base/l10n/l10n_util_mac.h"
+
+namespace {
+// Find bar left padding
+const CGFloat kFindBarLeftPadding = 16;
+} // anonymous namespace
+
+@implementation FindBarTextField
+
+@synthesize overlayWidth = _overlayWidth;
+
+#pragma mark - UIView
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ self.textAlignment = NSTextAlignmentNatural;
+ self.accessibilityLabel =
+ l10n_util::GetNSStringWithFixup(IDS_IOS_PLACEHOLDER_FIND_IN_PAGE);
+ }
+ return self;
+}
+
+#pragma mark - Public methods
+
+- (void)setOverlayWidth:(CGFloat)overlayWidth {
+ _overlayWidth = overlayWidth;
+ [self setNeedsLayout];
+}
+
+#pragma mark - UITextField
+
+- (CGRect)textRectForBounds:(CGRect)bounds {
+ return [self editingRectForBounds:bounds];
+}
+
+- (CGRect)editingRectForBounds:(CGRect)bounds {
+ // Reduce the width by the width of the overlay + padding for both sides of
+ // the text.
+ bounds.size.width -= _overlayWidth + 2 * kFindBarLeftPadding;
+ bounds.origin.x += kFindBarLeftPadding;
+
+ // Shift the text to the right side of the overlay for RTL languages.
+ if (base::i18n::IsRTL())
+ bounds.origin.x += _overlayWidth;
+ return bounds;
+}
+
+@end
« no previous file with comments | « ios/chrome/browser/ui/find_bar/find_bar_text_field.h ('k') | ios/chrome/browser/ui/find_bar/find_bar_touch_forwarding_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698