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

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

Issue 11876036: Alternate NTP: Don't hide bookmark bar on instant (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 6 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 @interface FastResizeView (PrivateMethods) 10 @interface FastResizeView (PrivateMethods)
11 // Lays out this views subviews. If fast resize mode is on, does not resize any 11 // Lays out this views subviews. If fast resize mode is on, does not resize any
12 // subviews and instead pegs them to the top left. If fast resize mode is off, 12 // subviews and instead pegs them to the top left. If fast resize mode is off,
13 // sets the subviews' frame to be equal to this view's bounds. 13 // sets the subviews' frame to be equal to this view's bounds.
14 - (void)layoutSubviews; 14 - (void)layoutSubviews;
15 @end 15 @end
16 16
17 @implementation FastResizeView 17 @implementation FastResizeView
18
19 @synthesize contentOffset = contentOffset_;
20
18 - (void)setFastResizeMode:(BOOL)fastResizeMode { 21 - (void)setFastResizeMode:(BOOL)fastResizeMode {
19 fastResizeMode_ = fastResizeMode; 22 fastResizeMode_ = fastResizeMode;
20 23
21 // Force a relayout when coming out of fast resize mode. 24 // Force a relayout when coming out of fast resize mode.
22 if (!fastResizeMode_) 25 if (!fastResizeMode_)
23 [self layoutSubviews]; 26 [self layoutSubviews];
24 } 27 }
25 28
26 - (void)resizeSubviewsWithOldSize:(NSSize)oldSize { 29 - (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
27 [self layoutSubviews]; 30 [self layoutSubviews];
28 } 31 }
29 32
30 - (void)drawRect:(NSRect)dirtyRect { 33 - (void)drawRect:(NSRect)dirtyRect {
31 // If we are in fast resize mode, our subviews may not completely cover our 34 // If we are in fast resize mode, our subviews may not completely cover our
32 // bounds, so we fill with white. If we are not in fast resize mode, we do 35 // bounds, so we fill with white. If we are not in fast resize mode, we do
33 // not need to draw anything. 36 // not need to draw anything.
34 if (fastResizeMode_) { 37 if (!fastResizeMode_)
35 [[NSColor whiteColor] set]; 38 return;
36 NSRectFill(dirtyRect); 39
37 } 40 // Don't draw on the non-content area.
41 NSRect clipRect = [self bounds];
42 clipRect.size.height -= contentOffset_;
43 NSRectClip(clipRect);
44
45 [[NSColor whiteColor] set];
46 NSRectFill(dirtyRect);
38 } 47 }
39 48
40
41 @end 49 @end
42 50
43 @implementation FastResizeView (PrivateMethods) 51 @implementation FastResizeView (PrivateMethods)
44 - (void)layoutSubviews { 52 - (void)layoutSubviews {
45 // There should never be more than one subview. There can be zero, if we are 53 // There should never be more than one subview. There can be zero, if we are
46 // in the process of switching tabs or closing the window. In those cases, no 54 // in the process of switching tabs or closing the window. In those cases, no
47 // layout is needed. 55 // layout is needed.
48 NSArray* subviews = [self subviews]; 56 NSArray* subviews = [self subviews];
49 DCHECK([subviews count] <= 1); 57 DCHECK([subviews count] <= 1);
50 if ([subviews count] < 1) 58 if ([subviews count] < 1)
51 return; 59 return;
52 60
53 NSView* subview = [subviews objectAtIndex:0]; 61 NSView* subview = [subviews objectAtIndex:0];
54 NSRect bounds = [self bounds]; 62 NSRect bounds = [self bounds];
55 63
56 if (fastResizeMode_) { 64 if (fastResizeMode_) {
57 NSRect frame = [subview frame]; 65 NSRect frame = [subview frame];
58 frame.origin.x = 0; 66 frame.origin.x = 0;
59 frame.origin.y = NSHeight(bounds) - NSHeight(frame); 67 frame.origin.y = NSHeight(bounds) - NSHeight(frame);
60 [subview setFrame:frame]; 68 [subview setFrame:frame];
61 } else { 69 } else {
62 [subview setFrame:bounds]; 70 [subview setFrame:bounds];
63 } 71 }
64 } 72 }
65 @end 73 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698