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

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

Issue 1182183003: Move EndsWith to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match { 521 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match {
522 const base::string16& inputText = base::UTF8ToUTF16( 522 const base::string16& inputText = base::UTF8ToUTF16(
523 match.GetAdditionalInfo(kACMatchPropertyInputText)); 523 match.GetAdditionalInfo(kACMatchPropertyInputText));
524 int contentsStartIndex = 0; 524 int contentsStartIndex = 0;
525 base::StringToInt( 525 base::StringToInt(
526 match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex), 526 match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex),
527 &contentsStartIndex); 527 &contentsStartIndex);
528 // Ignore invalid state. 528 // Ignore invalid state.
529 if (!base::StartsWith(match.fill_into_edit, inputText, true) || 529 if (!base::StartsWith(match.fill_into_edit, inputText, true) ||
530 !EndsWith(match.fill_into_edit, match.contents, true) || 530 !base::EndsWith(match.fill_into_edit, match.contents, true) ||
531 ((size_t)contentsStartIndex >= inputText.length())) { 531 ((size_t)contentsStartIndex >= inputText.length())) {
532 return 0; 532 return 0;
533 } 533 }
534 bool isContentsRTL = (base::i18n::RIGHT_TO_LEFT == 534 bool isContentsRTL = (base::i18n::RIGHT_TO_LEFT ==
535 base::i18n::GetFirstStrongCharacterDirection(match.contents)); 535 base::i18n::GetFirstStrongCharacterDirection(match.contents));
536 536
537 // Color does not matter. 537 // Color does not matter.
538 NSAttributedString* attributedString = 538 NSAttributedString* attributedString =
539 CreateAttributedString(inputText, DimTextColor()); 539 CreateAttributedString(inputText, DimTextColor());
540 base::scoped_nsobject<NSTextStorage> textStorage( 540 base::scoped_nsobject<NSTextStorage> textStorage(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 578 }
579 glyphOffset -= minOffset; 579 glyphOffset -= minOffset;
580 if (glyphWidth == 0) 580 if (glyphWidth == 0)
581 glyphWidth = inputWidth - glyphOffset; 581 glyphWidth = inputWidth - glyphOffset;
582 if (isContentsRTL) 582 if (isContentsRTL)
583 glyphOffset += glyphWidth; 583 glyphOffset += glyphWidth;
584 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset; 584 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset;
585 } 585 }
586 586
587 @end 587 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698