Title: [264383] trunk
- Revision
- 264383
- Author
- wenson_hs...@apple.com
- Date
- 2020-07-14 17:20:21 -0700 (Tue, 14 Jul 2020)
Log Message
REGRESSION (r264101): Sharing a link attaches an image instead of the URL
https://bugs.webkit.org/show_bug.cgi?id=214329
<rdar://problem/65513607>
Reviewed by Tim Horton and Devin Rousso.
Source/WebKit:
r264101 added logic that attempts to share an activated (i.e. long-pressed) element as an image, if the image
URL scheme for the element is equal to "data" (ignoring case sensitivity). However, in the case where the image
URL is nil, the call to `[element.imageURL.scheme caseInsensitiveCompare:@"data"]` is 0, which (conveniently) is
equal to `NSOrderedSame`. This causes us to incorrectly proceed by sharing the element as an image.
Fix this by going through URL::protocolIsData(), so we don't end up with 0 (`NSOrderedSame`) when
`element.imageURL.scheme` is `nil`.
Test: ShareSheetTests.ShareAnchorElementAsURL
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant handleElementActionWithType:element:needsInteraction:]):
Tools:
Add a new API test to verify that the "share action" for a link shares the URL, rather than a snapshot of the
anchor element.
* TestWebKitAPI/Tests/ios/ShareSheetTests.mm:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (264382 => 264383)
--- trunk/Source/WebKit/ChangeLog 2020-07-14 23:36:58 UTC (rev 264382)
+++ trunk/Source/WebKit/ChangeLog 2020-07-15 00:20:21 UTC (rev 264383)
@@ -1,5 +1,26 @@
2020-07-14 Wenson Hsieh <wenson_hs...@apple.com>
+ REGRESSION (r264101): Sharing a link attaches an image instead of the URL
+ https://bugs.webkit.org/show_bug.cgi?id=214329
+ <rdar://problem/65513607>
+
+ Reviewed by Tim Horton and Devin Rousso.
+
+ r264101 added logic that attempts to share an activated (i.e. long-pressed) element as an image, if the image
+ URL scheme for the element is equal to "data" (ignoring case sensitivity). However, in the case where the image
+ URL is nil, the call to `[element.imageURL.scheme caseInsensitiveCompare:@"data"]` is 0, which (conveniently) is
+ equal to `NSOrderedSame`. This causes us to incorrectly proceed by sharing the element as an image.
+
+ Fix this by going through URL::protocolIsData(), so we don't end up with 0 (`NSOrderedSame`) when
+ `element.imageURL.scheme` is `nil`.
+
+ Test: ShareSheetTests.ShareAnchorElementAsURL
+
+ * UIProcess/ios/WKActionSheetAssistant.mm:
+ (-[WKActionSheetAssistant handleElementActionWithType:element:needsInteraction:]):
+
+2020-07-14 Wenson Hsieh <wenson_hs...@apple.com>
+
[iOS] The completion handler in -handleKeyWebEvent:withCompletionHandler: is sometimes never called
https://bugs.webkit.org/show_bug.cgi?id=214295
<rdar://problem/60539389>
Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm (264382 => 264383)
--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm 2020-07-14 23:36:58 UTC (rev 264382)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm 2020-07-15 00:20:21 UTC (rev 264383)
@@ -828,7 +828,7 @@
[delegate actionSheetAssistant:self performAction:WebKit::SheetAction::SaveImage];
break;
case _WKElementActionTypeShare:
- if ([element.imageURL.scheme caseInsensitiveCompare:@"data"] == NSOrderedSame && element.image && [delegate respondsToSelector:@selector(actionSheetAssistant:shareElementWithImage:rect:)])
+ if (URL(element.imageURL).protocolIsData() && element.image && [delegate respondsToSelector:@selector(actionSheetAssistant:shareElementWithImage:rect:)])
[delegate actionSheetAssistant:self shareElementWithImage:element.image rect:element.boundingRect];
else
[delegate actionSheetAssistant:self shareElementWithURL:element.URL ?: element.imageURL rect:element.boundingRect];
Modified: trunk/Tools/ChangeLog (264382 => 264383)
--- trunk/Tools/ChangeLog 2020-07-14 23:36:58 UTC (rev 264382)
+++ trunk/Tools/ChangeLog 2020-07-15 00:20:21 UTC (rev 264383)
@@ -1,3 +1,16 @@
+2020-07-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ REGRESSION (r264101): Sharing a link attaches an image instead of the URL
+ https://bugs.webkit.org/show_bug.cgi?id=214329
+ <rdar://problem/65513607>
+
+ Reviewed by Tim Horton and Devin Rousso.
+
+ Add a new API test to verify that the "share action" for a link shares the URL, rather than a snapshot of the
+ anchor element.
+
+ * TestWebKitAPI/Tests/ios/ShareSheetTests.mm:
+
2020-07-14 Alex Christensen <achristen...@webkit.org>
REGRESSION(r262341) URL::createCFURL should produce a CFURL that uses UTF-8 to decode its percent-encoded sequences
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/ShareSheetTests.mm (264382 => 264383)
--- trunk/Tools/TestWebKitAPI/Tests/ios/ShareSheetTests.mm 2020-07-14 23:36:58 UTC (rev 264382)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/ShareSheetTests.mm 2020-07-15 00:20:21 UTC (rev 264383)
@@ -101,6 +101,24 @@
TestWebKitAPI::Util::run(&done);
}
+TEST(ShareSheetTests, ShareAnchorElementAsURL)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ auto observer = adoptNS([[ShareSheetObserver alloc] init]);
+ [webView setUIDelegate:observer.get()];
+ [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
+
+ __block bool done = false;
+ [observer setActivityItemsHandler:^(NSArray *activityItems) {
+ EXPECT_EQ(1UL, activityItems.count);
+ EXPECT_WK_STREQ("https://www.apple.com/", [[activityItems objectAtIndex:0] absoluteString]);
+ done = true;
+ }];
+
+ showShareSheet(webView.get(), observer.get(), CGPointMake(100, 100));
+ TestWebKitAPI::Util::run(&done);
+}
+
#endif // !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes