Changeset 150653 in webkit


Ignore:
Timestamp:
May 24, 2013 12:41:37 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Add more lines to the context during Dictionary lookups
https://bugs.webkit.org/show_bug.cgi?id=115256

Patch by Thomas Deniau <deniau@apple.com> on 2013-05-24
Reviewed by Ryosuke Niwa.

Source/WebCore:

No new tests - no new functionality.

  • WebCore.exp.in: Export a few methods in VisibleUnits needed to be able

to call previousLinePosition(), nextLinePosition(), startOfLine() and
endOfLine() in WebPageMac.mm when determining the context while looking
up a dictionary definition. These symbols used to be exported for iOS
only, export them on the desktop too.

Source/WebKit2:

  • WebProcess/WebPage/mac/WebPageMac.mm:

(WebKit::WebPage::performDictionaryLookupAtLocation):
Instead of using the current paragraph as the context (which stops at
line breaks), get a few lines before and after the point, so that the
context contains at least four lines in each direction.
This way the Dictionary will be able to look up things that extend past
the current line.

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150652 r150653  
     12013-05-24  Thomas Deniau  <deniau@apple.com>
     2
     3        Add more lines to the context during Dictionary lookups
     4        https://bugs.webkit.org/show_bug.cgi?id=115256
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        No new tests - no new functionality.
     9
     10        * WebCore.exp.in: Export a few methods in VisibleUnits needed to be able
     11        to call previousLinePosition(), nextLinePosition(), startOfLine() and
     12        endOfLine() in WebPageMac.mm when determining the context while looking
     13        up a dictionary definition. These symbols used to be exported for iOS
     14        only, export them on the desktop too.
     15
    1162013-05-24  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebCore/WebCore.exp.in

    r150633 r150653  
    169169__ZN7WebCore11iBeamCursorEv
    170170__ZN7WebCore11memoryCacheEv
     171__ZN7WebCore11startOfLineERKNS_15VisiblePositionE
    171172__ZN7WebCore11startOfWordERKNS_15VisiblePositionENS_9EWordSideE
    172173__ZN7WebCore11writeToFileEiPKci
     
    567568__ZN7WebCore16isEndOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
    568569__ZN7WebCore16isUserVisibleURLEP8NSString
     570__ZN7WebCore16nextLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
    569571__ZN7WebCore16scriptNameToCodeERKN3WTF6StringE
    570572__ZN7WebCore16startOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
     
    687689__ZN7WebCore20deleteEmptyDirectoryERKN3WTF6StringE
    688690__ZN7WebCore20makeRGBA32FromFloatsEffff
     691__ZN7WebCore20previousLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
    689692__ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
    690693__ZN7WebCore20toUInt32EnforceRangeEPN3JSC9ExecStateENS0_7JSValueE
     
    12651268__ZN7WebCore9TimerBaseD2Ev
    12661269__ZN7WebCore9closeFileERi
     1270__ZN7WebCore9endOfLineERKNS_15VisiblePositionE
    12671271__ZN7WebCore9endOfWordERKNS_15VisiblePositionENS_9EWordSideE
    12681272__ZN7WebCore9fontCacheEv
     
    14501454__ZNK7WebCore15VisiblePosition14localCaretRectERPNS_12RenderObjectE
    14511455__ZNK7WebCore15VisiblePosition19absoluteCaretBoundsEv
     1456__ZNK7WebCore15VisiblePosition45lineDirectionPointForBlockDirectionNavigationEv
    14521457__ZNK7WebCore15VisiblePosition4nextENS_27EditingBoundaryCrossingRuleE
    14531458__ZNK7WebCore15VisiblePosition8previousENS_27EditingBoundaryCrossingRuleE
     
    16391644__ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb
    16401645__ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb
     1646__ZNK7WebCore8Position28offsetForPositionAfterAnchorEv
    16411647__ZNK7WebCore8Position8upstreamENS_27EditingBoundaryCrossingRuleE
    16421648__ZNK7WebCore9DOMWindow27pendingUnloadEventListenersEv
     
    20712077__ZN7WebCore11MemoryCache20removeImageFromCacheERKNS_4KURLE
    20722078__ZN7WebCore11isEndOfLineERKNS_15VisiblePositionE
    2073 __ZN7WebCore11startOfLineERKNS_15VisiblePositionE
    20742079__ZN7WebCore12EventHandler10mouseMovedEP8WebEvent
    20752080__ZN7WebCore12EventHandler10wheelEventEP8WebEvent
     
    21202125__ZN7WebCore16VisibleSelectionC1Ev
    21212126__ZN7WebCore16jsStringWithCacheSlowCaseEPN3JSC9ExecStateERN3WTF7HashMapIPNS3_10StringImplENS0_4WeakINS0_8JSStringEEENS3_10StringHashENS3_10HashTraitsIS6_EENSB_IS9_EEEES6_
    2122 __ZN7WebCore16nextLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
    21232127__ZN7WebCore16nextWordPositionERKNS_15VisiblePositionE
    21242128__ZN7WebCore17CredentialStorage16clearCredentialsEv
     
    21352139__ZN7WebCore20networkStateNotifierEv
    21362140__ZN7WebCore20nextSentencePositionERKNS_15VisiblePositionE
    2137 __ZN7WebCore20previousLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
    21382141__ZN7WebCore20previousWordPositionERKNS_15VisiblePositionE
    21392142__ZN7WebCore21MemoryPressureHandler19clearMemoryPressureEv
     
    22152218__ZN7WebCore9TileCache14drainLayerPoolEv
    22162219__ZN7WebCore9TileCache20setLayerPoolCapacityEj
    2217 __ZN7WebCore9endOfLineERKNS_15VisiblePositionE
    22182220__ZNK7WebCore10FloatPointcv7CGPointEv
    22192221__ZNK7WebCore14FrameSelection17wordOffsetInRangeEPKNS_5RangeE
     
    22292231__ZNK7WebCore14FrameSelection36elementRangeContainingCaretSelectionEv
    22302232__ZNK7WebCore14SecurityOrigin8toStringEv
    2231 __ZNK7WebCore15VisiblePosition45lineDirectionPointForBlockDirectionNavigationEv
    22322233__ZNK7WebCore15VisiblePosition4leftEb
    22332234__ZNK7WebCore15VisiblePosition5rightEb
     
    22572258__ZNK7WebCore7IntSizecv6CGSizeEv
    22582259__ZNK7WebCore8Document31isTelephoneNumberParsingEnabledEv
    2259 __ZNK7WebCore8Position28offsetForPositionAfterAnchorEv
    22602260__ZNK7WebCore9FloatRectcv6CGRectEv
    22612261__ZNK7WebCore9FloatSizecv6CGSizeEv
  • trunk/Source/WebKit2/ChangeLog

    r150648 r150653  
     12013-05-24  Thomas Deniau  <deniau@apple.com>
     2
     3        Add more lines to the context during Dictionary lookups
     4        https://bugs.webkit.org/show_bug.cgi?id=115256
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * WebProcess/WebPage/mac/WebPageMac.mm:
     9        (WebKit::WebPage::performDictionaryLookupAtLocation):
     10        Instead of using the current paragraph as the context (which stops at
     11        line breaks), get a few lines before and after the point, so that the
     12        context contains at least four lines in each direction.
     13        This way the Dictionary will be able to look up things that extend past
     14        the current line.
     15
    1162013-05-24  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r150243 r150653  
    508508    NSDictionary *options = nil;
    509509
    510     // As context, we are going to use the surrounding paragraph of text.
    511     VisiblePosition paragraphStart = startOfParagraph(position);
    512     VisiblePosition paragraphEnd = endOfParagraph(position);
    513 
    514     NSRange rangeToPass = NSMakeRange(TextIterator::rangeLength(makeRange(paragraphStart, position).get()), 0);
    515 
    516     RefPtr<Range> fullCharacterRange = makeRange(paragraphStart, paragraphEnd);
     510    // As context, we are going to use four lines of text before and after the point. (Dictionary can sometimes look up things that are four lines long)
     511    const int numberOfLinesOfContext = 4;
     512    VisiblePosition contextStart = position;
     513    VisiblePosition contextEnd = position;
     514    for (int i = 0; i < numberOfLinesOfContext; i++) {
     515        VisiblePosition n = previousLinePosition(contextStart, contextStart.lineDirectionPointForBlockDirectionNavigation());
     516        if (n.isNull() || n == contextStart)
     517            break;
     518        contextStart = n;
     519    }
     520    for (int i = 0; i < numberOfLinesOfContext; i++) {
     521        VisiblePosition n = nextLinePosition(contextEnd, contextEnd.lineDirectionPointForBlockDirectionNavigation());
     522        if (n.isNull() || n == contextEnd)
     523            break;
     524        contextEnd = n;
     525    }
     526    contextStart = startOfLine(contextStart);
     527    contextEnd = endOfLine(contextEnd);
     528   
     529    NSRange rangeToPass = NSMakeRange(TextIterator::rangeLength(makeRange(contextStart, position).get()), 0);
     530
     531    RefPtr<Range> fullCharacterRange = makeRange(contextStart, contextEnd);
    517532    String fullPlainTextString = plainText(fullCharacterRange.get());
    518533
Note: See TracChangeset for help on using the changeset viewer.