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

Unified Diff: chrome/browser/ui/cocoa/hover_close_button.mm

Issue 11823047: mac: Pixel-based click detection for the tab close button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/tabs/tab_view.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/hover_close_button.mm
diff --git a/chrome/browser/ui/cocoa/hover_close_button.mm b/chrome/browser/ui/cocoa/hover_close_button.mm
index 28322b4eae5c3d77c07bd4afa9e906a6a59b680d..b09abe79d72035bf1d89de830b8ebe45b9566b22 100644
--- a/chrome/browser/ui/cocoa/hover_close_button.mm
+++ b/chrome/browser/ui/cocoa/hover_close_button.mm
@@ -79,6 +79,24 @@ NSString* const kFadeOutValueKeyPath = @"fadeOutValue";
[self animationDidStop:animation];
}
+// Override to only accept clicks within the bounds of the defined path, not
+// the entire bounding box. |aPoint| is in the superview's coordinate system.
+- (NSView*)hitTest:(NSPoint)point {
+ NSPoint localPoint = [self convertPoint:point fromView:[self superview]];
+ NSRect pointRect = NSMakeRect(localPoint.x, localPoint.y, 1, 1);
+
+ NSImage* hoverImage = [self imageForHoverState:kHoverStateMouseOver];
+ NSRect destinationRect = NSMakeRect(
+ 0, 0, NSWidth([self bounds]), NSHeight([self bounds]));
sail 2013/01/10 17:57:19 All our code already assumes that [self bounds] ha
Nico 2013/01/10 23:26:51 Done, thanks.
+ if ([hoverImage hitTestRect:pointRect
+ withImageDestinationRect:destinationRect
+ context:nil
+ hints:nil
+ flipped:YES])
+ return [super hitTest:point];
+ return nil;
+}
+
- (void)drawRect:(NSRect)dirtyRect {
NSImage* image = [self imageForHoverState:[self hoverState]];
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/tabs/tab_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698