alloy: views: mac: Add three-finger-swipe navigation gesture support

This adds support for the three-finger-swipe navigation gesture with
Alloy/Views. The default implementation matches the Chrome runtime
and navigates the browser back/forward. We also add an Alloy/Views-
specific client callback in CefBrowserViewDelegate for optional
custom handling of the gesture event.
This commit is contained in:
Nik Pavlov
2023-05-26 09:05:33 +00:00
committed by Marshall Greenblatt
parent 29b5999fd7
commit eb63f9e7ae
11 changed files with 145 additions and 8 deletions

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=e38c41a553d518abcd1b912d32281e99b93c4fd7$
// $hash=94e93810316b74e54eb315d97c6fc6f1cc0c9cc5$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
@@ -120,6 +120,18 @@ typedef struct _cef_browser_view_delegate_t {
///
cef_chrome_toolbar_type_t(CEF_CALLBACK* get_chrome_toolbar_type)(
struct _cef_browser_view_delegate_t* self);
///
/// Called when |browser_view| receives a gesture command. Return true (1) to
/// handle (or disable) a |gesture_command| or false (0) to propagate the
/// gesture to the browser for default handling. This function will only be
/// called with the Alloy runtime. To handle these commands with the Chrome
/// runtime implement cef_command_handler_t::OnChromeCommand instead.
///
int(CEF_CALLBACK* on_gesture_command)(
struct _cef_browser_view_delegate_t* self,
struct _cef_browser_view_t* browser_view,
cef_gesture_command_t gesture_command);
} cef_browser_view_delegate_t;
#ifdef __cplusplus

View File

@@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "ffa07abf4b1f2e4bb228a0ec6b8959b6923236ba"
#define CEF_API_HASH_UNIVERSAL "61103000223ad380e5538c1c57862166d0882752"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "25327dfd50f3fd5aefd523622c42297ff5a02382"
#define CEF_API_HASH_PLATFORM "f6cd8cea55b2198ff51b8a1e47239050f23b5a9e"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "f021e371a8edb71ca9158cffa8c3ada1db2d9955"
#define CEF_API_HASH_PLATFORM "af3e1ed369344bc2d40b5d4da10e582309d14e06"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "f8a8b9758a53e7ba8b259151176b54edefea5471"
#define CEF_API_HASH_PLATFORM "58a17b28e55e61dee2f39a7a05a8cac49d37d031"
#endif
#ifdef __cplusplus

View File

@@ -3606,6 +3606,14 @@ typedef enum {
CEF_DOWNLOAD_INTERRUPT_REASON_CRASH = 50,
} cef_download_interrupt_reason_t;
///
/// Specifies the gesture commands.
///
typedef enum {
CEF_GESTURE_COMMAND_BACK,
CEF_GESTURE_COMMAND_FORWARD,
} cef_gesture_command_t;
#ifdef __cplusplus
}
#endif

View File

@@ -114,6 +114,19 @@ class CefBrowserViewDelegate : public CefViewDelegate {
///
/*--cef(default_retval=CEF_CTT_NONE)--*/
virtual ChromeToolbarType GetChromeToolbarType() { return CEF_CTT_NONE; }
///
/// Called when |browser_view| receives a gesture command. Return true to
/// handle (or disable) a |gesture_command| or false to propagate the gesture
/// to the browser for default handling. This method will only be called with
/// the Alloy runtime. To handle these commands with the Chrome runtime
/// implement CefCommandHandler::OnChromeCommand instead.
///
/*--cef()--*/
virtual bool OnGestureCommand(CefRefPtr<CefBrowserView> browser_view,
cef_gesture_command_t gesture_command) {
return false;
}
};
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_