| OLD | NEW |
| 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" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (no_frame_change_during_fullscreen) | 168 if (no_frame_change_during_fullscreen) |
| 169 [window_ setFrame:frame_before_fullscreen_ display:YES animate:NO]; | 169 [window_ setFrame:frame_before_fullscreen_ display:YES animate:NO]; |
| 170 [[NSNotificationCenter defaultCenter] | 170 [[NSNotificationCenter defaultCenter] |
| 171 postNotificationName:NSWindowDidExitFullScreenNotification | 171 postNotificationName:NSWindowDidExitFullScreenNotification |
| 172 object:window_]; | 172 object:window_]; |
| 173 window_ = nil; | 173 window_ = nil; |
| 174 is_in_transition_ = false; | 174 is_in_transition_ = false; |
| 175 style_as_fullscreen_ = false; | 175 style_as_fullscreen_ = false; |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool is_in_transition() { return is_in_transition_; } |
| 179 |
| 178 private: | 180 private: |
| 179 base::mac::ScopedObjCClassSwizzler toggle_fullscreen_swizzler_; | 181 base::mac::ScopedObjCClassSwizzler toggle_fullscreen_swizzler_; |
| 180 base::mac::ScopedObjCClassSwizzler style_mask_swizzler_; | 182 base::mac::ScopedObjCClassSwizzler style_mask_swizzler_; |
| 181 base::mac::ScopedObjCClassSwizzler set_style_mask_swizzler_; | 183 base::mac::ScopedObjCClassSwizzler set_style_mask_swizzler_; |
| 182 | 184 |
| 183 // The currently fullscreen window. | 185 // The currently fullscreen window. |
| 184 NSWindow* window_ = nil; | 186 NSWindow* window_ = nil; |
| 185 NSRect frame_before_fullscreen_; | 187 NSRect frame_before_fullscreen_; |
| 186 NSRect frame_during_fullscreen_; | 188 NSRect frame_during_fullscreen_; |
| 187 bool is_in_transition_ = false; | 189 bool is_in_transition_ = false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 198 ScopedFakeNSWindowFullscreen::ScopedFakeNSWindowFullscreen() { | 200 ScopedFakeNSWindowFullscreen::ScopedFakeNSWindowFullscreen() { |
| 199 DCHECK(!g_fake_fullscreen_impl); | 201 DCHECK(!g_fake_fullscreen_impl); |
| 200 impl_.reset(new Impl); | 202 impl_.reset(new Impl); |
| 201 g_fake_fullscreen_impl = impl_.get(); | 203 g_fake_fullscreen_impl = impl_.get(); |
| 202 } | 204 } |
| 203 | 205 |
| 204 ScopedFakeNSWindowFullscreen::~ScopedFakeNSWindowFullscreen() { | 206 ScopedFakeNSWindowFullscreen::~ScopedFakeNSWindowFullscreen() { |
| 205 g_fake_fullscreen_impl = nullptr; | 207 g_fake_fullscreen_impl = nullptr; |
| 206 } | 208 } |
| 207 | 209 |
| 210 bool ScopedFakeNSWindowFullscreen::IsInTransition() { |
| 211 return impl_->is_in_transition(); |
| 212 } |
| 213 |
| 208 } // namespace test | 214 } // namespace test |
| 209 } // namespace ui | 215 } // namespace ui |
| 210 | 216 |
| 211 @implementation ToggleFullscreenDonorForWindow | 217 @implementation ToggleFullscreenDonorForWindow |
| 212 | 218 |
| 213 - (void)toggleFullScreen:(id)sender { | 219 - (void)toggleFullScreen:(id)sender { |
| 214 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self); | 220 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self); |
| 215 g_fake_fullscreen_impl->ToggleFullscreenForWindow(window); | 221 g_fake_fullscreen_impl->ToggleFullscreenForWindow(window); |
| 216 } | 222 } |
| 217 | 223 |
| 218 - (NSUInteger)styleMask { | 224 - (NSUInteger)styleMask { |
| 219 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self); | 225 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(self); |
| 220 return g_fake_fullscreen_impl->StyleMaskForWindow(window); | 226 return g_fake_fullscreen_impl->StyleMaskForWindow(window); |
| 221 } | 227 } |
| 222 | 228 |
| 223 - (void)setStyleMask:(NSUInteger)newMask { | 229 - (void)setStyleMask:(NSUInteger)newMask { |
| 224 // Permit the non-fullscreen bits of the style mask to be changed while | 230 // 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. | 231 // currently fullscreen, but don't let AppKit see any fullscreen bits. |
| 226 NSUInteger currentMask = [self styleMask]; | 232 NSUInteger currentMask = [self styleMask]; |
| 227 if ((newMask ^ currentMask) & NSFullScreenWindowMask) { | 233 if ((newMask ^ currentMask) & NSFullScreenWindowMask) { |
| 228 // Since 10.11, OSX triggers fullscreen transitions via setStyleMask, but | 234 // Since 10.11, OSX triggers fullscreen transitions via setStyleMask, but |
| 229 // the faker doesn't attempt to fake them yet. | 235 // the faker doesn't attempt to fake them yet. |
| 230 NOTREACHED() << "Can't set NSFullScreenWindowMask while faking fullscreen."; | 236 NOTREACHED() << "Can't set NSFullScreenWindowMask while faking fullscreen."; |
| 231 } | 237 } |
| 232 newMask &= ~NSFullScreenWindowMask; | 238 newMask &= ~NSFullScreenWindowMask; |
| 233 g_fake_fullscreen_impl->SetStyleMaskImplementation()(self, _cmd, newMask); | 239 g_fake_fullscreen_impl->SetStyleMaskImplementation()(self, _cmd, newMask); |
| 234 } | 240 } |
| 235 | 241 |
| 236 @end | 242 @end |
| OLD | NEW |