Commit 7b56a573 authored by tommycli's avatar tommycli Committed by Commit Bot

Omnibox UI: Create right-margin on Cocoa dropdown

BUG=729197
TBR=groby@chromium.org

Review-Url: https://codereview.chromium.org/2927193002
Cr-Commit-Position: refs/heads/master@{#478801}
parent 6cdbe506
......@@ -66,7 +66,7 @@ class OmniboxPopupViewMac;
+ (NSAttributedString*)createSeparatorStringForDarkTheme:(BOOL)isDarkTheme;
+ (CGFloat)getContentAreaWidth:(NSRect)cellFrame;
+ (CGFloat)getTextContentAreaWidth:(CGFloat)cellContentMaxWidth;
+ (CGFloat)getContentTextHeightForDoubleLine:(BOOL)isDoubleLine;
......
......@@ -483,8 +483,8 @@ NSAttributedString* CreateClassifiedAttributedString(
base::mac::ObjCCastStrict<OmniboxPopupCellData>([self objectValue]);
OmniboxPopupMatrix* tableView =
base::mac::ObjCCastStrict<OmniboxPopupMatrix>(controlView);
CGFloat remainingWidth = [OmniboxPopupCell getContentAreaWidth:cellFrame] -
[tableView contentLeftPadding];
CGFloat remainingWidth =
[OmniboxPopupCell getTextContentAreaWidth:[tableView contentMaxWidth]];
CGFloat contentsWidth = [cellData getMatchContentsWidth];
CGFloat separatorWidth = [[tableView separator] size].width;
CGFloat descriptionWidth =
......@@ -586,8 +586,8 @@ NSAttributedString* CreateClassifiedAttributedString(
OmniboxPopupCellData* cellData =
base::mac::ObjCCastStrict<OmniboxPopupCellData>([self objectValue]);
CGFloat offset = 0.0f;
CGFloat remainingWidth = [OmniboxPopupCell getContentAreaWidth:cellFrame] -
[tableView contentLeftPadding];
CGFloat remainingWidth =
[OmniboxPopupCell getTextContentAreaWidth:[tableView contentMaxWidth]];
CGFloat prefixWidth = [[cellData prefix] size].width;
CGFloat prefixOffset = 0.0f;
......@@ -720,8 +720,8 @@ NSAttributedString* CreateClassifiedAttributedString(
return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme));
}
+ (CGFloat)getContentAreaWidth:(NSRect)cellFrame {
return NSWidth(cellFrame) - kMaterialTextStartOffset;
+ (CGFloat)getTextContentAreaWidth:(CGFloat)cellContentMaxWidth {
return cellContentMaxWidth - kMaterialTextStartOffset;
}
+ (CGFloat)getContentTextHeightForDoubleLine:(BOOL)isDoubleLine {
......
......@@ -72,6 +72,9 @@ class OmniboxPopupMatrixObserver {
// Left margin padding for the content (i.e. icon and text) in a cell.
CGFloat contentLeftPadding_;
// Max width for the content in the cell.
CGFloat contentMaxWidth_;
// true if the OmniboxPopupMatrix should use the dark theme style.
BOOL hasDarkTheme_;
}
......@@ -80,6 +83,7 @@ class OmniboxPopupMatrixObserver {
@property(nonatomic) CGFloat maxMatchContentsWidth;
@property(nonatomic) CGFloat answerLineHeight;
@property(nonatomic) CGFloat contentLeftPadding;
@property(nonatomic) CGFloat contentMaxWidth;
@property(readonly, nonatomic) BOOL hasDarkTheme;
// Create a zero-size matrix.
......
......@@ -122,8 +122,8 @@ const NSInteger kMiddleButtonNumber = 2;
base::mac::ObjCCastStrict<OmniboxPopupCellData>(
[array_ objectAtIndex:row]);
// Subtract any Material Design padding and/or icon.
rowRect.size.width = [OmniboxPopupCell getContentAreaWidth:rowRect] -
[matrix contentLeftPadding];
rowRect.size.width =
[OmniboxPopupCell getTextContentAreaWidth:[matrix contentMaxWidth]];
NSAttributedString* text = [cellData description];
// Provide no more than 3 lines of space.
rowRect.size.height =
......@@ -146,6 +146,7 @@ const NSInteger kMiddleButtonNumber = 2;
@synthesize separator = separator_;
@synthesize maxMatchContentsWidth = maxMatchContentsWidth_;
@synthesize contentLeftPadding = contentLeftPadding_;
@synthesize contentMaxWidth = contentMaxWidth_;
@synthesize answerLineHeight = answerLineHeight_;
@synthesize hasDarkTheme = hasDarkTheme_;
......
......@@ -273,6 +273,7 @@ void OmniboxPopupViewMac::PositionPopup(const CGFloat matrixHeight) {
NSRect matrix_frame = NSZeroRect;
matrix_frame.origin.x = 0;
[matrix_ setContentLeftPadding:match_omnibox_width ? 0 : field_origin_base.x];
[matrix_ setContentMaxWidth:NSWidth([field_ bounds])];
matrix_frame.origin.y = PopupPaddingVertical();
matrix_frame.size.width = table_width;
matrix_frame.size.height = matrixHeight;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment