| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |