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

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: Second. 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 NSRect contentRect = NSMakeRect(60, 229, 750, 600); 50 NSRect contentRect = NSMakeRect(60, 229, 750, 600);
51 base::scoped_nsobject<FramedBrowserWindow> window( 51 base::scoped_nsobject<FramedBrowserWindow> window(
52 [[FramedBrowserWindow alloc] initWithContentRect:contentRect 52 [[FramedBrowserWindow alloc] initWithContentRect:contentRect
53 hasTabStrip:hasTabStrip]); 53 hasTabStrip:hasTabStrip]);
54 [window setReleasedWhenClosed:YES]; 54 [window setReleasedWhenClosed:YES];
55 [window setAutorecalculatesKeyViewLoop:YES]; 55 [window setAutorecalculatesKeyViewLoop:YES];
56 56
57 if ((self = [super initWithWindow:window])) { 57 if ((self = [super initWithWindow:window])) {
58 [[self window] setDelegate:self]; 58 [[self window] setDelegate:self];
59 59
60 chromeContentView_.reset(
61 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 750, 600)]);
62 [chromeContentView_
63 setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
64 [[[self window] contentView] addSubview:chromeContentView_];
65
60 tabContentArea_.reset([[FastResizeView alloc] initWithFrame: 66 tabContentArea_.reset([[FastResizeView alloc] initWithFrame:
61 NSMakeRect(0, 0, 750, 600)]); 67 NSMakeRect(0, 0, 750, 600)]);
Andre 2014/07/11 00:57:11 initWithFrame:[chromeContentView_ bounds] to avoid
erikchen 2014/07/11 01:17:43 Done.
62 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable | 68 [tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
63 NSViewHeightSizable]; 69 NSViewHeightSizable];
64 [[[self window] contentView] addSubview:tabContentArea_]; 70 [self.chromeContentView addSubview:tabContentArea_];
Andre 2014/07/11 00:57:11 nit: self.chromeContentView -> chromeContentView_
erikchen 2014/07/11 01:17:43 Done.
Scott Hess - ex-Googler 2014/07/11 18:08:34 There are a couple other places in the patch which
erikchen 2014/07/11 20:48:04 That's not possible for most of the classes, since
Scott Hess - ex-Googler 2014/07/11 21:10:52 There are so few cases of self.accessor in the cod
erikchen 2014/07/11 21:18:19 Fair points. Got it.
65 71
66 tabStripView_.reset([[TabStripView alloc] initWithFrame: 72 tabStripView_.reset([[TabStripView alloc] initWithFrame:
67 NSMakeRect(0, 0, 750, 37)]); 73 NSMakeRect(0, 0, 750, 37)]);
68 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | 74 [tabStripView_ setAutoresizingMask:NSViewWidthSizable |
69 NSViewMinYMargin]; 75 NSViewMinYMargin];
70 if (hasTabStrip) 76 if (hasTabStrip)
71 [self addTabStripToWindow]; 77 [self addTabStripToWindow];
72 } 78 }
73 return self; 79 return self;
74 } 80 }
75 81
76 - (TabStripView*)tabStripView { 82 - (TabStripView*)tabStripView {
77 return tabStripView_; 83 return tabStripView_;
78 } 84 }
79 85
80 - (FastResizeView*)tabContentArea { 86 - (FastResizeView*)tabContentArea {
81 return tabContentArea_; 87 return tabContentArea_;
82 } 88 }
83 89
90 - (NSView*)chromeContentView {
91 return chromeContentView_;
92 }
93
84 // Add the top tab strop to the window, above the content box and add it to the 94 // 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 95 // view hierarchy as a sibling of the content view so it can overlap with the
86 // window frame. 96 // window frame.
87 - (void)addTabStripToWindow { 97 - (void)addTabStripToWindow {
88 // The frame doesn't matter. This class relies on subclasses to do tab strip 98 // The frame doesn't matter. This class relies on subclasses to do tab strip
89 // layout. 99 // layout.
90 NSView* contentParent = [[self window] cr_windowView]; 100 NSView* contentParent = [[self window] cr_windowView];
91 [contentParent addSubview:tabStripView_]; 101 [contentParent addSubview:tabStripView_];
92 } 102 }
93 103
(...skipping 26 matching lines...) Expand all
120 overlayWindow_ = [[TabWindowOverlayWindow alloc] 130 overlayWindow_ = [[TabWindowOverlayWindow alloc]
121 initWithContentRect:[window frame] 131 initWithContentRect:[window frame]
122 styleMask:NSBorderlessWindowMask 132 styleMask:NSBorderlessWindowMask
123 backing:NSBackingStoreBuffered 133 backing:NSBackingStoreBuffered
124 defer:YES]; 134 defer:YES];
125 [overlayWindow_ setTitle:@"overlay"]; 135 [overlayWindow_ setTitle:@"overlay"];
126 [overlayWindow_ setBackgroundColor:[NSColor clearColor]]; 136 [overlayWindow_ setBackgroundColor:[NSColor clearColor]];
127 [overlayWindow_ setOpaque:NO]; 137 [overlayWindow_ setOpaque:NO];
128 [overlayWindow_ setDelegate:self]; 138 [overlayWindow_ setDelegate:self];
129 139
130 originalContentView_ = [window contentView]; 140 originalContentView_ = self.chromeContentView;
131 [window addChildWindow:overlayWindow_ ordered:NSWindowAbove]; 141 [window addChildWindow:overlayWindow_ ordered:NSWindowAbove];
132 142
133 // Explicitly set the responder to be nil here (for restoring later). 143 // Explicitly set the responder to be nil here (for restoring later).
134 // If the first responder were to be left non-nil here then 144 // If the first responder were to be left non-nil here then
135 // [RenderWidgethostViewCocoa resignFirstResponder] would be called, 145 // [RenderWidgethostViewCocoa resignFirstResponder] would be called,
136 // followed by RenderWidgetHost::Blur(), which would result in an unexpected 146 // followed by RenderWidgetHost::Blur(), which would result in an unexpected
137 // loss of focus. 147 // loss of focus.
138 focusBeforeOverlay_.reset([[FocusTracker alloc] initWithWindow:window]); 148 focusBeforeOverlay_.reset([[FocusTracker alloc] initWithWindow:window]);
139 [window makeFirstResponder:nil]; 149 [window makeFirstResponder:nil];
140 150
141 // Move the original window's tab strip view and content view to the overlay 151 // 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 152 // window. The content view is added as a subview of the overlay window's
143 // content view (rather than using setContentView:) because the overlay 153 // content view (rather than using setContentView:) because the overlay
144 // window has a different content size (due to it being borderless). 154 // window has a different content size (due to it being borderless).
145 [[overlayWindow_ cr_windowView] addSubview:[self tabStripView]]; 155 [[overlayWindow_ cr_windowView] addSubview:[self tabStripView]];
146 [[overlayWindow_ contentView] addSubview:originalContentView_]; 156 [[overlayWindow_ contentView] addSubview:originalContentView_];
147 157
148 [overlayWindow_ orderFront:nil]; 158 [overlayWindow_ orderFront:nil];
149 } else if (!useOverlay && overlayWindow_) { 159 } else if (!useOverlay && overlayWindow_) {
150 DCHECK(originalContentView_); 160 DCHECK(originalContentView_);
151 161
152 // Return the original window's tab strip view and content view to their 162 // 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 163 // 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 164 // content view and therefore it should always be added after the content
155 // view is set. 165 // view is set.
156 [window setContentView:originalContentView_]; 166 [[window contentView] addSubview:originalContentView_
167 positioned:NSWindowBelow
168 relativeTo:nil];
157 [[window cr_windowView] addSubview:[self tabStripView]]; 169 [[window cr_windowView] addSubview:[self tabStripView]];
158 [[window cr_windowView] updateTrackingAreas]; 170 [[window cr_windowView] updateTrackingAreas];
159 171
160 [focusBeforeOverlay_ restoreFocusInWindow:window]; 172 [focusBeforeOverlay_ restoreFocusInWindow:window];
161 focusBeforeOverlay_.reset(); 173 focusBeforeOverlay_.reset();
162 174
163 [window display]; 175 [window display];
164 [window removeChildWindow:overlayWindow_]; 176 [window removeChildWindow:overlayWindow_];
165 177
166 [overlayWindow_ orderOut:nil]; 178 [overlayWindow_ orderOut:nil];
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 closeDeferred_ = YES; 304 closeDeferred_ = YES;
293 } 305 }
294 306
295 // Called when the size of the window content area has changed. Override to 307 // Called when the size of the window content area has changed. Override to
296 // position specific views. Base class implementation does nothing. 308 // position specific views. Base class implementation does nothing.
297 - (void)layoutSubviews { 309 - (void)layoutSubviews {
298 NOTIMPLEMENTED(); 310 NOTIMPLEMENTED();
299 } 311 }
300 312
301 @end 313 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698