Commit 2c6bf0a6 authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

[iOS] Only disable clipping for long URLs on iOS 12.

Adds a check for the URL length and only disables clipping on URLs
longer than 800 characters.

Bug: 860790
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Idf7ccf4582a107ca61e384451dd1415b63337dc0
Reviewed-on: https://chromium-review.googlesource.com/1160491
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580517}
parent 2c920ffc
......@@ -14,6 +14,17 @@
#error "This file requires ARC support."
#endif
namespace {
// Clipping of long URLs is disabled on iOS 12 due to a bug with UITextField
// not being rendered when the backing layer is large (approx. 915
// characters with current font). This is used as the max number of characters
// to clip.
// TODO(crbug.com/860790) : reenable clipping on iOS 12.
const CGFloat kMaxCharsToClipOnIOS12 = 800;
} // namespace
@interface ClippingTextFieldContainer ()
@property(nonatomic, strong) NSLayoutConstraint* leftConstraint;
......@@ -69,11 +80,12 @@
}
- (void)startClipping {
// TODO(crbug.com/860790) : reenable this.
if (base::ios::IsRunningOnIOS12OrLater()) {
// Clipping is disabled on iOS 12 due to a bug with UITextField not being
// rendered when the backing layer is large (approx. 915 characters with
// current font).
// TODO(crbug.com/860790) : reenable clipping on iOS 12.
if (base::ios::IsRunningOnIOS12OrLater() &&
self.textField.text.length > kMaxCharsToClipOnIOS12) {
// Clipping of long URLs is disabled on iOS 12 due to a bug with UITextField
// not being rendered when the backing layer is large (approx. 915
// characters with current font).
return;
}
......@@ -84,6 +96,16 @@
}
- (void)applyClipping {
// TODO(crbug.com/860790) : reenable clipping on iOS 12.
if (base::ios::IsRunningOnIOS12OrLater() &&
self.textField.text.length > kMaxCharsToClipOnIOS12) {
// Clipping of long URLs is disabled on iOS 12 due to a bug with UITextField
// not being rendered when the backing layer is large (approx. 915
// characters with current font).
[self stopClipping];
return;
}
CGFloat suffixWidth = 0;
CGFloat prefixWidth =
-[self leftConstantWithAttributedText:self.textField.attributedText
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment