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

Side by Side Diff: chrome/browser/cocoa/location_bar/bubble_decoration.mm

Issue 2870059: [Mac] Adjust omnibox decoration dragging to keep image under mouse. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Move method per Trung. Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/location_bar/bubble_decoration.h" 5 #import "chrome/browser/cocoa/location_bar/bubble_decoration.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/cocoa/image_utils.h" 8 #import "chrome/browser/cocoa/image_utils.h"
9 9
10 namespace { 10 namespace {
(...skipping 25 matching lines...) Expand all
36 return kOmittedWidth; 36 return kOmittedWidth;
37 37
38 const CGFloat image_width = image ? [image size].width : 0.0; 38 const CGFloat image_width = image ? [image size].width : 0.0;
39 if (!label) 39 if (!label)
40 return kBubblePadding + image_width; 40 return kBubblePadding + image_width;
41 41
42 const CGFloat label_width = [label sizeWithAttributes:attributes_].width; 42 const CGFloat label_width = [label sizeWithAttributes:attributes_].width;
43 return kBubblePadding + image_width + label_width; 43 return kBubblePadding + image_width + label_width;
44 } 44 }
45 45
46 NSRect BubbleDecoration::GetImageRectInFrame(NSRect frame) {
47 NSRect imageRect = NSInsetRect(frame, 0.0, kKeywordYInset);
48 if (image_)
49 imageRect.size = [image_ size];
50 return imageRect;
51 }
52
46 CGFloat BubbleDecoration::GetWidthForSpace(CGFloat width) { 53 CGFloat BubbleDecoration::GetWidthForSpace(CGFloat width) {
47 const CGFloat all_width = GetWidthForImageAndLabel(image_, label_); 54 const CGFloat all_width = GetWidthForImageAndLabel(image_, label_);
48 if (all_width <= width) 55 if (all_width <= width)
49 return all_width; 56 return all_width;
50 57
51 const CGFloat image_width = GetWidthForImageAndLabel(image_, nil); 58 const CGFloat image_width = GetWidthForImageAndLabel(image_, nil);
52 if (image_width <= width) 59 if (image_width <= width)
53 return image_width; 60 return image_width;
54 61
55 return kOmittedWidth; 62 return kOmittedWidth;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 label_.reset([label copy]); 111 label_.reset([label copy]);
105 } 112 }
106 113
107 void BubbleDecoration::SetColors(NSColor* border_color, 114 void BubbleDecoration::SetColors(NSColor* border_color,
108 NSColor* background_color, 115 NSColor* background_color,
109 NSColor* text_color) { 116 NSColor* text_color) {
110 border_color_.reset([border_color retain]); 117 border_color_.reset([border_color retain]);
111 background_color_.reset([background_color retain]); 118 background_color_.reset([background_color retain]);
112 text_color_.reset([text_color retain]); 119 text_color_.reset([text_color retain]);
113 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/location_bar/bubble_decoration.h ('k') | chrome/browser/cocoa/location_bar/ev_bubble_decoration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698