From 630f89ebfe02b6c3f8264526cf49085b6ef25d1f Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Mon, 19 Jun 2017 23:04:50 -0400 Subject: [PATCH 1/2] [WebKit] Update to Xcode 9 beta 1 --- src/WKWebKit/Defs.cs | 8 +++ src/wkwebkit.cs | 166 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) diff --git a/src/WKWebKit/Defs.cs b/src/WKWebKit/Defs.cs index 716827ca0932..169b248dacc8 100644 --- a/src/WKWebKit/Defs.cs +++ b/src/WKWebKit/Defs.cs @@ -56,6 +56,14 @@ public enum WKErrorCode : nint { JavaScriptExceptionOccurred, [iOS (9,0)][Mac (10,11, onlyOn64 : true)] JavaScriptResultTypeIsUnsupported, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreCompileFailed, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreLookUpFailed, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreRemoveFailed, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreVersionMismatch } #if !MONOMAC || !XAMCORE_4_0 diff --git a/src/wkwebkit.cs b/src/wkwebkit.cs index 0bd498567bda..6b831bdfce87 100644 --- a/src/wkwebkit.cs +++ b/src/wkwebkit.cs @@ -61,6 +61,76 @@ interface WKBackForwardList { WKBackForwardListItem ItemAtIndex (nint index); } + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + interface WKContentRuleList + { + [Export ("identifier")] + string Identifier { get; } + } + + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + interface WKContentRuleListStore + { + [Static] + [Export ("defaultStore")] + WKContentRuleListStore DefaultStore (); + + [Static] + [Export ("storeWithURL:")] + WKContentRuleListStore FromUrl (NSUrl url); + + [Export ("compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:")] + [Async] + void CompileContentRuleList (string identifier, string encodedContentRuleList, Action completionHandler); + + [Export ("lookUpContentRuleListForIdentifier:completionHandler:")] + [Async] + void LookUpContentRuleList (string identifier, Action completionHandler); + + [Export ("removeContentRuleListForIdentifier:completionHandler:")] + [Async] + void RemoveContentRuleList (string identifier, Action completionHandler); + + [Export ("getAvailableContentRuleListIdentifiers:")] + [Async] + void GetAvailableContentRuleListIdentifiers (Action callback); + } + + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + [DisableDefaultCtor] + interface WKHttpCookieStore + { + [Export ("getAllCookies:")] + [Async] + void GetAllCookies (Action completionHandler); + + [Export ("setCookie:completionHandler:")] + [Async] + void SetCookie (NSHttpCookie cookie, [NullAllowed] Action completionHandler); + + [Export ("deleteCookie:completionHandler:")] + [Async] + void DeleteCookie (NSHttpCookie cookie, [NullAllowed] Action completionHandler); + + [Export ("addObserver:")] + void AddObserver (WKHttpCookieStoreObserver observer); + + [Export ("removeObserver:")] + void RemoveObserver (WKHttpCookieStoreObserver observer); + } + + [Mac (10,13), iOS (11,0)] + [Protocol] + [BaseType (typeof(NSObject))] + interface WKHttpCookieStoreObserver + { + [Export ("cookiesDidChangeInCookieStore:")] + void CookiesDidChangeInCookieStore (WKHttpCookieStore cookieStore); + } + [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] interface WKFrameInfo : NSCopying { @@ -227,6 +297,58 @@ interface WKSecurityOrigin { nint Port { get; } } + + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + interface WKSnapshotConfiguration { + [Export ("rect")] + CGRect Rect { get; set; } + + [Export ("snapshotWidth")] + NSNumber SnapshotWidth { get; set; } + } + +#if XAMCORE_2_0 + [Mac (10,13), iOS (11,0)] + [Protocol] + [BaseType (typeof(NSObject))] + interface WKUrlSchemeHandler + { + [Abstract] + [Export ("webView:startURLSchemeTask:")] + void StartUrlSchemeTask (WKWebView webView, WKUrlSchemeTask urlSchemeTask); + + [Abstract] + [Export ("webView:stopURLSchemeTask:")] + void StopUrlSchemeTask (WKWebView webView, WKUrlSchemeTask urlSchemeTask); + } +#endif + [Mac (10,13), iOS (11,0)] + [Protocol] + [BaseType (typeof(NSObject))] + interface WKUrlSchemeTask + { + [Abstract] + [Export ("request", ArgumentSemantic.Copy)] + NSUrlRequest Request { get; } + + [Abstract] + [Export ("didReceiveResponse:")] + void DidReceiveResponse (NSUrlResponse response); + + [Abstract] + [Export ("didReceiveData:")] + void DidReceiveData (NSData data); + + [Abstract] + [Export ("didFinish")] + void DidFinish (); + + [Abstract] + [Export ("didFailWithError:")] + void DidFailWithError (NSError error); + } + [iOS (9,0), Mac(10,11, onlyOn64 : true)] [BaseType (typeof(NSObject))] interface WKWebsiteDataRecord @@ -296,6 +418,10 @@ interface WKWebsiteDataStore : NSCoding { [Export ("removeDataOfTypes:modifiedSince:completionHandler:")] [Async] void RemoveDataOfTypes (NSSet websiteDataTypes, NSDate date, Action completionHandler); + + [Mac (10, 13), iOS (11, 0)] + [Export ("httpCookieStore")] + WKHttpCookieStore HttpCookieStore { get; } } [Mac (10,10, onlyOn64 : true), iOS (8,0)] @@ -355,6 +481,18 @@ interface WKUserContentController : NSCoding { [Export ("removeScriptMessageHandlerForName:")] void RemoveScriptMessageHandler (string name); + + [Mac (10,13), iOS (11,0)] + [Export ("addContentRuleList:")] + void AddContentRuleList (WKContentRuleList contentRuleList); + + [Mac (10,13), iOS (11,0)] + [Export ("removeContentRuleList:")] + void RemoveContentRuleList (WKContentRuleList contentRuleList); + + [Mac (10,13), iOS (11,0)] + [Export ("removeAllContentRuleLists")] + void RemoveAllContentRuleLists (); } [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit @@ -519,6 +657,23 @@ interface WKWebView { [iOS (10,0)][Mac (10,12, onlyOn64 : true)] [NullAllowed, Export ("serverTrust")] SecTrust ServerTrust { get; } + +#if !MONOMAC + [iOS (11,0)] + [Async] + [Export ("takeSnapshotWithConfiguration:completionHandler:")] + void TakeSnapshot ([NullAllowed] WKSnapshotConfiguration snapshotConfiguration, Action completionHandler); +#else + [Mac (10,13)] + [Export ("takeSnapshotWithConfiguration:completionHandler:")] + [Async] + void TakeSnapshot ([NullAllowed] WKSnapshotConfiguration snapshotConfiguration, Action completionHandler); +#endif + [Mac (10,13), iOS (11,0)] + [Static] + [Export ("handlesURLScheme:")] + bool HandlesUrlScheme (string urlScheme); + } delegate void WKJavascriptEvaluationResult (NSObject result, NSError error); @@ -586,6 +741,17 @@ interface WKWebViewConfiguration : NSCopying, NSCoding { [NoMac] [Export ("ignoresViewportScaleLimits")] bool IgnoresViewportScaleLimits { get; set; } + +#if XAMCORE_2_0 + [Mac (10,13), iOS (11,0)] + [Export ("setURLSchemeHandler:forURLScheme:")] + void SetUrlSchemeHandler ([NullAllowed] WKUrlSchemeHandler urlSchemeHandler, string urlScheme); + + [Mac (10,13), iOS (11,0)] + [Export ("urlSchemeHandlerForURLScheme:")] + [return: NullAllowed] + WKUrlSchemeHandler GetUrlSchemeHandler (string urlScheme); +#endif } [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit From fe85b426fe526b41ce71a4de09b21e438520d20d Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 20 Jun 2017 22:11:52 -0400 Subject: [PATCH 2/2] [WebKit] Update on protocols based on the feedback, and Action parameter in callback --- src/wkwebkit.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/wkwebkit.cs b/src/wkwebkit.cs index 6b831bdfce87..e70f89b38f49 100644 --- a/src/wkwebkit.cs +++ b/src/wkwebkit.cs @@ -75,7 +75,7 @@ interface WKContentRuleListStore { [Static] [Export ("defaultStore")] - WKContentRuleListStore DefaultStore (); + WKContentRuleListStore DefaultStore { get; } [Static] [Export ("storeWithURL:")] @@ -95,7 +95,7 @@ interface WKContentRuleListStore [Export ("getAvailableContentRuleListIdentifiers:")] [Async] - void GetAvailableContentRuleListIdentifiers (Action callback); + void GetAvailableContentRuleListIdentifiers (Action callback); } [Mac (10,13), iOS (11,0)] @@ -116,15 +116,16 @@ interface WKHttpCookieStore void DeleteCookie (NSHttpCookie cookie, [NullAllowed] Action completionHandler); [Export ("addObserver:")] - void AddObserver (WKHttpCookieStoreObserver observer); + void AddObserver (IWKHttpCookieStoreObserver observer); [Export ("removeObserver:")] - void RemoveObserver (WKHttpCookieStoreObserver observer); + void RemoveObserver (IWKHttpCookieStoreObserver observer); } + interface IWKHttpCookieStoreObserver {} + [Mac (10,13), iOS (11,0)] [Protocol] - [BaseType (typeof(NSObject))] interface WKHttpCookieStoreObserver { [Export ("cookiesDidChangeInCookieStore:")] @@ -309,23 +310,24 @@ interface WKSnapshotConfiguration { } #if XAMCORE_2_0 + interface IWKUrlSchemeHandler {} [Mac (10,13), iOS (11,0)] [Protocol] - [BaseType (typeof(NSObject))] interface WKUrlSchemeHandler { [Abstract] [Export ("webView:startURLSchemeTask:")] - void StartUrlSchemeTask (WKWebView webView, WKUrlSchemeTask urlSchemeTask); + void StartUrlSchemeTask (WKWebView webView, IWKUrlSchemeTask urlSchemeTask); [Abstract] [Export ("webView:stopURLSchemeTask:")] - void StopUrlSchemeTask (WKWebView webView, WKUrlSchemeTask urlSchemeTask); + void StopUrlSchemeTask (WKWebView webView, IWKUrlSchemeTask urlSchemeTask); } #endif + interface IWKUrlSchemeTask {} + [Mac (10,13), iOS (11,0)] [Protocol] - [BaseType (typeof(NSObject))] interface WKUrlSchemeTask { [Abstract] @@ -745,12 +747,12 @@ interface WKWebViewConfiguration : NSCopying, NSCoding { #if XAMCORE_2_0 [Mac (10,13), iOS (11,0)] [Export ("setURLSchemeHandler:forURLScheme:")] - void SetUrlSchemeHandler ([NullAllowed] WKUrlSchemeHandler urlSchemeHandler, string urlScheme); + void SetUrlSchemeHandler ([NullAllowed] IWKUrlSchemeHandler urlSchemeHandler, string urlScheme); [Mac (10,13), iOS (11,0)] [Export ("urlSchemeHandlerForURLScheme:")] [return: NullAllowed] - WKUrlSchemeHandler GetUrlSchemeHandler (string urlScheme); + IWKUrlSchemeHandler GetUrlSchemeHandler (string urlScheme); #endif }