From 20da02bf2e8d7e784a25bfee0b7c146857a79616 Mon Sep 17 00:00:00 2001 From: DreamLoveJay Date: Tue, 29 Jul 2025 20:34:54 +0800 Subject: [PATCH] =?UTF-8?q?ArkTS1.2=E5=9B=9E=E8=B0=83=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=8C=E6=AD=A5Master=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: DreamLoveJay --- .gitee/CODEOWNERS | 52 +++++++++++++++++++ .../src/ani/native/web/web_module_methods.cpp | 8 +-- .../implementation/web_modifier_callbacks.cpp | 26 +++++----- .../pattern/web/ani/web_model_static_test.cpp | 1 + 4 files changed, 70 insertions(+), 17 deletions(-) diff --git a/.gitee/CODEOWNERS b/.gitee/CODEOWNERS index 0e662fb030f..87c0e4435ae 100644 --- a/.gitee/CODEOWNERS +++ b/.gitee/CODEOWNERS @@ -3132,6 +3132,58 @@ interfaces/napi/kits/router/ @arkui_superman interfaces/napi/kits/text_menu_controller/ @huawei_g_five interfaces/napi/kits/utils/ @arkuiframework +[Web ArkTS1.2] +frameworks/core/interfaces/native/ani/web_ani_modifier.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/client_authentication_handler_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/client_authentication_handler_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/console_message_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/console_message_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/controller_handler_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/controller_handler_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/data_resubmission_handler_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/data_resubmission_handler_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/event_result_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/event_result_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/file_selector_param_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/file_selector_param_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/file_selector_result_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/file_selector_result_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/full_screen_exit_handler_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/full_screen_exit_handler_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/http_auth_handler_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/http_auth_handler_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/js_geolocation_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/js_geolocation_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/js_result_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/js_result_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/permission_request_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/permission_request_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/rich_text_modifier.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/screen_capture_handler_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/screen_capture_handler_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/ssl_error_handler_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/ssl_error_handler_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_context_menu_param_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_context_menu_param_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_context_menu_result_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_context_menu_result_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_controller_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_controller_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_cookie_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_cookie_peer.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_keyboard_controller_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_keyboard_controller_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_modifier.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_modifier_callbacks.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_modifier_callbacks.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_resource_error_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_resource_error_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_resource_request_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_resource_request_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_resource_response_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web_resource_response_peer_impl.h @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/webview_controller_accessor.cpp @arkwebinarkuireview +frameworks/core/interfaces/native/implementation/web/webview_controller_peer_impl.h @arkwebinarkuireview [Test source] test/mock/core/event/ @arkuievent diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ani/native/web/web_module_methods.cpp b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ani/native/web/web_module_methods.cpp index d82d058442b..a97171171c8 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ani/native/web/web_module_methods.cpp +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/ani/native/web/web_module_methods.cpp @@ -78,12 +78,12 @@ void SetWebOptions(ani_env* env, ani_class aniClass, ani_long node, ani_object o auto setHapPathFunc = [vm, object = savePtr](const std::string& hapPath) { ani_string aniHapPath = nullptr; ani_env* envTemp = GetAniEnv(vm); - if (!envTemp || envTemp->String_NewUTF8(hapPath.c_str(), hapPath.size(), &aniHapPath) != ANI_OK) { - envTemp->GlobalReference_Delete(object); + if (!envTemp) { return; } - if (envTemp->Object_CallMethodByName_Void( - reinterpret_cast(object), "_setHapPath", "Lstd/core/String;:V", aniHapPath) != ANI_OK) { + if (envTemp->String_NewUTF8(hapPath.c_str(), hapPath.size(), &aniHapPath) != ANI_OK || + envTemp->Object_CallMethodByName_Void( + reinterpret_cast(object), "_setHapPath", "Lstd/core/String;:V", aniHapPath) != ANI_OK) { envTemp->GlobalReference_Delete(object); return; } diff --git a/frameworks/core/interfaces/native/implementation/web_modifier_callbacks.cpp b/frameworks/core/interfaces/native/implementation/web_modifier_callbacks.cpp index e8d232c1ba4..4e8b5025266 100644 --- a/frameworks/core/interfaces/native/implementation/web_modifier_callbacks.cpp +++ b/frameworks/core/interfaces/native/implementation/web_modifier_callbacks.cpp @@ -65,7 +65,7 @@ void OnPageEnd(const CallbackHelper& arkCallback, CHECK_NULL_VOID(eventInfo); Ark_OnPageEndEvent parameter; parameter.url = Converter::ArkValue(eventInfo->GetLoadedUrl()); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnPageBegin(const CallbackHelper& arkCallback, @@ -79,7 +79,7 @@ void OnPageBegin(const CallbackHelper& arkCallba CHECK_NULL_VOID(eventInfo); Ark_OnPageBeginEvent parameter; parameter.url = Converter::ArkValue(eventInfo->GetLoadedUrl()); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnProgressChange(const CallbackHelper& arkCallback, @@ -93,7 +93,7 @@ void OnProgressChange(const CallbackHelper& CHECK_NULL_VOID(eventInfo); Ark_OnProgressChangeEvent parameter; parameter.newProgress = Converter::ArkValue(eventInfo->GetNewProgress()); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnTitleReceive(const CallbackHelper& arkCallback, @@ -264,7 +264,7 @@ void OnErrorReceive(const CallbackHelper& ark auto requestPeer = new WebResourceRequestPeer(); requestPeer->webRequest = eventInfo->GetRequest(); parameter.request = requestPeer; - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnHttpErrorReceive(const CallbackHelper& arkCallback, @@ -350,7 +350,7 @@ void OnRenderExited(const CallbackHelper& ark Ark_OnRenderExitedEvent parameter; parameter.renderExitReason = Converter::ArkValue( static_cast(eventInfo->GetExitedReason())); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } bool OnShowFileSelector(const CallbackHelper& arkCallback, @@ -682,7 +682,7 @@ void OnWindowNew(const CallbackHelper& arkCallba auto peer = new ControllerHandlerPeer(); peer->handler = eventInfo->GetWebWindowNewHandler(); parameter.handler = peer; - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnWindowExit(const CallbackHelper& arkCallback, @@ -692,7 +692,7 @@ void OnWindowExit(const CallbackHelper& arkCallback, auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); pipelineContext->UpdateCurrentActiveNode(weakNode); - arkCallback.Invoke(); + arkCallback.InvokeSync(); } bool OnInterceptKey(const CallbackHelper& arkCallback, @@ -827,7 +827,7 @@ void OnPageVisible(const CallbackHelper& arkCa CHECK_NULL_VOID(eventInfo); Ark_OnPageVisibleEvent parameter; parameter.url = Converter::ArkValue(eventInfo->GetUrl()); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); }; #ifdef ARKUI_CAPI_UNITTEST func(); @@ -1093,7 +1093,7 @@ void OnNativeEmbedDataInfo(const CallbackHelper(arkInfo); parameter.status = Converter::ArkValue(eventInfo->GetStatus()); parameter.surfaceId = Converter::ArkValue(eventInfo->GetSurfaceId()); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnNativeEmbedVisibilityChange(const CallbackHelper& arkCallback, @@ -1105,7 +1105,7 @@ void OnNativeEmbedVisibilityChange(const CallbackHelper(eventInfo->GetEmbedId()); parameter.visibility = Converter::ArkValue(eventInfo->GetVisibility()); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnNativeEmbedTouchInfo(const CallbackHelper& arkCallback, @@ -1160,7 +1160,7 @@ void OnRenderProcessNotResponding(const CallbackHelper(eventInfo->GetPid()); parameter.reason = Converter::ArkValue( static_cast(eventInfo->GetReason())); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } void OnRenderProcessResponding(const CallbackHelper& arkCallback, @@ -1170,7 +1170,7 @@ void OnRenderProcessResponding(const CallbackHelperUpdateCurrentActiveNode(weakNode); - arkCallback.Invoke(); + arkCallback.InvokeSync(); } void OnViewportFitChanged(const CallbackHelper& arkCallback, @@ -1184,7 +1184,7 @@ void OnViewportFitChanged(const CallbackHelper& ar CHECK_NULL_VOID(eventInfo); Ark_ViewportFit parameter = Converter::ArkValue( static_cast(eventInfo->GetViewportFit())); - arkCallback.Invoke(parameter); + arkCallback.InvokeSync(parameter); } WebKeyboardOption OnWebKeyboard(const CallbackHelper& arkCallback, diff --git a/test/unittest/core/pattern/web/ani/web_model_static_test.cpp b/test/unittest/core/pattern/web/ani/web_model_static_test.cpp index dd39aa92cfa..b50c8641242 100644 --- a/test/unittest/core/pattern/web/ani/web_model_static_test.cpp +++ b/test/unittest/core/pattern/web/ani/web_model_static_test.cpp @@ -1211,6 +1211,7 @@ HWTEST_F(WebModelStaticTest, SetOnPageStartedEvent001, TestSize.Level1) webEventHub->FireOnPageFinishedEvent(mockEventInfo); EXPECT_TRUE(callbackCalled); auto onProgressChangeImpl = [](const BaseEventInfo* info) {}; + WebModelStatic::SetOnProgressChange(nullptr, onProgressChangeImpl); WebModelStatic::SetOnProgressChange(AccessibilityManager::RawPtr(frameNode), onProgressChangeImpl); auto titleReceiveEventId = [](const BaseEventInfo* info) {}; WebModelStatic::SetOnTitleReceive(AccessibilityManager::RawPtr(frameNode), titleReceiveEventId); -- Gitee