超大函数整改

Signed-off-by: b30058220 <baodi1@huawei.com>
Change-Id: Id1fb622ff56fe97c1218d4c040385bc6d6a95ccd
This commit is contained in:
b30058220 2024-08-22 06:49:43 +00:00
parent c340abcf41
commit 3420bd8c0b

View File

@ -118,6 +118,7 @@ bool GetPixelMapByCustom(DragControllerAsyncCtx* asyncCtx);
bool GetPixelMapArrayByCustom(DragControllerAsyncCtx* asyncCtx, napi_value customBuilder, int arrayLength);
ParameterType getParameterType(DragControllerAsyncCtx* asyncCtx);
void SetMouseDragMonitorState(DragControllerAsyncCtx *asyncCtx, bool state);
void HandleExecuteDrag(napi_env env, DragControllerAsyncCtx *asyncCtx);
class DragAction {
public:
@ -556,6 +557,18 @@ void SetMouseDragMonitorState(DragControllerAsyncCtx *asyncCtx, bool state)
TAG_LOGI(AceLogTag::ACE_DRAG, "Set mouse drag monitor state %{public}d success", state);
}
void HandleExecuteDrag(napi_env env, DragControllerAsyncCtx *asyncCtx)
{
ParameterType parameterType = getParameterType(asyncCtx);
if (parameterType == ParameterType::DRAGITEMINFO) {
OnComplete(asyncCtx);
} else if (parameterType == ParameterType::CUSTOMBUILDER) {
GetPixelMapByCustom(asyncCtx);
} else {
NapiThrow(env, "parameter parsing error.", ERROR_CODE_PARAM_INVALID);
}
}
void HandleSuccess(DragControllerAsyncCtx* asyncCtx, const DragNotifyMsg& dragNotifyMsg,
const DragStatus dragStatus)
{
@ -1561,14 +1574,7 @@ static napi_value JSExecuteDrag(napi_env env, napi_callback_info info)
return result;
}
SetMouseDragMonitorState(dragAsyncContext, true);
ParameterType parameterType = getParameterType(dragAsyncContext);
if (parameterType == ParameterType::DRAGITEMINFO) {
OnComplete(dragAsyncContext);
} else if (parameterType == ParameterType::CUSTOMBUILDER) {
GetPixelMapByCustom(dragAsyncContext);
} else {
NapiThrow(env, "parameter parsing error.", ERROR_CODE_PARAM_INVALID);
}
HandleExecuteDrag(env, dragAsyncContext);
napi_escape_handle(env, scope, result, &result);
napi_close_escapable_handle_scope(env, scope);
return result;