| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/location_bar/button_decoration.h" | 7 #import "chrome/browser/ui/cocoa/location_bar/button_decoration.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 ButtonState old_state = GetButtonState(); | 28 ButtonState old_state = GetButtonState(); |
| 29 SetButtonState(ButtonDecoration::kButtonStatePressed); | 29 SetButtonState(ButtonDecoration::kButtonStatePressed); |
| 30 [control_view setNeedsDisplay:YES]; | 30 [control_view setNeedsDisplay:YES]; |
| 31 | 31 |
| 32 bool handled = OnMousePressed(frame); | 32 bool handled = OnMousePressed(frame); |
| 33 | 33 |
| 34 SetButtonState(old_state); | 34 SetButtonState(old_state); |
| 35 return handled; | 35 return handled; |
| 36 } | 36 } |
| 37 | 37 |
| 38 CGFloat ButtonDecoration::GetWidthForSpace(CGFloat width) { | 38 CGFloat ButtonDecoration::GetWidthForSpace(CGFloat width, CGFloat text_width) { |
| 39 NSImage* image = GetImage(); | 39 NSImage* image = GetImage(); |
| 40 if (image) { | 40 if (image) { |
| 41 const CGFloat image_width = [image size].width; | 41 const CGFloat image_width = [image size].width; |
| 42 if (image_width <= width) | 42 if (image_width <= width) |
| 43 return image_width; | 43 return image_width; |
| 44 } | 44 } |
| 45 return kOmittedWidth; | 45 return kOmittedWidth; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ButtonDecoration::DrawInFrame(NSRect frame, NSView* control_view) { | 48 void ButtonDecoration::DrawInFrame(NSRect frame, NSView* control_view) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 DCHECK(hover_image_.get()); | 89 DCHECK(hover_image_.get()); |
| 90 return hover_image_.get(); | 90 return hover_image_.get(); |
| 91 case kButtonStatePressed: | 91 case kButtonStatePressed: |
| 92 DCHECK(pressed_image_.get()); | 92 DCHECK(pressed_image_.get()); |
| 93 return pressed_image_.get(); | 93 return pressed_image_.get(); |
| 94 default: | 94 default: |
| 95 NOTREACHED(); | 95 NOTREACHED(); |
| 96 return nil; | 96 return nil; |
| 97 } | 97 } |
| 98 } | 98 } |
| OLD | NEW |