Title: [175831] trunk/Source/WebKit/mac
- Revision
- 175831
- Author
- [email protected]
- Date
- 2014-11-10 14:12:01 -0800 (Mon, 10 Nov 2014)
Log Message
WK1: Text is getting selected even when an action menu fails to invoke
https://bugs.webkit.org/show_bug.cgi?id=138576
-and corresponding-
rdar://problem/18931330
Reviewed by Tim Horton.
Selection changes should happen in willOpenMenu: instead of prepareForMenu:
* WebView/WebActionMenuController.h:
* WebView/WebActionMenuController.mm:
(-[WebActionMenuController prepareForMenu:withEvent:]):
(-[WebActionMenuController willOpenMenu:withEvent:]):
_selectLookupText no longer needs to return a BOOL indicating success or failure.
(-[WebActionMenuController _selectLookupText]):
(-[WebActionMenuController _defaultMenuItemsForHitTestResult:]):
Pass willOpenMenu: on to the controller.
* WebView/WebView.mm:
(-[WebView willOpenMenu:withEvent:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (175830 => 175831)
--- trunk/Source/WebKit/mac/ChangeLog 2014-11-10 22:05:52 UTC (rev 175830)
+++ trunk/Source/WebKit/mac/ChangeLog 2014-11-10 22:12:01 UTC (rev 175831)
@@ -1,5 +1,28 @@
2014-11-10 Beth Dakin <[email protected]>
+ WK1: Text is getting selected even when an action menu fails to invoke
+ https://bugs.webkit.org/show_bug.cgi?id=138576
+ -and corresponding-
+ rdar://problem/18931330
+
+ Reviewed by Tim Horton.
+
+ Selection changes should happen in willOpenMenu: instead of prepareForMenu:
+ * WebView/WebActionMenuController.h:
+ * WebView/WebActionMenuController.mm:
+ (-[WebActionMenuController prepareForMenu:withEvent:]):
+ (-[WebActionMenuController willOpenMenu:withEvent:]):
+
+ _selectLookupText no longer needs to return a BOOL indicating success or failure.
+ (-[WebActionMenuController _selectLookupText]):
+ (-[WebActionMenuController _defaultMenuItemsForHitTestResult:]):
+
+ Pass willOpenMenu: on to the controller.
+ * WebView/WebView.mm:
+ (-[WebView willOpenMenu:withEvent:]):
+
+2014-11-10 Beth Dakin <[email protected]>
+
Speculative build fix.
* WebView/WebActionMenuController.mm:
Modified: trunk/Source/WebKit/mac/WebView/WebActionMenuController.h (175830 => 175831)
--- trunk/Source/WebKit/mac/WebView/WebActionMenuController.h 2014-11-10 22:05:52 UTC (rev 175830)
+++ trunk/Source/WebKit/mac/WebView/WebActionMenuController.h 2014-11-10 22:12:01 UTC (rev 175831)
@@ -38,6 +38,7 @@
- (id)initWithWebView:(WebView *)webView;
- (void)webViewClosed;
- (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event;
+- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event;
- (void)didCloseMenu:(NSMenu *)menu withEvent:(NSEvent *)event;
@end
Modified: trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm (175830 => 175831)
--- trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-11-10 22:05:52 UTC (rev 175830)
+++ trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm 2014-11-10 22:12:01 UTC (rev 175831)
@@ -118,9 +118,6 @@
WebElementDictionary *hitTestResult = [self performHitTestAtPoint:[_webView convertPoint:event.locationInWindow fromView:nil]];
NSArray *menuItems = [self _defaultMenuItemsForHitTestResult:hitTestResult];
- if (_type != WebActionMenuReadOnlyText)
- [[_webView _selectedOrMainFrame] _clearSelection];
-
// Allow clients to customize the menu items.
if ([[_webView UIDelegate] respondsToSelector:@selector(_webView:actionMenuItemsForHitTestResult:withType:defaultActionMenuItems:)])
menuItems = [[_webView UIDelegate] _webView:_webView actionMenuItemsForHitTestResult:hitTestResult withType:_type defaultActionMenuItems:menuItems];
@@ -129,6 +126,22 @@
[actionMenu addItem:item];
}
+- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
+{
+ if (menu != _webView.actionMenu)
+ return;
+
+ if (_type != WebActionMenuReadOnlyText) {
+ [[_webView _selectedOrMainFrame] _clearSelection];
+ return;
+ }
+
+ // Action menus for text should highlight the text so that it is clear what the action menu actions
+ // will apply to. If the text is already selected, the menu will use the existing selection.
+ if (!_hitTestResult.isSelected())
+ [self _selectLookupText];
+}
+
- (void)didCloseMenu:(NSMenu *)menu withEvent:(NSEvent *)event
{
if (menu != _webView.actionMenu)
@@ -270,19 +283,19 @@
WKShowWordDefinitionWindow(popupInfo.attributedString.get(), textBaselineOrigin, popupInfo.options.get());
}
-- (BOOL)_selectLookupText
+- (void)_selectLookupText
{
NSDictionary *options = nil;
RefPtr<Range> lookupRange = rangeForDictionaryLookupAtHitTestResult(_hitTestResult, &options);
if (!lookupRange)
- return false;
+ return;
Frame* frame = _hitTestResult.innerNode()->document().frame();
if (!frame)
- return false;
+ return;
frame->selection().setSelectedRange(lookupRange.get(), DOWNSTREAM, true);
- return true;
+ return;
}
static DictionaryPopupInfo performDictionaryLookupForSelection(Frame* frame, const VisibleSelection& selection)
@@ -406,10 +419,6 @@
Node* node = _hitTestResult.innerNode();
if (node && node->isTextNode()) {
- if (![[hitTestResult objectForKey:WebElementIsSelectedKey] boolValue]) {
- if (![self _selectLookupText])
- return @[ ];
- }
_type = WebActionMenuReadOnlyText;
return [self _defaultMenuItemsForText:hitTestResult];
}
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (175830 => 175831)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2014-11-10 22:05:52 UTC (rev 175830)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2014-11-10 22:12:01 UTC (rev 175831)
@@ -8544,6 +8544,14 @@
[_private->actionMenuController prepareForMenu:menu withEvent:event];
}
+- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
+{
+ if (menu != self.actionMenu)
+ return;
+
+ [_private->actionMenuController willOpenMenu:menu withEvent:event];
+}
+
- (void)didCloseMenu:(NSMenu *)menu withEvent:(NSEvent *)event
{
if (menu != self.actionMenu)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes