Title: [176225] branches/safari-600.3-branch/Source/WebKit/mac
- Revision
- 176225
- Author
- dburk...@apple.com
- Date
- 2014-11-17 13:32:22 -0800 (Mon, 17 Nov 2014)
Log Message
Merge r176099. <rdar://problem/18877520>
Modified Paths
Diff
Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (176224 => 176225)
--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog 2014-11-17 21:26:44 UTC (rev 176224)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog 2014-11-17 21:32:22 UTC (rev 176225)
@@ -1,5 +1,30 @@
2014-11-17 Dana Burkart <dburk...@apple.com>
+ Merge r176099. <rdar://problem/18877520>
+
+ 2014-11-13 Beth Dakin <bda...@apple.com>
+
+ WK1: Support default actions for video
+ https://bugs.webkit.org/show_bug.cgi?id=138713
+ -and corresponding-
+ rdar://problem/18877520
+
+ Reviewed by Tim Horton.
+
+ Call setToNonShadowAncestor() for media HitTestResults.
+ * WebView/WebActionMenuController.mm:
+ (-[WebActionMenuController performHitTestAtPoint:]):
+
+ Default items and actions.
+ (-[WebActionMenuController _defaultMenuItemsForVideo:]):
+ (-[WebActionMenuController _copyVideoURL:]):
+ (-[WebActionMenuController _saveVideoToDownloads:]):
+ (-[WebActionMenuController _createActionMenuItemForTag:withHitTestResult:]):
+ (-[WebActionMenuController _defaultMenuItemsForHitTestResult:]):
+ * WebView/WebUIDelegatePrivate.h:
+
+2014-11-17 Dana Burkart <dburk...@apple.com>
+
Merge r176093. <rdar://problem/18975774>
2014-11-13 Tim Horton <timothy_hor...@apple.com>
Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (176224 => 176225)
--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-11-17 21:26:44 UTC (rev 176224)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-11-17 21:32:22 UTC (rev 176225)
@@ -114,6 +114,15 @@
HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
_hitTestResult = coreFrame->eventHandler().hitTestResultAtPoint(IntPoint(point), hitType);
+ // We hit test including shadow content to get the desired result for editable text regions.
+ // But for media, we want to re-set to the shadow root.
+ if (Node* node = _hitTestResult.innerNode()) {
+ if (Element* shadowHost = node->shadowHost()) {
+ if (shadowHost->isMediaElement())
+ _hitTestResult.setToNonShadowAncestor();
+ }
+ }
+
return [[[WebElementDictionary alloc] initWithHitTestResult:_hitTestResult] autorelease];
}
@@ -414,6 +423,44 @@
[_webView _downloadURL:_hitTestResult.absoluteImageURL()];
}
+#pragma mark Video actions
+
+- (NSArray*)_defaultMenuItemsForVideo:(WebElementDictionary *)hitTestResult
+{
+ RetainPtr<NSMenuItem> copyVideoURLItem = [self _createActionMenuItemForTag:WebActionMenuItemTagCopyVideoURL withHitTestResult:hitTestResult];
+
+ RetainPtr<NSMenuItem> saveToDownloadsItem = [self _createActionMenuItemForTag:WebActionMenuItemTagSaveVideoToDownloads withHitTestResult:hitTestResult];
+ if (!_hitTestResult.isDownloadableMedia() || !_webView.downloadDelegate)
+ [saveToDownloadsItem setEnabled:NO];
+
+ RetainPtr<NSMenuItem> shareItem = [self _createActionMenuItemForTag:WebActionMenuItemTagShareVideo withHitTestResult:hitTestResult];
+ NSString *urlToShare = _hitTestResult.absoluteMediaURL();
+ if (!_hitTestResult.isDownloadableMedia()) {
+ [saveToDownloadsItem setEnabled:NO];
+ urlToShare = [_webView mainFrameURL];
+ }
+ _sharingServicePicker = adoptNS([[NSSharingServicePicker alloc] initWithItems:@[ urlToShare ]]);
+ [_sharingServicePicker setDelegate:self];
+ [shareItem setSubmenu:[_sharingServicePicker menu]];
+
+ return @[ copyVideoURLItem.get(), [NSMenuItem separatorItem], saveToDownloadsItem.get(), shareItem.get() ];
+}
+
+- (void)_copyVideoURL:(id)sender
+{
+ NSString *urlToCopy = _hitTestResult.absoluteMediaURL();
+ if (!_hitTestResult.isDownloadableMedia())
+ urlToCopy = [_webView mainFrameURL];
+
+ [[NSPasteboard generalPasteboard] clearContents];
+ [[NSPasteboard generalPasteboard] writeObjects:@[ urlToCopy ]];
+}
+
+- (void)_saveVideoToDownloads:(id)sender
+{
+ [_webView _downloadURL:_hitTestResult.absoluteMediaURL()];
+}
+
#pragma mark Text actions
- (NSArray *)_defaultMenuItemsForText:(WebElementDictionary *)hitTestResult
@@ -732,6 +779,23 @@
image = [NSImage imageNamed:@"NSActionMenuShare"];
break;
+ case WebActionMenuItemTagCopyVideoURL:
+ selector = @selector(_copyVideoURL:);
+ title = WEB_UI_STRING_KEY("Copy", "Copy (video action menu item)", "video action menu item");
+ image = [NSImage imageNamed:@"NSActionMenuCopy"];
+ break;
+
+ case WebActionMenuItemTagSaveVideoToDownloads:
+ selector = @selector(_saveVideoToDownloads:);
+ title = WEB_UI_STRING_KEY("Save to Downloads", "Save to Downloads (video action menu item)", "video action menu item");
+ image = [NSImage imageNamed:@"NSActionMenuSaveToDownloads"];
+ break;
+
+ case WebActionMenuItemTagShareVideo:
+ title = WEB_UI_STRING_KEY("Share", "Share (video action menu item)", "video action menu item");
+ image = [NSImage imageNamed:@"NSActionMenuShare"];
+ break;
+
default:
ASSERT_NOT_REACHED();
return nil;
Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h (176224 => 176225)
--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h 2014-11-17 21:26:44 UTC (rev 176224)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h 2014-11-17 21:32:22 UTC (rev 176225)
@@ -124,7 +124,10 @@
WebActionMenuItemTagCopyImage,
WebActionMenuItemTagAddImageToPhotos,
WebActionMenuItemTagSaveImageToDownloads,
- WebActionMenuItemTagShareImage
+ WebActionMenuItemTagShareImage,
+ WebActionMenuItemTagCopyVideoURL,
+ WebActionMenuItemTagSaveVideoToDownloads,
+ WebActionMenuItemTagShareVideo
};
typedef enum {
@@ -135,6 +138,7 @@
WebActionMenuWhitespaceInEditableArea,
WebActionMenuEditableTextWithSuggestions,
WebActionMenuImage,
+ WebActionMenuVideo,
WebActionMenuDataDetectedItem,
WebActionMenuMailtoLink
} WebActionMenuType;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes