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

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: rebase Created 7 years, 5 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 if (fastResizeMode_ == fastResizeMode) 20 if (fastResizeMode_ == fastResizeMode)
23 return; 21 return;
24 22
25 fastResizeMode_ = fastResizeMode; 23 fastResizeMode_ = fastResizeMode;
26 24
27 // Force a relayout when coming out of fast resize mode. 25 // Force a relayout when coming out of fast resize mode.
28 if (!fastResizeMode_) 26 if (!fastResizeMode_)
29 [self layoutSubviews]; 27 [self layoutSubviews];
30 28
31 [self setNeedsDisplay:YES]; 29 [self setNeedsDisplay:YES];
32 } 30 }
33 31
34 - (void)resizeSubviewsWithOldSize:(NSSize)oldSize { 32 - (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
35 [self layoutSubviews]; 33 [self layoutSubviews];
36 } 34 }
37 35
38 - (void)drawRect:(NSRect)dirtyRect { 36 - (void)drawRect:(NSRect)dirtyRect {
39 // If we are in fast resize mode, our subviews may not completely cover our 37 // If we are in fast resize mode, our subviews may not completely cover our
40 // bounds, so we fill with white. If we are not in fast resize mode, we do 38 // bounds, so we fill with white. If we are not in fast resize mode, we do
41 // not need to draw anything. 39 // not need to draw anything.
42 if (!fastResizeMode_) 40 if (!fastResizeMode_)
43 return; 41 return;
44 42
45 // Don't draw on the non-content area.
46 NSRect clipRect = [self bounds];
47 clipRect.size.height -= contentOffset_;
48 NSRectClip(clipRect);
49
50 [[NSColor whiteColor] set]; 43 [[NSColor whiteColor] set];
51 NSRectFill(dirtyRect); 44 NSRectFill(dirtyRect);
52 } 45 }
53 46
54 - (NSView*)hitTest:(NSPoint)point {
55 NSView* result = [super hitTest:point];
56 // Never return this view during hit testing. This allows overlapping views to
57 // get events even when they are not topmost.
58 if ([result isEqual:self])
59 return nil;
60 return result;
61 }
62
63 @end 47 @end
64 48
65 @implementation FastResizeView (PrivateMethods) 49 @implementation FastResizeView (PrivateMethods)
66 50
67 - (void)layoutSubviews { 51 - (void)layoutSubviews {
68 // There should never be more than one subview. There can be zero, if we are 52 // There should never be more than one subview. There can be zero, if we are
69 // in the process of switching tabs or closing the window. In those cases, no 53 // in the process of switching tabs or closing the window. In those cases, no
70 // layout is needed. 54 // layout is needed.
71 NSArray* subviews = [self subviews]; 55 NSArray* subviews = [self subviews];
72 DCHECK([subviews count] <= 1); 56 DCHECK([subviews count] <= 1);
73 if ([subviews count] < 1) 57 if ([subviews count] < 1)
74 return; 58 return;
75 59
76 NSView* subview = [subviews objectAtIndex:0]; 60 NSView* subview = [subviews objectAtIndex:0];
77 NSRect bounds = [self bounds]; 61 NSRect bounds = [self bounds];
78 62
79 if (fastResizeMode_) { 63 if (fastResizeMode_) {
80 NSRect frame = [subview frame]; 64 NSRect frame = [subview frame];
81 frame.origin.x = 0; 65 frame.origin.x = 0;
82 frame.origin.y = NSHeight(bounds) - NSHeight(frame); 66 frame.origin.y = NSHeight(bounds) - NSHeight(frame);
83 [subview setFrame:frame]; 67 [subview setFrame:frame];
84 } else { 68 } else {
85 [subview setFrame:bounds]; 69 [subview setFrame:bounds];
86 } 70 }
87 } 71 }
88 72
89 @end 73 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/fast_resize_view.h ('k') | chrome/browser/ui/cocoa/tab_contents/instant_overlay_controller_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698