Title: [176737] branches/safari-600.3-branch/Source/WebKit

Diff

Modified: branches/safari-600.3-branch/Source/WebKit/ChangeLog (176736 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/ChangeLog	2014-12-03 20:13:02 UTC (rev 176736)
+++ branches/safari-600.3-branch/Source/WebKit/ChangeLog	2014-12-03 20:15:51 UTC (rev 176737)
@@ -1,3 +1,19 @@
+2014-12-03  Dana Burkart  <[email protected]>
+
+        Merge r176680. <rdar://problem/19067172>
+
+    2014-12-02  Tim Horton  <[email protected]>
+
+            Implement Lookup transition from selection for Legacy WebKit
+            https://bugs.webkit.org/show_bug.cgi?id=139180
+            <rdar://problem/19067172>
+
+            Reviewed by Beth Dakin.
+
+            * WebKit.xcodeproj/project.pbxproj:
+            Add mac/WebView/DictionaryPopupInfo.h.
+
+
 2014-10-28  Dana Burkart  <[email protected]>
 
         Merge r174791. <rdar://problem/18753175>

Modified: branches/safari-600.3-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (176736 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2014-12-03 20:13:02 UTC (rev 176736)
+++ branches/safari-600.3-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2014-12-03 20:15:51 UTC (rev 176737)
@@ -85,6 +85,7 @@
 		2D25396718CE85C200270222 /* WebSharingServicePickerController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D25396518CE85C200270222 /* WebSharingServicePickerController.mm */; };
 		2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */; };
 		2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */; };
+		2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */; };
 		312E2FE514E48182007CCA18 /* WebNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE314E48182007CCA18 /* WebNotification.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 312E2FE414E48182007CCA18 /* WebNotification.mm */; };
 		312E2FE914E48215007CCA18 /* WebNotificationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE814E48215007CCA18 /* WebNotificationInternal.h */; };
@@ -541,6 +542,7 @@
 		2D81DAB303EB0B2D00A80166 /* WebFormDelegate.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebFormDelegate.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSelectionServiceController.h; sourceTree = "<group>"; };
 		2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSelectionServiceController.mm; sourceTree = "<group>"; };
+		2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryPopupInfo.h; sourceTree = "<group>"; };
 		312E2FE314E48182007CCA18 /* WebNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotification.h; sourceTree = "<group>"; };
 		312E2FE414E48182007CCA18 /* WebNotification.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNotification.mm; sourceTree = "<group>"; };
 		312E2FE814E48215007CCA18 /* WebNotificationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationInternal.h; sourceTree = "<group>"; };
@@ -1294,6 +1296,7 @@
 				F52CA6BD02DF9D0F018635CA /* HTML */,
 				51E94C0706C02CA300A9B09E /* PDF */,
 				A10C1D79182030190036883A /* ios */,
+				2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */,
 				935D44E219F9AFF000FB5306 /* WebActionMenuController.h */,
 				935D44E319F9AFF000FB5306 /* WebActionMenuController.mm */,
 				8373435A0624EE0D00F3B289 /* WebArchive.h */,
@@ -1814,6 +1817,7 @@
 				A10C1D8C1820305E0036883A /* WebPDFViewIPhone.h in Headers */,
 				9398106D0824BF01008DF038 /* WebKitErrorsPrivate.h in Headers */,
 				CD8BFCE815531224005AFB25 /* WebKitFullScreenListener.h in Headers */,
+				2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */,
 				9398101D0824BF01008DF038 /* WebKitLogging.h in Headers */,
 				9398101E0824BF01008DF038 /* WebKitNSStringExtras.h in Headers */,
 				1AAF58940EDCCF15008D883D /* WebKitPluginAgent.defs in Headers */,

Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (176736 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-03 20:13:02 UTC (rev 176736)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-03 20:15:51 UTC (rev 176737)
@@ -1,3 +1,51 @@
+2014-12-03  Dana Burkart  <[email protected]>
+
+        Merge r176680. <rdar://problem/19067172>
+
+    2014-12-02  Tim Horton  <[email protected]>
+
+            Implement Lookup transition from selection for Legacy WebKit
+            https://bugs.webkit.org/show_bug.cgi?id=139180
+            <rdar://problem/19067172>
+
+            Reviewed by Beth Dakin.
+
+            * WebView/DictionaryPopupInfo.h: Added.
+            Split DictionaryPopupInfo out into its own file.
+
+            * WebView/WebActionMenuController.mm:
+            (-[WebActionMenuController _lookupText:]):
+            Hand the DictionaryPopupInfo to WebView, which will show the TextIndicator and invoke Lookup.
+
+            (performDictionaryLookupForSelection):
+            (performDictionaryLookupForRange):
+            Plumb the transition style through these helpers.
+            Create a TextIndicator from the selection range.
+
+            * WebView/WebHTMLView.mm:
+            (-[WebHTMLView _lookUpInDictionaryFromMenu:]):
+            Make use of TextIndicator (and DictionaryPopupInfo, and the new
+            _showDictionaryLookupPopup on WebView) to add a transition from blue
+            when performing Lookup from the context menu.
+
+            (-[WebHTMLView quickLookWithEvent:]):
+            Remove our TextIndicator whenever a normal three-finger-tap event
+            comes through, as it will have its own indication.
+
+            * WebView/WebView.mm:
+            (-[WebView _commonInitializationWithFrameName:groupName:]):
+            (-[WebView _dictionaryLookupPopoverWillClose:]):
+            Register for the LUNotificationPopoverWillClose notification and remove
+            our TextIndicator when it is called, just like in WebKit2.
+            Deregistration is already handled in _close.
+
+            (-[WebView _showDictionaryLookupPopup:]):
+            Just like WebKit2, show our TextIndicator and tell Lookup not to show its own,
+            if the relevant API is available.
+
+            * WebView/WebViewInternal.h:
+
+
 2014-12-02  Dana Burkart  <[email protected]>
 
         Merge r176618. <rdar://problem/18992185>

Added: branches/safari-600.3-branch/Source/WebKit/mac/WebView/DictionaryPopupInfo.h (0 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/DictionaryPopupInfo.h	                        (rev 0)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/DictionaryPopupInfo.h	2014-12-03 20:15:51 UTC (rev 176737)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(MAC)
+
+#import <WebCore/FloatPoint.h>
+#import <wtf/RetainPtr.h>
+
+@class NSAttributedString;
+@class NSDictionary;
+
+namespace WebCore {
+class TextIndicator;
+};
+
+struct DictionaryPopupInfo {
+    NSPoint origin;
+    RetainPtr<NSDictionary> options;
+    RetainPtr<NSAttributedString> attributedString;
+    RefPtr<WebCore::TextIndicator> textIndicator;
+};
+
+#endif // PLATFORM(MAC)

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (176736 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-03 20:13:02 UTC (rev 176736)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-03 20:15:51 UTC (rev 176737)
@@ -30,6 +30,7 @@
 #import "DOMElementInternal.h"
 #import "DOMNodeInternal.h"
 #import "DOMRangeInternal.h"
+#import "DictionaryPopupInfo.h"
 #import "WebDocumentInternal.h"
 #import "WebElementDictionary.h"
 #import "WebFrameInternal.h"
@@ -87,12 +88,6 @@
 
 using namespace WebCore;
 
-struct DictionaryPopupInfo {
-    NSPoint origin;
-    RetainPtr<NSDictionary> options;
-    RetainPtr<NSAttributedString> attributedString;
-};
-
 @implementation WebActionMenuController
 
 - (id)initWithWebView:(WebView *)webView
@@ -634,15 +629,7 @@
         return;
 
     DictionaryPopupInfo popupInfo = performDictionaryLookupForSelection(frame, frame->selection().selection());
-    if (!popupInfo.attributedString)
-        return;
-
-    NSPoint textBaselineOrigin = popupInfo.origin;
-
-    // Convert to screen coordinates.
-    textBaselineOrigin = [_webView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
-
-    [getLULookupDefinitionModuleClass() showDefinitionForTerm:popupInfo.attributedString.get() atLocation:textBaselineOrigin options:popupInfo.options.get()];
+    [_webView _showDictionaryLookupPopup:popupInfo];
 }
 
 - (void)_paste:(id)sender
@@ -682,11 +669,11 @@
     DictionaryPopupInfo popupInfo;
     RefPtr<Range> selectedRange = rangeForDictionaryLookupForSelection(selection, &options);
     if (selectedRange)
-        popupInfo = performDictionaryLookupForRange(frame, *selectedRange, options);
+        popupInfo = performDictionaryLookupForRange(frame, *selectedRange, options, TextIndicatorPresentationTransition::BounceAndCrossfade);
     return popupInfo;
 }
 
-static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options)
+static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
 {
     DictionaryPopupInfo popupInfo;
     if (range.text().stripWhiteSpace().isEmpty())
@@ -722,6 +709,7 @@
     }];
 
     popupInfo.attributedString = scaledNSAttributedString.get();
+    popupInfo.textIndicator = TextIndicator::createWithRange(range, presentationTransition);
     return popupInfo;
 }
 

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm (176736 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm	2014-12-03 20:13:02 UTC (rev 176736)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm	2014-12-03 20:15:51 UTC (rev 176737)
@@ -34,6 +34,7 @@
 #import "DOMDocumentInternal.h"
 #import "DOMNodeInternal.h"
 #import "DOMRangeInternal.h"
+#import "DictionaryPopupInfo.h"
 #import "WebActionMenuController.h"
 #import "WebArchive.h"
 #import "WebClipView.h"
@@ -114,6 +115,7 @@
 #import <WebCore/StyleProperties.h>
 #import <WebCore/Text.h>
 #import <WebCore/TextAlternativeWithRange.h>
+#import <WebCore/TextIndicator.h>
 #import <WebCore/TextUndoInsertionMarkupMac.h>
 #import <WebCore/WebCoreObjCExtras.h>
 #import <WebCore/WebNSAttributedStringExtras.h>
@@ -5682,13 +5684,23 @@
 
     NSRect rect = coreFrame->selection().selectionBounds();
 
-    NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0,1)];
+    NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0, 1)];
     NSFont *font = [attributes objectForKey:NSFontAttributeName];
     if (font)
-        rect.origin.y += [font ascender];
+        rect.origin.y += [font descender];
 
-    [self showDefinitionForAttributedString:attrString atPoint:rect.origin];
+    DictionaryPopupInfo info;
+    info.attributedString = attrString;
+    info.origin = coreFrame->view()->contentsToWindow(enclosingIntRect(rect)).location();
+    info.textIndicator = TextIndicator::createWithSelectionInFrame(*coreFrame, TextIndicatorPresentationTransition::BounceAndCrossfade);
+    [[self _webView] _showDictionaryLookupPopup:info];
 }
+
+- (void)quickLookWithEvent:(NSEvent *)event
+{
+    [[self _webView] _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:[] { }];
+    [super quickLookWithEvent:event];
+}
 #endif // !PLATFORM(IOS)
 
 - (void)_executeSavedKeypressCommands

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm (176736 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm	2014-12-03 20:13:02 UTC (rev 176736)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm	2014-12-03 20:15:51 UTC (rev 176737)
@@ -35,6 +35,7 @@
 #import "DOMDocumentInternal.h"
 #import "DOMNodeInternal.h"
 #import "DOMRangeInternal.h"
+#import "DictionaryPopupInfo.h"
 #import "WebAlternativeTextClient.h"
 #import "WebApplicationCache.h"
 #import "WebBackForwardListInternal.h"
@@ -208,7 +209,9 @@
 #import "WebNSPasteboardExtras.h"
 #import "WebNSPrintOperationExtras.h"
 #import "WebPDFView.h"
+#import <WebCore/LookupSPI.h>
 #import <WebCore/NSViewSPI.h>
+#import <WebCore/SoftLinking.h>
 #import <WebCore/TextIndicator.h>
 #import <WebCore/TextIndicatorWindow.h>
 #import <WebCore/WebVideoFullscreenController.h>
@@ -292,6 +295,11 @@
 #import <WebCore/HIDGamepadProvider.h>
 #endif
 
+#if PLATFORM(MAC)
+SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)
+#endif
+
 #if !PLATFORM(IOS)
 @interface NSSpellChecker (WebNSSpellCheckerDetails)
 - (void)_preflightChosenSpellServer;
@@ -1024,6 +1032,9 @@
 
 #if !PLATFORM(IOS)
     [self _registerDraggedTypes];
+
+    if (canLoadLUNotificationPopoverWillClose())
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
 #endif
 
     [self _setIsVisible:[self _isViewVisible]];
@@ -8554,7 +8565,8 @@
     return NSMakeRect(rect.origin.x, [self bounds].size.height - rect.origin.y - rect.size.height, rect.size.width, rect.size.height);
 }
 
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+#if PLATFORM(MAC)
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 - (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event
 {
     if (menu != self.actionMenu)
@@ -8579,6 +8591,12 @@
     [_private->actionMenuController didCloseMenu:menu withEvent:event];
 }
 
+- (WebActionMenuController *)_actionMenuController
+{
+    return _private->actionMenuController;
+}
+#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
 - (void)_setTextIndicator:(TextIndicator *)textIndicator fadeOut:(BOOL)fadeOut animationCompletionHandler:(std::function<void ()>)completionHandler
 {
     if (!textIndicator) {
@@ -8597,12 +8615,34 @@
     [self _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:^ { }];
 }
 
-- (WebActionMenuController *)_actionMenuController
+- (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo
 {
-    return _private->actionMenuController;
+    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()) {
+        RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([dictionaryPopupInfo.options mutableCopy]);
+        if (!mutableOptions)
+            mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
+        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
+        [self _setTextIndicator:dictionaryPopupInfo.textIndicator.get() fadeOut:NO animationCompletionHandler:[dictionaryPopupInfo, textBaselineOrigin, mutableOptions] {
+            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
+        }];
+    } else
+        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
 }
-#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 
+- (void)_dictionaryLookupPopoverWillClose:(NSNotification *)notification
+{
+    [self _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:[] { }];
+}
+#endif // PLATFORM(MAC)
+
 @end
 
 @implementation WebView (WebViewDeviceOrientation)

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h (176736 => 176737)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h	2014-12-03 20:13:02 UTC (rev 176736)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h	2014-12-03 20:15:51 UTC (rev 176737)
@@ -58,6 +58,7 @@
 struct DictationAlternative;
 }
 
+struct DictionaryPopupInfo;
 class WebSelectionServiceController;
 #endif
 
@@ -258,6 +259,7 @@
 #if PLATFORM(MAC) && defined(__cplusplus)
 - (void)_setTextIndicator:(WebCore::TextIndicator*)textIndicator fadeOut:(BOOL)fadeOut animationCompletionHandler:(std::function<void ()>)completionHandler;
 - (void)_clearTextIndicator;
+- (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo;
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 - (WebActionMenuController *)_actionMenuController;
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to