summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 17:56:40 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 17:56:40 +0000
commitf9c1f09a66f96929bd1d75d7aceaf3d8146cb9b6 (patch)
tree70973e9237a824603b734f2cb75374c834c50c30
parent2f3bc65c0d7abb88bc3f9c88d32625eceaa7f5bc (diff)
downloadchromium_src-f9c1f09a66f96929bd1d75d7aceaf3d8146cb9b6.zip
chromium_src-f9c1f09a66f96929bd1d75d7aceaf3d8146cb9b6.tar.gz
chromium_src-f9c1f09a66f96929bd1d75d7aceaf3d8146cb9b6.tar.bz2
Restrict new tab button clicks to inside the image bounds, not anywhere in the bounds of the button in the nib.
Nib change: Make the new tab button a subclass of NewTabButton instead of NSButton BUG=45738 TEST=clicking new tab button still works as expected. Review URL: http://codereview.chromium.org/3046016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53488 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/nibs/BrowserWindow.xib131
-rw-r--r--chrome/browser/cocoa/new_tab_button.h23
-rw-r--r--chrome/browser/cocoa/new_tab_button.mm38
-rw-r--r--chrome/chrome_browser.gypi2
4 files changed, 161 insertions, 33 deletions
diff --git a/chrome/app/nibs/BrowserWindow.xib b/chrome/app/nibs/BrowserWindow.xib
index 4345d67..a0fa228 100644
--- a/chrome/app/nibs/BrowserWindow.xib
+++ b/chrome/app/nibs/BrowserWindow.xib
@@ -1,14 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9L31a</string>
- <string key="IBDocument.InterfaceBuilderVersion">677</string>
- <string key="IBDocument.AppKitVersion">949.54</string>
- <string key="IBDocument.HIToolboxVersion">353.00</string>
+ <string key="IBDocument.SystemVersion">10F569</string>
+ <string key="IBDocument.InterfaceBuilderVersion">788</string>
+ <string key="IBDocument.AppKitVersion">1038.29</string>
+ <string key="IBDocument.HIToolboxVersion">461.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="NS.object.0">788</string>
+ </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="89"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -16,7 +19,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -42,7 +45,7 @@
<string key="NSWindowTitle"/>
<string key="NSWindowClass">ChromeBrowserWindow</string>
<nil key="NSViewClass"/>
- <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSWindowContentMinSize">{400, 250}</string>
<object class="NSView" key="NSWindowView" id="1006">
<nil key="NSNextResponder"/>
@@ -61,7 +64,7 @@
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{400, 272}</string>
- <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
</object>
<object class="NSCustomView" id="1029219716">
<nil key="NSNextResponder"/>
@@ -80,7 +83,7 @@
<string key="NSContents"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
- <double key="NSSize">1.300000e+01</double>
+ <double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="131944810"/>
@@ -97,10 +100,9 @@
<string key="NSClassName">TabStripView</string>
</object>
<object class="NSCustomView" id="529166964">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">272</int>
<string key="NSFrameSize">{236, 393}</string>
- <reference key="NSSuperview"/>
<string key="NSClassName">SideTabStripView</string>
</object>
</object>
@@ -161,28 +163,26 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
- <object class="NSArray" key="object" id="490739442">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
- <reference key="parent" ref="490739442"/>
- <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
- <reference key="parent" ref="490739442"/>
+ <reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
- <reference key="parent" ref="490739442"/>
+ <reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
@@ -192,7 +192,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1006"/>
</object>
- <reference key="parent" ref="490739442"/>
+ <reference key="parent" ref="0"/>
<string key="objectName">Browser</string>
</object>
<object class="IBObjectRecord">
@@ -211,7 +211,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="131944810"/>
</object>
- <reference key="parent" ref="490739442"/>
+ <reference key="parent" ref="0"/>
<string key="objectName">TabBar</string>
</object>
<object class="IBObjectRecord">
@@ -236,13 +236,13 @@
<object class="IBObjectRecord">
<int key="objectID">89</int>
<reference key="object" ref="529166964"/>
- <reference key="parent" ref="490739442"/>
+ <reference key="parent" ref="0"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
@@ -262,6 +262,7 @@
<string>2.IBViewIntegration.shadowOffsetWidth</string>
<string>56.IBEditorWindowLastContentRect</string>
<string>56.IBPluginDependency</string>
+ <string>66.CustomClassName</string>
<string>66.IBPluginDependency</string>
<string>67.IBPluginDependency</string>
<string>84.IBPluginDependency</string>
@@ -282,15 +283,16 @@
<boolean value="YES"/>
<string>{400, 250}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <real value="0.000000e+00"/>
+ <real value="0.0"/>
<object class="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
- <real value="0.000000e+00"/>
- <real value="0.000000e+00"/>
+ <real value="0.0"/>
+ <real value="0.0"/>
<string>{{138, 199}, {483, 36}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>NewTabButton</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -300,9 +302,7 @@
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -310,9 +310,7 @@
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -369,6 +367,13 @@
<string key="NS.key.0">commandDispatch:</string>
<string key="NS.object.0">id</string>
</object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <string key="NS.key.0">commandDispatch:</string>
+ <object class="IBActionInfo" key="NS.object.0">
+ <string key="name">commandDispatch:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
@@ -403,6 +408,13 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">NSView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/view_id_util.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">NSWindow</string>
<reference key="sourceIdentifier" ref="924273615"/>
</object>
@@ -414,6 +426,14 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">NewTabButton</string>
+ <string key="superclassName">NSButton</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/new_tab_button.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">SideTabStripView</string>
<string key="superclassName">TabStripView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -428,6 +448,13 @@
<string key="NS.key.0">newTabButton</string>
<string key="NS.object.0">NSButton</string>
</object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <string key="NS.key.0">newTabButton</string>
+ <object class="IBToOneOutletInfo" key="NS.object.0">
+ <string key="name">newTabButton</string>
+ <string key="candidateClassName">NSButton</string>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">browser/cocoa/tab_strip_view.h</string>
@@ -438,7 +465,7 @@
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>sideTabStripView_</string>
<string>tabContentArea_</string>
@@ -451,6 +478,30 @@
<string>TabStripView</string>
</object>
</object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>sideTabStripView_</string>
+ <string>tabContentArea_</string>
+ <string>topTabStripView_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBToOneOutletInfo">
+ <string key="name">sideTabStripView_</string>
+ <string key="candidateClassName">TabStripView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">tabContentArea_</string>
+ <string key="candidateClassName">FastResizeView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">topTabStripView_</string>
+ <string key="candidateClassName">TabStripView</string>
+ </object>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">browser/cocoa/tab_window_controller.h</string>
@@ -459,6 +510,20 @@
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+ <integer value="1050" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+ <integer value="1050" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
+ <integer value="3000" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
diff --git a/chrome/browser/cocoa/new_tab_button.h b/chrome/browser/cocoa/new_tab_button.h
new file mode 100644
index 0000000..dddcf4c
--- /dev/null
+++ b/chrome/browser/cocoa/new_tab_button.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_NEW_TAB_BUTTON
+#define CHROME_BROWSER_COCOA_NEW_TAB_BUTTON
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/scoped_nsobject.h"
+
+// Overrides hit-test behavior to only accept clicks inside the image of the
+// button, not just inside the bounding box. This could be abstracted to general
+// use, but no other buttons are so irregularly shaped with respect to their
+// bounding box.
+
+@interface NewTabButton : NSButton {
+ @private
+ scoped_nsobject<NSBezierPath> imagePath_;
+}
+@end
+
+#endif // CHROME_BROWSER_COCOA_NEW_TAB_BUTTON
diff --git a/chrome/browser/cocoa/new_tab_button.mm b/chrome/browser/cocoa/new_tab_button.mm
new file mode 100644
index 0000000..c5e41df
--- /dev/null
+++ b/chrome/browser/cocoa/new_tab_button.mm
@@ -0,0 +1,38 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/cocoa/new_tab_button.h"
+
+@implementation NewTabButton
+
+// Approximate the shape. It doesn't need to be perfect. This will need to be
+// updated if the size or shape of the icon ever changes.
+// TODO(pinkerton): use a click mask image instead of hard-coding points.
+- (NSBezierPath*)pathForButton {
+ if (imagePath_.get())
+ return imagePath_.get();
+
+ // Cache the path as it doesn't change (the coordinates are local to this
+ // view). There's not much point making constants for these, as they are
+ // custom.
+ imagePath_.reset([[NSBezierPath bezierPath] retain]);
+ [imagePath_ moveToPoint:NSMakePoint(9, 7)];
+ [imagePath_ lineToPoint:NSMakePoint(26, 7)];
+ [imagePath_ lineToPoint:NSMakePoint(33, 23)];
+ [imagePath_ lineToPoint:NSMakePoint(14, 23)];
+ [imagePath_ lineToPoint:NSMakePoint(9, 7)];
+ return imagePath_;
+}
+
+// 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)aPoint {
+ NSBezierPath* buttonPath = [self pathForButton];
+ NSPoint localPoint = [self convertPoint:aPoint fromView:[self superview]];
+ if ([buttonPath containsPoint:localPoint])
+ return [super hitTest:aPoint];
+ return nil;
+}
+
+@end
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 7a87f00..849abcf 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -907,6 +907,8 @@
'browser/cocoa/menu_controller.mm',
'browser/cocoa/multi_key_equivalent_button.h',
'browser/cocoa/multi_key_equivalent_button.mm',
+ 'browser/cocoa/new_tab_button.h',
+ 'browser/cocoa/new_tab_button.mm',
'browser/cocoa/notifications/balloon_controller.mm',
'browser/cocoa/notifications/balloon_controller.h',
'browser/cocoa/notifications/balloon_view_bridge.h',