<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[175864] branches/safari-600.3-branch/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/175864">175864</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2014-11-11 00:49:10 -0800 (Tue, 11 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/175779">r175779</a>. rdar://problems/18742164</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebCoreChangeLog">branches/safari-600.3-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebCoreWebCoreexpin">branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#branchessafari6003branchSourceWebCorerenderingHitTestResultcpp">branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp</a></li>
<li><a href="#branchessafari6003branchSourceWebCorerenderingHitTestResulth">branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2ChangeLog">branches/safari-600.3-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuItemTypesh">branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuTypesh">branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedWebHitTestResultcpp">branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedWebHitTestResulth">branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2WebProcessWebPagemacWebPageMacmm">branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6003branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-11-11 Matthew Hanson <matthew_hanson@apple.com>
+
+ Merge r175779. <rdar://problem/18742164>
+
+ 2014-11-08 Beth Dakin <bdakin@apple.com>
+
+ Implement action menu support for videos
+ https://bugs.webkit.org/show_bug.cgi?id=138534
+ -and corresponding-
+ rdar://problem/18742164
+
+ Reviewed by Tim Horton.
+
+ Export needed symbols and added not-yet-implemented
+ HitTestResult::isMediaThatCanBeDownloaded() so that action menus will work as
+ expected once it is implemented.
+ * WebCore.exp.in:
+ * rendering/HitTestResult.cpp:
+ (WebCore::HitTestResult::isMediaThatCanBeDownloaded):
+ * rendering/HitTestResult.h:
+
+
</ins><span class="cx"> 2014-11-06 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r175710. <rdar://problem/18898712>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -310,6 +310,7 @@
</span><span class="cx"> __ZN7WebCore13HTTPHeaderMap6removeENS_14HTTPHeaderNameE
</span><span class="cx"> __ZN7WebCore13HTTPHeaderMapC1Ev
</span><span class="cx"> __ZN7WebCore13HTTPHeaderMapD1Ev
</span><ins>+__ZN7WebCore13HitTestResult22setToNonShadowAncestorEv
</ins><span class="cx"> __ZN7WebCore13HitTestResultC1ERKNS_11LayoutPointE
</span><span class="cx"> __ZN7WebCore13HitTestResultC1ERKNS_11LayoutPointEjjjj
</span><span class="cx"> __ZN7WebCore13HitTestResultC1ERKNS_15HitTestLocationE
</span><span class="lines">@@ -1677,6 +1678,7 @@
</span><span class="cx"> __ZNK7WebCore13HitTestResult16altDisplayStringEv
</span><span class="cx"> __ZNK7WebCore13HitTestResult17isContentEditableEv
</span><span class="cx"> __ZNK7WebCore13HitTestResult18titleDisplayStringEv
</span><ins>+__ZNK7WebCore13HitTestResult19isDownloadableMediaEv
</ins><span class="cx"> __ZNK7WebCore13HitTestResult19mediaIsInFullscreenEv
</span><span class="cx"> __ZNK7WebCore13HitTestResult19rectBasedTestResultEv
</span><span class="cx"> __ZNK7WebCore13HitTestResult21innerNonSharedElementEv
</span><span class="lines">@@ -1905,6 +1907,7 @@
</span><span class="cx"> __ZNK7WebCore4Font5widthERKNS_7TextRunEPN3WTF7HashSetIPKNS_14SimpleFontDataENS4_7PtrHashIS8_EENS4_10HashTraitsIS8_EEEEPNS_13GlyphOverflowE
</span><span class="cx"> __ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEiiNS0_24CustomFontNotReadyActionE
</span><span class="cx"> __ZNK7WebCore4FonteqERKS0_
</span><ins>+__ZNK7WebCore4Node10shadowHostEv
</ins><span class="cx"> __ZNK7WebCore4Node11textContentEb
</span><span class="cx"> __ZNK7WebCore4Node13ownerDocumentEv
</span><span class="cx"> __ZNK7WebCore4Node14isDescendantOfEPKS0_
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCorerenderingHitTestResultcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -505,6 +505,13 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool HitTestResult::isDownloadableMedia() const
+{
+ // FIXME: We should actually answer instead of always returning true for media elements.
+ // https://bugs.webkit.org/show_bug.cgi?id=138530
+ return mediaElement() ? true : false;
+}
+
</ins><span class="cx"> URL HitTestResult::absoluteLinkURL() const
</span><span class="cx"> {
</span><span class="cx"> if (m_innerURLElement)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebCorerenderingHitTestResulth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -124,6 +124,7 @@
</span><span class="cx"> bool mediaIsVideo() const;
</span><span class="cx"> bool mediaMuted() const;
</span><span class="cx"> void toggleMediaMuteState() const;
</span><ins>+ bool isDownloadableMedia() const;
</ins><span class="cx">
</span><span class="cx"> // Returns true if it is rect-based hit test and needs to continue until the rect is fully
</span><span class="cx"> // enclosed by the boundaries of a node.
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -1,5 +1,51 @@
</span><span class="cx"> 2014-11-11 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r175779. <rdar://problem/18742164>
+
+ 2014-11-08 Beth Dakin <bdakin@apple.com>
+
+ Implement action menu support for videos
+ https://bugs.webkit.org/show_bug.cgi?id=138534
+ -and corresponding-
+ rdar://problem/18742164
+
+ Reviewed by Tim Horton.
+
+ New menu type and items types.
+ * Shared/API/c/WKActionMenuItemTypes.h:
+ * Shared/API/c/WKActionMenuTypes.h:
+
+ Plumb isMediaThatCanBeDownloaded() up to WebHitTestResult.
+ * Shared/WebHitTestResult.cpp:
+ (WebKit::WebHitTestResult::Data::Data):
+ (WebKit::WebHitTestResult::Data::encode):
+ (WebKit::WebHitTestResult::Data::decode):
+ * Shared/WebHitTestResult.h:
+ (WebKit::WebHitTestResult::isMediaThatCanBeDownloaded):
+
+ Re-name _canAddImageToPhotos to _canAddMediaToPhotos, which is more accurate. We
+ might use this method for videos some day, so now it has an accurate name.
+ * UIProcess/mac/WKActionMenuController.mm:
+
+ Default items and their actions.
+ (-[WKActionMenuController _defaultMenuItemsForVideo]):
+ (-[WKActionMenuController _copyVideoURL:]):
+ (-[WKActionMenuController _saveVideoToDownloads:]):
+ (-[WKActionMenuController _defaultMenuItemsForImage]):
+ (-[WKActionMenuController _canAddMediaToPhotos]):
+ (-[WKActionMenuController _addImageToPhotos:]):
+ (-[WKActionMenuController _createActionMenuItemForTag:]):
+ (-[WKActionMenuController _defaultMenuItems:]):
+ (-[WKActionMenuController _canAddImageToPhotos]): Deleted.
+
+ 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.
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::performActionMenuHitTestAtLocation):
+
+
+2014-11-11 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r175770. <rdar://problem/18909717>
</span><span class="cx">
</span><span class="cx"> 2014-11-07 Conrad Shultz <conrad_shultz@apple.com>
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuItemTypesh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -44,7 +44,10 @@
</span><span class="cx"> kWKContextActionItemTagCopyText,
</span><span class="cx"> kWKContextActionItemTagLookupText,
</span><span class="cx"> kWKContextActionItemTagPaste,
</span><del>- kWKContextActionItemTagTextSuggestions
</del><ins>+ kWKContextActionItemTagTextSuggestions,
+ kWKContextActionItemTagCopyVideoURL,
+ kWKContextActionItemTagSaveVideoToDownloads,
+ kWKContextActionItemTagShareVideo
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #ifdef __cplusplus
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuTypesh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -40,7 +40,8 @@
</span><span class="cx"> kWKActionMenuReadOnlyText,
</span><span class="cx"> kWKActionMenuEditableText,
</span><span class="cx"> kWKActionMenuEditableTextWithSuggestions,
</span><del>- kWKActionMenuWhitespaceInEditableArea
</del><ins>+ kWKActionMenuWhitespaceInEditableArea,
+ kWKActionMenuVideo
</ins><span class="cx"> };
</span><span class="cx"> typedef uint32_t _WKActionMenuType;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedWebHitTestResultcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> , isScrollbar(hitTestResult.scrollbar())
</span><span class="cx"> , isSelected(hitTestResult.isSelected())
</span><span class="cx"> , isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
</span><ins>+ , isDownloadableMedia(hitTestResult.isDownloadableMedia())
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -74,6 +75,7 @@
</span><span class="cx"> encoder << isScrollbar;
</span><span class="cx"> encoder << isSelected;
</span><span class="cx"> encoder << isTextNode;
</span><ins>+ encoder << isDownloadableMedia;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool WebHitTestResult::Data::decode(IPC::ArgumentDecoder& decoder, WebHitTestResult::Data& hitTestResultData)
</span><span class="lines">@@ -88,7 +90,8 @@
</span><span class="cx"> || !decoder.decode(hitTestResultData.elementBoundingBox)
</span><span class="cx"> || !decoder.decode(hitTestResultData.isScrollbar)
</span><span class="cx"> || !decoder.decode(hitTestResultData.isSelected)
</span><del>- || !decoder.decode(hitTestResultData.isTextNode))
</del><ins>+ || !decoder.decode(hitTestResultData.isTextNode)
+ || !decoder.decode(hitTestResultData.isDownloadableMedia))
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> return true;
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedWebHitTestResulth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> bool isScrollbar;
</span><span class="cx"> bool isSelected;
</span><span class="cx"> bool isTextNode;
</span><ins>+ bool isDownloadableMedia;
</ins><span class="cx">
</span><span class="cx"> Data();
</span><span class="cx"> explicit Data(const WebCore::HitTestResult&);
</span><span class="lines">@@ -85,6 +86,8 @@
</span><span class="cx">
</span><span class="cx"> bool isTextNode() const { return m_data.isTextNode; }
</span><span class="cx">
</span><ins>+ bool isDownloadableMedia() const { return m_data.isDownloadableMedia; }
+
</ins><span class="cx"> private:
</span><span class="cx"> explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
</span><span class="cx"> : m_data(hitTestResultData)
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">
</span><span class="cx"> @interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate>
</span><span class="cx"> - (void)_updateActionMenuItemsForStage:(MenuUpdateStage)stage;
</span><del>-- (BOOL)_canAddImageToPhotos;
</del><ins>+- (BOOL)_canAddMediaToPhotos;
</ins><span class="cx"> - (void)_showTextIndicator;
</span><span class="cx"> - (void)_hideTextIndicator;
</span><span class="cx"> @end
</span><span class="lines">@@ -391,13 +391,51 @@
</span><span class="cx"> _previewPopover = nil;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark Video actions
+
+- (NSArray *)_defaultMenuItemsForVideo
+{
+ RetainPtr<NSMenuItem> copyVideoURLItem = [self _createActionMenuItemForTag:kWKContextActionItemTagCopyVideoURL];
+
+ RetainPtr<NSMenuItem> saveToDownloadsItem;
+ RefPtr<WebHitTestResult> hitTestResult = WebHitTestResult::create(_hitTestResult.hitTestResult);
+ if (hitTestResult->isDownloadableMedia())
+ saveToDownloadsItem = [self _createActionMenuItemForTag:kWKContextActionItemTagSaveVideoToDownloads];
+ else
+ saveToDownloadsItem = [NSMenuItem separatorItem];
+
+ RetainPtr<NSMenuItem> shareItem = [self _createActionMenuItemForTag:kWKContextActionItemTagShareVideo];
+ String videoURL = hitTestResult->absoluteMediaURL();
+ if (!videoURL.isEmpty()) {
+ _sharingServicePicker = adoptNS([[NSSharingServicePicker alloc] initWithItems:@[ videoURL ]]);
+ [_sharingServicePicker setDelegate:self];
+ [shareItem setSubmenu:[_sharingServicePicker menu]];
+ }
+
+ return @[ copyVideoURLItem.get(), [NSMenuItem separatorItem], saveToDownloadsItem.get(), shareItem.get() ];
+}
+
+- (void)_copyVideoURL:(id)sender
+{
+ RefPtr<WebHitTestResult> hitTestResult = WebHitTestResult::create(_hitTestResult.hitTestResult);
+
+ [[NSPasteboard generalPasteboard] clearContents];
+ [[NSPasteboard generalPasteboard] writeObjects:@[ hitTestResult->absoluteMediaURL() ]];
+}
+
+- (void)_saveVideoToDownloads:(id)sender
+{
+ RefPtr<WebHitTestResult> hitTestResult = WebHitTestResult::create(_hitTestResult.hitTestResult);
+ _page->process().context().download(_page, hitTestResult->absoluteMediaURL());
+}
+
</ins><span class="cx"> #pragma mark Image actions
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForImage
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<NSMenuItem> copyImageItem = [self _createActionMenuItemForTag:kWKContextActionItemTagCopyImage];
</span><span class="cx"> RetainPtr<NSMenuItem> addToPhotosItem;
</span><del>- if ([self _canAddImageToPhotos])
</del><ins>+ if ([self _canAddMediaToPhotos])
</ins><span class="cx"> addToPhotosItem = [self _createActionMenuItemForTag:kWKContextActionItemTagAddImageToPhotos];
</span><span class="cx"> else
</span><span class="cx"> addToPhotosItem = [NSMenuItem separatorItem];
</span><span class="lines">@@ -478,14 +516,14 @@
</span><span class="cx"> return path;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (BOOL)_canAddImageToPhotos
</del><ins>+- (BOOL)_canAddMediaToPhotos
</ins><span class="cx"> {
</span><span class="cx"> return [getIKSlideshowClass() canExportToApplication:@"com.apple.Photos"];
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_addImageToPhotos:(id)sender
</span><span class="cx"> {
</span><del>- if (![self _canAddImageToPhotos])
</del><ins>+ if (![self _canAddMediaToPhotos])
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> RefPtr<ShareableBitmap> bitmap = _hitTestResult.image;
</span><span class="lines">@@ -753,6 +791,23 @@
</span><span class="cx"> image = [NSImage imageNamed:@"NSActionMenuSpelling"];
</span><span class="cx"> break;
</span><span class="cx">
</span><ins>+ case kWKContextActionItemTagCopyVideoURL:
+ selector = @selector(_copyVideoURL:);
+ title = @"Copy";
+ image = [NSImage imageNamed:@"NSActionMenuCopy"];
+ break;
+
+ case kWKContextActionItemTagSaveVideoToDownloads:
+ selector = @selector(_saveVideoToDownloads:);
+ title = @"Save to Downloads";
+ image = [NSImage imageNamed:@"NSActionMenuSaveToDownloads"];
+ break;
+
+ case kWKContextActionItemTagShareVideo:
+ title = @"Share";
+ image = [NSImage imageNamed:@"NSActionMenuShare"];
+ break;
+
</ins><span class="cx"> default:
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> return nil;
</span><span class="lines">@@ -802,6 +857,11 @@
</span><span class="cx"> return [self _defaultMenuItemsForLink];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (!hitTestResult->absoluteMediaURL().isEmpty()) {
+ _type = kWKActionMenuVideo;
+ return [self _defaultMenuItemsForVideo];
+ }
+
</ins><span class="cx"> if (!hitTestResult->absoluteImageURL().isEmpty() && _hitTestResult.image) {
</span><span class="cx"> _type = kWKActionMenuImage;
</span><span class="cx"> return [self _defaultMenuItemsForImage];
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (175863 => 175864)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-11-11 08:49:03 UTC (rev 175863)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-11-11 08:49:10 UTC (rev 175864)
</span><span class="lines">@@ -1176,6 +1176,15 @@
</span><span class="cx"> HitTestResult hitTestResult(locationInContentCoordinates);
</span><span class="cx"> mainRenderView.hitTest(request, hitTestResult);
</span><span class="cx">
</span><ins>+ // 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();
+ }
+ }
+
</ins><span class="cx"> ActionMenuHitTestResult actionMenuResult;
</span><span class="cx"> actionMenuResult.hitTestLocationInViewCooordinates = locationInViewCooordinates;
</span><span class="cx"> actionMenuResult.hitTestResult = WebHitTestResult::Data(hitTestResult);
</span></span></pre>
</div>
</div>
</body>
</html>