Changeset 196679 in webkit
- Timestamp:
- Feb 16, 2016 7:27:05 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r196674 r196679 1 2016-02-16 Dean Jackson <dino@apple.com> 2 3 Allow double tap to zoom in fast-click pages 4 https://bugs.webkit.org/show_bug.cgi?id=154318 5 <rdar://problem/24223767> 6 7 Reviewed by Simon Fraser and Benjamin Poulain. 8 9 Most of the patch comes from Jon Lee. 10 11 Our fast-click algorithm exposed a number of cases where 12 people missed the double-tap-to-zoom behaviour. In particular, 13 when you double tap on a large body of text, typical in 14 blogs and articles. 15 16 This patch enhances the algorithm to have a parallel 17 double-tap gesture recognizer in the situations where 18 fast-click is enabled. This new gesture recongizer does 19 not cause the single tap to block for 350ms, so clicks 20 are still dispatched fast. If it fires, we already have 21 some information about whether we have a pending double 22 tap, based on the first tap. 23 24 * UIProcess/ios/PageClientImplIOS.mm: 25 (WebKit::PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary): Remove the optimization 26 that only told the content view to disable on pages that allowed double taps. We now allow 27 them even on fast click pages. 28 29 * UIProcess/ios/WKContentViewInteraction.h: Add the new UITapGestureRecognizer for double taps 30 in fast click pages. This is called nonBlockingDoubleTapGestureRecognizer because, unlike 31 the existing DoubleTapGestureRecognizer, this one does not force the singleTapRecognizer 32 to wait. 33 * UIProcess/ios/WKContentViewInteraction.mm: 34 (-[WKContentView setupInteraction]): Set up the new UITapGestureRecognizer. 35 (-[WKContentView cleanupInteraction]): And remove it when we're done. 36 (-[WKContentView _removeDefaultGestureRecognizers]): Ditto. 37 (-[WKContentView _addDefaultGestureRecognizers]): 38 (-[WKContentView _inspectorNodeSearchRecognized:]): Something happened, we are no longer in 39 a potential double tap situation. 40 (-[WKContentView _disableDoubleTapGesturesDuringTapIfNecessary:]): Remove the check 41 for potential tap in progress. 42 (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]): 43 (-[WKContentView gestureRecognizerShouldBegin:]): 44 (-[WKContentView _highlightLongPressRecognized:]): Again, something happened, so we are 45 no longer in a double tap situation. 46 (-[WKContentView _longPressRecognized:]): Ditto. 47 (-[WKContentView _singleTapRecognized:]): Ditto. 48 (-[WKContentView _doubleTapRecognized:]): Ditto. 49 (-[WKContentView _resetIsDoubleTapPending]): 50 (-[WKContentView _fastDoubleTapRecognized:]): We're now pending a double tap. 51 (-[WKContentView _twoFingerDoubleTapRecognized:]): 52 (-[WKContentView _didNotHandleTapAsClick:]): If we get here and we have a pending 53 double tap, then trigger a zoom operation. 54 (-[WKContentView _setDoubleTapGesturesEnabled:]): 55 1 56 2016-02-16 Alex Christensen <achristensen@webkit.org> 2 57 -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r195769 r196679 262 262 void PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) 263 263 { 264 if (!m_webView._allowsDoubleTapGestures)265 return;266 267 264 [m_contentView _disableDoubleTapGesturesDuringTapIfNecessary:requestID]; 268 265 } -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
r196037 r196679 103 103 RetainPtr<UILongPressGestureRecognizer> _longPressGestureRecognizer; 104 104 RetainPtr<UITapGestureRecognizer> _doubleTapGestureRecognizer; 105 RetainPtr<UITapGestureRecognizer> _nonBlockingDoubleTapGestureRecognizer; 105 106 RetainPtr<UITapGestureRecognizer> _twoFingerDoubleTapGestureRecognizer; 106 107 RetainPtr<WKInspectorNodeSearchGestureRecognizer> _inspectorNodeSearchGestureRecognizer; … … 155 156 BOOL _isTapHighlightIDValid; 156 157 BOOL _potentialTapInProgress; 158 BOOL _isDoubleTapPending; 157 159 BOOL _highlightLongPressCanClick; 158 160 BOOL _hasTapHighlightForPotentialTap; -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r196645 r196679 462 462 [self addGestureRecognizer:_singleTapGestureRecognizer.get()]; 463 463 464 _nonBlockingDoubleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_nonBlockingDoubleTapRecognized:)]); 465 [_nonBlockingDoubleTapGestureRecognizer setNumberOfTapsRequired:2]; 466 [_nonBlockingDoubleTapGestureRecognizer setDelegate:self]; 467 [_nonBlockingDoubleTapGestureRecognizer setEnabled:NO]; 468 [self addGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()]; 469 464 470 [self _createAndConfigureDoubleTapGestureRecognizer]; 465 471 … … 495 501 _smartMagnificationController = std::make_unique<SmartMagnificationController>(self); 496 502 _isExpectingFastSingleTapCommit = NO; 503 _potentialTapInProgress = NO; 504 _isDoubleTapPending = NO; 497 505 _showDebugTapHighlightsForFastClicking = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitShowFastClickDebugTapHighlights"]; 498 506 } … … 533 541 [self removeGestureRecognizer:_doubleTapGestureRecognizer.get()]; 534 542 543 [_nonBlockingDoubleTapGestureRecognizer setDelegate:nil]; 544 [self removeGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()]; 545 535 546 [_twoFingerDoubleTapGestureRecognizer setDelegate:nil]; 536 547 [self removeGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()]; … … 560 571 [self removeGestureRecognizer:_highlightLongPressGestureRecognizer.get()]; 561 572 [self removeGestureRecognizer:_doubleTapGestureRecognizer.get()]; 573 [self removeGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()]; 562 574 [self removeGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()]; 563 575 } … … 569 581 [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()]; 570 582 [self addGestureRecognizer:_doubleTapGestureRecognizer.get()]; 583 [self addGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()]; 571 584 [self addGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()]; 572 585 } … … 733 746 { 734 747 ASSERT(_inspectorNodeSearchEnabled); 748 [self _resetIsDoubleTapPending]; 735 749 736 750 CGPoint point = [gestureRecognizer locationInView:self]; … … 921 935 - (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID 922 936 { 923 if ( !_potentialTapInProgress ||_latestTapID != requestID)937 if (_latestTapID != requestID) 924 938 return; 925 939 … … 1050 1064 return YES; 1051 1065 1066 if (isSamePair(gestureRecognizer, otherGestureRecognizer, _singleTapGestureRecognizer.get(), _nonBlockingDoubleTapGestureRecognizer.get())) 1067 return YES; 1068 1069 if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _nonBlockingDoubleTapGestureRecognizer.get())) 1070 return YES; 1071 1052 1072 if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _previewSecondaryGestureRecognizer.get())) 1053 1073 return YES; … … 1113 1133 if (gestureRecognizer == _highlightLongPressGestureRecognizer 1114 1134 || gestureRecognizer == _doubleTapGestureRecognizer 1135 || gestureRecognizer == _nonBlockingDoubleTapGestureRecognizer 1115 1136 || gestureRecognizer == _twoFingerDoubleTapGestureRecognizer 1116 1137 || gestureRecognizer == _singleTapGestureRecognizer) { … … 1234 1255 { 1235 1256 ASSERT(gestureRecognizer == _highlightLongPressGestureRecognizer); 1257 [self _resetIsDoubleTapPending]; 1236 1258 1237 1259 _lastInteractionLocation = gestureRecognizer.startPoint; … … 1264 1286 { 1265 1287 ASSERT(gestureRecognizer == _longPressGestureRecognizer); 1288 [self _resetIsDoubleTapPending]; 1266 1289 1267 1290 _lastInteractionLocation = gestureRecognizer.startPoint; … … 1288 1311 ASSERT(gestureRecognizer == _singleTapGestureRecognizer); 1289 1312 ASSERT(!_potentialTapInProgress); 1313 [self _resetIsDoubleTapPending]; 1290 1314 1291 1315 _page->potentialTapAtPosition(gestureRecognizer.location, ++_latestTapID); … … 1313 1337 { 1314 1338 [self _cancelInteraction]; 1339 } 1340 1341 - (void)_didNotHandleTapAsClick:(const WebCore::IntPoint&)point 1342 { 1343 // FIXME: we should also take into account whether or not the UI delegate 1344 // has handled this notification. 1345 if (_hasValidPositionInformation && point == _positionInformation.point && _positionInformation.isDataDetectorLink) { 1346 [self _showDataDetectorsSheet]; 1347 return; 1348 } 1349 1350 if (!_isDoubleTapPending) 1351 return; 1352 1353 _smartMagnificationController->handleSmartMagnificationGesture(_lastInteractionLocation); 1354 _isDoubleTapPending = NO; 1315 1355 } 1316 1356 … … 1352 1392 - (void)_doubleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer 1353 1393 { 1394 [self _resetIsDoubleTapPending]; 1354 1395 _lastInteractionLocation = gestureRecognizer.location; 1355 1396 … … 1357 1398 } 1358 1399 1400 - (void)_resetIsDoubleTapPending 1401 { 1402 _isDoubleTapPending = NO; 1403 } 1404 1405 - (void)_nonBlockingDoubleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer 1406 { 1407 _lastInteractionLocation = gestureRecognizer.location; 1408 _isDoubleTapPending = YES; 1409 } 1410 1359 1411 - (void)_twoFingerDoubleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer 1360 1412 { 1413 [self _resetIsDoubleTapPending]; 1361 1414 _lastInteractionLocation = gestureRecognizer.location; 1362 1415 … … 1400 1453 { 1401 1454 _page->clearSelection(); 1402 }1403 1404 - (void)_didNotHandleTapAsClick:(const WebCore::IntPoint&)point1405 {1406 // FIXME: we should also take into account whether or not the UI delegate1407 // has handled this notification.1408 if (_hasValidPositionInformation && point == _positionInformation.point && _positionInformation.isDataDetectorLink)1409 [self _showDataDetectorsSheet];1410 1455 } 1411 1456 … … 2461 2506 2462 2507 [_doubleTapGestureRecognizer setEnabled:enabled]; 2508 [_nonBlockingDoubleTapGestureRecognizer setEnabled:!enabled]; 2509 [self _resetIsDoubleTapPending]; 2463 2510 } 2464 2511
Note: See TracChangeset
for help on using the changeset viewer.