1 /* 2 * Copyright (c) 2022-2023 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_PIPELINE_PIPELINE_BASE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_PIPELINE_PIPELINE_BASE_H 18 19 #include <atomic> 20 #include <functional> 21 #include <memory> 22 #include <optional> 23 #include <shared_mutex> 24 #include <stack> 25 #include <string> 26 #include <unordered_map> 27 #include <utility> 28 29 #include "base/geometry/dimension.h" 30 #include "base/log/ace_performance_monitor.h" 31 #include "base/resource/asset_manager.h" 32 #include "base/resource/data_provider_manager.h" 33 #include "base/resource/shared_image_manager.h" 34 #include "base/thread/task_executor.h" 35 #include "core/accessibility/accessibility_manager.h" 36 #include "core/animation/schedule_task.h" 37 #include "core/common/clipboard/clipboard_proxy.h" 38 #include "core/common/display_info.h" 39 #include "core/common/draw_delegate.h" 40 #include "core/common/event_manager.h" 41 #include "core/common/platform_bridge.h" 42 #include "core/common/platform_res_register.h" 43 #include "core/common/resource/resource_configuration.h" 44 #include "core/common/thp_extra_manager.h" 45 #include "core/common/thread_checker.h" 46 #include "core/common/window_animation_config.h" 47 #include "core/components/common/layout/constants.h" 48 #include "core/components/common/properties/animation_option.h" 49 #include "core/components/theme/resource_adapter.h" 50 #include "core/components/theme/theme_manager.h" 51 #include "core/components_ng/pattern/ui_extension/ui_extension_config.h" 52 #include "core/components_ng/property/safe_area_insets.h" 53 #include "core/event/axis_event.h" 54 #include "core/event/key_event.h" 55 #include "core/event/mouse_event.h" 56 #include "core/event/rotation_event.h" 57 #include "core/event/touch_event.h" 58 #include "core/event/pointer_event.h" 59 #include "core/gestures/gesture_info.h" 60 #include "core/image/image_cache.h" 61 #include "core/pipeline/container_window_manager.h" 62 #include "core/components_ng/manager/display_sync/ui_display_sync_manager.h" 63 #include "interfaces/inner_api/ace/serialized_gesture.h" 64 65 namespace OHOS::Rosen { 66 class RSTransaction; 67 class AvoidArea; 68 } // namespace OHOS::Rosen 69 70 namespace OHOS::Ace { 71 namespace NG { 72 class FrameNode; 73 } // namespace NG 74 75 struct KeyboardAnimationCurve { 76 std::string curveType_; 77 std::vector<float> curveParams_; 78 uint32_t duration_ = 0; 79 }; 80 81 struct KeyboardAnimationConfig { 82 KeyboardAnimationCurve curveIn_; 83 KeyboardAnimationCurve curveOut_; 84 }; 85 86 struct FontInfo; 87 struct FontConfigJsonInfo; 88 class Frontend; 89 class OffscreenCanvas; 90 class Window; 91 class FontManager; 92 class ManagerInterface; 93 class NavigationController; 94 enum class FrontendType; 95 using SharePanelCallback = std::function<void(const std::string& bundleName, const std::string& abilityName)>; 96 using AceVsyncCallback = std::function<void(uint64_t, uint64_t)>; 97 98 class ACE_FORCE_EXPORT PipelineBase : public AceType { 99 DECLARE_ACE_TYPE(PipelineBase, AceType); 100 101 public: 102 PipelineBase() = default; 103 PipelineBase(std::shared_ptr<Window> window, RefPtr<TaskExecutor> taskExecutor, RefPtr<AssetManager> assetManager, 104 const RefPtr<Frontend>& frontend, int32_t instanceId); 105 PipelineBase(std::shared_ptr<Window> window, RefPtr<TaskExecutor> taskExecutor, RefPtr<AssetManager> assetManager, 106 const RefPtr<Frontend>& frontend, int32_t instanceId, RefPtr<PlatformResRegister> platformResRegister); 107 ~PipelineBase() override; 108 109 static RefPtr<PipelineBase> GetCurrentContext(); 110 111 static RefPtr<PipelineBase> GetCurrentContextSafely(); 112 113 static RefPtr<PipelineBase> GetCurrentContextSafelyWithCheck(); 114 115 static RefPtr<PipelineBase> GetMainPipelineContext(); 116 117 static RefPtr<ThemeManager> CurrentThemeManager(); 118 119 static void SetCallBackNode(const WeakPtr<NG::FrameNode>& node); 120 121 /* 122 * Change px to vp with density of current pipeline 123 */ 124 static double Px2VpWithCurrentDensity(double px); 125 126 /* 127 * Change vp to px with density of current pipeline 128 */ 129 static double Vp2PxWithCurrentDensity(double vp); 130 131 /* 132 * Get density of current pipeline if valid, or return density of default display 133 */ 134 static double GetCurrentDensity(); 135 136 static ColorMode GetCurrentColorMode(); 137 138 virtual void SetupRootElement() = 0; 139 140 virtual uint64_t GetTimeFromExternalTimer(); 141 142 virtual bool NeedSoftKeyboard() = 0; 143 144 virtual void SetOnWindowFocused(const std::function<void()>& callback) = 0; 145 146 bool Animate(const AnimationOption& option, const RefPtr<Curve>& curve, 147 const std::function<void()>& propertyCallback, const std::function<void()>& finishCallBack = nullptr); 148 149 virtual void AddKeyFrame( 150 float fraction, const RefPtr<Curve>& curve, const std::function<void()>& propertyCallback) = 0; 151 152 virtual void AddKeyFrame(float fraction, const std::function<void()>& propertyCallback) = 0; 153 154 void PrepareOpenImplicitAnimation(); 155 CatchInteractiveAnimations(const std::function<void ()> & animationCallback)156 virtual bool CatchInteractiveAnimations(const std::function<void()>& animationCallback) 157 { 158 return false; 159 } 160 161 void OpenImplicitAnimation(const AnimationOption& option, const RefPtr<Curve>& curve, 162 const std::function<void()>& finishCallback = nullptr); 163 164 void StartImplicitAnimation(const AnimationOption& operation, const RefPtr<Curve>& curve, 165 const std::function<void()>& finishCallback = nullptr, const std::optional<int32_t>& count = std::nullopt); 166 HasPendingAnimation()167 bool HasPendingAnimation() const 168 { 169 return !pendingFrontendAnimation_.empty(); 170 } 171 172 void PrepareCloseImplicitAnimation(); 173 174 bool CloseImplicitAnimation(); 175 176 void ForceLayoutForImplicitAnimation(); 177 178 void ForceRenderForImplicitAnimation(); 179 180 // add schedule task and return the unique mark id. 181 virtual uint32_t AddScheduleTask(const RefPtr<ScheduleTask>& task) = 0; 182 183 // remove schedule task by id. 184 virtual void RemoveScheduleTask(uint32_t id) = 0; 185 186 // Called by view when touch event received. 187 virtual void OnTouchEvent(const TouchEvent& point, bool isSubPipe = false) = 0; 188 189 // Called by ohos AceContainer when touch event received. 190 virtual void OnTouchEvent(const TouchEvent& point, const RefPtr<NG::FrameNode>& node, bool isSubPipe = false) 191 {} 192 OnAccessibilityHoverEvent(const TouchEvent & point,const RefPtr<NG::FrameNode> & node)193 virtual void OnAccessibilityHoverEvent(const TouchEvent& point, const RefPtr<NG::FrameNode>& node) {} 194 OnPenHoverEvent(const TouchEvent & point,const RefPtr<NG::FrameNode> & node)195 virtual void OnPenHoverEvent(const TouchEvent& point, const RefPtr<NG::FrameNode>& node) {} 196 HandlePenHoverOut(const TouchEvent & point)197 virtual void HandlePenHoverOut(const TouchEvent& point) {} 198 199 // Called by container when key event received. 200 // if return false, then this event needs platform to handle it. 201 virtual bool OnNonPointerEvent(const NonPointerEvent& event) = 0; 202 203 // Called by view when mouse event received. 204 virtual void OnMouseEvent(const MouseEvent& event) = 0; 205 206 // Called by ohos AceContainer when mouse event received. OnMouseEvent(const MouseEvent & event,const RefPtr<NG::FrameNode> & node)207 virtual void OnMouseEvent(const MouseEvent& event, const RefPtr<NG::FrameNode>& node) {} 208 OnMouseMoveEventForAxisEvent(const MouseEvent & event,const RefPtr<NG::FrameNode> & node)209 virtual void OnMouseMoveEventForAxisEvent(const MouseEvent& event, const RefPtr<NG::FrameNode>& node) {}; 210 211 // Called by view when axis event received. 212 virtual void OnAxisEvent(const AxisEvent& event) = 0; 213 214 // Called by ohos AceContainer when axis event received. OnAxisEvent(const AxisEvent & event,const RefPtr<NG::FrameNode> & node)215 virtual void OnAxisEvent(const AxisEvent& event, const RefPtr<NG::FrameNode>& node) {} 216 217 // Called by container when rotation event received. 218 // if return false, then this event needs platform to handle it. 219 virtual bool OnRotationEvent(const RotationEvent& event) const = 0; 220 221 // Called by window when received vsync signal. 222 virtual void OnVsyncEvent(uint64_t nanoTimestamp, uint64_t frameCount); 223 224 // Called by viewr 225 virtual void OnDragEvent(const DragPointerEvent& pointerEvent, DragEventAction action, 226 const RefPtr<NG::FrameNode>& node = nullptr) = 0; 227 228 // Called by view when idle event. 229 virtual void OnIdle(int64_t deadline) = 0; 230 231 virtual void SetBuildAfterCallback(const std::function<void()>& callback) = 0; 232 233 virtual void DispatchDisplaySync(uint64_t nanoTimestamp) = 0; 234 235 virtual void FlushAnimation(uint64_t nanoTimestamp) = 0; 236 237 virtual void SendEventToAccessibility(const AccessibilityEvent& accessibilityEvent); 238 239 virtual void SaveExplicitAnimationOption(const AnimationOption& option) = 0; 240 241 virtual void CreateExplicitAnimator(const std::function<void()>& onFinishEvent) = 0; 242 243 virtual void ClearExplicitAnimationOption() = 0; 244 245 virtual AnimationOption GetExplicitAnimationOption() const = 0; 246 247 virtual void Destroy(); 248 249 virtual void OnShow() = 0; 250 251 virtual void OnHide() = 0; 252 253 virtual void WindowFocus(bool isFocus) = 0; 254 WindowActivate(bool isActive)255 virtual void WindowActivate(bool isActive) {} 256 257 virtual void ContainerModalUnFocus() = 0; 258 259 virtual void ShowContainerTitle(bool isShow, bool hasDeco = true, bool needUpdate = false) = 0; 260 261 virtual void OnSurfaceChanged(int32_t width, int32_t height, 262 WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED, 263 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr) = 0; 264 265 virtual void OnSurfacePositionChanged(int32_t posX, int32_t posY) = 0; 266 OnSurfaceDensityChanged(double density)267 virtual void OnSurfaceDensityChanged(double density) 268 { 269 // To avoid the race condition caused by the offscreen canvas get density from the pipeline in the worker 270 // thread. 271 std::lock_guard lock(densityChangeMutex_); 272 for (auto&& [id, callback] : densityChangedCallbacks_) { 273 if (callback) { 274 callback(density); 275 } 276 } 277 } 278 SendUpdateVirtualNodeFocusEvent()279 void SendUpdateVirtualNodeFocusEvent() 280 { 281 auto accessibilityManager = GetAccessibilityManager(); 282 CHECK_NULL_VOID(accessibilityManager); 283 accessibilityManager->UpdateVirtualNodeFocus(); 284 } 285 RegisterWindowDensityCallback(std::function<double ()> && callback)286 void RegisterWindowDensityCallback(std::function<double()>&& callback) 287 { 288 windowDensityCallback_ = callback; 289 } 290 GetWindowDensity()291 double GetWindowDensity() const 292 { 293 if (windowDensityCallback_) { 294 return windowDensityCallback_(); 295 } 296 return 1.0; 297 } 298 RegisterDensityChangedCallback(std::function<void (double)> && callback)299 int32_t RegisterDensityChangedCallback(std::function<void(double)>&& callback) 300 { 301 if (callback) { 302 // To avoid the race condition caused by the offscreen canvas get density from the pipeline in the worker 303 // thread. 304 std::lock_guard lock(densityChangeMutex_); 305 densityChangedCallbacks_.emplace(++densityChangeCallbackId_, std::move(callback)); 306 return densityChangeCallbackId_; 307 } 308 return 0; 309 } 310 UnregisterDensityChangedCallback(int32_t callbackId)311 void UnregisterDensityChangedCallback(int32_t callbackId) 312 { 313 // To avoid the race condition caused by the offscreen canvas get density from the pipeline in the worker 314 // thread. 315 std::lock_guard lock(densityChangeMutex_); 316 densityChangedCallbacks_.erase(callbackId); 317 } 318 319 virtual void OnTransformHintChanged(uint32_t transform) = 0; 320 321 virtual void OnSystemBarHeightChanged(double statusBar, double navigationBar) = 0; 322 323 virtual void OnSurfaceDestroyed() = 0; 324 325 virtual void NotifyOnPreDraw() = 0; 326 327 virtual bool CallRouterBackToPopPage(bool* isUserAccept = nullptr) = 0; 328 PopPageStackOverlay()329 virtual bool PopPageStackOverlay() 330 { 331 return false; 332 } 333 HideOverlays()334 virtual void HideOverlays() {} 335 OnPageShow()336 virtual void OnPageShow() {} 337 338 virtual void OnActionEvent(const std::string& action); 339 340 virtual void Finish(bool autoFinish = true) const {} 341 RequestFullWindow(int32_t duration)342 virtual void RequestFullWindow(int32_t duration) {} 343 344 virtual bool RequestFocus(const std::string& targetNodeId, bool isSyncRequest = false) 345 { 346 return false; 347 } 348 349 // Called by AceContainer. 350 bool Dump(const std::vector<std::string>& params) const; 351 DumpUIExt()352 virtual void DumpUIExt() const {} 353 IsLastPage()354 virtual bool IsLastPage() 355 { 356 return false; 357 } 358 GetIsDeclarative()359 virtual bool GetIsDeclarative() const 360 { 361 return true; 362 } 363 SetAppBgColor(const Color & color)364 virtual void SetAppBgColor(const Color& color) 365 { 366 appBgColor_ = color; 367 } 368 SetWindowContainerColor(const Color & activeColor,const Color & inactiveColor)369 virtual void SetWindowContainerColor(const Color& activeColor, const Color& inactiveColor) {} 370 ChangeDarkModeBrightness()371 virtual void ChangeDarkModeBrightness() {} 372 SetFormRenderingMode(int8_t renderMode)373 void SetFormRenderingMode(int8_t renderMode) 374 { 375 renderingMode_ = renderMode; 376 } 377 SetFormEnableBlurBackground(bool enableBlurBackground)378 void SetFormEnableBlurBackground(bool enableBlurBackground) 379 { 380 enableBlurBackground_ = enableBlurBackground; 381 } 382 GetAppBgColor()383 const Color& GetAppBgColor() const 384 { 385 return appBgColor_; 386 } 387 GetAppLabelId()388 int32_t GetAppLabelId() const 389 { 390 return appLabelId_; 391 } 392 SetAppLabelId(int32_t appLabelId)393 void SetAppLabelId(int32_t appLabelId) 394 { 395 appLabelId_ = appLabelId; 396 } 397 398 virtual void SetAppTitle(const std::string& title) = 0; 399 400 virtual void SetAppIcon(const RefPtr<PixelMap>& icon) = 0; 401 SetContainerButtonHide(bool hideSplit,bool hideMaximize,bool hideMinimize,bool hideClose)402 virtual void SetContainerButtonHide(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose) {} 403 EnableContainerModalGesture(bool isEnable)404 virtual void EnableContainerModalGesture(bool isEnable) {} 405 GetContainerFloatingTitleVisible()406 virtual bool GetContainerFloatingTitleVisible() 407 { 408 return false; 409 } 410 GetContainerCustomTitleVisible()411 virtual bool GetContainerCustomTitleVisible() 412 { 413 return false; 414 } 415 GetContainerControlButtonVisible()416 virtual bool GetContainerControlButtonVisible() 417 { 418 return false; 419 } 420 RefreshRootBgColor()421 virtual void RefreshRootBgColor() const {} 422 PostponePageTransition()423 virtual void PostponePageTransition() {} LaunchPageTransition()424 virtual void LaunchPageTransition() {} 425 GetBoundingRectData(int32_t nodeId,Rect & rect)426 virtual void GetBoundingRectData(int32_t nodeId, Rect& rect) {} 427 CheckAndUpdateKeyboardInset(float keyboardHeight)428 virtual void CheckAndUpdateKeyboardInset(float keyboardHeight) {} 429 430 virtual RefPtr<AccessibilityManager> GetAccessibilityManager() const; 431 GetNavigationController(const std::string & id)432 virtual std::shared_ptr<NavigationController> GetNavigationController(const std::string& id) 433 { 434 return nullptr; 435 } 436 437 void SetRootSize(double density, float width, float height); 438 439 void UpdateFontWeightScale(); 440 SetFollowSystem(bool followSystem)441 void SetFollowSystem(bool followSystem) 442 { 443 followSystem_ = followSystem; 444 } 445 SetMaxAppFontScale(float maxAppFontScale)446 void SetMaxAppFontScale(float maxAppFontScale) 447 { 448 maxAppFontScale_ = maxAppFontScale; 449 } 450 GetMaxAppFontScale()451 float GetMaxAppFontScale() 452 { 453 return maxAppFontScale_; 454 } 455 IsFollowSystem()456 bool IsFollowSystem() 457 { 458 return followSystem_; 459 } 460 461 double NormalizeToPx(const Dimension& dimension) const; 462 463 double ConvertPxToVp(const Dimension& dimension) const; 464 465 using FinishEventHandler = std::function<void()>; SetFinishEventHandler(FinishEventHandler && listener)466 void SetFinishEventHandler(FinishEventHandler&& listener) 467 { 468 finishEventHandler_ = std::move(listener); 469 } 470 471 using StartAbilityHandler = std::function<void(const std::string& address)>; SetStartAbilityHandler(StartAbilityHandler && listener)472 void SetStartAbilityHandler(StartAbilityHandler&& listener) 473 { 474 startAbilityHandler_ = std::move(listener); 475 } 476 void HyperlinkStartAbility(const std::string& address) const; 477 478 using StartAbilityOnQueryHandler = std::function<void(const std::string& queryWord)>; SetStartAbilityOnQueryHandler(StartAbilityOnQueryHandler && listener)479 void SetStartAbilityOnQueryHandler(StartAbilityOnQueryHandler&& listener) 480 { 481 startAbilityOnQueryHandler_ = std::move(listener); 482 } 483 void StartAbilityOnQuery(const std::string& queryWord) const; 484 485 using ActionEventHandler = std::function<void(const std::string& action)>; SetActionEventHandler(ActionEventHandler && listener)486 void SetActionEventHandler(ActionEventHandler&& listener) 487 { 488 actionEventHandler_ = std::move(listener); 489 } 490 491 using FormLinkInfoUpdateHandler = std::function<void(const std::vector<std::string>&)>; SetFormLinkInfoUpdateHandler(FormLinkInfoUpdateHandler && listener)492 void SetFormLinkInfoUpdateHandler(FormLinkInfoUpdateHandler&& listener) 493 { 494 formLinkInfoUpdateHandler_ = std::move(listener); 495 } 496 497 using StatusBarEventHandler = std::function<void(const Color& color)>; SetStatusBarEventHandler(StatusBarEventHandler && listener)498 void SetStatusBarEventHandler(StatusBarEventHandler&& listener) 499 { 500 statusBarBgColorEventHandler_ = std::move(listener); 501 } 502 void NotifyStatusBarBgColor(const Color& color) const; 503 504 using PopupEventHandler = std::function<void()>; SetPopupEventHandler(PopupEventHandler && listener)505 void SetPopupEventHandler(PopupEventHandler&& listener) 506 { 507 popupEventHandler_ = std::move(listener); 508 } 509 void NotifyPopupDismiss() const; 510 511 using MenuEventHandler = std::function<void()>; SetMenuEventHandler(MenuEventHandler && listener)512 void SetMenuEventHandler(MenuEventHandler&& listener) 513 { 514 menuEventHandler_ = std::move(listener); 515 } 516 void NotifyMenuDismiss() const; 517 518 using ContextMenuEventHandler = std::function<void()>; SetContextMenuEventHandler(ContextMenuEventHandler && listener)519 void SetContextMenuEventHandler(ContextMenuEventHandler&& listener) 520 { 521 contextMenuEventHandler_ = std::move(listener); 522 } 523 void NotifyContextMenuDismiss() const; 524 525 using RouterBackEventHandler = std::function<void()>; SetRouterBackEventHandler(RouterBackEventHandler && listener)526 void SetRouterBackEventHandler(RouterBackEventHandler&& listener) 527 { 528 routerBackEventHandler_ = std::move(listener); 529 } 530 void NotifyRouterBackDismiss() const; 531 532 using PopPageSuccessEventHandler = std::function<void(const std::string& pageUrl, const int32_t pageId)>; SetPopPageSuccessEventHandler(PopPageSuccessEventHandler && listener)533 void SetPopPageSuccessEventHandler(PopPageSuccessEventHandler&& listener) 534 { 535 popPageSuccessEventHandler_.push_back(std::move(listener)); 536 } 537 void NotifyPopPageSuccessDismiss(const std::string& pageUrl, int32_t pageId) const; 538 539 using IsPagePathInvalidEventHandler = std::function<void(bool& isPageInvalid)>; SetIsPagePathInvalidEventHandler(IsPagePathInvalidEventHandler && listener)540 void SetIsPagePathInvalidEventHandler(IsPagePathInvalidEventHandler&& listener) 541 { 542 isPagePathInvalidEventHandler_.push_back(std::move(listener)); 543 } 544 void NotifyIsPagePathInvalidDismiss(bool isPageInvalid) const; 545 546 using DestroyEventHandler = std::function<void()>; SetDestroyHandler(DestroyEventHandler && listener)547 void SetDestroyHandler(DestroyEventHandler&& listener) 548 { 549 destroyEventHandler_.push_back(std::move(listener)); 550 } 551 void NotifyDestroyEventDismiss() const; 552 553 using DispatchTouchEventHandler = std::function<void(const TouchEvent& event)>; SetDispatchTouchEventHandler(DispatchTouchEventHandler && listener)554 void SetDispatchTouchEventHandler(DispatchTouchEventHandler&& listener) 555 { 556 dispatchTouchEventHandler_.push_back(std::move(listener)); 557 } 558 void NotifyDispatchTouchEventDismiss(const TouchEvent& event) const; 559 560 using GetViewScaleCallback = std::function<bool(float&, float&)>; SetGetViewScaleCallback(GetViewScaleCallback && callback)561 void SetGetViewScaleCallback(GetViewScaleCallback&& callback) 562 { 563 getViewScaleCallback_ = callback; 564 } 565 566 using OnPageShowCallBack = std::function<void()>; SetOnPageShow(OnPageShowCallBack && onPageShowCallBack)567 void SetOnPageShow(OnPageShowCallBack&& onPageShowCallBack) 568 { 569 onPageShowCallBack_ = std::move(onPageShowCallBack); 570 } 571 572 using AnimationCallback = std::function<void()>; SetAnimationCallback(AnimationCallback && callback)573 void SetAnimationCallback(AnimationCallback&& callback) 574 { 575 animationCallback_ = std::move(callback); 576 } 577 578 using ProfilerCallback = std::function<void(const std::string&)>; SetOnVsyncProfiler(const ProfilerCallback & callback)579 void SetOnVsyncProfiler(const ProfilerCallback& callback) 580 { 581 onVsyncProfiler_ = callback; 582 } 583 584 using OnRouterChangeCallback = bool (*)(const std::string currentRouterPath); AddRouterChangeCallback(const OnRouterChangeCallback & onRouterChangeCallback)585 void AddRouterChangeCallback(const OnRouterChangeCallback& onRouterChangeCallback) 586 { 587 onRouterChangeCallback_ = onRouterChangeCallback; 588 } 589 590 void onRouterChange(const std::string& url); 591 ResetOnVsyncProfiler()592 void ResetOnVsyncProfiler() 593 { 594 onVsyncProfiler_ = nullptr; 595 } 596 GetViewScale(float & scaleX,float & scaleY)597 bool GetViewScale(float& scaleX, float& scaleY) 598 { 599 if (getViewScaleCallback_) { 600 return getViewScaleCallback_(scaleX, scaleY); 601 } 602 return false; 603 } 604 GetTaskExecutor()605 RefPtr<TaskExecutor> GetTaskExecutor() const 606 { 607 return taskExecutor_; 608 } 609 610 RefPtr<Frontend> GetFrontend() const; 611 GetInstanceId()612 int32_t GetInstanceId() const 613 { 614 return instanceId_; 615 } 616 617 void ClearImageCache(); 618 619 void SetImageCache(const RefPtr<ImageCache>& imageChache); 620 621 RefPtr<ImageCache> GetImageCache() const; 622 GetOrCreateSharedImageManager()623 const RefPtr<SharedImageManager>& GetOrCreateSharedImageManager() 624 { 625 std::scoped_lock<std::shared_mutex> lock(imageMtx_); 626 if (!sharedImageManager_) { 627 sharedImageManager_ = MakeRefPtr<SharedImageManager>(taskExecutor_); 628 } 629 return sharedImageManager_; 630 } 631 GetOrCreateUIDisplaySyncManager()632 const RefPtr<UIDisplaySyncManager>& GetOrCreateUIDisplaySyncManager() 633 { 634 std::call_once(displaySyncFlag_, [this]() { 635 if (!uiDisplaySyncManager_) { 636 uiDisplaySyncManager_ = MakeRefPtr<UIDisplaySyncManager>(); 637 } 638 }); 639 return uiDisplaySyncManager_; 640 } 641 GetWindow()642 Window* GetWindow() 643 { 644 return window_.get(); 645 } 646 GetAssetManager()647 RefPtr<AssetManager> GetAssetManager() const 648 { 649 return assetManager_; 650 } 651 GetMinPlatformVersion()652 int32_t GetMinPlatformVersion() const 653 { 654 // Since API10, the platform version data format has changed. 655 // Use the last three digits of data as platform version. For example (4000000010). 656 return minPlatformVersion_ % 1000; 657 } 658 SetMinPlatformVersion(int32_t minPlatformVersion)659 void SetMinPlatformVersion(int32_t minPlatformVersion) 660 { 661 minPlatformVersion_ = minPlatformVersion; 662 } 663 SetInstallationFree(int32_t installationFree)664 void SetInstallationFree(int32_t installationFree) 665 { 666 installationFree_ = installationFree; 667 } 668 GetInstallationFree()669 bool GetInstallationFree() const 670 { 671 return installationFree_; 672 } 673 SetSharePanelCallback(SharePanelCallback && callback)674 void SetSharePanelCallback(SharePanelCallback&& callback) 675 { 676 sharePanelCallback_ = std::move(callback); 677 } 678 FireSharePanelCallback(const std::string & bundleName,const std::string & abilityName)679 void FireSharePanelCallback(const std::string& bundleName, const std::string& abilityName) 680 { 681 if (sharePanelCallback_) { 682 sharePanelCallback_(bundleName, abilityName); 683 } 684 } 685 GetThemeManager()686 RefPtr<ThemeManager> GetThemeManager() const 687 { 688 std::shared_lock<std::shared_mutex> lock(themeMtx_); 689 return themeManager_; 690 } 691 SetThemeManager(RefPtr<ThemeManager> theme)692 void SetThemeManager(RefPtr<ThemeManager> theme) 693 { 694 CHECK_RUN_ON(UI); 695 std::unique_lock<std::shared_mutex> lock(themeMtx_); 696 themeManager_ = std::move(theme); 697 } 698 UpdateThemeManager(const RefPtr<ResourceAdapter> & adapter)699 void UpdateThemeManager(const RefPtr<ResourceAdapter>& adapter) { 700 std::unique_lock<std::shared_mutex> lock(themeMtx_); 701 CHECK_NULL_VOID(themeManager_); 702 auto themeConstants = themeManager_->GetThemeConstants(); 703 CHECK_NULL_VOID(themeConstants); 704 themeConstants->UpdateResourceAdapter(adapter); 705 } 706 707 template<typename T> GetTheme()708 RefPtr<T> GetTheme() const 709 { 710 std::shared_lock<std::shared_mutex> lock(themeMtx_); 711 if (themeManager_) { 712 return themeManager_->GetTheme<T>(); 713 } 714 return {}; 715 } 716 717 template<typename T> GetTheme(int32_t themeScopeId)718 RefPtr<T> GetTheme(int32_t themeScopeId) const 719 { 720 std::shared_lock<std::shared_mutex> lock(themeMtx_); 721 if (themeManager_) { 722 return themeManager_->GetTheme<T>(themeScopeId); 723 } 724 return {}; 725 } 726 727 bool CheckIfGetTheme(); 728 729 template<typename T> GetDraggable()730 bool GetDraggable() 731 { 732 if (!CheckIfGetTheme()) { 733 return false; 734 } 735 auto theme = GetTheme<T>(); 736 CHECK_NULL_RETURN(theme, false); 737 return theme->GetDraggable(); 738 } 739 GetTextFieldManager()740 const RefPtr<ManagerInterface>& GetTextFieldManager() 741 { 742 return textFieldManager_; 743 } 744 void SetTextFieldManager(const RefPtr<ManagerInterface>& manager); 745 GetFontManager()746 const RefPtr<FontManager>& GetFontManager() const 747 { 748 return fontManager_; 749 } 750 GetDataProviderManager()751 const RefPtr<DataProviderManagerInterface>& GetDataProviderManager() const 752 { 753 return dataProviderManager_; 754 } SetDataProviderManager(const RefPtr<DataProviderManagerInterface> & dataProviderManager)755 void SetDataProviderManager(const RefPtr<DataProviderManagerInterface>& dataProviderManager) 756 { 757 dataProviderManager_ = dataProviderManager; 758 } 759 GetMessageBridge()760 const RefPtr<PlatformBridge>& GetMessageBridge() const 761 { 762 return messageBridge_; 763 } SetMessageBridge(const RefPtr<PlatformBridge> & messageBridge)764 void SetMessageBridge(const RefPtr<PlatformBridge>& messageBridge) 765 { 766 messageBridge_ = messageBridge; 767 } 768 SetIsJsCard(bool isJsCard)769 void SetIsJsCard(bool isJsCard) 770 { 771 isJsCard_ = isJsCard; 772 } 773 SetIsJsPlugin(bool isJsPlugin)774 void SetIsJsPlugin(bool isJsPlugin) 775 { 776 isJsPlugin_ = isJsPlugin; 777 } 778 SetDrawDelegate(std::unique_ptr<DrawDelegate> delegate)779 void SetDrawDelegate(std::unique_ptr<DrawDelegate> delegate) 780 { 781 drawDelegate_ = std::move(delegate); 782 } 783 IsJsCard()784 bool IsJsCard() const 785 { 786 return isJsCard_; 787 } 788 IsJsPlugin()789 bool IsJsPlugin() const 790 { 791 return isJsPlugin_; 792 } 793 SetIsFormRender(bool isEtsCard)794 void SetIsFormRender(bool isEtsCard) 795 { 796 isFormRender_ = isEtsCard; 797 } 798 IsFormRender()799 bool IsFormRender() const 800 { 801 return isFormRender_; 802 } 803 IsFormRenderExceptDynamicComponent()804 bool IsFormRenderExceptDynamicComponent() const 805 { 806 return isFormRender_ && !isDynamicRender_; 807 } 808 SetIsDynamicRender(bool isDynamicRender)809 void SetIsDynamicRender(bool isDynamicRender) 810 { 811 isDynamicRender_ = isDynamicRender; 812 } 813 IsDynamicRender()814 bool IsDynamicRender() const 815 { 816 return isDynamicRender_; 817 } 818 819 // Get the dp scale which used to covert dp to logic px. GetDipScale()820 double GetDipScale() const 821 { 822 return dipScale_; 823 } 824 825 // Get the window design scale used to covert lpx to logic px. GetLogicScale()826 double GetLogicScale() const 827 { 828 return designWidthScale_; 829 } 830 GetFontScale()831 float GetFontScale() const 832 { 833 return fontScale_; 834 } 835 void SetFontScale(float fontScale); 836 GetFontWeightScale()837 float GetFontWeightScale() const 838 { 839 return fontWeightScale_; 840 } 841 void SetFontWeightScale(float fontWeightScale); 842 GetWindowId()843 uint32_t GetWindowId() const 844 { 845 return windowId_; 846 } 847 SetWindowId(uint32_t windowId)848 void SetWindowId(uint32_t windowId) 849 { 850 windowId_ = windowId; 851 } 852 853 bool NeedTouchInterpolation(); 854 SetFocusWindowId(uint32_t windowId)855 void SetFocusWindowId(uint32_t windowId) 856 { 857 focusWindowId_ = windowId; 858 } 859 GetFocusWindowId()860 uint32_t GetFocusWindowId() const 861 { 862 return focusWindowId_.value_or(windowId_); 863 } 864 IsFocusWindowIdSetted()865 bool IsFocusWindowIdSetted() const 866 { 867 return focusWindowId_.has_value(); 868 } 869 SetIsArkUIHookEnabled(bool enable)870 void SetIsArkUIHookEnabled(bool enable) 871 { 872 isArkUIHookEnabled_ = enable; 873 } 874 bool IsArkUIHookEnabled() const; 875 SetRealHostWindowId(uint32_t realHostWindowId)876 void SetRealHostWindowId(uint32_t realHostWindowId) 877 { 878 realHostWindowId_ = realHostWindowId; 879 } 880 GetRealHostWindowId()881 uint32_t GetRealHostWindowId() const 882 { 883 return realHostWindowId_.value_or(GetFocusWindowId()); 884 } 885 IsRealHostWindowIdSetted()886 bool IsRealHostWindowIdSetted() const 887 { 888 return realHostWindowId_.has_value(); 889 } 890 GetViewScale()891 float GetViewScale() const 892 { 893 return viewScale_; 894 } 895 SetIsCurrentInForceSplitMode(bool split)896 void SetIsCurrentInForceSplitMode(bool split) 897 { 898 isCurrentInForceSplitMode_ = split; 899 } 900 IsCurrentInForceSplitMode()901 bool IsCurrentInForceSplitMode() const 902 { 903 return isCurrentInForceSplitMode_; 904 } 905 906 double CalcPageWidth(double rootWidth) const; 907 908 double GetPageWidth() const; 909 GetRootWidth()910 double GetRootWidth() const 911 { 912 return rootWidth_; 913 } 914 GetRootHeight()915 double GetRootHeight() const 916 { 917 return rootHeight_; 918 } 919 GetWindowOriginalWidth()920 int32_t GetWindowOriginalWidth() const 921 { 922 return width_; 923 } 924 SetWindowModal(WindowModal modal)925 void SetWindowModal(WindowModal modal) 926 { 927 windowModal_ = modal; 928 } 929 GetWindowModal()930 WindowModal GetWindowModal() const 931 { 932 return windowModal_; 933 } 934 IsFullScreenModal()935 bool IsFullScreenModal() const 936 { 937 return windowModal_ == WindowModal::NORMAL || windowModal_ == WindowModal::SEMI_MODAL_FULL_SCREEN || 938 windowModal_ == WindowModal::CONTAINER_MODAL || isFullWindow_; 939 } 940 SetIsRightToLeft(bool isRightToLeft)941 void SetIsRightToLeft(bool isRightToLeft) 942 { 943 isRightToLeft_ = isRightToLeft; 944 } 945 IsRightToLeft()946 bool IsRightToLeft() const 947 { 948 return isRightToLeft_; 949 } 950 SetEventManager(const RefPtr<EventManager> & eventManager)951 void SetEventManager(const RefPtr<EventManager>& eventManager) 952 { 953 eventManager_ = eventManager; 954 } 955 GetEventManager()956 RefPtr<EventManager> GetEventManager() const 957 { 958 return eventManager_; 959 } 960 GetWindowManager()961 const RefPtr<WindowManager>& GetWindowManager() const 962 { 963 return windowManager_; 964 } 965 966 bool HasFloatTitle() const; 967 IsRebuildFinished()968 bool IsRebuildFinished() const 969 { 970 return isRebuildFinished_; 971 } 972 973 void RequestFrame(); 974 975 void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "", 976 const std::string& moduleName = ""); 977 978 void GetSystemFontList(std::vector<std::string>& fontList); 979 980 bool GetSystemFont(const std::string& fontName, FontInfo& fontInfo); 981 982 void GetUIFontConfig(FontConfigJsonInfo& fontConfigJsonInfo); 983 984 void TryLoadImageInfo(const std::string& src, std::function<void(bool, int32_t, int32_t)>&& loadCallback); 985 986 RefPtr<OffscreenCanvas> CreateOffscreenCanvas(int32_t width, int32_t height); 987 988 void PostAsyncEvent(TaskExecutor::Task&& task, const std::string& name, 989 TaskExecutor::TaskType type = TaskExecutor::TaskType::UI); 990 991 void PostAsyncEvent(const TaskExecutor::Task& task, const std::string& name, 992 TaskExecutor::TaskType type = TaskExecutor::TaskType::UI); 993 994 void PostSyncEvent(const TaskExecutor::Task& task, const std::string& name, 995 TaskExecutor::TaskType type = TaskExecutor::TaskType::UI); 996 997 virtual void FlushReload(const ConfigurationChange& configurationChange, bool fullUpdate = true) {} 998 FlushBuild()999 virtual void FlushBuild() {} 1000 FlushReloadTransition()1001 virtual void FlushReloadTransition() {} RebuildFontNode()1002 virtual void RebuildFontNode() {} GetFrontendType()1003 FrontendType GetFrontendType() const 1004 { 1005 return frontendType_; 1006 } 1007 GetDensity()1008 double GetDensity() const 1009 { 1010 return density_; 1011 } 1012 GetPlatformResRegister()1013 RefPtr<PlatformResRegister> GetPlatformResRegister() const 1014 { 1015 return platformResRegister_; 1016 } 1017 1018 void SetTouchPipeline(const WeakPtr<PipelineBase>& context); 1019 void RemoveTouchPipeline(const WeakPtr<PipelineBase>& context); 1020 1021 void OnVirtualKeyboardAreaChange(Rect keyboardArea, 1022 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, const float safeHeight = 0.0f, 1023 bool supportAvoidance = false, bool forceChange = false); 1024 void OnVirtualKeyboardAreaChange(Rect keyboardArea, double positionY, double height, 1025 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, bool forceChange = false); 1026 1027 void OnFoldStatusChanged(FoldStatus foldStatus); 1028 1029 using foldStatusChangedCallback = std::function<bool(FoldStatus)>; SetFoldStatusChangeCallback(foldStatusChangedCallback && listener)1030 void SetFoldStatusChangeCallback(foldStatusChangedCallback&& listener) 1031 { 1032 foldStatusChangedCallback_.emplace_back(std::move(listener)); 1033 } 1034 1035 void OnFoldDisplayModeChanged(FoldDisplayMode foldDisplayMode); 1036 1037 using virtualKeyBoardCallback = std::function<bool(int32_t, int32_t, double, bool)>; SetVirtualKeyBoardCallback(virtualKeyBoardCallback && listener)1038 void SetVirtualKeyBoardCallback(virtualKeyBoardCallback&& listener) 1039 { 1040 static std::atomic<int32_t> pseudoId(-1); // -1 will not be conflict with real node ids. 1041 auto nodeId = pseudoId.fetch_sub(1, std::memory_order_relaxed); 1042 virtualKeyBoardCallback_.emplace(std::make_pair(nodeId, std::move(listener))); 1043 } SetVirtualKeyBoardCallback(int32_t nodeId,virtualKeyBoardCallback && listener)1044 void SetVirtualKeyBoardCallback(int32_t nodeId, virtualKeyBoardCallback&& listener) 1045 { 1046 virtualKeyBoardCallback_.emplace(std::make_pair(nodeId, std::move(listener))); 1047 } RemoveVirtualKeyBoardCallback(int32_t nodeId)1048 void RemoveVirtualKeyBoardCallback(int32_t nodeId) 1049 { 1050 virtualKeyBoardCallback_.erase(nodeId); 1051 } NotifyVirtualKeyBoard(int32_t width,int32_t height,double keyboard,bool isCustomKeyboard)1052 bool NotifyVirtualKeyBoard(int32_t width, int32_t height, double keyboard, bool isCustomKeyboard) const 1053 { 1054 bool isConsume = false; 1055 for (const auto& [nodeId, iterVirtualKeyBoardCallback] : virtualKeyBoardCallback_) { 1056 if (iterVirtualKeyBoardCallback && iterVirtualKeyBoardCallback(width, height, keyboard, isCustomKeyboard)) { 1057 isConsume = true; 1058 } 1059 } 1060 return isConsume; 1061 } 1062 1063 using configChangedCallback = std::function<void()>; SetConfigChangedCallback(int32_t nodeId,configChangedCallback && listener)1064 void SetConfigChangedCallback(int32_t nodeId, configChangedCallback&& listener) 1065 { 1066 configChangedCallback_.emplace(make_pair(nodeId, std::move(listener))); 1067 } RemoveConfigChangedCallback(int32_t nodeId)1068 void RemoveConfigChangedCallback(int32_t nodeId) 1069 { 1070 configChangedCallback_.erase(nodeId); 1071 } 1072 NotifyConfigurationChange()1073 void NotifyConfigurationChange() 1074 { 1075 for (const auto& [nodeId, callback] : configChangedCallback_) { 1076 if (callback) { 1077 callback(); 1078 } 1079 } 1080 } 1081 NotifyColorModeChange(uint32_t colorMode)1082 virtual void NotifyColorModeChange(uint32_t colorMode) {} 1083 1084 using PostRTTaskCallback = std::function<void(std::function<void()>&&)>; SetPostRTTaskCallBack(PostRTTaskCallback && callback)1085 void SetPostRTTaskCallBack(PostRTTaskCallback&& callback) 1086 { 1087 postRTTaskCallback_ = std::move(callback); 1088 } 1089 PostTaskToRT(std::function<void ()> && task)1090 void PostTaskToRT(std::function<void()>&& task) 1091 { 1092 if (postRTTaskCallback_) { 1093 postRTTaskCallback_(std::move(task)); 1094 } 1095 } 1096 1097 void SetGetWindowRectImpl(std::function<Rect()>&& callback); 1098 1099 void InitGetGlobalWindowRectCallback(std::function<Rect()>&& callback); 1100 1101 Rect GetCurrentWindowRect() const; 1102 1103 Rect GetGlobalDisplayWindowRect() const; 1104 1105 using SafeAreaInsets = NG::SafeAreaInsets; 1106 1107 virtual void UpdateSystemSafeArea(const SafeAreaInsets& systemSafeArea, bool checkSceneBoardWindow = false) {} 1108 1109 virtual void UpdateCutoutSafeArea(const SafeAreaInsets& cutoutSafeArea, bool checkSceneBoardWindow = false) {} 1110 1111 virtual void UpdateNavSafeArea(const SafeAreaInsets& navSafeArea, bool checkSceneBoardWindow = false) {} 1112 1113 virtual void UpdateSystemSafeAreaWithoutAnimation(const SafeAreaInsets& systemSafeArea, 1114 bool checkSceneBoardWindow = false) {} 1115 1116 virtual void UpdateCutoutSafeAreaWithoutAnimation(const SafeAreaInsets& cutoutSafeArea, 1117 bool checkSceneBoardWindow = false) {} 1118 1119 virtual void UpdateNavSafeAreaWithoutAnimation(const SafeAreaInsets& navSafeArea, 1120 bool checkSceneBoardWindow = false) {} 1121 UpdateOriginAvoidArea(const Rosen::AvoidArea & avoidArea,uint32_t type)1122 virtual void UpdateOriginAvoidArea(const Rosen::AvoidArea& avoidArea, uint32_t type) {} 1123 SetEnableKeyBoardAvoidMode(KeyBoardAvoidMode value)1124 virtual void SetEnableKeyBoardAvoidMode(KeyBoardAvoidMode value) {} 1125 GetEnableKeyBoardAvoidMode()1126 virtual KeyBoardAvoidMode GetEnableKeyBoardAvoidMode() { 1127 return KeyBoardAvoidMode::OFFSET; 1128 } 1129 IsEnableKeyBoardAvoidMode()1130 virtual bool IsEnableKeyBoardAvoidMode() { 1131 return false; 1132 } 1133 SetPixelRoundMode(PixelRoundMode pixelRoundMode)1134 void SetPixelRoundMode(PixelRoundMode pixelRoundMode) 1135 { 1136 pixelRoundMode_ = pixelRoundMode; 1137 } 1138 GetPixelRoundMode()1139 PixelRoundMode GetPixelRoundMode() const 1140 { 1141 return pixelRoundMode_; 1142 } 1143 SetPluginOffset(const Offset & offset)1144 void SetPluginOffset(const Offset& offset) 1145 { 1146 pluginOffset_ = offset; 1147 } 1148 GetPluginOffset()1149 Offset GetPluginOffset() const 1150 { 1151 return pluginOffset_; 1152 } 1153 SetPluginEventOffset(const Offset & offset)1154 void SetPluginEventOffset(const Offset& offset) 1155 { 1156 pluginEventOffset_ = offset; 1157 } 1158 GetPluginEventOffset()1159 Offset GetPluginEventOffset() const 1160 { 1161 return pluginEventOffset_; 1162 } NotifyMemoryLevel(int32_t level)1163 virtual void NotifyMemoryLevel(int32_t level) {} 1164 SetDisplayWindowRectInfo(const Rect & displayWindowRectInfo)1165 virtual void SetDisplayWindowRectInfo(const Rect& displayWindowRectInfo) 1166 { 1167 displayWindowRectInfo_ = displayWindowRectInfo; 1168 } 1169 SetWindowSizeChangeReason(WindowSizeChangeReason reason)1170 virtual void SetWindowSizeChangeReason(WindowSizeChangeReason reason) {} 1171 1172 // This method can get the coordinates and size of the current window, 1173 // which can be added to the return value of the GetGlobalOffset method to get the window coordinates of the node. GetDisplayWindowRectInfo()1174 const Rect& GetDisplayWindowRectInfo() const 1175 { 1176 return displayWindowRectInfo_; 1177 } FlushModifier()1178 virtual void FlushModifier() {} 1179 virtual void FlushMessages(std::function<void()> callback = nullptr) = 0; SetGSVsyncCallback(std::function<void (void)> && callback)1180 void SetGSVsyncCallback(std::function<void(void)>&& callback) 1181 { 1182 gsVsyncCallback_ = std::move(callback); 1183 } 1184 1185 virtual void FlushUITasks(bool triggeredByImplicitAnimation = false) = 0; 1186 FlushAfterLayoutCallbackInImplicitAnimationTask()1187 virtual void FlushAfterLayoutCallbackInImplicitAnimationTask() {} 1188 1189 virtual void FlushPipelineImmediately() = 0; 1190 1191 virtual void FlushOnceVsyncTask() = 0; 1192 1193 // get animateTo closure option GetSyncAnimationOption()1194 AnimationOption GetSyncAnimationOption() 1195 { 1196 return animationOption_; 1197 } 1198 SetSyncAnimationOption(const AnimationOption & option)1199 void SetSyncAnimationOption(const AnimationOption& option) 1200 { 1201 animationOption_ = option; 1202 } 1203 SetKeyboardAnimationConfig(const KeyboardAnimationConfig & config)1204 void SetKeyboardAnimationConfig(const KeyboardAnimationConfig& config) 1205 { 1206 keyboardAnimationConfig_ = config; 1207 } 1208 GetKeyboardAnimationConfig()1209 KeyboardAnimationConfig GetKeyboardAnimationConfig() const 1210 { 1211 return keyboardAnimationConfig_; 1212 } 1213 SetNextFrameLayoutCallback(std::function<void ()> && callback)1214 void SetNextFrameLayoutCallback(std::function<void()>&& callback) 1215 { 1216 nextFrameLayoutCallback_ = std::move(callback); 1217 } 1218 SetForegroundCalled(bool isForegroundCalled)1219 void SetForegroundCalled(bool isForegroundCalled) 1220 { 1221 isForegroundCalled_ = isForegroundCalled; 1222 } 1223 SetIsSubPipeline(bool isSubPipeline)1224 void SetIsSubPipeline(bool isSubPipeline) 1225 { 1226 isSubPipeline_ = isSubPipeline; 1227 } 1228 IsSubPipeline()1229 bool IsSubPipeline() const 1230 { 1231 return isSubPipeline_; 1232 } 1233 SetParentPipeline(const WeakPtr<PipelineBase> & pipeline)1234 void SetParentPipeline(const WeakPtr<PipelineBase>& pipeline) 1235 { 1236 parentPipeline_ = pipeline; 1237 } 1238 1239 void SetSubWindowVsyncCallback(AceVsyncCallback&& callback, int32_t subWindowId); 1240 1241 void SetJsFormVsyncCallback(AceVsyncCallback&& callback, int32_t subWindowId); 1242 1243 void RemoveSubWindowVsyncCallback(int32_t subWindowId); 1244 1245 void RemoveJsFormVsyncCallback(int32_t subWindowId); 1246 SetIsLayoutFullScreen(bool isLayoutFullScreen)1247 virtual void SetIsLayoutFullScreen(bool isLayoutFullScreen) {} SetIsNeedAvoidWindow(bool isLayoutFullScreen)1248 virtual void SetIsNeedAvoidWindow(bool isLayoutFullScreen) {} SetIgnoreViewSafeArea(bool ignoreViewSafeArea)1249 virtual void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) {} OnFoldStatusChange(FoldStatus foldStatus)1250 virtual void OnFoldStatusChange(FoldStatus foldStatus) {} OnFoldDisplayModeChange(FoldDisplayMode foldDisplayMode)1251 virtual void OnFoldDisplayModeChange(FoldDisplayMode foldDisplayMode) {} OnRawKeyboardChangedCallback()1252 virtual void OnRawKeyboardChangedCallback() {} 1253 SetIsAppWindow(bool isAppWindow)1254 void SetIsAppWindow(bool isAppWindow) 1255 { 1256 isAppWindow_ = isAppWindow; 1257 } 1258 GetIsAppWindow()1259 bool GetIsAppWindow() const 1260 { 1261 return isAppWindow_; 1262 } 1263 SetFormAnimationStartTime(int64_t time)1264 void SetFormAnimationStartTime(int64_t time) 1265 { 1266 formAnimationStartTime_ = time; 1267 } 1268 GetFormAnimationStartTime()1269 int64_t GetFormAnimationStartTime() const 1270 { 1271 return formAnimationStartTime_; 1272 } 1273 SetIsFormAnimation(bool isFormAnimation)1274 void SetIsFormAnimation(bool isFormAnimation) 1275 { 1276 isFormAnimation_ = isFormAnimation; 1277 } 1278 IsFormAnimation()1279 bool IsFormAnimation() const 1280 { 1281 return isFormAnimation_; 1282 } 1283 SetFormAnimationFinishCallback(bool isFormAnimationFinishCallback)1284 void SetFormAnimationFinishCallback(bool isFormAnimationFinishCallback) 1285 { 1286 isFormAnimationFinishCallback_ = isFormAnimationFinishCallback; 1287 } 1288 IsFormAnimationFinishCallback()1289 bool IsFormAnimationFinishCallback() const 1290 { 1291 return isFormAnimationFinishCallback_; 1292 } 1293 1294 // restore RestoreNodeInfo(std::unique_ptr<JsonValue> nodeInfo)1295 virtual void RestoreNodeInfo(std::unique_ptr<JsonValue> nodeInfo) {} 1296 GetStoredNodeInfo()1297 virtual std::unique_ptr<JsonValue> GetStoredNodeInfo() 1298 { 1299 return nullptr; 1300 } 1301 GetLastTouchTime()1302 uint64_t GetLastTouchTime() const 1303 { 1304 return lastTouchTime_; 1305 } 1306 AddFormLinkInfo(int32_t id,const std::string & info)1307 void AddFormLinkInfo(int32_t id, const std::string& info) 1308 { 1309 LOGI("AddFormLinkInfo is %{public}s, id is %{public}d", info.c_str(), id); 1310 formLinkInfoMap_[id] = info; 1311 } 1312 IsLayouting()1313 virtual bool IsLayouting() const 1314 { 1315 return false; 1316 } 1317 SetHalfLeading(bool halfLeading)1318 void SetHalfLeading(bool halfLeading) 1319 { 1320 halfLeading_ = halfLeading; 1321 } 1322 GetHalfLeading()1323 bool GetHalfLeading() const 1324 { 1325 return halfLeading_; 1326 } 1327 SetHasPreviewTextOption(bool hasOption)1328 void SetHasPreviewTextOption(bool hasOption) 1329 { 1330 hasPreviewTextOption_ = hasOption; 1331 } 1332 GetHasPreviewTextOption()1333 bool GetHasPreviewTextOption() const 1334 { 1335 return hasPreviewTextOption_; 1336 } 1337 SetSupportPreviewText(bool changeSupported)1338 void SetSupportPreviewText(bool changeSupported) 1339 { 1340 hasSupportedPreviewText_ = !changeSupported; 1341 } 1342 GetSupportPreviewText()1343 bool GetSupportPreviewText() const 1344 { 1345 return hasSupportedPreviewText_; 1346 } 1347 GetOnFocus()1348 bool GetOnFocus() const 1349 { 1350 return onFocus_; 1351 } 1352 GetOnActive()1353 bool GetOnActive() const 1354 { 1355 return onActive_; 1356 } 1357 GetVsyncTime()1358 uint64_t GetVsyncTime() const 1359 { 1360 return vsyncTime_; 1361 } 1362 SetVsyncTime(uint64_t time)1363 void SetVsyncTime(uint64_t time) 1364 { 1365 vsyncTime_ = time; 1366 } 1367 1368 virtual bool ReachResponseDeadline() const; 1369 UpdateCurrentActiveNode(const WeakPtr<NG::FrameNode> & node)1370 virtual void UpdateCurrentActiveNode(const WeakPtr<NG::FrameNode>& node) {} 1371 GetCurrentExtraInfo()1372 virtual std::string GetCurrentExtraInfo() { return ""; } 1373 virtual void UpdateTitleInTargetPos(bool isShow = true, int32_t height = 0) {} 1374 SetCursor(int32_t cursorValue)1375 virtual void SetCursor(int32_t cursorValue) {} 1376 RestoreDefault(int32_t windowId,MouseStyleChangeReason reason)1377 virtual void RestoreDefault(int32_t windowId, MouseStyleChangeReason reason) {} 1378 SetOnFormRecycleCallback(std::function<std::string ()> && onFormRecycle)1379 void SetOnFormRecycleCallback(std::function<std::string()>&& onFormRecycle) 1380 { 1381 onFormRecycle_ = std::move(onFormRecycle); 1382 } 1383 1384 std::string OnFormRecycle(); 1385 SetOnFormRecoverCallback(std::function<void (std::string)> && onFormRecover)1386 void SetOnFormRecoverCallback(std::function<void(std::string)>&& onFormRecover) 1387 { 1388 onFormRecover_ = std::move(onFormRecover); 1389 } 1390 1391 void OnFormRecover(const std::string& statusData); 1392 IsDragging()1393 virtual bool IsDragging() const 1394 { 1395 return false; 1396 } 1397 SetIsDragging(bool isDragging)1398 virtual void SetIsDragging(bool isDragging) {} 1399 ResetDragging()1400 virtual void ResetDragging() {} 1401 GetSerializedGesture()1402 virtual const SerializedGesture& GetSerializedGesture() const 1403 { 1404 return serializedGesture_; 1405 } 1406 PrintVsyncInfoIfNeed()1407 virtual bool PrintVsyncInfoIfNeed() const 1408 { 1409 return false; 1410 } 1411 StartWindowAnimation()1412 virtual void StartWindowAnimation() {} 1413 StopWindowAnimation()1414 virtual void StopWindowAnimation() {} 1415 AddSyncGeometryNodeTask(std::function<void ()> && task)1416 virtual void AddSyncGeometryNodeTask(std::function<void()>&& task) {} 1417 FlushSyncGeometryNodeTasks()1418 virtual void FlushSyncGeometryNodeTasks() {} 1419 ChangeSensitiveNodes(bool flag)1420 virtual void ChangeSensitiveNodes(bool flag) {} 1421 IsContainerModalVisible()1422 virtual bool IsContainerModalVisible() const 1423 { 1424 return false; 1425 } 1426 GetFrameCount()1427 uint32_t GetFrameCount() const 1428 { 1429 return frameCount_; 1430 } 1431 CheckAndLogLastReceivedTouchEventInfo(int32_t eventId,TouchType type)1432 virtual void CheckAndLogLastReceivedTouchEventInfo(int32_t eventId, TouchType type) {} 1433 CheckAndLogLastConsumedTouchEventInfo(int32_t eventId,TouchType type)1434 virtual void CheckAndLogLastConsumedTouchEventInfo(int32_t eventId, TouchType type) {} 1435 CheckAndLogLastReceivedMouseEventInfo(int32_t eventId,MouseAction action)1436 virtual void CheckAndLogLastReceivedMouseEventInfo(int32_t eventId, MouseAction action) {} 1437 CheckAndLogLastConsumedMouseEventInfo(int32_t eventId,MouseAction action)1438 virtual void CheckAndLogLastConsumedMouseEventInfo(int32_t eventId, MouseAction action) {} 1439 CheckAndLogLastReceivedAxisEventInfo(int32_t eventId,AxisAction action)1440 virtual void CheckAndLogLastReceivedAxisEventInfo(int32_t eventId, AxisAction action) {} 1441 CheckAndLogLastConsumedAxisEventInfo(int32_t eventId,AxisAction action)1442 virtual void CheckAndLogLastConsumedAxisEventInfo(int32_t eventId, AxisAction action) {} 1443 GetPageAvoidOffset()1444 virtual float GetPageAvoidOffset() 1445 { 1446 return 0.0f; 1447 } 1448 CheckNeedAvoidInSubWindow()1449 virtual bool CheckNeedAvoidInSubWindow() 1450 { 1451 return false; 1452 } 1453 1454 virtual bool IsDensityChanged() const = 0; 1455 1456 virtual bool IsNeedReloadDensity() const = 0; 1457 1458 virtual void SetIsNeedReloadDensity(bool isNeedReloadDensity) = 0; 1459 GetResponseRegion(const RefPtr<NG::FrameNode> & rootNode)1460 virtual std::string GetResponseRegion(const RefPtr<NG::FrameNode>& rootNode) 1461 { 1462 return ""; 1463 }; 1464 NotifyResponseRegionChanged(const RefPtr<NG::FrameNode> & rootNode)1465 virtual void NotifyResponseRegionChanged(const RefPtr<NG::FrameNode>& rootNode) {}; 1466 DisableNotifyResponseRegionChanged()1467 virtual void DisableNotifyResponseRegionChanged() {}; 1468 SetTHPExtraManager(const RefPtr<NG::THPExtraManager> & thpExtraMgr)1469 void SetTHPExtraManager(const RefPtr<NG::THPExtraManager>& thpExtraMgr) 1470 { 1471 thpExtraMgr_ = thpExtraMgr; 1472 } 1473 GetTHPExtraManager()1474 const RefPtr<NG::THPExtraManager>& GetTHPExtraManager() const 1475 { 1476 return thpExtraMgr_; 1477 } 1478 1479 void SetUiDvsyncSwitch(bool on); 1480 virtual bool GetOnShow() const = 0; 1481 bool IsDestroyed(); 1482 1483 void SetDestroyed(); 1484 1485 #if defined(SUPPORT_TOUCH_TARGET_TEST) 1486 // Called by hittest to find touch node is equal target. 1487 virtual bool OnTouchTargetHitTest(const TouchEvent& point, bool isSubPipe = false, 1488 const std::string& target = "") = 0; 1489 #endif IsWindowFocused()1490 virtual bool IsWindowFocused() const 1491 { 1492 return GetOnFocus(); 1493 } 1494 IsWindowActivated()1495 virtual bool IsWindowActivated() const 1496 { 1497 return GetOnActive(); 1498 } 1499 SetDragNodeGrayscale(float dragNodeGrayscale)1500 void SetDragNodeGrayscale(float dragNodeGrayscale) 1501 { 1502 dragNodeGrayscale_ = dragNodeGrayscale; 1503 } 1504 GetDragNodeGrayscale()1505 float GetDragNodeGrayscale() const 1506 { 1507 return dragNodeGrayscale_; 1508 } 1509 IsDirtyNodesEmpty()1510 virtual bool IsDirtyNodesEmpty() const 1511 { 1512 return true; 1513 } 1514 IsDirtyLayoutNodesEmpty()1515 virtual bool IsDirtyLayoutNodesEmpty() const 1516 { 1517 return true; 1518 } 1519 IsDirtyPropertyNodesEmpty()1520 virtual bool IsDirtyPropertyNodesEmpty() const 1521 { 1522 return true; 1523 } 1524 SetFlushTSUpdates(std::function<bool (int32_t)> && flushTSUpdates)1525 virtual void SetFlushTSUpdates(std::function<bool(int32_t)>&& flushTSUpdates) 1526 { 1527 /* only implemented in PipelineContext for NG */ 1528 } 1529 1530 void SetUIExtensionEventCallback(std::function<void(uint32_t)>&& callback); 1531 void AddUIExtensionCallbackEvent(NG::UIExtCallbackEventId eventId); 1532 void FireAllUIExtensionEvents(); 1533 void FireUIExtensionEventOnceImmediately(NG::UIExtCallbackEventId eventId); 1534 void FireUIExtensionEventInner(uint32_t eventId); 1535 SetOpenInvisibleFreeze(bool isOpenInvisibleFreeze)1536 void SetOpenInvisibleFreeze(bool isOpenInvisibleFreeze) 1537 { 1538 isOpenInvisibleFreeze_ = isOpenInvisibleFreeze; 1539 } 1540 IsOpenInvisibleFreeze()1541 bool IsOpenInvisibleFreeze() const 1542 { 1543 return isOpenInvisibleFreeze_; 1544 } 1545 1546 // Prints out the count of the unexecuted finish callback 1547 std::string GetUnexecutedFinishCount() const; 1548 1549 void SetAccessibilityEventCallback(std::function<void(uint32_t, int64_t)>&& callback); 1550 1551 void AddAccessibilityCallbackEvent(AccessibilityCallbackEventId event, int64_t parameter); 1552 1553 void FireAccessibilityEvents(); 1554 void FireAccessibilityEventInner(uint32_t event, int64_t parameter); 1555 SetTouchAccelarate(bool isEnable)1556 virtual void SetTouchAccelarate(bool isEnable) {} SetTouchPassThrough(bool isEnable)1557 virtual void SetTouchPassThrough(bool isEnable) {} SetEnableSwipeBack(bool isEnable)1558 virtual void SetEnableSwipeBack(bool isEnable) {} SetBackgroundColorModeUpdated(bool backgroundColorModeUpdated)1559 virtual void SetBackgroundColorModeUpdated(bool backgroundColorModeUpdated) {} 1560 IsSystmColorChange()1561 bool IsSystmColorChange() 1562 { 1563 return isSystemColorChange_; 1564 } 1565 SetIsSystemColorChange(bool isSystemColorChange)1566 void SetIsSystemColorChange(bool isSystemColorChange) 1567 { 1568 isSystemColorChange_ = isSystemColorChange; 1569 } 1570 1571 std::shared_ptr<ArkUIPerfMonitor> GetPerfMonitor(); 1572 1573 /** 1574 * @description: Set the target api version of the application. 1575 * @param: The target api version of the application. 1576 */ SetApiTargetVersion(int32_t apiTargetVersion)1577 void SetApiTargetVersion(int32_t apiTargetVersion) 1578 { 1579 apiTargetVersion_ = apiTargetVersion; 1580 } 1581 1582 /** 1583 * @description: Get the target api version of the application. 1584 * @return: The target api version of the application. 1585 */ GetApiTargetVersion()1586 int32_t GetApiTargetVersion() const 1587 { 1588 return apiTargetVersion_; 1589 } 1590 1591 /** 1592 * @description: Compare whether the target api version of the application is greater than or equal to the incoming 1593 * target. If it is possible to obtain the pipeline without using GetCurrentContext, GetCurrentContextSafely, and 1594 * GetCurrentContextSafelyWithCheck, the performance will be better than Container::GreatOrEqualApiTargetVersion. 1595 * @param: Target version to be isolated. 1596 * @return: return the compare result. 1597 */ GreatOrEqualAPITargetVersion(PlatformVersion version)1598 bool GreatOrEqualAPITargetVersion(PlatformVersion version) const 1599 { 1600 return apiTargetVersion_ >= static_cast<int32_t>(version); 1601 } 1602 1603 /** 1604 * @description: Compare whether the target api version of the application is less than the incoming target 1605 * version. If it is possible to obtain the pipeline without using GetCurrentContext, GetCurrentContextSafely, and 1606 * GetCurrentContextSafelyWithCheck, the performance will be better than Container::LessThanAPITargetVersion. 1607 * @param: Target version to be isolated. 1608 * @return: return the compare result. 1609 */ LessThanAPITargetVersion(PlatformVersion version)1610 bool LessThanAPITargetVersion(PlatformVersion version) const 1611 { 1612 return apiTargetVersion_ < static_cast<int32_t>(version); 1613 } 1614 SaveConfigurationConfig(const ConfigurationChange & configurationChange)1615 void SaveConfigurationConfig(const ConfigurationChange& configurationChange) 1616 { 1617 configurationChange_ = configurationChange; 1618 } 1619 GetConfigurationChange()1620 const ConfigurationChange& GetConfigurationChange() const 1621 { 1622 return configurationChange_; 1623 } 1624 1625 void SetUiDVSyncCommandTime(uint64_t vsyncTime); 1626 void ForceUpdateDesignWidthScale(int32_t width); 1627 protected: 1628 virtual bool MaybeRelease() override; TryCallNextFrameLayoutCallback()1629 void TryCallNextFrameLayoutCallback() 1630 { 1631 if (isForegroundCalled_ && nextFrameLayoutCallback_) { 1632 isForegroundCalled_ = false; 1633 nextFrameLayoutCallback_(); 1634 LOGI("nextFrameLayoutCallback called"); 1635 } 1636 } 1637 OnDumpInfo(const std::vector<std::string> & params)1638 virtual bool OnDumpInfo(const std::vector<std::string>& params) const 1639 { 1640 return false; 1641 } 1642 virtual void FlushVsync(uint64_t nanoTimestamp, uint64_t frameCount) = 0; 1643 virtual void SetRootRect(double width, double height, double offset = 0.0) = 0; 1644 virtual void FlushPipelineWithoutAnimation() = 0; 1645 1646 virtual void OnVirtualKeyboardHeightChange(float keyboardHeight, 1647 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, const float safeHeight = 0.0f, 1648 const bool supportAvoidance = false, bool forceChange = false) 1649 {} 1650 virtual void OnVirtualKeyboardHeightChange(float keyboardHeight, double positionY, double height, 1651 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr, bool forceChange = false) 1652 {} 1653 1654 void UpdateRootSizeAndScale(int32_t width, int32_t height); 1655 SetIsReloading(bool isReloading)1656 void SetIsReloading(bool isReloading) 1657 { 1658 isReloading_ = isReloading; 1659 } 1660 bool FireUIExtensionEventValid(); 1661 1662 std::function<void()> GetWrappedAnimationCallback(const AnimationOption& option, 1663 const std::function<void()>& finishCallback, const std::optional<int32_t>& count = std::nullopt); 1664 1665 bool MarkUpdateSubwindowKeyboardInsert(int32_t instanceId, double keyboardHeight, int32_t type); 1666 1667 double Vp2PxInner(double vpValue) const; 1668 1669 std::map<int32_t, configChangedCallback> configChangedCallback_; 1670 std::map<int32_t, virtualKeyBoardCallback> virtualKeyBoardCallback_; 1671 std::list<foldStatusChangedCallback> foldStatusChangedCallback_; 1672 1673 bool isRebuildFinished_ = false; 1674 bool isJsCard_ = false; 1675 bool isFormRender_ = false; 1676 bool isDynamicRender_ = false; 1677 bool isRightToLeft_ = false; 1678 bool isFullWindow_ = false; 1679 bool isAppWindow_ = true; 1680 bool installationFree_ = false; 1681 bool isSubPipeline_ = false; 1682 bool isReloading_ = false; 1683 1684 bool isSystemColorChange_ = false; 1685 1686 bool isJsPlugin_ = false; 1687 bool isOpenInvisibleFreeze_ = false; 1688 PixelRoundMode pixelRoundMode_ = PixelRoundMode::PIXEL_ROUND_ON_LAYOUT_FINISH; 1689 1690 std::unordered_map<int32_t, AceVsyncCallback> subWindowVsyncCallbacks_; 1691 std::unordered_map<int32_t, AceVsyncCallback> jsFormVsyncCallbacks_; 1692 int32_t minPlatformVersion_ = 0; 1693 uint32_t windowId_ = 0; 1694 // UIExtensionAbility need component windowID 1695 std::optional<uint32_t> focusWindowId_; 1696 std::optional<uint32_t> realHostWindowId_; 1697 1698 int32_t appLabelId_ = 0; 1699 float fontScale_ = 1.0f; 1700 float fontWeightScale_ = 1.0f; 1701 float designWidthScale_ = 1.0f; 1702 float viewScale_ = 1.0f; 1703 double density_ = 1.0; 1704 double dipScale_ = 1.0; 1705 bool isCurrentInForceSplitMode_ = false; 1706 double rootHeight_ = 0.0; 1707 double rootWidth_ = 0.0; 1708 int32_t width_ = 0; 1709 int32_t height_ = 0; 1710 bool isArkUIHookEnabled_ = false; 1711 FrontendType frontendType_; 1712 WindowModal windowModal_ = WindowModal::NORMAL; 1713 1714 Offset pluginOffset_ { 0, 0 }; 1715 Offset pluginEventOffset_ { 0, 0 }; 1716 Color appBgColor_ = Color::WHITE; 1717 int8_t renderingMode_ = 0; 1718 bool enableBlurBackground_ = false; 1719 1720 std::unique_ptr<DrawDelegate> drawDelegate_; 1721 std::stack<bool> pendingImplicitLayout_; 1722 std::stack<bool> pendingImplicitRender_; 1723 std::stack<bool> pendingFrontendAnimation_; 1724 std::shared_ptr<Window> window_; 1725 RefPtr<TaskExecutor> taskExecutor_; 1726 RefPtr<AssetManager> assetManager_; 1727 WeakPtr<Frontend> weakFrontend_; 1728 int32_t instanceId_ = 0; 1729 RefPtr<EventManager> eventManager_; 1730 RefPtr<ImageCache> imageCache_; 1731 RefPtr<SharedImageManager> sharedImageManager_; 1732 mutable std::shared_mutex imageMtx_; 1733 mutable std::shared_mutex themeMtx_; 1734 mutable std::mutex destructMutex_; 1735 RefPtr<ThemeManager> themeManager_; 1736 RefPtr<DataProviderManagerInterface> dataProviderManager_; 1737 RefPtr<FontManager> fontManager_; 1738 RefPtr<ManagerInterface> textFieldManager_; 1739 RefPtr<PlatformBridge> messageBridge_; 1740 RefPtr<WindowManager> windowManager_; 1741 OnPageShowCallBack onPageShowCallBack_; 1742 AnimationCallback animationCallback_; 1743 ProfilerCallback onVsyncProfiler_; 1744 FinishEventHandler finishEventHandler_; 1745 StartAbilityHandler startAbilityHandler_; 1746 StartAbilityOnQueryHandler startAbilityOnQueryHandler_; 1747 ActionEventHandler actionEventHandler_; 1748 FormLinkInfoUpdateHandler formLinkInfoUpdateHandler_; 1749 RefPtr<PlatformResRegister> platformResRegister_; 1750 1751 WeakPtr<PipelineBase> parentPipeline_; 1752 1753 std::vector<WeakPtr<PipelineBase>> touchPluginPipelineContext_; 1754 RefPtr<Clipboard> clipboard_; 1755 std::function<void(const std::string&)> clipboardCallback_ = nullptr; 1756 Rect displayWindowRectInfo_; 1757 AnimationOption animationOption_; 1758 KeyboardAnimationConfig keyboardAnimationConfig_; 1759 1760 std::function<void()> nextFrameLayoutCallback_ = nullptr; 1761 SharePanelCallback sharePanelCallback_ = nullptr; 1762 std::atomic<bool> isForegroundCalled_ = false; 1763 std::atomic<bool> onFocus_ = false; 1764 std::atomic<bool> onActive_ = false; 1765 uint64_t lastTouchTime_ = 0; 1766 uint64_t lastMouseTime_ = 0; 1767 uint64_t lastDragTime_ = 0; 1768 std::map<int32_t, std::string> formLinkInfoMap_; 1769 struct FunctionHash { operatorFunctionHash1770 std::size_t operator()(const std::shared_ptr<std::function<void()>>& functionPtr) const 1771 { 1772 return std::hash<std::function<void()>*>()(functionPtr.get()); 1773 } 1774 }; 1775 std::function<std::string()> onFormRecycle_; 1776 std::function<void(std::string)> onFormRecover_; 1777 1778 uint64_t compensationValue_ = 0; 1779 int64_t recvTime_ = 0; 1780 int64_t currRecvTime_ = -1; 1781 std::once_flag displaySyncFlag_; 1782 RefPtr<UIDisplaySyncManager> uiDisplaySyncManager_; 1783 1784 SerializedGesture serializedGesture_; 1785 RefPtr<NG::THPExtraManager> thpExtraMgr_; 1786 uint64_t DVSyncChangeTime_ = 0; 1787 bool commandTimeUpdate_ = false; 1788 bool dvsyncTimeUpdate_ = false; 1789 int32_t dvsyncTimeUseCount_ = 0; 1790 private: 1791 void DumpFrontend() const; 1792 double ModifyKeyboardHeight(double keyboardHeight) const; 1793 StatusBarEventHandler statusBarBgColorEventHandler_; 1794 PopupEventHandler popupEventHandler_; 1795 MenuEventHandler menuEventHandler_; 1796 ContextMenuEventHandler contextMenuEventHandler_; 1797 RouterBackEventHandler routerBackEventHandler_; 1798 std::list<PopPageSuccessEventHandler> popPageSuccessEventHandler_; 1799 std::list<IsPagePathInvalidEventHandler> isPagePathInvalidEventHandler_; 1800 std::list<DestroyEventHandler> destroyEventHandler_; 1801 std::list<DispatchTouchEventHandler> dispatchTouchEventHandler_; 1802 GetViewScaleCallback getViewScaleCallback_; 1803 // OnRouterChangeCallback is function point, need to be initialized. 1804 OnRouterChangeCallback onRouterChangeCallback_ = nullptr; 1805 PostRTTaskCallback postRTTaskCallback_; 1806 std::function<void(void)> gsVsyncCallback_; 1807 std::unordered_set<std::shared_ptr<std::function<void()>>, FunctionHash> finishFunctions_; 1808 std::unordered_set<int32_t> finishCount_; 1809 bool isFormAnimationFinishCallback_ = false; 1810 int64_t formAnimationStartTime_ = 0; 1811 bool isFormAnimation_ = false; 1812 bool halfLeading_ = false; 1813 bool hasSupportedPreviewText_ = true; 1814 bool hasPreviewTextOption_ = false; 1815 // whether visible area need to be calculate at each vsync after approximate timeout. 1816 uint64_t vsyncTime_ = 0; 1817 1818 bool destroyed_ = false; 1819 uint32_t frameCount_ = 0; 1820 bool followSystem_ = false; 1821 float maxAppFontScale_ = static_cast<float>(INT32_MAX); 1822 float dragNodeGrayscale_ = 0.0f; 1823 int32_t apiTargetVersion_ = 0; 1824 bool lastUiDvsyncStatus_ = false; 1825 1826 // To avoid the race condition caused by the offscreen canvas get density from the pipeline in the worker thread. 1827 std::mutex densityChangeMutex_; 1828 int32_t densityChangeCallbackId_ = 0; 1829 std::unordered_map<int32_t, std::function<void(double)>> densityChangedCallbacks_; 1830 std::function<double()> windowDensityCallback_; 1831 std::function<void(uint32_t)> uiExtensionEventCallback_; 1832 std::set<NG::UIExtCallbackEvent> uiExtensionEvents_; 1833 std::function<void(uint32_t, int64_t)> accessibilityCallback_; 1834 std::set<AccessibilityCallbackEvent> accessibilityEvents_; 1835 std::shared_ptr<ArkUIPerfMonitor> perfMonitor_; 1836 ConfigurationChange configurationChange_; 1837 1838 ACE_DISALLOW_COPY_AND_MOVE(PipelineBase); 1839 }; 1840 1841 } // namespace OHOS::Ace 1842 1843 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_PIPELINE_PIPELINE_BASE_H 1844