Changeset 261457 in webkit
- Timestamp:
- May 10, 2020 12:28:11 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r261453 r261457 1 2020-05-10 Tim Horton <timothy_horton@apple.com> 2 3 Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it 4 https://bugs.webkit.org/show_bug.cgi?id=211686 5 <rdar://problem/57941589> 6 7 Reviewed by Wenson Hsieh. 8 9 * dom/MouseRelatedEvent.h: 10 * editing/cocoa/DataDetection.h: 11 * editing/cocoa/DataDetection.mm: 12 (WebCore::DataDetection::canPresentDataDetectorsUIForElement): 13 (WebCore::DataDetection::shouldCancelDefaultAction): Deleted. 14 Rename shouldCancelDefaultAction to canPresentDataDetectorsUIForElement. 15 This bit indicates whether a given element should invoke DD UI instead of 16 doing its default action, so either name is OK, but it feels better to 17 have it in the affirmative direction. 18 19 * html/HTMLAnchorElement.cpp: 20 (WebCore::HTMLAnchorElement::handleClick): 21 Determine if tapping on an anchor should invoke DataDetectors UI instead 22 of performing the default action, and short-circuit if that is possible. 23 24 * loader/EmptyClients.h: 25 * page/ChromeClient.h: 26 1 27 2020-05-09 Wenson Hsieh <wenson_hsieh@apple.com> 2 28 -
trunk/Source/WebCore/dom/MouseRelatedEvent.h
r250060 r261457 62 62 int pageX() const final; 63 63 int pageY() const final; 64 FloatPoint locationInRootViewCoordinates() const;64 WEBCORE_EXPORT FloatPoint locationInRootViewCoordinates() const; 65 65 virtual const LayoutPoint& pageLocation() const; 66 66 WEBCORE_EXPORT int x() const; -
trunk/Source/WebCore/editing/cocoa/DataDetection.h
r260753 r261457 68 68 WEBCORE_EXPORT static bool isDataDetectorLink(Element&); 69 69 WEBCORE_EXPORT static String dataDetectorIdentifier(Element&); 70 WEBCORE_EXPORT static bool shouldCancelDefaultAction(Element&);70 WEBCORE_EXPORT static bool canPresentDataDetectorsUIForElement(Element&); 71 71 WEBCORE_EXPORT static bool requiresExtendedContext(Element&); 72 72 #endif -
trunk/Source/WebCore/editing/cocoa/DataDetection.mm
r261153 r261457 184 184 } 185 185 186 bool DataDetection:: shouldCancelDefaultAction(Element& element)186 bool DataDetection::canPresentDataDetectorsUIForElement(Element& element) 187 187 { 188 188 if (!isDataDetectorLink(element)) -
trunk/Source/WebCore/html/HTMLAnchorElement.cpp
r261013 r261457 26 26 27 27 #include "AdClickAttribution.h" 28 #include "Chrome.h" 29 #include "ChromeClient.h" 28 30 #include "DOMTokenList.h" 29 31 #include "ElementIterator.h" … … 58 60 #include <wtf/text/StringConcatenateNumbers.h> 59 61 62 #if PLATFORM(COCOA) 63 #include "DataDetection.h" 64 #endif 65 60 66 namespace WebCore { 61 67 … … 467 473 URL completedURL = document().completeURL(url.toString()); 468 474 475 #if ENABLE(DATA_DETECTION) && PLATFORM(IOS_FAMILY) 476 if (DataDetection::isDataDetectorLink(*this) && DataDetection::canPresentDataDetectorsUIForElement(*this)) { 477 if (auto* page = document().page()) { 478 if (page->chrome().client().showDataDetectorsUIForElement(*this, event)) 479 return; 480 } 481 } 482 #endif 483 469 484 String downloadAttribute; 470 485 #if ENABLE(DOWNLOAD_ATTRIBUTE) -
trunk/Source/WebCore/loader/EmptyClients.h
r259330 r261457 179 179 void removeScrollingLayer(Node*, PlatformLayer*, PlatformLayer*) final { } 180 180 181 void webAppOrientationsUpdated() final { }; 182 void showPlaybackTargetPicker(bool, RouteSharingPolicy, const String&) final { }; 181 void webAppOrientationsUpdated() final { } 182 void showPlaybackTargetPicker(bool, RouteSharingPolicy, const String&) final { } 183 184 bool showDataDetectorsUIForElement(const Element&, const Event&) final { return false; } 183 185 #endif // PLATFORM(IOS_FAMILY) 184 186 -
trunk/Source/WebCore/page/ChromeClient.h
r261398 r261457 273 273 virtual void webAppOrientationsUpdated() = 0; 274 274 virtual void showPlaybackTargetPicker(bool hasVideo, RouteSharingPolicy, const String&) = 0; 275 276 virtual bool showDataDetectorsUIForElement(const Element&, const Event&) = 0; 275 277 #endif 276 278 -
trunk/Source/WebKit/ChangeLog
r261454 r261457 1 2020-05-10 Tim Horton <timothy_horton@apple.com> 2 3 Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it 4 https://bugs.webkit.org/show_bug.cgi?id=211686 5 <rdar://problem/57941589> 6 7 Reviewed by Wenson Hsieh. 8 9 Previously, iOS WebKit had code in handleTap, handleTwoFingerTapAtPoint, and commitPotentialTap, 10 which introspected the hit element /before/ dispatching the tap (or synthetic click) to the DOM, 11 short circuiting all normal event handling machinery in order to prevent the default action 12 and present the Data Detectors UI for the given link. 13 14 There's one immediate problem with this, which is that there is no similar code in the direct 15 click event handler path, which we now use for trackpad/mouse input on iPad. There's also a 16 secondary problem (which we have not seen in practice), which is that pages cannot preventDefault 17 to avoid launching the Data Detectors UI on a link, like they could to prevent an ordinary 18 link from being followed. 19 20 In order to resolve both issues and reduce duplication of logic, move the code that introspects 21 the element and invokes Data Detectors UI from high-level WebKit event dispatch code (where it 22 doesn't really belong) down to WebCore's default click event handler for anchors, right next to 23 the code that would ordinarily cause a navigation. This way, no matter how we get here, whether 24 by synthetic click or real click, we'll invoke the Data Detectors UI. 25 26 One alternative considered at length: we could actually let the navigation happen, and instead 27 handle the switch in navigation policy code, but there are a few reasons that did not seem ideal: 28 1) We'd need to plumb platform-specific data structures through a ton of FrameLoader code. 29 2) Clients often block non-HTTP(S) navigations, so in order to keep the feature functional, 30 we'd have to disregard the client's policy decision, defeating much of the purpose of making 31 use of the navigation mechanism in the first place. 32 33 * UIProcess/PageClient.h: 34 * UIProcess/WebPageProxy.h: 35 * UIProcess/WebPageProxy.messages.in: 36 * UIProcess/ios/PageClientImplIOS.h: 37 * UIProcess/ios/PageClientImplIOS.mm: 38 (WebKit::PageClientImpl::showDataDetectorsUIForPositionInformation): 39 * UIProcess/ios/WebPageProxyIOS.mm: 40 (WebKit::WebPageProxy::showDataDetectorsUIForPositionInformation): 41 * WebProcess/WebCoreSupport/WebChromeClient.h: 42 * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm: 43 (WebKit::WebChromeClient::showDataDetectorsUIForElement): 44 Plumb showDataDetectorsUIForPositionInformation from iOS WebKit's ChromeClient 45 implementation all the way to WKContentView. 46 47 * UIProcess/ios/WKActionSheetAssistant.h: 48 * UIProcess/ios/WKActionSheetAssistant.mm: 49 (-[WKActionSheetAssistant showDataDetectorsUIForPositionInformation:]): 50 (-[WKActionSheetAssistant contextMenuInteraction:configurationForMenuAtLocation:]): 51 (-[WKActionSheetAssistant contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]): 52 (-[WKActionSheetAssistant showDataDetectorsSheet]): Deleted. 53 Make it possible to push InteractionInformationAtPosition into WKActionSheetAssistant, 54 instead of having it always pull a fresh one upon invocation, so that we can use the 55 position information passed along with the showDataDetectorsUIForPositionInformation message. 56 57 (-[WKActionSheetAssistant _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]): 58 (-[WKActionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:]): 59 Fix an existing bug where Data Detectors context menus would show extra default actions, 60 by moving our implementation of the -_contextMenuInteraction:overrideSuggestedActionsForConfiguration: 61 delegate here, sharing it with WKContentViewInteraction. 62 63 In a future patch, we should reconsider having three separate UIContextMenuInteractions. 64 65 Also, remove the contextMenuPresentationLocationForActionSheetAssistant: delegate, 66 since it will be wrong in the case of pushed-in position information, and instead 67 use the position information's original hit test point. 68 69 * UIProcess/ios/WKContentViewInteraction.h: 70 * UIProcess/ios/WKContentViewInteraction.mm: 71 (-[WKContentView _showDataDetectorsUI]): 72 (-[WKContentView _showDataDetectorsUIForPositionInformation:]): 73 (-[WKContentView _actionForLongPressFromPositionInformation:]): 74 (-[WKContentView _didNotHandleTapAsClick:]): 75 (-[WKContentView dataDetectionContextForPositionInformation:]): 76 (-[WKContentView dataDetectionContextForActionSheetAssistant:positionInformation:]): 77 (-[WKContentView _showDataDetectorsSheet]): Deleted. 78 (-[WKContentView currentPositionInformation]): Deleted. 79 (-[WKContentView dataDetectionContextForActionSheetAssistant:]): Deleted. 80 Instead of exposing an unnecessary -currentPositionInformation getter on WKActionSheetAssistant, 81 provide it as an argument to the WKActionSheetAssistantDelegate methods that actually need it. 82 83 (-[WKContentView contextMenuPresentationLocationForActionSheetAssistant:]): Deleted. 84 (-[WKContentView _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]): 85 Adopt WKActionSheetAssistant's suggestedActions mechanism so we can share code. 86 87 * UIProcess/ios/WKPDFView.mm: 88 (-[WKPDFView _showActionSheetForURL:atLocation:withAnnotationRect:]): 89 (-[WKPDFView dataDetectionContextForActionSheetAssistant:positionInformation:]): 90 (-[WKPDFView dataDetectionContextForActionSheetAssistant:]): Deleted. 91 Adapt to some WKActionSheetAssistantDelegate changes. 92 93 * WebProcess/WebPage/WebPage.h: 94 * WebProcess/WebPage/ios/WebPageIOS.mm: 95 (WebKit::WebPage::handleTap): 96 (WebKit::WebPage::handleTwoFingerTapAtPoint): 97 (WebKit::WebPage::commitPotentialTap): 98 Remove the aforementioned short-circuiting paths for Data Detectors links. 1 99 2020-05-09 David Kilzer <ddkilzer@apple.com> 2 100 -
trunk/Source/WebKit/UIProcess/PageClient.h
r261320 r261457 413 413 virtual void saveImageToLibrary(Ref<WebCore::SharedBuffer>&&) = 0; 414 414 virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&) = 0; 415 virtual void showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition&) = 0; 415 416 virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) = 0; 416 417 virtual void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel) = 0; -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r261407 r261457 820 820 void requestDocumentEditingContext(WebKit::DocumentEditingContextRequest, CompletionHandler<void(WebKit::DocumentEditingContext)>&&); 821 821 void generateSyntheticEditingCommand(SyntheticEditingCommandType); 822 void showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition&); 822 823 #if ENABLE(DRAG_SUPPORT) 823 824 void didHandleDragStartRequest(bool started); -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r261203 r261457 427 427 UpdateStringForFind(String findString) 428 428 HandleAutocorrectionContext(struct WebKit::WebAutocorrectionContext context) 429 430 ShowDataDetectorsUIForPositionInformation(struct WebKit::InteractionInformationAtPosition information) 429 431 #endif 430 432 -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h
r261232 r261457 169 169 void saveImageToLibrary(Ref<WebCore::SharedBuffer>&&) override; 170 170 void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&) override; 171 void showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition&) override; 171 172 172 173 bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, const FrameInfoData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override; -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
r261320 r261457 948 948 } 949 949 950 void PageClientImpl::showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition& positionInformation) 951 { 952 [m_contentView _showDataDetectorsUIForPositionInformation:positionInformation]; 953 } 954 950 955 } // namespace WebKit 951 956 -
trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h
r261303 r261457 37 37 } 38 38 39 @class UIMenuElement; 39 40 @class UITargetedPreview; 40 41 @class WKActionSheetAssistant; … … 61 62 - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant willStartInteractionWithElement:(_WKActivatedElementInfo *)element; 62 63 - (void)actionSheetAssistantDidStopInteraction:(WKActionSheetAssistant *)assistant; 63 - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant ;64 - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant positionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation; 64 65 - (NSString *)selectedTextForActionSheetAssistant:(WKActionSheetAssistant *)assistant; 65 66 - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant getAlternateURLForImage:(UIImage *)image completion:(void (^)(NSURL *alternateURL, NSDictionary *userInfo))completion; 66 - (CGPoint)contextMenuPresentationLocationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;67 67 #if USE(UICONTEXTMENU) 68 68 - (UITargetedPreview *)createTargetedContextMenuHintForActionSheetAssistant:(WKActionSheetAssistant *)assistant; … … 83 83 - (void)showLinkSheet; 84 84 - (void)showImageSheet; 85 - (void)showDataDetectors Sheet;85 - (void)showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation; 86 86 - (void)cleanupSheet; 87 87 - (void)updateSheetPosition; … … 91 91 - (void)interactionDidStartWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)information; 92 92 - (NSArray *)currentAvailableActionTitles; 93 - ( Optional<WebKit::InteractionInformationAtPosition>)currentPositionInformation;93 - (NSArray<UIMenuElement *> *)suggestedActionsForContextMenuWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation; 94 94 @end 95 95 -
trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm
r261303 r261457 661 661 #endif 662 662 663 - (void)showDataDetectors Sheet663 - (void)showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation 664 664 { 665 665 #if ENABLE(DATA_DETECTION) … … 667 667 return; 668 668 669 if (![self synchronouslyRetrievePositionInformation]) 670 return; 669 _positionInformation = positionInformation; 671 670 672 671 if (!WebCore::DataDetection::canBePresentedByDataDetectors(_positionInformation->url)) … … 681 680 NSString *textAtSelection = nil; 682 681 683 if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant: )])684 context = [_delegate dataDetectionContextForActionSheetAssistant:self ];682 if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:positionInformation:)]) 683 context = [_delegate dataDetectionContextForActionSheetAssistant:self positionInformation:*_positionInformation]; 685 684 if ([_delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)]) 686 685 textAtSelection = [_delegate selectedTextForActionSheetAssistant:self]; … … 697 696 return; 698 697 699 #if ENABLE(DATA_DETECTION) && USE(UICONTEXTMENU) && HAVE(UICONTEXTMENU_LOCATION) 700 auto delegate = _delegate.get(); 701 if ([delegate respondsToSelector:@selector(contextMenuPresentationLocationForActionSheetAssistant:)]) { 702 [self ensureContextMenuInteraction]; 703 [_dataDetectorContextMenuInteraction _presentMenuAtLocation:[delegate contextMenuPresentationLocationForActionSheetAssistant:self]]; 704 return; 705 } 706 #endif 707 698 #if USE(UICONTEXTMENU) && HAVE(UICONTEXTMENU_LOCATION) 699 [self ensureContextMenuInteraction]; 700 [_dataDetectorContextMenuInteraction _presentMenuAtLocation:_positionInformation->request.point]; 701 #else 708 702 NSMutableArray *elementActions = [NSMutableArray array]; 709 703 for (NSUInteger actionNumber = 0; actionNumber < [dataDetectorsActions count]; actionNumber++) { … … 724 718 [self cleanupSheet]; 725 719 #endif 720 #endif // ENABLE(DATA_DETECTION) 726 721 } 727 722 … … 733 728 NSString *textAtSelection = nil; 734 729 735 if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant: )])736 context = [_delegate dataDetectionContextForActionSheetAssistant:self ];730 if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:positionInformation:)]) 731 context = [_delegate dataDetectionContextForActionSheetAssistant:self positionInformation:*_positionInformation]; 737 732 if ([_delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)]) 738 733 textAtSelection = [_delegate selectedTextForActionSheetAssistant:self]; … … 740 735 NSDictionary *newContext = nil; 741 736 DDResultRef ddResult = [controller resultForURL:_positionInformation->url identifier:_positionInformation->dataDetectorIdentifier selectedText:textAtSelection results:_positionInformation->dataDetectorResults.get() context:context extendedContext:&newContext]; 742 743 737 744 738 CGRect sourceRect; … … 759 753 { 760 754 auto delegate = _delegate.get(); 761 CGPoint center = CGPointZero;755 CGPoint center = _positionInformation->request.point; 762 756 763 757 if ([delegate respondsToSelector:@selector(createTargetedContextMenuHintForActionSheetAssistant:)]) 764 758 return [delegate createTargetedContextMenuHintForActionSheetAssistant:self]; 765 759 766 if ([delegate respondsToSelector:@selector(contextMenuPresentationLocationForActionSheetAssistant:)])767 center = [delegate contextMenuPresentationLocationForActionSheetAssistant:self];768 760 RetainPtr<UIPreviewParameters> unusedPreviewParameters = adoptNS([[UIPreviewParameters alloc] init]); 769 761 RetainPtr<UIPreviewTarget> previewTarget = adoptNS([[UIPreviewTarget alloc] initWithContainer:_view.getAutoreleased() center:center]); … … 785 777 }]; 786 778 } 779 780 static NSArray<UIMenuElement *> *menuElementsFromDefaultActions(RetainPtr<NSArray> defaultElementActions, RetainPtr<_WKActivatedElementInfo> elementInfo) 781 { 782 if (![defaultElementActions count]) 783 return nil; 784 785 auto actions = [NSMutableArray arrayWithCapacity:[defaultElementActions count]]; 786 for (_WKElementAction *elementAction in defaultElementActions.get()) 787 [actions addObject:[elementAction uiActionForElementInfo:elementInfo.get()]]; 788 789 return actions; 790 } 791 792 - (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration 793 { 794 if (!_positionInformation) 795 return nil; 796 return [self suggestedActionsForContextMenuWithPositionInformation:*_positionInformation]; 797 } 798 799 - (NSArray<UIMenuElement *> *)suggestedActionsForContextMenuWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation 800 { 801 auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithInteractionInformationAtPosition:positionInformation userInfo:nil]); 802 RetainPtr<NSArray<_WKElementAction *>> defaultActionsFromAssistant = positionInformation.isLink ? [self defaultActionsForLinkSheet:elementInfo.get()] : [self defaultActionsForImageSheet:elementInfo.get()]; 803 return menuElementsFromDefaultActions(defaultActionsFromAssistant, elementInfo); 804 805 } 806 787 807 #endif 788 808 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r261303 r261457 531 531 - (WKFormInputSession *)_formInputSession; 532 532 - (void)_didChangeWebViewEditability; 533 - (NSDictionary *)dataDetectionContextForPositionInformation:(WebKit::InteractionInformationAtPosition)positionInformation; 533 - (NSDictionary *)dataDetectionContextForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation; 534 - (void)_showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation; 534 535 535 536 - (void)willFinishIgnoringCalloutBarFadeAfterPerformingAction; … … 550 551 - (void)_requestDOMPasteAccessWithElementRect:(const WebCore::IntRect&)elementRect originIdentifier:(const String&)originIdentifier completionHandler:(CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&)completionHandler; 551 552 552 @property (nonatomic, readonly) WebKit::InteractionInformationAtPosition currentPositionInformation;553 553 - (void)doAfterPositionInformationUpdate:(void (^)(WebKit::InteractionInformationAtPosition))action forRequest:(WebKit::InteractionInformationRequest)request; 554 554 - (BOOL)ensurePositionInformationIsUpToDate:(WebKit::InteractionInformationRequest)request; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r261361 r261457 2149 2149 } 2150 2150 2151 - (void)_showDataDetectorsSheet 2152 { 2153 [_actionSheetAssistant showDataDetectorsSheet]; 2151 - (void)_showDataDetectorsUI 2152 { 2153 [self _showDataDetectorsUIForPositionInformation:_positionInformation]; 2154 } 2155 2156 - (void)_showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation 2157 { 2158 [_actionSheetAssistant showDataDetectorsUIForPositionInformation:positionInformation]; 2154 2159 } 2155 2160 … … 2168 2173 #if ENABLE(DATA_DETECTION) 2169 2174 if (WebCore::DataDetection::canBePresentedByDataDetectors(positionInformation.url)) 2170 return @selector(_showDataDetectors Sheet);2175 return @selector(_showDataDetectorsUI); 2171 2176 #endif 2172 2177 return @selector(_showLinkSheet); … … 2181 2186 { 2182 2187 return [self _actionForLongPressFromPositionInformation:_positionInformation]; 2183 }2184 2185 - (WebKit::InteractionInformationAtPosition)currentPositionInformation2186 {2187 return _positionInformation;2188 2188 } 2189 2189 … … 2723 2723 { 2724 2724 [self _resetInputViewDeferral]; 2725 2726 // FIXME: we should also take into account whether or not the UI delegate2727 // has handled this notification.2728 #if ENABLE(DATA_DETECTION)2729 if (_hasValidPositionInformation && point == _positionInformation.request.point && _positionInformation.isDataDetectorLink) {2730 [self _showDataDetectorsSheet];2731 return;2732 }2733 #endif2734 2725 2735 2726 if (!_isDoubleTapPending) … … 6905 6896 } 6906 6897 6907 - (NSDictionary *)dataDetectionContextForPositionInformation:( WebKit::InteractionInformationAtPosition)positionInformation6898 - (NSDictionary *)dataDetectionContextForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation 6908 6899 { 6909 6900 RetainPtr<NSMutableDictionary> context; … … 6934 6925 } 6935 6926 6936 - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant 6937 { 6938 return [self dataDetectionContextForPositionInformation: assistant.currentPositionInformation.valueOr(_positionInformation)];6927 - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant positionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation 6928 { 6929 return [self dataDetectionContextForPositionInformation:positionInformation]; 6939 6930 } 6940 6931 … … 6953 6944 } else 6954 6945 completion(nil, nil); 6955 }6956 6957 - (CGPoint)contextMenuPresentationLocationForActionSheetAssistant:(WKActionSheetAssistant *)assistant6958 {6959 return [self lastInteractionLocation];6960 6946 } 6961 6947 … … 9212 9198 - (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration 9213 9199 { 9214 if (_contextMenuActionProviderDelegateNeedsOverride) {9215 auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithInteractionInformationAtPosition:_positionInformation userInfo:nil]);9216 RetainPtr<NSArray<_WKElementAction *>> defaultActionsFromAssistant = _positionInformation.isLink ? [_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()] : [_actionSheetAssistant defaultActionsForImageSheet:elementInfo.get()];9217 return menuElementsFromDefaultActions(defaultActionsFromAssistant, elementInfo);9218 }9219 9200 // If we're here we're in the legacy path, which ignores the suggested actions anyway. 9220 return nil; 9201 if (!_contextMenuActionProviderDelegateNeedsOverride) 9202 return nil; 9203 9204 return [_actionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:_positionInformation]; 9221 9205 } 9222 9206 -
trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm
r261168 r261457 486 486 487 487 _positionInformation = WTFMove(positionInformation); 488 488 489 #if ENABLE(DATA_DETECTION) 489 if (WebCore::DataDetection::canBePresentedByDataDetectors(_positionInformation.url)) 490 [_actionSheetAssistant showDataDetectorsSheet]; 491 else 490 if (WebCore::DataDetection::canBePresentedByDataDetectors(_positionInformation.url)) { 491 [_actionSheetAssistant showDataDetectorsUIForPositionInformation:positionInformation]; 492 return; 493 } 492 494 #endif 493 [_actionSheetAssistant showLinkSheet]; 495 496 [_actionSheetAssistant showLinkSheet]; 494 497 } 495 498 … … 583 586 } 584 587 585 - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant 588 - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant positionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation 586 589 { 587 590 auto webView = _webView.getAutoreleased(); -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r261299 r261457 1622 1622 } 1623 1623 1624 void WebPageProxy::showDataDetectorsUIForPositionInformation(const InteractionInformationAtPosition& positionInfo) 1625 { 1626 pageClient().showDataDetectorsUIForPositionInformation(positionInfo); 1627 } 1628 1629 1624 1630 } // namespace WebKit 1625 1631 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
r261398 r261457 186 186 187 187 bool shouldUseMouseEventForSelection(const WebCore::PlatformMouseEvent&) final; 188 189 bool showDataDetectorsUIForElement(const WebCore::Element&, const WebCore::Event&) final; 188 190 #endif 189 191 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm
r260820 r261457 31 31 #import "DrawingArea.h" 32 32 #import "EditableImageControllerMessages.h" 33 #import "InteractionInformationAtPosition.h" 34 #import "InteractionInformationRequest.h" 33 35 #import "UIKitSPI.h" 34 36 #import "WebCoreArgumentCoders.h" … … 40 42 #import <WebCore/ContentChangeObserver.h> 41 43 #import <WebCore/Icon.h> 44 #import <WebCore/MouseEvent.h> 42 45 #import <WebCore/NotImplemented.h> 43 46 #import <WebCore/PlatformMouseEvent.h> … … 194 197 } 195 198 199 bool WebChromeClient::showDataDetectorsUIForElement(const Element& element, const Event& event) 200 { 201 if (!event.isMouseEvent()) 202 return false; 203 204 // FIXME: Ideally, we would be able to generate InteractionInformationAtPosition without re-hit-testing the element. 205 auto& mouseEvent = downcast<MouseEvent>(event); 206 auto positionInformation = m_page.positionInformation(InteractionInformationRequest { roundedIntPoint(mouseEvent.locationInRootViewCoordinates()) }); 207 m_page.send(Messages::WebPageProxy::ShowDataDetectorsUIForPositionInformation(positionInformation)); 208 return true; 209 } 210 196 211 } // namespace WebKit 197 212 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r261398 r261457 1293 1293 static WebCore::IntRect absoluteInteractionBoundsForElement(const WebCore::Element&); 1294 1294 static WebCore::IntRect rootViewInteractionBoundsForElement(const WebCore::Element&); 1295 1296 InteractionInformationAtPosition positionInformation(const InteractionInformationRequest&); 1297 1295 1298 #endif // PLATFORM(IOS_FAMILY) 1296 1299 … … 1369 1372 1370 1373 void sendPositionInformation(InteractionInformationAtPosition&&); 1371 InteractionInformationAtPosition positionInformation(const InteractionInformationRequest&);1372 1374 RefPtr<ShareableBitmap> shareableBitmapSnapshotForNode(WebCore::Element&); 1373 1375 WebAutocorrectionContext autocorrectionContext(); -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r261398 r261457 870 870 if (!frameRespondingToClick || lastLayerTreeTransactionId < WebFrame::fromCoreFrame(*frameRespondingToClick)->firstLayerTreeTransactionIDAfterDidCommitLoad()) 871 871 send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint)); 872 #if ENABLE(DATA_DETECTION)873 else if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {874 InteractionInformationRequest request(adjustedIntPoint);875 requestPositionInformation(request);876 send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint));877 }878 #endif879 872 else 880 873 handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers); … … 1078 1071 } 1079 1072 sendTapHighlightForNodeIfNecessary(requestID, nodeRespondingToClick); 1080 #if ENABLE(DATA_DETECTION) 1081 if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) { 1082 InteractionInformationRequest request(roundedIntPoint(adjustedPoint)); 1083 requestPositionInformation(request); 1084 send(Messages::WebPageProxy::DidNotHandleTapAsClick(roundedIntPoint(adjustedPoint))); 1085 } else 1086 #endif 1087 completeSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, WebCore::TwoFingerTap); 1073 completeSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, WebCore::TwoFingerTap); 1088 1074 } 1089 1075 … … 1169 1155 } 1170 1156 1171 if (m_potentialTapNode == nodeRespondingToClick) { 1172 #if ENABLE(DATA_DETECTION) 1173 if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) { 1174 InteractionInformationRequest request(roundedIntPoint(m_potentialTapLocation)); 1175 requestPositionInformation(request); 1176 commitPotentialTapFailed(); 1177 } else 1178 #endif 1179 handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, pointerId); 1180 } else 1157 if (m_potentialTapNode == nodeRespondingToClick) 1158 handleSyntheticClick(*nodeRespondingToClick, adjustedPoint, modifiers, pointerId); 1159 else 1181 1160 commitPotentialTapFailed(); 1182 1161 -
trunk/Source/WebKitLegacy/ios/ChangeLog
r260725 r261457 1 2020-05-10 Tim Horton <timothy_horton@apple.com> 2 3 Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it 4 https://bugs.webkit.org/show_bug.cgi?id=211686 5 <rdar://problem/57941589> 6 7 Reviewed by Wenson Hsieh. 8 9 * WebCoreSupport/WebChromeClientIOS.h: 10 1 11 2020-04-11 Darin Adler <darin@apple.com> 2 12 -
trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h
r253636 r261457 98 98 RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) final; 99 99 100 bool showDataDetectorsUIForElement(const WebCore::Element&, const WebCore::Event&) final { return false; } 101 100 102 #if ENABLE(ORIENTATION_EVENTS) 101 103 int deviceOrientation() const final;
Note: See TracChangeset
for help on using the changeset viewer.