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