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

Side by Side Diff: ios/chrome/browser/ui/omnibox/omnibox_view_ios.mm

Issue 2803783002: Ensure strikethrough font renders in omnibox on iOS 10.3 (Closed)
Patch Set: Limit workaround to iOS 10.3 and later Created 3 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/omnibox/omnibox_view_ios.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" 5 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h"
6 6
7 #import <CoreText/CoreText.h> 7 #import <CoreText/CoreText.h>
8 #import <MobileCoreServices/MobileCoreServices.h> 8 #import <MobileCoreServices/MobileCoreServices.h>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/ios/device_util.h" 12 #include "base/ios/device_util.h"
13 #include "base/ios/ios_util.h"
13 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
14 #include "base/metrics/user_metrics.h" 15 #include "base/metrics/user_metrics.h"
15 #include "base/metrics/user_metrics_action.h" 16 #include "base/metrics/user_metrics_action.h"
16 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
17 #include "base/strings/sys_string_conversions.h" 18 #include "base/strings/sys_string_conversions.h"
18 #include "components/omnibox/browser/autocomplete_input.h" 19 #include "components/omnibox/browser/autocomplete_input.h"
19 #include "components/omnibox/browser/autocomplete_match.h" 20 #include "components/omnibox/browser/autocomplete_match.h"
20 #include "components/omnibox/browser/omnibox_edit_model.h" 21 #include "components/omnibox/browser/omnibox_edit_model.h"
21 #include "components/omnibox/browser/omnibox_popup_model.h" 22 #include "components/omnibox/browser/omnibox_popup_model.h"
22 #include "components/toolbar/toolbar_model.h" 23 #include "components/toolbar/toolbar_model.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 preloader_(preloader), 181 preloader_(preloader),
181 ignore_popup_updates_(false), 182 ignore_popup_updates_(false),
182 attributing_display_string_(nil) { 183 attributing_display_string_(nil) {
183 popup_view_.reset(new OmniboxPopupViewIOS(this, model(), positioner)); 184 popup_view_.reset(new OmniboxPopupViewIOS(this, model(), positioner));
184 field_delegate_.reset( 185 field_delegate_.reset(
185 [[AutocompleteTextFieldDelegate alloc] initWithEditView:this]); 186 [[AutocompleteTextFieldDelegate alloc] initWithEditView:this]);
186 [field_ setDelegate:field_delegate_]; 187 [field_ setDelegate:field_delegate_];
187 [field_ addTarget:field_delegate_ 188 [field_ addTarget:field_delegate_
188 action:@selector(textFieldDidChange:) 189 action:@selector(textFieldDidChange:)
189 forControlEvents:UIControlEventEditingChanged]; 190 forControlEvents:UIControlEventEditingChanged];
191 use_strikethrough_workaround_ = base::ios::IsRunningOnOrLater(10, 3, 0);
190 } 192 }
191 193
192 OmniboxViewIOS::~OmniboxViewIOS() { 194 OmniboxViewIOS::~OmniboxViewIOS() {
193 // |field_| outlives this object. 195 // |field_| outlives this object.
194 [field_ setDelegate:nil]; 196 [field_ setDelegate:nil];
195 197
196 [field_ removeTarget:field_delegate_ 198 [field_ removeTarget:field_delegate_
197 action:@selector(textFieldDidChange:) 199 action:@selector(textFieldDidChange:)
198 forControlEvents:UIControlEventEditingChanged]; 200 forControlEvents:UIControlEventEditingChanged];
199 201
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 666
665 if ((security_level == security_state::NONE) || 667 if ((security_level == security_state::NONE) ||
666 (security_level == security_state::HTTP_SHOW_WARNING)) { 668 (security_level == security_state::HTTP_SHOW_WARNING)) {
667 return; 669 return;
668 } 670 }
669 671
670 DCHECK_NE(security_state::SECURITY_WARNING, security_level); 672 DCHECK_NE(security_state::SECURITY_WARNING, security_level);
671 DCHECK_NE(security_state::SECURE_WITH_POLICY_INSTALLED_CERT, security_level); 673 DCHECK_NE(security_state::SECURE_WITH_POLICY_INSTALLED_CERT, security_level);
672 674
673 if (security_level == security_state::DANGEROUS) { 675 if (security_level == security_state::DANGEROUS) {
676 if (use_strikethrough_workaround_) {
677 // Workaround: Add extra attribute to allow strikethough to apply on iOS
678 // 10.3+. See https://crbug.com/699702 for discussion.
679 [attributing_display_string_
680 addAttribute:NSBaselineOffsetAttributeName
681 value:@0
682 range:NSMakeRange(0, [attributing_display_string_ length])];
683 }
684
674 // Add a strikethrough through the scheme. 685 // Add a strikethrough through the scheme.
675 [attributing_display_string_ 686 [attributing_display_string_
676 addAttribute:NSStrikethroughStyleAttributeName 687 addAttribute:NSStrikethroughStyleAttributeName
677 value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] 688 value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
678 range:range.ToNSRange()]; 689 range:range.ToNSRange()];
679 } 690 }
680 691
681 UIColor* color = GetSecureTextColor(security_level, [field_ incognito]); 692 UIColor* color = GetSecureTextColor(security_level, [field_ incognito]);
682 if (color) { 693 if (color) {
683 [attributing_display_string_ addAttribute:NSForegroundColorAttributeName 694 [attributing_display_string_ addAttribute:NSForegroundColorAttributeName
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 // is being left out for now because it was not present before the OmniboxView 884 // is being left out for now because it was not present before the OmniboxView
874 // rewrite. 885 // rewrite.
875 #if 0 886 #if 0
876 // When editing is in progress, the url text is not colored, so there is 887 // When editing is in progress, the url text is not colored, so there is
877 // nothing to emphasize. (Calling SetText() in that situation would also be 888 // nothing to emphasize. (Calling SetText() in that situation would also be
878 // harmful, as it would reset the carat position to the end of the text.) 889 // harmful, as it would reset the carat position to the end of the text.)
879 if (!IsEditingOrEmpty()) 890 if (!IsEditingOrEmpty())
880 SetText(GetText()); 891 SetText(GetText());
881 #endif 892 #endif
882 } 893 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/omnibox/omnibox_view_ios.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698