Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2165 int modelIndex = tabStripModel_->active_index(); | 2165 int modelIndex = tabStripModel_->active_index(); |
| 2166 if (modelIndex < 0) | 2166 if (modelIndex < 0) |
| 2167 return nil; | 2167 return nil; |
| 2168 NSInteger index = [self indexFromModelIndex:modelIndex]; | 2168 NSInteger index = [self indexFromModelIndex:modelIndex]; |
| 2169 if (index < 0 || | 2169 if (index < 0 || |
| 2170 index >= (NSInteger)[tabContentsArray_ count]) | 2170 index >= (NSInteger)[tabContentsArray_ count]) |
| 2171 return nil; | 2171 return nil; |
| 2172 return [tabContentsArray_ objectAtIndex:index]; | 2172 return [tabContentsArray_ objectAtIndex:index]; |
| 2173 } | 2173 } |
| 2174 | 2174 |
| 2175 - (void)addWindowControls { | |
| 2176 if (!fullscreenWindowControls_) { | |
| 2177 // Make the container view. | |
| 2178 CGFloat height = NSHeight([tabStripView_ frame]); | |
| 2179 NSRect frame = NSMakeRect(0, 0, self.leftIndentForControls, height); | |
|
Robert Sesek
2014/09/02 19:01:05
This file has an overwhelming preference against d
erikchen
2014/09/03 00:31:44
I removed all instances of dot notation from this
| |
| 2180 fullscreenWindowControls_.reset([[NSView alloc] initWithFrame:frame]); | |
| 2181 [fullscreenWindowControls_ | |
| 2182 setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable]; | |
| 2183 | |
| 2184 // Add the traffic light buttons. The horizontal layout was determined by | |
| 2185 // manual inspection on Yosemite. | |
| 2186 NSUInteger styleMask = [tabStripView_ window].styleMask; | |
| 2187 NSButton* closeButton = [NSWindow standardWindowButton:NSWindowCloseButton | |
| 2188 forStyleMask:styleMask]; | |
| 2189 | |
| 2190 // Vertically center the buttons in the tab strip. | |
| 2191 CGFloat buttonY = floor((height - NSHeight(closeButton.bounds)) / 2); | |
| 2192 [closeButton setFrameOrigin:NSMakePoint(11, buttonY)]; | |
|
Robert Sesek
2014/09/02 19:01:05
Pull these magic numbers into method-local magic n
erikchen
2014/09/03 00:31:44
Done.
| |
| 2193 [fullscreenWindowControls_ addSubview:closeButton]; | |
| 2194 | |
| 2195 NSButton* miniaturizeButton = | |
| 2196 [NSWindow standardWindowButton:NSWindowMiniaturizeButton | |
| 2197 forStyleMask:styleMask]; | |
| 2198 [miniaturizeButton setFrameOrigin:NSMakePoint(31, buttonY)]; | |
| 2199 [miniaturizeButton setEnabled:NO]; | |
| 2200 [fullscreenWindowControls_ addSubview:miniaturizeButton]; | |
| 2201 | |
| 2202 NSButton* fullscreenButton = | |
| 2203 [NSWindow standardWindowButton:NSWindowZoomButton | |
| 2204 forStyleMask:styleMask]; | |
| 2205 [fullscreenWindowControls_ addSubview:fullscreenButton]; | |
| 2206 [fullscreenButton setFrameOrigin:NSMakePoint(51, buttonY)]; | |
| 2207 } | |
| 2208 | |
| 2209 if (![permanentSubviews_ containsObject:fullscreenWindowControls_]) { | |
| 2210 [self addSubviewToPermanentList:fullscreenWindowControls_]; | |
| 2211 [self regenerateSubviewList]; | |
| 2212 } | |
| 2213 } | |
| 2214 | |
| 2215 - (void)removeWindowControls { | |
| 2216 if (fullscreenWindowControls_) | |
| 2217 [permanentSubviews_ removeObject:fullscreenWindowControls_]; | |
| 2218 [self regenerateSubviewList]; | |
| 2219 } | |
| 2220 | |
| 2175 - (void)themeDidChangeNotification:(NSNotification*)notification { | 2221 - (void)themeDidChangeNotification:(NSNotification*)notification { |
| 2176 [self setNewTabImages]; | 2222 [self setNewTabImages]; |
| 2177 } | 2223 } |
| 2178 | 2224 |
| 2179 - (void)setNewTabImages { | 2225 - (void)setNewTabImages { |
| 2180 ThemeService *theme = | 2226 ThemeService *theme = |
| 2181 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]); | 2227 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]); |
| 2182 if (!theme) | 2228 if (!theme) |
| 2183 return; | 2229 return; |
| 2184 | 2230 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2229 } | 2275 } |
| 2230 | 2276 |
| 2231 NSRect GetSheetParentBoundsForParentView(NSView* view) { | 2277 NSRect GetSheetParentBoundsForParentView(NSView* view) { |
| 2232 // If the devtools view is open, it shrinks the size of the WebContents, so go | 2278 // If the devtools view is open, it shrinks the size of the WebContents, so go |
| 2233 // up the hierarchy to the devtools container view to avoid that. Note that | 2279 // up the hierarchy to the devtools container view to avoid that. Note that |
| 2234 // the devtools view is always in the hierarchy even if it is not open or it | 2280 // the devtools view is always in the hierarchy even if it is not open or it |
| 2235 // is detached. | 2281 // is detached. |
| 2236 NSView* devtools_view = [[[view superview] superview] superview]; | 2282 NSView* devtools_view = [[[view superview] superview] superview]; |
| 2237 return [devtools_view convertRect:[devtools_view bounds] toView:nil]; | 2283 return [devtools_view convertRect:[devtools_view bounds] toView:nil]; |
| 2238 } | 2284 } |
| OLD | NEW |