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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for initial review. Created 8 years, 9 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) 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/tabpose_window.h" 5 #import "chrome/browser/ui/cocoa/tabpose_window.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 return topOffset; 249 return topOffset;
250 } 250 }
251 251
252 - (int)bottomOffset { 252 - (int)bottomOffset {
253 int bottomOffset = 0; 253 int bottomOffset = 0;
254 TabContentsWrapper* devToolsContents = 254 TabContentsWrapper* devToolsContents =
255 DevToolsWindow::GetDevToolsContents(contents_->web_contents()); 255 DevToolsWindow::GetDevToolsContents(contents_->web_contents());
256 if (devToolsContents && devToolsContents->web_contents() && 256 if (devToolsContents && devToolsContents->web_contents() &&
257 devToolsContents->web_contents()->GetRenderViewHost() && 257 devToolsContents->web_contents()->GetRenderViewHost() &&
258 devToolsContents->web_contents()->GetRenderViewHost()->view()) { 258 devToolsContents->web_contents()->GetRenderViewHost()->GetView()) {
259 // The devtool's size might not be up-to-date, but since its height doesn't 259 // The devtool's size might not be up-to-date, but since its height doesn't
260 // change on window resize, and since most users don't use devtools, this is 260 // change on window resize, and since most users don't use devtools, this is
261 // good enough. 261 // good enough.
262 bottomOffset += 262 bottomOffset +=
263 devToolsContents->web_contents()->GetRenderViewHost()->view()-> 263 devToolsContents->web_contents()->GetRenderViewHost()->GetView()->
264 GetViewBounds().height(); 264 GetViewBounds().height();
265 bottomOffset += 1; // :-( Divider line between web contents and devtools. 265 bottomOffset += 1; // :-( Divider line between web contents and devtools.
266 } 266 }
267 return bottomOffset; 267 return bottomOffset;
268 } 268 }
269 269
270 - (void)drawBackingStore:(BackingStoreMac*)backing_store 270 - (void)drawBackingStore:(BackingStoreMac*)backing_store
271 inRect:(CGRect)destRect 271 inRect:(CGRect)destRect
272 context:(CGContextRef)context { 272 context:(CGContextRef)context {
273 // TODO(thakis): Add a sublayer for each accelerated surface in the rwhv. 273 // TODO(thakis): Add a sublayer for each accelerated surface in the rwhv.
274 // Until then, accelerated layers (CoreAnimation NPAPI plugins, compositor) 274 // Until then, accelerated layers (CoreAnimation NPAPI plugins, compositor)
275 // won't show up in tabpose. 275 // won't show up in tabpose.
276 gfx::ScopedCGContextSaveGState CGContextSaveGState(context); 276 gfx::ScopedCGContextSaveGState CGContextSaveGState(context);
277 CGContextSetInterpolationQuality(context, kCGInterpolationHigh); 277 CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
278 if (backing_store->cg_layer()) { 278 if (backing_store->cg_layer()) {
279 CGContextDrawLayerInRect(context, destRect, backing_store->cg_layer()); 279 CGContextDrawLayerInRect(context, destRect, backing_store->cg_layer());
280 } else { 280 } else {
281 base::mac::ScopedCFTypeRef<CGImageRef> image( 281 base::mac::ScopedCFTypeRef<CGImageRef> image(
282 CGBitmapContextCreateImage(backing_store->cg_bitmap())); 282 CGBitmapContextCreateImage(backing_store->cg_bitmap()));
283 CGContextDrawImage(context, destRect, image); 283 CGContextDrawImage(context, destRect, image);
284 } 284 }
285 } 285 }
286 286
287 - (void)drawInContext:(CGContextRef)context { 287 - (void)drawInContext:(CGContextRef)context {
288 RenderWidgetHost* rwh = contents_->web_contents()->GetRenderViewHost(); 288 RenderWidgetHost* rwh = contents_->web_contents()->GetRenderViewHost();
289 // NULL if renderer crashed. 289 // NULL if renderer crashed.
290 content::RenderWidgetHostView* rwhv = rwh ? rwh->view() : NULL; 290 content::RenderWidgetHostView* rwhv = rwh ? rwh->GetView() : NULL;
291 if (!rwhv) { 291 if (!rwhv) {
292 // TODO(thakis): Maybe draw a sad tab layer? 292 // TODO(thakis): Maybe draw a sad tab layer?
293 [super drawInContext:context]; 293 [super drawInContext:context];
294 return; 294 return;
295 } 295 }
296 296
297 // The size of the TabContent's RenderWidgetHost might not fit to the 297 // The size of the TabContent's RenderWidgetHost might not fit to the
298 // current browser window at all, for example if the window was resized while 298 // current browser window at all, for example if the window was resized while
299 // this TabContents object was not an active tab. 299 // this TabContents object was not an active tab.
300 // Compute the required size ourselves. Leave room for eventual infobars and 300 // Compute the required size ourselves. Leave room for eventual infobars and
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 tile.set_tab_contents(contents); 1683 tile.set_tab_contents(contents);
1684 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; 1684 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index];
1685 [thumbLayer setTabContents:contents]; 1685 [thumbLayer setTabContents:contents];
1686 } 1686 }
1687 1687
1688 - (void)tabStripModelDeleted { 1688 - (void)tabStripModelDeleted {
1689 [self close]; 1689 [self close];
1690 } 1690 }
1691 1691
1692 @end 1692 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698