Title: [272228] trunk
Revision
272228
Author
[email protected]
Date
2021-02-02 12:57:05 -0800 (Tue, 02 Feb 2021)

Log Message

Adopt UIEventAttribution instead of _UIEventAttribution
https://bugs.webkit.org/show_bug.cgi?id=220683

Reviewed by John Wilander.

Source/WebKit:

UIKit introduced UIEventAttribution, so let's adopt it so they can remove their SPI.
See rdar://73629041

* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _setUIEventAttribution:]):
(-[WKWebView _uiEventAttribution]):

Source/WTF:

* wtf/PlatformHave.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
(-[MockEventAttribution initWithReportEndpoint:destinationURL:]):
(TestWebKitAPI::TEST):
(-[MockEventAttribution initWithReportEndpoint:attributeOn:]): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (272227 => 272228)


--- trunk/Source/WTF/ChangeLog	2021-02-02 20:18:01 UTC (rev 272227)
+++ trunk/Source/WTF/ChangeLog	2021-02-02 20:57:05 UTC (rev 272228)
@@ -1,3 +1,12 @@
+2021-02-02  Alex Christensen  <[email protected]>
+
+        Adopt UIEventAttribution instead of _UIEventAttribution
+        https://bugs.webkit.org/show_bug.cgi?id=220683
+
+        Reviewed by John Wilander.
+
+        * wtf/PlatformHave.h:
+
 2021-02-02  Carlos Garcia Campos  <[email protected]>
 
         [GTK][WPE] Migrate WebKitTestServer to libsoup 2.48 API

Modified: trunk/Source/WTF/wtf/PlatformHave.h (272227 => 272228)


--- trunk/Source/WTF/wtf/PlatformHave.h	2021-02-02 20:18:01 UTC (rev 272227)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2021-02-02 20:57:05 UTC (rev 272228)
@@ -742,6 +742,10 @@
 #define HAVE_RUNNINGBOARD_WEBKIT_PRIORITY_SUPPORT 1
 #endif
 
+#if ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000)
+#define HAVE_UI_EVENT_ATTRIBUTION 1
+#endif
+
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) \
     || ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000) \
     || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 80000) \

Modified: trunk/Source/WebKit/ChangeLog (272227 => 272228)


--- trunk/Source/WebKit/ChangeLog	2021-02-02 20:18:01 UTC (rev 272227)
+++ trunk/Source/WebKit/ChangeLog	2021-02-02 20:57:05 UTC (rev 272228)
@@ -1,3 +1,18 @@
+2021-02-02  Alex Christensen  <[email protected]>
+
+        Adopt UIEventAttribution instead of _UIEventAttribution
+        https://bugs.webkit.org/show_bug.cgi?id=220683
+
+        Reviewed by John Wilander.
+
+        UIKit introduced UIEventAttribution, so let's adopt it so they can remove their SPI.
+        See rdar://73629041
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/ios/WKWebViewIOS.mm:
+        (-[WKWebView _setUIEventAttribution:]):
+        (-[WKWebView _uiEventAttribution]):
+
 2021-02-02  Rini Patel  <[email protected]>
 
         Remove unused functions from GraphicsContextGL and ExtensionsGL

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (272227 => 272228)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-02-02 20:18:01 UTC (rev 272227)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-02-02 20:57:05 UTC (rev 272228)
@@ -108,6 +108,7 @@
 
 #endif
 
+@class UIEventAttribution;
 @class WKBrowsingContextHandle;
 @class WKDownload;
 @class WKFrameInfo;
@@ -394,6 +395,7 @@
 @interface WKWebView (WKPrivateIOS)
 
 @property (nonatomic, copy, setter=_setEventAttribution:) _UIEventAttribution *_eventAttribution WK_API_AVAILABLE(ios(WK_IOS_TBA));
+@property (nonatomic, copy, setter=_setUIEventAttribution:) UIEventAttribution *_uiEventAttribution WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
 @property (nonatomic, readonly) CGRect _contentVisibleRect WK_API_AVAILABLE(ios(10.0));
 

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (272227 => 272228)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2021-02-02 20:18:01 UTC (rev 272227)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2021-02-02 20:57:05 UTC (rev 272228)
@@ -65,6 +65,10 @@
 #import "WKDataDetectorTypesInternal.h"
 #endif
 
+#if HAVE(UI_EVENT_ATTRIBUTION)
+#import <UIKit/UIEventAttribution.h>
+#endif
+
 #include "UIKitSoftLink.h"
 
 #define FORWARD_ACTION_TO_WKCONTENTVIEW(_action) \
@@ -2522,6 +2526,37 @@
 
 @implementation WKWebView (WKPrivateIOS)
 
+- (void)_setUIEventAttribution:(UIEventAttribution *)attribution
+{
+#if HAVE(UI_EVENT_ATTRIBUTION)
+    if (attribution) {
+        WebCore::PrivateClickMeasurement measurement(
+            WebCore::PrivateClickMeasurement::SourceID(attribution.sourceIdentifier),
+            WebCore::PrivateClickMeasurement::SourceSite(attribution.reportEndpoint),
+            WebCore::PrivateClickMeasurement::AttributeOnSite(attribution.destinationURL),
+            attribution.sourceDescription,
+            attribution.purchaser
+        );
+        _page->setPrivateClickMeasurement(WTFMove(measurement));
+    } else
+        _page->setPrivateClickMeasurement(WTF::nullopt);
+#endif
+}
+
+- (UIEventAttribution *)_uiEventAttribution
+{
+#if HAVE(UI_EVENT_ATTRIBUTION)
+    auto& measurement = _page->privateClickMeasurement();
+    if (!measurement || !measurement->sourceID().isValid())
+        return nil;
+
+    auto attributeOnURL = URL(URL(), makeString("https://", measurement->attributeOnSite().registrableDomain.string()));
+    return [[[UIEventAttribution alloc] initWithSourceIdentifier:measurement->sourceID().id destinationURL:attributeOnURL sourceDescription:measurement->sourceDescription() purchaser:measurement->purchaser()] autorelease];
+#else
+    return nil;
+#endif
+}
+
 - (void)_setEventAttribution:(_UIEventAttribution *)attribution
 {
     if (attribution) {

Modified: trunk/Tools/ChangeLog (272227 => 272228)


--- trunk/Tools/ChangeLog	2021-02-02 20:18:01 UTC (rev 272227)
+++ trunk/Tools/ChangeLog	2021-02-02 20:57:05 UTC (rev 272228)
@@ -1,3 +1,15 @@
+2021-02-02  Alex Christensen  <[email protected]>
+
+        Adopt UIEventAttribution instead of _UIEventAttribution
+        https://bugs.webkit.org/show_bug.cgi?id=220683
+
+        Reviewed by John Wilander.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
+        (-[MockEventAttribution initWithReportEndpoint:destinationURL:]):
+        (TestWebKitAPI::TEST):
+        (-[MockEventAttribution initWithReportEndpoint:attributeOn:]): Deleted.
+
 2021-02-02  Aakash Jain  <[email protected]>
 
         [build.webkit.org] unzip layout-test-results in background

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm (272227 => 272228)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm	2021-02-02 20:18:01 UTC (rev 272227)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm	2021-02-02 20:57:05 UTC (rev 272228)
@@ -25,7 +25,7 @@
 
 #import "config.h"
 
-#if PLATFORM(IOS_FAMILY)
+#if HAVE(UI_EVENT_ATTRIBUTION)
 
 #import "HTTPServer.h"
 #import "PlatformUtilities.h"
@@ -38,23 +38,23 @@
 @interface MockEventAttribution : NSObject
 
 @property (nonatomic, assign, readonly) uint8_t sourceIdentifier;
-@property (nonatomic, copy, readonly) NSURL *attributeOn;
+@property (nonatomic, copy, readonly) NSURL *destinationURL;
 @property (nonatomic, copy, readonly) NSURL *reportEndpoint;
 @property (nonatomic, copy, readonly) NSString *sourceDescription;
 @property (nonatomic, copy, readonly) NSString *purchaser;
-- (instancetype)initWithReportEndpoint:(NSURL *)reportEndpoint attributeOn:(NSURL *)attributeOn;
+- (instancetype)initWithReportEndpoint:(NSURL *)reportEndpoint destinationURL:(NSURL *)destinationURL;
 
 @end
 
 @implementation MockEventAttribution
 
-- (instancetype)initWithReportEndpoint:(NSURL *)reportEndpoint attributeOn:(NSURL *)attributeOn
+- (instancetype)initWithReportEndpoint:(NSURL *)reportEndpoint destinationURL:(NSURL *)destinationURL
 {
     if (!(self = [super init]))
         return nil;
 
     _sourceIdentifier = 42;
-    _attributeOn = attributeOn;
+    _destinationURL = destinationURL;
     _reportEndpoint = reportEndpoint;
     _sourceDescription = @"test source description";
     _purchaser = @"test purchaser";
@@ -101,9 +101,9 @@
     NSURL *serverURL = server.request().URL;
 
     auto exampleURL = [NSURL URLWithString:@"https://example.com/"];
-    auto attribution = [[[MockEventAttribution alloc] initWithReportEndpoint:server.request().URL attributeOn:exampleURL] autorelease];
+    auto attribution = [[[MockEventAttribution alloc] initWithReportEndpoint:server.request().URL destinationURL:exampleURL] autorelease];
     auto webView = [[WKWebView new] autorelease];
-    webView._eventAttribution = (_UIEventAttribution *)attribution;
+    webView._uiEventAttribution = (UIEventAttribution *)attribution;
     [webView.configuration.websiteDataStore _setResourceLoadStatisticsEnabled:YES];
     [webView.configuration.websiteDataStore _allowTLSCertificateChain:@[(id)testCertificate().get()] forHost:serverURL.host];
     [webView _setPrivateClickMeasurementConversionURLForTesting:serverURL completionHandler:^{
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to