diff --git a/src/WKWebKit/Defs.cs b/src/WKWebKit/Defs.cs index b930a7db0e..67e9c4c83a 100644 --- a/src/WKWebKit/Defs.cs +++ b/src/WKWebKit/Defs.cs @@ -62,4 +62,38 @@ namespace XamCore.WebKit public enum WKSelectionGranularity : nint { Dynamic, Character } + + [iOS (10,0)][NoMac] + [Native] + [Flags] + public enum WKDataDetectorTypes : nuint { + None = 0, + PhoneNumber = 1 << 0, + Link = 1 << 1, + Address = 1 << 2, + CalendarEvent = 1 << 3, + TrackingNumber = 1 << 4, + FlightNumber = 1 << 5, + LookupSuggestion = 1 << 6, + SpotlightSuggestion = LookupSuggestion, +#if XAMCORE_2_0 + All = UInt64.MaxValue +#else + All = UInt32.MaxValue +#endif + } + + [iOS (10,0)][Mac (10,12, only64: true)] + [Native] + [Flags] + public enum WKAudiovisualMediaTypes : nuint { + None = 0, + Audio = 1 << 0, + Video = 1 << 1, +#if XAMCORE_2_0 + All = UInt64.MaxValue +#else + All = UInt32.MaxValue +#endif + } } diff --git a/src/wkwebkit.cs b/src/wkwebkit.cs index ba5b12dae6..e6f24736ce 100644 --- a/src/wkwebkit.cs +++ b/src/wkwebkit.cs @@ -159,11 +159,7 @@ namespace XamCore.WebKit [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] - #if !MONOMAC interface WKPreferences : NSCoding { - #else - interface WKPreferences { - #endif [Export ("minimumFontSize")] nfloat MinimumFontSize { get; set; } @@ -267,11 +263,7 @@ namespace XamCore.WebKit [iOS (9,0), Mac(10,11, onlyOn64 : true)] [BaseType (typeof(NSObject))] - #if !MONOMAC interface WKWebsiteDataStore : NSCoding { - #else - interface WKWebsiteDataStore { - #endif [Static] [Export ("defaultDataStore")] @@ -320,15 +312,26 @@ namespace XamCore.WebKit [iOS (9,0)][Mac (10,11, onlyOn64 : true)] [Export ("webViewDidClose:")] void DidClose (WKWebView webView); + + [iOS (10,0)][NoMac] + [Export ("webView:shouldPreviewElement:")] + bool ShouldPreviewElement (WKWebView webView, WKPreviewElementInfo elementInfo); + +#if !MONOMAC + [iOS (10,0)][NoMac] + [Export ("webView:previewingViewControllerForElement:defaultActions:")] + [return: NullAllowed] + UIViewController GetPreviewingViewController (WKWebView webView, WKPreviewElementInfo elementInfo, IWKPreviewActionItem[] previewActions); + + [iOS (10,0)][NoMac] + [Export ("webView:commitPreviewingViewController:")] + void CommitPreviewingViewController (WKWebView webView, UIViewController previewingViewController); +#endif } [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] - #if !MONOMAC interface WKUserContentController : NSCoding { - #else - interface WKUserContentController { - #endif [Export ("userScripts")] WKUserScript [] UserScripts { get; } @@ -508,11 +511,7 @@ namespace XamCore.WebKit [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] - #if !MONOMAC interface WKWebViewConfiguration : NSCopying, NSCoding { - #else - interface WKWebViewConfiguration : NSCopying { - #endif [Export ("processPool", ArgumentSemantic.Retain)] WKProcessPool ProcessPool { get; set; } @@ -542,7 +541,7 @@ namespace XamCore.WebKit [Export ("allowsInlineMediaPlayback")] bool AllowsInlineMediaPlayback { get; set; } - [Availability (Introduced = Platform.iOS_8_0, Deprecated = Platform.iOS_9_0, Message = "Use RequiresUserActionForMediaPlayback")] + [Availability (Introduced = Platform.iOS_8_0, Deprecated = Platform.iOS_9_0, Message = "Use RequiresUserActionForMediaPlayback or MediaTypesRequiringUserActionForPlayback")] [Export ("mediaPlaybackRequiresUserAction")] bool MediaPlaybackRequiresUserAction { get; set; } @@ -553,23 +552,26 @@ namespace XamCore.WebKit [Export ("selectionGranularity")] WKSelectionGranularity SelectionGranularity { get; set; } - [iOS (9,0)] + [Availability (Introduced = Platform.iOS_9_0, Deprecated = Platform.iOS_10_0, Message = "Use MediaTypesRequiringUserActionForPlayback")] [Export ("requiresUserActionForMediaPlayback")] bool RequiresUserActionForMediaPlayback { get; set; } [iOS (9,0)] [Export ("allowsPictureInPictureMediaPlayback")] bool AllowsPictureInPictureMediaPlayback { get; set; } + + [iOS (10, 0)] + [Export ("dataDetectorTypes", ArgumentSemantic.Assign)] + WKDataDetectorTypes DataDetectorTypes { get; set; } #endif + [iOS (10,0)][Mac (10,12, only64: true)] + [Export ("mediaTypesRequiringUserActionForPlayback", ArgumentSemantic.Assign)] + WKAudiovisualMediaTypes MediaTypesRequiringUserActionForPlayback { get; set; } } [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] - #if !MONOMAC interface WKProcessPool : NSCoding { - #else - interface WKProcessPool { - #endif // as of Mac 10.10, iOS 8.0 Beta 2, // this interface is completely empty } @@ -604,5 +606,44 @@ namespace XamCore.WebKit NSNumber height { get; } } - + [iOS (10,0)][Mac (10,12, onlyOn64 : true)] + [BaseType (typeof (NSObject))] + interface WKElementInfo : NSCopying { + [Export ("linkURL")] + NSUrl LinkUrl { get; } + } + +#if !MONOMAC + interface IWKPreviewActionItem {} + + [iOS (10,0)][NoMac] + [Protocol] + interface WKPreviewActionItem : UIPreviewActionItem { + [Abstract] + [Export ("identifier", ArgumentSemantic.Copy)] + NSString Identifier { get; } + } +#endif + + [iOS (10,0)][NoMac] + [Static] + interface WKPreviewActionItemIdentifier { + [Field ("WKPreviewActionItemIdentifierOpen")] + NSString Open { get; } + + [Field ("WKPreviewActionItemIdentifierAddToReadingList")] + NSString AddToReadingList { get; } + + [Field ("WKPreviewActionItemIdentifierCopy")] + NSString Copy { get; } + + [Field ("WKPreviewActionItemIdentifierShare")] + NSString Share { get; } + } + + // @interface WKPreviewElementInfo : WKElementInfo + [iOS (10,0)][NoMac] + [BaseType (typeof (WKElementInfo))] + interface WKPreviewElementInfo { + } } diff --git a/tests/introspection/ApiSelectorTest.cs b/tests/introspection/ApiSelectorTest.cs index 5e85eb0cd9..d2a825d368 100644 --- a/tests/introspection/ApiSelectorTest.cs +++ b/tests/introspection/ApiSelectorTest.cs @@ -96,6 +96,12 @@ namespace Introspection { // AVAudioChannelLayout and AVAudioFormat started conforming to NSSecureCoding in OSX 10.11 and iOS 9 case "AVAudioChannelLayout": case "AVAudioFormat": + // NSSecureCoding added in iOS 10 / macOS 10.12 + case "WKPreferences": + case "WKUserContentController": + case "WKProcessPool": + case "WKWebViewConfiguration": + case "WKWebsiteDataStore": switch (selectorName) { case "encodeWithCoder:": return true;