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

Side by Side Diff: chrome/browser/cocoa/status_bubble_mac.mm

Issue 178036: Status bubble obscures a link when download shelf is visible (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 11 years, 3 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 | Annotate | Revision Log
« 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/cocoa/status_bubble_mac.h" 5 #include "chrome/browser/cocoa/status_bubble_mac.h"
6 6
7 #include "app/gfx/text_elider.h" 7 #include "app/gfx/text_elider.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (!window_) 142 if (!window_)
143 return; 143 return;
144 144
145 NSPoint cursor_location = [NSEvent mouseLocation]; 145 NSPoint cursor_location = [NSEvent mouseLocation];
146 --cursor_location.y; // docs say the y coord starts at 1 not 0; don't ask why 146 --cursor_location.y; // docs say the y coord starts at 1 not 0; don't ask why
147 147
148 // Get the normal position of the frame. 148 // Get the normal position of the frame.
149 NSRect window_frame = [window_ frame]; 149 NSRect window_frame = [window_ frame];
150 window_frame.origin = [parent_ frame].origin; 150 window_frame.origin = [parent_ frame].origin;
151 151
152 // Adjust the position to sit on top of download shelf.
153 // |delegate_| can be nil during unit tests.
154 if (is_download_shelf_visible_) {
155 if ([delegate_ respondsToSelector:@selector(verticalOffsetForStatusBubble)])
156 window_frame.origin.y += [delegate_ verticalOffsetForStatusBubble];
157 }
158
152 // Get the cursor position relative to the popup. 159 // Get the cursor position relative to the popup.
153 cursor_location.x -= NSMaxX(window_frame); 160 cursor_location.x -= NSMaxX(window_frame);
154 cursor_location.y -= NSMaxY(window_frame); 161 cursor_location.y -= NSMaxY(window_frame);
155 162
156 // If the mouse is in a position where we think it would move the 163 // If the mouse is in a position where we think it would move the
157 // status bubble, figure out where and how the bubble should be moved. 164 // status bubble, figure out where and how the bubble should be moved.
158 if (cursor_location.y < kMousePadding && 165 if (cursor_location.y < kMousePadding &&
159 cursor_location.x < kMousePadding) { 166 cursor_location.x < kMousePadding) {
160 int offset = kMousePadding - cursor_location.y; 167 int offset = kMousePadding - cursor_location.y;
161 168
(...skipping 18 matching lines...) Expand all
180 [[window_ contentView] setStyle:STYLE_STANDARD]; 187 [[window_ contentView] setStyle:STYLE_STANDARD];
181 } 188 }
182 189
183 offset_ = offset; 190 offset_ = offset;
184 window_frame.origin.y -= offset; 191 window_frame.origin.y -= offset;
185 } else { 192 } else {
186 offset_ = 0; 193 offset_ = 0;
187 [[window_ contentView] setStyle:STYLE_STANDARD]; 194 [[window_ contentView] setStyle:STYLE_STANDARD];
188 } 195 }
189 196
190 // |delegate_| can be nil during unit tests.
191 if (is_download_shelf_visible_) {
192 if ([delegate_ respondsToSelector:@selector(verticalOffsetForStatusBubble)])
193 window_frame.origin.y += [delegate_ verticalOffsetForStatusBubble];
194 }
195
196 [window_ setFrame:window_frame display:YES]; 197 [window_ setFrame:window_frame display:YES];
197 } 198 }
198 199
199 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { 200 void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) {
200 is_download_shelf_visible_ = visible; 201 is_download_shelf_visible_ = visible;
201 } 202 }
202 203
203 void StatusBubbleMac::Create() { 204 void StatusBubbleMac::Create() {
204 if (window_) 205 if (window_)
205 return; 206 return;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 329
329 NSDictionary* textDict = [NSDictionary dictionaryWithObjectsAndKeys: 330 NSDictionary* textDict = [NSDictionary dictionaryWithObjectsAndKeys:
330 textFont, NSFontAttributeName, 331 textFont, NSFontAttributeName,
331 textShadow, NSShadowAttributeName, 332 textShadow, NSShadowAttributeName,
332 nil]; 333 nil];
333 [content_ drawAtPoint:NSMakePoint(kTextPositionX, kTextPositionY) 334 [content_ drawAtPoint:NSMakePoint(kTextPositionX, kTextPositionY)
334 withAttributes:textDict]; 335 withAttributes:textDict];
335 } 336 }
336 337
337 @end 338 @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