Skip to main content
Version: 12 Dec 2024

ml_webview.h

Classes

Name
structMLWebViewCursorState
Struct to define the cursor's state.
structMLWebViewEventCallbacks
Event handler for MLWebView callbacks.
structMLWebViewSettings
Struct to define webview initialization.
structMLWebViewProcessSettings
Struct to define webview process initialization.

Types

Name
typedef struct MLWebViewCursorStateMLWebViewCursorState
Struct to define the cursor's state.
typedef struct MLWebViewEventCallbacksMLWebViewEventCallbacks
Event handler for MLWebView callbacks.
typedef struct MLWebViewSettingsMLWebViewSettings
Struct to define webview initialization.
typedef struct MLWebViewProcessSettingsMLWebViewProcessSettings
Struct to define webview process initialization.

Enums

Name
enumMLWebViewTextInputType
{
MLWebViewTextInputType_None = 0,
MLWebViewTextInputType_Text,
MLWebViewTextInputType_Password,
MLWebViewTextInputType_Search,
MLWebViewTextInputType_Email,
MLWebViewTextInputType_Number,
MLWebViewTextInputType_Telephone,
MLWebViewTextInputType_URL,
MLWebViewTextInputType_Date,
MLWebViewTextInputType_DateTime,
MLWebViewTextInputType_DateTimeLocal,
MLWebViewTextInputType_Month,
MLWebViewTextInputType_Time,
MLWebViewTextInputType_Week,
MLWebViewTextInputType_TextArea,
MLWebViewTextInputType_ContentEditable,
MLWebViewTextInputType_DateTimeField,
MLWebViewTextInputType_Ensure32Bits = 0x7FFFFFFF
}
The type of text entry selected when on_show_keyboard is called.
enumMLWebViewTextInputFlags
{
MLWebViewTextInputFlags_None = 0,
MLWebViewTextInputFlags_AutocompleteOn = 1 << 0,
MLWebViewTextInputFlags_AutocompleteOff = 1 << 1,
MLWebViewTextInputFlags_AutocorrectOn = 1 << 2,
MLWebViewTextInputFlags_AutocorrectOff = 1 << 3,
MLWebViewTextInputFlags_SpellcheckOn = 1 << 4,
MLWebViewTextInputFlags_SpellcheckOff = 1 << 5,
MLWebViewTextInputFlags_AutocapitalizeNone = 1 << 6,
MLWebViewTextInputFlags_AutocapitalizeCharacters = 1 << 7,
MLWebViewTextInputFlags_AutocapitalizeWords = 1 << 8,
MLWebViewTextInputFlags_AutocapitalizeSentences = 1 << 9,
MLWebViewTextInputFlags_HaveNextFocusableElement = 1 << 10,
MLWebViewTextInputFlags_HavePreviousFocusableElement = 1 << 11,
MLWebViewTextInputFlags_HasBeenPasswordField = 1 << 12,
MLWebViewTextInputFlags_Ensure32Bits = 0x7FFFFFFF
}
Flags related to a text entry field passed when on_show_keyboard is called.
enumMLWebViewEventFlags
{
MLWebViewEventFlags_None = 0,
MLWebViewEventFlags_CapsLockOn = 1 << 0,
MLWebViewEventFlags_ShiftDown = 1 << 1,
MLWebViewEventFlags_ControlDown = 1 << 2,
MLWebViewEventFlags_AltDown = 1 << 3,
MLWebViewEventFlags_LeftMouseButton = 1 << 4,
MLWebViewEventFlags_MiddleMouseButton = 1 << 5,
MLWebViewEventFlags_RightMouseButton = 1 << 6,
MLWebViewEventFlags_CommandDown = 1 << 7,
MLWebViewEventFlags_NumLockOn = 1 << 8,
MLWebViewEventFlags_IsKeyPad = 1 << 9,
MLWebViewEventFlags_IsLeft = 1 << 10,
MLWebViewEventFlags_IsRight = 1 << 11,
MLWebViewEventFlags_AltGRDown = 1 << 12,
MLWebViewEventFlags_Ensure32Bits = 0x7FFFFFFF
}
Flags to set special key states during input.
enumAnonymous Enum 31
{
MLResultAPIPrefix_WebView = ( 0xebf7 << 16)
}
enumMLWebViewResult
{
MLWebViewResult_ZoomLimitReached = MLResultAPIPrefix_WebView,
MLWebViewResult_Ensure32Bits = 0x7FFFFFFF
}
Return values for the WebView API calls.
enumMLWebViewProcessSettingFlags
{
MLWebViewProcessSettingFlags_None = 0,
MLWebViewProcessSettingFlags_WebInspectorOn = 1 << 0,
MLWebViewProcessSettingFlags_Ensure32Bits = 0x7FFFFFFF
}
Flags set for the process using webview.
enumMLWebViewPauseType
{
MLWebViewPauseType_Multimedia = 0,
MLWebViewPauseType_Timers,
MLWebViewPauseType_Discard,
MLWebViewPauseType_Ensure32Bits = 0x7FFFFFFF
}
The type of the webview pause.

Functions

Name
voidMLWebViewCursorStateInit(MLWebViewCursorState * inout_cursor_state)
Initializes a MLWebViewCursorState with the default parameters.
voidMLWebViewEventCallbacksInit(MLWebViewEventCallbacks * inout_callback)
Initializes a MLWebViewEventCallbacks with the default parameters.
voidMLWebViewSettingsInit(MLWebViewSettings * inout_settings)
Initializes a MLWebViewSettings with the default parameters.
voidMLWebViewProcessSettingsInit(MLWebViewProcessSettings * inout_settings)
Initializes a MLWebViewProcessSettings with the default parameters.
MLResultMLWebViewSetProcessSettings(const MLWebViewProcessSettings * settings)
Specify the process settings to be used for webviews.
MLResultMLWebViewCreate(MLHandle out_handle, const MLWebViewSettings in_settings)
Create a MLWebView.
MLResultMLWebViewDestroy(MLHandle handle)
Destroy a MLWebView.
MLResultMLWebViewSetEventCallbacks(MLHandle web_view, const MLWebViewEventCallbacks * callbacks)
Specify the callbacks for a MLWebView.
MLResultMLWebViewAcquireNextAvailableFrame(MLHandle web_view, struct AHardwareBuffer ** out_native_buffer)
Acquires next available frame buffer for rendering.
MLResultMLWebViewReleaseFrame(MLHandle web_view, struct AHardwareBuffer * native_buffer)
Release a frame acquired by MLWebViewAcquireNextAvailableFrame.
MLResultMLWebViewGoTo(MLHandle web_view, const char * url)
Go to a URL with the specified MLWebView.
MLResultMLWebViewGoBack(MLHandle web_view)
Trigger a "Back" action in the MLWebView.
MLResultMLWebViewGoForward(MLHandle web_view)
Trigger a "Forward" action in the MLWebView.
MLResultMLWebViewReload(MLHandle web_view)
Trigger a "Reload" action in the MLWebView.
MLResultMLWebViewGetUrl(MLHandle web_view, uint32_t inout_size, char inout_url)
Get the current URL. Set out_url to NULL to get the length of the current URL.
MLResultMLWebViewCanGoBack(MLHandle web_view, bool * out_can_go_back)
Checks if the "Back" action is currently valid.
MLResultMLWebViewCanGoForward(MLHandle web_view, bool * out_can_go_forward)
Checks if the "Forward" action is currently valid.
MLResultMLWebViewInjectMouseMove(MLHandle web_view, const MLWebViewCursorState * cursor_state)
Moves the WebView mouse.
MLResultMLWebViewInjectMouseButtonDown(MLHandle web_view, const MLWebViewCursorState * cursor_state)
Sends a mouse button down/pressed event on a specific location on screen.
MLResultMLWebViewInjectMouseButtonUp(MLHandle web_view, const MLWebViewCursorState * cursor_state)
Sends a mouse button up/released event on a specific location on screen.
MLResultMLWebViewInjectChar(MLHandle web_view, uint32_t char_utf32)
Sends a printable char keyboard event to MLWebView.
MLResultMLWebViewInjectKeyDown(MLHandle web_view, int32_t key_code, uint32_t modifier_mask)
Sends a key down/pressed event to MLWebView.
MLResultMLWebViewInjectKeyUp(MLHandle web_view, int32_t key_code, uint32_t modifier_mask)
Sends a key up/release event to MLWebView.
MLResultMLWebViewGetScrollSize(MLHandle web_view, int32_t out_width, int32_t out_height)
This API is stubbed out and translates to a no-op.
MLResultMLWebViewGetScrollOffset(MLHandle web_view, int32_t out_x, int32_t out_y)
This API is stubbed out and translates to a no-op.
MLResultMLWebViewScrollBy(MLHandle web_view, const int32_t x_pixels, const int32_t y_pixels)
Triggers a mouse "Scroll" event.
MLResultMLWebViewGetZoomFactor(MLHandle web_view, double * out_zoom_factor)
Get the current zoom factor. The default zoom factor is 1.0.
MLResultMLWebViewZoomIn(MLHandle web_view)
Zoom in one level.
MLResultMLWebViewZoomOut(MLHandle web_view)
Zoom out one level.
MLResultMLWebViewResetZoom(MLHandle web_view)
Reset zoom level to 1.0.
MLResultMLWebViewGetFrameTransformMatrix(MLHandle web_view, MLMat4f * out_matrix)
Retrieves the 4x4 texture coordinate transform matrix used by all MLWebView frames.
MLResultMLWebViewRemoveAllCookies(MLHandle web_view)
Remove all webview cookies.
MLResultMLWebViewClearCache(MLHandle web_view)
Clear the webview cache.
MLResultMLWebViewPause(MLHandle web_view, MLWebViewPauseType pause_type)
Pause the webview. Call MLWebViewResume to resume.
MLResultMLWebViewResume(MLHandle web_view)
Resumes a webview after a previous call of the MLWebViewPause.

Enums Documentation

MLWebViewTextInputType

EnumeratorValueDescription
MLWebViewTextInputType_None0
MLWebViewTextInputType_Text
MLWebViewTextInputType_Password
MLWebViewTextInputType_Search
MLWebViewTextInputType_Email
MLWebViewTextInputType_Number
MLWebViewTextInputType_Telephone
MLWebViewTextInputType_URL
MLWebViewTextInputType_Date
MLWebViewTextInputType_DateTime
MLWebViewTextInputType_DateTimeLocal
MLWebViewTextInputType_Month
MLWebViewTextInputType_Time
MLWebViewTextInputType_Week
MLWebViewTextInputType_TextArea
MLWebViewTextInputType_ContentEditable
MLWebViewTextInputType_DateTimeField
MLWebViewTextInputType_Ensure32Bits0x7FFFFFFF

The type of text entry selected when on_show_keyboard is called.

API Level:

  • 20

MLWebViewTextInputFlags

EnumeratorValueDescription
MLWebViewTextInputFlags_None0
MLWebViewTextInputFlags_AutocompleteOn1 << 0
MLWebViewTextInputFlags_AutocompleteOff1 << 1
MLWebViewTextInputFlags_AutocorrectOn1 << 2
MLWebViewTextInputFlags_AutocorrectOff1 << 3
MLWebViewTextInputFlags_SpellcheckOn1 << 4
MLWebViewTextInputFlags_SpellcheckOff1 << 5
MLWebViewTextInputFlags_AutocapitalizeNone1 << 6
MLWebViewTextInputFlags_AutocapitalizeCharacters1 << 7
MLWebViewTextInputFlags_AutocapitalizeWords1 << 8
MLWebViewTextInputFlags_AutocapitalizeSentences1 << 9
MLWebViewTextInputFlags_HaveNextFocusableElement1 << 10
MLWebViewTextInputFlags_HavePreviousFocusableElement1 << 11
MLWebViewTextInputFlags_HasBeenPasswordField1 << 12
MLWebViewTextInputFlags_Ensure32Bits0x7FFFFFFF

Flags related to a text entry field passed when on_show_keyboard is called.

API Level:

  • 20

MLWebViewEventFlags

EnumeratorValueDescription
MLWebViewEventFlags_None0
MLWebViewEventFlags_CapsLockOn1 << 0
MLWebViewEventFlags_ShiftDown1 << 1
MLWebViewEventFlags_ControlDown1 << 2
MLWebViewEventFlags_AltDown1 << 3
MLWebViewEventFlags_LeftMouseButton1 << 4
MLWebViewEventFlags_MiddleMouseButton1 << 5
MLWebViewEventFlags_RightMouseButton1 << 6
MLWebViewEventFlags_CommandDown1 << 7
MLWebViewEventFlags_NumLockOn1 << 8
MLWebViewEventFlags_IsKeyPad1 << 9
MLWebViewEventFlags_IsLeft1 << 10
MLWebViewEventFlags_IsRight1 << 11
MLWebViewEventFlags_AltGRDown1 << 12
MLWebViewEventFlags_Ensure32Bits0x7FFFFFFF

Flags to set special key states during input.

API Level:

  • 20

Anonymous Enum 31

EnumeratorValueDescription
MLResultAPIPrefix_WebView( 0xebf7 << 16)Defines the prefix for MLWebViewResult codes.

MLWebViewResult

EnumeratorValueDescription
MLWebViewResult_ZoomLimitReachedMLResultAPIPrefix_WebView
MLWebViewResult_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Return values for the WebView API calls.

API Level:

  • 20

MLWebViewProcessSettingFlags

EnumeratorValueDescription
MLWebViewProcessSettingFlags_None0
MLWebViewProcessSettingFlags_WebInspectorOn1 << 0The bit to enable (1) or disable (0) web inspector.
MLWebViewProcessSettingFlags_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Flags set for the process using webview.

API Level:

  • 22

MLWebViewPauseType

EnumeratorValueDescription
MLWebViewPauseType_Multimedia0Pause all multimedia activities of the webview.
MLWebViewPauseType_TimersPause javascript timers of the webview.
MLWebViewPauseType_DiscardPause and discard the webview rendering process. But keep alive the MLWebView handle.
MLWebViewPauseType_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

The type of the webview pause.

API Level:

  • 22

Types Documentation

MLWebViewCursorState

typedef struct MLWebViewCursorState MLWebViewCursorState;

Struct to define the cursor's state.

This structure must be initialized by calling MLWebViewCursorStateInit before use.

More Info

API Level:

  • 20

MLWebViewEventCallbacks

typedef struct MLWebViewEventCallbacks MLWebViewEventCallbacks;

Event handler for MLWebView callbacks.

This structure must be initialized by calling MLWebViewEventCallbacksInit before use.

More Info

API Level:

  • 24

MLWebViewSettings

typedef struct MLWebViewSettings MLWebViewSettings;

Struct to define webview initialization.

This structure must be initialized by calling MLWebViewSettingsInit before use.

More Info

API Level:

  • 24

MLWebViewProcessSettings

typedef struct MLWebViewProcessSettings MLWebViewProcessSettings;

Struct to define webview process initialization.

This structure must be initialized by calling MLWebViewProcessSettingsInit before use.

More Info

API Level:

  • 22

Functions Documentation

MLWebViewCursorStateInit

static inline void MLWebViewCursorStateInit(
MLWebViewCursorState * inout_cursor_state
)

Initializes a MLWebViewCursorState with the default parameters.

Parameters

MLWebViewCursorState *inout_cursor_stateThe object to initialize with default values.

Required Permissions:

  • None

API Level:

  • 20

MLWebViewEventCallbacksInit

static inline void MLWebViewEventCallbacksInit(
MLWebViewEventCallbacks * inout_callback
)

Initializes a MLWebViewEventCallbacks with the default parameters.

Parameters

MLWebViewEventCallbacks *inout_callbackThe object to initialize with default settings.

Required Permissions:

  • None

API Level:

  • 24

MLWebViewSettingsInit

static inline void MLWebViewSettingsInit(
MLWebViewSettings * inout_settings
)

Initializes a MLWebViewSettings with the default parameters.

Parameters

MLWebViewSettings *inout_settingsThe object to initialize with default settings.

Required Permissions:

  • None

API Level:

  • 20

MLWebViewProcessSettingsInit

static inline void MLWebViewProcessSettingsInit(
MLWebViewProcessSettings * inout_settings
)

Initializes a MLWebViewProcessSettings with the default parameters.

Parameters

MLWebViewProcessSettings *inout_settingsThe object to initialize with default settings.

Required Permissions:

  • None

API Level:

  • 22

MLWebViewSetProcessSettings

MLResult MLWebViewSetProcessSettings(
const MLWebViewProcessSettings * settings
)

Specify the process settings to be used for webviews.

Parameters

const MLWebViewProcessSettings *settingsThe settings to be used for webviews.

Returns

MLResultMLResult_InvalidParamIf settings is null.
MLResultMLResult_NotImplementedIf called after MLWebViewCreate.
MLResultMLResult_OkIf settings is not null.

Required Permissions:

  • None
note

Current implementation only supports enabling and disabling web inspector before first call to MLWebViewCreate. If all webviews have been destroyed, it is possible to call this with effect again. Default is to disable.

API Level:

  • 22

MLWebViewCreate

MLResult MLWebViewCreate(
MLHandle * out_handle,
const MLWebViewSettings * in_settings
)

Create a MLWebView.

Parameters

MLHandle *out_handleHandle that is ready to use with all other MLWebView API calls.
const MLWebViewSettings *in_settingsThe initialization paramaters for the webview.

Returns

MLResultMLResult_InvalidParamout_handle, in_settings, or application_vm pointer was null.
MLResultMLResult_OkIf version >= 2, returns MLResult_Ok for successful start of asynchronous operation, but any eventual failure will be reported through on_service_failed. If version < 2, this indicates that synchronous creation was successful.
MLResultMLResult_PermissionDeniedMissing required permission(s).
MLResultMLResult_UnspecifiedFailureUnable to create the MLWebView, MLWebViewCallbacks struct version < 2.

Required Permissions:

  • com.magicleap.permission.WEBVIEW (protection level: normal)

The MLWebView will be ready to use once this function returns with MLResult_OK.

note

In version >= 2 for MLWebViewCallbacks struct, MLWebViewCreate launches a separate thread to create a webview. If creation fails and the on_service_failed callback is not null the MLResult code will be passed into the on_service_failed callback. The on_service_connected callback will be called if it is not null and creation was successful. For version < 2 of MLWebViewCallbacks struct, MLWebViewCallbacks will create in synchronous mode.

API Level:

  • 24

MLWebViewDestroy

MLResult MLWebViewDestroy(
MLHandle handle
)

Destroy a MLWebView.

Parameters

MLHandlehandleThe handle to invalidate.

Returns

MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe MLWebView was destroyed successfully.
MLResultMLResult_UnspecifiedFailureAn error occurred destroying the MLWebView.

Required Permissions:

  • None

The MLWebView will be terminated by this function call and the handle shall no longer be valid.

API Level:

  • 21

MLWebViewSetEventCallbacks

MLResult MLWebViewSetEventCallbacks(
MLHandle web_view,
const MLWebViewEventCallbacks * callbacks
)

Specify the callbacks for a MLWebView.

Parameters

MLHandleweb_viewThe MLWebView to link the event handler.
const MLWebViewEventCallbacks *callbacksThe event handler to link to the MLWebView.

Returns

MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkMLWebView event handler was set.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 24

MLWebViewAcquireNextAvailableFrame

MLResult MLWebViewAcquireNextAvailableFrame(
MLHandle web_view,
struct AHardwareBuffer ** out_native_buffer
)

Acquires next available frame buffer for rendering.

Parameters

MLHandleweb_viewThe webview being accessed.
struct AHardwareBuffer **out_native_bufferPointer to an AHardwareBuffer.

Returns

MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe frame is ready.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None
note

To use with OpenGL, EGL, and Vulkan please see: https://developer.android.com/ndk/reference/group/a-hardware-buffer for details.

API Level:

  • 21

MLWebViewReleaseFrame

MLResult MLWebViewReleaseFrame(
MLHandle web_view,
struct AHardwareBuffer * native_buffer
)

Release a frame acquired by MLWebViewAcquireNextAvailableFrame.

Parameters

MLHandleweb_viewThe webview being accessed.
struct AHardwareBuffer *native_bufferThe frame being released.

Returns

MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkFrame successfully released.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.
MLResultMLResult_UnspecifiedFailureAn error occurred releasing the frame.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewGoTo

MLResult MLWebViewGoTo(
MLHandle web_view,
const char * url
)

Go to a URL with the specified MLWebView.

Parameters

MLHandleweb_viewThe webview being accessed.
const char *urlThe URL that will be loaded.

Returns

MLResultMLResult_IllegalStateWebView was paused. MLWebViewResume should be called before this function.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe WebView is attempting to load the specified URL.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

Note that success with this call only indicates that a load will be attempted. Caller can be notified about issues loading the URL via the event handler on_load_error.

API Level:

  • 21

MLWebViewGoBack

MLResult MLWebViewGoBack(
MLHandle web_view
)

Trigger a "Back" action in the MLWebView.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_OkThe WebView Back action was initiated or cannot go back any further.
MLResultMLResult_IllegalStateWebView was paused. MLWebViewResume should be called before this function.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

Query MLWebViewCanGoBack before calling this method. If there is no valid page to go back to, this method will be no-op.

API Level:

  • 21

MLWebViewGoForward

MLResult MLWebViewGoForward(
MLHandle web_view
)

Trigger a "Forward" action in the MLWebView.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_IllegalStateWebView was paused. MLWebViewResume should be called before this function.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe WebView Forward action was initiated or cannot go forward any further.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

Query MLWebViewCanGoForward before calling this method. If there is no valid page to go forward to, this method will be no-op.

API Level:

  • 21

MLWebViewReload

MLResult MLWebViewReload(
MLHandle web_view
)

Trigger a "Reload" action in the MLWebView.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_IllegalStateWebView was paused. MLWebViewResume should be called before this function.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe WebView Reload action was initiated.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewGetUrl

MLResult MLWebViewGetUrl(
MLHandle web_view,
uint32_t * inout_size,
char * inout_url
)

Get the current URL. Set out_url to NULL to get the length of the current URL.

Parameters

MLHandleweb_viewThe webview being accessed.
uint32_t *inout_sizeThe size that has been allocated in out_url to hold the URL. This will be set to the actual length of URL if inout_size and size needed for the URL are different.
char *inout_urlThe URL up to inout_size of characters.

Returns

MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe WebView URL was acquired.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewCanGoBack

MLResult MLWebViewCanGoBack(
MLHandle web_view,
bool * out_can_go_back
)

Checks if the "Back" action is currently valid.

Parameters

MLHandleweb_viewThe webview being accessed.
bool *out_can_go_backTrue if "Back" has a valid page to go to.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe status of going "Back" was acquired.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewCanGoForward

MLResult MLWebViewCanGoForward(
MLHandle web_view,
bool * out_can_go_forward
)

Checks if the "Forward" action is currently valid.

Parameters

MLHandleweb_viewThe webview being accessed.
bool *out_can_go_forwardTrue if "Forward" has a valid page to go to.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe status of going "Forward" was acquired.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewInjectMouseMove

MLResult MLWebViewInjectMouseMove(
MLHandle web_view,
const MLWebViewCursorState * cursor_state
)

Moves the WebView mouse.

Parameters

MLHandleweb_viewThe webview being accessed.
const MLWebViewCursorState *cursor_stateInformation about the mouse movement.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe internal mouse was moved.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None
note

Please see MLWebViewInjectMouseButtonDown for behavior.

API Level:

  • 21

MLWebViewInjectMouseButtonDown

MLResult MLWebViewInjectMouseButtonDown(
MLHandle web_view,
const MLWebViewCursorState * cursor_state
)

Sends a mouse button down/pressed event on a specific location on screen.

Parameters

MLHandleweb_viewThe webview being accessed.
const MLWebViewCursorState *cursor_stateInformation about the mouse button event.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkIf successful.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None
note

Behavior: (1) Click behavior: On mouse down, (x, y) is saved and mouse down sent. When mouse up received within 200ms, mouse up sent to previous mouse down (x, y) position so Chromium interprets as click. (2) Drag behavior: On mouse down (x, y) is saved and mouse down sent. When mouse moves within timeout period of 200ms, webview will continue to wait. Otherwise, mouse move sent to current (x, y) location to let Chromium interpret as drag. (3) These click and drag behaviors make it possible to just send mouse events as they are received and the underlying Chromium implementation will work as expected.


MLWebViewInjectMouseButtonUp

MLResult MLWebViewInjectMouseButtonUp(
MLHandle web_view,
const MLWebViewCursorState * cursor_state
)

Sends a mouse button up/released event on a specific location on screen.

Parameters

MLHandleweb_viewThe webview being accessed.
const MLWebViewCursorState *cursor_stateInformation about the mouse button event.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkIf successful.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None
note

Please see MLWebViewInjectMouseButtonDown for behavior.


MLWebViewInjectChar

MLResult MLWebViewInjectChar(
MLHandle web_view,
uint32_t char_utf32
)

Sends a printable char keyboard event to MLWebView.

Parameters

MLHandleweb_viewTarget webview.
uint32_tchar_utf32Printable char utf code.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe key event was injected.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewInjectKeyDown

MLResult MLWebViewInjectKeyDown(
MLHandle web_view,
int32_t key_code,
uint32_t modifier_mask
)

Sends a key down/pressed event to MLWebView.

Parameters

MLHandleweb_viewTarget webview.
int32_tkey_codeKey code.
uint32_tmodifier_maskShould be one or combination of MLWebViewEventFlags.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe key event was injected.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewInjectKeyUp

MLResult MLWebViewInjectKeyUp(
MLHandle web_view,
int32_t key_code,
uint32_t modifier_mask
)

Sends a key up/release event to MLWebView.

Parameters

MLHandleweb_viewTarget webview.
int32_tkey_codeKey code.
uint32_tmodifier_maskShould be one or combination of MLWebViewEventFlags.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe key event was injected.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewGetScrollSize

MLResult MLWebViewGetScrollSize(
MLHandle web_view,
int32_t * out_width,
int32_t * out_height
)

This API is stubbed out and translates to a no-op.

Parameters

MLHandleweb_viewThe webview being accessed.
int32_t *out_widthThe number representing the entire width of the webview, in pixels.
int32_t *out_heightThe number representing the entire height of the webview, in pixels.

Returns

MLResultMLResult_NotImplementedThis API is stubbed out and translates to a no-op.

Required Permissions:

  • None
Deprecated

Deprecated since 1.2.0. Scheduled for removal.

API Level:

  • 21

MLWebViewGetScrollOffset

MLResult MLWebViewGetScrollOffset(
MLHandle web_view,
int32_t * out_x,
int32_t * out_y
)

This API is stubbed out and translates to a no-op.

Parameters

MLHandleweb_viewThe webview being accessed.
int32_t *out_xThe number representing the horizontal offset of the webview, in pixels.
int32_t *out_yThe number representing the vertical offset of the webview, in pixels.

Returns

MLResultMLResult_NotImplementedThis API is stubbed out and translates to a no-op.

Required Permissions:

  • None
Deprecated

Deprecated since 1.2.0. Scheduled for removal.

API Level:

  • 21

MLWebViewScrollBy

MLResult MLWebViewScrollBy(
MLHandle web_view,
const int32_t x_pixels,
const int32_t y_pixels
)

Triggers a mouse "Scroll" event.

Parameters

MLHandleweb_viewThe webview being accessed.
const int32_tx_pixelsThe number of pixels to scroll on the x axis.
const int32_ty_pixelsThe number of pixels to scroll on the y axis.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe MLWebView was scrolled.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewGetZoomFactor

MLResult MLWebViewGetZoomFactor(
MLHandle web_view,
double * out_zoom_factor
)

Get the current zoom factor. The default zoom factor is 1.0.

Parameters

MLHandleweb_viewThe webview being accessed.
double *out_zoom_factorCurrent numeric value for zoom factor.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe out_zoom_factor parameter was updated with the current zoom value.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.
MLResultMLResult_UnspecifiedFailureFailed to get the zoom factor due to an internal error.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewZoomIn

MLResult MLWebViewZoomIn(
MLHandle web_view
)

Zoom in one level.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe MLWebView zoomed in.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.
MLResultMLResult_UnspecifiedFailureFailed to zoom in due to an internal error.
MLResultMLWebViewResult_ZoomLimitReachedif cannot zoom in any further.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewZoomOut

MLResult MLWebViewZoomOut(
MLHandle web_view
)

Zoom out one level.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe MLWebView zoomed out.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.
MLResultMLResult_UnspecifiedFailureFailed to zoom out due to an internal error.
MLResultMLWebViewResult_ZoomLimitReachedif cannot zoom out any further.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewResetZoom

MLResult MLWebViewResetZoom(
MLHandle web_view
)

Reset zoom level to 1.0.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkThe MLWebView zoom was reset.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.
MLResultMLResult_UnspecifiedFailureFailed to reset zoom due to an internal error.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewGetFrameTransformMatrix

MLResult MLWebViewGetFrameTransformMatrix(
MLHandle web_view,
MLMat4f * out_matrix
)

Retrieves the 4x4 texture coordinate transform matrix used by all MLWebView frames.

Parameters

MLHandleweb_viewThe webview being accessed.
MLMat4f *out_matrixThe retrieved matrix.

Returns

MLResultMLResult_OkThe constant matrix was retrieved.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.

Required Permissions:

  • None

This transform matrix maps 2D homogeneous texture coordinates of the form (s, t, 0, 1) with s and t in the inclusive range [0, 1] to the texture coordinate that should be used to sample that location from the texture. Sampling the texture outside of the range of this transform is undefined.

The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via the glLoadMatrixf or glUniformMatrix4fv functions.

API Level:

  • 21

MLWebViewRemoveAllCookies

MLResult MLWebViewRemoveAllCookies(
MLHandle web_view
)

Remove all webview cookies.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkIf all cookies removed successfully.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.
MLResultMLResult_UnspecifiedFailureRemoving all cookies failed due to an internal error.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewClearCache

MLResult MLWebViewClearCache(
MLHandle web_view
)

Clear the webview cache.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_IllegalStateWebView was paused. See MLWebViewPause.
MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkIf cache cleared successfully.
MLResultMLResult_PendingIf the MLWebView handle is not ready to use if asynchronous creation was used, MLWebViewCallbacks struct version >= 2.
MLResultMLResult_UnspecifiedFailureClearing cache failed due to an internal error.

Required Permissions:

  • None

API Level:

  • 21

MLWebViewPause

MLResult MLWebViewPause(
MLHandle web_view,
MLWebViewPauseType pause_type
)

Pause the webview. Call MLWebViewResume to resume.

Parameters

MLHandleweb_viewThe webview being accessed.
MLWebViewPauseTypepause_typeThe webview pause type MLWebViewPauseType. MLWebViewPauseType_Multimedia Is a simple pause for all multimedia of the webview. MLWebViewPauseType_Timers Intended to stop animation of the webview content. MLWebViewPauseType_Discard Uses to free the webview rendering process but keep alive the MLWebView handle.

Returns

MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle or invalid MLWebViewPauseType value.
MLResultMLResult_OkIf paused successfully.
MLResultMLResult_PendingMLWebView handle is not ready to use. See an asynchronous mode of the MLWebViewCreate.
MLResultMLResult_UnspecifiedFailurePause failed due to an internal error.

This method provides a multiple pause types to the webview.

API Level:

  • 22

MLWebViewResume

MLResult MLWebViewResume(
MLHandle web_view
)

Resumes a webview after a previous call of the MLWebViewPause.

Parameters

MLHandleweb_viewThe webview being accessed.

Returns

MLResultMLResult_InvalidParamUnable to find the specified MLWebView handle.
MLResultMLResult_OkIf resumed successfully.
MLResultMLResult_PendingMLWebView handle is not ready to use. See an asynchronous mode of the MLWebViewCreate.
MLResultMLResult_UnspecifiedFailureResume failed due to an internal error.

Resume webview to the normal operation for all webview pause types.

API Level:

  • 22

Source code

// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2022 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%

#pragma once

#include "ml_api.h"
#include "ml_types.h"

ML_EXTERN_C_BEGIN

typedef enum MLWebViewTextInputType {
MLWebViewTextInputType_None = 0,
MLWebViewTextInputType_Text,
MLWebViewTextInputType_Password,
MLWebViewTextInputType_Search,
MLWebViewTextInputType_Email,
MLWebViewTextInputType_Number,
MLWebViewTextInputType_Telephone,
MLWebViewTextInputType_URL,
MLWebViewTextInputType_Date,
MLWebViewTextInputType_DateTime,
MLWebViewTextInputType_DateTimeLocal,
MLWebViewTextInputType_Month,
MLWebViewTextInputType_Time,
MLWebViewTextInputType_Week,
MLWebViewTextInputType_TextArea,
MLWebViewTextInputType_ContentEditable,
MLWebViewTextInputType_DateTimeField,
MLWebViewTextInputType_Ensure32Bits = 0x7FFFFFFF
} MLWebViewTextInputType;

typedef enum MLWebViewTextInputFlags {
MLWebViewTextInputFlags_None = 0,
MLWebViewTextInputFlags_AutocompleteOn = 1 << 0,
MLWebViewTextInputFlags_AutocompleteOff = 1 << 1,
MLWebViewTextInputFlags_AutocorrectOn = 1 << 2,
MLWebViewTextInputFlags_AutocorrectOff = 1 << 3,
MLWebViewTextInputFlags_SpellcheckOn = 1 << 4,
MLWebViewTextInputFlags_SpellcheckOff = 1 << 5,
MLWebViewTextInputFlags_AutocapitalizeNone = 1 << 6,
MLWebViewTextInputFlags_AutocapitalizeCharacters = 1 << 7,
MLWebViewTextInputFlags_AutocapitalizeWords = 1 << 8,
MLWebViewTextInputFlags_AutocapitalizeSentences = 1 << 9,
MLWebViewTextInputFlags_HaveNextFocusableElement = 1 << 10,
MLWebViewTextInputFlags_HavePreviousFocusableElement = 1 << 11,
MLWebViewTextInputFlags_HasBeenPasswordField = 1 << 12,
MLWebViewTextInputFlags_Ensure32Bits = 0x7FFFFFFF
} MLWebViewTextInputFlags;

typedef enum MLWebViewEventFlags {
MLWebViewEventFlags_None = 0,
MLWebViewEventFlags_CapsLockOn = 1 << 0,
MLWebViewEventFlags_ShiftDown = 1 << 1,
MLWebViewEventFlags_ControlDown = 1 << 2,
MLWebViewEventFlags_AltDown = 1 << 3,
MLWebViewEventFlags_LeftMouseButton = 1 << 4,
MLWebViewEventFlags_MiddleMouseButton = 1 << 5,
MLWebViewEventFlags_RightMouseButton = 1 << 6,
MLWebViewEventFlags_CommandDown = 1 << 7,
MLWebViewEventFlags_NumLockOn = 1 << 8,
MLWebViewEventFlags_IsKeyPad = 1 << 9,
MLWebViewEventFlags_IsLeft = 1 << 10,
MLWebViewEventFlags_IsRight = 1 << 11,
MLWebViewEventFlags_AltGRDown = 1 << 12,
MLWebViewEventFlags_Ensure32Bits = 0x7FFFFFFF
} MLWebViewEventFlags;

enum {
MLResultAPIPrefix_WebView = MLRESULT_PREFIX(0xebf7)
};

typedef enum MLWebViewResult {
MLWebViewResult_ZoomLimitReached = MLResultAPIPrefix_WebView,
MLWebViewResult_Ensure32Bits = 0x7FFFFFFF
} MLWebViewResult;

typedef enum MLWebViewProcessSettingFlags {
MLWebViewProcessSettingFlags_None = 0,
MLWebViewProcessSettingFlags_WebInspectorOn = 1 << 0,
MLWebViewProcessSettingFlags_Ensure32Bits = 0x7FFFFFFF
} MLWebViewProcessSettingFlags;

typedef struct MLWebViewCursorState {
uint32_t version;
uint32_t x_position;
uint32_t y_position;
MLWebViewEventFlags modifiers;
} MLWebViewCursorState;

ML_STATIC_INLINE void MLWebViewCursorStateInit(MLWebViewCursorState* inout_cursor_state) {
if (inout_cursor_state) {
inout_cursor_state->version = 1;
inout_cursor_state->x_position = 0;
inout_cursor_state->y_position = 0;
inout_cursor_state->modifiers = MLWebViewEventFlags_None;
}
}

typedef struct MLWebViewEventCallbacks {

uint32_t version;

void* user_data;

void (*on_before_resource_load)(const char* resource_url, void* user_data);
void (*on_load_end)(bool is_main_frame, int32_t http_status_code, void* user_data);
void (*on_load_error)(bool is_main_frame, int32_t http_status_code, const char* error_str, const char* failed_url, void* user_data);
bool (*on_certificate_error)(int32_t error_code, const char* url, const char* error_message, const char* details, void* user_data);
void (*on_show_keyboard)(int32_t x,
int32_t y,
int32_t width,
int32_t height,
int32_t text_input_flags,
MLWebViewTextInputType text_input_type,
void* user_data);
void (*on_keyboard_dismiss)(void* user_data);
void (*on_destroy)(void* user_data);
void (*on_service_connected)(void* user_data);
void (*on_service_disconnected)(void* user_data);
void (*on_service_failed)(MLResult result, void* user_data);

bool (*on_before_popup)(const char* url, void* user_data);

void (*on_popup_opened)(uint64_t popup_id, const char* url, void* user_data);

void (*on_popup_closed)(MLHandle handle, void* user_data);
} MLWebViewEventCallbacks;

ML_STATIC_INLINE void MLWebViewEventCallbacksInit(MLWebViewEventCallbacks* inout_callback) {
if (inout_callback) {
inout_callback->version = 3u;
inout_callback->user_data = NULL;
inout_callback->on_before_resource_load = NULL;
inout_callback->on_load_end = NULL;
inout_callback->on_load_error = NULL;
inout_callback->on_certificate_error = NULL;
inout_callback->on_show_keyboard = NULL;
inout_callback->on_keyboard_dismiss = NULL;
inout_callback->on_destroy = NULL;
inout_callback->on_service_connected = NULL;
inout_callback->on_service_disconnected = NULL;
inout_callback->on_service_failed = NULL;
inout_callback->on_before_popup = NULL;
inout_callback->on_popup_opened = NULL;
inout_callback->on_popup_closed = NULL;
}
}

typedef struct MLWebViewSettings {
uint32_t version;
uint32_t width;
uint32_t height;
void* application_vm;
void* context;
MLWebViewEventCallbacks callbacks;
bool is_popup;
uint64_t popup_id;
} MLWebViewSettings;

ML_STATIC_INLINE void MLWebViewSettingsInit(MLWebViewSettings* inout_settings) {
if (inout_settings) {
inout_settings->version = 3u;
inout_settings->width = 1200;
inout_settings->height = 750;
inout_settings->application_vm = NULL;
inout_settings->context = NULL;
inout_settings->is_popup = false;
inout_settings->popup_id = 0;
MLWebViewEventCallbacksInit(&inout_settings->callbacks);
}
}

typedef struct MLWebViewProcessSettings {
uint32_t version;
uint32_t flags;
} MLWebViewProcessSettings;

ML_STATIC_INLINE void MLWebViewProcessSettingsInit(MLWebViewProcessSettings* inout_settings) {
if (inout_settings) {
inout_settings->version = 1;
inout_settings->flags = MLWebViewProcessSettingFlags_None;
}
}

ML_API MLResult ML_CALL MLWebViewSetProcessSettings(const MLWebViewProcessSettings* settings);

ML_API MLResult ML_CALL MLWebViewCreate(MLHandle *out_handle,
const MLWebViewSettings *in_settings);

ML_API MLResult ML_CALL MLWebViewDestroy(MLHandle handle);

ML_API MLResult ML_CALL MLWebViewSetEventCallbacks(MLHandle web_view,
const MLWebViewEventCallbacks* callbacks);

struct AHardwareBuffer;

ML_API MLResult ML_CALL MLWebViewAcquireNextAvailableFrame(MLHandle web_view,
struct AHardwareBuffer** out_native_buffer);

ML_API MLResult ML_CALL MLWebViewReleaseFrame(MLHandle web_view, struct AHardwareBuffer* native_buffer);

ML_API MLResult ML_CALL MLWebViewGoTo(MLHandle web_view, const char* url);

ML_API MLResult ML_CALL MLWebViewGoBack(MLHandle web_view);

ML_API MLResult ML_CALL MLWebViewGoForward(MLHandle web_view);

ML_API MLResult ML_CALL MLWebViewReload(MLHandle web_view);

ML_API MLResult ML_CALL MLWebViewGetUrl(MLHandle web_view, uint32_t* inout_size, char* inout_url);

ML_API MLResult ML_CALL MLWebViewCanGoBack(MLHandle web_view, bool* out_can_go_back);

ML_API MLResult ML_CALL MLWebViewCanGoForward(MLHandle web_view, bool* out_can_go_forward);

ML_API MLResult ML_CALL MLWebViewInjectMouseMove(MLHandle web_view, const MLWebViewCursorState* cursor_state);

ML_API MLResult ML_CALL MLWebViewInjectMouseButtonDown(MLHandle web_view,
const MLWebViewCursorState* cursor_state);

ML_API MLResult ML_CALL MLWebViewInjectMouseButtonUp(MLHandle web_view,
const MLWebViewCursorState* cursor_state);

ML_API MLResult ML_CALL MLWebViewInjectChar(MLHandle web_view, uint32_t char_utf32);

ML_API MLResult ML_CALL MLWebViewInjectKeyDown(MLHandle web_view, int32_t key_code, uint32_t modifier_mask);

ML_API MLResult ML_CALL MLWebViewInjectKeyUp(MLHandle web_view, int32_t key_code, uint32_t modifier_mask);

ML_DEPRECATED_MSG("Unimplemented and scheduled for removal.")
ML_API MLResult ML_CALL MLWebViewGetScrollSize(MLHandle web_view, int32_t* out_width, int32_t* out_height);

ML_DEPRECATED_MSG("Unimplemented and scheduled for removal.")
ML_API MLResult ML_CALL MLWebViewGetScrollOffset(MLHandle web_view, int32_t* out_x, int32_t* out_y);

ML_API MLResult ML_CALL MLWebViewScrollBy(MLHandle web_view, const int32_t x_pixels, const int32_t y_pixels);

ML_API MLResult ML_CALL MLWebViewGetZoomFactor(MLHandle web_view, double* out_zoom_factor);

ML_API MLResult ML_CALL MLWebViewZoomIn(MLHandle web_view);

ML_API MLResult ML_CALL MLWebViewZoomOut(MLHandle web_view);

ML_API MLResult ML_CALL MLWebViewResetZoom(MLHandle web_view);

ML_API MLResult ML_CALL MLWebViewGetFrameTransformMatrix(MLHandle web_view, MLMat4f* out_matrix);

ML_API MLResult ML_CALL MLWebViewRemoveAllCookies(MLHandle web_view);

ML_API MLResult ML_CALL MLWebViewClearCache(MLHandle web_view);

typedef enum MLWebViewPauseType {
MLWebViewPauseType_Multimedia = 0,
MLWebViewPauseType_Timers,
MLWebViewPauseType_Discard,
MLWebViewPauseType_Ensure32Bits = 0x7FFFFFFF
} MLWebViewPauseType;

ML_API MLResult ML_CALL MLWebViewPause(MLHandle web_view, MLWebViewPauseType pause_type);

ML_API MLResult ML_CALL MLWebViewResume(MLHandle web_view);

ML_EXTERN_C_END