1 /* 2 * Copyright (c) 2022-2024 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PIPELINE_NG_CONTEXT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PIPELINE_NG_CONTEXT_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <list> 22 #include <unordered_map> 23 #include <utility> 24 25 #include "interfaces/inner_api/ace/arkui_rect.h" 26 27 #include "base/geometry/ng/rect_t.h" 28 #include "base/log/frame_info.h" 29 #include "base/log/frame_report.h" 30 #include "base/memory/referenced.h" 31 #include "base/utils/device_config.h" 32 #include "base/view_data/view_data_wrap.h" 33 #include "core/accessibility/accessibility_manager_ng.h" 34 #include "core/common/frontend.h" 35 #include "core/common/thp_extra_manager.h" 36 #include "core/components/common/layout/constants.h" 37 #include "core/components_ng/base/frame_node.h" 38 #include "core/components_ng/gestures/recognizers/gesture_recognizer.h" 39 #include "core/components_ng/manager/drag_drop/drag_drop_manager.h" 40 #include "core/components_ng/manager/frame_rate/frame_rate_manager.h" 41 #include "core/components_ng/manager/full_screen/full_screen_manager.h" 42 #include "core/components_ng/manager/post_event/post_event_manager.h" 43 #include "core/components_ng/manager/privacy_sensitive/privacy_sensitive_manager.h" 44 #include "core/components_ng/manager/safe_area/safe_area_manager.h" 45 #include "core/components_ng/manager/navigation/navigation_manager.h" 46 #include "core/components_ng/manager/form_visible/form_visible_manager.h" 47 #include "core/components_ng/manager/select_overlay/select_overlay_manager.h" 48 #include "core/components_ng/manager/shared_overlay/shared_overlay_manager.h" 49 #include "core/components_ng/pattern/custom/custom_node.h" 50 #ifdef WINDOW_SCENE_SUPPORTED 51 #include "core/components_ng/pattern/ui_extension/ui_extension_manager.h" 52 #endif 53 #include "core/components_ng/manager/focus/focus_manager.h" 54 #include "core/components_ng/pattern/overlay/overlay_manager.h" 55 #include "core/components_ng/pattern/recycle_view/recycle_manager.h" 56 #include "core/components_ng/pattern/stage/stage_manager.h" 57 #include "core/components_ng/pattern/web/itouch_event_callback.h" 58 #include "core/components_ng/property/safe_area_insets.h" 59 #include "core/event/touch_event.h" 60 #include "core/pipeline/pipeline_base.h" 61 62 namespace OHOS::Ace::NG { 63 64 using VsyncCallbackFun = std::function<void()>; 65 using FrameCallbackFunc = std::function<void(uint64_t nanoTimestamp)>; 66 67 class ACE_FORCE_EXPORT PipelineContext : public PipelineBase { 68 DECLARE_ACE_TYPE(NG::PipelineContext, PipelineBase); 69 70 public: 71 using SurfaceChangedCallbackMap = 72 std::unordered_map<int32_t, std::function<void(int32_t, int32_t, int32_t, int32_t, WindowSizeChangeReason)>>; 73 using SurfacePositionChangedCallbackMap = std::unordered_map<int32_t, std::function<void(int32_t, int32_t)>>; 74 using FoldStatusChangedCallbackMap = std::unordered_map<int32_t, std::function<void(FoldStatus)>>; 75 using HalfFoldHoverChangedCallbackMap = std::unordered_map<int32_t, std::function<void(bool)>>; 76 using FoldDisplayModeChangedCallbackMap = std::unordered_map<int32_t, std::function<void(FoldDisplayMode)>>; 77 using TransformHintChangedCallbackMap = std::unordered_map<int32_t, std::function<void(uint32_t)>>; 78 using PredictTask = std::function<void(int64_t, bool)>; 79 PipelineContext(std::shared_ptr<Window> window, RefPtr<TaskExecutor> taskExecutor, 80 RefPtr<AssetManager> assetManager, RefPtr<PlatformResRegister> platformResRegister, 81 const RefPtr<Frontend>& frontend, int32_t instanceId); 82 PipelineContext(std::shared_ptr<Window> window, RefPtr<TaskExecutor> taskExecutor, 83 RefPtr<AssetManager> assetManager, const RefPtr<Frontend>& frontend, int32_t instanceId); 84 PipelineContext() = default; 85 86 ~PipelineContext() override = default; 87 88 static RefPtr<PipelineContext> GetCurrentContext(); 89 90 static RefPtr<PipelineContext> GetCurrentContextSafely(); 91 92 static RefPtr<PipelineContext> GetCurrentContextSafelyWithCheck(); 93 94 static PipelineContext* GetCurrentContextPtrSafely(); 95 96 static PipelineContext* GetCurrentContextPtrSafelyWithCheck(); 97 98 99 static RefPtr<PipelineContext> GetMainPipelineContext(); 100 101 static RefPtr<PipelineContext> GetContextByContainerId(int32_t containerId); 102 103 static float GetCurrentRootWidth(); 104 105 static float GetCurrentRootHeight(); 106 107 void SetupRootElement() override; 108 109 void SetupSubRootElement(); 110 111 bool NeedSoftKeyboard() override; 112 SetOnWindowFocused(const std::function<void ()> & callback)113 void SetOnWindowFocused(const std::function<void()>& callback) override 114 { 115 focusOnNodeCallback_ = callback; 116 } 117 GetWindowFocusCallback()118 const std::function<void()>& GetWindowFocusCallback() const 119 { 120 return focusOnNodeCallback_; 121 } 122 GetRootElement()123 const RefPtr<FrameNode>& GetRootElement() const 124 { 125 return rootNode_; 126 } 127 AddKeyFrame(float fraction,const RefPtr<Curve> & curve,const std::function<void ()> & propertyCallback)128 void AddKeyFrame(float fraction, const RefPtr<Curve>& curve, const std::function<void()>& propertyCallback) override 129 {} 130 AddKeyFrame(float fraction,const std::function<void ()> & propertyCallback)131 void AddKeyFrame(float fraction, const std::function<void()>& propertyCallback) override {} 132 133 // add schedule task and return the unique mark id. 134 uint32_t AddScheduleTask(const RefPtr<ScheduleTask>& task) override; 135 136 // remove schedule task by id. 137 void RemoveScheduleTask(uint32_t id) override; 138 139 void OnTouchEvent(const TouchEvent& point, const RefPtr<NG::FrameNode>& node, bool isSubPipe = false) override; 140 141 void OnAccessibilityHoverEvent(const TouchEvent& point, const RefPtr<NG::FrameNode>& node) override; 142 143 void OnPenHoverEvent(const TouchEvent& point, const RefPtr<NG::FrameNode>& node) override; 144 145 void HandlePenHoverOut(const TouchEvent& point) override; 146 147 void OnMouseEvent(const MouseEvent& event, const RefPtr<NG::FrameNode>& node) override; 148 149 void OnAxisEvent(const AxisEvent& event, const RefPtr<NG::FrameNode>& node) override; 150 151 // Called by view when touch event received. 152 void OnTouchEvent(const TouchEvent& point, bool isSubPipe = false) override; 153 154 #if defined(SUPPORT_TOUCH_TARGET_TEST) 155 // Used to determine whether the touched frameNode is the target 156 bool OnTouchTargetHitTest(const TouchEvent& point, bool isSubPipe = false, const std::string& target = "") override; 157 #endif 158 // Called by container when key event received. 159 // if return false, then this event needs platform to handle it. 160 bool OnKeyEvent(const KeyEvent& event) override; 161 162 // ReDispatch KeyEvent from Web process. 163 void ReDispatch(KeyEvent& keyEvent); 164 165 // Called by view when mouse event received. 166 void OnMouseEvent(const MouseEvent& event) override; 167 168 // Do mouse event actively. 169 void FlushMouseEvent(); 170 171 // Called by view when axis event received. 172 void OnAxisEvent(const AxisEvent& event) override; 173 174 // Called by container when rotation event received. 175 // if return false, then this event needs platform to handle it. OnRotationEvent(const RotationEvent & event)176 bool OnRotationEvent(const RotationEvent& event) const override 177 { 178 return false; 179 } 180 181 void OnDragEvent(const PointerEvent& pointerEvent, DragEventAction action, 182 const RefPtr<NG::FrameNode>& node = nullptr) override; 183 184 // Called by view when idle event. 185 void OnIdle(int64_t deadline) override; 186 SetBuildAfterCallback(const std::function<void ()> & callback)187 void SetBuildAfterCallback(const std::function<void()>& callback) override 188 { 189 buildFinishCallbacks_.emplace_back(callback); 190 } 191 SaveExplicitAnimationOption(const AnimationOption & option)192 void SaveExplicitAnimationOption(const AnimationOption& option) override {} 193 CreateExplicitAnimator(const std::function<void ()> & onFinishEvent)194 void CreateExplicitAnimator(const std::function<void()>& onFinishEvent) override {} 195 ClearExplicitAnimationOption()196 void ClearExplicitAnimationOption() override {} 197 GetExplicitAnimationOption()198 AnimationOption GetExplicitAnimationOption() const override 199 { 200 return {}; 201 } 202 203 bool HasOnAreaChangeNode(int32_t nodeId); 204 205 void AddOnAreaChangeNode(int32_t nodeId); 206 207 void RemoveOnAreaChangeNode(int32_t nodeId); 208 209 void HandleOnAreaChangeEvent(uint64_t nanoTimestamp); 210 211 // Just register notification, no need to update callback. 212 void AddVisibleAreaChangeNode(const int32_t nodeId); 213 214 void AddVisibleAreaChangeNode(const RefPtr<FrameNode>& node, 215 const std::vector<double>& ratio, const VisibleRatioCallback& callback, bool isUserCallback = true, 216 bool isCalculateInnerClip = false); 217 void RemoveVisibleAreaChangeNode(int32_t nodeId); 218 219 void HandleVisibleAreaChangeEvent(uint64_t nanoTimestamp); 220 221 void HandleSubwindow(bool isShow); 222 223 void Destroy() override; 224 225 void OnShow() override; 226 227 void OnHide() override; 228 229 void WindowFocus(bool isFocus) override; 230 231 void ContainerModalUnFocus() override; 232 233 void ShowContainerTitle(bool isShow, bool hasDeco = true, bool needUpdate = false) override; 234 235 void SetAppBgColor(const Color& color) override; 236 237 void SetAppTitle(const std::string& title) override; 238 239 void SetAppIcon(const RefPtr<PixelMap>& icon) override; 240 241 void OnSurfaceChanged(int32_t width, int32_t height, 242 WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED, 243 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr) override; 244 245 void OnLayoutCompleted(const std::string& componentId); 246 void OnDrawCompleted(const std::string& componentId); 247 248 void OnSurfacePositionChanged(int32_t posX, int32_t posY) override; 249 250 void OnSurfaceDensityChanged(double density) override; 251 OnSystemBarHeightChanged(double statusBar,double navigationBar)252 void OnSystemBarHeightChanged(double statusBar, double navigationBar) override {} 253 OnSurfaceDestroyed()254 void OnSurfaceDestroyed() override {} 255 NotifyOnPreDraw()256 void NotifyOnPreDraw() override {} 257 CallRouterBackToPopPage()258 bool CallRouterBackToPopPage() override 259 { 260 return OnBackPressed(); 261 } 262 263 bool OnBackPressed(); 264 265 RefPtr<FrameNode> FindNavigationNodeToHandleBack(const RefPtr<UINode>& node, bool& isEntry); 266 267 void AddDirtyPropertyNode(const RefPtr<FrameNode>& dirty); 268 269 void AddDirtyCustomNode(const RefPtr<UINode>& dirtyNode); 270 271 void AddDirtyLayoutNode(const RefPtr<FrameNode>& dirty); 272 273 void AddLayoutNode(const RefPtr<FrameNode>& layoutNode); 274 275 void AddDirtyRenderNode(const RefPtr<FrameNode>& dirty); 276 277 void AddDirtyFreezeNode(FrameNode* node); 278 279 void AddPredictTask(PredictTask&& task); 280 281 void AddAfterLayoutTask(std::function<void()>&& task, bool isFlushInImplicitAnimationTask = false); 282 283 void AddPersistAfterLayoutTask(std::function<void()>&& task); 284 285 void AddLatestFrameLayoutFinishTask(std::function<void()>&& task); 286 287 void AddAfterRenderTask(std::function<void()>&& task); 288 AddDragWindowVisibleTask(std::function<void ()> && task)289 void AddDragWindowVisibleTask(std::function<void()>&& task) 290 { 291 dragWindowVisibleCallback_ = std::move(task); 292 } 293 294 void FlushOnceVsyncTask() override; 295 296 void FlushFreezeNode(); 297 void FlushDirtyPropertyNodes(); 298 void FlushDirtyNodeUpdate(); 299 300 void SetRootRect(double width, double height, double offset) override; 301 302 void SetWindowSceneConsumed(bool isConsumed); 303 304 bool IsWindowSceneConsumed(); 305 306 void UpdateSystemSafeArea(const SafeAreaInsets& systemSafeArea) override; 307 void UpdateCutoutSafeArea(const SafeAreaInsets& cutoutSafeArea) override; 308 void UpdateNavSafeArea(const SafeAreaInsets& navSafeArea) override; 309 void UpdateOriginAvoidArea(const Rosen::AvoidArea& avoidArea, uint32_t type) override; 310 311 float GetPageAvoidOffset() override; 312 313 bool CheckNeedAvoidInSubWindow() override; 314 315 void CheckAndUpdateKeyboardInset(float keyboardHeight) override; 316 317 void UpdateSizeChangeReason( 318 WindowSizeChangeReason type, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 319 UpdateDisplayAvailableRect(const Rect & displayAvailableRect)320 void UpdateDisplayAvailableRect(const Rect& displayAvailableRect) 321 { 322 displayAvailableRect_ = displayAvailableRect; 323 } GetDisplayAvailableRect()324 Rect GetDisplayAvailableRect() const 325 { 326 return displayAvailableRect_; 327 } 328 void SetEnableKeyBoardAvoidMode(bool value) override; 329 bool IsEnableKeyBoardAvoidMode() override; 330 331 void RequireSummary() override; 332 GetSafeAreaManager()333 const RefPtr<SafeAreaManager>& GetSafeAreaManager() const 334 { 335 return safeAreaManager_; 336 } 337 virtual SafeAreaInsets GetSafeArea() const; 338 339 virtual SafeAreaInsets GetSafeAreaWithoutProcess() const; 340 341 const RefPtr<FullScreenManager>& GetFullScreenManager(); 342 343 RefPtr<AccessibilityManagerNG> GetAccessibilityManagerNG(); 344 345 void SendEventToAccessibilityWithNode( 346 const AccessibilityEvent& accessibilityEvent, const RefPtr<FrameNode>& node); 347 348 const RefPtr<StageManager>& GetStageManager(); 349 350 const RefPtr<OverlayManager>& GetOverlayManager(); 351 352 const RefPtr<SelectOverlayManager>& GetSelectOverlayManager(); 353 GetSharedOverlayManager()354 const RefPtr<SharedOverlayManager>& GetSharedOverlayManager() 355 { 356 return sharedTransitionManager_; 357 } 358 359 #ifdef WINDOW_SCENE_SUPPORTED GetUIExtensionManager()360 const RefPtr<UIExtensionManager>& GetUIExtensionManager() 361 { 362 return uiExtensionManager_; 363 } 364 #endif 365 366 const RefPtr<DragDropManager>& GetDragDropManager(); 367 368 const RefPtr<FocusManager>& GetFocusManager() const; 369 370 const RefPtr<FocusManager>& GetOrCreateFocusManager(); 371 GetFrameRateManager()372 const RefPtr<FrameRateManager>& GetFrameRateManager() 373 { 374 return frameRateManager_; 375 } 376 377 void FlushBuild() override; 378 379 void FlushPipelineImmediately() override; 380 void RebuildFontNode() override; 381 382 void AddBuildFinishCallBack(std::function<void()>&& callback); 383 384 void AddWindowStateChangedCallback(int32_t nodeId); 385 386 void RemoveWindowStateChangedCallback(int32_t nodeId); 387 388 void AddWindowFocusChangedCallback(int32_t nodeId); 389 390 void RemoveWindowFocusChangedCallback(int32_t nodeId); 391 392 void AddWindowSizeChangeCallback(int32_t nodeId); 393 394 void RemoveWindowSizeChangeCallback(int32_t nodeId); 395 396 void AddNavigationNode(int32_t pageId, WeakPtr<UINode> navigationNode); 397 398 void RemoveNavigationNode(int32_t pageId, int32_t nodeId); 399 400 void FirePageChanged(int32_t pageId, bool isOnShow); 401 402 bool HasDifferentDirectionGesture() const; 403 IsKeyInPressed(KeyCode tarCode)404 bool IsKeyInPressed(KeyCode tarCode) const 405 { 406 CHECK_NULL_RETURN(eventManager_, false); 407 return eventManager_->IsKeyInPressed(tarCode); 408 } 409 GetIsFocusingByTab()410 bool GetIsFocusingByTab() const 411 { 412 return isFocusingByTab_; 413 } 414 SetIsFocusingByTab(bool isFocusingByTab)415 void SetIsFocusingByTab(bool isFocusingByTab) 416 { 417 isFocusingByTab_ = isFocusingByTab; 418 } 419 GetIsFocusActive()420 bool GetIsFocusActive() const 421 { 422 return isFocusActive_; 423 } 424 425 bool SetIsFocusActive(bool isFocusActive); 426 427 void AddIsFocusActiveUpdateEvent(const RefPtr<FrameNode>& node, const std::function<void(bool)>& eventCallback); 428 void RemoveIsFocusActiveUpdateEvent(const RefPtr<FrameNode>& node); 429 IsTabJustTriggerOnKeyEvent()430 bool IsTabJustTriggerOnKeyEvent() const 431 { 432 return isTabJustTriggerOnKeyEvent_; 433 } 434 GetOnShow()435 bool GetOnShow() const override 436 { 437 return onShow_; 438 } 439 440 bool ChangeMouseStyle(int32_t nodeId, MouseFormat format, int32_t windowId = 0, bool isByPass = false); 441 442 bool RequestFocus(const std::string& targetNodeId, bool isSyncRequest = false) override; 443 void AddDirtyFocus(const RefPtr<FrameNode>& node); 444 void AddDirtyRequestFocus(const RefPtr<FrameNode>& node); 445 void RootLostFocus(BlurReason reason = BlurReason::FOCUS_SWITCH) const; 446 447 void SetContainerWindow(bool isShow) override; 448 void SetContainerButtonHide(bool hideSplit, bool hideMaximize, bool hideMinimize) override; 449 void SetCloseButtonStatus(bool isEnabled); 450 451 void AddNodesToNotifyMemoryLevel(int32_t nodeId); 452 void RemoveNodesToNotifyMemoryLevel(int32_t nodeId); 453 void NotifyMemoryLevel(int32_t level) override; 454 void FlushModifier() override; 455 void FlushMessages() override; 456 457 void FlushUITasks(bool triggeredByImplicitAnimation = false) override; 458 void FlushUITaskWithSingleDirtyNode(const RefPtr<FrameNode>& node); 459 460 void FlushAfterLayoutCallbackInImplicitAnimationTask() override; 461 IsLayouting()462 bool IsLayouting() const override 463 { 464 return taskScheduler_->IsLayouting(); 465 } 466 467 // end pipeline, exit app 468 void Finish(bool autoFinish) const override; GetRootRect()469 RectF GetRootRect() 470 { 471 CHECK_NULL_RETURN(rootNode_, RectF()); 472 auto geometryNode = rootNode_->GetGeometryNode(); 473 CHECK_NULL_RETURN(geometryNode, RectF()); 474 return geometryNode->GetFrameRect(); 475 } 476 477 void FlushReload(const ConfigurationChange& configurationChange, bool fullUpdate = true) override; 478 RegisterSurfaceChangedCallback(std::function<void (int32_t,int32_t,int32_t,int32_t,WindowSizeChangeReason)> && callback)479 int32_t RegisterSurfaceChangedCallback( 480 std::function<void(int32_t, int32_t, int32_t, int32_t, WindowSizeChangeReason)>&& callback) 481 { 482 if (callback) { 483 surfaceChangedCallbackMap_.emplace(++callbackId_, std::move(callback)); 484 return callbackId_; 485 } 486 return 0; 487 } 488 UnregisterSurfaceChangedCallback(int32_t callbackId)489 void UnregisterSurfaceChangedCallback(int32_t callbackId) 490 { 491 surfaceChangedCallbackMap_.erase(callbackId); 492 } 493 RegisterFoldStatusChangedCallback(std::function<void (FoldStatus)> && callback)494 int32_t RegisterFoldStatusChangedCallback(std::function<void(FoldStatus)>&& callback) 495 { 496 if (callback) { 497 foldStatusChangedCallbackMap_.emplace(callbackId_, std::move(callback)); 498 return callbackId_; 499 } 500 return 0; 501 } 502 UnRegisterFoldStatusChangedCallback(int32_t callbackId)503 void UnRegisterFoldStatusChangedCallback(int32_t callbackId) 504 { 505 foldStatusChangedCallbackMap_.erase(callbackId); 506 } 507 RegisterHalfFoldHoverChangedCallback(std::function<void (bool)> && callback)508 int32_t RegisterHalfFoldHoverChangedCallback(std::function<void(bool)>&& callback) 509 { 510 if (callback) { 511 halfFoldHoverChangedCallbackMap_.emplace(++callbackId_, std::move(callback)); 512 return callbackId_; 513 } 514 return 0; 515 } 516 UnRegisterHalfFoldHoverChangedCallback(int32_t callbackId)517 void UnRegisterHalfFoldHoverChangedCallback(int32_t callbackId) 518 { 519 halfFoldHoverChangedCallbackMap_.erase(callbackId); 520 } 521 522 void UpdateHalfFoldHoverStatus(int32_t windowWidth, int32_t windowHeight); 523 IsHalfFoldHoverStatus()524 bool IsHalfFoldHoverStatus() 525 { 526 return isHalfFoldHoverStatus_; 527 } 528 529 void OnHalfFoldHoverChangedCallback(); 530 RegisterFoldDisplayModeChangedCallback(std::function<void (FoldDisplayMode)> && callback)531 int32_t RegisterFoldDisplayModeChangedCallback(std::function<void(FoldDisplayMode)>&& callback) 532 { 533 if (callback) { 534 foldDisplayModeChangedCallbackMap_.emplace(++callbackId_, std::move(callback)); 535 return callbackId_; 536 } 537 return 0; 538 } 539 UnRegisterFoldDisplayModeChangedCallback(int32_t callbackId)540 void UnRegisterFoldDisplayModeChangedCallback(int32_t callbackId) 541 { 542 foldDisplayModeChangedCallbackMap_.erase(callbackId); 543 } 544 RegisterSurfacePositionChangedCallback(std::function<void (int32_t,int32_t)> && callback)545 int32_t RegisterSurfacePositionChangedCallback(std::function<void(int32_t, int32_t)>&& callback) 546 { 547 if (callback) { 548 surfacePositionChangedCallbackMap_.emplace(++callbackId_, std::move(callback)); 549 return callbackId_; 550 } 551 return 0; 552 } 553 UnregisterSurfacePositionChangedCallback(int32_t callbackId)554 void UnregisterSurfacePositionChangedCallback(int32_t callbackId) 555 { 556 surfacePositionChangedCallbackMap_.erase(callbackId); 557 } 558 RegisterTransformHintChangeCallback(std::function<void (uint32_t)> && callback)559 int32_t RegisterTransformHintChangeCallback(std::function<void(uint32_t)>&& callback) 560 { 561 if (callback) { 562 transformHintChangedCallbackMap_.emplace(++callbackId_, std::move(callback)); 563 return callbackId_; 564 } 565 return 0; 566 } 567 UnregisterTransformHintChangedCallback(int32_t callbackId)568 void UnregisterTransformHintChangedCallback(int32_t callbackId) 569 { 570 transformHintChangedCallbackMap_.erase(callbackId); 571 } 572 SetMouseStyleHoldNode(int32_t id)573 void SetMouseStyleHoldNode(int32_t id) 574 { 575 if (mouseStyleNodeId_ == -1) { 576 mouseStyleNodeId_ = id; 577 } 578 } FreeMouseStyleHoldNode(int32_t id)579 void FreeMouseStyleHoldNode(int32_t id) 580 { 581 if (mouseStyleNodeId_ == id) { 582 mouseStyleNodeId_ = -1; 583 } 584 } 585 MarkNeedFlushMouseEvent()586 void MarkNeedFlushMouseEvent() 587 { 588 isNeedFlushMouseEvent_ = true; 589 } 590 MarkNeedFlushAnimationStartTime()591 void MarkNeedFlushAnimationStartTime() 592 { 593 isNeedFlushAnimationStartTime_ = true; 594 } 595 596 // font 597 void AddFontNodeNG(const WeakPtr<UINode>& node); 598 void RemoveFontNodeNG(const WeakPtr<UINode>& node); 599 600 // restore 601 void RestoreNodeInfo(std::unique_ptr<JsonValue> nodeInfo) override; 602 std::unique_ptr<JsonValue> GetStoredNodeInfo() override; 603 void StoreNode(int32_t restoreId, const WeakPtr<FrameNode>& node); 604 bool GetRestoreInfo(int32_t restoreId, std::string& restoreInfo); RemoveStoredNode(int32_t restoreId)605 void RemoveStoredNode(int32_t restoreId) 606 { 607 storeNode_.erase(restoreId); 608 } 609 void SetNeedRenderNode(const WeakPtr<FrameNode>& node); 610 611 void SetIgnoreViewSafeArea(bool value) override; 612 void SetIsLayoutFullScreen(bool value) override; 613 void SetIsNeedAvoidWindow(bool value) override; 614 615 void AddAnimationClosure(std::function<void()>&& animation); 616 void FlushAnimationClosure(); 617 void DumpJsInfo(const std::vector<std::string>& params) const; 618 619 bool DumpPageViewData(const RefPtr<FrameNode>& node, RefPtr<ViewDataWrap> viewDataWrap, 620 bool skipSubAutoFillContainer = false, bool needsRecordData = false); 621 bool CheckNeedAutoSave(); 622 bool CheckOverlayFocus(); 623 void NotifyFillRequestSuccess(AceAutoFillType autoFillType, RefPtr<ViewDataWrap> viewDataWrap); 624 void NotifyFillRequestFailed(RefPtr<FrameNode> node, int32_t errCode, 625 const std::string& fillContent = "", bool isPopup = false); 626 627 std::shared_ptr<NavigationController> GetNavigationController(const std::string& id) override; 628 void AddOrReplaceNavigationNode(const std::string& id, const WeakPtr<FrameNode>& node); 629 void DeleteNavigationNode(const std::string& id); 630 631 void SetJSViewActive(bool active, WeakPtr<CustomNode> custom); 632 AddGestureTask(const DelayedTask & task)633 void AddGestureTask(const DelayedTask& task) 634 { 635 delayedTasks_.emplace_back(task); 636 } 637 RemoveGestureTask(const DelayedTask & task)638 void RemoveGestureTask(const DelayedTask& task) 639 { 640 for (auto iter = delayedTasks_.begin(); iter != delayedTasks_.end();) { 641 if (iter->recognizer == task.recognizer) { 642 iter = delayedTasks_.erase(iter); 643 } else { 644 ++iter; 645 } 646 } 647 } 648 SetScreenNode(const RefPtr<FrameNode> & node)649 void SetScreenNode(const RefPtr<FrameNode>& node) 650 { 651 CHECK_NULL_VOID(node); 652 screenNode_ = AceType::WeakClaim(AceType::RawPtr(node)); 653 } GetScreenNode()654 RefPtr<FrameNode> GetScreenNode() const 655 { 656 return screenNode_.Upgrade(); 657 } 658 SetFocusedWindowSceneNode(const WeakPtr<FrameNode> & node)659 void SetFocusedWindowSceneNode(const WeakPtr<FrameNode>& node) 660 { 661 windowSceneNode_ = node; 662 } GetFocusedWindowSceneNode()663 RefPtr<FrameNode> GetFocusedWindowSceneNode() const 664 { 665 return windowSceneNode_.Upgrade(); 666 } 667 668 // for frontend animation interface. 669 void OpenFrontendAnimation( 670 const AnimationOption& option, const RefPtr<Curve>& curve, const std::function<void()>& finishCallback); 671 void CloseFrontendAnimation(); 672 673 void UpdateTitleInTargetPos(bool isShow, int32_t height) override; 674 675 void SetCursor(int32_t cursorValue) override; 676 677 void RestoreDefault(int32_t windowId = 0) override; 678 679 void OnFoldStatusChange(FoldStatus foldStatus) override; 680 void OnFoldDisplayModeChange(FoldDisplayMode foldDisplayMode) override; 681 UpdateCurrentActiveNode(const WeakPtr<FrameNode> & node)682 void UpdateCurrentActiveNode(const WeakPtr<FrameNode>& node) override 683 { 684 activeNode_ = std::move(node); 685 } 686 687 void OnTransformHintChanged(uint32_t transform) override; 688 GetTransformHint()689 uint32_t GetTransformHint() const 690 { 691 return transform_; 692 } 693 GetCurrentActiveNode()694 const WeakPtr<FrameNode>& GetCurrentActiveNode() const 695 { 696 return activeNode_; 697 } 698 699 std::string GetCurrentExtraInfo() override; 700 const RefPtr<PostEventManager>& GetPostEventManager(); 701 702 void SetContainerModalTitleVisible(bool customTitleSettedShow, bool floatingTitleSettedShow); 703 void SetContainerModalTitleHeight(int32_t height); 704 int32_t GetContainerModalTitleHeight(); 705 bool GetContainerModalButtonsRect(RectF& containerModal, RectF& buttons); 706 void SubscribeContainerModalButtonsRectChange( 707 std::function<void(RectF& containerModal, RectF& buttons)>&& callback); 708 bool IsDragging() const override; 709 void SetIsDragging(bool isDragging) override; 710 711 void ResetDragging() override; 712 713 void GetWindowPaintRectWithoutMeasureAndLayout(RectInt& rect); 714 715 const SerializedGesture& GetSerializedGesture() const override; 716 // return value means whether it has printed info 717 bool PrintVsyncInfoIfNeed() const override; 718 void SetUIExtensionImeShow(bool imeShow); 719 StartWindowAnimation()720 void StartWindowAnimation() override 721 { 722 isWindowAnimation_ = true; 723 } 724 StopWindowAnimation()725 void StopWindowAnimation() override 726 { 727 isWindowAnimation_ = false; 728 } 729 730 void AddSyncGeometryNodeTask(std::function<void()>&& task) override; 731 void FlushSyncGeometryNodeTasks() override; 732 GetNavigationManager()733 const RefPtr<NavigationManager>& GetNavigationManager() const 734 { 735 return navigationMgr_; 736 } 737 GetFormVisibleManager()738 const RefPtr<FormVisibleManager>& GetFormVisibleManager() const 739 { 740 return formVisibleMgr_; 741 } 742 GetRecycleManager()743 const std::unique_ptr<RecycleManager>& GetRecycleManager() const 744 { 745 return recycleManager_; 746 } 747 SetOnceVsyncListener(VsyncCallbackFun vsync)748 void SetOnceVsyncListener(VsyncCallbackFun vsync) 749 { 750 onceVsyncListener_ = std::move(vsync); 751 } 752 HasOnceVsyncListener()753 bool HasOnceVsyncListener() { 754 return onceVsyncListener_ != nullptr; 755 } 756 GetPrivacySensitiveManager()757 RefPtr<PrivacySensitiveManager> GetPrivacySensitiveManager() const 758 { 759 return privacySensitiveManager_; 760 } 761 ChangeSensitiveNodes(bool flag)762 void ChangeSensitiveNodes(bool flag) override 763 { 764 privacySensitiveManager_->TriggerFrameNodesSensitive(flag); 765 } 766 767 void FlushRequestFocus(); 768 769 Dimension GetCustomTitleHeight(); 770 771 void SetOverlayNodePositions(std::vector<Ace::RectF> rects); 772 773 static void SetCallBackNode(const WeakPtr<NG::FrameNode>& node); 774 775 std::vector<Ace::RectF> GetOverlayNodePositions(); 776 777 void RegisterOverlayNodePositionsUpdateCallback( 778 const std::function<void(std::vector<Ace::RectF>)>&& callback); 779 780 void TriggerOverlayNodePositionsUpdateCallback(std::vector<Ace::RectF> rects); 781 782 bool IsContainerModalVisible() override; 783 SetDoKeyboardAvoidAnimate(bool isDoKeyboardAvoidAnimate)784 void SetDoKeyboardAvoidAnimate(bool isDoKeyboardAvoidAnimate) 785 { 786 isDoKeyboardAvoidAnimate_ = isDoKeyboardAvoidAnimate; 787 } 788 789 void DetachNode(RefPtr<UINode> uiNode); 790 791 void CheckNeedUpdateBackgroundColor(Color& color); 792 793 bool CheckNeedDisableUpdateBackgroundImage(); 794 SetIsFreezeFlushMessage(bool isFreezeFlushMessage)795 void SetIsFreezeFlushMessage(bool isFreezeFlushMessage) 796 { 797 isFreezeFlushMessage_ = isFreezeFlushMessage; 798 } 799 IsFreezeFlushMessage()800 bool IsFreezeFlushMessage() const 801 { 802 return isFreezeFlushMessage_; 803 } 804 805 void ChangeDarkModeBrightness() override; 806 807 std::string GetResponseRegion(const RefPtr<NG::FrameNode>& rootNode) override; 808 809 void NotifyResponseRegionChanged(const RefPtr<NG::FrameNode>& rootNode) override; 810 SetLocalColorMode(ColorMode colorMode)811 void SetLocalColorMode(ColorMode colorMode) 812 { 813 auto localColorModeValue = static_cast<int32_t>(colorMode); 814 localColorMode_ = localColorModeValue; 815 } 816 GetLocalColorMode()817 ColorMode GetLocalColorMode() const 818 { 819 ColorMode colorMode = static_cast<ColorMode>(localColorMode_.load()); 820 return colorMode; 821 } 822 823 void CheckAndLogLastReceivedTouchEventInfo(int32_t eventId, TouchType type) override; 824 825 void CheckAndLogLastConsumedTouchEventInfo(int32_t eventId, TouchType type) override; 826 827 void CheckAndLogLastReceivedMouseEventInfo(int32_t eventId, MouseAction action) override; 828 829 void CheckAndLogLastConsumedMouseEventInfo(int32_t eventId, MouseAction action) override; 830 831 void CheckAndLogLastReceivedAxisEventInfo(int32_t eventId, AxisAction action) override; 832 833 void CheckAndLogLastConsumedAxisEventInfo(int32_t eventId, AxisAction action) override; 834 SetVsyncListener(VsyncCallbackFun vsync)835 void SetVsyncListener(VsyncCallbackFun vsync) 836 { 837 vsyncListener_ = std::move(vsync); 838 } 839 840 void RegisterTouchEventListener(const std::shared_ptr<ITouchEventCallback>& listener); 841 void UnregisterTouchEventListener(const WeakPtr<NG::Pattern>& pattern); 842 SetPredictNode(const RefPtr<FrameNode> & node)843 void SetPredictNode(const RefPtr<FrameNode>& node) 844 { 845 predictNode_ = node; 846 } 847 ResetPredictNode()848 void ResetPredictNode() 849 { 850 predictNode_.Reset(); 851 } 852 853 void AddFrameCallback(FrameCallbackFunc&& frameCallbackFunc, FrameCallbackFunc&& idleCallbackFunc, 854 int64_t delayMillis); 855 856 void FlushFrameCallback(uint64_t nanoTimestamp); 857 858 void TriggerIdleCallback(int64_t deadline); 859 860 void PreLayout(uint64_t nanoTimestamp, uint32_t frameCount); 861 IsDensityChanged()862 bool IsDensityChanged() const override 863 { 864 return isDensityChanged_; 865 } 866 867 868 void AddFrameNodeChangeListener(const WeakPtr<FrameNode>& node); 869 void RemoveFrameNodeChangeListener(int32_t nodeId); 870 bool AddChangedFrameNode(const WeakPtr<FrameNode>& node); 871 void RemoveChangedFrameNode(int32_t nodeId); 872 IsWindowFocused()873 bool IsWindowFocused() const override 874 { 875 return isWindowHasFocused_ && GetOnFoucs(); 876 } 877 SetForceSplitEnable(bool isForceSplit,const std::string & homePage)878 void SetForceSplitEnable(bool isForceSplit, const std::string& homePage) 879 { 880 TAG_LOGI(AceLogTag::ACE_ROUTER, "set force split %{public}s", isForceSplit ? "enable" : "disable"); 881 isForceSplit_ = isForceSplit; 882 homePageConfig_ = homePage; 883 } 884 GetForceSplitEnable()885 bool GetForceSplitEnable() const 886 { 887 return isForceSplit_; 888 } 889 GetHomePageConfig()890 std::string GetHomePageConfig() const 891 { 892 return homePageConfig_; 893 } 894 895 void GetInspectorTree(); 896 void NotifyAllWebPattern(bool isRegister); 897 898 bool CatchInteractiveAnimations(const std::function<void()>& animationCallback) override; 899 900 void CollectTouchEventsBeforeVsync(std::list<TouchEvent>& touchEvents); 901 IsDirtyNodesEmpty()902 bool IsDirtyNodesEmpty() const override 903 { 904 return dirtyNodes_.empty(); 905 } 906 IsDirtyLayoutNodesEmpty()907 bool IsDirtyLayoutNodesEmpty() const override 908 { 909 return taskScheduler_->IsDirtyLayoutNodesEmpty(); 910 } 911 912 void SyncSafeArea(SafeAreaSyncType syncType = SafeAreaSyncType::SYNC_TYPE_NONE); 913 bool CheckThreadSafe() const; 914 void AnimateOnSafeAreaUpdate(); 915 IsHoverModeChange()916 bool IsHoverModeChange() const 917 { 918 return isHoverModeChanged_; 919 } 920 921 void UpdateHalfFoldHoverProperty(int32_t windowWidth, int32_t windowHeight); 922 923 void PostKeyboardAvoidTask(); 924 925 protected: 926 void StartWindowSizeChangeAnimate(int32_t width, int32_t height, WindowSizeChangeReason type, 927 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 928 void StartWindowMaximizeAnimation(int32_t width, int32_t height, 929 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 930 void StartFullToMultWindowAnimation(int32_t width, int32_t height, WindowSizeChangeReason type, 931 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 932 933 void FlushVsync(uint64_t nanoTimestamp, uint32_t frameCount) override; 934 void FlushPipelineWithoutAnimation() override; 935 void FlushFocus(); 936 void FlushFocusWithNode(RefPtr<FrameNode> focusNode, bool isScope); 937 void DispatchDisplaySync(uint64_t nanoTimestamp) override; 938 void FlushAnimation(uint64_t nanoTimestamp) override; 939 bool OnDumpInfo(const std::vector<std::string>& params) const override; 940 941 void OnVirtualKeyboardHeightChange(float keyboardHeight, 942 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, const float safeHeight = 0.0f, 943 const bool supportAvoidance = false, bool forceChange = false) override; 944 void OnVirtualKeyboardHeightChange(float keyboardHeight, double positionY, double height, 945 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, bool forceChange = false) override; 946 SetIsLayouting(bool layouting)947 void SetIsLayouting(bool layouting) 948 { 949 taskScheduler_->SetIsLayouting(layouting); 950 } 951 void AvoidanceLogic(float keyboardHeight, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, 952 const float safeHeight = 0.0f, const bool supportAvoidance = false); 953 void OriginalAvoidanceLogic( 954 float keyboardHeight, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 955 RefPtr<FrameNode> GetContainerModalNode(); 956 void DoKeyboardAvoidAnimate(const KeyboardAnimationConfig& keyboardAnimationConfig, float keyboardHeight, 957 const std::function<void()>& func); 958 void StartFoldStatusDelayTask(FoldStatus foldStatus); 959 960 private: 961 void ExecuteSurfaceChangedCallbacks(int32_t newWidth, int32_t newHeight, WindowSizeChangeReason type); 962 963 void FlushWindowStateChangedCallback(bool isShow); 964 965 void FlushWindowFocusChangedCallback(bool isFocus); 966 967 void FlushWindowSizeChangeCallback(int32_t width, int32_t height, WindowSizeChangeReason type); 968 969 void FlushTouchEvents(); 970 void FlushWindowPatternInfo(); 971 void FlushFocusView(); 972 void FlushFocusScroll(); 973 974 void ProcessDelayTasks(); 975 976 void InspectDrew(); 977 978 bool TriggerKeyEventDispatch(const KeyEvent& event); 979 980 bool DispatchTabKey(const KeyEvent& event, const RefPtr<FocusView>& curFocusView); 981 982 bool IsSkipShortcutAndFocusMove(); 983 984 void FlushBuildFinishCallbacks(); 985 986 void DumpPipelineInfo() const; 987 988 void RegisterRootEvent(); 989 990 void ResetDraggingStatus(const TouchEvent& touchPoint, const RefPtr<FrameNode>& node = nullptr); 991 992 void CompensateTouchMoveEvent(const TouchEvent& event); 993 994 bool CompensateTouchMoveEventFromUnhandledEvents(const TouchEvent& event); 995 996 FrameInfo* GetCurrentFrameInfo(uint64_t recvTime, uint64_t timeStamp); 997 998 // only used for static form. 999 void UpdateFormLinkInfos(); 1000 1001 void FlushFrameRate(); 1002 1003 void RegisterFocusCallback(); 1004 1005 template<typename T> 1006 struct NodeCompare { operatorNodeCompare1007 bool operator()(const T& nodeLeft, const T& nodeRight) const 1008 { 1009 if (!nodeLeft || !nodeRight) { 1010 return false; 1011 } 1012 if (nodeLeft->GetDepth() < nodeRight->GetDepth()) { 1013 return true; 1014 } 1015 if (nodeLeft->GetDepth() == nodeRight->GetDepth()) { 1016 return nodeLeft < nodeRight; 1017 } 1018 return false; 1019 } 1020 }; 1021 1022 std::tuple<float, float, float, float> LinearInterpolation(const std::tuple<float, float, uint64_t>& history, 1023 const std::tuple<float, float, uint64_t>& current, const uint64_t nanoTimeStamp); 1024 1025 std::tuple<float, float, float, float> GetResampleCoord(const std::vector<TouchEvent>& history, 1026 const std::vector<TouchEvent>& current, const uint64_t nanoTimeStamp, const bool isScreen); 1027 1028 std::tuple<float, float, uint64_t> GetAvgPoint(const std::vector<TouchEvent>& events, const bool isScreen); 1029 1030 bool GetResampleTouchEvent(const std::vector<TouchEvent>& history, 1031 const std::vector<TouchEvent>& current, const uint64_t nanoTimeStamp, TouchEvent& newTouchEvent); 1032 1033 TouchEvent GetLatestPoint(const std::vector<TouchEvent>& current, const uint64_t nanoTimeStamp); 1034 1035 void FlushNodeChangeFlag(); 1036 void CleanNodeChangeFlag(); 1037 1038 uint64_t AdjustVsyncTimeStamp(uint64_t nanoTimestamp); 1039 bool FlushModifierAnimation(uint64_t nanoTimestamp); 1040 1041 std::unique_ptr<UITaskScheduler> taskScheduler_ = std::make_unique<UITaskScheduler>(); 1042 1043 std::unordered_map<uint32_t, WeakPtr<ScheduleTask>> scheduleTasks_; 1044 1045 std::list<WeakPtr<FrameNode>> dirtyFreezeNode_; // used in freeze feature. 1046 std::set<RefPtr<FrameNode>, NodeCompare<RefPtr<FrameNode>>> dirtyPropertyNodes_; // used in node api. 1047 std::set<RefPtr<UINode>, NodeCompare<RefPtr<UINode>>> dirtyNodes_; 1048 std::list<std::function<void()>> buildFinishCallbacks_; 1049 1050 // window on show or on hide 1051 std::set<int32_t> onWindowStateChangedCallbacks_; 1052 // window on focused or on unfocused 1053 std::list<int32_t> onWindowFocusChangedCallbacks_; 1054 // window on drag 1055 std::list<int32_t> onWindowSizeChangeCallbacks_; 1056 1057 std::list<int32_t> nodesToNotifyMemoryLevel_; 1058 1059 std::list<TouchEvent> touchEvents_; 1060 1061 std::vector<std::function<void(const std::vector<std::string>&)>> dumpListeners_; 1062 1063 RefPtr<FrameNode> rootNode_; 1064 1065 int32_t curFocusNodeId_ = -1; 1066 1067 bool preIsHalfFoldHoverStatus_ = false; 1068 bool isHoverModeChanged_ = false; 1069 1070 std::set<WeakPtr<FrameNode>> needRenderNode_; 1071 1072 int32_t callbackId_ = 0; 1073 SurfaceChangedCallbackMap surfaceChangedCallbackMap_; 1074 SurfacePositionChangedCallbackMap surfacePositionChangedCallbackMap_; 1075 FoldStatusChangedCallbackMap foldStatusChangedCallbackMap_; 1076 HalfFoldHoverChangedCallbackMap halfFoldHoverChangedCallbackMap_; 1077 FoldDisplayModeChangedCallbackMap foldDisplayModeChangedCallbackMap_; 1078 TransformHintChangedCallbackMap transformHintChangedCallbackMap_; 1079 1080 bool isOnAreaChangeNodesCacheVaild_ = false; 1081 std::vector<FrameNode*> onAreaChangeNodesCache_; 1082 std::unordered_set<int32_t> onAreaChangeNodeIds_; 1083 std::unordered_set<int32_t> onVisibleAreaChangeNodeIds_; 1084 1085 RefPtr<AccessibilityManagerNG> accessibilityManagerNG_; 1086 RefPtr<StageManager> stageManager_; 1087 RefPtr<OverlayManager> overlayManager_; 1088 RefPtr<FullScreenManager> fullScreenManager_; 1089 RefPtr<SelectOverlayManager> selectOverlayManager_; 1090 RefPtr<DragDropManager> dragDropManager_; 1091 RefPtr<FocusManager> focusManager_; 1092 RefPtr<SharedOverlayManager> sharedTransitionManager_; 1093 #ifdef WINDOW_SCENE_SUPPORTED 1094 RefPtr<UIExtensionManager> uiExtensionManager_; 1095 #endif 1096 RefPtr<SafeAreaManager> safeAreaManager_ = MakeRefPtr<SafeAreaManager>(); 1097 RefPtr<FrameRateManager> frameRateManager_ = MakeRefPtr<FrameRateManager>(); 1098 RefPtr<PrivacySensitiveManager> privacySensitiveManager_ = MakeRefPtr<PrivacySensitiveManager>(); 1099 Rect displayAvailableRect_; 1100 std::unordered_map<size_t, TouchTestResult> touchTestResults_; 1101 WeakPtr<FrameNode> dirtyFocusNode_; 1102 WeakPtr<FrameNode> dirtyFocusScope_; 1103 WeakPtr<FrameNode> dirtyRequestFocusNode_; 1104 WeakPtr<FrameNode> screenNode_; 1105 WeakPtr<FrameNode> windowSceneNode_; 1106 uint32_t nextScheduleTaskId_ = 0; 1107 int32_t mouseStyleNodeId_ = -1; 1108 uint64_t resampleTimeStamp_ = 0; 1109 uint64_t animationTimeStamp_ = 0; 1110 bool hasIdleTasks_ = false; 1111 bool isFocusingByTab_ = false; 1112 bool isFocusActive_ = false; 1113 bool isTabJustTriggerOnKeyEvent_ = false; 1114 bool isWindowHasFocused_ = false; 1115 bool onShow_ = false; 1116 bool isNeedFlushMouseEvent_ = false; 1117 bool isNeedFlushAnimationStartTime_ = false; 1118 bool canUseLongPredictTask_ = false; 1119 bool isWindowSceneConsumed_ = false; 1120 bool isDensityChanged_ = false; 1121 bool isBeforeDragHandleAxis_ = false; 1122 WeakPtr<FrameNode> activeNode_; 1123 std::unique_ptr<MouseEvent> lastMouseEvent_; 1124 bool isWindowAnimation_ = false; 1125 bool prevKeyboardAvoidMode_ = false; 1126 bool isFreezeFlushMessage_ = false; 1127 1128 RefPtr<FrameNode> focusNode_; 1129 std::function<void()> focusOnNodeCallback_; 1130 std::function<void()> dragWindowVisibleCallback_; 1131 1132 std::optional<bool> needSoftKeyboard_; 1133 std::optional<bool> windowFocus_; 1134 std::optional<bool> windowShow_; 1135 1136 std::unordered_map<int32_t, WeakPtr<FrameNode>> storeNode_; 1137 std::unordered_map<int32_t, std::string> restoreNodeInfo_; 1138 std::unordered_map<int32_t, std::vector<WeakPtr<UINode>>> pageToNavigationNodes_; 1139 std::unordered_map<int32_t, std::vector<TouchEvent>> historyPointsById_; 1140 1141 std::list<FrameInfo> dumpFrameInfos_; 1142 std::list<std::function<void()>> animationClosuresList_; 1143 1144 std::map<int32_t, std::function<void(bool)>> isFocusActiveUpdateEvents_; 1145 mutable std::mutex navigationMutex_; 1146 std::map<std::string, WeakPtr<FrameNode>> navigationNodes_; 1147 std::list<DelayedTask> delayedTasks_; 1148 RefPtr<PostEventManager> postEventManager_; 1149 1150 std::unordered_map<int32_t, TouchEvent> idToTouchPoints_; 1151 std::unordered_map<int32_t, uint64_t> lastDispatchTime_; 1152 std::vector<Ace::RectF> overlayNodePositions_; 1153 std::function<void(std::vector<Ace::RectF>)> overlayNodePositionUpdateCallback_; 1154 1155 RefPtr<FrameNode> predictNode_; 1156 1157 VsyncCallbackFun onceVsyncListener_; 1158 VsyncCallbackFun vsyncListener_; 1159 ACE_DISALLOW_COPY_AND_MOVE(PipelineContext); 1160 1161 int32_t preNodeId_ = -1; 1162 1163 RefPtr<NavigationManager> navigationMgr_ = MakeRefPtr<NavigationManager>(); 1164 RefPtr<FormVisibleManager> formVisibleMgr_ = MakeRefPtr<FormVisibleManager>(); 1165 std::unique_ptr<RecycleManager> recycleManager_ = std::make_unique<RecycleManager>(); 1166 std::vector<std::shared_ptr<ITouchEventCallback>> listenerVector_; 1167 bool customTitleSettedShow_ = true; 1168 bool isShowTitle_ = false; 1169 bool isDoKeyboardAvoidAnimate_ = true; 1170 int32_t lastAnimatorExpectedFrameRate_ = -1; 1171 std::atomic<int32_t> localColorMode_ = static_cast<int32_t>(ColorMode::COLOR_MODE_UNDEFINED); 1172 bool isForceSplit_ = false; 1173 std::string homePageConfig_; 1174 1175 std::list<FrameCallbackFunc> frameCallbackFuncs_; 1176 std::list<FrameCallbackFunc> idleCallbackFuncs_; 1177 uint32_t transform_ = 0; 1178 std::list<WeakPtr<FrameNode>> changeInfoListeners_; 1179 std::list<WeakPtr<FrameNode>> changedNodes_; 1180 bool isHalfFoldHoverStatus_ = false; 1181 CancelableCallback<void()> foldStatusDelayTask_; 1182 bool isFirstRootLayout_ = true; 1183 bool isFirstFlushMessages_ = true; 1184 1185 friend class ScopedLayout; 1186 }; 1187 1188 /** 1189 * @description: only protect isLayouting_ flag in pipeline and 1190 * the user needs to guarantee that current layout is not nested 1191 */ 1192 class ACE_FORCE_EXPORT ScopedLayout final { 1193 public: 1194 ScopedLayout(PipelineContext* pipeline); 1195 ~ScopedLayout(); 1196 1197 private: 1198 PipelineContext* pipeline_ = nullptr; 1199 bool isLayouting_ = false; 1200 }; 1201 } // namespace OHOS::Ace::NG 1202 1203 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PIPELINE_NG_CONTEXT_H 1204