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

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

Issue 2915283003: Omnibox UI: Confine Cocoa suggestion lines to a single-line. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 557
558 // Have to nudge the baseline down 1pt in Material Design for the text 558 // Have to nudge the baseline down 1pt in Material Design for the text
559 // that follows, so that it's the same as the bottom of the image. 559 // that follows, so that it's the same as the bottom of the image.
560 origin.y += 1; 560 origin.y += 1;
561 } 561 }
562 } else { 562 } else {
563 if (isVerticalLayout) { 563 if (isVerticalLayout) {
564 origin.x = left; 564 origin.x = left;
565 origin.y += halfLineHeight * 2; 565 origin.y += halfLineHeight * 2;
566 } else { 566 } else {
567 origin.x += [self drawMatchPart:[tableView separator] 567 [self drawMatchPart:[tableView separator]
568 withFrame:cellFrame 568 withFrame:cellFrame
569 origin:origin 569 origin:origin
570 withMaxWidth:separatorWidth 570 withMaxWidth:separatorWidth
571 forDarkTheme:isDarkTheme]; 571 forDarkTheme:isDarkTheme];
tommycli 2017/06/02 23:35:07 not strictly speaking related, but just fixing up
tommycli 2017/06/02 23:42:43 Err nevermind, I realized it was correct the way i
572 } 572 }
573 } 573 }
574 [self drawMatchPart:[cellData description] 574 [self drawMatchPart:[cellData description]
575 withFrame:cellFrame 575 withFrame:cellFrame
576 origin:origin 576 origin:origin
577 withMaxWidth:descriptionMaxWidth 577 withMaxWidth:descriptionMaxWidth
578 forDarkTheme:isDarkTheme]; 578 forDarkTheme:isDarkTheme];
579 } 579 }
580 } 580 }
581 581
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString 630 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString
631 withFrame:(NSRect)cellFrame 631 withFrame:(NSRect)cellFrame
632 origin:(NSPoint)origin 632 origin:(NSPoint)origin
633 withMaxWidth:(int)maxWidth 633 withMaxWidth:(int)maxWidth
634 forDarkTheme:(BOOL)isDarkTheme { 634 forDarkTheme:(BOOL)isDarkTheme {
635 NSRect renderRect = NSIntersectionRect( 635 NSRect renderRect = NSIntersectionRect(
636 cellFrame, NSOffsetRect(cellFrame, origin.x, origin.y)); 636 cellFrame, NSOffsetRect(cellFrame, origin.x, origin.y));
637 renderRect.size.width = 637 renderRect.size.width =
638 std::min(NSWidth(renderRect), static_cast<CGFloat>(maxWidth)); 638 std::min(NSWidth(renderRect), static_cast<CGFloat>(maxWidth));
639 renderRect.size.height = std::min(NSWidth(renderRect), kDefaultTextHeight);
639 if (!NSIsEmptyRect(renderRect)) { 640 if (!NSIsEmptyRect(renderRect)) {
640 [attributedString drawWithRect:FlipIfRTL(renderRect, cellFrame) 641 [attributedString drawWithRect:FlipIfRTL(renderRect, cellFrame)
641 options:NSStringDrawingUsesLineFragmentOrigin | 642 options:NSStringDrawingUsesLineFragmentOrigin |
642 NSStringDrawingTruncatesLastVisibleLine]; 643 NSStringDrawingTruncatesLastVisibleLine];
643 } 644 }
644 return NSWidth(renderRect); 645 return NSWidth(renderRect);
645 } 646 }
646 647
647 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match { 648 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match {
648 const base::string16& inputText = base::UTF8ToUTF16( 649 const base::string16& inputText = base::UTF8ToUTF16(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 724 }
724 725
725 + (CGFloat)getContentTextHeightForDoubleLine:(BOOL)isDoubleLine { 726 + (CGFloat)getContentTextHeightForDoubleLine:(BOOL)isDoubleLine {
726 CGFloat height = kDefaultTextHeight + 2 * GetVerticalMargin(); 727 CGFloat height = kDefaultTextHeight + 2 * GetVerticalMargin();
727 if (isDoubleLine) 728 if (isDoubleLine)
728 height += kDefaultTextHeight + kDefaultVerticalMargin; 729 height += kDefaultTextHeight + kDefaultVerticalMargin;
729 return height; 730 return height;
730 } 731 }
731 732
732 @end 733 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698