• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_base.h"
17 
18 #include "core/components_ng/manager/drag_drop/drag_drop_behavior_reporter/drag_drop_behavior_reporter.h"
19 #include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
20 #include "core/components_ng/manager/drag_drop/drag_drop_initiating/drag_drop_initiating_state_machine.h"
21 #include "core/components_ng/manager/drag_drop/utils/drag_animation_helper.h"
22 #include "core/components_ng/pattern/text/text_pattern.h"
23 #include "core/components_ng/pattern/text_drag/text_drag_pattern.h"
24 #include "core/gestures/drag_event.h"
25 #include "core/pipeline_ng/pipeline_context.h"
26 namespace OHOS::Ace::NG {
27 namespace {
28 constexpr int32_t PIXELMAP_ANIMATION_DURATION = 300;
29 constexpr float PIXELMAP_DRAG_SCALE_MULTIPLE = 1.05f;
30 } // namespace
31 
DoPixelMapScaleForDragThroughTouch(DragDropInitiatingParams & params,const RefPtr<PixelMap> & pixelMap,float targetScale)32 void DragDropInitiatingStateBase::DoPixelMapScaleForDragThroughTouch(
33     DragDropInitiatingParams& params, const RefPtr<PixelMap>& pixelMap, float targetScale)
34 {
35 #if defined(PIXEL_MAP_SUPPORTED)
36     params.preScaledPixelMap = PixelMap::CopyPixelMap(pixelMap);
37     if (!params.preScaledPixelMap) {
38         TAG_LOGW(AceLogTag::ACE_DRAG, "Copy preScaledPixelMap is failure!");
39         return;
40     }
41     params.preScaledPixelMap->Scale(targetScale, targetScale, AceAntiAliasingOption::HIGH);
42     params.preScaleValue = targetScale;
43 #endif
44 }
45 
PrepareFinalPixelMapForDragThroughTouch(const RefPtr<PixelMap> & pixelMap,bool immediately)46 void DragDropInitiatingStateBase::PrepareFinalPixelMapForDragThroughTouch(
47     const RefPtr<PixelMap>& pixelMap, bool immediately)
48 {
49     auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
50     CHECK_NULL_VOID(pipeline);
51     auto dragDropManager = pipeline->GetDragDropManager();
52     CHECK_NULL_VOID(dragDropManager);
53     auto windowScale = dragDropManager->GetWindowScale();
54     float scale = windowScale * PIXELMAP_DRAG_SCALE_MULTIPLE;
55 
56     auto task = [weak = WeakClaim(this), pixelMap, scale]() {
57         auto stateBase = weak.Upgrade();
58         CHECK_NULL_VOID(stateBase);
59         auto machine = stateBase->GetStateMachine();
60         CHECK_NULL_VOID(machine);
61         auto& params = machine->GetDragDropInitiatingParams();
62         stateBase->DoPixelMapScaleForDragThroughTouch(params, pixelMap, scale);
63         params.isThumbnailCallbackTriggered = true;
64     };
65 
66     if (immediately) {
67         task();
68         return;
69     }
70 
71     auto taskScheduler = pipeline->GetTaskExecutor();
72     CHECK_NULL_VOID(taskScheduler);
73     taskScheduler->PostTask(task, TaskExecutor::TaskType::UI, "ArkUIPrepareScaledPixel", PriorityType::VIP);
74 }
75 
FireCustomerOnDragEnd()76 void DragDropInitiatingStateBase::FireCustomerOnDragEnd()
77 {
78     auto machine = GetStateMachine();
79     CHECK_NULL_VOID(machine);
80     auto params = machine->GetDragDropInitiatingParams();
81     auto frameNode = params.frameNode.Upgrade();
82     CHECK_NULL_VOID(frameNode);
83     auto pipelineContext = frameNode->GetContextRefPtr();
84     CHECK_NULL_VOID(pipelineContext);
85     auto eventHub = frameNode ->GetOrCreateEventHub<EventHub>();
86     CHECK_NULL_VOID(eventHub);
87     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
88     CHECK_NULL_VOID(gestureHub);
89     gestureHub->FireCustomerOnDragEnd(pipelineContext, eventHub);
90 }
91 
HidePixelMap(bool startDrag,double x,double y,bool showAnimation)92 void DragDropInitiatingStateBase::HidePixelMap(bool startDrag, double x, double y, bool showAnimation)
93 {
94     auto machine = GetStateMachine();
95     CHECK_NULL_VOID(machine);
96     auto params = machine->GetDragDropInitiatingParams();
97     auto frameNode = params.frameNode.Upgrade();
98     CHECK_NULL_VOID(frameNode);
99     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
100     CHECK_NULL_VOID(gestureHub);
101     auto pipelineContext = frameNode->GetContextRefPtr();
102     CHECK_NULL_VOID(pipelineContext);
103     auto manager = pipelineContext->GetOverlayManager();
104     CHECK_NULL_VOID(manager);
105     if (params.hasGatherNode) {
106         DragAnimationHelper::HideDragNodeCopyWithAnimation(manager, frameNode);
107     }
108 
109     if (showAnimation) {
110         manager->RemovePixelMapAnimation(startDrag, x, y);
111     } else {
112         manager->RemovePixelMap();
113     }
114 }
115 
HideEventColumn()116 void DragDropInitiatingStateBase::HideEventColumn()
117 {
118     auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck();
119     CHECK_NULL_VOID(pipelineContext);
120     auto manager = pipelineContext->GetOverlayManager();
121     CHECK_NULL_VOID(manager);
122     manager->RemoveEventColumn();
123 }
124 
IsAllowedDrag()125 bool DragDropInitiatingStateBase::IsAllowedDrag()
126 {
127     auto machine = GetStateMachine();
128     CHECK_NULL_RETURN(machine, false);
129     auto params = machine->GetDragDropInitiatingParams();
130     auto frameNode = params.frameNode.Upgrade();
131     CHECK_NULL_RETURN(frameNode, false);
132     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
133     CHECK_NULL_RETURN(gestureHub, false);
134     auto eventHub = frameNode->GetOrCreateEventHub<EventHub>();
135     CHECK_NULL_RETURN(eventHub, false);
136     bool isAllowedDrag = gestureHub->IsAllowedDrag(eventHub);
137     return isAllowedDrag;
138 }
139 
UpdateDragPreviewOptionFromModifier()140 void DragDropInitiatingStateBase::UpdateDragPreviewOptionFromModifier()
141 {
142     auto machine = GetStateMachine();
143     CHECK_NULL_VOID(machine);
144     auto& params = machine->GetDragDropInitiatingParams();
145     auto frameNode = params.frameNode.Upgrade();
146     CHECK_NULL_VOID(frameNode);
147     auto dragPreviewOption = frameNode->GetDragPreviewOption();
148     DragDropFuncWrapper::UpdatePreviewOptionDefaultAttr(dragPreviewOption, dragPreviewOption.isMultiSelectionEnabled);
149     frameNode->SetDragPreviewOptions(dragPreviewOption);
150     auto modifierOnApply = dragPreviewOption.onApply;
151     if (modifierOnApply) {
152         DragDropFuncWrapper::UpdateDragPreviewOptionsFromModifier(modifierOnApply, dragPreviewOption);
153         frameNode->SetDragPreviewOptions(dragPreviewOption);
154     }
155     params.optionsAfterApplied = dragPreviewOption.options;
156 }
157 
ResetBorderRadiusAnimation()158 void DragDropInitiatingStateBase::ResetBorderRadiusAnimation()
159 {
160     auto machine = GetStateMachine();
161     CHECK_NULL_VOID(machine);
162     auto params = machine->GetDragDropInitiatingParams();
163     auto frameNode = params.frameNode.Upgrade();
164     CHECK_NULL_VOID(frameNode);
165     auto renderContext = frameNode->GetRenderContext();
166     CHECK_NULL_VOID(renderContext);
167     auto context = frameNode->GetContextRefPtr();
168     CHECK_NULL_VOID(context);
169     BorderRadiusProperty borderRadius;
170     if (renderContext->GetBorderRadius().has_value()) {
171         borderRadius.UpdateWithCheck(renderContext->GetBorderRadius().value());
172     }
173     borderRadius.multiValued = false;
174     AnimationOption option;
175     option.SetDuration(PIXELMAP_ANIMATION_DURATION);
176     option.SetCurve(Curves::FRICTION);
177     AnimationUtils::Animate(
178         option,
179         [renderContext = renderContext, borderRadius = borderRadius]() {
180             renderContext->UpdateBorderRadius(borderRadius);
181         },
182         option.GetOnFinishEvent(), nullptr, context);
183 }
184 
CheckStatusForPanActionBegin(const RefPtr<FrameNode> & frameNode,const GestureEvent & info)185 bool DragDropInitiatingStateBase::CheckStatusForPanActionBegin(
186     const RefPtr<FrameNode>& frameNode, const GestureEvent& info)
187 {
188     auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
189     CHECK_NULL_RETURN(pipeline, false);
190     auto dragDropManager = pipeline->GetDragDropManager();
191     CHECK_NULL_RETURN(dragDropManager, false);
192     if (dragDropManager->IsDragging() || dragDropManager->IsMSDPDragging()) {
193         DragDropBehaviorReporterTrigger trigger(DragReporterPharse::DRAG_START, Container::CurrentId());
194         DragDropBehaviorReporter::GetInstance().UpdateDragStartResult(DragStartResult::REPEAT_DRAG_FAIL);
195         TAG_LOGI(AceLogTag::ACE_DRAG, "It's already dragging now, dragging is %{public}d, MSDP dragging is %{public}d",
196             dragDropManager->IsDragging(), dragDropManager->IsMSDPDragging());
197         return false;
198     }
199     if (dragDropManager->IsDragNodeNeedClean()) {
200         TAG_LOGI(AceLogTag::ACE_DRAG, "Drag node have been cleaned by backpress or click event, stop dragging.");
201         return false;
202     }
203     CHECK_NULL_RETURN(frameNode, false);
204     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
205     CHECK_NULL_RETURN(gestureHub, false);
206     if (gestureHub->GetTextDraggable() && !gestureHub->GetIsTextDraggable()) {
207         TAG_LOGI(AceLogTag::ACE_DRAG, "Text category component does not meet the drag condition, forbidden drag.");
208         dragDropManager->ResetDragging();
209         return false;
210     }
211     return true;
212 }
213 
GetCurDuration(const TouchEvent & touchEvent,int32_t curDuration)214 int32_t DragDropInitiatingStateBase::GetCurDuration(const TouchEvent& touchEvent, int32_t curDuration)
215 {
216     int64_t currentTimeStamp = GetSysTimestamp();
217     auto machine = GetStateMachine();
218     CHECK_NULL_RETURN(machine, 0);
219     int64_t eventTimeStamp = static_cast<int64_t>(touchEvent.time.time_since_epoch().count());
220     if (currentTimeStamp > eventTimeStamp) {
221         curDuration = curDuration - static_cast<int32_t>((currentTimeStamp- eventTimeStamp) / TIME_BASE);
222         curDuration = curDuration < 0 ? 0: curDuration;
223     }
224     return curDuration;
225 }
226 
SetTextPixelMap()227 void DragDropInitiatingStateBase::SetTextPixelMap()
228 {
229     auto machine = GetStateMachine();
230     CHECK_NULL_VOID(machine);
231     auto params = machine->GetDragDropInitiatingParams();
232     auto frameNode = params.frameNode.Upgrade();
233     CHECK_NULL_VOID(frameNode);
234     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
235     CHECK_NULL_VOID(gestureHub);
236     auto pattern = frameNode->GetPattern<TextDragBase>();
237     CHECK_NULL_VOID(pattern);
238     auto dragNode = pattern->MoveDragNode();
239     pattern->CloseSelectOverlay();
240     CHECK_NULL_VOID(dragNode);
241     if (params.preScaledPixelMap) {
242         gestureHub->SetPixelMap(params.preScaledPixelMap);
243         params.preScaledPixelMap = nullptr;
244         return;
245     }
246     auto renderContext = dragNode->GetRenderContext();
247     CHECK_NULL_VOID(renderContext);
248     auto pixelMap = renderContext->GetThumbnailPixelMap();
249     if (pixelMap) {
250         gestureHub->SetPixelMap(pixelMap);
251     } else {
252         gestureHub->SetPixelMap(nullptr);
253     }
254 }
255 
GetTextAnimationFinishCallback(bool startDrag,const RefPtr<FrameNode> & frameNode,const RefPtr<GestureEventHub> & gestureHub)256 std::function<void()> GetTextAnimationFinishCallback(
257     bool startDrag, const RefPtr<FrameNode>& frameNode, const RefPtr<GestureEventHub>& gestureHub)
258 {
259     CHECK_NULL_RETURN(frameNode, nullptr);
260     auto pattern = frameNode->GetPattern<TextDragBase>();
261     CHECK_NULL_RETURN(pattern, nullptr);
262     auto node = pattern->MoveDragNode();
263     CHECK_NULL_RETURN(node, nullptr);
264     auto textDragPattern = node->GetPattern<TextDragPattern>();
265     CHECK_NULL_RETURN(textDragPattern, nullptr);
266     auto modifier = textDragPattern->GetOverlayModifier();
267     CHECK_NULL_RETURN(modifier, nullptr);
268     return [id = Container::CurrentId(), startDrag, weakPattern = WeakPtr<TextDragBase>(pattern),
269                weakEvent = AceType::WeakClaim(AceType::RawPtr(gestureHub)),
270                weakModifier = WeakPtr<TextDragOverlayModifier>(modifier)] {
271         ContainerScope scope(id);
272         auto pattern = weakPattern.Upgrade();
273         CHECK_NULL_VOID(pattern);
274         if (!startDrag) {
275             auto modifier = weakModifier.Upgrade();
276             CHECK_NULL_VOID(modifier);
277             pattern->ShowHandles(modifier->IsHandlesShow());
278         }
279         // 长按ai菜单预览回落时,执行弹出ai菜单操作
280         pattern->ShowAIEntityMenuForCancel();
281         auto pipeline = PipelineContext::GetCurrentContext();
282         CHECK_NULL_VOID(pipeline);
283         if (!pattern->IsPreviewMenuShow()) {
284             auto manager = pipeline->GetOverlayManager();
285             CHECK_NULL_VOID(manager);
286             manager->RemovePixelMap();
287         }
288         TAG_LOGD(AceLogTag::ACE_DRAG, "In removeColumnNode callback, set DragWindowVisible true.");
289         auto gestureHub = weakEvent.Upgrade();
290         CHECK_NULL_VOID(gestureHub);
291         auto dragDropManager = pipeline->GetDragDropManager();
292         if (!gestureHub->IsPixelMapNeedScale() && dragDropManager && dragDropManager->IsDragging()) {
293             InteractionInterface::GetInstance()->SetDragWindowVisible(true);
294         }
295         gestureHub->SetPixelMap(nullptr);
296     };
297 }
298 
HideTextAnimation(bool startDrag,double globalX,double globalY)299 void DragDropInitiatingStateBase::HideTextAnimation(bool startDrag, double globalX, double globalY)
300 {
301     TAG_LOGD(AceLogTag::ACE_DRAG, "DragEvent start hide text animation.");
302     auto machine = GetStateMachine();
303     CHECK_NULL_VOID(machine);
304     auto params = machine->GetDragDropInitiatingParams();
305     auto frameNode = params.frameNode.Upgrade();
306     CHECK_NULL_VOID(frameNode);
307     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
308     CHECK_NULL_VOID(gestureHub);
309     auto eventHub = frameNode->GetOrCreateEventHub<EventHub>();
310     CHECK_NULL_VOID(eventHub);
311     bool isAllowedDrag = gestureHub->IsAllowedDrag(eventHub);
312     if (!gestureHub->GetTextDraggable() || !isAllowedDrag) {
313         TAG_LOGD(AceLogTag::ACE_DRAG, "Text is not draggable, stop set hide text animation.");
314         return;
315     }
316     auto removeColumnNode = GetTextAnimationFinishCallback(startDrag, frameNode, gestureHub);
317     AnimationOption option;
318     option.SetDuration(PIXELMAP_ANIMATION_DURATION);
319     option.SetCurve(Curves::SHARP);
320     option.SetOnFinishEvent(removeColumnNode);
321 
322     auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
323     CHECK_NULL_VOID(pipeline);
324     auto manager = pipeline->GetOverlayManager();
325     CHECK_NULL_VOID(manager);
326     auto dragNode = manager->GetPixelMapNode();
327     if (!dragNode) {
328         auto pattern = frameNode->GetPattern<TextDragBase>();
329         CHECK_NULL_VOID(pattern);
330         // 长按ai菜单预览回落时,执行弹出ai菜单操作
331         pattern->ShowAIEntityMenuForCancel();
332         return;
333     }
334     auto dragFrame = dragNode->GetGeometryNode()->GetFrameRect();
335     auto frameWidth = dragFrame.Width();
336     auto frameHeight = dragFrame.Height();
337     auto pixelMap = gestureHub->GetPixelMap();
338     float scale = 1.0f;
339     if (pixelMap) {
340         scale = gestureHub->GetPixelMapScale(pixelMap->GetHeight(), pixelMap->GetWidth());
341     }
342     auto context = dragNode->GetRenderContext();
343     CHECK_NULL_VOID(context);
344     auto dragcontext = dragNode->GetContextRefPtr();
345     CHECK_NULL_VOID(dragcontext);
346     context->UpdateTransformScale(VectorF(1.0f, 1.0f));
347     AnimationUtils::Animate(
348         option,
349         [context, startDrag, globalX, globalY, frameWidth, frameHeight, scale]() {
350             if (startDrag) {
351                 context->UpdatePosition(OffsetT<Dimension>(Dimension(globalX + frameWidth * PIXELMAP_WIDTH_RATE),
352                     Dimension(globalY + frameHeight * PIXELMAP_HEIGHT_RATE)));
353                 context->UpdateTransformScale(VectorF(scale, scale));
354                 context->OnModifyDone();
355             }
356         },
357         option.GetOnFinishEvent(), nullptr, dragcontext);
358 }
359 
HandleTextDragCallback()360 void DragDropInitiatingStateBase::HandleTextDragCallback()
361 {
362     auto machine = GetStateMachine();
363     CHECK_NULL_VOID(machine);
364     auto params = machine->GetDragDropInitiatingParams();
365     auto frameNode = params.frameNode.Upgrade();
366     CHECK_NULL_VOID(frameNode);
367     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
368     CHECK_NULL_VOID(gestureHub);
369     auto pattern = frameNode->GetPattern<TextBase>();
370     if (pattern->BetweenSelectedPosition(params.touchOffset)) {
371         if (params.getTextThumbnailPixelMapCallback) {
372             params.getTextThumbnailPixelMapCallback(params.touchOffset);
373         }
374     } else if (!gestureHub->GetIsTextDraggable()) {
375         gestureHub->SetPixelMap(nullptr);
376     }
377 }
378 
HandleTextDragStart(const RefPtr<FrameNode> & frameNode,const GestureEvent & info)379 void DragDropInitiatingStateBase::HandleTextDragStart(const RefPtr<FrameNode>& frameNode, const GestureEvent& info)
380 {
381     auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
382     CHECK_NULL_VOID(pipeline);
383     auto dragDropManager = pipeline->GetDragDropManager();
384     CHECK_NULL_VOID(dragDropManager);
385     CHECK_NULL_VOID(frameNode);
386     auto pattern = frameNode->GetPattern<TextBase>();
387     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
388     CHECK_NULL_VOID(gestureHub);
389     if (info.GetSourceDevice() != SourceType::MOUSE) {
390         CHECK_NULL_VOID(pattern);
391         if (!pattern->IsSelected() && !pattern->CanAIEntityDrag()) {
392             dragDropManager->ResetDragging();
393             gestureHub->SetIsTextDraggable(false);
394             TAG_LOGW(AceLogTag::ACE_DRAG, "Text is not selected, stop dragging.");
395             DragDropBehaviorReporterTrigger trigger(DragReporterPharse::DRAG_START, Container::CurrentId());
396             DragDropBehaviorReporter::GetInstance().UpdateDragStartResult(DragStartResult::TEXT_NOT_SELECT);
397             return;
398         }
399         if (gestureHub->GetIsTextDraggable()) {
400             SetTextPixelMap();
401         } else {
402             gestureHub->SetPixelMap(nullptr);
403         }
404     } else {
405         if (gestureHub->GetTextDraggable() && pattern) {
406             if (!pattern->IsSelected() || pattern->GetMouseStatus() == MouseStatus::MOVE) {
407                 dragDropManager->ResetDragging();
408                 gestureHub->SetIsTextDraggable(false);
409                 TAG_LOGW(AceLogTag::ACE_DRAG, "Text isSelected: %{public}d, stop dragging.", pattern->IsSelected());
410                 DragDropBehaviorReporterTrigger trigger(DragReporterPharse::DRAG_START, Container::CurrentId());
411                 DragDropBehaviorReporter::GetInstance().UpdateDragStartResult(DragStartResult::TEXT_NOT_SELECT);
412                 return;
413             }
414             HandleTextDragCallback();
415         }
416     }
417     auto gestureEventInfo = info;
418     gestureHub->HandleOnDragStart(gestureEventInfo);
419 }
420 
UpdatePointInfoForFinger(const TouchEvent & touchEvent)421 void DragDropInitiatingStateBase::UpdatePointInfoForFinger(const TouchEvent& touchEvent)
422 {
423     if (touchEvent.type == TouchType::MOVE) {
424         auto point = Point(touchEvent.x, touchEvent.y, touchEvent.screenX, touchEvent.screenY);
425         auto pipeline = PipelineContext::GetCurrentContextSafelyWithCheck();
426         CHECK_NULL_VOID(pipeline);
427         auto dragDropManager = pipeline->GetDragDropManager();
428         CHECK_NULL_VOID(dragDropManager);
429         dragDropManager->UpdatePointInfoForFinger(touchEvent.id, point);
430     }
431 }
432 
OnActionEnd(const GestureEvent & info)433 void DragDropInitiatingStateBase::OnActionEnd(const GestureEvent& info)
434 {
435     TAG_LOGI(AceLogTag::ACE_DRAG, "Trigger drag action end.");
436     DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
437     auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck();
438     CHECK_NULL_VOID(pipelineContext);
439     auto dragDropManager = pipelineContext->GetDragDropManager();
440     CHECK_NULL_VOID(dragDropManager);
441     if (dragDropManager->IsAboutToPreview()) {
442         dragDropManager->ResetDragging();
443     }
444     dragDropManager->SetIsDragNodeNeedClean(false);
445     dragDropManager->SetIsDisableDefaultDropAnimation(true);
446     auto machine = GetStateMachine();
447     CHECK_NULL_VOID(machine);
448     machine->RequestStatusTransition(static_cast<int32_t>(DragDropInitiatingStatus::IDLE));
449 }
450 
OnActionCancel(const GestureEvent & info)451 void DragDropInitiatingStateBase::OnActionCancel(const GestureEvent& info)
452 {
453     TAG_LOGI(AceLogTag::ACE_DRAG, "Trigger drag action cancel.");
454     DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
455     auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck();
456     CHECK_NULL_VOID(pipelineContext);
457     auto dragDropManager = pipelineContext->GetDragDropManager();
458     CHECK_NULL_VOID(dragDropManager);
459     if (dragDropManager->IsAboutToPreview()) {
460         dragDropManager->ResetDragging();
461     }
462     dragDropManager->SetIsDragNodeNeedClean(false);
463     dragDropManager->SetIsDisableDefaultDropAnimation(true);
464     auto machine = GetStateMachine();
465     CHECK_NULL_VOID(machine);
466     machine->RequestStatusTransition(static_cast<int32_t>(DragDropInitiatingStatus::IDLE));
467 }
468 } // namespace OHOS::Ace::NG
469