Title: [190745] branches/safari-601-branch/Source

Diff

Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (190744 => 190745)


--- branches/safari-601-branch/Source/WebCore/ChangeLog	2015-10-08 20:56:12 UTC (rev 190744)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog	2015-10-08 21:08:45 UTC (rev 190745)
@@ -1,3 +1,18 @@
+2015-10-08  Lucas Forschler  <[email protected]>
+
+        Merge r188443. rdar://problem/22801969
+
+    2015-08-13  Tim Horton  <[email protected]>
+
+            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.
+
 2015-10-02  Matthew Hanson  <[email protected]>
 
         Merge r190380. rdar://problem/22888962

Modified: branches/safari-601-branch/Source/WebCore/platform/spi/mac/LookupSPI.h (190744 => 190745)


--- branches/safari-601-branch/Source/WebCore/platform/spi/mac/LookupSPI.h	2015-10-08 20:56:12 UTC (rev 190744)
+++ branches/safari-601-branch/Source/WebCore/platform/spi/mac/LookupSPI.h	2015-10-08 21:08:45 UTC (rev 190745)
@@ -42,6 +42,7 @@
 
 + (NSRange)tokenRangeForString:(NSString *)string range:(NSRange)range options:(NSDictionary **)options;
 + (void)showDefinitionForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options;
++ (void)showDefinitionForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options;
 + (void)hideDefinition;
 
 @end
@@ -50,10 +51,12 @@
 
 #if  __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 
-@interface LULookupDefinitionModule (AnimationController)
+@interface LULookupDefinitionModule ()
 
 + (id<NSImmediateActionAnimationController>)lookupAnimationControllerForTerm:(NSAttributedString *)term atLocation:(NSPoint)screenPoint options:(NSDictionary *)options;
 
++ (id<NSImmediateActionAnimationController>)lookupAnimationControllerForTerm:(NSAttributedString *)term relativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView options:(NSDictionary *)options;
+
 @end
 
 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000

Modified: branches/safari-601-branch/Source/WebKit/mac/ChangeLog (190744 => 190745)


--- branches/safari-601-branch/Source/WebKit/mac/ChangeLog	2015-10-08 20:56:12 UTC (rev 190744)
+++ branches/safari-601-branch/Source/WebKit/mac/ChangeLog	2015-10-08 21:08:45 UTC (rev 190745)
@@ -1,3 +1,22 @@
+2015-10-08  Lucas Forschler  <[email protected]>
+
+        Merge r188443. rdar://problem/22801969
+
+    2015-08-13  Tim Horton  <[email protected]>
+
+            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.
+
+            * 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.
+
 2015-10-02  Matthew Hanson  <[email protected]>
 
         Merge r189122. rdar://problem/22801996

Modified: branches/safari-601-branch/Source/WebKit/mac/WebView/WebView.mm (190744 => 190745)


--- branches/safari-601-branch/Source/WebKit/mac/WebView/WebView.mm	2015-10-08 20:56:12 UTC (rev 190744)
+++ branches/safari-601-branch/Source/WebKit/mac/WebView/WebView.mm	2015-10-08 21:08:45 UTC (rev 190745)
@@ -8561,12 +8561,7 @@
     if (!dictionaryPopupInfo.attributedString)
         return nil;
 
-    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
-
-    // Convert to screen coordinates.
-    textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
-
-    if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose()) {
+    if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose() && dictionaryPopupInfo.textIndicator) {
         if (!_private->hasInitializedLookupObserver) {
             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
             _private->hasInitializedLookupObserver = YES;
@@ -8577,9 +8572,17 @@
             mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
         [self _setTextIndicator:*dictionaryPopupInfo.textIndicator withLifetime:TextIndicatorLifetime::Permanent];
-        return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
+
+        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(lookupAnimationControllerForTerm:relativeToRect:ofView:options:)]) {
+            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator->textRectsInBoundingRectCoordinates()[0];
+            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator->textBoundingRectInRootViewCoordinates().location());
+            return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:[self _convertRectFromRootView:firstTextRectInViewCoordinates] ofView:self options:mutableOptions.get()];
+        }
     }
 
+    // Convert to screen coordinates.
+    NSPoint textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(dictionaryPopupInfo.origin.x, dictionaryPopupInfo.origin.y, 0, 0)].origin;
+
     return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
 }
 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
@@ -8627,12 +8630,7 @@
     if (!dictionaryPopupInfo.attributedString)
         return;
 
-    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
-
-    // Convert to screen coordinates.
-    textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
-
-    if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose()) {
+    if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose() && dictionaryPopupInfo.textIndicator) {
         if (!_private->hasInitializedLookupObserver) {
             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
             _private->hasInitializedLookupObserver = YES;
@@ -8643,9 +8641,19 @@
             mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
         [self _setTextIndicator:*dictionaryPopupInfo.textIndicator withLifetime:TextIndicatorLifetime::Permanent];
-        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
-    } else
-        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
+
+        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
+            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator->textRectsInBoundingRectCoordinates()[0];
+            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator->textBoundingRectInRootViewCoordinates().location());
+            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:[self _convertRectFromRootView:firstTextRectInViewCoordinates] ofView:self options:mutableOptions.get()];
+            return;
+        }
+    }
+
+    // Convert to screen coordinates.
+    NSPoint textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(dictionaryPopupInfo.origin.x, dictionaryPopupInfo.origin.y, 0, 0)].origin;
+
+    [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
 }
 
 - (void)_dictionaryLookupPopoverWillClose:(NSNotification *)notification

Modified: branches/safari-601-branch/Source/WebKit2/ChangeLog (190744 => 190745)


--- branches/safari-601-branch/Source/WebKit2/ChangeLog	2015-10-08 20:56:12 UTC (rev 190744)
+++ branches/safari-601-branch/Source/WebKit2/ChangeLog	2015-10-08 21:08:45 UTC (rev 190745)
@@ -1,3 +1,22 @@
+2015-10-08  Lucas Forschler  <[email protected]>
+
+        Merge r188443. rdar://problem/22801969
+
+    2015-08-13  Tim Horton  <[email protected]>
+
+            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.
+
+            * 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.
+
 2015-10-02  Babak Shafiei  <[email protected]>
 
         Merge r190418.

Modified: branches/safari-601-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (190744 => 190745)


--- branches/safari-601-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-10-08 20:56:12 UTC (rev 190744)
+++ branches/safari-601-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2015-10-08 21:08:45 UTC (rev 190745)
@@ -587,12 +587,6 @@
     if (!getLULookupDefinitionModuleClass())
         return;
 
-    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
-
-    // Convert to screen coordinates.
-    textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
-    textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
-
     RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
 
     [m_wkView _prepareForDictionaryLookup];
@@ -600,9 +594,22 @@
     if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
         [m_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) withLifetime:TextIndicatorLifetime::Permanent];
         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
-        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
-    } else
-        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
+
+        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
+            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator.textRectsInBoundingRectCoordinates[0];
+            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates.location());
+            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() relativeToRect:firstTextRectInViewCoordinates ofView:m_wkView options:mutableOptions.get()];
+            return;
+        }
+    }
+
+    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
+
+    // Convert to screen coordinates.
+    textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
+    textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
+
+    [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
 }
 
 void PageClientImpl::dismissContentRelativeChildWindows(bool withAnimation)

Modified: branches/safari-601-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm (190744 => 190745)


--- branches/safari-601-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm	2015-10-08 20:56:12 UTC (rev 190744)
+++ branches/safari-601-branch/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm	2015-10-08 21:08:45 UTC (rev 190745)
@@ -469,18 +469,23 @@
 
     [_wkView _prepareForDictionaryLookup];
 
+    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
+    if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
+        [_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) withLifetime:TextIndicatorLifetime::Permanent];
+        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
+
+        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(lookupAnimationControllerForTerm:relativeToRect:ofView:options:)]) {
+            FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator.textRectsInBoundingRectCoordinates[0];
+            firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates.location());
+            return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() relativeToRect:firstTextRectInViewCoordinates ofView:_wkView options:mutableOptions.get()];
+        }
+    }
+
     // Convert baseline to screen coordinates.
     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
     textBaselineOrigin = [_wkView convertPoint:textBaselineOrigin toView:nil];
     textBaselineOrigin = [_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
 
-    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
-    if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
-        RefPtr<TextIndicator> indicator = TextIndicator::create(dictionaryPopupInfo.textIndicator);
-        [_wkView _setTextIndicator:*indicator withLifetime:TextIndicatorLifetime::Permanent];
-        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
-        return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
-    }
     return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to