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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_enter_fullscreen_transition.h

Issue 846443004: mac: Implement custom AppKit Enter Fullscreen transition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
Andre 2015/01/12 06:10:03 2015
erikchen 2015/01/12 19:18:58 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_FULLSCREEN_TRANSITION_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_FULLSCREEN_TRANSITION_H_
7
8 #import <AppKit/AppKit.h>
9 #import <Foundation/Foundation.h>
10
11 // This class is responsible for managing the custom transition of a
12 // BrowserWindow from its normal state into an AppKit Fullscreen state.
13 //
14 // By default, when AppKit Fullscreens a window, it creates a new virtual
15 // desktop and slides it in from the right of the screen. At the same time, the
16 // old virtual desktop slides off to the left. This animation takes one second,
17 // and the time is not customizable without elevated privileges or a
18 // self-modifying binary
19 // (https://code.google.com/p/chromium/issues/detail?id=414527). During that
20 // second, no user interaction is possible.
21 //
22 // The default implementation of the AppKit transition smoothly animates a
23 // window from its original size to the full size of the screen. At the
24 // beginning of the animation, it takes a snapshot of the window's current
25 // state. Then it resizes the window, calls drawRect: (theorized, not tested),
26 // and takes a snapshot of the window's final state. The animation is a simple
27 // crossfade between the two snapshots. This has a flaw. Frequently, the
28 // renderer has not yet drawn content for the resized window by the time
29 // drawRect: is called. As a result, the animation is effectively a no-op. When
30 // the animation is finished, the new web content flashes in.
31 //
32 // The window's delegate can override two methods to customize the transition.
33 // -customWindowsToEnterFullScreenForWindow:
34 // The return of this method is an array of NSWindows. Each window that is
35 // returned will be added to the new virtual desktop after the animation is
36 // finished, but will not be a part of the animation itself.
37 // -window:startCustomAnimationToEnterFullScreenWithDuration:
38 // In this method, the window's delegate adds animations to the windows
39 // returned in the above method.
40 //
41 // The goal of this class is to mimic the default animation, but instead of
42 // taking a snapshot of the final web content, it uses the live web content
43 // during the animation.
44 //
45 // See https://code.google.com/p/chromium/issues/detail?id=414527#c22 and its
46 // preceding comments for a more detailed description of the implementation,
47 // and the reasoning behind the decisions made.
48 //
49 // Recommended usage:
50 // (Override method on NSWindow's delegate)
51 // - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window {
52 // self.transition = [[BrowserWindowEnterFullscreenTransition alloc]
53 // initWithWindow:window];
Andre 2015/01/12 06:10:03 This is only sample code, but it's a leak without
erikchen 2015/01/12 19:18:58 I added an autorelease. There's no way to determi
54 // return [self.transition customWindowsToEnterFullScreen];
55 // }
56 //
57 // (Override method on NSWindow's delegate)
58 // - (void)window:(NSWindow*)window
59 // startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration {
60 // [self.transition
61 // startCustomAnimationToEnterFullScreenWithDuration:duration];
62 // }
63 //
64 // (Override method on NSWindow's delegate)
65 // - (void)windowDidEnterFullScreen:(NSNotification*)notification {
66 // self.transition = nil;
67 // }
68 //
69 // (Override method on NSWindow)
70 // - (NSRect)constrainFrameRect:(NSRect)frame toScreen:(NSScreen*)screen {
71 // if (self.transition && ![self.transition shouldWindowBeConstrained])
72 // return frame;
73 // return [super constrainFrameRect:frame toScreen:screen];
74 // }
75
76 @interface BrowserWindowEnterFullscreenTransition : NSObject
77
78 // Designated initializer. |window| is the NSWindow that is going to be moved
79 // into a fullscreen Space (virtual desktop), and resized to have the same size
80 // as the screen. |window|'s root view must be layer backed.
81 - (instancetype)initWithWindow:(NSWindow*)window;
82
83 // Returns the windows to be used in the custom transition.
84 // - Takes a snapshot of the current window.
85 // - Makes a new snapshot window which shows the snapshot in the same
86 // location as the current window.
87 // - Adds the style mask NSFullScreenWindowMask to the current window.
88 // - Makes the current window transparent, and resizes the current window to
89 // be the same size as the screen.
90 - (NSArray*)customWindowsToEnterFullScreen;
91
92 // Begins the animations used for the custom fullscreen transition.
93 // - Animates the snapshot to the full size of the screen while fading it out.
94 // - Animates the current window from it's original location to its final
95 // location, while fading it in.
96 // Note: The two animations are added to different layers in different windows.
97 // There is no explicit logic to keep the two animations in sync. If this
98 // proves to be a problem, the relevant layers should attempt to sync up their
99 // time offsets with CACurrentMediaTime().
100 - (void)startCustomAnimationToEnterFullScreenWithDuration:
101 (NSTimeInterval)duration;
102
103 // When this method returns true, the NSWindow method
104 // -constrainFrameRect:toScreen: must return the frame rect without
105 // constraining it. The owner of the instance of this class is responsible for
106 // hooking up this logic.
107 - (BOOL)shouldWindowBeUnconstrained;
108
109 @end
110
111 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_FULLSCREEN_TRANSITION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698