     func contextMenuHelper(_ contextMenuHelper: ContextMenuHelper, didCancelGestureRecognizer: UIGestureRecognizer)
 }
 
-class ContextMenuHelper: NSObject {
+class ContextMenuHelper: NSObject, UIGestureRecognizerDelegate {
     struct Elements {
         let link: URL?
         let image: URL?

            return
        }

        // To prevent the tapped link from proceeding with navigation, "cancel" the native WKWebView
        // `_highlightLongPressRecognizer`. This preserves the original behavior as seen here:
        // https://github.com/WebKit/webkit/blob/d591647baf54b4b300ca5501c21a68455429e182/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm#L1600-L1614
        if let nativeHighlightLongPressRecognizer = self.nativeHighlightLongPressRecognizer,
            nativeHighlightLongPressRecognizer.isEnabled {
            nativeHighlightLongPressRecognizer.isEnabled = false
            nativeHighlightLongPressRecognizer.isEnabled = true
        }

        if let elements = self.elements {
            delegate?.contextMenuHelper(self, didLongPressElements: elements, gestureRecognizer: sender)


        self.tab = tab
    }

    lazy var gestureRecognizer: UILongPressGestureRecognizer = {
        let g = UILongPressGestureRecognizer(target: self, action: #selector(self.longPressGestureDetected))
        g.delegate = self
        return g
    }()

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }

    // BVC KVO events for all changes on the webview will call this. 
    // It is called frequently during a page load (particularly on progress changes and URL changes).
    // As of iOS 12, WKContentView gesture setup is async, but it has been called by the time
    // the webview is ready to load an URL. After this has happened, we can override the gesture.
    func replaceGestureHandlerIfNeeded() {
        if #available(iOS 13.0, *) {
            if !(tab?.webView?.gestureRecognizers?.contains(gestureRecognizer) ?? true) {
                tab?.webView?.addGestureRecognizer(gestureRecognizer)
            }
        } else {
            DispatchQueue.main.async {
                if self.gestureRecognizerWithDescriptionFragment("ContextMenuHelper") == nil {
                    self.replaceWebViewLongPress()
                }
            }
        }
    }

    @available(iOS, obsoleted: 13.0)
    private func replaceWebViewLongPress() {
        // WebKit installs gesture handlers async. If `replaceWebViewLongPress` is called after a wkwebview in most cases a small delay is sufficient
        // See also https://bugs.webkit.org/show_bug.cgi?id=193366
