From 3836a9361db1ecb992f30f9d9e94613241044a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=97?= Date: Mon, 18 Aug 2025 11:19:53 +0800 Subject: [PATCH 1/6] JsError message fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡晗 --- .../window_manager_napi/js_window_manager.cpp | 15 ++-- .../window_runtime/window_napi/js_window.cpp | 89 ++++++++++++------- .../window_runtime/window_napi/js_window.h | 1 + 3 files changed, 68 insertions(+), 37 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index f94a568d46..f8b924b216 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -882,7 +882,7 @@ static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value ca if (lists->ability->GetWindow() == nullptr) { lists->errorCode = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : static_cast(WMError::WM_ERROR_NULLPTR); - lists->errMsg = "FA mode can not get ability window"; + lists->errMsg = "[window][getLastWindow]msg: FA mode can not get ability window"; return; } lists->window = Window::GetTopWindowWithId(lists->ability->GetWindow()->GetWindowId()); @@ -891,7 +891,7 @@ static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value ca if (contextPtr == nullptr || context == nullptr) { lists->errorCode = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : static_cast(WMError::WM_ERROR_NULLPTR); - lists->errMsg = "Stage mode without context"; + lists->errMsg = "[window][getLastWindow]msg: Stage mode without context"; return; } lists->window = Window::GetTopWindowWithContext(context->lock()); @@ -901,9 +901,10 @@ static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value ca if (lists == nullptr) { if (newApi) { task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "napi abnormal")); + "[window][getLastWindow]msg: NAPI abnormal")); } else { - task.Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, "napi abnormal")); + task.Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, + "[window][getLastWindow]msg: NAPI abnormal")); } return; } @@ -921,10 +922,10 @@ static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value ca if (lists->window == nullptr || lists->window->GetWindowState() == WindowState::STATE_DESTROYED) { if (newApi) { task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "Get top window failed")); + "[window][getLastWindow]msg: Get top window failed")); } else { task.Reject(env, JsErrUtils::CreateJsError(env, WMError::WM_ERROR_NULLPTR, - "Get top window failed")); + "[window][getLastWindow]msg: Get top window failed")); } return; } @@ -1108,7 +1109,7 @@ napi_value JsWindowManager::OnSetWaterMarkImage(napi_env env, napi_callback_info nativeBoolean = (GetType(env, argv[1]) == napi_boolean ? argv[1] : nullptr); } } - + std::shared_ptr pixelMap; pixelMap = OHOS::Media::PixelMapNapi::GetPixelMap(env, nativeObject); if (pixelMap == nullptr) { diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 8f78407d4c..27502b8dc4 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -977,7 +977,7 @@ napi_value JsWindow::SetGestureBackEnabled(napi_env env, napi_callback_info info JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetGestureBackEnabled(env, info) : nullptr; } - + napi_value JsWindow::GetGestureBackEnabled(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]"); @@ -1055,6 +1055,12 @@ napi_value NapiThrowError(napi_env env, WmErrorCode errCode) return NapiGetUndefined(env); } +napi_value NapiThrowError(napi_env env, WmErrorCode errCode, const std::string& msg) +{ + napi_throw(env, JsErrUtils::CreateJsError(env, errCode, msg)); + return NapiGetUndefined(env); +} + napi_valuetype GetType(napi_env env, napi_value value) { napi_valuetype res = napi_undefined; @@ -1713,7 +1719,7 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) NapiAsyncTask::ExecuteCallback execute; NapiAsyncTask::CompleteCallback complete; SetMoveWindowToGlobalAsyncTask(execute, complete, wptr(windowToken_), x, y); - + napi_value lastParam = (argc <= lastParamIndex) ? nullptr : ((argv[lastParamIndex] != nullptr && GetType(env, argv[lastParamIndex]) == napi_function) ? argv[lastParamIndex] : nullptr); @@ -2332,7 +2338,8 @@ napi_value JsWindow::OnSetDialogBackGestureEnabled(napi_env env, napi_callback_i NapiAsyncTask::CompleteCallback complete = [weakToken, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setDialogBackGestureEnabled]msg:System abnormal")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { @@ -3689,14 +3696,16 @@ napi_value JsWindow::OnSetWindowFocusable(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task.Reject(env, - JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "Invalidate params.")); + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setWindowFocusable]msg: Window is nullptr")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetFocusable(focusable)); if (ret == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set focusable failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][setWindowFocusable]msg: Window set focusable failed")); } WLOGI("Window [%{public}u, %{public}s] set focusable end", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); @@ -3752,13 +3761,15 @@ napi_value JsWindow::OnSetTopmost(napi_env env, napi_callback_info info) NapiAsyncTask::CompleteCallback complete = [weakToken, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setTopmost]msg: System abnormal")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "Window set topmost failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, + "[window][setTopmost]msg: Window set topmost failed")); } }; napi_value result = nullptr; @@ -3962,7 +3973,7 @@ napi_value JsWindow::OnSetWakeUpScreen(napi_env env, napi_callback_info info) if (ret != WmErrorCode::WM_OK) { return NapiThrowError(env, ret); } - + WLOGI("Window [%{public}u, %{public}s] set wake up screen %{public}d end", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), wakeUp); return NapiGetUndefined(env); @@ -4149,7 +4160,8 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) } if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "WindowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setTouchableAreas]msg:widnow is nullptr"); } Rect windowRect = windowToken_->GetRect(); std::vector touchableAreas; @@ -4163,7 +4175,8 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "CompleteCallback window is nullptr"); - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setTouchableAreas]msg:widnow is nullptr")); return; } WMError ret = weakWindow->SetTouchHotAreas(touchableAreas); @@ -4458,18 +4471,21 @@ napi_value JsWindow::OnRaiseAboveTarget(napi_env env, napi_callback_info info) [weakToken, subWindowId, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][raiseAboveTarget]msg: Window is nullptr")); return; } if (errCode != WmErrorCode::WM_OK) { - task.Reject(env, JsErrUtils::CreateJsError(env, errCode, "Invalidate params.")); + task.Reject(env, JsErrUtils::CreateJsError(env, errCode, + "[window][raiseAboveTarget]msg: Invalidate params.")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->RaiseAboveTarget(subWindowId)); if (ret == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set raiseAboveTarget failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, ret, + "[window][raiseAboveTarget]msg: Window set raiseAboveTarget failed")); } }; @@ -4487,36 +4503,42 @@ napi_value JsWindow::OnKeepKeyboardOnFocus(napi_env env, napi_callback_info info napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { WLOGFE("Argc is invalid: %{public}zu", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][OnKeepKeyboardOnFocus]msg:argc is invalid"); } bool keepKeyboardFlag = false; napi_value nativeVal = argv[0]; if (nativeVal == nullptr) { WLOGFE("Failed to get parameter keepKeyboardFlag"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][OnKeepKeyboardOnFocus]msg:nativeVal is null"); } else { WmErrorCode errCode = WmErrorCode::WM_OK; CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM, napi_get_value_bool(env, nativeVal, &keepKeyboardFlag)); if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM, + "[window][OnKeepKeyboardOnFocus]msg:invalid nativeVal"); } } if (windowToken_ == nullptr) { WLOGFE("WindowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][OnKeepKeyboardOnFocus]msg:WindowToken_ is nullptr"); } if (!WindowHelper::IsSystemWindow(windowToken_->GetType()) && !WindowHelper::IsSubWindow(windowToken_->GetType())) { - WLOGFE("KeepKeyboardOnFocus is not allowed since window is not system window or app subwindow"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + WLOGFE("not allowed since window is not system window or app subwindow"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, + "[window][OnKeepKeyboardOnFocus]msg:windowType is invalid"); } WmErrorCode ret = windowToken_->KeepKeyboardOnFocus(keepKeyboardFlag); if (ret != WmErrorCode::WM_OK) { - WLOGFE("Window KeepKeyboardOnFocus failed"); - return NapiThrowError(env, ret); + WLOGFE("failed"); + return NapiThrowError(env, ret, + "[window][OnKeepKeyboardOnFocus]msg:failed"); } WLOGI("Window [%{public}u, %{public}s] KeepKeyboardOnFocus end, keepKeyboardFlag = %{public}d", @@ -5032,14 +5054,16 @@ napi_value JsWindow::OnRaiseToAppTop(napi_env env, napi_callback_info info) auto window = weakToken.promote(); if (window == nullptr) { WLOGFE("window is nullptr"); - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][raiseToAppTop]msg: Window is nullptr")); return; } WmErrorCode errCode = WM_JS_TO_ERROR_CODE_MAP.at(window->RaiseToAppTop()); if (errCode != WmErrorCode::WM_OK) { WLOGFE("raise window zorder failed"); - task.Reject(env, JsErrUtils::CreateJsError(env, errCode)); + task.Reject(env, JsErrUtils::CreateJsError(env, errCode, + "[window][raiseToAppTop]msg: Raise window zorder failed")); return; } task.Resolve(env, NapiGetUndefined(env)); @@ -5710,7 +5734,7 @@ napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) [weakToken, isAddFlag, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "System abnormal.")); + "[window][setHandwritingFlag]msg:System abnormal.")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { @@ -6780,7 +6804,7 @@ napi_value JsWindow::OnIsFocused(napi_env env, napi_callback_info info) TLOGE(WmsLogTag::WMS_FOCUS, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } - + bool isFocused = window->IsFocused(); TLOGI(WmsLogTag::WMS_FOCUS, "window [%{public}u, %{public}s] get isFocused end, isFocused = %{public}u", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isFocused); @@ -6809,13 +6833,15 @@ static void SetRequestFocusTask(NapiAsyncTask::ExecuteCallback& execute, NapiAsy }; complete = [weakToken, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][requestFocus]msg: System abnormal")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "JsWindow::OnRequestFocus failed")); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, + "[window][requestFocus]msg: Request focus failed")); } }; } @@ -7198,7 +7224,8 @@ napi_value JsWindow::OnSetExclusivelyHighlighted(napi_env env, napi_callback_inf auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_FOCUS, "%{public}s: window is nullptr", where); - task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, + "[window][setExclusivelyHighlighted]msg: Window is nullptr")); return; } WMError ret = window->SetExclusivelyHighlighted(exclusivelyHighlighted); @@ -7206,14 +7233,16 @@ napi_value JsWindow::OnSetExclusivelyHighlighted(napi_env env, napi_callback_inf task->Resolve(env, NapiGetUndefined(env)); } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); - task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set exclusively highlighted failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, + "[window][setExclusivelyHighlighted]msg: Set exclusively highlighted failed")); } TLOGNI(WmsLogTag::WMS_FOCUS, "%{public}s: end, window: [%{public}u, %{public}s]", where, window->GetWindowId(), window->GetWindowName().c_str()); }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setExclusivelyHighlighted]msg: Failed to send event")); } return result; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index e6c294f495..979b923cdb 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -39,6 +39,7 @@ napi_value NapiGetUndefined(napi_env env); napi_valuetype GetType(napi_env env, napi_value value); bool NapiIsCallable(napi_env env, napi_value value); napi_value NapiThrowError(napi_env env, WmErrorCode errCode); +napi_value NapiThrowError(napi_env env, WmErrorCode errCode, const std::string& msg); class JsWindow final { public: explicit JsWindow(const sptr& window); -- Gitee From 35ab13deab8a6efa8f60867db5acd68518b90959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=97?= Date: Mon, 18 Aug 2025 11:24:31 +0800 Subject: [PATCH 2/6] add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡晗 --- .../window_runtime/window_manager_napi/js_window_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index f8b924b216..c040c2b4f1 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -1342,8 +1342,8 @@ napi_value JsWindowManager::OnShiftAppWindowPointerEvent(napi_env env, napi_call } }; if (napi_status::napi_ok != napi_send_event(env, std::move(asyncTask), napi_eprio_high)) { - napiAsyncTask->Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][shiftAppWindowPointerEvent]msg:send event failed")); } return result; } -- Gitee From 8629ec169923028564593af26a87de4b1a455868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=97?= Date: Mon, 18 Aug 2025 11:47:24 +0800 Subject: [PATCH 3/6] fix difference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡晗 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 27502b8dc4..9799ca5259 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4161,7 +4161,7 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "WindowToken_ is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setTouchableAreas]msg:widnow is nullptr"); + "[window][setTouchableAreas]msg:widnow is null"); } Rect windowRect = windowToken_->GetRect(); std::vector touchableAreas; @@ -4176,7 +4176,7 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) if (weakWindow == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "CompleteCallback window is nullptr"); task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setTouchableAreas]msg:widnow is nullptr")); + "[window][setTouchableAreas]msg:widnow is null")); return; } WMError ret = weakWindow->SetTouchHotAreas(touchableAreas); -- Gitee From d5d0099b31c5346e906fec4b3f8deb886a60916c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=97?= Date: Mon, 18 Aug 2025 03:54:55 +0000 Subject: [PATCH 4/6] update interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡晗 --- .../window_runtime/window_manager_napi/js_window_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index c040c2b4f1..e4cc6575f9 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -1109,7 +1109,7 @@ napi_value JsWindowManager::OnSetWaterMarkImage(napi_env env, napi_callback_info nativeBoolean = (GetType(env, argv[1]) == napi_boolean ? argv[1] : nullptr); } } - + std::shared_ptr pixelMap; pixelMap = OHOS::Media::PixelMapNapi::GetPixelMap(env, nativeObject); if (pixelMap == nullptr) { -- Gitee From 31dbc88db570100f196420998de12a02fc0eda7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=97?= Date: Mon, 18 Aug 2025 03:58:45 +0000 Subject: [PATCH 5/6] update interfaces/kits/napi/window_runtime/window_napi/js_window.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡晗 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 9799ca5259..b8056b514e 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -977,7 +977,7 @@ napi_value JsWindow::SetGestureBackEnabled(napi_env env, napi_callback_info info JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetGestureBackEnabled(env, info) : nullptr; } - + napi_value JsWindow::GetGestureBackEnabled(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]"); @@ -1719,7 +1719,7 @@ napi_value JsWindow::OnMoveWindowToGlobal(napi_env env, napi_callback_info info) NapiAsyncTask::ExecuteCallback execute; NapiAsyncTask::CompleteCallback complete; SetMoveWindowToGlobalAsyncTask(execute, complete, wptr(windowToken_), x, y); - + napi_value lastParam = (argc <= lastParamIndex) ? nullptr : ((argv[lastParamIndex] != nullptr && GetType(env, argv[lastParamIndex]) == napi_function) ? argv[lastParamIndex] : nullptr); @@ -6804,7 +6804,7 @@ napi_value JsWindow::OnIsFocused(napi_env env, napi_callback_info info) TLOGE(WmsLogTag::WMS_FOCUS, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } - + bool isFocused = window->IsFocused(); TLOGI(WmsLogTag::WMS_FOCUS, "window [%{public}u, %{public}s] get isFocused end, isFocused = %{public}u", windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isFocused); -- Gitee From b70026ad09865eeb25c7c9d96ec7b22f2d65030c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=97?= Date: Mon, 18 Aug 2025 04:45:34 +0000 Subject: [PATCH 6/6] update interfaces/kits/napi/window_runtime/window_napi/js_window.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡晗 --- .../napi/window_runtime/window_napi/js_window.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index b8056b514e..cf3aa4fa1a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4161,7 +4161,7 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "WindowToken_ is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setTouchableAreas]msg:widnow is null"); + "[window][setTouchableAreas]msg:window is null"); } Rect windowRect = windowToken_->GetRect(); std::vector touchableAreas; @@ -4176,7 +4176,7 @@ napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) if (weakWindow == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "CompleteCallback window is nullptr"); task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][setTouchableAreas]msg:widnow is null")); + "[window][setTouchableAreas]msg:window is null")); return; } WMError ret = weakWindow->SetTouchHotAreas(touchableAreas); @@ -4525,7 +4525,7 @@ napi_value JsWindow::OnKeepKeyboardOnFocus(napi_env env, napi_callback_info info if (windowToken_ == nullptr) { WLOGFE("WindowToken_ is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, - "[window][OnKeepKeyboardOnFocus]msg:WindowToken_ is nullptr"); + "[window][OnKeepKeyboardOnFocus]msg:WindowToken_ is null"); } if (!WindowHelper::IsSystemWindow(windowToken_->GetType()) && !WindowHelper::IsSubWindow(windowToken_->GetType())) { @@ -7240,9 +7240,8 @@ napi_value JsWindow::OnSetExclusivelyHighlighted(napi_env env, napi_callback_inf where, window->GetWindowId(), window->GetWindowName().c_str()); }; if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { - napiAsyncTask->Reject(env, CreateJsError(env, - static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "[window][setExclusivelyHighlighted]msg: Failed to send event")); + napiAsyncTask->Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "[window][setExclusivelyHighlighted]msg: Failed to send event")); } return result; } -- Gitee