Changeset 188443 in webkit
- Timestamp:
- Aug 13, 2015, 11:31:24 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r188439 r188443 1 2015-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 1 12 2015-08-13 Simon Fraser <simon.fraser@apple.com> 2 13 -
trunk/Source/WebCore/platform/spi/mac/LookupSPI.h
r177326 r188443 43 43 + (NSRange)tokenRangeForString:(NSString *)string range:(NSRange)range options:(NSDictionary **)options; 44 44 + (void)showDefinitionForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options; 45 + (void)showDefinitionForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options; 45 46 + (void)hideDefinition; 46 47 … … 51 52 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 52 53 53 @interface LULookupDefinitionModule ( AnimationController)54 @interface LULookupDefinitionModule () 54 55 55 56 + (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; 56 59 57 60 @end -
trunk/Source/WebKit/mac/ChangeLog
r188420 r188443 1 2015-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 1 16 2015-08-13 Tim Horton <timothy_horton@apple.com> 2 17 -
trunk/Source/WebKit/mac/WebView/WebView.mm
r188420 r188443 8552 8552 return nil; 8553 8553 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) { 8560 8555 if (!_private->hasInitializedLookupObserver) { 8561 8556 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil]; … … 8568 8563 [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()]; 8569 8564 [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; 8572 8575 8573 8576 return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()]; … … 8618 8621 return; 8619 8622 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) { 8626 8624 if (!_private->hasInitializedLookupObserver) { 8627 8625 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil]; … … 8634 8632 [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()]; 8635 8633 [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()]; 8639 8647 } 8640 8648 -
trunk/Source/WebKit2/ChangeLog
r188441 r188443 1 2015-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 1 16 2015-08-13 Commit Queue <commit-queue@webkit.org> 2 17 -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm
r188420 r188443 589 589 return; 590 590 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 591 607 NSPoint textBaselineOrigin = dictionaryPopupInfo.origin; 592 608 … … 595 611 textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin; 596 612 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()]; 607 614 } 608 615 -
trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm
r188420 r188443 471 471 [_wkView _prepareForDictionaryLookup]; 472 472 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 473 485 // Convert baseline to screen coordinates. 474 486 NSPoint textBaselineOrigin = dictionaryPopupInfo.origin; … … 476 488 textBaselineOrigin = [_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin; 477 489 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 }485 490 return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()]; 486 491 }
Note:
See TracChangeset
for help on using the changeset viewer.