Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
FlutterTouchInterceptingView Class Reference

#include <FlutterPlatformViews_Internal.h>

Inheritance diagram for FlutterTouchInterceptingView:

Instance Methods

(instancetype) - initWithEmbeddedView:platformViewsController:gestureRecognizersBlockingPolicy:
 
(void) - releaseGesture
 
(void) - blockGesture
 
(UIView *) - embeddedView
 
(id- accessibilityContainer
 

Properties

id flutterAccessibilityContainer
 
FlutterPlatformViewGestureRecognizersBlockingPolicy blockingPolicy
 

Detailed Description

Definition at line 525 of file FlutterPlatformViews.mm.

Method Documentation

◆ accessibilityContainer

- (id) accessibilityContainer

Provided by category FlutterTouchInterceptingView(Tests).

◆ blockGesture

- (void) blockGesture

Definition at line 522 of file FlutterPlatformViews.mm.

644 {
645 switch (_blockingPolicy) {
647 // No-op. Handled by hit test.
648 break;
650 // We block all other gesture recognizers immediately in this policy.
651 self.delayingRecognizer.state = UIGestureRecognizerStateEnded;
652
653 // On iOS 18.2, WKWebView's internal recognizer likely caches the old state of its blocking
654 // recognizers (i.e. delaying recognizer), resulting in non-tappable links. See
655 // https://github.com/flutter/flutter/issues/158961. Removing and adding back the delaying
656 // recognizer solves the problem, possibly because UIKit notifies all the recognizers related
657 // to (blocking or blocked by) this recognizer. It is not possible to inject this workaround
658 // from the web view plugin level. Right now we only observe this issue for
659 // FlutterPlatformViewGestureRecognizersBlockingPolicyEager, but we should try it if a similar
660 // issue arises for the other policy.
661 if (@available(iOS 26.0, *)) {
662 // This performs a nested DFS, with the outer one searching for any web view, and the inner
663 // one searching for a TouchEventsGestureRecognizer inside the web view. Once found, disable
664 // and immediately reenable it to reset its state.
665 // TODO(hellohuanlin): remove this flag after it is battle tested.
666 NSNumber* isWorkaroundDisabled =
667 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTDisableWebViewGestureReset"];
668 if (!isWorkaroundDisabled.boolValue) {
669 [self searchAndFixWebView:self.embeddedView];
670 }
671 } else if (@available(iOS 18.2, *)) {
672 // The 1P web view plugin provides a WKWebView itself as the platform view. However, some 3P
673 // plugins provide wrappers of WKWebView instead, and AdMob banner has a WKWebView at
674 // depth 7. So we perform DFS to search the view hierarchy.
675 if ([self containsWebView:self.embeddedView]) {
676 [self removeGestureRecognizer:self.delayingRecognizer];
677 [self addGestureRecognizer:self.delayingRecognizer];
678 }
679 }
680
681 break;
683 if (self.delayingRecognizer.touchedEndedWithoutBlocking) {
684 // If touchesEnded of the `DelayingGesureRecognizer` has been already invoked,
685 // we want to set the state of the `DelayingGesureRecognizer` to
686 // `UIGestureRecognizerStateEnded` as soon as possible.
687 self.delayingRecognizer.state = UIGestureRecognizerStateEnded;
688 } else {
689 // If touchesEnded of the `DelayingGesureRecognizer` has not been invoked,
690 // We will set a flag to notify the `DelayingGesureRecognizer` to set the state to
691 // `UIGestureRecognizerStateEnded` when touchesEnded is called.
692 self.delayingRecognizer.shouldEndInNextTouchesEnded = YES;
693 }
694 break;
695 default:
696 break;
697 }
698}
@ FlutterPlatformViewGestureRecognizersBlockingPolicyEager
@ FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded
@ FlutterPlatformViewGestureRecognizersBlockingPolicyDoNotBlockGesture

◆ embeddedView

- (UIView *) embeddedView

◆ initWithEmbeddedView:platformViewsController:gestureRecognizersBlockingPolicy:

- (instancetype) initWithEmbeddedView: (UIView*)  embeddedView
platformViewsController: (FlutterPlatformViewsController*)  platformViewsController
gestureRecognizersBlockingPolicy: (FlutterPlatformViewGestureRecognizersBlockingPolicy blockingPolicy 

Definition at line 522 of file FlutterPlatformViews.mm.

526 :(UIView*)embeddedView
527 platformViewsController:(FlutterPlatformViewsController*)platformViewsController
528 gestureRecognizersBlockingPolicy:
530 self = [super initWithFrame:embeddedView.frame];
531 if (self) {
532 self.multipleTouchEnabled = YES;
533 _embeddedView = embeddedView;
534 _platformViewsController = platformViewsController;
535 _flutterViewController = platformViewsController.flutterViewController;
536 embeddedView.autoresizingMask =
537 (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
538
539 [self addSubview:embeddedView];
540
541 ForwardingGestureRecognizer* forwardingRecognizer =
542 [[ForwardingGestureRecognizer alloc] initWithTarget:self
543 platformViewsController:platformViewsController];
544
545 _delayingRecognizer =
546 [[FlutterDelayingGestureRecognizer alloc] initWithTarget:self
547 action:nil
548 forwardingRecognizer:forwardingRecognizer];
549 _blockingPolicy = blockingPolicy;
550
551 // For hit test, don't block gestures using delaying recognizer. However, we still
552 // forward touches so Flutter can process it in its gesture arena (e.g. dismiss a
553 // drop-down menu when tapping outside of the menu but inside the platform view).
555 [self addGestureRecognizer:_delayingRecognizer];
556 }
557 [self addGestureRecognizer:forwardingRecognizer];
558 }
559 return self;
560}
UIViewController< FlutterViewResponder > * _flutterViewController
FlutterPlatformViewGestureRecognizersBlockingPolicy
FlutterPlatformViewGestureRecognizersBlockingPolicy blockingPolicy
UIViewController< FlutterViewResponder > *_Nullable flutterViewController
The flutter view controller.
instancetype initWithFrame

◆ releaseGesture

- (void) releaseGesture

Definition at line 522 of file FlutterPlatformViews.mm.

576 {
577 self.delayingRecognizer.state = UIGestureRecognizerStateFailed;
578}

Property Documentation

◆ blockingPolicy

- (FlutterPlatformViewGestureRecognizersBlockingPolicy) blockingPolicy
readnonatomicassign

Definition at line 159 of file FlutterPlatformViews_Internal.h.

◆ flutterAccessibilityContainer

- (id) flutterAccessibilityContainer
readwritenonatomicretain

Definition at line 158 of file FlutterPlatformViews_Internal.h.


The documentation for this class was generated from the following files: