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

Side by Side Diff: chrome/browser/ui/cocoa/framed_browser_window.mm

Issue 329793003: Don't draw a window title on browser windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
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/framed_browser_window.h" 5 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/mac_util.h"
8 #include "base/mac/sdk_forward_declarations.h" 9 #include "base/mac/sdk_forward_declarations.h"
9 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 10 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 13 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
13 #import "chrome/browser/ui/cocoa/custom_frame_view.h" 14 #import "chrome/browser/ui/cocoa/custom_frame_view.h"
14 #import "chrome/browser/ui/cocoa/nsview_additions.h" 15 #import "chrome/browser/ui/cocoa/nsview_additions.h"
15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 16 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
16 #import "chrome/browser/ui/cocoa/themed_window.h" 17 #import "chrome/browser/ui/cocoa/themed_window.h"
17 #include "chrome/browser/themes/theme_properties.h" 18 #include "chrome/browser/themes/theme_properties.h"
(...skipping 11 matching lines...) Expand all
29 namespace { 30 namespace {
30 31
31 const CGFloat kBrowserFrameViewPaintHeight = 60.0; 32 const CGFloat kBrowserFrameViewPaintHeight = 60.0;
32 33
33 // Size of the gradient. Empirically determined so that the gradient looks 34 // Size of the gradient. Empirically determined so that the gradient looks
34 // like what the heuristic does when there are just a few tabs. 35 // like what the heuristic does when there are just a few tabs.
35 const CGFloat kWindowGradientHeight = 24.0; 36 const CGFloat kWindowGradientHeight = 24.0;
36 37
37 } 38 }
38 39
39 @interface FramedBrowserWindow (Private) 40 @interface FramedBrowserWindow ()
40 41
41 - (void)adjustCloseButton:(NSNotification*)notification; 42 - (void)adjustCloseButton:(NSNotification*)notification;
42 - (void)adjustMiniaturizeButton:(NSNotification*)notification; 43 - (void)adjustMiniaturizeButton:(NSNotification*)notification;
43 - (void)adjustZoomButton:(NSNotification*)notification; 44 - (void)adjustZoomButton:(NSNotification*)notification;
44 - (void)adjustButton:(NSButton*)button 45 - (void)adjustButton:(NSButton*)button
45 ofKind:(NSWindowButton)kind; 46 ofKind:(NSWindowButton)kind;
46 - (NSView*)frameView; 47 - (NSView*)frameView;
47 48
48 @end 49 @end
49 50
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 eventHandled = YES; 246 eventHandled = YES;
246 } 247 }
247 } 248 }
248 } 249 }
249 if (!eventHandled) { 250 if (!eventHandled) {
250 [super sendEvent:event]; 251 [super sendEvent:event];
251 } 252 }
252 } 253 }
253 254
254 - (void)setShouldHideTitle:(BOOL)flag { 255 - (void)setShouldHideTitle:(BOOL)flag {
255 shouldHideTitle_ = flag; 256 if ([self respondsToSelector:@selector(setTitleVisibility:)])
257 self.titleVisibility = flag ? NSWindowTitleHidden : NSWindowTitleVisible;
258 else
259 shouldHideTitle_ = flag;
256 } 260 }
257 261
258 - (BOOL)_isTitleHidden { 262 - (BOOL)_isTitleHidden {
259 return shouldHideTitle_; 263 // Only intervene with 10.6-10.9.
264 if ([self respondsToSelector:@selector(setTitleVisibility:)])
265 return [super _isTitleHidden];
266 else
267 return shouldHideTitle_;
260 } 268 }
261 269
262 - (CGFloat)windowButtonsInterButtonSpacing { 270 - (CGFloat)windowButtonsInterButtonSpacing {
263 return windowButtonsInterButtonSpacing_; 271 return windowButtonsInterButtonSpacing_;
264 } 272 }
265 273
266 // This method is called whenever a window is moved in order to ensure it fits 274 // This method is called whenever a window is moved in order to ensure it fits
267 // on the screen. We cannot always handle resizes without breaking, so we 275 // on the screen. We cannot always handle resizes without breaking, so we
268 // prevent frame constraining in those cases. 276 // prevent frame constraining in those cases.
269 - (NSRect)constrainFrameRect:(NSRect)frame toScreen:(NSScreen*)screen { 277 - (NSRect)constrainFrameRect:(NSRect)frame toScreen:(NSScreen*)screen {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 yRadius:cornerRadius] addClip]; 350 yRadius:cornerRadius] addClip];
343 [[NSBezierPath bezierPathWithRect:rect] addClip]; 351 [[NSBezierPath bezierPathWithRect:rect] addClip];
344 352
345 // Do the theming. 353 // Do the theming.
346 BOOL themed = [FramedBrowserWindow 354 BOOL themed = [FramedBrowserWindow
347 drawWindowThemeInDirtyRect:rect 355 drawWindowThemeInDirtyRect:rect
348 forView:view 356 forView:view
349 bounds:windowRect 357 bounds:windowRect
350 forceBlackBackground:NO]; 358 forceBlackBackground:NO];
351 359
352 // If the window needs a title and we painted over the title as drawn by the 360 // In Yosemite: The title is drawn by a subview and not painted on. Therefore,
353 // default window paint, paint it ourselves. 361 // never worry about drawing it. Pre-Yosemite: If the window needs a title and
354 if (themed && [view respondsToSelector:@selector(_titlebarTitleRect)] && 362 // we painted over the title as drawn by the default window paint, paint it
363 // ourselves.
364 if (base::mac::IsOSMavericksOrEarlier() &&
Mark Mentovai 2014/06/12 18:27:14 Ask if the window doesn’t respond to the selector
Avi (use Gerrit) 2014/06/12 18:30:31 Done.
365 themed && [view respondsToSelector:@selector(_titlebarTitleRect)] &&
355 [view respondsToSelector:@selector(_drawTitleStringIn:withColor:)] && 366 [view respondsToSelector:@selector(_drawTitleStringIn:withColor:)] &&
356 ![self _isTitleHidden]) { 367 ![self _isTitleHidden]) {
357 [view _drawTitleStringIn:[view _titlebarTitleRect] 368 [view _drawTitleStringIn:[view _titlebarTitleRect]
358 withColor:[self titleColor]]; 369 withColor:[self titleColor]];
359 } 370 }
360 371
361 // Pinstripe the top. 372 // Pinstripe the top.
362 if (themed) { 373 if (themed) {
363 CGFloat lineWidth = [view cr_lineWidth]; 374 CGFloat lineWidth = [view cr_lineWidth];
364 375
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 ThemedWindowStyle windowStyle = [self themedWindowStyle]; 498 ThemedWindowStyle windowStyle = [self themedWindowStyle];
488 BOOL incognito = windowStyle & THEMED_INCOGNITO; 499 BOOL incognito = windowStyle & THEMED_INCOGNITO;
489 500
490 if (incognito) 501 if (incognito)
491 return [NSColor whiteColor]; 502 return [NSColor whiteColor];
492 else 503 else
493 return [NSColor windowFrameTextColor]; 504 return [NSColor windowFrameTextColor];
494 } 505 }
495 506
496 @end 507 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/framed_browser_window.h ('k') | chrome/browser/ui/cocoa/framed_browser_window_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698