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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_window_controller.mm

Issue 379293003: mac: Fix tab dragging visual bug in Yosemite. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set the frame of the chromeContentView when adding it as a subview. Created 6 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
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/tabs/tab_window_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 8 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
9 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 9 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
(...skipping 29 matching lines...) Expand all
40 themeImagePositionForAlignment:alignment]; 40 themeImagePositionForAlignment:alignment];
41 } 41 }
42 return NSZeroPoint; 42 return NSZeroPoint;
43 } 43 }
44 44
45 @end 45 @end
46 46
47 @implementation TabWindowController 47 @implementation TabWindowController
48 48
49 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip { 49 - (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip {
50 NSRect contentRect = NSMakeRect(60, 229, 750, 600); 50 const CGFloat kDefaultWidth = 750;
51 const CGFloat kDefaultHeight = 600;
52
53 NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight);
51 base::scoped_nsobject<FramedBrowserWindow> window( 54 base::scoped_nsobject<FramedBrowserWindow> window(
52 [[FramedBrowserWindow alloc] initWithContentRect:contentRect 55 [[FramedBrowserWindow alloc] initWithContentRect:contentRect
53 hasTabStrip:hasTabStrip]); 56 hasTabStrip:hasTabStrip]);
54 [window setReleasedWhenClosed:YES]; 57 [window setReleasedWhenClosed:YES];
55 [window setAutorecalculatesKeyViewLoop:YES]; 58 [window setAutorecalculatesKeyViewLoop:YES];
56 59
57 if ((self = [super initWithWindow:window])) { 60 if ((self = [super initWithWindow:window])) {
58 [[self window] setDelegate:self]; 61 [[self window] setDelegate:self];
59 62
60 tabContentArea_.reset([[FastResizeView alloc] initWithFrame: 63 chromeContentView_.reset([[NSView alloc]
61 NSMakeRect(0, 0, 750, 600)]); 64 initWithFrame:NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight)]);
65 [chromeContentView_
66 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
67 [[[self window] contentView] addSubview:chromeContentView_];
68
69 tabContentArea_.reset(
70 [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]);
62 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable | 71 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
63 NSViewHeightSizable]; 72 NSViewHeightSizable];
64 [[[self window] contentView] addSubview:tabContentArea_]; 73 [chromeContentView_ addSubview:tabContentArea_];
65 74
66 tabStripView_.reset([[TabStripView alloc] initWithFrame: 75 tabStripView_.reset([[TabStripView alloc]
67 NSMakeRect(0, 0, 750, 37)]); 76 initWithFrame:NSMakeRect(0, 0, kDefaultWidth, 37)]);
68 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | 77 [tabStripView_ setAutoresizingMask:NSViewWidthSizable |
69 NSViewMinYMargin]; 78 NSViewMinYMargin];
70 if (hasTabStrip) 79 if (hasTabStrip)
71 [self addTabStripToWindow]; 80 [self addTabStripToWindow];
72 } 81 }
73 return self; 82 return self;
74 } 83 }
75 84
76 - (TabStripView*)tabStripView { 85 - (TabStripView*)tabStripView {
77 return tabStripView_; 86 return tabStripView_;
78 } 87 }
79 88
80 - (FastResizeView*)tabContentArea { 89 - (FastResizeView*)tabContentArea {
81 return tabContentArea_; 90 return tabContentArea_;
82 } 91 }
83 92
93 - (NSView*)chromeContentView {
94 return chromeContentView_;
95 }
96
84 // Add the top tab strop to the window, above the content box and add it to the 97 // Add the top tab strop to the window, above the content box and add it to the
85 // view hierarchy as a sibling of the content view so it can overlap with the 98 // view hierarchy as a sibling of the content view so it can overlap with the
86 // window frame. 99 // window frame.
87 - (void)addTabStripToWindow { 100 - (void)addTabStripToWindow {
88 // The frame doesn't matter. This class relies on subclasses to do tab strip 101 // The frame doesn't matter. This class relies on subclasses to do tab strip
89 // layout. 102 // layout.
90 NSView* contentParent = [[self window] cr_windowView]; 103 NSView* contentParent = [[self window] cr_windowView];
91 [contentParent addSubview:tabStripView_]; 104 [contentParent addSubview:tabStripView_];
92 } 105 }
93 106
(...skipping 26 matching lines...) Expand all
120 overlayWindow_ = [[TabWindowOverlayWindow alloc] 133 overlayWindow_ = [[TabWindowOverlayWindow alloc]
121 initWithContentRect:[window frame] 134 initWithContentRect:[window frame]
122 styleMask:NSBorderlessWindowMask 135 styleMask:NSBorderlessWindowMask
123 backing:NSBackingStoreBuffered 136 backing:NSBackingStoreBuffered
124 defer:YES]; 137 defer:YES];
125 [overlayWindow_ setTitle:@"overlay"]; 138 [overlayWindow_ setTitle:@"overlay"];
126 [overlayWindow_ setBackgroundColor:[NSColor clearColor]]; 139 [overlayWindow_ setBackgroundColor:[NSColor clearColor]];
127 [overlayWindow_ setOpaque:NO]; 140 [overlayWindow_ setOpaque:NO];
128 [overlayWindow_ setDelegate:self]; 141 [overlayWindow_ setDelegate:self];
129 142
130 originalContentView_ = [window contentView]; 143 originalContentView_ = self.chromeContentView;
131 [window addChildWindow:overlayWindow_ ordered:NSWindowAbove]; 144 [window addChildWindow:overlayWindow_ ordered:NSWindowAbove];
132 145
133 // Explicitly set the responder to be nil here (for restoring later). 146 // Explicitly set the responder to be nil here (for restoring later).
134 // If the first responder were to be left non-nil here then 147 // If the first responder were to be left non-nil here then
135 // [RenderWidgethostViewCocoa resignFirstResponder] would be called, 148 // [RenderWidgethostViewCocoa resignFirstResponder] would be called,
136 // followed by RenderWidgetHost::Blur(), which would result in an unexpected 149 // followed by RenderWidgetHost::Blur(), which would result in an unexpected
137 // loss of focus. 150 // loss of focus.
138 focusBeforeOverlay_.reset([[FocusTracker alloc] initWithWindow:window]); 151 focusBeforeOverlay_.reset([[FocusTracker alloc] initWithWindow:window]);
139 [window makeFirstResponder:nil]; 152 [window makeFirstResponder:nil];
140 153
141 // Move the original window's tab strip view and content view to the overlay 154 // Move the original window's tab strip view and content view to the overlay
142 // window. The content view is added as a subview of the overlay window's 155 // window. The content view is added as a subview of the overlay window's
143 // content view (rather than using setContentView:) because the overlay 156 // content view (rather than using setContentView:) because the overlay
144 // window has a different content size (due to it being borderless). 157 // window has a different content size (due to it being borderless).
145 [[overlayWindow_ cr_windowView] addSubview:[self tabStripView]]; 158 [[overlayWindow_ cr_windowView] addSubview:[self tabStripView]];
146 [[overlayWindow_ contentView] addSubview:originalContentView_]; 159 [[overlayWindow_ contentView] addSubview:originalContentView_];
147 160
148 [overlayWindow_ orderFront:nil]; 161 [overlayWindow_ orderFront:nil];
149 } else if (!useOverlay && overlayWindow_) { 162 } else if (!useOverlay && overlayWindow_) {
150 DCHECK(originalContentView_); 163 DCHECK(originalContentView_);
151 164
152 // Return the original window's tab strip view and content view to their 165 // Return the original window's tab strip view and content view to their
153 // places. The TabStripView always needs to be in front of the window's 166 // places. The TabStripView always needs to be in front of the window's
154 // content view and therefore it should always be added after the content 167 // content view and therefore it should always be added after the content
155 // view is set. 168 // view is set.
156 [window setContentView:originalContentView_]; 169 [[window contentView] addSubview:originalContentView_
170 positioned:NSWindowBelow
171 relativeTo:nil];
172 originalContentView_.frame = [[window contentView] bounds];
157 [[window cr_windowView] addSubview:[self tabStripView]]; 173 [[window cr_windowView] addSubview:[self tabStripView]];
158 [[window cr_windowView] updateTrackingAreas]; 174 [[window cr_windowView] updateTrackingAreas];
159 175
160 [focusBeforeOverlay_ restoreFocusInWindow:window]; 176 [focusBeforeOverlay_ restoreFocusInWindow:window];
161 focusBeforeOverlay_.reset(); 177 focusBeforeOverlay_.reset();
162 178
163 [window display]; 179 [window display];
164 [window removeChildWindow:overlayWindow_]; 180 [window removeChildWindow:overlayWindow_];
165 181
166 [overlayWindow_ orderOut:nil]; 182 [overlayWindow_ orderOut:nil];
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 closeDeferred_ = YES; 308 closeDeferred_ = YES;
293 } 309 }
294 310
295 // Called when the size of the window content area has changed. Override to 311 // Called when the size of the window content area has changed. Override to
296 // position specific views. Base class implementation does nothing. 312 // position specific views. Base class implementation does nothing.
297 - (void)layoutSubviews { 313 - (void)layoutSubviews {
298 NOTIMPLEMENTED(); 314 NOTIMPLEMENTED();
299 } 315 }
300 316
301 @end 317 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_window_controller.h ('k') | chrome/browser/ui/cocoa/version_independent_window.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698