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

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

Issue 18009003: Instant Extended: Delete unused overlay code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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 18
19 @synthesize contentOffset = contentOffset_;
20
21 - (void)setFastResizeMode:(BOOL)fastResizeMode { 19 - (void)setFastResizeMode:(BOOL)fastResizeMode {
22 fastResizeMode_ = fastResizeMode; 20 fastResizeMode_ = fastResizeMode;
23 21
24 // Force a relayout when coming out of fast resize mode. 22 // Force a relayout when coming out of fast resize mode.
25 if (!fastResizeMode_) 23 if (!fastResizeMode_)
26 [self layoutSubviews]; 24 [self layoutSubviews];
27 } 25 }
28 26
29 - (void)resizeSubviewsWithOldSize:(NSSize)oldSize { 27 - (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
30 [self layoutSubviews]; 28 [self layoutSubviews];
31 } 29 }
32 30
33 - (void)drawRect:(NSRect)dirtyRect { 31 - (void)drawRect:(NSRect)dirtyRect {
34 // If we are in fast resize mode, our subviews may not completely cover our 32 // If we are in fast resize mode, our subviews may not completely cover our
35 // bounds, so we fill with white. If we are not in fast resize mode, we do 33 // bounds, so we fill with white. If we are not in fast resize mode, we do
36 // not need to draw anything. 34 // not need to draw anything.
37 if (!fastResizeMode_) 35 if (!fastResizeMode_)
38 return; 36 return;
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]; 38 [[NSColor whiteColor] set];
46 NSRectFill(dirtyRect); 39 NSRectFill(dirtyRect);
47 } 40 }
48 41
49 - (NSView*)hitTest:(NSPoint)point {
50 NSView* result = [super hitTest:point];
51 // Never return this view during hit testing. This allows overlapping views to
52 // get events even when they are not topmost.
53 if ([result isEqual:self])
54 return nil;
55 return result;
56 }
57
58 @end 42 @end
59 43
60 @implementation FastResizeView (PrivateMethods) 44 @implementation FastResizeView (PrivateMethods)
45
61 - (void)layoutSubviews { 46 - (void)layoutSubviews {
62 // There should never be more than one subview. There can be zero, if we are 47 // There should never be more than one subview. There can be zero, if we are
63 // in the process of switching tabs or closing the window. In those cases, no 48 // in the process of switching tabs or closing the window. In those cases, no
64 // layout is needed. 49 // layout is needed.
65 NSArray* subviews = [self subviews]; 50 NSArray* subviews = [self subviews];
66 DCHECK([subviews count] <= 1); 51 DCHECK([subviews count] <= 1);
67 if ([subviews count] < 1) 52 if ([subviews count] < 1)
68 return; 53 return;
69 54
70 NSView* subview = [subviews objectAtIndex:0]; 55 NSView* subview = [subviews objectAtIndex:0];
71 NSRect bounds = [self bounds]; 56 NSRect bounds = [self bounds];
72 57
73 if (fastResizeMode_) { 58 if (fastResizeMode_) {
74 NSRect frame = [subview frame]; 59 NSRect frame = [subview frame];
75 frame.origin.x = 0; 60 frame.origin.x = 0;
76 frame.origin.y = NSHeight(bounds) - NSHeight(frame); 61 frame.origin.y = NSHeight(bounds) - NSHeight(frame);
77 [subview setFrame:frame]; 62 [subview setFrame:frame];
78 } else { 63 } else {
79 [subview setFrame:bounds]; 64 [subview setFrame:bounds];
80 } 65 }
81 } 66 }
67
82 @end 68 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698