| OLD | NEW |
| 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 Loading... |
| 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, true) || | 566 if (!base::StartsWith(match.fill_into_edit, inputText, |
| 567 !base::EndsWith(match.fill_into_edit, match.contents, true) || | 567 base::CompareCase::SENSITIVE) || |
| 568 !base::EndsWith(match.fill_into_edit, match.contents, |
| 569 base::CompareCase::SENSITIVE) || |
| 568 ((size_t)contentsStartIndex >= inputText.length())) { | 570 ((size_t)contentsStartIndex >= inputText.length())) { |
| 569 return 0; | 571 return 0; |
| 570 } | 572 } |
| 571 bool isContentsRTL = (base::i18n::RIGHT_TO_LEFT == | 573 bool isContentsRTL = (base::i18n::RIGHT_TO_LEFT == |
| 572 base::i18n::GetFirstStrongCharacterDirection(match.contents)); | 574 base::i18n::GetFirstStrongCharacterDirection(match.contents)); |
| 573 | 575 |
| 574 // Color does not matter. | 576 // Color does not matter. |
| 575 NSAttributedString* attributedString = | 577 NSAttributedString* attributedString = |
| 576 CreateAttributedString(inputText, DimTextColor()); | 578 CreateAttributedString(inputText, DimTextColor()); |
| 577 base::scoped_nsobject<NSTextStorage> textStorage( | 579 base::scoped_nsobject<NSTextStorage> textStorage( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset; | 623 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset; |
| 622 } | 624 } |
| 623 | 625 |
| 624 + (NSAttributedString*)createSeparatorString { | 626 + (NSAttributedString*)createSeparatorString { |
| 625 base::string16 raw_separator = | 627 base::string16 raw_separator = |
| 626 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); | 628 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
| 627 return CreateAttributedString(raw_separator, DimTextColor()); | 629 return CreateAttributedString(raw_separator, DimTextColor()); |
| 628 } | 630 } |
| 629 | 631 |
| 630 @end | 632 @end |
| OLD | NEW |