2016-08-04 06:34:29 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/osr/osr_web_contents_view.h"
|
2016-08-04 06:34:29 +00:00
|
|
|
|
2016-09-06 08:24:37 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2016-08-04 06:34:29 +00:00
|
|
|
@interface OffScreenView : NSView
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation OffScreenView
|
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)dirtyRect {
|
|
|
|
NSString* str = @"No content under offscreen mode";
|
|
|
|
NSMutableParagraphStyle* paragraphStyle =
|
2023-08-04 08:47:29 +00:00
|
|
|
[[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
2022-06-01 06:12:47 +00:00
|
|
|
[paragraphStyle setAlignment:NSTextAlignmentCenter];
|
2018-04-20 18:47:04 +00:00
|
|
|
NSDictionary* attributes =
|
|
|
|
[NSDictionary dictionaryWithObject:paragraphStyle
|
|
|
|
forKey:NSParagraphStyleAttributeName];
|
2016-08-04 06:34:29 +00:00
|
|
|
NSAttributedString* text =
|
2023-08-04 08:47:29 +00:00
|
|
|
[[NSAttributedString alloc] initWithString:str attributes:attributes];
|
2016-08-04 06:34:29 +00:00
|
|
|
NSRect frame = NSMakeRect(0, (self.frame.size.height - text.size.height) / 2,
|
|
|
|
self.frame.size.width, text.size.height);
|
|
|
|
[str drawInRect:frame withAttributes:attributes];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
|
|
|
|
return offScreenView_;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
|
|
|
|
return offScreenView_;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
|
|
|
|
return [offScreenView_ window];
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenWebContentsView::PlatformCreate() {
|
|
|
|
offScreenView_ = [[OffScreenView alloc] init];
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenWebContentsView::PlatformDestroy() {
|
2023-08-04 08:47:29 +00:00
|
|
|
offScreenView_ = nil;
|
2016-08-04 06:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace electron
|