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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm

Issue 1233453011: Revert of Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 556 }
557 557
558 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match { 558 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match {
559 const base::string16& inputText = base::UTF8ToUTF16( 559 const base::string16& inputText = base::UTF8ToUTF16(
560 match.GetAdditionalInfo(kACMatchPropertyInputText)); 560 match.GetAdditionalInfo(kACMatchPropertyInputText));
561 int contentsStartIndex = 0; 561 int contentsStartIndex = 0;
562 base::StringToInt( 562 base::StringToInt(
563 match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex), 563 match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex),
564 &contentsStartIndex); 564 &contentsStartIndex);
565 // Ignore invalid state. 565 // Ignore invalid state.
566 if (!base::StartsWith(match.fill_into_edit, inputText, 566 if (!base::StartsWith(match.fill_into_edit, inputText, true) ||
567 base::CompareCase::SENSITIVE) || 567 !base::EndsWith(match.fill_into_edit, match.contents, true) ||
568 !base::EndsWith(match.fill_into_edit, match.contents,
569 base::CompareCase::SENSITIVE) ||
570 ((size_t)contentsStartIndex >= inputText.length())) { 568 ((size_t)contentsStartIndex >= inputText.length())) {
571 return 0; 569 return 0;
572 } 570 }
573 bool isContentsRTL = (base::i18n::RIGHT_TO_LEFT == 571 bool isContentsRTL = (base::i18n::RIGHT_TO_LEFT ==
574 base::i18n::GetFirstStrongCharacterDirection(match.contents)); 572 base::i18n::GetFirstStrongCharacterDirection(match.contents));
575 573
576 // Color does not matter. 574 // Color does not matter.
577 NSAttributedString* attributedString = 575 NSAttributedString* attributedString =
578 CreateAttributedString(inputText, DimTextColor()); 576 CreateAttributedString(inputText, DimTextColor());
579 base::scoped_nsobject<NSTextStorage> textStorage( 577 base::scoped_nsobject<NSTextStorage> textStorage(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset; 621 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset;
624 } 622 }
625 623
626 + (NSAttributedString*)createSeparatorString { 624 + (NSAttributedString*)createSeparatorString {
627 base::string16 raw_separator = 625 base::string16 raw_separator =
628 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); 626 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR);
629 return CreateAttributedString(raw_separator, DimTextColor()); 627 return CreateAttributedString(raw_separator, DimTextColor());
630 } 628 }
631 629
632 @end 630 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698