Changeset 242801 in webkit
- Timestamp:
- Mar 12, 2019, 10:41:59 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
-
WebCore/PAL/ChangeLog (modified) (1 diff)
-
WebCore/PAL/pal/spi/ios/DataDetectorsUISPI.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/ios/WKActionSheetAssistant.h (modified) (1 diff)
-
WebKit/UIProcess/ios/WKActionSheetAssistant.mm (modified) (13 diffs)
-
WebKit/UIProcess/ios/WKContentViewInteraction.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/PAL/ChangeLog
r242776 r242801 1 2019-03-12 Jennifer Moore <jennifer.moore@apple.com> 2 3 Check whether to launch a default action instead of action sheet 4 https://bugs.webkit.org/show_bug.cgi?id=195225 5 <rdar://problem/47715544> 6 7 Reviewed by Daniel Bates. 8 9 Add new SPI declarations. 10 11 * pal/spi/ios/DataDetectorsUISPI.h: 12 1 13 2019-03-11 Ross Kirsling <ross.kirsling@sony.com> 2 14 -
trunk/Source/WebCore/PAL/pal/spi/ios/DataDetectorsUISPI.h
r237266 r242801 63 63 #endif 64 64 65 @interface DDDetectionController (Staging_48014858) 66 - (NSString *)titleForURL:(NSURL *)url results:(NSArray *)results context:(NSDictionary *)context; 67 - (DDAction *)defaultActionForURL:(NSURL *)url results:(NSArray *)results context:(NSDictionary *)context; 68 - (void)interactionDidStartForURL:(NSURL *)url; 69 - (BOOL)shouldImmediatelyLaunchDefaultActionForURL:(NSURL *)url; 70 @end 71 65 72 SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsUI) 66 73 SOFT_LINK_CLASS(DataDetectorsUI, DDDetectionController) -
trunk/Source/WebKit/ChangeLog
r242798 r242801 1 2019-03-12 Jennifer Moore <jennifer.moore@apple.com> 2 3 Check whether to launch a default action instead of action sheet 4 https://bugs.webkit.org/show_bug.cgi?id=195225 5 <rdar://problem/47715544> 6 7 Reviewed by Daniel Bates and Tim Horton. 8 9 Notify DataDetectors at the start of a touch on a link, and check whether to immediately 10 launch the default action instead of an action sheet. 11 12 * UIProcess/ios/WKActionSheetAssistant.h: 13 * UIProcess/ios/WKActionSheetAssistant.mm: 14 (-[WKActionSheetAssistant interactionDidStart]): 15 (-[WKActionSheetAssistant _createSheetWithElementActions:defaultTitle:showLinkTitle:]): 16 (-[WKActionSheetAssistant showImageSheet]): 17 (-[WKActionSheetAssistant showLinkSheet]): 18 (-[WKActionSheetAssistant showDataDetectorsSheet]): 19 (-[WKActionSheetAssistant _createSheetWithElementActions:showLinkTitle:]): Deleted. 20 * UIProcess/ios/WKContentViewInteraction.mm: 21 (-[WKContentView _webTouchEventsRecognized:]): 22 : 1 23 2019-03-12 Zalan Bujtas <zalan@apple.com> 2 24 -
trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h
r239427 r242801 80 80 - (RetainPtr<NSArray>)defaultActionsForImageSheet:(_WKActivatedElementInfo *)elementInfo; 81 81 - (BOOL)isShowingSheet; 82 - (void)interactionDidStartWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)information; 82 83 - (NSArray *)currentAvailableActionTitles; 83 84 @end -
trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm
r240798 r242801 167 167 } 168 168 169 - (_WKElementAction *)_elementActionForDDAction:(DDAction *)action 170 { 171 auto retainedSelf = retainPtr(self); 172 _WKElementAction *elementAction = [_WKElementAction elementActionWithTitle:action.localizedName actionHandler:^(_WKActivatedElementInfo *actionInfo) { 173 retainedSelf->_isPresentingDDUserInterface = action.hasUserInterface; 174 [[getDDDetectionControllerClass() sharedController] performAction:action fromAlertController:retainedSelf->_interactionSheet.get() interactionDelegate:retainedSelf.get()]; 175 }]; 176 elementAction.dismissalHandler = ^BOOL { 177 return !action.hasUserInterface; 178 }; 179 return elementAction; 180 } 181 169 182 static const CGFloat presentationElementRectPadding = 15; 170 183 … … 268 281 { 269 282 return _interactionSheet != nil; 283 } 284 285 - (void)interactionDidStartWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)information 286 { 287 #if ENABLE(DATA_DETECTION) 288 if (!_delegate) 289 return; 290 291 if (!WebCore::DataDetection::canBePresentedByDataDetectors(information.url)) 292 return; 293 294 NSURL *targetURL = information.url; 295 if (!targetURL) 296 return; 297 298 auto *controller = [getDDDetectionControllerClass() sharedController]; 299 if ([controller respondsToSelector:@selector(interactionDidStartForURL:)]) 300 [controller interactionDidStartForURL:targetURL]; 301 #endif 270 302 } 271 303 … … 283 315 } 284 316 285 - (void)_createSheetWithElementActions:(NSArray *)actions showLinkTitle:(BOOL)showLinkTitle317 - (void)_createSheetWithElementActions:(NSArray *)actions defaultTitle:(NSString *)defaultTitle showLinkTitle:(BOOL)showLinkTitle 286 318 { 287 319 auto delegate = _delegate.get(); … … 310 342 titleIsURL = YES; 311 343 } 312 } else 344 } else if (defaultTitle) 345 titleString = defaultTitle; 346 else 313 347 titleString = _positionInformation->title; 314 348 … … 371 405 } 372 406 373 [self _createSheetWithElementActions:actions.get() showLinkTitle:YES];407 [self _createSheetWithElementActions:actions.get() defaultTitle:nil showLinkTitle:YES]; 374 408 if (!_interactionSheet) 375 409 return; … … 517 551 { 518 552 ASSERT(!_elementInfo); 519 520 auto delegate = _delegate.get(); 521 if (!delegate) 553 if (!_delegate) 522 554 return; 523 555 … … 533 565 534 566 auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:_positionInformation->request.point title:_positionInformation->title ID:_positionInformation->idAttribute rect:_positionInformation->bounds image:_positionInformation->image.get()]); 535 if ([ delegate respondsToSelector:@selector(actionSheetAssistant:showCustomSheetForElement:)] && [delegate actionSheetAssistant:self showCustomSheetForElement:elementInfo.get()]) {567 if ([_delegate respondsToSelector:@selector(actionSheetAssistant:showCustomSheetForElement:)] && [_delegate actionSheetAssistant:self showCustomSheetForElement:elementInfo.get()]) { 536 568 _needsLinkIndicator = NO; 537 569 return; … … 540 572 auto defaultActions = [self defaultActionsForLinkSheet:elementInfo.get()]; 541 573 542 RetainPtr<NSArray> actions = [ delegate actionSheetAssistant:self decideActionsForElement:elementInfo.get() defaultActions:WTFMove(defaultActions)];574 RetainPtr<NSArray> actions = [_delegate actionSheetAssistant:self decideActionsForElement:elementInfo.get() defaultActions:WTFMove(defaultActions)]; 543 575 544 576 if (![actions count]) { … … 547 579 } 548 580 549 [self _createSheetWithElementActions:actions.get() showLinkTitle:YES];581 [self _createSheetWithElementActions:actions.get() defaultTitle:nil showLinkTitle:YES]; 550 582 if (!_interactionSheet) { 551 583 _needsLinkIndicator = NO; … … 562 594 { 563 595 #if ENABLE(DATA_DETECTION) 564 auto delegate = _delegate.get(); 565 if (!delegate) 596 if (!_delegate) 566 597 return; 567 598 … … 581 612 RetainPtr<NSMutableDictionary> extendedContext; 582 613 583 if ([ delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)])584 context = [ delegate dataDetectionContextForActionSheetAssistant:self];585 if ([ delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)])586 textAtSelection = [ delegate selectedTextForActionSheetAssistant:self];614 if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)]) 615 context = [_delegate dataDetectionContextForActionSheetAssistant:self]; 616 if ([_delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)]) 617 textAtSelection = [_delegate selectedTextForActionSheetAssistant:self]; 587 618 if (!_positionInformation->textBefore.isEmpty() || !_positionInformation->textAfter.isEmpty()) { 588 619 extendedContext = adoptNS([@{ … … 595 626 context = extendedContext.get(); 596 627 } 628 629 if ([controller respondsToSelector:@selector(shouldImmediatelyLaunchDefaultActionForURL:)] && [controller shouldImmediatelyLaunchDefaultActionForURL:targetURL]) { 630 auto action = [controller defaultActionForURL:targetURL results:nil context:context]; 631 auto *elementAction = [self _elementActionForDDAction:action]; 632 [elementAction _runActionWithElementInfo:_elementInfo.get() forActionSheetAssistant:self]; 633 return; 634 } 635 597 636 NSArray *dataDetectorsActions = [controller actionsForURL:targetURL identifier:_positionInformation->dataDetectorIdentifier selectedText:textAtSelection results:_positionInformation->dataDetectorResults.get() context:context]; 598 637 if ([dataDetectorsActions count] == 0) … … 602 641 for (NSUInteger actionNumber = 0; actionNumber < [dataDetectorsActions count]; actionNumber++) { 603 642 DDAction *action = [dataDetectorsActions objectAtIndex:actionNumber]; 604 RetainPtr<WKActionSheetAssistant> retainedSelf = self; 605 _WKElementAction *elementAction = [_WKElementAction elementActionWithTitle:[action localizedName] actionHandler:^(_WKActivatedElementInfo *actionInfo) { 606 retainedSelf.get()->_isPresentingDDUserInterface = action.hasUserInterface; 607 [[getDDDetectionControllerClass() sharedController] performAction:action fromAlertController:retainedSelf.get()->_interactionSheet.get() interactionDelegate:retainedSelf.get()]; 608 }]; 609 elementAction.dismissalHandler = ^{ 610 return (BOOL)!action.hasUserInterface; 611 }; 643 auto *elementAction = [self _elementActionForDDAction:action]; 612 644 [elementActions addObject:elementAction]; 613 645 } 614 646 615 [self _createSheetWithElementActions:elementActions showLinkTitle:NO]; 647 NSString *title = [controller titleForURL:targetURL results:nil context:context]; 648 [self _createSheetWithElementActions:elementActions defaultTitle:title showLinkTitle:NO]; 616 649 if (!_interactionSheet) 617 650 return; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r242796 r242801 1221 1221 [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture]; 1222 1222 _layerTreeTransactionIdAtLastTouchStart = downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).lastCommittedLayerTreeTransactionID(); 1223 1224 [self doAfterPositionInformationUpdate:[assistant = WeakObjCPtr<WKActionSheetAssistant>(_actionSheetAssistant.get())] (WebKit::InteractionInformationAtPosition information) { 1225 [assistant interactionDidStartWithPositionInformation:information]; 1226 } forRequest:WebKit::InteractionInformationRequest(WebCore::IntPoint(_lastInteractionLocation))]; 1223 1227 } 1224 1228
Note:
See TracChangeset
for help on using the changeset viewer.