From 38fddc1774176c2426c992b269081b7ca89c0a95 Mon Sep 17 00:00:00 2001 From: yourkindfather Date: Mon, 11 Aug 2025 11:36:46 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E5=8F=8C=E5=86=85=E6=A0=B8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AE=8F=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yourkindfather --- .../napi_webview_controller.cpp | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp index df4f69f36..00b7b20b8 100644 --- a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp +++ b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp @@ -1187,7 +1187,8 @@ napi_value NapiWebviewController::SetWebDebuggingAccess(napi_env env, napi_callb } } - if (ArkWeb::getActiveWebEngineVersion() < ArkWeb::ArkWebEngineVersion::M132) { + if (IS_CALLING_FROM_M114()) { + WVLOG_W("SetWebDebuggingAccess unsupported engine version: M114"); webDebuggingPort = 0; } @@ -2899,7 +2900,9 @@ napi_value NapiWebviewController::GetTitle(napi_env env, napi_callback_info info napi_value NapiWebviewController::GetProgress(napi_env env, napi_callback_info info) { - if (ArkWeb::getActiveWebEngineVersion() < ArkWeb::ArkWebEngineVersion::M132) { + if (IS_CALLING_FROM_M114()) { + WVLOG_W("GetProgress unsupported engine version: M114"); + BusinessError::ThrowErrorByErrcode(env, CAPABILITY_NOT_SUPPORTED_ERROR); return nullptr; } @@ -6164,7 +6167,8 @@ napi_value NapiWebviewController::SetBackForwardCacheOptions(napi_env env, napi_ napi_value NapiWebviewController::SetAppCustomUserAgent(napi_env env, napi_callback_info info) { - if (ArkWeb::getActiveWebEngineVersion() < ArkWeb::ArkWebEngineVersion::M132) { + if (IS_CALLING_FROM_M114()) { + WVLOG_W("SetAppCustomUserAgent unsupported engine version: M114"); return nullptr; } @@ -6194,7 +6198,8 @@ napi_value NapiWebviewController::SetAppCustomUserAgent(napi_env env, napi_callb napi_value NapiWebviewController::SetUserAgentForHosts(napi_env env, napi_callback_info info) { - if (ArkWeb::getActiveWebEngineVersion() < ArkWeb::ArkWebEngineVersion::M132) { + if (IS_CALLING_FROM_M114()) { + WVLOG_W("SetUserAgentForHosts unsupported engine version: M114"); return nullptr; } @@ -7392,7 +7397,8 @@ napi_value NapiWebviewController::AvoidVisibleViewportBottom(napi_env env, napi_ napi_value NapiWebviewController::SetErrorPageEnabled(napi_env env, napi_callback_info info) { - if (ArkWeb::getActiveWebEngineVersion() < ArkWeb::ArkWebEngineVersion::M132) { + if (IS_CALLING_FROM_M114()) { + WVLOG_W("SetErrorPageEnabled unsupported engine version: M114"); return nullptr; } @@ -7434,7 +7440,8 @@ napi_value NapiWebviewController::GetErrorPageEnabled(napi_env env, napi_callbac { napi_value result = nullptr; bool getErrorPageEnabled = false; - if (ArkWeb::getActiveWebEngineVersion() < ArkWeb::ArkWebEngineVersion::M132) { + if (IS_CALLING_FROM_M114()) { + WVLOG_W("GetErrorPageEnabled unsupported engine version: M114"); NAPI_CALL(env, napi_get_boolean(env, getErrorPageEnabled, &result)); return result; } @@ -7584,6 +7591,7 @@ napi_value ArkWebTransfer::CreateWebMessagePortTransfer(napi_env env, napi_callb napi_value NapiWebviewController::EnablePrivateNetworkAccess(napi_env env, napi_callback_info info) { if (IS_CALLING_FROM_M114()) { + WVLOG_W("EnablePrivateNetworkAccess unsupported engine version: M114"); return nullptr; } @@ -7616,7 +7624,8 @@ napi_value NapiWebviewController::IsPrivateNetworkAccessEnabled(napi_env env, na { napi_value result = nullptr; bool pnaEnabled = false; - if (ArkWeb::getActiveWebEngineVersion() < ArkWeb::ArkWebEngineVersion::M132) { + if (IS_CALLING_FROM_M114()) { + WVLOG_W("IsPrivateNetworkAccessEnabled unsupported engine version: M114"); NAPI_CALL(env, napi_get_boolean(env, pnaEnabled, &result)); return result; } -- Gitee From 74211df175a7d7fe59bb130b841ee7ef07bc9c05 Mon Sep 17 00:00:00 2001 From: ZhaoPengfei Date: Tue, 12 Aug 2025 11:17:00 +0800 Subject: [PATCH 02/15] move callback into locked area Signed-off-by: ZhaoPengfei --- .../graphic_adapter/include/vsync_adapter_impl.h | 1 - .../graphic_adapter/src/vsync_adapter_impl.cpp | 14 +++++--------- .../graphic_adapter_test/graphic_adapter_test.cpp | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ohos_adapter/graphic_adapter/include/vsync_adapter_impl.h b/ohos_adapter/graphic_adapter/include/vsync_adapter_impl.h index ee5ad1b0c..b29b2267d 100644 --- a/ohos_adapter/graphic_adapter/include/vsync_adapter_impl.h +++ b/ohos_adapter/graphic_adapter/include/vsync_adapter_impl.h @@ -65,7 +65,6 @@ private: }; std::shared_ptr frameRateLinker_; static void (*callback_)(); - static void (*onVsyncEndCallback_)(); bool frameRateLinkerEnable_ = false; bool isGPUProcess_ = false; std::string pkgName_ {""}; diff --git a/ohos_adapter/graphic_adapter/src/vsync_adapter_impl.cpp b/ohos_adapter/graphic_adapter/src/vsync_adapter_impl.cpp index 5db1fdac0..b7659644c 100644 --- a/ohos_adapter/graphic_adapter/src/vsync_adapter_impl.cpp +++ b/ohos_adapter/graphic_adapter/src/vsync_adapter_impl.cpp @@ -33,7 +33,6 @@ const std::string APS_CLIENT_SO = "/system/lib64/libaps_client.z.so"; } void (*VSyncAdapterImpl::callback_)() = nullptr; -void (*VSyncAdapterImpl::onVsyncEndCallback_)() = nullptr; VSyncAdapterImpl::~VSyncAdapterImpl() { @@ -127,13 +126,7 @@ void VSyncAdapterImpl::OnVsync(int64_t timestamp, void* client) { auto vsyncClient = static_cast(client); if (vsyncClient) { - if (callback_) { - callback_(); - } vsyncClient->VsyncCallbackInner(timestamp); - if (onVsyncEndCallback_) { - onVsyncEndCallback_(); - } } else { WVLOG_E("VsyncClient is null"); } @@ -143,6 +136,10 @@ void VSyncAdapterImpl::VsyncCallbackInner(int64_t timestamp) { std::unordered_map vsyncCallbacks; std::lock_guard lock(mtx_); + if (callback_) { + callback_(); + } + vsyncCallbacks = vsyncCallbacks_; vsyncCallbacks_.clear(); @@ -199,13 +196,12 @@ void VSyncAdapterImpl::SetFramePreferredRate(int32_t preferredRate) void VSyncAdapterImpl::SetOnVsyncCallback(void (*callback)()) { WVLOG_D("callback function: %{public}ld", (long)callback); + std::lock_guard lock(mtx_); callback_ = callback; } void VSyncAdapterImpl::SetOnVsyncEndCallback(void (*onVsyncEndCallback)()) { - WVLOG_D("onVsyncEndCallback function: %{public}ld", (long)onVsyncEndCallback); - onVsyncEndCallback_ = onVsyncEndCallback; } void VSyncAdapterImpl::SetIsGPUProcess(bool isGPU) diff --git a/test/unittest/ohos_adapter/graphic_adapter_test/graphic_adapter_test.cpp b/test/unittest/ohos_adapter/graphic_adapter_test/graphic_adapter_test.cpp index 00830b863..a56728b65 100644 --- a/test/unittest/ohos_adapter/graphic_adapter_test/graphic_adapter_test.cpp +++ b/test/unittest/ohos_adapter/graphic_adapter_test/graphic_adapter_test.cpp @@ -107,6 +107,7 @@ HWTEST_F(GraphicAdapterTest, GraphicAdapterTest_RequestVsync_001, TestSize.Level adapter.OnVsync(1, client); client = &vsyncAdapter; adapter.OnVsync(1, client); + adapter.VsyncCallbackInner(0); adapter.VsyncCallbackInner(1); int64_t period = adapter.GetVSyncPeriod(); EXPECT_EQ(period, 0); -- Gitee From 5c6711f86957cf940b0b535878a82e22ce45e602 Mon Sep 17 00:00:00 2001 From: xuefuzhang Date: Thu, 14 Aug 2025 15:38:38 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=B3=84=E9=9C=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuefuzhang --- interfaces/kits/cj/include/web_scheme_handler_request.h | 4 ++-- .../napi/webviewcontroller/web_scheme_handler_request.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/cj/include/web_scheme_handler_request.h b/interfaces/kits/cj/include/web_scheme_handler_request.h index 68169f350..ef69c421d 100644 --- a/interfaces/kits/cj/include/web_scheme_handler_request.h +++ b/interfaces/kits/cj/include/web_scheme_handler_request.h @@ -61,7 +61,7 @@ namespace OHOS::Webview { }; ~WebHttpBodyStreamImpl() { - if (!stream_) { + if (stream_) { OH_ArkWebResourceRequest_DestroyHttpBodyStream(stream_); stream_ = nullptr; } @@ -209,4 +209,4 @@ namespace OHOS::Webview { ArkWeb_ResourceHandler* handler_ = nullptr; }; } -#endif // WEB_SCHEME_HANDLER_REQUEST_H \ No newline at end of file +#endif // WEB_SCHEME_HANDLER_REQUEST_H diff --git a/interfaces/kits/napi/webviewcontroller/web_scheme_handler_request.cpp b/interfaces/kits/napi/webviewcontroller/web_scheme_handler_request.cpp index 12f390273..f30ebba9a 100644 --- a/interfaces/kits/napi/webviewcontroller/web_scheme_handler_request.cpp +++ b/interfaces/kits/napi/webviewcontroller/web_scheme_handler_request.cpp @@ -665,7 +665,7 @@ WebHttpBodyStream::WebHttpBodyStream(napi_env env, WebHttpBodyStream::~WebHttpBodyStream() { WVLOG_D("WebHttpBodyStream::~WebHttpBodyStream"); - if (!stream_) { + if (stream_) { OH_ArkWebResourceRequest_DestroyHttpBodyStream(stream_); stream_ = nullptr; } -- Gitee From 0cd81aaa0da3668d78988bb2b2448afc4a1ffaa3 Mon Sep 17 00:00:00 2001 From: SprucEovo Date: Mon, 18 Aug 2025 09:23:43 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SprucEovo --- .../kits/napi/webviewcontroller/napi_webview_controller.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp index 04999f2b5..060260b1d 100644 --- a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp +++ b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp @@ -6916,6 +6916,7 @@ napi_value NapiWebviewController::GetPageOffset(napi_env env, if (!webviewController) { return nullptr; } + webviewController->GetPageOffset(&offsetX, &offsetY); napi_create_object(env, &result); napi_create_double(env, static_cast(offsetX), &horizontal); napi_create_double(env, static_cast(offsetY), &vertical); -- Gitee From b6c479f9b31d3f001c7e47cb5ae6515dc466be37 Mon Sep 17 00:00:00 2001 From: taoxueao Date: Mon, 18 Aug 2025 02:30:48 +0000 Subject: [PATCH 05/15] update ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp. Signed-off-by: taoxueao --- .../src/system_properties_adapter_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp b/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp index 7eb15da90..73e9970e2 100644 --- a/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp +++ b/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp @@ -188,9 +188,9 @@ std::string SystemPropertiesAdapterImpl::GetUserAgentOSName() std::string SystemPropertiesAdapterImpl::GetUserAgentOSVersion() { - return OHOS::system::GetParameter("const.product.os.dist.apiname", "").empty() ? - OHOS::system::GetParameter("const.product.os.dist.version", "") : - OHOS::system::GetParameter("const.product.os.dist.apiname", ""); + std::string apiname = OHOS::system::GetParameter("const.product.os.dist.apiname", ""); + std::string version = OHOS::system::GetParameter("const.product.os.dist.version", ""); + return apiname.empty() ? version : apiname; } std::string SystemPropertiesAdapterImpl::GetUserAgentBaseOSName() -- Gitee From 9c896373f3a71812da9d0c680c2b30c29893e2fc Mon Sep 17 00:00:00 2001 From: SprucEovo Date: Mon, 18 Aug 2025 10:47:27 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E8=93=9D=E9=BB=84=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SprucEovo --- interfaces/kits/napi/js/webview_export.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/napi/js/webview_export.js b/interfaces/kits/napi/js/webview_export.js index 29518b169..e68300ece 100644 --- a/interfaces/kits/napi/js/webview_export.js +++ b/interfaces/kits/napi/js/webview_export.js @@ -79,9 +79,9 @@ function takePhoto(param, selectResult) { .then((pickerResult) => { selectResult.handleFileList([pickerResult.resultUri]); }).catch((error) => { - console.log('selectFile error:' + JSON.stringify(error)); - throw error; - }); + console.log('selectFile error:' + JSON.stringify(error)); + throw error; + }); } catch (error) { console.log('the pick call failed, error code' + JSON.stringify(error)); @@ -116,9 +116,9 @@ function selectFile(param, result) { let filePath = documentSelectResult; result.handleFileList(filePath); }).catch((error) => { - console.log('selectFile error: ' + JSON.stringify(error)); - throw error; - }); + console.log('selectFile error: ' + JSON.stringify(error)); + throw error; + }); } else { documentPicker.save(createDocumentSaveOptions(param)) .then((documentSaveResult) => { -- Gitee From 338a525e1fa505aabd52a3443ed7926a36259e11 Mon Sep 17 00:00:00 2001 From: SprucEovo Date: Mon, 18 Aug 2025 10:54:14 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SprucEovo --- interfaces/kits/napi/js/webview_export.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/napi/js/webview_export.js b/interfaces/kits/napi/js/webview_export.js index e68300ece..b943813e3 100644 --- a/interfaces/kits/napi/js/webview_export.js +++ b/interfaces/kits/napi/js/webview_export.js @@ -133,10 +133,10 @@ function selectFile(param, result) { let watcher = fileIo.createWatcher(tempPath, 0x4, () => { fileIo.copy(tempUri, filePaths[0]).then(() => { - console.log('Web save file succeeded in copying.'); + console.log('Web save file succeeded in copying. '); fileIo.unlink(tempPath); }).catch((err) => { - console.error(`Web save file failed to copy: ${JSON.stringify(err)}.`); + console.error(`Web save file failed to copy: ${JSON.stringify(err)}`); }).finally(() => { watcher.stop(); }); @@ -145,9 +145,9 @@ function selectFile(param, result) { } result.handleFileList([tempUri]); }).catch((error) => { - console.log('saveFile error: ' + JSON.stringify(error)); - throw error; - }); + console.log('saveFile error: ' + JSON.stringify(error)); + throw error; + }); } } catch (error) { console.log('picker error: ' + JSON.stringify(error)); @@ -496,7 +496,7 @@ Object.defineProperty(webview.WebviewController.prototype, 'fileSelectorShowFrom console.error(`openCustomDialog error code is ${error.code}, message is ${error.message}`); }); } else if (callback.fileparam.isCapture() && - (isContainImageMimeType(callback.fileparam.getAcceptType()) || isContainVideoMimeType(callback.fileparam.getAcceptType()))) { + (isContainImageMimeType(callback.fileparam.getAcceptType()) || isContainVideoMimeType(callback.fileparam.getAcceptType()))) { console.log('take photo will be directly invoked due to the capture property'); takePhoto(callback.fileparam, callback.fileresult); } else { -- Gitee From 7e32a4f7b1f6973e5768a13d439cf07c000bb57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9C=89=E5=BA=B7?= Date: Mon, 18 Aug 2025 11:47:24 +0800 Subject: [PATCH 08/15] 8/18 sync code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张有康 --- .../napi_webview_controller.cpp | 596 +++++++++--------- .../include/ohos_nweb/nweb_autofill.h | 4 +- .../ark_web_accessibility_node_info_impl.cpp | 10 +- .../ark_web_accessibility_node_info_impl.h | 4 +- 4 files changed, 308 insertions(+), 306 deletions(-) diff --git a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp index 4771f5c3d..2eb0d05c1 100644 --- a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp +++ b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp @@ -72,14 +72,14 @@ constexpr int32_t MAX_DATABASE_SIZE_IN_MB = 100; constexpr uint32_t MAX_KEYS_COUNT = 100; constexpr size_t MAX_KEY_LENGTH = 2048; constexpr size_t MAX_URL_TRUST_LIST_STR_LEN = 10 * 1024 * 1024; // 10M +constexpr size_t BFCACHE_DEFAULT_SIZE = 1; +constexpr size_t BFCACHE_DEFAULT_TIMETOLIVE = 600; constexpr double A4_WIDTH = 8.27; constexpr double A4_HEIGHT = 11.69; constexpr double SCALE_MIN = 0.1; constexpr double SCALE_MAX = 2.0; constexpr double HALF = 2.0; constexpr double TEN_MILLIMETER_TO_INCH = 0.39; -constexpr size_t BFCACHE_DEFAULT_SIZE = 1; -constexpr size_t BFCACHE_DEFAULT_TIMETOLIVE = 600; constexpr const char* EVENT_ATTACH_STATE_CHANGE = "controllerAttachStateChange"; using WebPrintWriteResultCallback = std::function; @@ -630,7 +630,7 @@ napi_value NapiWebviewController::Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("getCustomUserAgent", NapiWebviewController::GetCustomUserAgent), DECLARE_NAPI_FUNCTION("setCustomUserAgent", NapiWebviewController::SetCustomUserAgent), DECLARE_NAPI_FUNCTION("getTitle", NapiWebviewController::GetTitle), - DECLARE_NAPI_FUNCTION("getProgress", NapiWebviewController::GetProgress), + DECLARE_NAPI_FUNCTION("getProgress", NapiWebviewController::GetProgress), DECLARE_NAPI_FUNCTION("getPageHeight", NapiWebviewController::GetPageHeight), DECLARE_NAPI_FUNCTION("backOrForward", NapiWebviewController::BackOrForward), DECLARE_NAPI_FUNCTION("storeWebArchive", NapiWebviewController::StoreWebArchive), @@ -654,6 +654,7 @@ napi_value NapiWebviewController::Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("deleteJavaScriptRegister", NapiWebviewController::DeleteJavaScriptRegister), DECLARE_NAPI_FUNCTION("runJavaScript", NapiWebviewController::RunJavaScript), DECLARE_NAPI_FUNCTION("runJavaScriptExt", NapiWebviewController::RunJavaScriptExt), + DECLARE_NAPI_FUNCTION("createPdf", NapiWebviewController::RunCreatePDFExt), DECLARE_NAPI_FUNCTION("getUrl", NapiWebviewController::GetUrl), DECLARE_NAPI_FUNCTION("terminateRenderProcess", NapiWebviewController::TerminateRenderProcess), DECLARE_NAPI_FUNCTION("getOriginalUrl", NapiWebviewController::GetOriginalUrl), @@ -743,13 +744,12 @@ napi_value NapiWebviewController::Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("setBackForwardCacheOptions", NapiWebviewController::SetBackForwardCacheOptions), DECLARE_NAPI_FUNCTION("scrollByWithResult", NapiWebviewController::ScrollByWithResult), DECLARE_NAPI_FUNCTION("updateInstanceId", NapiWebviewController::UpdateInstanceId), - DECLARE_NAPI_STATIC_FUNCTION("trimMemoryByPressureLevel", - NapiWebviewController::TrimMemoryByPressureLevel), DECLARE_NAPI_FUNCTION("getScrollOffset", NapiWebviewController::GetScrollOffset), DECLARE_NAPI_FUNCTION("getPageOffset", NapiWebviewController::GetPageOffset), - DECLARE_NAPI_FUNCTION("createPdf", NapiWebviewController::RunCreatePDFExt), + DECLARE_NAPI_STATIC_FUNCTION("trimMemoryByPressureLevel", + NapiWebviewController::TrimMemoryByPressureLevel), DECLARE_NAPI_FUNCTION("getLastHitTest", NapiWebviewController::GetLastHitTest), DECLARE_NAPI_FUNCTION("getAttachState", NapiWebviewController::GetAttachState), DECLARE_NAPI_FUNCTION("on", NapiWebviewController::On), @@ -972,6 +972,16 @@ napi_value NapiWebviewController::Init(napi_env env, napi_value exports) sizeof(offlineResourceTypeProperties[0]), offlineResourceTypeProperties, &offlineResourceTypeEnum); napi_set_named_property(env, exports, OFFLINE_RESOURCE_TYPE_ENUM_NAME.c_str(), offlineResourceTypeEnum); + napi_value scrollTypeEnum = nullptr; + napi_property_descriptor scrollTypeProperties[] = { + DECLARE_NAPI_STATIC_PROPERTY("EVENT", NapiParseUtils::ToInt32Value(env, + static_cast(ScrollType::EVENT))), + }; + napi_define_class(env, WEB_SCROLL_TYPE_ENUM_NAME.c_str(), WEB_SCROLL_TYPE_ENUM_NAME.length(), + NapiParseUtils::CreateEnumConstructor, nullptr, sizeof(scrollTypeProperties) / + sizeof(scrollTypeProperties[0]), scrollTypeProperties, &scrollTypeEnum); + napi_set_named_property(env, exports, WEB_SCROLL_TYPE_ENUM_NAME.c_str(), scrollTypeEnum); + napi_value pressureLevelEnum = nullptr; napi_property_descriptor pressureLevelProperties[] = { DECLARE_NAPI_STATIC_PROPERTY("MEMORY_PRESSURE_LEVEL_MODERATE", NapiParseUtils::ToInt32Value(env, @@ -984,16 +994,6 @@ napi_value NapiWebviewController::Init(napi_env env, napi_value exports) sizeof(pressureLevelProperties[0]), pressureLevelProperties, &pressureLevelEnum); napi_set_named_property(env, exports, WEB_PRESSURE_LEVEL_ENUM_NAME.c_str(), pressureLevelEnum); - napi_value scrollTypeEnum = nullptr; - napi_property_descriptor scrollTypeProperties[] = { - DECLARE_NAPI_STATIC_PROPERTY("EVENT", NapiParseUtils::ToInt32Value(env, - static_cast(ScrollType::EVENT))), - }; - napi_define_class(env, WEB_SCROLL_TYPE_ENUM_NAME.c_str(), WEB_SCROLL_TYPE_ENUM_NAME.length(), - NapiParseUtils::CreateEnumConstructor, nullptr, sizeof(scrollTypeProperties) / - sizeof(scrollTypeProperties[0]), scrollTypeProperties, &scrollTypeEnum); - napi_set_named_property(env, exports, WEB_SCROLL_TYPE_ENUM_NAME.c_str(), scrollTypeEnum); - napi_value controllerAttachStateEnum = nullptr; napi_property_descriptor controllerAttachStateProperties[] = { DECLARE_NAPI_STATIC_PROPERTY("UNATTACHED", NapiParseUtils::ToInt32Value(env, @@ -4617,6 +4617,7 @@ napi_value NapiWebviewController::ScrollTo(napi_env env, napi_callback_info info BusinessError::ThrowErrorByErrcode(env, INIT_ERROR); return nullptr; } + if (argc == INTEGER_THREE) { webviewController->ScrollToWithAnime(x, y, duration); } else { @@ -4668,6 +4669,7 @@ napi_value NapiWebviewController::ScrollBy(napi_env env, napi_callback_info info BusinessError::ThrowErrorByErrcode(env, INIT_ERROR); return nullptr; } + if (argc == INTEGER_THREE) { webviewController->ScrollByWithAnime(deltaX, deltaY, duration); } else { @@ -5041,92 +5043,6 @@ napi_value NapiWebviewController::PrefetchResource(napi_env env, napi_callback_i return result; } -napi_value NapiWebviewController::ClearPrefetchedResource(napi_env env, napi_callback_info info) -{ - napi_value thisVar = nullptr; - napi_value result = nullptr; - size_t argc = INTEGER_ONE; - napi_value argv[INTEGER_ONE] = { 0 }; - napi_get_undefined(env, &result); - napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); - if (argc != INTEGER_ONE) { - WVLOG_E("BusinessError: 401. Arg count must be 1."); - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); - return nullptr; - } - - std::vector cacheKeyList; - if (!ParseCacheKeyList(env, argv[INTEGER_ZERO], &cacheKeyList)) { - WVLOG_E("BusinessError: 401. The type of 'cacheKeyList' must be Array of string."); - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); - return nullptr; - } - - NAPI_CALL(env, napi_get_undefined(env, &result)); - NWebHelper::Instance().ClearPrefetchedResource(cacheKeyList); - return result; -} - -napi_value NapiWebviewController::SetDownloadDelegate(napi_env env, napi_callback_info info) -{ - WVLOG_D("WebDownloader::JS_SetDownloadDelegate"); - NWebHelper::Instance().LoadNWebSDK(); - size_t argc = 1; - napi_value argv[1] = {0}; - napi_value thisVar = nullptr; - void* data = nullptr; - napi_get_cb_info(env, info, &argc, argv, &thisVar, &data); - - WebDownloadDelegate* delegate = nullptr; - napi_value obj = argv[0]; - napi_unwrap(env, obj, (void**)&delegate); - if (!delegate) { - WVLOG_E("[DOWNLOAD] WebDownloader::JS_SetDownloadDelegate delegate is null"); - (void)RemoveDownloadDelegateRef(env, thisVar); - return nullptr; - } - napi_create_reference(env, obj, 1, &delegate->delegate_); - - WebviewController *webviewController = nullptr; - NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&webviewController)); - if (webviewController == nullptr || !webviewController->IsInit()) { - BusinessError::ThrowErrorByErrcode(env, INIT_ERROR); - WVLOG_E("create message port failed, napi unwrap webviewController failed"); - return nullptr; - } - int32_t nwebId = webviewController->GetWebId(); - WebDownloadManager::AddDownloadDelegateForWeb(nwebId, delegate); - return nullptr; -} - -napi_value NapiWebviewController::StartDownload(napi_env env, napi_callback_info info) -{ - WVLOG_D("[DOWNLOAD] NapiWebviewController::StartDownload"); - size_t argc = 1; - napi_value argv[1] = {0}; - napi_value thisVar = nullptr; - void* data = nullptr; - napi_get_cb_info(env, info, &argc, argv, &thisVar, &data); - - WebviewController *webviewController = nullptr; - NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&webviewController)); - if (webviewController == nullptr || !webviewController->IsInit()) { - BusinessError::ThrowErrorByErrcode(env, INIT_ERROR); - WVLOG_E("create message port failed, napi unwrap webviewController failed"); - return nullptr; - } - - std::string url; - if (!ParsePrepareUrl(env, argv[INTEGER_ZERO], url)) { - BusinessError::ThrowErrorByErrcode(env, INVALID_URL); - return nullptr; - } - int32_t nwebId = webviewController->GetWebId(); - NWebHelper::Instance().LoadNWebSDK(); - WebDownloader_StartDownload(nwebId, url.c_str()); - return nullptr; -} - napi_value NapiWebviewController::CloseAllMediaPresentations(napi_env env, napi_callback_info info) { napi_value result = nullptr; @@ -5192,27 +5108,29 @@ napi_value NapiWebviewController::GetMediaPlaybackState(napi_env env, napi_callb return result; } -napi_value NapiWebviewController::SetConnectionTimeout(napi_env env, napi_callback_info info) +napi_value NapiWebviewController::ClearPrefetchedResource(napi_env env, napi_callback_info info) { + napi_value thisVar = nullptr; napi_value result = nullptr; size_t argc = INTEGER_ONE; - napi_value argv[INTEGER_ONE] = { nullptr }; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + napi_value argv[INTEGER_ONE] = { 0 }; + napi_get_undefined(env, &result); + napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); if (argc != INTEGER_ONE) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "one")); - return result; + WVLOG_E("BusinessError: 401. Arg count must be 1."); + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); + return nullptr; } - int32_t timeout = 0; - if (!NapiParseUtils::ParseInt32(env, argv[INTEGER_ZERO], timeout) || (timeout <= 0)) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - "BusinessError: 401. Parameter error. The type of 'timeout' must be int and must be positive integer."); - return result; + std::vector cacheKeyList; + if (!ParseCacheKeyList(env, argv[INTEGER_ZERO], &cacheKeyList)) { + WVLOG_E("BusinessError: 401. The type of 'cacheKeyList' must be Array of string."); + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); + return nullptr; } - NWebHelper::Instance().SetConnectionTimeout(timeout); NAPI_CALL(env, napi_get_undefined(env, &result)); + NWebHelper::Instance().ClearPrefetchedResource(cacheKeyList); return result; } @@ -5564,6 +5482,91 @@ napi_value NapiWebPrintDocument::JsConstructor(napi_env env, napi_callback_info return thisVar; } +napi_value NapiWebviewController::SetDownloadDelegate(napi_env env, napi_callback_info info) +{ + WVLOG_D("WebDownloader::JS_SetDownloadDelegate"); + NWebHelper::Instance().LoadNWebSDK(); + + size_t argc = 1; + napi_value argv[1] = {0}; + napi_value thisVar = nullptr; + void* data = nullptr; + napi_get_cb_info(env, info, &argc, argv, &thisVar, &data); + + WebDownloadDelegate* delegate = nullptr; + napi_value obj = argv[0]; + napi_unwrap(env, obj, (void**)&delegate); + if (!delegate) { + WVLOG_E("[DOWNLOAD] WebDownloader::JS_SetDownloadDelegate delegate is null"); + (void)RemoveDownloadDelegateRef(env, thisVar); + return nullptr; + } + napi_create_reference(env, obj, 1, &delegate->delegate_); + + WebviewController *webviewController = nullptr; + NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&webviewController)); + if (webviewController == nullptr || !webviewController->IsInit()) { + BusinessError::ThrowErrorByErrcode(env, INIT_ERROR); + WVLOG_E("create message port failed, napi unwrap webviewController failed"); + return nullptr; + } + int32_t nwebId = webviewController->GetWebId(); + WebDownloadManager::AddDownloadDelegateForWeb(nwebId, delegate); + return nullptr; +} + +napi_value NapiWebviewController::StartDownload(napi_env env, napi_callback_info info) +{ + WVLOG_D("[DOWNLOAD] NapiWebviewController::StartDownload"); + size_t argc = 1; + napi_value argv[1] = {0}; + napi_value thisVar = nullptr; + void* data = nullptr; + napi_get_cb_info(env, info, &argc, argv, &thisVar, &data); + + WebviewController *webviewController = nullptr; + NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&webviewController)); + if (webviewController == nullptr || !webviewController->IsInit()) { + BusinessError::ThrowErrorByErrcode(env, INIT_ERROR); + WVLOG_E("create message port failed, napi unwrap webviewController failed"); + return nullptr; + } + + std::string url; + if (!ParsePrepareUrl(env, argv[INTEGER_ZERO], url)) { + BusinessError::ThrowErrorByErrcode(env, INVALID_URL); + return nullptr; + } + int32_t nwebId = webviewController->GetWebId(); + NWebHelper::Instance().LoadNWebSDK(); + WebDownloader_StartDownload(nwebId, url.c_str()); + return nullptr; +} + +napi_value NapiWebviewController::SetConnectionTimeout(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + size_t argc = INTEGER_ONE; + napi_value argv[INTEGER_ONE] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != INTEGER_ONE) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "one")); + return result; + } + + int32_t timeout = 0; + if (!NapiParseUtils::ParseInt32(env, argv[INTEGER_ZERO], timeout) || (timeout <= 0)) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + "BusinessError: 401. Parameter error. The type of 'timeout' must be int and must be positive integer."); + return result; + } + + NWebHelper::Instance().SetConnectionTimeout(timeout); + NAPI_CALL(env, napi_get_undefined(env, &result)); + return result; +} + napi_value NapiWebviewController::SetPrintBackground(napi_env env, napi_callback_info info) { napi_value result = nullptr; @@ -5746,6 +5749,7 @@ napi_value NapiWebviewController::EnableIntelligentTrackingPrevention( WebviewController *webviewController = GetWebviewController(env, info); if (!webviewController) { + WVLOG_E("EnableIntelligentTrackingPrevention failed for webviewController failed"); return result; } webviewController->EnableIntelligentTrackingPrevention(enabled); @@ -5767,6 +5771,7 @@ napi_value NapiWebviewController::IsIntelligentTrackingPreventionEnabled( WebviewController *webviewController = GetWebviewController(env, info); if (!webviewController) { + WVLOG_E("IsIntelligentTrackingPreventionEnabled failed for webviewController failed"); return result; } @@ -6248,29 +6253,6 @@ napi_value NapiWebviewController::SetUserAgentForHosts(napi_env env, napi_callba return result; } -napi_value NapiWebviewController::WarmupServiceWorker(napi_env env, napi_callback_info info) -{ - napi_value thisVar = nullptr; - napi_value result = nullptr; - size_t argc = INTEGER_ONE; - napi_value argv[INTEGER_ONE] = { 0 }; - napi_get_undefined(env, &result); - napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); - if (argc != INTEGER_ONE) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); - return result; - } - - std::string url; - if (!ParsePrepareUrl(env, argv[INTEGER_ZERO], url)) { - BusinessError::ThrowErrorByErrcode(env, INVALID_URL); - return result; - } - - NWebHelper::Instance().WarmupServiceWorker(url); - return result; -} - napi_value NapiWebviewController::InjectOfflineResources(napi_env env, napi_callback_info info) { napi_value thisVar = nullptr; @@ -6449,13 +6431,49 @@ napi_value NapiWebviewController::ClearHostIP(napi_env env, napi_callback_info i return result; } -napi_value NapiWebviewController::EnableWholeWebPageDrawing( - napi_env env, napi_callback_info info) +napi_value NapiWebviewController::WarmupServiceWorker(napi_env env, napi_callback_info info) { + napi_value thisVar = nullptr; napi_value result = nullptr; - NWebHelper::Instance().EnableWholeWebPageDrawing(); - NAPI_CALL(env, napi_get_undefined(env, &result)); - return result; + size_t argc = INTEGER_ONE; + napi_value argv[INTEGER_ONE] = { 0 }; + napi_get_undefined(env, &result); + napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); + if (argc != INTEGER_ONE) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); + return result; + } + + std::string url; + if (!ParsePrepareUrl(env, argv[INTEGER_ZERO], url)) { + BusinessError::ThrowErrorByErrcode(env, INVALID_URL); + return result; + } + + NWebHelper::Instance().WarmupServiceWorker(url); + return result; +} + +napi_value NapiWebviewController::GetSurfaceId(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + WebviewController *webviewController = GetWebviewController(env, info); + if (!webviewController) { + return nullptr; + } + + std::string surfaceId = webviewController->GetSurfaceId(); + napi_create_string_utf8(env, surfaceId.c_str(), surfaceId.length(), &result); + return result; +} + +napi_value NapiWebviewController::EnableWholeWebPageDrawing( + napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + NWebHelper::Instance().EnableWholeWebPageDrawing(); + NAPI_CALL(env, napi_get_undefined(env, &result)); + return result; } napi_value NapiWebviewController::EnableAdsBlock( @@ -6535,97 +6553,6 @@ napi_value NapiWebviewController::IsAdsBlockEnabledForCurPage(napi_env env, napi return result; } -napi_value NapiWebviewController::GetSurfaceId(napi_env env, napi_callback_info info) -{ - napi_value result = nullptr; - WebviewController *webviewController = GetWebviewController(env, info); - if (!webviewController) { - return nullptr; - } - - std::string surfaceId = webviewController->GetSurfaceId(); - napi_create_string_utf8(env, surfaceId.c_str(), surfaceId.length(), &result); - return result; -} - -napi_value NapiWebviewController::UpdateInstanceId(napi_env env, napi_callback_info info) -{ - WVLOG_D("Instance changed"); - napi_value result = nullptr; - napi_value thisVar = nullptr; - size_t argc = INTEGER_ONE; - napi_value argv[INTEGER_ONE] = { 0 }; - - napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); - if (argc != INTEGER_ONE) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); - return result; - } - - int32_t newId = 0; - if (!NapiParseUtils::ParseInt32(env, argv[INTEGER_ZERO], newId)) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); - return result; - } - - WebviewController *webviewController = nullptr; - napi_status status = napi_unwrap(env, thisVar, (void **)&webviewController); - if ((!webviewController) || (status != napi_ok) || !webviewController->IsInit()) { - return result; - } - - webviewController->UpdateInstanceId(newId); - - NAPI_CALL(env, napi_get_undefined(env, &result)); - return result; -} - -napi_value NapiWebviewController::SetUrlTrustList(napi_env env, napi_callback_info info) -{ - WVLOG_D("SetUrlTrustList invoked"); - - napi_value result = nullptr; - NAPI_CALL(env, napi_get_undefined(env, &result)); - - napi_value thisVar = nullptr; - size_t argc = INTEGER_ONE; - napi_value argv[INTEGER_ONE] = { 0 }; - napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); - if (argc != INTEGER_ONE) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "one")); - return result; - } - - std::string urlTrustList; - if (!NapiParseUtils::ParseString(env, argv[0], urlTrustList)) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, "urlTrustList", "string")); - return result; - } - if (urlTrustList.size() > MAX_URL_TRUST_LIST_STR_LEN) { - WVLOG_E("EnableAdsBlock: url trust list len is too large."); - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); - return result; - } - - WebviewController* webviewController = GetWebviewController(env, info); - if (!webviewController) { - WVLOG_E("webview controller is null or not init"); - return result; - } - - std::string detailMsg; - ErrCode ret = webviewController->SetUrlTrustList(urlTrustList, detailMsg); - if (ret != NO_ERROR) { - WVLOG_E("SetUrlTrustList failed, error code: %{public}d", ret); - BusinessError::ThrowErrorByErrcode(env, ret, - NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_DETAIL_ERROR_MSG, detailMsg.c_str())); - return result; - } - return result; -} - WebSnapshotCallback CreateWebPageSnapshotResultCallback( napi_env env, napi_ref jsCallback, bool check, int32_t inputWidth, int32_t inputHeight) { @@ -6817,6 +6744,84 @@ napi_value NapiWebviewController::WebPageSnapshot(napi_env env, napi_callback_in return result; } +napi_value NapiWebviewController::SetUrlTrustList(napi_env env, napi_callback_info info) +{ + WVLOG_D("SetUrlTrustList invoked"); + + napi_value result = nullptr; + NAPI_CALL(env, napi_get_undefined(env, &result)); + + napi_value thisVar = nullptr; + size_t argc = INTEGER_ONE; + napi_value argv[INTEGER_ONE] = { 0 }; + napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); + if (argc != INTEGER_ONE) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "one")); + return result; + } + + std::string urlTrustList; + if (!NapiParseUtils::ParseString(env, argv[0], urlTrustList)) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, "urlTrustList", "string")); + return result; + } + if (urlTrustList.size() > MAX_URL_TRUST_LIST_STR_LEN) { + WVLOG_E("url trust list len is too large."); + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); + return result; + } + + WebviewController* webviewController = GetWebviewController(env, info); + if (!webviewController) { + WVLOG_E("webview controller is null or not init"); + return result; + } + + std::string detailMsg; + ErrCode ret = webviewController->SetUrlTrustList(urlTrustList, detailMsg); + if (ret != NO_ERROR) { + WVLOG_E("SetUrlTrustList failed, error code: %{public}d", ret); + BusinessError::ThrowErrorByErrcode(env, ret, + NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_DETAIL_ERROR_MSG, detailMsg.c_str())); + return result; + } + return result; +} + +napi_value NapiWebviewController::UpdateInstanceId(napi_env env, napi_callback_info info) +{ + WVLOG_D("Instance changed"); + napi_value result = nullptr; + napi_value thisVar = nullptr; + size_t argc = INTEGER_ONE; + napi_value argv[INTEGER_ONE] = { 0 }; + + napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); + if (argc != INTEGER_ONE) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); + return result; + } + + int32_t newId = 0; + if (!NapiParseUtils::ParseInt32(env, argv[INTEGER_ZERO], newId)) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR); + return result; + } + + WebviewController *webviewController = nullptr; + napi_status status = napi_unwrap(env, thisVar, (void **)&webviewController); + if ((!webviewController) || (status != napi_ok) || !webviewController->IsInit()) { + return result; + } + + webviewController->UpdateInstanceId(newId); + + NAPI_CALL(env, napi_get_undefined(env, &result)); + return result; +} + napi_value NapiWebviewController::SetPathAllowingUniversalAccess( napi_env env, napi_callback_info info) { @@ -6867,33 +6872,42 @@ napi_value NapiWebviewController::SetPathAllowingUniversalAccess( return result; } -napi_value NapiWebviewController::TrimMemoryByPressureLevel(napi_env env, - napi_callback_info info) +napi_value NapiWebviewController::ScrollByWithResult(napi_env env, napi_callback_info info) { - napi_value thisVar = nullptr; - napi_value result = nullptr; - size_t argc = INTEGER_ONE; - napi_value argv[INTEGER_ONE] = { 0 }; - int32_t memoryLevel; - napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); - if (argc != INTEGER_ONE) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString( - ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "one")); - return result; - } + napi_value thisVar = nullptr; + napi_value result = nullptr; + size_t argc = INTEGER_TWO; + napi_value argv[INTEGER_TWO] = { 0 }; + float deltaX; + float deltaY; - if (!NapiParseUtils::ParseInt32(env, argv[INTEGER_ZERO], memoryLevel)) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, - "PressureLevel", "number")); - return result; - } + napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); + if (argc != INTEGER_TWO) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "two")); + return result; + } - memoryLevel = memoryLevel == 1 ? 0 : memoryLevel; - NWebHelper::Instance().TrimMemoryByPressureLevel(memoryLevel); - NAPI_CALL(env, napi_get_undefined(env, &result)); - return result; + if (!NapiParseUtils::ParseFloat(env, argv[INTEGER_ZERO], deltaX)) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, "deltaX", "number")); + return result; + } + + if (!NapiParseUtils::ParseFloat(env, argv[INTEGER_ONE], deltaY)) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, "deltaY", "number")); + return result; + } + + WebviewController *webviewController = GetWebviewController(env, info); + if (!webviewController) { + return nullptr; + } + + bool scrollByWithResult = webviewController->ScrollByWithResult(deltaX, deltaY); + NAPI_CALL(env, napi_get_boolean(env, scrollByWithResult, &result)); + return result; } napi_value NapiWebviewController::GetScrollOffset(napi_env env, @@ -6904,14 +6918,11 @@ napi_value NapiWebviewController::GetScrollOffset(napi_env env, napi_value vertical; float offsetX = 0; float offsetY = 0; - WebviewController* webviewController = GetWebviewController(env, info); if (!webviewController) { return nullptr; } - webviewController->GetScrollOffset(&offsetX, &offsetY); - napi_create_object(env, &result); napi_create_double(env, static_cast(offsetX), &horizontal); napi_create_double(env, static_cast(offsetY), &vertical); @@ -6945,42 +6956,33 @@ napi_value NapiWebviewController::GetPageOffset(napi_env env, return result; } -napi_value NapiWebviewController::ScrollByWithResult(napi_env env, napi_callback_info info) +napi_value NapiWebviewController::TrimMemoryByPressureLevel(napi_env env, + napi_callback_info info) { - napi_value thisVar = nullptr; - napi_value result = nullptr; - size_t argc = INTEGER_TWO; - napi_value argv[INTEGER_TWO] = { 0 }; - float deltaX; - float deltaY; - - napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); - if (argc != INTEGER_TWO) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "two")); - return result; - } - - if (!NapiParseUtils::ParseFloat(env, argv[INTEGER_ZERO], deltaX)) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, "deltaX", "number")); - return result; - } - - if (!NapiParseUtils::ParseFloat(env, argv[INTEGER_ONE], deltaY)) { - BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, - NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, "deltaY", "number")); - return result; - } + napi_value thisVar = nullptr; + napi_value result = nullptr; + size_t argc = INTEGER_ONE; + napi_value argv[INTEGER_ONE] = { 0 }; + int32_t memoryLevel; + napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); + if (argc != INTEGER_ONE) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString( + ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "one")); + return result; + } - WebviewController *webviewController = GetWebviewController(env, info); - if (!webviewController) { - return nullptr; - } + if (!NapiParseUtils::ParseInt32(env, argv[INTEGER_ZERO], memoryLevel)) { + BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, + NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, + "PressureLevel", "number")); + return result; + } - bool scrollByWithResult = webviewController->ScrollByWithResult(deltaX, deltaY); - NAPI_CALL(env, napi_get_boolean(env, scrollByWithResult, &result)); - return result; + memoryLevel = memoryLevel == 1 ? 0 : memoryLevel; + NWebHelper::Instance().TrimMemoryByPressureLevel(memoryLevel); + NAPI_CALL(env, napi_get_undefined(env, &result)); + return result; } napi_value NapiWebviewController::RemoveAllCache(napi_env env, napi_callback_info info) @@ -7614,7 +7616,7 @@ napi_value NapiWebviewController::EnablePrivateNetworkAccess(napi_env env, napi_ napi_value result = nullptr; size_t argc = INTEGER_ONE; napi_value argv[INTEGER_ONE] = {0}; - + NAPI_CALL(env, napi_get_undefined(env, &result)); napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); if (argc != INTEGER_ONE) { @@ -7622,18 +7624,18 @@ napi_value NapiWebviewController::EnablePrivateNetworkAccess(napi_env env, napi_ NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_NUMBERS_ERROR_ONE, "one")); return result; } - + bool pnaEnabled = false; if (!NapiParseUtils::ParseBoolean(env, argv[0], pnaEnabled)) { BusinessError::ThrowErrorByErrcode(env, PARAM_CHECK_ERROR, NWebError::FormatString(ParamCheckErrorMsgTemplate::TYPE_ERROR, "enable", "boolean")); return result; } - + NWebHelper::Instance().EnablePrivateNetworkAccess(pnaEnabled); return result; } - + napi_value NapiWebviewController::IsPrivateNetworkAccessEnabled(napi_env env, napi_callback_info info) { napi_value result = nullptr; diff --git a/ohos_interface/include/ohos_nweb/nweb_autofill.h b/ohos_interface/include/ohos_nweb/nweb_autofill.h index e3eb979fa..7fc117e61 100644 --- a/ohos_interface/include/ohos_nweb/nweb_autofill.h +++ b/ohos_interface/include/ohos_nweb/nweb_autofill.h @@ -54,8 +54,6 @@ const std::string NWEB_AUTOFILL_TEL_COUNTRY_CODE = "tel-country-code"; const std::string NWEB_AUTOFILL_EMAIL = "email"; const std::string NWEB_AUTOFILL_CC_NUMBER = "cc-number"; const std::string NWEB_AUTOFILL_ID_CARD_NUMBER = "id-card-number"; -const std::string NWEB_AUTOFILL_DETAIL_INFO_WITHOUT_STREET = "detail-info-without-street"; -const std::string NWEB_AUTOFILL_FORMAT_ADDRESS = "format-address"; const std::string NWEB_AUTOFILL_NICKNAME = "nickname"; const std::string NWEB_AUTOFILL_USERNAME = "username"; const std::string NWEB_AUTOFILL_PASSWORD = "password"; @@ -72,6 +70,8 @@ const std::string NWEB_AUTOFILL_LICENSE_FILE_NUMBER = "license-file-number"; const std::string NWEB_AUTOFILL_LICENSE_PLATE = "license-plate"; const std::string NWEB_AUTOFILL_ENGINE_NUMBER = "engine-number"; const std::string NWEB_AUTOFILL_LICENSE_CHASSIS_NUMBER = "license-chassis-number"; +const std::string NWEB_AUTOFILL_DETAIL_INFO_WITHOUT_STREET = "detail-info-without-street"; +const std::string NWEB_AUTOFILL_FORMAT_ADDRESS = "format-address"; enum NWebAutofillEvent { UNKNOWN = 0, diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.cpp index be7881b6d..3f5741f08 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.cpp +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.cpp @@ -289,11 +289,6 @@ ArkWebString ArkWebAccessibilityNodeInfoImpl::GetAccessibilityText() return ArkWebStringClassToStruct(nweb_accessibility_node_info_->GetAccessibilityText()); } -ArkWebString ArkWebAccessibilityNodeInfoImpl::GetHtmlElementId() -{ - return ArkWebStringClassToStruct(nweb_accessibility_node_info_->GetHtmlElementId()); -} - ArkWebString ArkWebAccessibilityNodeInfoImpl::GetComponentTypeDescription() { return ArkWebStringClassToStruct(nweb_accessibility_node_info_->GetComponentTypeDescription()); @@ -308,4 +303,9 @@ ArkWebString ArkWebAccessibilityNodeInfoImpl::GetExpandedState() { return ArkWebStringClassToStruct(nweb_accessibility_node_info_->GetExpandedState()); } + +ArkWebString ArkWebAccessibilityNodeInfoImpl::GetHtmlElementId() +{ + return ArkWebStringClassToStruct(nweb_accessibility_node_info_->GetHtmlElementId()); +} } // namespace OHOS::ArkWeb diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.h b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.h index be2a3d628..924f689f2 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.h +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_accessibility_node_info_impl.h @@ -136,14 +136,14 @@ public: ArkWebString GetAccessibilityText() override; - ArkWebString GetHtmlElementId() override; - ArkWebString GetComponentTypeDescription() override; int32_t GetCheckboxGroupSelectedStatus() override; ArkWebString GetExpandedState() override; + ArkWebString GetHtmlElementId() override; + private: std::shared_ptr nweb_accessibility_node_info_; }; -- Gitee From c7158a349026016e150a960add1757cc647c52de Mon Sep 17 00:00:00 2001 From: SprucEovo Date: Mon, 18 Aug 2025 16:18:11 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SprucEovo --- ohos_nweb/src/nweb_config_helper.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ohos_nweb/src/nweb_config_helper.cpp b/ohos_nweb/src/nweb_config_helper.cpp index 6b1a91e4c..ff97c0fb5 100644 --- a/ohos_nweb/src/nweb_config_helper.cpp +++ b/ohos_nweb/src/nweb_config_helper.cpp @@ -575,12 +575,8 @@ void NWebConfigHelper::ParseWindowOrientationConfig(xmlNodePtr nodePtr, char* orientationPtr = (char *)xmlGetProp(curNodePtr,BAD_CAST(XML_ENABLE_WINDOW_ORIENTATION)); if (!bundleNamePtr || !orientationPtr) { WVLOG_E("invalid bundleNamePtr or orientationPtr!"); - if (bundleNamePtr) { - xmlFree(bundleNamePtr); - } - if (orientationPtr) { - xmlFree(orientationPtr); - } + xmlFree(bundleNamePtr); + xmlFree(orientationPtr); continue; } std::string bundleName(bundleNamePtr); -- Gitee From bb2823fbd7f12d9e9a603c251e4f7daeb00123e0 Mon Sep 17 00:00:00 2001 From: fenggechang Date: Mon, 18 Aug 2025 16:21:43 +0800 Subject: [PATCH 10/15] add errorcode for AvoidVisibleViewportBottom 114 Signed-off-by: fenggechang --- .../kits/napi/webviewcontroller/napi_webview_controller.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp index 4771f5c3d..c2263f1c8 100644 --- a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp +++ b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp @@ -7372,6 +7372,7 @@ napi_value NapiWebviewController::AvoidVisibleViewportBottom(napi_env env, napi_ { if (IS_CALLING_FROM_M114()) { WVLOG_W("AvoidVisibleViewportBottom unsupported engine version: M114"); + BusinessError::ThrowErrorByErrcode(env, CAPABILITY_NOT_SUPPORTED_ERROR); return nullptr; } napi_value thisVar = nullptr; -- Gitee From 1336caacf3ef771fd69d12e0f9afdb5c8c5938cc Mon Sep 17 00:00:00 2001 From: minjiaqi1 Date: Mon, 18 Aug 2025 18:27:07 +0800 Subject: [PATCH 11/15] fix ut test display source mode Signed-off-by: minjiaqi1 --- .../display_manager_adapter_impl_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/display_manager_adapter_impl_test/display_manager_adapter_impl_test.cpp b/test/unittest/display_manager_adapter_impl_test/display_manager_adapter_impl_test.cpp index 908fd92ea..0691597ad 100644 --- a/test/unittest/display_manager_adapter_impl_test/display_manager_adapter_impl_test.cpp +++ b/test/unittest/display_manager_adapter_impl_test/display_manager_adapter_impl_test.cpp @@ -459,7 +459,7 @@ HWTEST_F(DisplayManagerAdapterImplTest, DisplayManagerAdapterImplTest_012, TestS EXPECT_GT(displayAdapterImpl->GetDensityDpi(), 0); EXPECT_GE(displayAdapterImpl->GetX(), 0); EXPECT_GE(displayAdapterImpl->GetY(), 0); - EXPECT_EQ(displayAdapterImpl->GetDisplaySourceMode(), DisplaySourceMode::NONE); + EXPECT_NE(displayAdapterImpl->GetDisplaySourceMode(), DisplaySourceMode::NONE); EXPECT_GE(displayAdapterImpl->GetPhysicalWidth(), 0); EXPECT_GE(displayAdapterImpl->GetPhysicalHeight(), 0); EXPECT_GT(displayAdapterImpl->GetDefaultVirtualPixelRatio(), 0); -- Gitee From 829e9992816037bedc2421fe6f3c3b992619b92f Mon Sep 17 00:00:00 2001 From: taoxueao Date: Mon, 18 Aug 2025 12:47:22 +0000 Subject: [PATCH 12/15] update ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp. Signed-off-by: taoxueao --- .../src/system_properties_adapter_impl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp b/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp index 73e9970e2..9d9b6e0b2 100644 --- a/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp +++ b/ohos_adapter/system_properties_adapter/src/system_properties_adapter_impl.cpp @@ -189,8 +189,7 @@ std::string SystemPropertiesAdapterImpl::GetUserAgentOSName() std::string SystemPropertiesAdapterImpl::GetUserAgentOSVersion() { std::string apiname = OHOS::system::GetParameter("const.product.os.dist.apiname", ""); - std::string version = OHOS::system::GetParameter("const.product.os.dist.version", ""); - return apiname.empty() ? version : apiname; + return apiname.empty() ? OHOS::system::GetParameter("const.product.os.dist.version", "") : apiname; } std::string SystemPropertiesAdapterImpl::GetUserAgentBaseOSName() -- Gitee From e2742207f7e6e2f01dd4ace5ec323ba3b955cf81 Mon Sep 17 00:00:00 2001 From: lizeqiang Date: Mon, 18 Aug 2025 20:54:52 +0800 Subject: [PATCH 13/15] fix dual core predlopen error Signed-off-by: lizeqiang --- arkweb_utils/arkweb_utils.cpp | 4 ++-- arkweb_utils/arkweb_utils.h | 2 +- .../bridge/webview/ark_web_adapter_webview_bridge_helper.cpp | 2 +- .../bridge/webview/ark_web_nweb_webview_bridge_helper.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arkweb_utils/arkweb_utils.cpp b/arkweb_utils/arkweb_utils.cpp index ec54831f7..2e1c63fc1 100644 --- a/arkweb_utils/arkweb_utils.cpp +++ b/arkweb_utils/arkweb_utils.cpp @@ -390,7 +390,7 @@ void* ArkWebBridgeHelperLoadLibFile(int openMode, const std::string& libNsName, return libFileHandler; } -void* ArkWebBridgeHelperSharedInit(bool isPreDlopen, bool runMode) +void* ArkWebBridgeHelperSharedInit(bool runMode) { std::string libFileName = "libarkweb_engine.so"; @@ -411,7 +411,7 @@ void* ArkWebBridgeHelperSharedInit(bool isPreDlopen, bool runMode) libFileHandler = ArkWebBridgeHelperLoadLibFile(RTLD_NOW, libDirPath + "/" + libFileName) #endif - if (!isPreDlopen && libFileHandler != nullptr) { + if (libFileHandler != nullptr) { g_webEngineInitFlag = true; WVLOG_I("g_webEngineInitFlag set to true. setActiveWebEngineVersion will be ignored."); } diff --git a/arkweb_utils/arkweb_utils.h b/arkweb_utils/arkweb_utils.h index 79ccd0185..5038192f9 100644 --- a/arkweb_utils/arkweb_utils.h +++ b/arkweb_utils/arkweb_utils.h @@ -88,7 +88,7 @@ ARKWEB_EXPORT void PreloadArkWebLibForBrowser(); ARKWEB_EXPORT void LogForUnsupportedFunc(ArkWebEngineVersion version, const char* msg); -ARKWEB_EXPORT void* ArkWebBridgeHelperSharedInit(bool isPreDlopen, bool runMode = true); +ARKWEB_EXPORT void* ArkWebBridgeHelperSharedInit(bool runMode = true); } // namespace OHOS::ArkWeb #endif // WEB_WEBVIEW_ARKWEB_UTILS_ARKWEB_UTILS_H \ No newline at end of file diff --git a/ohos_interface/ohos_glue/ohos_adapter/bridge/webview/ark_web_adapter_webview_bridge_helper.cpp b/ohos_interface/ohos_glue/ohos_adapter/bridge/webview/ark_web_adapter_webview_bridge_helper.cpp index d4aa306d4..ea9b65b4a 100644 --- a/ohos_interface/ohos_glue/ohos_adapter/bridge/webview/ark_web_adapter_webview_bridge_helper.cpp +++ b/ohos_interface/ohos_glue/ohos_adapter/bridge/webview/ark_web_adapter_webview_bridge_helper.cpp @@ -36,7 +36,7 @@ void ArkWebAdapterWebviewBridgeHelper::Init() return; } - void* libFileHandler = ArkWebBridgeHelperSharedInit(false); + void* libFileHandler = ArkWebBridgeHelperSharedInit(); if (!libFileHandler) { ARK_WEB_BRIDGE_ERROR_LOG("library resources loaded failed"); return; diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_webview_bridge_helper.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_webview_bridge_helper.cpp index 79cd6cc9a..ff5872812 100644 --- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_webview_bridge_helper.cpp +++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_webview_bridge_helper.cpp @@ -34,7 +34,7 @@ bool ArkWebNWebWebviewBridgeHelper::Init(bool runMode, const std::string& bundle return true; } - void* libFileHandler = ArkWebBridgeHelperSharedInit(false, runMode); + void* libFileHandler = ArkWebBridgeHelperSharedInit(runMode); if (!libFileHandler) { ARK_WEB_BRIDGE_ERROR_LOG("library resources loaded failed"); return false; @@ -75,7 +75,7 @@ void ArkWebNWebWebviewBridgeHelper::PreDlopenLibFile(const std::string& bundlePa return; } - libFileHandler_ = ArkWebBridgeHelperSharedInit(true); + libFileHandler_ = ArkWebBridgeHelperSharedInit(); } } // namespace OHOS::ArkWeb -- Gitee From 762b1929ccf2ad1f347ff6f1f72b1975eb116d7b Mon Sep 17 00:00:00 2001 From: liuao Date: Tue, 19 Aug 2025 16:36:15 +0800 Subject: [PATCH 14/15] 0819 update ArkWebCore.hap to 6.0 Signed-off-by: liuao --- ohos_nweb/prebuilts/arm/ArkWebCore.hap | 4 ++-- ohos_nweb/prebuilts/arm64/ArkWebCore.hap | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ohos_nweb/prebuilts/arm/ArkWebCore.hap b/ohos_nweb/prebuilts/arm/ArkWebCore.hap index 9d6c7ea4c..24b9b7aa9 100644 --- a/ohos_nweb/prebuilts/arm/ArkWebCore.hap +++ b/ohos_nweb/prebuilts/arm/ArkWebCore.hap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a2c746237e03bb072ae214e8e5d2a7115342b8e591cd6b768f162712cd94282 -size 116622817 +oid sha256:4e4e58c3feab41059f7994a25430fd265babbbd734943e1ec7a7ec79c572c249 +size 116631011 diff --git a/ohos_nweb/prebuilts/arm64/ArkWebCore.hap b/ohos_nweb/prebuilts/arm64/ArkWebCore.hap index d29aa0644..071f8db4a 100644 --- a/ohos_nweb/prebuilts/arm64/ArkWebCore.hap +++ b/ohos_nweb/prebuilts/arm64/ArkWebCore.hap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4354c793cc10a8763a10961320468a709ddae61aa9c838e956616289b7e8c1b8 -size 122459582 +oid sha256:6089e61d8b0a963406c475a80042f40566d280937768b8593eda2a9dfd9c34df +size 122455492 -- Gitee From 90fd210c25be943a24976777cd23099212b1e62d Mon Sep 17 00:00:00 2001 From: fuyongyuan Date: Wed, 20 Aug 2025 17:33:58 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=A9=E7=BD=91?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=AD=EF=BC=8Ccrashpad=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E7=9A=84so=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fuyongyuan --- config.gni | 3 ++- ohos_adapter/BUILD.gn | 5 +++++ ohos_nweb/BUILD.gn | 7 +++++++ ohos_nweb/src/nweb_crashpad_handler_main.cpp | 11 ++++++++--- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/config.gni b/config.gni index 14dbc04ac..3085542b6 100644 --- a/config.gni +++ b/config.gni @@ -105,4 +105,5 @@ webview_engine_so = "libarkweb_engine.so" webview_app_hap_path = "/system/app/ArkWeb/ArkWebCore.hap" webview_app_hap_path2 = "/system/app/${webview_package_name}/ArkWebCore.hap" -legacy_webview_sandbox_lib_path = "/data/storage/el1/bundle/arkweblegacy/libs/${target_cpu}" \ No newline at end of file +legacy_webview_sandbox_lib_path = "/data/storage/el1/bundle/arkweblegacy/libs/${target_cpu}" +asan_webview_sandbox_lib_path = "/data/storage/el1/bundle/arkwebcore_asan/libs/${target_cpu}" \ No newline at end of file diff --git a/ohos_adapter/BUILD.gn b/ohos_adapter/BUILD.gn index 1901b59f4..f2bda40cf 100644 --- a/ohos_adapter/BUILD.gn +++ b/ohos_adapter/BUILD.gn @@ -59,6 +59,11 @@ ohos_shared_library("nweb_ohos_adapter") { "WEBVIEW_SANDBOX_PATH=\"${webview_sandbox_path}\"", ] + if (use_hwasan) { + defines += [ + "WEBVIEW_SANDBOX_LIB_PATH_ASAN=\"${asan_webview_sandbox_lib_path}\"", + ] + } sources = [ "aafwk_adapter/src/aafwk_app_mgr_client_adapter_impl.cpp", "aafwk_adapter/src/aafwk_browser_client_adapter_impl.cpp", diff --git a/ohos_nweb/BUILD.gn b/ohos_nweb/BUILD.gn index 0ca315a0a..1ccc21a3e 100644 --- a/ohos_nweb/BUILD.gn +++ b/ohos_nweb/BUILD.gn @@ -37,6 +37,13 @@ defines += [ "WEBVIEW_ENGINE_SO=\"${webview_engine_so}\"", ] +if (use_hwasan) { + defines += [ + "IS_ASAN", + "WEBVIEW_SANDBOX_LIB_PATH_ASAN=\"${asan_webview_sandbox_lib_path}\"", + ] +} + config("nweb_config") { include_dirs = [ "${target_gen_dir}/include" ] include_dirs += [ "include" ] diff --git a/ohos_nweb/src/nweb_crashpad_handler_main.cpp b/ohos_nweb/src/nweb_crashpad_handler_main.cpp index abd52ded0..c59254cde 100644 --- a/ohos_nweb/src/nweb_crashpad_handler_main.cpp +++ b/ohos_nweb/src/nweb_crashpad_handler_main.cpp @@ -48,17 +48,22 @@ std::optional GetEngineType(int argc, char* argv[]) { int main(int argc, char* argv[]) { std::string libCrashpadHandler; + std::string webPath = WEBVIEW_SANDBOX_LIB_PATH; +#if defined(IS_ASAN) && defined(webview_arm64) + if (access(std::string(WEBVIEW_SANDBOX_LIB_PATH_ASAN).c_str(), F_OK) == 0) { + webPath = WEBVIEW_SANDBOX_LIB_PATH_ASAN; + } +#endif if (auto engineType = GetEngineType(argc, argv); engineType.has_value() && engineType.value() == "LEGACY") { libCrashpadHandler = std::string(LEGACY_WEBVIEW_SANDBOX_LIB_PATH) + "/" + std::string(WEBVIEW_CRASHPAD_HANDLER_SO); } else { - libCrashpadHandler = std::string(WEBVIEW_SANDBOX_LIB_PATH) + "/" - + std::string(WEBVIEW_CRASHPAD_HANDLER_SO); + libCrashpadHandler = webPath + "/" + std::string(WEBVIEW_CRASHPAD_HANDLER_SO); } Dl_namespace dlns; dlns_init(&dlns, "nweb_ns"); - dlns_create(&dlns, std::string(WEBVIEW_SANDBOX_LIB_PATH).c_str()); + dlns_create(&dlns, webPath.c_str()); Dl_namespace ndkns; dlns_get("ndk", &ndkns); -- Gitee