mac: cefclient: Fix deprecation warnings

This commit is contained in:
Marshall Greenblatt
2023-07-24 12:57:37 -04:00
parent 8b46735b79
commit b07a9e1843
4 changed files with 30 additions and 16 deletions

View File

@@ -21,6 +21,10 @@
#import <AppKit/NSAccessibility.h> #import <AppKit/NSAccessibility.h>
// Begin disable NSOpenGL deprecation warnings.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface BrowserOpenGLView @interface BrowserOpenGLView
: NSOpenGLView <NSDraggingSource, NSDraggingDestination, NSAccessibility> { : NSOpenGLView <NSDraggingSource, NSDraggingDestination, NSAccessibility> {
@private @private
@@ -119,15 +123,18 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) {
[self resetDragDrop]; [self resetDragDrop];
NSArray* types = [NSArray NSArray* types = [NSArray arrayWithObjects:kCEFDragDummyPboardType,
arrayWithObjects:kCEFDragDummyPboardType, NSStringPboardType, NSPasteboardTypeFileURL,
NSFilenamesPboardType, NSPasteboardTypeString, nil]; NSPasteboardTypeString, nil];
[self registerForDraggedTypes:types]; [self registerForDraggedTypes:types];
} }
return self; return self;
} }
// End disable NSOpenGL deprecation warnings.
#pragma clang diagnostic pop
- (void)dealloc { - (void)dealloc {
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
removeObserver:self removeObserver:self
@@ -998,7 +1005,7 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) {
} }
// URL. // URL.
if ([type isEqualToString:NSURLPboardType]) { if ([type isEqualToString:NSPasteboardTypeURL]) {
DCHECK(current_drag_data_->IsLink()); DCHECK(current_drag_data_->IsLink());
NSString* strUrl = NSString* strUrl =
[NSString stringWithUTF8String:current_drag_data_->GetLinkURL() [NSString stringWithUTF8String:current_drag_data_->GetLinkURL()
@@ -1030,12 +1037,12 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) {
forType:fileUTI_]; forType:fileUTI_];
// Plain text. // Plain text.
} else if ([type isEqualToString:NSStringPboardType]) { } else if ([type isEqualToString:NSPasteboardTypeString]) {
NSString* strTitle = NSString* strTitle =
[NSString stringWithUTF8String:current_drag_data_->GetFragmentText() [NSString stringWithUTF8String:current_drag_data_->GetFragmentText()
.ToString() .ToString()
.c_str()]; .c_str()];
[pboard setString:strTitle forType:NSStringPboardType]; [pboard setString:strTitle forType:NSPasteboardTypeString];
} else if ([type isEqualToString:kCEFDragDummyPboardType]) { } else if ([type isEqualToString:kCEFDragDummyPboardType]) {
// The dummy type _was_ promised and someone decided to call the bluff. // The dummy type _was_ promised and someone decided to call the bluff.
@@ -1122,7 +1129,7 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) {
// URL (and title). // URL (and title).
if (current_drag_data_->IsLink()) { if (current_drag_data_->IsLink()) {
[pasteboard_ addTypes:@[ NSURLPboardType, kNSURLTitlePboardType ] [pasteboard_ addTypes:@[ NSPasteboardTypeURL, kNSURLTitlePboardType ]
owner:self]; owner:self];
} }
@@ -1149,9 +1156,15 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) {
CFRelease(mimeTypeCF); CFRelease(mimeTypeCF);
// File (HFS) promise. // File (HFS) promise.
NSArray* fileUTIList = @[ fileUTI_ ]; NSArray* fileUTIList = @[ fileUTI_ ];
[pasteboard_ addTypes:@[ NSFilesPromisePboardType ] owner:self]; NSString* NSPasteboardTypeFileURLPromise =
#if __has_feature(objc_arc)
(__bridge NSString*)kPasteboardTypeFileURLPromise;
#else
(NSString*)kPasteboardTypeFileURLPromise;
#endif
[pasteboard_ addTypes:@[ NSPasteboardTypeFileURLPromise ] owner:self];
[pasteboard_ setPropertyList:fileUTIList [pasteboard_ setPropertyList:fileUTIList
forType:NSFilesPromisePboardType]; forType:NSPasteboardTypeFileURLPromise];
[pasteboard_ addTypes:fileUTIList owner:self]; [pasteboard_ addTypes:fileUTIList owner:self];
} }
@@ -1159,7 +1172,7 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) {
// Plain text. // Plain text.
if (!current_drag_data_->GetFragmentText().empty()) { if (!current_drag_data_->GetFragmentText().empty()) {
[pasteboard_ addTypes:@[ NSStringPboardType ] owner:self]; [pasteboard_ addTypes:@[ NSPasteboardTypeString ] owner:self];
} }
} }
@@ -1171,14 +1184,14 @@ NSPoint ConvertPointFromWindowToScreen(NSWindow* window, NSPoint point) {
NSArray* types = [pboard types]; NSArray* types = [pboard types];
// Get plain text. // Get plain text.
if ([types containsObject:NSStringPboardType]) { if ([types containsObject:NSPasteboardTypeString]) {
data->SetFragmentText( data->SetFragmentText(
[[pboard stringForType:NSStringPboardType] UTF8String]); [[pboard stringForType:NSPasteboardTypeString] UTF8String]);
} }
// Get files. // Get files.
if ([types containsObject:NSFilenamesPboardType]) { if ([types containsObject:NSPasteboardTypeFileURL]) {
NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; NSArray* files = [pboard propertyListForType:NSPasteboardTypeFileURL];
if ([files isKindOfClass:[NSArray class]] && [files count]) { if ([files isKindOfClass:[NSArray class]] && [files count]) {
for (NSUInteger i = 0; i < [files count]; i++) { for (NSUInteger i = 0; i < [files count]; i++) {
NSString* filename = [files objectAtIndex:i]; NSString* filename = [files objectAtIndex:i];

View File

@@ -7,6 +7,7 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include <gl/gl.h> #include <gl/gl.h>
#elif defined(OS_MAC) #elif defined(OS_MAC)
#define GL_SILENCE_DEPRECATION
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#include <GL/gl.h> #include <GL/gl.h>

View File

@@ -58,7 +58,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
[button autorelease]; [button autorelease];
#endif // !__has_feature(objc_arc) #endif // !__has_feature(objc_arc)
[button setTitle:title]; [button setTitle:title];
[button setBezelStyle:NSSmallSquareBezelStyle]; [button setBezelStyle:NSBezelStyleSmallSquare];
[button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
[parent addSubview:button]; [parent addSubview:button];
rect->origin.x += BUTTON_WIDTH; rect->origin.x += BUTTON_WIDTH;

View File

@@ -43,7 +43,7 @@ void ExtractUnderlines(NSAttributedString* string,
if (NSColor* colorAttr = if (NSColor* colorAttr =
[attrs objectForKey:NSUnderlineColorAttributeName]) { [attrs objectForKey:NSUnderlineColorAttributeName]) {
color = CefColorFromNSColor( color = CefColorFromNSColor(
[colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); [colorAttr colorUsingColorSpace:NSColorSpace.deviceRGBColorSpace]);
} }
cef_composition_underline_t line = { cef_composition_underline_t line = {
{static_cast<uint32_t>(range.location), {static_cast<uint32_t>(range.location),