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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_view.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: sail 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/hover_close_button.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/themes/theme_service.h" 8 #include "chrome/browser/themes/theme_service.h"
9 #import "chrome/browser/ui/cocoa/nsview_additions.h" 9 #import "chrome/browser/ui/cocoa/nsview_additions.h"
10 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 10 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 - (void)setTrackingEnabled:(BOOL)enabled { 140 - (void)setTrackingEnabled:(BOOL)enabled {
141 if (![closeButton_ isHidden]) { 141 if (![closeButton_ isHidden]) {
142 [closeButton_ setTrackingEnabled:enabled]; 142 [closeButton_ setTrackingEnabled:enabled];
143 } 143 }
144 } 144 }
145 145
146 // Determines which view a click in our frame actually hit. It's either this 146 // Determines which view a click in our frame actually hit. It's either this
147 // view or our child close button. 147 // view or our child close button.
148 - (NSView*)hitTest:(NSPoint)aPoint { 148 - (NSView*)hitTest:(NSPoint)aPoint {
149 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; 149 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]];
150 if (![closeButton_ isHidden]) 150 if (![closeButton_ isHidden]) {
151 if (NSPointInRect(viewPoint, [closeButton_ frame])) return closeButton_; 151 if (NSPointInRect(viewPoint,[closeButton_ frame]) &&
152 [closeButton_ hitTest:viewPoint]) {
153 return closeButton_;
154 }
155 }
152 156
153 NSRect pointRect = NSMakeRect(viewPoint.x, viewPoint.y, 1, 1); 157 NSRect pointRect = NSMakeRect(viewPoint.x, viewPoint.y, 1, 1);
154 158
155 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 159 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
156 NSImage* left = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage(); 160 NSImage* left = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage();
157 if (viewPoint.x < [left size].width) { 161 if (viewPoint.x < [left size].width) {
158 NSRect imageRect = NSMakeRect(0, 0, [left size].width, [left size].height); 162 NSRect imageRect = NSMakeRect(0, 0, [left size].width, [left size].height);
159 if ([left hitTestRect:pointRect withImageDestinationRect:imageRect 163 if ([left hitTestRect:pointRect withImageDestinationRect:imageRect
160 context:nil hints:nil flipped:NO]) { 164 context:nil hints:nil flipped:NO]) {
161 return self; 165 return self;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; 700 CGFloat middleWidth = tabWidth - leftWidth - rightWidth;
697 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); 701 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight);
698 [[NSColor whiteColor] setFill]; 702 [[NSColor whiteColor] setFill];
699 NSRectFill(middleRect); 703 NSRectFill(middleRect);
700 704
701 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); 705 maskCache_.reset(CGBitmapContextCreateImage(maskContext));
702 return maskCache_; 706 return maskCache_;
703 } 707 }
704 708
705 @end // @implementation TabView(Private) 709 @end // @implementation TabView(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/hover_close_button.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698