Changeset 183077 in webkit


Ignore:
Timestamp:
Apr 21, 2015, 3:01:52 PM (10 years ago)
Author:
Brent Fulgham
Message:

Context menu doesn't account for selection semantics
https://bugs.webkit.org/show_bug.cgi?id=143958
<rdar://problem/19735706>

Reviewed by Tim Horton.

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

  • page/EventHandler.cpp:

(WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):
(WebCore::EventHandler::selectClosestWordFromHitTestResult):

  • page/EventHandler.h:
  • page/mac/EventHandlerMac.mm:

(WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r183074 r183077  
     12015-04-21  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Context menu doesn't account for selection semantics
     4        https://bugs.webkit.org/show_bug.cgi?id=143958
     5        <rdar://problem/19735706>
     6
     7        Reviewed by Tim Horton.
     8
     9        Before using the default word-only selection, check with the
     10        lookup service to see if we can get a semantically appropriate
     11        selection.
     12
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):
     15        (WebCore::EventHandler::selectClosestWordFromHitTestResult):
     16        * page/EventHandler.h:
     17        * page/mac/EventHandlerMac.mm:
     18        (WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):
     19
    1202015-04-21  Anders Carlsson  <andersca@apple.com>
    221
  • trunk/Source/WebCore/page/EventHandler.cpp

    r182963 r183077  
    570570}
    571571
     572#if !PLATFORM(MAC)
     573VisibleSelection EventHandler::selectClosestWordFromHitTestResultBasedOnLookup(const HitTestResult&)
     574{
     575    return VisibleSelection();
     576}
     577#endif
     578
    572579void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& result, AppendTrailingWhitespace appendTrailingWhitespace)
    573580{
     
    576583
    577584    if (targetNode && targetNode->renderer()) {
    578         VisiblePosition pos(targetNode->renderer()->positionForPoint(result.localPoint(), nullptr));
    579         if (pos.isNotNull()) {
    580             newSelection = VisibleSelection(pos);
    581             newSelection.expandUsingGranularity(WordGranularity);
    582         }
    583 
    584         if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSelection.isRange())
    585             newSelection.appendTrailingWhitespace();
     585        newSelection = selectClosestWordFromHitTestResultBasedOnLookup(result);
     586        if (newSelection.isNone()) {
     587            VisiblePosition pos(targetNode->renderer()->positionForPoint(result.localPoint(), nullptr));
     588            if (pos.isNotNull()) {
     589                newSelection = VisibleSelection(pos);
     590                newSelection.expandUsingGranularity(WordGranularity);
     591            }
     592
     593            if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSelection.isRange())
     594                newSelection.appendTrailingWhitespace();
     595        }
    586596
    587597        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), WordGranularity);
  • trunk/Source/WebCore/page/EventHandler.h

    r182963 r183077  
    326326    bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity);
    327327    void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
     328    VisibleSelection selectClosestWordFromHitTestResultBasedOnLookup(const HitTestResult&);
    328329    void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
    329330    void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r182334 r183077  
    3232#include "ChromeClient.h"
    3333#include "DataTransfer.h"
     34#include "DictionaryLookup.h"
    3435#include "DragController.h"
    3536#include "EventNames.h"
     
    4647#include "Pasteboard.h"
    4748#include "PlatformEventFactoryMac.h"
     49#include "Range.h"
    4850#include "RenderLayer.h"
    4951#include "RenderListBox.h"
     
    10081010}
    10091011
    1010 }
     1012VisibleSelection EventHandler::selectClosestWordFromHitTestResultBasedOnLookup(const HitTestResult& result)
     1013{
     1014    NSDictionary *options = nil;
     1015    if (RefPtr<Range> range = rangeForDictionaryLookupAtHitTestResult(result, &options))
     1016        return VisibleSelection(range.get());
     1017
     1018    return VisibleSelection();
     1019}
     1020
     1021}
Note: See TracChangeset for help on using the changeset viewer.