Diff
Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebCore/ChangeLog 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog 2014-12-10 23:35:26 UTC (rev 177109)
@@ -1,3 +1,21 @@
+2014-12-10 Matthew Hanson <[email protected]>
+
+ Merge r176999. rdar://problem/19149219
+
+ 2014-12-08 Beth Dakin <[email protected]>
+
+ Copy and Lookup menu items should be disabled when something is not copyable
+ https://bugs.webkit.org/show_bug.cgi?id=139423
+
+ Reviewed by Tim Horton.
+
+ New function allowCopy() indicates whether the HitTestResult would allow itself to
+ be copied onto the pasteboard.
+ * WebCore.exp.in:
+ * rendering/HitTestResult.cpp:
+ (WebCore::HitTestResult::allowsCopy):
+ * rendering/HitTestResult.h:
+
2014-10-29 Chris Dumez <[email protected]>
Crash in CachedRawResource::canReuse() when reloading http://dnd.wizards.com/dungeons-and-dragons/story
Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in 2014-12-10 23:35:26 UTC (rev 177109)
@@ -1665,6 +1665,7 @@
__ZNK7WebCore13GraphicsLayer26backingStoreMemoryEstimateEv
__ZNK7WebCore13HTTPHeaderMap3getENS_14HTTPHeaderNameE
__ZNK7WebCore13HTTPHeaderMap3getERKN3WTF6StringE
+__ZNK7WebCore13HitTestResult10allowsCopyEv
__ZNK7WebCore13HitTestResult10isLiveLinkEv
__ZNK7WebCore13HitTestResult10isSelectedEv
__ZNK7WebCore13HitTestResult11targetFrameEv
Modified: branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp 2014-12-10 23:35:26 UTC (rev 177109)
@@ -544,6 +544,21 @@
return !wordRange->text().isEmpty();
}
+bool HitTestResult::allowsCopy() const
+{
+ Node* node = innerNode();
+ if (!node)
+ return false;
+
+ RenderObject* renderer = node->renderer();
+ if (!renderer)
+ return false;
+
+ bool isUserSelectNone = renderer->style().userSelect() == SELECT_NONE;
+ bool isPasswordField = isHTMLInputElement(node) && toHTMLInputElement(node)->isPasswordField();
+ return !isPasswordField && !isUserSelectNone;
+}
+
URL HitTestResult::absoluteLinkURL() const
{
if (m_innerURLElement)
Modified: branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h 2014-12-10 23:35:26 UTC (rev 177109)
@@ -126,6 +126,7 @@
void toggleMediaMuteState() const;
bool isDownloadableMedia() const;
bool isOverTextInsideFormControlElement() const;
+ bool allowsCopy() 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: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog 2014-12-10 23:35:26 UTC (rev 177109)
@@ -1,3 +1,22 @@
+2014-12-10 Matthew Hanson <[email protected]>
+
+ Merge r176999. rdar://problem/19149219
+
+ 2014-12-08 Beth Dakin <[email protected]>
+
+ Copy and Lookup menu items should be disabled when something is not copyable
+ https://bugs.webkit.org/show_bug.cgi?id=139423
+
+ Reviewed by Tim Horton.
+
+ Disable both lookup and copy when a HitTestResult does not allow copy.
+ * WebView/WebActionMenuController.mm:
+
+ Set autoenablesItems to NO. It’s messing with our ability to control the enable/
+ disable state otherwise.
+ * WebView/WebView.mm:
+ (-[WebView _commonInitializationWithFrameName:groupName:]):
+
2014-12-08 Matthew Hanson <[email protected]>
Merge r176856. <rdar://problem/19157955>
Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-12-10 23:35:26 UTC (rev 177109)
@@ -764,13 +764,14 @@
selector = @selector(_copySelection:);
title = WEB_UI_STRING_KEY("Copy", "Copy (text action menu item)", "text action menu item");
image = [NSImage imageNamed:@"NSActionMenuCopy"];
+ enabled = _hitTestResult.allowsCopy();
break;
case WebActionMenuItemTagLookupText:
selector = @selector(_lookupText:);
title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item");
image = [NSImage imageNamed:@"NSActionMenuLookup"];
- enabled = getLULookupDefinitionModuleClass();
+ enabled = getLULookupDefinitionModuleClass() && _hitTestResult.allowsCopy();
break;
case WebActionMenuItemTagPaste:
Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm 2014-12-10 23:35:26 UTC (rev 177109)
@@ -893,6 +893,7 @@
RetainPtr<NSMenu> actionMenu = adoptNS([[NSMenu alloc] init]);
self.actionMenu = actionMenu.get();
_private->actionMenuController = [[WebActionMenuController alloc] initWithWebView:self];
+ self.actionMenu.autoenablesItems = NO;
}
#endif
Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog 2014-12-10 23:35:26 UTC (rev 177109)
@@ -1,3 +1,30 @@
+2014-12-10 Matthew Hanson <[email protected]>
+
+ Merge r176999. rdar://problem/19149219
+
+ 2014-12-08 Beth Dakin <[email protected]>
+
+ Copy and Lookup menu items should be disabled when something is not copyable
+ https://bugs.webkit.org/show_bug.cgi?id=139423
+
+ Reviewed by Tim Horton.
+
+ Add allowsCopy to the WebHitTestResult.
+ * Shared/WebHitTestResult.cpp:
+ (WebKit::WebHitTestResult::Data::Data):
+ (WebKit::WebHitTestResult::Data::encode):
+ (WebKit::WebHitTestResult::Data::decode):
+ * Shared/WebHitTestResult.h:
+ (WebKit::WebHitTestResult::allowsCopy):
+
+ Set autoenablesItems to NO. It’s messing with our ability to control the enable/
+ disable state otherwise.
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView initWithFrame:context:configuration:webView:]):
+
+ Disable both lookup and copy when a WebHitTestResult does not allow copy.
+ * UIProcess/mac/WKActionMenuController.mm:
+
2014-12-08 Matthew Hanson <[email protected]>
Merge r176883. <rdar://problem/19158331>
Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp 2014-12-10 23:35:26 UTC (rev 177109)
@@ -55,6 +55,7 @@
, isSelected(hitTestResult.isSelected())
, isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
, isOverTextInsideFormControlElement(hitTestResult.isOverTextInsideFormControlElement())
+ , allowsCopy(hitTestResult.allowsCopy())
, isDownloadableMedia(hitTestResult.isDownloadableMedia())
{
}
@@ -77,6 +78,7 @@
encoder << isSelected;
encoder << isTextNode;
encoder << isOverTextInsideFormControlElement;
+ encoder << allowsCopy;
encoder << isDownloadableMedia;
}
@@ -94,6 +96,7 @@
|| !decoder.decode(hitTestResultData.isSelected)
|| !decoder.decode(hitTestResultData.isTextNode)
|| !decoder.decode(hitTestResultData.isOverTextInsideFormControlElement)
+ || !decoder.decode(hitTestResultData.allowsCopy)
|| !decoder.decode(hitTestResultData.isDownloadableMedia))
return false;
Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h 2014-12-10 23:35:26 UTC (rev 177109)
@@ -55,6 +55,7 @@
bool isSelected;
bool isTextNode;
bool isOverTextInsideFormControlElement;
+ bool allowsCopy;
bool isDownloadableMedia;
Data();
@@ -89,6 +90,8 @@
bool isOverTextInsideFormControlElement() const { return m_data.isOverTextInsideFormControlElement; }
+ bool allowsCopy() const { return m_data.allowsCopy; }
+
bool isDownloadableMedia() const { return m_data.isDownloadableMedia; }
private:
Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2014-12-10 23:35:26 UTC (rev 177109)
@@ -3600,6 +3600,7 @@
self.actionMenu = menu.get();
_data->_actionMenuController = adoptNS([[WKActionMenuController alloc] initWithPage:*_data->_page view:self]);
self.actionMenu.delegate = _data->_actionMenuController.get();
+ self.actionMenu.autoenablesItems = NO;
}
#endif
Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (177108 => 177109)
--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm 2014-12-10 23:31:09 UTC (rev 177108)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm 2014-12-10 23:35:26 UTC (rev 177109)
@@ -981,6 +981,7 @@
NSString *title = nil;
NSImage *image = nil;
bool enabled = true;
+ RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
switch (tag) {
case kWKContextActionItemTagOpenLinkInDefaultBrowser:
@@ -1030,13 +1031,14 @@
selector = @selector(_copySelection:);
title = WEB_UI_STRING_KEY("Copy", "Copy (text action menu item)", "text action menu item");
image = [NSImage imageNamed:@"NSActionMenuCopy"];
+ enabled = hitTestResult->allowsCopy();
break;
case kWKContextActionItemTagLookupText:
selector = @selector(_lookupText:);
title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item");
image = [NSImage imageNamed:@"NSActionMenuLookup"];
- enabled = getLULookupDefinitionModuleClass();
+ enabled = getLULookupDefinitionModuleClass() && hitTestResult->allowsCopy();
break;
case kWKContextActionItemTagPaste: