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

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

Issue 3046016: Restrict new tab button clicks to inside the image bounds, not anywhere in th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/new_tab_button.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "chrome/browser/cocoa/new_tab_button.h"
6
7 @implementation NewTabButton
8
9 // Approximate the shape. It doesn't need to be perfect. This will need to be
10 // updated if the size or shape of the icon ever changes.
11 // TODO(pinkerton): use a click mask image instead of hard-coding points.
12 - (NSBezierPath*)pathForButton {
13 if (imagePath_.get())
14 return imagePath_.get();
15
16 // Cache the path as it doesn't change (the coordinates are local to this
17 // view). There's not much point making constants for these, as they are
18 // custom.
19 imagePath_.reset([[NSBezierPath bezierPath] retain]);
20 [imagePath_ moveToPoint:NSMakePoint(9, 7)];
21 [imagePath_ lineToPoint:NSMakePoint(26, 7)];
22 [imagePath_ lineToPoint:NSMakePoint(33, 23)];
23 [imagePath_ lineToPoint:NSMakePoint(14, 23)];
24 [imagePath_ lineToPoint:NSMakePoint(9, 7)];
25 return imagePath_;
26 }
27
28 // Override to only accept clicks within the bounds of the defined path, not
29 // the entire bounding box. |aPoint| is in the superview's coordinate system.
30 - (NSView*)hitTest:(NSPoint)aPoint {
31 NSBezierPath* buttonPath = [self pathForButton];
32 NSPoint localPoint = [self convertPoint:aPoint fromView:[self superview]];
33 if ([buttonPath containsPoint:localPoint])
34 return [super hitTest:aPoint];
35 return nil;
36 }
37
38 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/new_tab_button.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698