Diff
Modified: trunk/Source/WebKit/ChangeLog (249955 => 249956)
--- trunk/Source/WebKit/ChangeLog 2019-09-17 15:57:15 UTC (rev 249955)
+++ trunk/Source/WebKit/ChangeLog 2019-09-17 16:03:09 UTC (rev 249956)
@@ -1,3 +1,16 @@
+2019-09-17 Truitt Savell <[email protected]>
+
+ Unreviewed, rolling out r249950.
+
+ Broke the iOS build.
+
+ Reverted changeset:
+
+ "Remove the "Show Link Previews" and "Hide Link Previews"
+ action menus in the preview platter"
+ https://bugs.webkit.org/show_bug.cgi?id=201864
+ https://trac.webkit.org/changeset/249950
+
2019-09-17 Carlos Garcia Campos <[email protected]>
[GTK] Initial view loading is slow
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm (249955 => 249956)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm 2019-09-17 15:57:15 UTC (rev 249955)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm 2019-09-17 16:03:09 UTC (rev 249956)
@@ -164,9 +164,17 @@
[assistant.delegate actionSheetAssistant:assistant shareElementWithURL:actionInfo.URL ?: actionInfo.imageURL rect:actionInfo.boundingRect];
};
break;
- case _WKElementActionToggleShowLinkPreviews:
- // This action must still exist for compatibility, but doesn't do anything.
+ case _WKElementActionToggleShowLinkPreviews: {
+ bool showingLinkPreviews = true;
+ if (NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:webkitShowLinkPreviewsPreferenceKey])
+ showingLinkPreviews = value.boolValue;
+
+ title = showingLinkPreviews ? WEB_UI_STRING("Hide Link Previews", "Title for Hide Link Previews action button") : WEB_UI_STRING("Show Link Previews", "Title for Show Link Previews action button");
+ handler = ^(WKActionSheetAssistant *, _WKActivatedElementInfo *) {
+ [[NSUserDefaults standardUserDefaults] setBool:!showingLinkPreviews forKey:webkitShowLinkPreviewsPreferenceKey];
+ };
break;
+ }
default:
[NSException raise:NSInvalidArgumentException format:@"There is no standard web element action of type %ld.", (long)type];
return nil;
Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm (249955 => 249956)
--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm 2019-09-17 15:57:15 UTC (rev 249955)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm 2019-09-17 16:03:09 UTC (rev 249956)
@@ -558,6 +558,8 @@
[defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare assistant:self]];
}
+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionToggleShowLinkPreviews assistant:self]];
+
return defaultActions;
}
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (249955 => 249956)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-09-17 15:57:15 UTC (rev 249955)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-09-17 16:03:09 UTC (rev 249956)
@@ -7875,6 +7875,32 @@
return [UIMenu menuWithTitle:title children:actions];
}
+static UIMenu *menuWithShowLinkPreviewAction(UIMenu *originalMenu)
+{
+ if (!originalMenu)
+ return nil;
+
+ // Look for a UIAction that has the WKElementActionTypeToggleShowLinkPreviewsIdentifier.
+ NSUInteger result = [originalMenu.children indexOfObjectPassingTest:^BOOL(UIMenuElement *element, NSUInteger index, BOOL *stop) {
+ if (![element isKindOfClass:[UIAction class]])
+ return NO;
+ if ([(UIAction *)element identifier] == WKElementActionTypeToggleShowLinkPreviewsIdentifier) {
+ *stop = YES;
+ return YES;
+ }
+ return NO;
+ }];
+ if (result != NSNotFound)
+ return originalMenu;
+
+ // We didn't find one, so make a new UIMenu with the toggle action.
+ NSMutableArray<UIMenuElement *> *menuElements = [NSMutableArray arrayWithCapacity:(originalMenu.children.count + 1)];
+ [menuElements addObjectsFromArray:originalMenu.children];
+ _WKElementAction *toggleAction = [_WKElementAction elementActionWithType:_WKElementActionToggleShowLinkPreviews];
+ [menuElements addObject:[toggleAction uiActionForElementInfo:nil]];
+ return [originalMenu menuByReplacingChildren:menuElements];
+}
+
- (void)assignLegacyDataForContextMenuInteraction
{
ASSERT(!_contextMenuHasRequestedLegacyData);
@@ -7927,7 +7953,7 @@
_contextMenuLegacyPreviewController = dataDetectorsResult.get().previewProvider();
if (dataDetectorsResult && dataDetectorsResult.get().actionProvider) {
auto menuElements = menuElementsFromDefaultActions(defaultActionsFromAssistant, elementInfo);
- _contextMenuLegacyMenu = dataDetectorsResult.get().actionProvider(menuElements);
+ _contextMenuLegacyMenu = menuWithShowLinkPreviewAction(dataDetectorsResult.get().actionProvider(menuElements));
}
END_BLOCK_OBJC_EXCEPTIONS;
}
Modified: trunk/Tools/ChangeLog (249955 => 249956)
--- trunk/Tools/ChangeLog 2019-09-17 15:57:15 UTC (rev 249955)
+++ trunk/Tools/ChangeLog 2019-09-17 16:03:09 UTC (rev 249956)
@@ -1,3 +1,16 @@
+2019-09-17 Truitt Savell <[email protected]>
+
+ Unreviewed, rolling out r249950.
+
+ Broke the iOS build.
+
+ Reverted changeset:
+
+ "Remove the "Show Link Previews" and "Hide Link Previews"
+ action menus in the preview platter"
+ https://bugs.webkit.org/show_bug.cgi?id=201864
+ https://trac.webkit.org/changeset/249950
+
2019-09-17 Dean Jackson <[email protected]>
Remove the "Show Link Previews" and "Hide Link Previews" action menus in the preview platter
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm (249955 => 249956)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm 2019-09-17 15:57:15 UTC (rev 249955)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm 2019-09-17 16:03:09 UTC (rev 249956)
@@ -73,7 +73,7 @@
contextMenuRequested = true;
UIContextMenuContentPreviewProvider previewProvider = ^UIViewController * ()
{
- return [[[UIViewController alloc] init] autorelease];
+ return [UIViewController new];
};
UIContextMenuActionProvider actionProvider = ^UIMenu *(NSArray<UIMenuElement *> *suggestedActions)
{
@@ -248,56 +248,5 @@
#pragma clang diagnostic pop
-@interface TestContextMenuSuggestedActionsUIDelegate : NSObject <WKUIDelegate>
-@end
-@implementation TestContextMenuSuggestedActionsUIDelegate
-
-- (void)webView:(WKWebView *)webView contextMenuConfigurationForElement:(WKContextMenuElementInfo *)elementInfo completionHandler:(void(^)(UIContextMenuConfiguration * _Nullable))completionHandler
-{
- EXPECT_TRUE([elementInfo.linkURL.absoluteString isEqualToString:[linkURL absoluteString]]);
- contextMenuRequested = true;
- UIContextMenuContentPreviewProvider previewProvider = ^UIViewController * ()
- {
- return [[[UIViewController alloc] init] autorelease];
- };
- UIContextMenuActionProvider actionProvider = ^UIMenu *(NSArray<UIMenuElement *> *suggestedActions)
- {
- NSArray<NSString *> *expectedIdentifiers = @[
- @"WKElementActionTypeOpen",
- @"WKElementActionTypeAddToReadingList",
- @"WKElementActionTypeCopy",
- @"WKElementActionTypeShare"
- ];
- EXPECT_TRUE(expectedIdentifiers.count == suggestedActions.count);
-
- [suggestedActions enumerateObjectsUsingBlock:^(UIMenuElement *menuElement, NSUInteger index, BOOL *) {
- EXPECT_TRUE([menuElement isKindOfClass:[UIAction class]]);
- EXPECT_TRUE([[(UIAction *)menuElement identifier] isEqualToString:expectedIdentifiers[index]]);
- }];
- return [UIMenu menuWithTitle:@"" children:suggestedActions];
- };
- completionHandler([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:previewProvider actionProvider:actionProvider]);
-}
-
-- (void)webView:(WKWebView *)webView contextMenuWillPresentForElement:(WKContextMenuElementInfo *)elementInfo
-{
- willPresentCalled = true;
-}
-
-@end
-
-TEST(WebKit, ContextMenuSuggestedActions)
-{
- auto driver = contextMenuWebViewDriver([TestContextMenuSuggestedActionsUIDelegate class]);
- [driver begin:^(BOOL result) {
- EXPECT_TRUE(result);
- [driver clickDown];
- [driver clickUp];
- }];
- TestWebKitAPI::Util::run(&willPresentCalled);
- EXPECT_TRUE(contextMenuRequested);
- EXPECT_TRUE(willPresentCalled);
-}
-
#endif // PLATFORM(IOS) && USE(UICONTEXTMENU)