| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 std::min(NSWidth(renderRect), static_cast<CGFloat>(maxWidth)); | 601 std::min(NSWidth(renderRect), static_cast<CGFloat>(maxWidth)); |
| 602 if (!NSIsEmptyRect(renderRect)) { | 602 if (!NSIsEmptyRect(renderRect)) { |
| 603 [attributedString drawWithRect:FlipIfRTL(renderRect, cellFrame) | 603 [attributedString drawWithRect:FlipIfRTL(renderRect, cellFrame) |
| 604 options:NSStringDrawingUsesLineFragmentOrigin | | 604 options:NSStringDrawingUsesLineFragmentOrigin | |
| 605 NSStringDrawingTruncatesLastVisibleLine]; | 605 NSStringDrawingTruncatesLastVisibleLine]; |
| 606 } | 606 } |
| 607 return NSWidth(renderRect); | 607 return NSWidth(renderRect); |
| 608 } | 608 } |
| 609 | 609 |
| 610 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match { | 610 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match { |
| 611 const base::string16& inputText = base::UTF8ToUTF16( | 611 const base::string16& inputText = |
| 612 match.GetAdditionalInfo(kACMatchPropertyInputText)); | 612 base::UTF8ToUTF16(match.GetAdditionalInfo(kACMatchPropertyContentsText)); |
| 613 int contentsStartIndex = 0; | 613 int contentsStartIndex = 0; |
| 614 base::StringToInt( | 614 base::StringToInt( |
| 615 match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex), | 615 match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex), |
| 616 &contentsStartIndex); | 616 &contentsStartIndex); |
| 617 // Ignore invalid state. | 617 // Ignore invalid state. |
| 618 if (!base::StartsWith(match.fill_into_edit, inputText, | 618 if (!base::StartsWith(match.fill_into_edit, inputText, |
| 619 base::CompareCase::SENSITIVE) || | 619 base::CompareCase::SENSITIVE) || |
| 620 !base::EndsWith(match.fill_into_edit, match.contents, | 620 !base::EndsWith(match.fill_into_edit, match.contents, |
| 621 base::CompareCase::SENSITIVE) || | 621 base::CompareCase::SENSITIVE) || |
| 622 ((size_t)contentsStartIndex >= inputText.length())) { | 622 ((size_t)contentsStartIndex >= inputText.length())) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 base::string16 raw_separator = | 679 base::string16 raw_separator = |
| 680 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); | 680 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
| 681 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); | 681 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); |
| 682 } | 682 } |
| 683 | 683 |
| 684 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame { | 684 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame { |
| 685 return NSWidth(cellFrame) - kMaterialTextStartOffset; | 685 return NSWidth(cellFrame) - kMaterialTextStartOffset; |
| 686 } | 686 } |
| 687 | 687 |
| 688 @end | 688 @end |
| OLD | NEW |