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

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

Issue 1858823003: [Mac] Display no icon for ZOOM_NORMAL state in zoom decoration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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/zoom_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
index 9222a30dd3976c87d9e01ffa55ccedad0faeaf14..8b5b27be631f9f5502c140957b970087e715fc73 100644
--- a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
@@ -98,20 +98,35 @@ void ZoomDecoration::ShowAndUpdateUI(ui_zoom::ZoomController* zoom_controller,
NSString* tooltip_string,
bool location_bar_is_dark) {
if (ui::MaterialDesignController::IsModeMaterial()) {
+ gfx::VectorIconId iconId = gfx::VectorIconId::VECTOR_ICON_NONE;
ui_zoom::ZoomController::RelativeZoom relative_zoom =
zoom_controller->GetZoomRelativeToDefault();
- // There is no ZOOM_NORMAL under Material Design.
- gfx::VectorIconId iconId =
- relative_zoom == ui_zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM
- ? gfx::VectorIconId::ZOOM_MINUS
- : gfx::VectorIconId::ZOOM_PLUS;
-
- SkColor vectorIconColor = location_bar_is_dark ? SK_ColorWHITE
- : gfx::kChromeIconGrey;
- NSImage* theImage =
- NSImageFromImageSkia(gfx::CreateVectorIcon(iconId,
- 16,
- vectorIconColor));
+ if (relative_zoom == ui_zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM) {
+ iconId = gfx::VectorIconId::ZOOM_MINUS;
+ } else if (relative_zoom ==
+ ui_zoom::ZoomController::ZOOM_ABOVE_DEFAULT_ZOOM) {
+ iconId = gfx::VectorIconId::ZOOM_PLUS;
+ }
+
+ NSImage* theImage = nil;
+ if (iconId != gfx::VectorIconId::VECTOR_ICON_NONE) {
+ SkColor vectorIconColor = location_bar_is_dark ? SK_ColorWHITE
+ : gfx::kChromeIconGrey;
+ theImage = NSImageFromImageSkia(gfx::CreateVectorIcon(iconId,
+ 16,
+ vectorIconColor));
+ } else {
+ // Under Material Design there is no icon for ZOOM_NORMAL. This means
+ // it should be OK to set a nil image. However if the user is actively
+ // changing the zoom level and drives it back to 100%, there will be no
+ // icon and the zoom bubble will still be visible. ShowBubble() asks the
+ // autocomplete textfield for the zoom decoration's frame in order to
+ // position the bubble, but when the decoration's image is nil it has
+ // no frame. The result is the bubble positioned incorrectly. So, we have
+ // to set an empty image.
+ theImage =
+ [[[NSImage alloc] initWithSize:NSMakeSize(16, 16)] autorelease];
+ }
SetImage(theImage);
} else {
int image_id = IDR_ZOOM_NORMAL;
« 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