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

Unified Diff: chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.mm

Issue 273883002: Always display the origin chip, even if it won't fit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.mm b/chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.mm
index 43ca9adc3302e025647f5a785ff4506305785368..15f62dc036ed4ce59ccb0538cc5e06322d7a5bac 100644
--- a/chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.mm
@@ -125,27 +125,18 @@ void OriginChipDecoration::Update() {
}
CGFloat OriginChipDecoration::GetWidthForSpace(CGFloat width) {
- NSImage* icon = GetIconImage();
- if (!icon || [label_ length] == 0)
+ if (!GetIconImage() || [label_ length] == 0)
return kOmittedWidth;
- const CGFloat label_width = [label_ sizeWithAttributes:attributes_].width;
- const CGFloat min_width = kInnerLeftPadding +
- kIconSize +
- kIconLabelPadding +
- std::ceil(label_width) +
- kInnerRightPadding +
- kOuterRightPadding;
-
- return (width < min_width) ? kOmittedWidth : min_width;
+ // Clip the chip if it can't fit, rather than hiding it (kOmittedWidth).
+ return std::min(width, GetChipWidth() + kOuterRightPadding);
}
void OriginChipDecoration::DrawInFrame(NSRect frame, NSView* control_view) {
// The assets are aligned with the location bar assets, so check that we are
// being asked to draw against the edge, then draw over the border.
DCHECK(NSMinX(frame) == [control_view cr_lineWidth]);
- frame = NSMakeRect(0, NSMinY(frame), NSWidth(frame) - kOuterRightPadding,
- NSHeight(frame));
+ frame = NSMakeRect(0, NSMinY(frame), GetChipWidth(), NSHeight(frame));
const ui::NinePartImageIds image_ids = GetBackgroundImageIds();
@@ -224,6 +215,14 @@ bool OriginChipDecoration::ShouldShow() const {
owner_->GetToolbarModel()->origin_chip_enabled());
}
+CGFloat OriginChipDecoration::GetChipWidth() const {
+ return kInnerLeftPadding +
+ kIconSize +
+ kIconLabelPadding +
+ std::ceil([label_ sizeWithAttributes:attributes_].width) +
+ kInnerRightPadding;
+}
+
// TODO(macourteau): Implement eliding of the host.
// TODO(macourteau): Implement dragging support.
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698