⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 189942 in webkit


Ignore:
Timestamp:
Sep 17, 2015, 4:22:52 PM (11 years ago)
Author:
timothy_horton@apple.com
Message:

Block Objective-C exceptions in DictionaryLookup
https://bugs.webkit.org/show_bug.cgi?id=149256

Reviewed by Anders Carlsson.

  • editing/mac/DictionaryLookup.mm:

(WebCore::DictionaryLookup::rangeForSelection):
(WebCore::DictionaryLookup::rangeAtHitTestResult):
(WebCore::expandSelectionByCharacters):
(WebCore::DictionaryLookup::stringForPDFSelection):
(WebCore::showPopupOrCreateAnimationController):
(WebCore::DictionaryLookup::hidePopup):
It is possible for Lookup to throw an exception if one of its
related services dies for some reason. This shouldn't take down
our UI process, so block the exceptions.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r189941 r189942  
     12015-09-17  Tim Horton  <timothy_horton@apple.com>
     2
     3        Block Objective-C exceptions in DictionaryLookup
     4        https://bugs.webkit.org/show_bug.cgi?id=149256
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * editing/mac/DictionaryLookup.mm:
     9        (WebCore::DictionaryLookup::rangeForSelection):
     10        (WebCore::DictionaryLookup::rangeAtHitTestResult):
     11        (WebCore::expandSelectionByCharacters):
     12        (WebCore::DictionaryLookup::stringForPDFSelection):
     13        (WebCore::showPopupOrCreateAnimationController):
     14        (WebCore::DictionaryLookup::hidePopup):
     15        It is possible for Lookup to throw an exception if one of its
     16        related services dies for some reason. This shouldn't take down
     17        our UI process, so block the exceptions.
     18
    1192015-09-17  Yusuke Suzuki  <utatane.tea@gmail.com>
    220
  • trunk/Source/WebCore/editing/mac/DictionaryLookup.mm

    r189052 r189942  
    2929#if PLATFORM(MAC)
    3030
     31#import "BlockExceptions.h"
    3132#import "Document.h"
    3233#import "FocusController.h"
     
    8485    String fullPlainTextString = plainText(makeRange(paragraphStart, paragraphEnd).get());
    8586
     87    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    8688    // Since we already have the range we want, we just need to grab the returned options.
    8789    if (Class luLookupDefinitionModule = getLULookupDefinitionModuleClass())
    8890        [luLookupDefinitionModule tokenRangeForString:fullPlainTextString range:rangeToPass options:options];
     91    END_BLOCK_OBJC_EXCEPTIONS;
    8992
    9093    return selectedRange.release();
     
    128131        return nullptr;
    129132
     133    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     134
    130135    NSRange rangeToPass = NSMakeRange(TextIterator::rangeLength(makeRange(fullCharacterRange->startPosition(), position).get()), 0);
    131136
     
    141146
    142147    return TextIterator::subrange(fullCharacterRange.get(), extractedRange.location, extractedRange.length);
     148
     149    END_BLOCK_OBJC_EXCEPTIONS;
     150    return nullptr;
    143151}
    144152
    145153static void expandSelectionByCharacters(PDFSelection *selection, NSInteger numberOfCharactersToExpand, NSInteger& charactersAddedBeforeStart, NSInteger& charactersAddedAfterEnd)
    146154{
     155    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     156
    147157    size_t originalLength = selection.string.length;
    148158    [selection extendSelectionAtStart:numberOfCharactersToExpand];
     
    152162    [selection extendSelectionAtEnd:numberOfCharactersToExpand];
    153163    charactersAddedAfterEnd = selection.string.length - originalLength - charactersAddedBeforeStart;
     164
     165    END_BLOCK_OBJC_EXCEPTIONS;
    154166}
    155167
    156168NSString *DictionaryLookup::stringForPDFSelection(PDFSelection *selection, NSDictionary **options)
    157169{
     170    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     171
    158172    // Don't do anything if there is no character at the point.
    159173    if (!selection || !selection.string.length)
     
    187201    ASSERT([selection.string isEqualToString:[fullPlainTextString substringWithRange:extractedRange]]);
    188202    return selection.string;
     203
     204    END_BLOCK_OBJC_EXCEPTIONS;
     205    return nil;
    189206}
    190207
    191208static PlatformAnimationController showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, std::function<void(TextIndicator&)> textIndicatorInstallationCallback)
    192209{
     210    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     211
    193212    if (!getLULookupDefinitionModuleClass())
    194213        return nil;
     
    233252    [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    234253    return nil;
     254
     255    END_BLOCK_OBJC_EXCEPTIONS;
     256    return nil;
    235257}
    236258
     
    242264void DictionaryLookup::hidePopup()
    243265{
     266    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     267
    244268    if (!getLULookupDefinitionModuleClass())
    245269        return;
    246270    [getLULookupDefinitionModuleClass() hideDefinition];
     271
     272    END_BLOCK_OBJC_EXCEPTIONS;
    247273}
    248274
Note: See TracChangeset for help on using the changeset viewer.