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

Side by Side Diff: ui/base/test/scoped_fake_nswindow_fullscreen.mm

Issue 1905273002: Fix positioning of Mac permission prompts when fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 4 years, 7 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 | « ui/base/test/scoped_fake_nswindow_fullscreen.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/base/test/scoped_fake_nswindow_fullscreen.h" 5 #import "ui/base/test/scoped_fake_nswindow_fullscreen.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
11 #import "base/mac/mac_util.h" 11 #import "base/mac/mac_util.h"
12 #import "base/mac/scoped_nsobject.h" 12 #import "base/mac/scoped_nsobject.h"
13 #import "base/mac/scoped_objc_class_swizzler.h" 13 #import "base/mac/scoped_objc_class_swizzler.h"
14 #import "base/mac/sdk_forward_declarations.h" 14 #import "base/mac/sdk_forward_declarations.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h"
17 18
18 // This method exists on NSWindowDelegate on 10.7+. 19 // This method exists on NSWindowDelegate on 10.7+.
19 // To build on 10.6, we just need to declare it somewhere. We'll test 20 // To build on 10.6, we just need to declare it somewhere. We'll test
20 // -[NSObject respondsToSelector] before calling it. 21 // -[NSObject respondsToSelector] before calling it.
21 #if !defined(MAC_OS_X_VERSION_10_7) || \ 22 #if !defined(MAC_OS_X_VERSION_10_7) || \
22 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 23 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
23 @protocol NSWindowDelegateLion 24 @protocol NSWindowDelegateLion
24 - (NSSize)window:(NSWindow*)window 25 - (NSSize)window:(NSWindow*)window
25 willUseFullScreenContentSize:(NSSize)proposedSize; 26 willUseFullScreenContentSize:(NSSize)proposedSize;
26 @end 27 @end
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (no_frame_change_during_fullscreen) 169 if (no_frame_change_during_fullscreen)
169 [window_ setFrame:frame_before_fullscreen_ display:YES animate:NO]; 170 [window_ setFrame:frame_before_fullscreen_ display:YES animate:NO];
170 [[NSNotificationCenter defaultCenter] 171 [[NSNotificationCenter defaultCenter]
171 postNotificationName:NSWindowDidExitFullScreenNotification 172 postNotificationName:NSWindowDidExitFullScreenNotification
172 object:window_]; 173 object:window_];
173 window_ = nil; 174 window_ = nil;
174 is_in_transition_ = false; 175 is_in_transition_ = false;
175 style_as_fullscreen_ = false; 176 style_as_fullscreen_ = false;
176 } 177 }
177 178
179 bool is_in_transition() { return is_in_transition_; }
180
178 private: 181 private:
179 base::mac::ScopedObjCClassSwizzler toggle_fullscreen_swizzler_; 182 base::mac::ScopedObjCClassSwizzler toggle_fullscreen_swizzler_;
180 base::mac::ScopedObjCClassSwizzler style_mask_swizzler_; 183 base::mac::ScopedObjCClassSwizzler style_mask_swizzler_;
181 base::mac::ScopedObjCClassSwizzler set_style_mask_swizzler_; 184 base::mac::ScopedObjCClassSwizzler set_style_mask_swizzler_;
182 185
183 // The currently fullscreen window. 186 // The currently fullscreen window.
184 NSWindow* window_ = nil; 187 NSWindow* window_ = nil;
185 NSRect frame_before_fullscreen_; 188 NSRect frame_before_fullscreen_;
186 NSRect frame_during_fullscreen_; 189 NSRect frame_during_fullscreen_;
187 bool is_in_transition_ = false; 190 bool is_in_transition_ = false;
(...skipping 10 matching lines...) Expand all
198 ScopedFakeNSWindowFullscreen::ScopedFakeNSWindowFullscreen() { 201 ScopedFakeNSWindowFullscreen::ScopedFakeNSWindowFullscreen() {
199 DCHECK(!g_fake_fullscreen_impl); 202 DCHECK(!g_fake_fullscreen_impl);
200 impl_.reset(new Impl); 203 impl_.reset(new Impl);
201 g_fake_fullscreen_impl = impl_.get(); 204 g_fake_fullscreen_impl = impl_.get();
202 } 205 }
203 206
204 ScopedFakeNSWindowFullscreen::~ScopedFakeNSWindowFullscreen() { 207 ScopedFakeNSWindowFullscreen::~ScopedFakeNSWindowFullscreen() {
205 g_fake_fullscreen_impl = nullptr; 208 g_fake_fullscreen_impl = nullptr;
206 } 209 }
207 210
211 void ScopedFakeNSWindowFullscreen::FinishTransition() {
212 if (impl_->is_in_transition())
213 base::RunLoop().RunUntilIdle();
214
215 DCHECK(!impl_->is_in_transition());
216 }
217
208 } // namespace test 218 } // namespace test
209 } // namespace ui 219 } // namespace ui
210 220
211 @implementation ToggleFullscreenDonorForWindow 221 @implementation ToggleFullscreenDonorForWindow
212 222
213 - (void)toggleFullScreen:(id)sender { 223 - (void)toggleFullScreen:(id)sender {
214 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self); 224 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self);
215 g_fake_fullscreen_impl->ToggleFullscreenForWindow(window); 225 g_fake_fullscreen_impl->ToggleFullscreenForWindow(window);
216 } 226 }
217 227
218 - (NSUInteger)styleMask { 228 - (NSUInteger)styleMask {
219 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self); 229 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self);
220 return g_fake_fullscreen_impl->StyleMaskForWindow(window); 230 return g_fake_fullscreen_impl->StyleMaskForWindow(window);
221 } 231 }
222 232
223 - (void)setStyleMask:(NSUInteger)newMask { 233 - (void)setStyleMask:(NSUInteger)newMask {
224 // Permit the non-fullscreen bits of the style mask to be changed while 234 // Permit the non-fullscreen bits of the style mask to be changed while
225 // currently fullscreen, but don't let AppKit see any fullscreen bits. 235 // currently fullscreen, but don't let AppKit see any fullscreen bits.
226 NSUInteger currentMask = [self styleMask]; 236 NSUInteger currentMask = [self styleMask];
227 if ((newMask ^ currentMask) & NSFullScreenWindowMask) { 237 if ((newMask ^ currentMask) & NSFullScreenWindowMask) {
228 // Since 10.11, OSX triggers fullscreen transitions via setStyleMask, but 238 // Since 10.11, OSX triggers fullscreen transitions via setStyleMask, but
229 // the faker doesn't attempt to fake them yet. 239 // the faker doesn't attempt to fake them yet.
230 NOTREACHED() << "Can't set NSFullScreenWindowMask while faking fullscreen."; 240 NOTREACHED() << "Can't set NSFullScreenWindowMask while faking fullscreen.";
231 } 241 }
232 newMask &= ~NSFullScreenWindowMask; 242 newMask &= ~NSFullScreenWindowMask;
233 g_fake_fullscreen_impl->SetStyleMaskImplementation()(self, _cmd, newMask); 243 g_fake_fullscreen_impl->SetStyleMaskImplementation()(self, _cmd, newMask);
234 } 244 }
235 245
236 @end 246 @end
OLDNEW
« no previous file with comments | « ui/base/test/scoped_fake_nswindow_fullscreen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698