OLD | NEW |
---|---|
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/tab_contents/tab_contents_controller.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 return [NSColor whiteColor]; | 111 return [NSColor whiteColor]; |
112 | 112 |
113 // Fill with a dark tint of the new tab page's background color. This is | 113 // Fill with a dark tint of the new tab page's background color. This is |
114 // only seen when the subview is sized specially for fullscreen tab capture. | 114 // only seen when the subview is sized specially for fullscreen tab capture. |
115 NSColor* bgColor = nil; | 115 NSColor* bgColor = nil; |
116 ThemeService* const theme = | 116 ThemeService* const theme = |
117 static_cast<ThemeService*>([[self window] themeProvider]); | 117 static_cast<ThemeService*>([[self window] themeProvider]); |
118 if (theme) | 118 if (theme) |
119 bgColor = theme->GetNSColor(ThemeProperties::COLOR_NTP_BACKGROUND); | 119 bgColor = theme->GetNSColor(ThemeProperties::COLOR_NTP_BACKGROUND); |
120 if (!bgColor) | 120 if (!bgColor) |
121 bgColor = [[self window] backgroundColor]; | 121 bgColor = [NSColor whiteColor]; |
miu
2014/06/06 01:09:10
The decision (in https://codereview.chromium.org/2
| |
122 const float kDarknessFraction = 0.80f; | 122 const float kDarknessFraction = 0.80f; |
123 return [bgColor blendedColorWithFraction:kDarknessFraction | 123 return [bgColor blendedColorWithFraction:kDarknessFraction |
124 ofColor:[NSColor blackColor]]; | 124 ofColor:[NSColor blackColor]]; |
125 } | 125 } |
126 | 126 |
127 // Override -drawRect to fill the view with a solid color outside of the | |
128 // subview's frame. | |
129 - (void)drawRect:(NSRect)dirtyRect { | |
130 NSView* const contentsView = | |
131 [[self subviews] count] > 0 ? [[self subviews] objectAtIndex:0] : nil; | |
132 if (!contentsView || !NSContainsRect([contentsView frame], dirtyRect)) { | |
133 [[self computeBackgroundColor] setFill]; | |
134 NSRectFill(dirtyRect); | |
135 } | |
136 [super drawRect:dirtyRect]; | |
137 } | |
138 | |
139 // Override auto-resizing logic to query the delegate for the exact frame to | 127 // Override auto-resizing logic to query the delegate for the exact frame to |
140 // use for the contents view. | 128 // use for the contents view. |
141 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { | 129 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { |
142 NSView* const contentsView = | 130 NSView* const contentsView = |
143 [[self subviews] count] > 0 ? [[self subviews] objectAtIndex:0] : nil; | 131 [[self subviews] count] > 0 ? [[self subviews] objectAtIndex:0] : nil; |
144 if (!contentsView || [contentsView autoresizingMask] == NSViewNotSizable || | 132 if (!contentsView || [contentsView autoresizingMask] == NSViewNotSizable || |
145 !delegate_) { | 133 !delegate_) { |
146 return; | 134 return; |
147 } | 135 } |
148 | 136 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 [contentsNativeView setFrame:[self frameForContentsView]]; | 214 [contentsNativeView setFrame:[self frameForContentsView]]; |
227 if ([subviews count] == 0) { | 215 if ([subviews count] == 0) { |
228 [contentsContainer addSubview:contentsNativeView]; | 216 [contentsContainer addSubview:contentsNativeView]; |
229 } else if ([subviews objectAtIndex:0] != contentsNativeView) { | 217 } else if ([subviews objectAtIndex:0] != contentsNativeView) { |
230 [contentsContainer replaceSubview:[subviews objectAtIndex:0] | 218 [contentsContainer replaceSubview:[subviews objectAtIndex:0] |
231 with:contentsNativeView]; | 219 with:contentsNativeView]; |
232 } | 220 } |
233 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| | 221 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| |
234 NSViewHeightSizable]; | 222 NSViewHeightSizable]; |
235 | 223 |
236 // TODO(miu): The following can be removed once we use a CALayer in | |
237 // TabContentsContainerView. http://crbug.com/354598 | |
238 [contentsContainer setNeedsDisplay:YES]; | 224 [contentsContainer setNeedsDisplay:YES]; |
miu
2014/06/06 01:09:10
I kept this call to setNeedsDisplay since this wil
| |
239 | 225 |
240 // The rendering path with overlapping views disabled causes bugs when | 226 // The rendering path with overlapping views disabled causes bugs when |
241 // transitioning between composited and non-composited mode. | 227 // transitioning between composited and non-composited mode. |
242 // http://crbug.com/279472 | 228 // http://crbug.com/279472 |
243 if (!fullscreenView) | 229 if (!fullscreenView) |
244 contents_->SetAllowOverlappingViews(true); | 230 contents_->SetAllowOverlappingViews(true); |
245 } | 231 } |
246 | 232 |
247 - (void)changeWebContents:(WebContents*)newContents { | 233 - (void)changeWebContents:(WebContents*)newContents { |
248 contents_ = newContents; | 234 contents_ = newContents; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } else { | 342 } else { |
357 rect.ClampToCenteredSize(gfx::Size( | 343 rect.ClampToCenteredSize(gfx::Size( |
358 static_cast<int>(x / captureSize.height()), rect.height())); | 344 static_cast<int>(x / captureSize.height()), rect.height())); |
359 } | 345 } |
360 } | 346 } |
361 | 347 |
362 return NSRectFromCGRect(rect.ToCGRect()); | 348 return NSRectFromCGRect(rect.ToCGRect()); |
363 } | 349 } |
364 | 350 |
365 @end | 351 @end |
OLD | NEW |