Context menu doesn't account for selection semantics
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Apr 2015 22:10:29 +0000 (22:10 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Apr 2015 22:10:29 +0000 (22:10 +0000)
commita938585fc1c9bd9ff5872f7f2d79964a5c1cb022
treef7fc38fd39368fc079d068c67204d4c055051a18
parentbed1eb8138f669549138ed36fa6e7d40b9f2e383
Context menu doesn't account for selection semantics
https://bugs.webkit.org/show_bug.cgi?id=143958
<rdar://problem/19735706>

Reviewed by Tim Horton.

Source/WebCore:

Before using the default word-only selection for context menus, check with the
lookup service to see if we can get a semantically appropriate selection.

* editing/EditingBehavior.h:
(WebCore::EditingBehavior::shouldSelectBasedOnDictionaryLookup): Added, so that we can
behavior correctly when using non-Mac editing behavior.
* editing/mac/DictionaryLookup.mm:
(WebCore::rangeForDictionaryLookupAtHitTestResult): Modified to honor standard WebKit
behavior when hit testing at end-of-line/end-of-paragraph, etc.
* page/EventHandler.cpp:
(WebCore::EventHandler::shouldAppendTrailingWhitespace): New helper function to share code.
(WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup): Added.
(WebCore::EventHandler::selectClosestContextualWordFromMouseEvent): Added.
(WebCore::EventHandler::selectClosestContextualWordOrLinkFromMouseEvent): Renamed from selectClosestWordOrLinkFromMouseEvent.
Have this call the new 'selectClosestContextualWordFromMouseEvent' instead of the vanilla 'selectClosestWordFromMouseEvent'.
* page/EventHandler.h:
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup): Added.

LayoutTests:

* editing/selection/context-menu-text-selection-lookup-expected.txt: Added.
* editing/selection/context-menu-text-selection-lookup.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183138 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/selection/context-menu-text-selection-lookup-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/context-menu-text-selection-lookup.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/EditingBehavior.h
Source/WebCore/editing/mac/DictionaryLookup.mm
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/mac/EventHandlerMac.mm