Changeset 188443 in webkit


Ignore:
Timestamp:
Aug 13, 2015, 11:31:24 PM (10 years ago)
Author:
timothy_horton@apple.com
Message:

Performing a Lookup on wrapped text puts the popover arrow in the wrong place (off to the right)
https://bugs.webkit.org/show_bug.cgi?id=148012
<rdar://problem/19238094>

Reviewed by Simon Fraser.

  • platform/spi/mac/LookupSPI.h:

Add some SPI.

  • WebView/WebView.mm:

(-[WebView _animationControllerForDictionaryLookupPopupInfo:]):
(-[WebView _showDictionaryLookupPopup:]):
Adopt the new SPI, handing it the first text rect, instead of having it
guess where to put the popover.
Also, null-check the TextIndicator.

  • UIProcess/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::didPerformDictionaryLookup):

  • UIProcess/mac/WKImmediateActionController.mm:

(-[WKImmediateActionController _animationControllerForText]):
Adopt the new SPI, handing it the first text rect, instead of having it
guess where to put the popover.

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r188439 r188443  
     12015-08-13  Tim Horton  <timothy_horton@apple.com>
     2
     3        Performing a Lookup on wrapped text puts the popover arrow in the wrong place (off to the right)
     4        https://bugs.webkit.org/show_bug.cgi?id=148012
     5        <rdar://problem/19238094>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * platform/spi/mac/LookupSPI.h:
     10        Add some SPI.
     11
    1122015-08-13  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/Source/WebCore/platform/spi/mac/LookupSPI.h

    r177326 r188443  
    4343+ (NSRange)tokenRangeForString:(NSString *)string range:(NSRange)range options:(NSDictionary **)options;
    4444+ (void)showDefinitionForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options;
     45+ (void)showDefinitionForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options;
    4546+ (void)hideDefinition;
    4647
     
    5152#if  __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    5253
    53 @interface LULookupDefinitionModule (AnimationController)
     54@interface LULookupDefinitionModule ()
    5455
    5556+ (id<NSImmediateActionAnimationController>)lookupAnimationControllerForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options;
     57
     58+ (id<NSImmediateActionAnimationController>)lookupAnimationControllerForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options;
    5659
    5760@end
  • trunk/Source/WebKit/mac/ChangeLog

    r188420 r188443  
     12015-08-13  Tim Horton  <timothy_horton@apple.com>
     2
     3        Performing a Lookup on wrapped text puts the popover arrow in the wrong place (off to the right)
     4        https://bugs.webkit.org/show_bug.cgi?id=148012
     5        <rdar://problem/19238094>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * WebView/WebView.mm:
     10        (-[WebView _animationControllerForDictionaryLookupPopupInfo:]):
     11        (-[WebView _showDictionaryLookupPopup:]):
     12        Adopt the new SPI, handing it the first text rect, instead of having it
     13        guess where to put the popover.
     14        Also, null-check the TextIndicator.
     15
    1162015-08-13  Tim Horton  <timothy_horton@apple.com>
    217
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r188420 r188443  
    85528552        return nil;
    85538553
    8554     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
    8555 
    8556     // Convert to screen coordinates.
    8557     textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    8558 
    8559     if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose()) {
     8554    if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose() && dictionaryPopupInfo.textIndicator) {
    85608555        if (!_private->hasInitializedLookupObserver) {
    85618556            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
     
    85688563        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    85698564        [self _setTextIndicator:*dictionaryPopupInfo.textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
    8570         return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    8571     }
     8565
     8566        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(lookupAnimationControllerForTerm:relativeToRect:ofView:options:)]) {
     8567            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator->textRectsInBoundingRectCoordinates()[0];
     8568            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator->textBoundingRectInRootViewCoordinates().location());
     8569            return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:[self _convertRectFromRootView:firstTextRectInViewCoordinates] ofView:self options:mutableOptions.get()];
     8570        }
     8571    }
     8572
     8573    // Convert to screen coordinates.
     8574    NSPoint textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(dictionaryPopupInfo.origin.x, dictionaryPopupInfo.origin.y, 0, 0)].origin;
    85728575
    85738576    return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
     
    86188621        return;
    86198622
    8620     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
    8621 
    8622     // Convert to screen coordinates.
    8623     textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    8624 
    8625     if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose()) {
     8623    if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose() && dictionaryPopupInfo.textIndicator) {
    86268624        if (!_private->hasInitializedLookupObserver) {
    86278625            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
     
    86348632        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    86358633        [self _setTextIndicator:*dictionaryPopupInfo.textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
    8636         [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    8637     } else
    8638         [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
     8634
     8635        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
     8636            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator->textRectsInBoundingRectCoordinates()[0];
     8637            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator->textBoundingRectInRootViewCoordinates().location());
     8638            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:[self _convertRectFromRootView:firstTextRectInViewCoordinates] ofView:self options:mutableOptions.get()];
     8639            return;
     8640        }
     8641    }
     8642
     8643    // Convert to screen coordinates.
     8644    NSPoint textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(dictionaryPopupInfo.origin.x, dictionaryPopupInfo.origin.y, 0, 0)].origin;
     8645
     8646    [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
    86398647}
    86408648
  • trunk/Source/WebKit2/ChangeLog

    r188441 r188443  
     12015-08-13  Tim Horton  <timothy_horton@apple.com>
     2
     3        Performing a Lookup on wrapped text puts the popover arrow in the wrong place (off to the right)
     4        https://bugs.webkit.org/show_bug.cgi?id=148012
     5        <rdar://problem/19238094>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * UIProcess/mac/PageClientImpl.mm:
     10        (WebKit::PageClientImpl::didPerformDictionaryLookup):
     11        * UIProcess/mac/WKImmediateActionController.mm:
     12        (-[WKImmediateActionController _animationControllerForText]):
     13        Adopt the new SPI, handing it the first text rect, instead of having it
     14        guess where to put the popover.
     15
    1162015-08-13  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r188420 r188443  
    589589        return;
    590590
     591    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
     592
     593    [m_wkView _prepareForDictionaryLookup];
     594
     595    if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
     596        [m_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) withLifetime:TextIndicatorWindowLifetime::Permanent];
     597        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
     598
     599        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
     600            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator.textRectsInBoundingRectCoordinates[0];
     601            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates.location());
     602            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() relativeToRect:firstTextRectInViewCoordinates ofView:m_wkView options:mutableOptions.get()];
     603            return;
     604        }
     605    }
     606
    591607    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
    592608
     
    595611    textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    596612
    597     RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
    598 
    599     [m_wkView _prepareForDictionaryLookup];
    600 
    601     if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
    602         [m_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) withLifetime:TextIndicatorWindowLifetime::Permanent];
    603         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    604         [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    605     } else
    606         [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
     613    [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    607614}
    608615
  • trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm

    r188420 r188443  
    471471    [_wkView _prepareForDictionaryLookup];
    472472
     473    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
     474    if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
     475        [_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) withLifetime:TextIndicatorWindowLifetime::Permanent];
     476        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
     477
     478        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(lookupAnimationControllerForTerm:relativeToRect:ofView:options:)]) {
     479            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator.textRectsInBoundingRectCoordinates[0];
     480            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates.location());
     481            return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() relativeToRect:firstTextRectInViewCoordinates ofView:_wkView options:mutableOptions.get()];
     482        }
     483    }
     484
    473485    // Convert baseline to screen coordinates.
    474486    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
     
    476488    textBaselineOrigin = [_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    477489
    478     RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
    479     if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
    480         RefPtr<TextIndicator> indicator = TextIndicator::create(dictionaryPopupInfo.textIndicator);
    481         [_wkView _setTextIndicator:*indicator withLifetime:TextIndicatorWindowLifetime::Permanent];
    482         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    483         return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    484     }
    485490    return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    486491}
Note: See TracChangeset for help on using the changeset viewer.