From 35c09475e9efe3085a9ae6aaee0b647f6d927fec Mon Sep 17 00:00:00 2001 From: leezheng_hz Date: Wed, 18 Jun 2025 15:54:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=99=BD=E5=B1=8F=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=9C=80=E6=B1=82C=20API=E7=9A=84=E6=9E=9A=E4=B8=BE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: leezheng_hz --- .../interfaces/native/arkweb_error_code.h | 105 ++++++++++++++---- 1 file changed, 86 insertions(+), 19 deletions(-) diff --git a/web/webview/interfaces/native/arkweb_error_code.h b/web/webview/interfaces/native/arkweb_error_code.h index 4caab8f5d..03f5b3478 100644 --- a/web/webview/interfaces/native/arkweb_error_code.h +++ b/web/webview/interfaces/native/arkweb_error_code.h @@ -20,6 +20,7 @@ * @brief Provides APIs for the ArkWeb errors. * @since 12 */ + /** * @file arkweb_error_code.h * @@ -33,43 +34,109 @@ #define ARKWEB_ERROR_CODE_H typedef enum ArkWeb_ErrorCode { -/** @error Success. */ -ARKWEB_SUCCESS = 0, + /** @error Success. */ + ARKWEB_SUCCESS = 0, -/** @error Init error. */ -ARKWEB_INIT_ERROR = 17100001, + /** @error Init error. */ + ARKWEB_INIT_ERROR = 17100001, -/** @error Unknown error. */ -ARKWEB_ERROR_UNKNOWN = 17100100, + /** @error Unknown error. */ + ARKWEB_ERROR_UNKNOWN = 17100100, -/** @error Invalid param. */ -ARKWEB_INVALID_PARAM = 17100101, + /** @error Invalid param. */ + ARKWEB_INVALID_PARAM = 17100101, -/** @error Register custom schemes should be called before create any ArkWeb. */ -ARKWEB_SCHEME_REGISTER_FAILED = 17100102, + /** @error Register custom schemes should be called before create any ArkWeb. */ + ARKWEB_SCHEME_REGISTER_FAILED = 17100102, -/** @error Invalid url. */ -ARKWEB_INVALID_URL = 17100103, + /** @error Invalid url. */ + ARKWEB_INVALID_URL = 17100103, -/** @error Invalid cookie value. */ -ARKWEB_INVALID_COOKIE_VALUE = 17100104, + /** @error Invalid cookie value. */ + ARKWEB_INVALID_COOKIE_VALUE = 17100104, -/* + /* * @brief Failed to open the library. * * @syscap SystemCapability.Web.Webview.Core * @since 15 */ -ARKWEB_LIBRARY_OPEN_FAILURE = 17100105, + ARKWEB_LIBRARY_OPEN_FAILURE = 17100105, -/* + /* * @brief The required symbol was not found in the library. * * @syscap SystemCapability.Web.Webview.Core * @since 15 */ -ARKWEB_LIBRARY_SYMBOL_NOT_FOUND = 17100106, + ARKWEB_LIBRARY_SYMBOL_NOT_FOUND = 17100106, + + /* + * @brief The CookieManager not initialized. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_COOKIE_MANAGER_NOT_INITIALIZED = 17100107, } ArkWeb_ErrorCode; +typedef enum ArkWeb_BlanklessErrorCode { + /* + * @brief Success. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_BLANKLESS_SUCCESS = 0, + + /* + * @brief Unknown error. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_BLANKLESS_ERR_UNKNOWN = -1, + + /* + * @brief Invalid args. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_BLANKLESS_ERR_INVALID_ARGS = -2, + + /* + * @brief Init error. The web controller is not binded with the component. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_BLANKLESS_ERR_CONTROLLER_NOT_INITED = -3, + + /* + * @brief The key of blankless was not matched. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_BLANKLESS_KEY_NOT_MATCH = -4, + + /* + * @brief There are significant changes for the loading page. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_BLANKLESS_SIGNIFICANT_CHANGE = -5, + + /* + * @brief Device not support. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + ARKWEB_BLANKLESS_ERR_DEVICE_NOT_SUPPORT = 801, +} ArkWeb_BlanklessErrorCode; #endif // ARKWEB_ERROR_CODE_H -/** @} */ + +/** @} */ \ No newline at end of file -- Gitee From 653743eb4b1b89d79af2d64079110674cb29a107 Mon Sep 17 00:00:00 2001 From: leezheng_hz Date: Thu, 19 Jun 2025 09:33:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=99=BD=E5=B1=8F=E4=BC=98=E5=8C=96C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: leezheng_hz --- .../native/native_interface_arkweb.h | 111 ++++++++++++++---- 1 file changed, 90 insertions(+), 21 deletions(-) diff --git a/web/webview/interfaces/native/native_interface_arkweb.h b/web/webview/interfaces/native/native_interface_arkweb.h index 9df320d8c..d19bf0bfd 100644 --- a/web/webview/interfaces/native/native_interface_arkweb.h +++ b/web/webview/interfaces/native/native_interface_arkweb.h @@ -20,6 +20,7 @@ * @brief Provides APIs to use javascript proxy and run javascirpt code. * @since 11 */ + /** * @file native_interface_arkweb.h * @@ -31,13 +32,9 @@ */ #ifndef NATIVE_INTERFACE_ARKWEB_H #define NATIVE_INTERFACE_ARKWEB_H - #include #include - #include "arkweb_error_code.h" -#include "arkweb_type.h" - #ifdef __cplusplus extern "C" { #endif @@ -70,7 +67,7 @@ typedef void (*NativeArkWeb_OnValidCallback)(const char*); */ typedef void (*NativeArkWeb_OnDestroyCallback)(const char*); -/** +/* * @brief Loads a piece of code and execute JS code in the context of the currently displayed page. * * @param webTag The name of the web component. @@ -82,7 +79,7 @@ typedef void (*NativeArkWeb_OnDestroyCallback)(const char*); */ void OH_NativeArkWeb_RunJavaScript(const char* webTag, const char* jsCode, NativeArkWeb_OnJavaScriptCallback callback); -/** +/* * @brief Registers the JavaScript object and method list. * * @param webTag The name of the web component. @@ -98,7 +95,7 @@ void OH_NativeArkWeb_RunJavaScript(const char* webTag, const char* jsCode, Nativ void OH_NativeArkWeb_RegisterJavaScriptProxy(const char* webTag, const char* objName, const char** methodList, NativeArkWeb_OnJavaScriptProxyCallback* callback, int32_t size, bool needRefresh); -/** +/* * @brief Deletes the registered object which th given name. * * @param webTag The name of the web component. @@ -109,7 +106,7 @@ void OH_NativeArkWeb_RegisterJavaScriptProxy(const char* webTag, const char* obj */ void OH_NativeArkWeb_UnregisterJavaScriptProxy(const char* webTag, const char* objName); -/** +/* * @brief Registers the valid callback. * * @param webTag The name of the web component. @@ -120,7 +117,7 @@ void OH_NativeArkWeb_UnregisterJavaScriptProxy(const char* webTag, const char* o */ void OH_NativeArkWeb_SetJavaScriptProxyValidCallback(const char* webTag, NativeArkWeb_OnValidCallback callback); -/** +/* * @brief Get the valid callback. * * @param webTag The name of the web component. @@ -187,24 +184,96 @@ ArkWeb_ErrorCode OH_NativeArkWeb_LoadData(const char* webTag, const char* historyUrl); /** - * @brief Registers a JavaScript object with callback methods, which may return values. This object will be injected - * into all frames of the current page, including all iframes, and will be accessible using the specified - * name in ArkWeb_ProxyObjectWithResult. The object will only be available in JavaScript after the next - * load or reload. - * These methods will be executed in the ArkWeb worker thread. - * - * @param webTag Name of the web component. - * @param proxyObject JavaScript object to register, the object has callback functions with return value. - * @param permission Optional JSON string(default is null) for JSBridge permission control, - * allowing URL whitelist configuration at object-level and method-level. + * @brief Sets whether to enable blankless page loading. This API must be used in pair with the + * OH_NativeArkWeb_GetBlanklessInfoWithKey API. + * + * @param webTag webTag used when the webviewController is created. + * @param key Key value that uniquely identifies the current page. It must be the same as the key value of the + * OH_NativeArkWeb_GetBlanklessInfoWithKey API. + * @param isStarted Whether to enable frame interpolation. The value true indicates to enable frame + * interpolation, and the value false indicates the opposite. + * + * The default value is false. + * + * The value can be true or false. + * Action for setting an invalid value: N/A. + * @return Whether the API is successfully called. For details, see ArkWeb_BlanklessErrorCode. + * + * @since 20 + */ +ArkWeb_BlanklessErrorCode OH_NativeArkWeb_SetBlanklessLoadingWithKey(const char* webTag, + const char* key, + bool isStarted); + +/** + * @brief Clears the blankless loading cache of the page with a specified key value. + * + * @param key The list of key values of pages cached in the blankless loading solution. These key values are + * specified in OH_NativeArkWeb_GetBlanklessInfoWithKey. + * + * The default value is the list of key values of all pages cached in the blankless loading solution. + * + * The key length cannot exceed 2048 characters, and the number of keys must be less than or equal to 100. The + * URL is the same as that input to the Web component during page loading. + * + * When the key length exceeds 2048 characters, the key does not take effect. When the number of keys exceeds + * 100, the first 100 keys are used. If this parameter is set to NULL, the default value is used. + * @param size Size of the key list. + * + * @since 20 + */ +void OH_NativeArkWeb_ClearBlanklessLoadingCache(const char* key[], uint32_t size); + +/** + * @brief Obtains the prediction information about the blankless loading solution and enables the generation + * of the transition frame for the current loading. The application determines whether to enable the blankless + * loading solution based on the information. + * This API applies to pages in an applet or web application whose URLs are not fixed or cannot be uniquely + * identified. + * + * @param webTag webTag used when the webviewController is created. + * Default value: N/A. + * The value cannot be empty. + * When an invalid value is set, the error code is returned, and the API does not take effect. + * @param key Key value that uniquely identifies the current page. + * @return Return value of the ArkWeb_BlanklessInfo type. + * * @syscap SystemCapability.Web.Webview.Core * @since 20 */ -void OH_NativeArkWeb_RegisterAsyncThreadJavaScriptProxy(const char* webTag, - const ArkWeb_ProxyObjectWithResult* proxyObject, const char* permission); +ArkWeb_BlanklessInfo OH_NativeArkWeb_GetBlanklessInfoWithKey(const char* webTag, const char* key); +/** + * @brief Sets the cache capacity of the blankless loading solution and returns the value that takes effect. + * + * @param capacity Cache capacity, in MB. The maximum value is 100 MB. + * The default value is 30 MB. + * The value ranges from 0 to 100. If this parameter is set to 0, no cache capacity is available and the + * functionality is disabled globally. + * When the value is set to a number smaller than 0, the value 0 takes effect. When the value is set to a + * number greater than 100, the value 100 takes effect. + * @return The effective value that ranges from 0 MB to 100 MB. + * + * @since 20 + */ +uint32_t OH_NativeArkWeb_SetBlanklessLoadingCacheCapacity(uint32_t capacity); + +/** + * @brief Defines the blankless information. + * + * @since 20 + */ +typedef struct { + /** The errCode of the blankless. */ + ArkWeb_BlanklessErrorCode errCode; + /** The estimated similarity of the history snapshots. */ + double similarity; + /** The loadingTime of the history loading. */ + int32_t loadingTime; +} ArkWeb_BlanklessInfo; #ifdef __cplusplus }; #endif #endif // NATIVE_INTERFACE_ARKWEB_H + /** @} */ \ No newline at end of file -- Gitee