| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 fromRect:NSZeroRect | 485 fromRect:NSZeroRect |
| 486 operation:NSCompositeSourceOver | 486 operation:NSCompositeSourceOver |
| 487 fraction:1.0 | 487 fraction:1.0 |
| 488 respectFlipped:YES | 488 respectFlipped:YES |
| 489 hints:nil]; | 489 hints:nil]; |
| 490 | 490 |
| 491 NSPoint origin = | 491 NSPoint origin = |
| 492 NSMakePoint(kMaterialTextStartOffset + [tableView contentLeftPadding], | 492 NSMakePoint(kMaterialTextStartOffset + [tableView contentLeftPadding], |
| 493 kVerticalTextPadding); | 493 kVerticalTextPadding); |
| 494 if ([cellData matchType] == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { | 494 if ([cellData matchType] == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { |
| 495 // Infinite suggestions are rendered with a prefix (usually ellipsis), which | 495 // Tail suggestions are rendered with a prefix (usually ellipsis), which |
| 496 // appear vertically stacked. | 496 // appear vertically stacked. |
| 497 origin.x += [self drawMatchPrefixWithFrame:cellFrame | 497 origin.x += [self drawMatchPrefixWithFrame:cellFrame |
| 498 tableView:tableView | 498 tableView:tableView |
| 499 withContentsMaxWidth:&contentsMaxWidth | 499 withContentsMaxWidth:&contentsMaxWidth |
| 500 forDarkTheme:isDarkTheme]; | 500 forDarkTheme:isDarkTheme]; |
| 501 } | 501 } |
| 502 origin.x += [self drawMatchPart:[cellData contents] | 502 origin.x += [self drawMatchPart:[cellData contents] |
| 503 withFrame:cellFrame | 503 withFrame:cellFrame |
| 504 origin:origin | 504 origin:origin |
| 505 withMaxWidth:contentsMaxWidth | 505 withMaxWidth:contentsMaxWidth |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 // |maxMatchContentsWidth|. If |remainingWidth| is not sufficient to | 562 // |maxMatchContentsWidth|. If |remainingWidth| is not sufficient to |
| 563 // accommodate that, we reduce the offset so that the prefix gets rendered. | 563 // accommodate that, we reduce the offset so that the prefix gets rendered. |
| 564 prefixOffset = std::min( | 564 prefixOffset = std::min( |
| 565 remainingWidth - prefixWidth, | 565 remainingWidth - prefixWidth, |
| 566 std::max([cellData contentsOffset], [tableView maxMatchContentsWidth])); | 566 std::max([cellData contentsOffset], [tableView maxMatchContentsWidth])); |
| 567 offset = std::max<CGFloat>(0.0, prefixOffset - *contentsMaxWidth); | 567 offset = std::max<CGFloat>(0.0, prefixOffset - *contentsMaxWidth); |
| 568 } else { // The direction of contents is same as UI direction. | 568 } else { // The direction of contents is same as UI direction. |
| 569 // Ideally the offset should be |contentsOffset_|. If the max total width | 569 // Ideally the offset should be |contentsOffset_|. If the max total width |
| 570 // (|prefixWidth| + |maxMatchContentsWidth|) from offset will exceed the | 570 // (|prefixWidth| + |maxMatchContentsWidth|) from offset will exceed the |
| 571 // |remainingWidth|, then we shift the offset to the left , so that all | 571 // |remainingWidth|, then we shift the offset to the left , so that all |
| 572 // postfix suggestions are visible. | 572 // tail suggestions are visible. |
| 573 // We have to render the prefix, so offset has to be at least |prefixWidth|. | 573 // We have to render the prefix, so offset has to be at least |prefixWidth|. |
| 574 offset = | 574 offset = |
| 575 std::max(prefixWidth, | 575 std::max(prefixWidth, |
| 576 std::min(remainingWidth - [tableView maxMatchContentsWidth], | 576 std::min(remainingWidth - [tableView maxMatchContentsWidth], |
| 577 [cellData contentsOffset])); | 577 [cellData contentsOffset])); |
| 578 prefixOffset = offset - prefixWidth; | 578 prefixOffset = offset - prefixWidth; |
| 579 } | 579 } |
| 580 *contentsMaxWidth = std::min((int)ceilf(remainingWidth - prefixWidth), | 580 *contentsMaxWidth = std::min((int)ceilf(remainingWidth - prefixWidth), |
| 581 *contentsMaxWidth); | 581 *contentsMaxWidth); |
| 582 NSPoint origin = NSMakePoint( | 582 NSPoint origin = NSMakePoint( |
| (...skipping 96 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 |