Diff
Modified: trunk/Source/WebCore/ChangeLog (175778 => 175779)
--- trunk/Source/WebCore/ChangeLog 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebCore/ChangeLog 2014-11-08 19:07:50 UTC (rev 175779)
@@ -1,3 +1,20 @@
+2014-11-08 Beth Dakin <[email protected]>
+
+ 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:
+
2014-11-08 Chris Dumez <[email protected]>
Speed up HTMLInputElement::isEmptyValue()
Modified: trunk/Source/WebCore/WebCore.exp.in (175778 => 175779)
--- trunk/Source/WebCore/WebCore.exp.in 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-11-08 19:07:50 UTC (rev 175779)
@@ -311,6 +311,7 @@
__ZN7WebCore13HTTPHeaderMap6removeENS_14HTTPHeaderNameE
__ZN7WebCore13HTTPHeaderMapC1Ev
__ZN7WebCore13HTTPHeaderMapD1Ev
+__ZN7WebCore13HitTestResult22setToNonShadowAncestorEv
__ZN7WebCore13HitTestResultC1ERKNS_11LayoutPointE
__ZN7WebCore13HitTestResultC1ERKNS_11LayoutPointEjjjj
__ZN7WebCore13HitTestResultC1ERKNS_15HitTestLocationE
@@ -549,7 +550,6 @@
__ZN7WebCore15GraphicsContextC1EP9CGContext
__ZN7WebCore15GraphicsContextD1Ev
__ZN7WebCore15GraphicsLayerCA10initializeEv
-__ZN7WebCore15GraphicsLayerCA18setBackdropFiltersERKNS_16FilterOperationsE
__ZN7WebCore15GraphicsLayerCA10setFiltersERKNS_16FilterOperationsE
__ZN7WebCore15GraphicsLayerCA10setOpacityEf
__ZN7WebCore15GraphicsLayerCA11setChildrenERKN3WTF6VectorIPNS_13GraphicsLayerELm0ENS1_15CrashOnOverflowEEE
@@ -579,6 +579,7 @@
__ZN7WebCore15GraphicsLayerCA17setContentsOpaqueEb
__ZN7WebCore15GraphicsLayerCA17setCustomBehaviorENS_13GraphicsLayer14CustomBehaviorE
__ZN7WebCore15GraphicsLayerCA17suspendAnimationsEd
+__ZN7WebCore15GraphicsLayerCA18setBackdropFiltersERKNS_16FilterOperationsE
__ZN7WebCore15GraphicsLayerCA18setBackgroundColorERKNS_5ColorE
__ZN7WebCore15GraphicsLayerCA18setContentsToImageEPNS_5ImageE
__ZN7WebCore15GraphicsLayerCA18setContentsVisibleEb
@@ -1690,6 +1691,7 @@
__ZNK7WebCore13HitTestResult16altDisplayStringEv
__ZNK7WebCore13HitTestResult17isContentEditableEv
__ZNK7WebCore13HitTestResult18titleDisplayStringEv
+__ZNK7WebCore13HitTestResult19isDownloadableMediaEv
__ZNK7WebCore13HitTestResult19mediaIsInFullscreenEv
__ZNK7WebCore13HitTestResult19rectBasedTestResultEv
__ZNK7WebCore13HitTestResult21innerNonSharedElementEv
@@ -1931,6 +1933,7 @@
__ZNK7WebCore4Font5widthERKNS_7TextRunEPN3WTF7HashSetIPKNS_14SimpleFontDataENS4_7PtrHashIS8_EENS4_10HashTraitsIS8_EEEEPNS_13GlyphOverflowE
__ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEiiNS0_24CustomFontNotReadyActionE
__ZNK7WebCore4FonteqERKS0_
+__ZNK7WebCore4Node10shadowHostEv
__ZNK7WebCore4Node11textContentEb
__ZNK7WebCore4Node13ownerDocumentEv
__ZNK7WebCore4Node14isDescendantOfEPKS0_
Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (175778 => 175779)
--- trunk/Source/WebCore/rendering/HitTestResult.cpp 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp 2014-11-08 19:07:50 UTC (rev 175779)
@@ -505,6 +505,13 @@
#endif
}
+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;
+}
+
URL HitTestResult::absoluteLinkURL() const
{
if (m_innerURLElement)
Modified: trunk/Source/WebCore/rendering/HitTestResult.h (175778 => 175779)
--- trunk/Source/WebCore/rendering/HitTestResult.h 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebCore/rendering/HitTestResult.h 2014-11-08 19:07:50 UTC (rev 175779)
@@ -124,6 +124,7 @@
WEBCORE_EXPORT bool mediaIsVideo() const;
bool mediaMuted() const;
void toggleMediaMuteState() const;
+ bool isDownloadableMedia() const;
// Returns true if it is rect-based hit test and needs to continue until the rect is fully
// enclosed by the boundaries of a node.
Modified: trunk/Source/WebKit2/ChangeLog (175778 => 175779)
--- trunk/Source/WebKit2/ChangeLog 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebKit2/ChangeLog 2014-11-08 19:07:50 UTC (rev 175779)
@@ -1,3 +1,44 @@
+2014-11-08 Beth Dakin <[email protected]>
+
+ 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-08 Carlos Garcia Campos <[email protected]>
[GTK] Allow to create a view with a related page in WTR
Modified: trunk/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h (175778 => 175779)
--- trunk/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h 2014-11-08 19:07:50 UTC (rev 175779)
@@ -44,7 +44,10 @@
kWKContextActionItemTagCopyText,
kWKContextActionItemTagLookupText,
kWKContextActionItemTagPaste,
- kWKContextActionItemTagTextSuggestions
+ kWKContextActionItemTagTextSuggestions,
+ kWKContextActionItemTagCopyVideoURL,
+ kWKContextActionItemTagSaveVideoToDownloads,
+ kWKContextActionItemTagShareVideo
};
#ifdef __cplusplus
Modified: trunk/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h (175778 => 175779)
--- trunk/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h 2014-11-08 19:07:50 UTC (rev 175779)
@@ -40,7 +40,8 @@
kWKActionMenuReadOnlyText,
kWKActionMenuEditableText,
kWKActionMenuEditableTextWithSuggestions,
- kWKActionMenuWhitespaceInEditableArea
+ kWKActionMenuWhitespaceInEditableArea,
+ kWKActionMenuVideo
};
typedef uint32_t _WKActionMenuType;
Modified: trunk/Source/WebKit2/Shared/WebHitTestResult.cpp (175778 => 175779)
--- trunk/Source/WebKit2/Shared/WebHitTestResult.cpp 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebKit2/Shared/WebHitTestResult.cpp 2014-11-08 19:07:50 UTC (rev 175779)
@@ -54,6 +54,7 @@
, isScrollbar(hitTestResult.scrollbar())
, isSelected(hitTestResult.isSelected())
, isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
+ , isDownloadableMedia(hitTestResult.isDownloadableMedia())
{
}
@@ -74,6 +75,7 @@
encoder << isScrollbar;
encoder << isSelected;
encoder << isTextNode;
+ encoder << isDownloadableMedia;
}
bool WebHitTestResult::Data::decode(IPC::ArgumentDecoder& decoder, WebHitTestResult::Data& hitTestResultData)
@@ -88,7 +90,8 @@
|| !decoder.decode(hitTestResultData.elementBoundingBox)
|| !decoder.decode(hitTestResultData.isScrollbar)
|| !decoder.decode(hitTestResultData.isSelected)
- || !decoder.decode(hitTestResultData.isTextNode))
+ || !decoder.decode(hitTestResultData.isTextNode)
+ || !decoder.decode(hitTestResultData.isDownloadableMedia))
return false;
return true;
Modified: trunk/Source/WebKit2/Shared/WebHitTestResult.h (175778 => 175779)
--- trunk/Source/WebKit2/Shared/WebHitTestResult.h 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebKit2/Shared/WebHitTestResult.h 2014-11-08 19:07:50 UTC (rev 175779)
@@ -54,6 +54,7 @@
bool isScrollbar;
bool isSelected;
bool isTextNode;
+ bool isDownloadableMedia;
Data();
explicit Data(const WebCore::HitTestResult&);
@@ -85,6 +86,8 @@
bool isTextNode() const { return m_data.isTextNode; }
+ bool isDownloadableMedia() const { return m_data.isDownloadableMedia; }
+
private:
explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
: m_data(hitTestResultData)
Modified: trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (175778 => 175779)
--- trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm 2014-11-08 19:07:50 UTC (rev 175779)
@@ -63,7 +63,7 @@
@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate>
- (void)_updateActionMenuItemsForStage:(MenuUpdateStage)stage;
-- (BOOL)_canAddImageToPhotos;
+- (BOOL)_canAddMediaToPhotos;
- (void)_showTextIndicator;
- (void)_hideTextIndicator;
@end
@@ -391,13 +391,51 @@
_previewPopover = nil;
}
+#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());
+}
+
#pragma mark Image actions
- (NSArray *)_defaultMenuItemsForImage
{
RetainPtr<NSMenuItem> copyImageItem = [self _createActionMenuItemForTag:kWKContextActionItemTagCopyImage];
RetainPtr<NSMenuItem> addToPhotosItem;
- if ([self _canAddImageToPhotos])
+ if ([self _canAddMediaToPhotos])
addToPhotosItem = [self _createActionMenuItemForTag:kWKContextActionItemTagAddImageToPhotos];
else
addToPhotosItem = [NSMenuItem separatorItem];
@@ -478,14 +516,14 @@
return path;
}
-- (BOOL)_canAddImageToPhotos
+- (BOOL)_canAddMediaToPhotos
{
return [getIKSlideshowClass() canExportToApplication:@"com.apple.Photos"];
}
- (void)_addImageToPhotos:(id)sender
{
- if (![self _canAddImageToPhotos])
+ if (![self _canAddMediaToPhotos])
return;
RefPtr<ShareableBitmap> bitmap = _hitTestResult.image;
@@ -753,6 +791,23 @@
image = [NSImage imageNamed:@"NSActionMenuSpelling"];
break;
+ 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;
+
default:
ASSERT_NOT_REACHED();
return nil;
@@ -802,6 +857,11 @@
return [self _defaultMenuItemsForLink];
}
+ if (!hitTestResult->absoluteMediaURL().isEmpty()) {
+ _type = kWKActionMenuVideo;
+ return [self _defaultMenuItemsForVideo];
+ }
+
if (!hitTestResult->absoluteImageURL().isEmpty() && _hitTestResult.image) {
_type = kWKActionMenuImage;
return [self _defaultMenuItemsForImage];
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (175778 => 175779)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2014-11-08 18:07:28 UTC (rev 175778)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2014-11-08 19:07:50 UTC (rev 175779)
@@ -1181,6 +1181,15 @@
HitTestResult hitTestResult(locationInContentCoordinates);
mainRenderView.hitTest(request, hitTestResult);
+ // 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();
+ }
+ }
+
ActionMenuHitTestResult actionMenuResult;
actionMenuResult.hitTestLocationInViewCooordinates = locationInViewCooordinates;
actionMenuResult.hitTestResult = WebHitTestResult::Data(hitTestResult);