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

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h

Issue 2138213003: Mac: Do layout before adding the WebContents to the view hierarchy when switching tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ensureContentsVisibleInSuperview Created 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
7 7
8 #include <Cocoa/Cocoa.h> 8 #include <Cocoa/Cocoa.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 class FullscreenObserver; 12 class FullscreenObserver;
13 13
14 namespace content { 14 namespace content {
15 class WebContents; 15 class WebContents;
16 } 16 }
17 17
18 // A class that controls the WebContents view. It internally creates a container 18 // A class that controls the WebContents view. It internally creates a container
19 // view (the NSView accessed by calling |-view|) which manages the layout and 19 // view (the NSView accessed by calling |-view|) which manages the layout and
20 // display of the WebContents view. 20 // display of the WebContents view.
21 // 21 //
22 // Client code that inserts [controller view] into the view hierarchy needs to 22 // Client code that inserts [controller view] into the view hierarchy needs to
23 // beforehand call the |-ensureContentsSizeDoesNotChange| method. This will 23 // call -ensureContentsVisibleInSuperview:(NSView*)superview to match the
24 // avoid multiple resize messages being sent to the renderer and triggering 24 // container to the [superview bounds] and avoid multiple resize messages being
25 // redundant and costly layouts. After the view has been inserted, client code 25 // sent to the renderer, which triggers redundant and costly layouts.
26 // calls |-ensureContentsVisible| to display the WebContents view.
27 // 26 //
28 // AutoEmbedFullscreen mode: When enabled, TabContentsController will observe 27 // AutoEmbedFullscreen mode: When enabled, TabContentsController will observe
29 // for WebContents fullscreen changes and automatically swap the normal 28 // for WebContents fullscreen changes and automatically swap the normal
30 // WebContents view with the fullscreen view (if different). In addition, if a 29 // WebContents view with the fullscreen view (if different). In addition, if a
31 // WebContents is being screen-captured, the view will be centered within the 30 // WebContents is being screen-captured, the view will be centered within the
32 // container view, sized to the aspect ratio of the capture video resolution, 31 // container view, sized to the aspect ratio of the capture video resolution,
33 // and scaling will be avoided whenever possible. 32 // and scaling will be avoided whenever possible.
34 @interface TabContentsController : NSViewController { 33 @interface TabContentsController : NSViewController {
35 @private 34 @private
36 content::WebContents* contents_; // weak 35 content::WebContents* contents_; // weak
(...skipping 13 matching lines...) Expand all
50 // This flag is set to true when we don't want the fullscreen widget to 49 // This flag is set to true when we don't want the fullscreen widget to
51 // resize. This is done so that we can avoid resizing the fullscreen widget 50 // resize. This is done so that we can avoid resizing the fullscreen widget
52 // to intermediate sizes during the fullscreen transition. 51 // to intermediate sizes during the fullscreen transition.
53 // As a result, we would prevent janky movements during the transition and 52 // As a result, we would prevent janky movements during the transition and
54 // Pepper Fullscreen from blowing up. 53 // Pepper Fullscreen from blowing up.
55 @property(assign, nonatomic) BOOL blockFullscreenResize; 54 @property(assign, nonatomic) BOOL blockFullscreenResize;
56 55
57 // Create the contents of a tab represented by |contents|. 56 // Create the contents of a tab represented by |contents|.
58 - (id)initWithContents:(content::WebContents*)contents isPopup:(BOOL)popup; 57 - (id)initWithContents:(content::WebContents*)contents isPopup:(BOOL)popup;
59 58
60 // Call when the container view owned by TabContentsController is about to be 59 // Call to insert the container view into the view hierarchy, sizing it to match
61 // resized and inserted into the view hierarchy, so as to not trigger 60 // |superview|. Then, this method will select either the WebContents view or
62 // unnecessary content re-layout. 61 // the fullscreen view and swap it into the container for display.
63 - (void)ensureContentsSizeDoesNotChange; 62 - (void)ensureContentsVisibleInSuperview:(NSView*)superview;
64
65 // Call after the container view is inserted into the view hierarchy and
66 // properly sized. Then, this method will select either the WebContents view or
67 // the fullscreen view and swap it into the view hierarchy for display.
68 - (void)ensureContentsVisible;
69 63
70 // Called after we enter fullscreen to ensure that the fullscreen widget will 64 // Called after we enter fullscreen to ensure that the fullscreen widget will
71 // have the right frame. 65 // have the right frame.
72 - (void)updateFullscreenWidgetFrame; 66 - (void)updateFullscreenWidgetFrame;
73 67
74 // Call to change the underlying web contents object. View is not changed, 68 // Call to change the underlying web contents object. View is not changed,
75 // call |-ensureContentsVisible| to display the |newContents|'s render widget 69 // call |-ensureContentsVisible| to display the |newContents|'s render widget
76 // host view. 70 // host view.
77 - (void)changeWebContents:(content::WebContents*)newContents; 71 - (void)changeWebContents:(content::WebContents*)newContents;
78 72
(...skipping 11 matching lines...) Expand all
90 // an entirely new tab contents object. 84 // an entirely new tab contents object.
91 - (void)tabDidChange:(content::WebContents*)updatedContents; 85 - (void)tabDidChange:(content::WebContents*)updatedContents;
92 86
93 // Called to switch the container's subview to the WebContents-owned fullscreen 87 // Called to switch the container's subview to the WebContents-owned fullscreen
94 // widget or back to WebContentsView's widget. 88 // widget or back to WebContentsView's widget.
95 - (void)toggleFullscreenWidget:(BOOL)enterFullscreen; 89 - (void)toggleFullscreenWidget:(BOOL)enterFullscreen;
96 90
97 @end 91 @end
98 92
99 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_ 93 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698