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