Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / base / cocoa / controls / hover_image_menu_button.mm
blob85a311885bde1ea4f89f919693d7701c6ec6b14c
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "ui/base/cocoa/controls/hover_image_menu_button.h"
7 #include "base/mac/foundation_util.h"
8 #import "ui/base/cocoa/controls/hover_image_menu_button_cell.h"
10 @implementation HoverImageMenuButton
12 + (Class)cellClass {
13   return [HoverImageMenuButtonCell class];
16 - (id)initWithFrame:(NSRect)frameRect
17           pullsDown:(BOOL)flag {
18   if ((self = [super initWithFrame:frameRect
19                          pullsDown:flag])) {
20     trackingArea_.reset(
21         [[CrTrackingArea alloc] initWithRect:NSZeroRect
22                                      options:NSTrackingInVisibleRect |
23                                              NSTrackingMouseEnteredAndExited |
24                                              NSTrackingActiveInKeyWindow
25                                        owner:self
26                                     userInfo:nil]);
27     [self addTrackingArea:trackingArea_.get()];
28   }
29   return self;
32 - (HoverImageMenuButtonCell*)hoverImageMenuButtonCell {
33   return base::mac::ObjCCastStrict<HoverImageMenuButtonCell>([self cell]);
36 - (void)mouseEntered:(NSEvent*)theEvent {
37   [[self cell] setHovered:YES];
40 - (void)mouseExited:(NSEvent*)theEvent {
41   [[self cell] setHovered:NO];
44 @end