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/resource/asset_manager.h" 31 #include "base/resource/data_provider_manager.h" 32 #include "base/resource/shared_image_manager.h" 33 #include "base/thread/task_executor.h" 34 #include "core/accessibility/accessibility_manager.h" 35 #include "core/animation/schedule_task.h" 36 #include "core/common/clipboard/clipboard_proxy.h" 37 #include "core/common/display_info.h" 38 #include "core/common/draw_delegate.h" 39 #include "core/common/event_manager.h" 40 #include "core/common/platform_bridge.h" 41 #include "core/common/platform_res_register.h" 42 #include "core/common/resource/resource_configuration.h" 43 #include "core/common/thread_checker.h" 44 #include "core/common/window_animation_config.h" 45 #include "core/components/common/layout/constants.h" 46 #include "core/components/common/properties/animation_option.h" 47 #include "core/components/theme/theme_manager.h" 48 #include "core/components_ng/property/safe_area_insets.h" 49 #include "core/event/axis_event.h" 50 #include "core/event/key_event.h" 51 #include "core/event/mouse_event.h" 52 #include "core/event/rotation_event.h" 53 #include "core/event/touch_event.h" 54 #include "core/event/pointer_event.h" 55 #include "core/gestures/gesture_info.h" 56 #include "core/image/image_cache.h" 57 #include "core/pipeline/container_window_manager.h" 58 #include "core/components_ng/manager/display_sync/ui_display_sync_manager.h" 59 #include "interfaces/inner_api/ace/serialized_gesture.h" 60 61 namespace OHOS::Rosen { 62 class RSTransaction; 63 class AvoidArea; 64 } // namespace OHOS::Rosen 65 66 namespace OHOS::Ace { 67 namespace NG { 68 class FrameNode; 69 } // namespace NG 70 71 struct KeyboardAnimationConfig { 72 std::string curveType_; 73 std::vector<float> curveParams_; 74 uint32_t durationIn_ = 0; 75 uint32_t durationOut_ = 0; 76 }; 77 78 struct FontInfo; 79 struct FontConfigJsonInfo; 80 class Frontend; 81 class OffscreenCanvas; 82 class Window; 83 class FontManager; 84 class ManagerInterface; 85 class NavigationController; 86 enum class FrontendType; 87 using SharePanelCallback = std::function<void(const std::string& bundleName, const std::string& abilityName)>; 88 using AceVsyncCallback = std::function<void(uint64_t, uint32_t)>; 89 using EtsCardTouchEventCallback = std::function<void(const TouchEvent&, 90 SerializedGesture& serializedGesture)>; 91 92 class ACE_FORCE_EXPORT PipelineBase : public AceType { 93 DECLARE_ACE_TYPE(PipelineBase, AceType); 94 95 public: 96 PipelineBase() = default; 97 PipelineBase(std::shared_ptr<Window> window, RefPtr<TaskExecutor> taskExecutor, RefPtr<AssetManager> assetManager, 98 const RefPtr<Frontend>& frontend, int32_t instanceId); 99 PipelineBase(std::shared_ptr<Window> window, RefPtr<TaskExecutor> taskExecutor, RefPtr<AssetManager> assetManager, 100 const RefPtr<Frontend>& frontend, int32_t instanceId, RefPtr<PlatformResRegister> platformResRegister); 101 ~PipelineBase() override; 102 103 static RefPtr<PipelineBase> GetCurrentContext(); 104 105 static RefPtr<PipelineBase> GetCurrentContextSafely(); 106 107 static RefPtr<PipelineBase> GetMainPipelineContext(); 108 109 static RefPtr<ThemeManager> CurrentThemeManager(); 110 111 static void SetCallBackNode(const WeakPtr<NG::FrameNode>& node); 112 113 /* 114 * Change px to vp with density of current pipeline 115 */ 116 static double Px2VpWithCurrentDensity(double px); 117 118 /* 119 * Change vp to px with density of current pipeline 120 */ 121 static double Vp2PxWithCurrentDensity(double vp); 122 123 /* 124 * Get density of current pipeline if valid, or return density of default display 125 */ 126 static double GetCurrentDensity(); 127 128 virtual void SetupRootElement() = 0; 129 130 virtual uint64_t GetTimeFromExternalTimer(); 131 132 virtual bool NeedSoftKeyboard() = 0; 133 134 virtual void SetOnWindowFocused(const std::function<void()>& callback) = 0; 135 136 bool Animate(const AnimationOption& option, const RefPtr<Curve>& curve, 137 const std::function<void()>& propertyCallback, const std::function<void()>& finishCallBack = nullptr); 138 139 virtual void AddKeyFrame( 140 float fraction, const RefPtr<Curve>& curve, const std::function<void()>& propertyCallback) = 0; 141 142 virtual void AddKeyFrame(float fraction, const std::function<void()>& propertyCallback) = 0; 143 144 void PrepareOpenImplicitAnimation(); 145 146 void OpenImplicitAnimation(const AnimationOption& option, const RefPtr<Curve>& curve, 147 const std::function<void()>& finishCallback = nullptr); 148 149 void PrepareCloseImplicitAnimation(); 150 151 bool CloseImplicitAnimation(); 152 153 void ForceLayoutForImplicitAnimation(); 154 155 void ForceRenderForImplicitAnimation(); 156 157 // add schedule task and return the unique mark id. 158 virtual uint32_t AddScheduleTask(const RefPtr<ScheduleTask>& task) = 0; 159 160 // remove schedule task by id. 161 virtual void RemoveScheduleTask(uint32_t id) = 0; 162 163 // Called by view when touch event received. 164 virtual void OnTouchEvent(const TouchEvent& point, bool isSubPipe = false) = 0; 165 166 // Called by ohos AceContainer when touch event received. 167 virtual void OnTouchEvent(const TouchEvent& point, const RefPtr<NG::FrameNode>& node, bool isSubPipe = false) {} 168 169 // Called by container when key event received. 170 // if return false, then this event needs platform to handle it. 171 virtual bool OnKeyEvent(const KeyEvent& event) = 0; 172 173 // Called by view when mouse event received. 174 virtual void OnMouseEvent(const MouseEvent& event) = 0; 175 176 // Called by ohos AceContainer when mouse event received. OnMouseEvent(const MouseEvent & event,const RefPtr<NG::FrameNode> & node)177 virtual void OnMouseEvent(const MouseEvent& event, const RefPtr<NG::FrameNode>& node) {} 178 179 // Called by view when axis event received. 180 virtual void OnAxisEvent(const AxisEvent& event) = 0; 181 182 // Called by ohos AceContainer when axis event received. OnAxisEvent(const AxisEvent & event,const RefPtr<NG::FrameNode> & node)183 virtual void OnAxisEvent(const AxisEvent& event, const RefPtr<NG::FrameNode>& node) {} 184 185 // Called by container when rotation event received. 186 // if return false, then this event needs platform to handle it. 187 virtual bool OnRotationEvent(const RotationEvent& event) const = 0; 188 189 // Called by window when received vsync signal. 190 virtual void OnVsyncEvent(uint64_t nanoTimestamp, uint32_t frameCount); 191 192 // Called by view 193 virtual void OnDragEvent(const PointerEvent& pointerEvent, DragEventAction action) = 0; 194 195 // Called by view when idle event. 196 virtual void OnIdle(int64_t deadline) = 0; 197 198 virtual void SetBuildAfterCallback(const std::function<void()>& callback) = 0; 199 200 virtual void DispatchDisplaySync(uint64_t nanoTimestamp) = 0; 201 202 virtual void FlushAnimation(uint64_t nanoTimestamp) = 0; 203 204 virtual void SendEventToAccessibility(const AccessibilityEvent& accessibilityEvent); 205 206 virtual void SaveExplicitAnimationOption(const AnimationOption& option) = 0; 207 208 virtual void CreateExplicitAnimator(const std::function<void()>& onFinishEvent) = 0; 209 210 virtual void ClearExplicitAnimationOption() = 0; 211 212 virtual AnimationOption GetExplicitAnimationOption() const = 0; 213 214 virtual void Destroy(); 215 216 virtual void OnShow() = 0; 217 218 virtual void OnHide() = 0; 219 220 virtual void WindowFocus(bool isFocus) = 0; 221 222 virtual void ContainerModalUnFocus() = 0; 223 224 virtual void ShowContainerTitle(bool isShow, bool hasDeco = true, bool needUpdate = false) = 0; 225 226 virtual void OnSurfaceChanged(int32_t width, int32_t height, 227 WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED, 228 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr) = 0; 229 230 virtual void OnSurfacePositionChanged(int32_t posX, int32_t posY) = 0; 231 232 virtual void OnSurfaceDensityChanged(double density) = 0; 233 234 virtual void OnSystemBarHeightChanged(double statusBar, double navigationBar) = 0; 235 236 virtual void OnSurfaceDestroyed() = 0; 237 238 virtual void NotifyOnPreDraw() = 0; 239 240 virtual bool CallRouterBackToPopPage() = 0; 241 PopPageStackOverlay()242 virtual bool PopPageStackOverlay() 243 { 244 return false; 245 } 246 HideOverlays()247 virtual void HideOverlays() {} 248 OnPageShow()249 virtual void OnPageShow() {} 250 251 virtual void OnActionEvent(const std::string& action); 252 253 virtual void Finish(bool autoFinish = true) const {} 254 RequestFullWindow(int32_t duration)255 virtual void RequestFullWindow(int32_t duration) {} 256 RequestFocus(const std::string & targetNodeId)257 virtual bool RequestFocus(const std::string& targetNodeId) 258 { 259 return false; 260 } 261 262 // Called by AceContainer. 263 bool Dump(const std::vector<std::string>& params) const; 264 IsLastPage()265 virtual bool IsLastPage() 266 { 267 return false; 268 } 269 GetIsDeclarative()270 virtual bool GetIsDeclarative() const 271 { 272 return true; 273 } 274 SetAppBgColor(const Color & color)275 virtual void SetAppBgColor(const Color& color) 276 { 277 appBgColor_ = color; 278 } 279 GetAppBgColor()280 const Color& GetAppBgColor() const 281 { 282 return appBgColor_; 283 } 284 GetAppLabelId()285 int32_t GetAppLabelId() const 286 { 287 return appLabelId_; 288 } 289 SetAppLabelId(int32_t appLabelId)290 void SetAppLabelId(int32_t appLabelId) 291 { 292 appLabelId_ = appLabelId; 293 } 294 295 virtual void SetAppTitle(const std::string& title) = 0; 296 297 virtual void SetAppIcon(const RefPtr<PixelMap>& icon) = 0; 298 SetContainerButtonHide(bool hideSplit,bool hideMaximize,bool hideMinimize)299 virtual void SetContainerButtonHide(bool hideSplit, bool hideMaximize, bool hideMinimize) {} 300 RefreshRootBgColor()301 virtual void RefreshRootBgColor() const {} 302 PostponePageTransition()303 virtual void PostponePageTransition() {} LaunchPageTransition()304 virtual void LaunchPageTransition() {} 305 GetBoundingRectData(int32_t nodeId,Rect & rect)306 virtual void GetBoundingRectData(int32_t nodeId, Rect& rect) {} 307 308 virtual RefPtr<AccessibilityManager> GetAccessibilityManager() const; 309 GetNavigationController(const std::string & id)310 virtual std::shared_ptr<NavigationController> GetNavigationController(const std::string& id) 311 { 312 return nullptr; 313 } 314 315 void SetRootSize(double density, float width, float height); 316 317 void UpdateFontWeightScale(); 318 319 double NormalizeToPx(const Dimension& dimension) const; 320 321 double ConvertPxToVp(const Dimension& dimension) const; 322 323 using FinishEventHandler = std::function<void()>; SetFinishEventHandler(FinishEventHandler && listener)324 void SetFinishEventHandler(FinishEventHandler&& listener) 325 { 326 finishEventHandler_ = std::move(listener); 327 } 328 329 using StartAbilityHandler = std::function<void(const std::string& address)>; SetStartAbilityHandler(StartAbilityHandler && listener)330 void SetStartAbilityHandler(StartAbilityHandler&& listener) 331 { 332 startAbilityHandler_ = std::move(listener); 333 } 334 void HyperlinkStartAbility(const std::string& address) const; 335 336 using ActionEventHandler = std::function<void(const std::string& action)>; SetActionEventHandler(ActionEventHandler && listener)337 void SetActionEventHandler(ActionEventHandler&& listener) 338 { 339 actionEventHandler_ = std::move(listener); 340 } 341 342 using FormLinkInfoUpdateHandler = std::function<void(const std::vector<std::string>&)>; SetFormLinkInfoUpdateHandler(FormLinkInfoUpdateHandler && listener)343 void SetFormLinkInfoUpdateHandler(FormLinkInfoUpdateHandler&& listener) 344 { 345 formLinkInfoUpdateHandler_ = std::move(listener); 346 } 347 348 using StatusBarEventHandler = std::function<void(const Color& color)>; SetStatusBarEventHandler(StatusBarEventHandler && listener)349 void SetStatusBarEventHandler(StatusBarEventHandler&& listener) 350 { 351 statusBarBgColorEventHandler_ = std::move(listener); 352 } 353 void NotifyStatusBarBgColor(const Color& color) const; 354 355 using PopupEventHandler = std::function<void()>; SetPopupEventHandler(PopupEventHandler && listener)356 void SetPopupEventHandler(PopupEventHandler&& listener) 357 { 358 popupEventHandler_ = std::move(listener); 359 } 360 void NotifyPopupDismiss() const; 361 362 using MenuEventHandler = std::function<void()>; SetMenuEventHandler(MenuEventHandler && listener)363 void SetMenuEventHandler(MenuEventHandler&& listener) 364 { 365 menuEventHandler_ = std::move(listener); 366 } 367 void NotifyMenuDismiss() const; 368 369 using ContextMenuEventHandler = std::function<void()>; SetContextMenuEventHandler(ContextMenuEventHandler && listener)370 void SetContextMenuEventHandler(ContextMenuEventHandler&& listener) 371 { 372 contextMenuEventHandler_ = std::move(listener); 373 } 374 void NotifyContextMenuDismiss() const; 375 376 using RouterBackEventHandler = std::function<void()>; SetRouterBackEventHandler(RouterBackEventHandler && listener)377 void SetRouterBackEventHandler(RouterBackEventHandler&& listener) 378 { 379 routerBackEventHandler_ = std::move(listener); 380 } 381 void NotifyRouterBackDismiss() const; 382 383 using PopPageSuccessEventHandler = std::function<void(const std::string& pageUrl, const int32_t pageId)>; SetPopPageSuccessEventHandler(PopPageSuccessEventHandler && listener)384 void SetPopPageSuccessEventHandler(PopPageSuccessEventHandler&& listener) 385 { 386 popPageSuccessEventHandler_.push_back(std::move(listener)); 387 } 388 void NotifyPopPageSuccessDismiss(const std::string& pageUrl, int32_t pageId) const; 389 390 using IsPagePathInvalidEventHandler = std::function<void(bool& isPageInvalid)>; SetIsPagePathInvalidEventHandler(IsPagePathInvalidEventHandler && listener)391 void SetIsPagePathInvalidEventHandler(IsPagePathInvalidEventHandler&& listener) 392 { 393 isPagePathInvalidEventHandler_.push_back(std::move(listener)); 394 } 395 void NotifyIsPagePathInvalidDismiss(bool isPageInvalid) const; 396 397 using DestroyEventHandler = std::function<void()>; SetDestroyHandler(DestroyEventHandler && listener)398 void SetDestroyHandler(DestroyEventHandler&& listener) 399 { 400 destroyEventHandler_.push_back(std::move(listener)); 401 } 402 void NotifyDestroyEventDismiss() const; 403 404 using DispatchTouchEventHandler = std::function<void(const TouchEvent& event)>; SetDispatchTouchEventHandler(DispatchTouchEventHandler && listener)405 void SetDispatchTouchEventHandler(DispatchTouchEventHandler&& listener) 406 { 407 dispatchTouchEventHandler_.push_back(std::move(listener)); 408 } 409 void NotifyDispatchTouchEventDismiss(const TouchEvent& event) const; 410 411 using GetViewScaleCallback = std::function<bool(float&, float&)>; SetGetViewScaleCallback(GetViewScaleCallback && callback)412 void SetGetViewScaleCallback(GetViewScaleCallback&& callback) 413 { 414 getViewScaleCallback_ = callback; 415 } 416 417 using OnPageShowCallBack = std::function<void()>; SetOnPageShow(OnPageShowCallBack && onPageShowCallBack)418 void SetOnPageShow(OnPageShowCallBack&& onPageShowCallBack) 419 { 420 onPageShowCallBack_ = std::move(onPageShowCallBack); 421 } 422 423 using AnimationCallback = std::function<void()>; SetAnimationCallback(AnimationCallback && callback)424 void SetAnimationCallback(AnimationCallback&& callback) 425 { 426 animationCallback_ = std::move(callback); 427 } 428 429 using ProfilerCallback = std::function<void(const std::string&)>; SetOnVsyncProfiler(const ProfilerCallback & callback)430 void SetOnVsyncProfiler(const ProfilerCallback& callback) 431 { 432 onVsyncProfiler_ = callback; 433 } 434 435 using OnRouterChangeCallback = bool (*)(const std::string currentRouterPath); AddRouterChangeCallback(const OnRouterChangeCallback & onRouterChangeCallback)436 void AddRouterChangeCallback(const OnRouterChangeCallback& onRouterChangeCallback) 437 { 438 onRouterChangeCallback_ = onRouterChangeCallback; 439 } 440 441 void onRouterChange(const std::string& url); 442 ResetOnVsyncProfiler()443 void ResetOnVsyncProfiler() 444 { 445 onVsyncProfiler_ = nullptr; 446 } 447 GetViewScale(float & scaleX,float & scaleY)448 bool GetViewScale(float& scaleX, float& scaleY) 449 { 450 if (getViewScaleCallback_) { 451 return getViewScaleCallback_(scaleX, scaleY); 452 } 453 return false; 454 } 455 GetTaskExecutor()456 RefPtr<TaskExecutor> GetTaskExecutor() const 457 { 458 return taskExecutor_; 459 } 460 461 RefPtr<Frontend> GetFrontend() const; 462 GetInstanceId()463 int32_t GetInstanceId() const 464 { 465 return instanceId_; 466 } 467 468 void ClearImageCache(); 469 470 void SetImageCache(const RefPtr<ImageCache>& imageChache); 471 472 RefPtr<ImageCache> GetImageCache() const; 473 GetOrCreateSharedImageManager()474 const RefPtr<SharedImageManager>& GetOrCreateSharedImageManager() 475 { 476 std::scoped_lock<std::shared_mutex> lock(imageMtx_); 477 if (!sharedImageManager_) { 478 sharedImageManager_ = MakeRefPtr<SharedImageManager>(taskExecutor_); 479 } 480 return sharedImageManager_; 481 } 482 GetOrCreateUIDisplaySyncManager()483 const RefPtr<UIDisplaySyncManager>& GetOrCreateUIDisplaySyncManager() 484 { 485 std::call_once(displaySyncFlag_, [this]() { 486 if (!uiDisplaySyncManager_) { 487 uiDisplaySyncManager_ = MakeRefPtr<UIDisplaySyncManager>(); 488 } 489 }); 490 return uiDisplaySyncManager_; 491 } 492 GetWindow()493 Window* GetWindow() 494 { 495 return window_.get(); 496 } 497 GetAssetManager()498 RefPtr<AssetManager> GetAssetManager() const 499 { 500 return assetManager_; 501 } 502 GetMinPlatformVersion()503 int32_t GetMinPlatformVersion() const 504 { 505 // Since API10, the platform version data format has changed. 506 // Use the last three digits of data as platform version. For example (4000000010). 507 return minPlatformVersion_ % 1000; 508 } 509 SetMinPlatformVersion(int32_t minPlatformVersion)510 void SetMinPlatformVersion(int32_t minPlatformVersion) 511 { 512 minPlatformVersion_ = minPlatformVersion; 513 } 514 SetInstallationFree(int32_t installationFree)515 void SetInstallationFree(int32_t installationFree) 516 { 517 installationFree_ = installationFree; 518 } 519 GetInstallationFree()520 bool GetInstallationFree() const 521 { 522 return installationFree_; 523 } 524 SetSharePanelCallback(SharePanelCallback && callback)525 void SetSharePanelCallback(SharePanelCallback&& callback) 526 { 527 sharePanelCallback_ = std::move(callback); 528 } 529 FireSharePanelCallback(const std::string & bundleName,const std::string & abilityName)530 void FireSharePanelCallback(const std::string& bundleName, const std::string& abilityName) 531 { 532 if (sharePanelCallback_) { 533 sharePanelCallback_(bundleName, abilityName); 534 } 535 } 536 GetThemeManager()537 RefPtr<ThemeManager> GetThemeManager() const 538 { 539 std::shared_lock<std::shared_mutex> lock(themeMtx_); 540 return themeManager_; 541 } 542 SetThemeManager(RefPtr<ThemeManager> theme)543 void SetThemeManager(RefPtr<ThemeManager> theme) 544 { 545 CHECK_RUN_ON(UI); 546 std::unique_lock<std::shared_mutex> lock(themeMtx_); 547 themeManager_ = std::move(theme); 548 } 549 550 template<typename T> GetTheme()551 RefPtr<T> GetTheme() const 552 { 553 std::shared_lock<std::shared_mutex> lock(themeMtx_); 554 if (themeManager_) { 555 return themeManager_->GetTheme<T>(); 556 } 557 return {}; 558 } 559 560 template<typename T> GetDraggable()561 bool GetDraggable() 562 { 563 if (isJsCard_ || isFormRender_) { 564 return false; 565 } 566 auto theme = GetTheme<T>(); 567 CHECK_NULL_RETURN(theme, false); 568 return theme->GetDraggable(); 569 } 570 GetTextFieldManager()571 const RefPtr<ManagerInterface>& GetTextFieldManager() 572 { 573 return textFieldManager_; 574 } 575 void SetTextFieldManager(const RefPtr<ManagerInterface>& manager); 576 GetFontManager()577 const RefPtr<FontManager>& GetFontManager() const 578 { 579 return fontManager_; 580 } 581 GetDataProviderManager()582 const RefPtr<DataProviderManagerInterface>& GetDataProviderManager() const 583 { 584 return dataProviderManager_; 585 } SetDataProviderManager(const RefPtr<DataProviderManagerInterface> & dataProviderManager)586 void SetDataProviderManager(const RefPtr<DataProviderManagerInterface>& dataProviderManager) 587 { 588 dataProviderManager_ = dataProviderManager; 589 } 590 GetMessageBridge()591 const RefPtr<PlatformBridge>& GetMessageBridge() const 592 { 593 return messageBridge_; 594 } SetMessageBridge(const RefPtr<PlatformBridge> & messageBridge)595 void SetMessageBridge(const RefPtr<PlatformBridge>& messageBridge) 596 { 597 messageBridge_ = messageBridge; 598 } 599 SetIsJsCard(bool isJsCard)600 void SetIsJsCard(bool isJsCard) 601 { 602 isJsCard_ = isJsCard; 603 } 604 SetIsJsPlugin(bool isJsPlugin)605 void SetIsJsPlugin(bool isJsPlugin) 606 { 607 isJsPlugin_ = isJsPlugin; 608 } 609 SetDrawDelegate(std::unique_ptr<DrawDelegate> delegate)610 void SetDrawDelegate(std::unique_ptr<DrawDelegate> delegate) 611 { 612 drawDelegate_ = std::move(delegate); 613 } 614 IsJsCard()615 bool IsJsCard() const 616 { 617 return isJsCard_; 618 } 619 IsJsPlugin()620 bool IsJsPlugin() const 621 { 622 return isJsPlugin_; 623 } 624 SetIsFormRender(bool isEtsCard)625 void SetIsFormRender(bool isEtsCard) 626 { 627 isFormRender_ = isEtsCard; 628 } 629 IsFormRender()630 bool IsFormRender() const 631 { 632 return isFormRender_; 633 } 634 635 // Get the dp scale which used to covert dp to logic px. GetDipScale()636 double GetDipScale() const 637 { 638 return dipScale_; 639 } 640 641 // Get the window design scale used to covert lpx to logic px. GetLogicScale()642 double GetLogicScale() const 643 { 644 return designWidthScale_; 645 } 646 GetFontScale()647 float GetFontScale() const 648 { 649 return fontScale_; 650 } 651 void SetFontScale(float fontScale); 652 GetWindowId()653 uint32_t GetWindowId() const 654 { 655 return windowId_; 656 } 657 SetWindowId(uint32_t windowId)658 void SetWindowId(uint32_t windowId) 659 { 660 windowId_ = windowId; 661 } 662 SetFocusWindowId(uint32_t windowId)663 void SetFocusWindowId(uint32_t windowId) 664 { 665 focusWindowId_ = windowId; 666 } 667 GetFocusWindowId()668 uint32_t GetFocusWindowId() const 669 { 670 return focusWindowId_.value_or(windowId_); 671 } 672 IsFocusWindowIdSetted()673 bool IsFocusWindowIdSetted() const 674 { 675 return focusWindowId_.has_value(); 676 } 677 GetViewScale()678 float GetViewScale() const 679 { 680 return viewScale_; 681 } 682 GetRootWidth()683 double GetRootWidth() const 684 { 685 return rootWidth_; 686 } 687 GetRootHeight()688 double GetRootHeight() const 689 { 690 return rootHeight_; 691 } 692 SetWindowModal(WindowModal modal)693 void SetWindowModal(WindowModal modal) 694 { 695 windowModal_ = modal; 696 } 697 GetWindowModal()698 WindowModal GetWindowModal() const 699 { 700 return windowModal_; 701 } 702 IsFullScreenModal()703 bool IsFullScreenModal() const 704 { 705 return windowModal_ == WindowModal::NORMAL || windowModal_ == WindowModal::SEMI_MODAL_FULL_SCREEN || 706 windowModal_ == WindowModal::CONTAINER_MODAL || isFullWindow_; 707 } 708 SetIsRightToLeft(bool isRightToLeft)709 void SetIsRightToLeft(bool isRightToLeft) 710 { 711 isRightToLeft_ = isRightToLeft; 712 } 713 IsRightToLeft()714 bool IsRightToLeft() const 715 { 716 return isRightToLeft_; 717 } 718 SetEventManager(const RefPtr<EventManager> & eventManager)719 void SetEventManager(const RefPtr<EventManager>& eventManager) 720 { 721 eventManager_ = eventManager; 722 } 723 GetEventManager()724 RefPtr<EventManager> GetEventManager() const 725 { 726 return eventManager_; 727 } 728 GetWindowManager()729 const RefPtr<WindowManager>& GetWindowManager() const 730 { 731 return windowManager_; 732 } 733 734 bool HasFloatTitle() const; 735 IsRebuildFinished()736 bool IsRebuildFinished() const 737 { 738 return isRebuildFinished_; 739 } 740 741 void RequestFrame(); 742 743 void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "", 744 const std::string& moduleName = ""); 745 746 void GetSystemFontList(std::vector<std::string>& fontList); 747 748 bool GetSystemFont(const std::string& fontName, FontInfo& fontInfo); 749 750 void GetUIFontConfig(FontConfigJsonInfo& fontConfigJsonInfo); 751 752 void TryLoadImageInfo(const std::string& src, std::function<void(bool, int32_t, int32_t)>&& loadCallback); 753 754 RefPtr<OffscreenCanvas> CreateOffscreenCanvas(int32_t width, int32_t height); 755 756 void PostAsyncEvent(TaskExecutor::Task&& task, TaskExecutor::TaskType type = TaskExecutor::TaskType::UI); 757 758 void PostAsyncEvent(const TaskExecutor::Task& task, TaskExecutor::TaskType type = TaskExecutor::TaskType::UI); 759 760 void PostSyncEvent(const TaskExecutor::Task& task, TaskExecutor::TaskType type = TaskExecutor::TaskType::UI); 761 FlushReload(const ConfigurationChange & configurationChange)762 virtual void FlushReload(const ConfigurationChange& configurationChange) {} FlushBuild()763 virtual void FlushBuild() {} 764 FlushReloadTransition()765 virtual void FlushReloadTransition() {} GetFrontendType()766 FrontendType GetFrontendType() const 767 { 768 return frontendType_; 769 } 770 GetDensity()771 double GetDensity() const 772 { 773 return density_; 774 } 775 GetPlatformResRegister()776 RefPtr<PlatformResRegister> GetPlatformResRegister() const 777 { 778 return platformResRegister_; 779 } 780 781 void SetTouchPipeline(const WeakPtr<PipelineBase>& context); 782 void RemoveTouchPipeline(const WeakPtr<PipelineBase>& context); 783 784 void OnVirtualKeyboardAreaChange( 785 Rect keyboardArea, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 786 void OnVirtualKeyboardAreaChange( 787 Rect keyboardArea, double positionY, double height, 788 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr); 789 790 void OnFoldStatusChanged(FoldStatus foldStatus); 791 792 using foldStatusChangedCallback = std::function<bool(FoldStatus)>; SetFoldStatusChangeCallback(foldStatusChangedCallback && listener)793 void SetFoldStatusChangeCallback(foldStatusChangedCallback&& listener) 794 { 795 foldStatusChangedCallback_.emplace_back(std::move(listener)); 796 } 797 798 void OnFoldDisplayModeChanged(FoldDisplayMode foldDisplayMode); 799 800 using virtualKeyBoardCallback = std::function<bool(int32_t, int32_t, double)>; SetVirtualKeyBoardCallback(virtualKeyBoardCallback && listener)801 void SetVirtualKeyBoardCallback(virtualKeyBoardCallback&& listener) 802 { 803 virtualKeyBoardCallback_.push_back(std::move(listener)); 804 } NotifyVirtualKeyBoard(int32_t width,int32_t height,double keyboard)805 bool NotifyVirtualKeyBoard(int32_t width, int32_t height, double keyboard) const 806 { 807 bool isConsume = false; 808 for (const auto& iterVirtualKeyBoardCallback : virtualKeyBoardCallback_) { 809 if (iterVirtualKeyBoardCallback && iterVirtualKeyBoardCallback(width, height, keyboard)) { 810 isConsume = true; 811 } 812 } 813 return isConsume; 814 } 815 816 using configChangedCallback = std::function<void()>; SetConfigChangedCallback(configChangedCallback && listener)817 void SetConfigChangedCallback(configChangedCallback&& listener) 818 { 819 configChangedCallback_.push_back(std::move(listener)); 820 } 821 NotifyConfigurationChange()822 void NotifyConfigurationChange() 823 { 824 for (const auto& callback : configChangedCallback_) { 825 if (callback) { 826 callback(); 827 } 828 } 829 } 830 831 using PostRTTaskCallback = std::function<void(std::function<void()>&&)>; SetPostRTTaskCallBack(PostRTTaskCallback && callback)832 void SetPostRTTaskCallBack(PostRTTaskCallback&& callback) 833 { 834 postRTTaskCallback_ = std::move(callback); 835 } 836 PostTaskToRT(std::function<void ()> && task)837 void PostTaskToRT(std::function<void()>&& task) 838 { 839 if (postRTTaskCallback_) { 840 postRTTaskCallback_(std::move(task)); 841 } 842 } 843 844 void SetGetWindowRectImpl(std::function<Rect()>&& callback); 845 846 Rect GetCurrentWindowRect() const; 847 848 using SafeAreaInsets = NG::SafeAreaInsets; UpdateSystemSafeArea(const SafeAreaInsets & systemSafeArea)849 virtual void UpdateSystemSafeArea(const SafeAreaInsets& systemSafeArea) {} 850 UpdateCutoutSafeArea(const SafeAreaInsets & cutoutSafeArea)851 virtual void UpdateCutoutSafeArea(const SafeAreaInsets& cutoutSafeArea) {} 852 UpdateNavSafeArea(const SafeAreaInsets & navSafeArea)853 virtual void UpdateNavSafeArea(const SafeAreaInsets& navSafeArea) {} 854 UpdateOriginAvoidArea(const Rosen::AvoidArea & avoidArea,uint32_t type)855 virtual void UpdateOriginAvoidArea(const Rosen::AvoidArea& avoidArea, uint32_t type) {} 856 SetEnableKeyBoardAvoidMode(bool value)857 virtual void SetEnableKeyBoardAvoidMode(bool value) {} 858 IsEnableKeyBoardAvoidMode()859 virtual bool IsEnableKeyBoardAvoidMode() { 860 return false; 861 } 862 SetPluginOffset(const Offset & offset)863 void SetPluginOffset(const Offset& offset) 864 { 865 pluginOffset_ = offset; 866 } 867 GetPluginOffset()868 Offset GetPluginOffset() const 869 { 870 return pluginOffset_; 871 } 872 SetPluginEventOffset(const Offset & offset)873 void SetPluginEventOffset(const Offset& offset) 874 { 875 pluginEventOffset_ = offset; 876 } 877 GetPluginEventOffset()878 Offset GetPluginEventOffset() const 879 { 880 return pluginEventOffset_; 881 } NotifyMemoryLevel(int32_t level)882 virtual void NotifyMemoryLevel(int32_t level) {} 883 SetDisplayWindowRectInfo(const Rect & displayWindowRectInfo)884 void SetDisplayWindowRectInfo(const Rect& displayWindowRectInfo) 885 { 886 displayWindowRectInfo_ = displayWindowRectInfo; 887 } 888 889 virtual void SetContainerWindow(bool isShow) = 0; 890 891 // This method can get the coordinates and size of the current window, 892 // which can be added to the return value of the GetGlobalOffset method to get the window coordinates of the node. GetDisplayWindowRectInfo()893 const Rect& GetDisplayWindowRectInfo() const 894 { 895 return displayWindowRectInfo_; 896 } 897 virtual void FlushMessages() = 0; SetGSVsyncCallback(std::function<void (void)> && callback)898 void SetGSVsyncCallback(std::function<void(void)>&& callback) 899 { 900 gsVsyncCallback_ = std::move(callback); 901 } 902 903 virtual void FlushUITasks() = 0; 904 905 virtual void FlushPipelineImmediately() = 0; 906 907 // get animateTo closure option GetSyncAnimationOption()908 AnimationOption GetSyncAnimationOption() 909 { 910 return animationOption_; 911 } 912 SetSyncAnimationOption(const AnimationOption & option)913 void SetSyncAnimationOption(const AnimationOption& option) 914 { 915 animationOption_ = option; 916 } 917 SetKeyboardAnimationConfig(const KeyboardAnimationConfig & config)918 void SetKeyboardAnimationConfig(const KeyboardAnimationConfig& config) 919 { 920 keyboardAnimationConfig_ = config; 921 } 922 SetNextFrameLayoutCallback(std::function<void ()> && callback)923 void SetNextFrameLayoutCallback(std::function<void()>&& callback) 924 { 925 nextFrameLayoutCallback_ = std::move(callback); 926 } 927 SetForegroundCalled(bool isForegroundCalled)928 void SetForegroundCalled(bool isForegroundCalled) 929 { 930 isForegroundCalled_ = isForegroundCalled; 931 } 932 SetIsSubPipeline(bool isSubPipeline)933 void SetIsSubPipeline(bool isSubPipeline) 934 { 935 isSubPipeline_ = isSubPipeline; 936 } 937 IsSubPipeline()938 bool IsSubPipeline() const 939 { 940 return isSubPipeline_; 941 } 942 SetParentPipeline(const WeakPtr<PipelineBase> & pipeline)943 void SetParentPipeline(const WeakPtr<PipelineBase>& pipeline) 944 { 945 parentPipeline_ = pipeline; 946 } 947 948 void AddEtsCardTouchEventCallback(int32_t ponitId, EtsCardTouchEventCallback&& callback); 949 950 void HandleEtsCardTouchEvent(const TouchEvent& point, SerializedGesture &serializedGesture); 951 952 void RemoveEtsCardTouchEventCallback(int32_t ponitId); 953 954 void SetSubWindowVsyncCallback(AceVsyncCallback&& callback, int32_t subWindowId); 955 956 void SetJsFormVsyncCallback(AceVsyncCallback&& callback, int32_t subWindowId); 957 958 void RemoveSubWindowVsyncCallback(int32_t subWindowId); 959 960 void RemoveJsFormVsyncCallback(int32_t subWindowId); 961 SetIsLayoutFullScreen(bool isLayoutFullScreen)962 virtual void SetIsLayoutFullScreen(bool isLayoutFullScreen) {} SetIsNeedAvoidWindow(bool isLayoutFullScreen)963 virtual void SetIsNeedAvoidWindow(bool isLayoutFullScreen) {} SetIgnoreViewSafeArea(bool ignoreViewSafeArea)964 virtual void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) {} OnFoldStatusChange(FoldStatus foldStatus)965 virtual void OnFoldStatusChange(FoldStatus foldStatus) {} OnFoldDisplayModeChange(FoldDisplayMode foldDisplayMode)966 virtual void OnFoldDisplayModeChange(FoldDisplayMode foldDisplayMode) {} 967 SetIsAppWindow(bool isAppWindow)968 void SetIsAppWindow(bool isAppWindow) 969 { 970 isAppWindow_ = isAppWindow; 971 } 972 GetIsAppWindow()973 bool GetIsAppWindow() const 974 { 975 return isAppWindow_; 976 } 977 SetFormAnimationStartTime(int64_t time)978 void SetFormAnimationStartTime(int64_t time) 979 { 980 formAnimationStartTime_ = time; 981 } 982 GetFormAnimationStartTime()983 int64_t GetFormAnimationStartTime() const 984 { 985 return formAnimationStartTime_; 986 } 987 SetIsFormAnimation(bool isFormAnimation)988 void SetIsFormAnimation(bool isFormAnimation) 989 { 990 isFormAnimation_ = isFormAnimation; 991 } 992 IsFormAnimation()993 bool IsFormAnimation() const 994 { 995 return isFormAnimation_; 996 } 997 SetFormAnimationFinishCallback(bool isFormAnimationFinishCallback)998 void SetFormAnimationFinishCallback(bool isFormAnimationFinishCallback) 999 { 1000 isFormAnimationFinishCallback_ = isFormAnimationFinishCallback; 1001 } 1002 IsFormAnimationFinishCallback()1003 bool IsFormAnimationFinishCallback() const 1004 { 1005 return isFormAnimationFinishCallback_; 1006 } 1007 1008 // restore RestoreNodeInfo(std::unique_ptr<JsonValue> nodeInfo)1009 virtual void RestoreNodeInfo(std::unique_ptr<JsonValue> nodeInfo) {} 1010 GetStoredNodeInfo()1011 virtual std::unique_ptr<JsonValue> GetStoredNodeInfo() 1012 { 1013 return nullptr; 1014 } 1015 GetLastTouchTime()1016 uint64_t GetLastTouchTime() const 1017 { 1018 return lastTouchTime_; 1019 } 1020 AddFormLinkInfo(int32_t id,const std::string & info)1021 void AddFormLinkInfo(int32_t id, const std::string& info) 1022 { 1023 LOGI("AddFormLinkInfo is %{public}s, id is %{public}d", info.c_str(), id); 1024 formLinkInfoMap_[id] = info; 1025 } 1026 IsLayouting()1027 virtual bool IsLayouting() const 1028 { 1029 return false; 1030 } 1031 SetHalfLeading(bool halfLeading)1032 void SetHalfLeading(bool halfLeading) 1033 { 1034 halfLeading_ = halfLeading; 1035 } 1036 GetHalfLeading()1037 bool GetHalfLeading() const 1038 { 1039 return halfLeading_; 1040 } 1041 GetOnFoucs()1042 bool GetOnFoucs() const 1043 { 1044 return onFocus_; 1045 } 1046 SetSurfaceChangeMsg(int32_t width,int32_t height,WindowSizeChangeReason type,const std::shared_ptr<Rosen::RSTransaction> & rsTransaction)1047 void SetSurfaceChangeMsg(int32_t width, int32_t height, 1048 WindowSizeChangeReason type, 1049 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction) 1050 { 1051 width_ = width; 1052 height_ = height; 1053 type_ = type; 1054 rsTransaction_ = rsTransaction; 1055 delaySurfaceChange_ = true; 1056 } 1057 ResetSurfaceChangeMsg()1058 void ResetSurfaceChangeMsg() 1059 { 1060 delaySurfaceChange_ = false; 1061 } 1062 GetVsyncTime()1063 uint64_t GetVsyncTime() const 1064 { 1065 return vsyncTime_; 1066 } 1067 SetVsyncTime(uint64_t time)1068 void SetVsyncTime(uint64_t time) 1069 { 1070 vsyncTime_ = time; 1071 } 1072 UpdateCurrentActiveNode(const WeakPtr<NG::FrameNode> & node)1073 virtual void UpdateCurrentActiveNode(const WeakPtr<NG::FrameNode>& node) {} 1074 GetCurrentExtraInfo()1075 virtual std::string GetCurrentExtraInfo() { return ""; } 1076 virtual void UpdateTitleInTargetPos(bool isShow = true, int32_t height = 0) {} 1077 SetCursor(int32_t cursorValue)1078 virtual void SetCursor(int32_t cursorValue) {} 1079 RestoreDefault()1080 virtual void RestoreDefault() {} 1081 SetOnFormRecycleCallback(std::function<std::string ()> && onFormRecycle)1082 void SetOnFormRecycleCallback(std::function<std::string()>&& onFormRecycle) 1083 { 1084 onFormRecycle_ = std::move(onFormRecycle); 1085 } 1086 1087 std::string OnFormRecycle(); 1088 SetOnFormRecoverCallback(std::function<void (std::string)> && onFormRecover)1089 void SetOnFormRecoverCallback(std::function<void(std::string)>&& onFormRecover) 1090 { 1091 onFormRecover_ = std::move(onFormRecover); 1092 } 1093 1094 void OnFormRecover(const std::string& statusData); 1095 IsDragging()1096 virtual bool IsDragging() const 1097 { 1098 return false; 1099 } 1100 SetIsDragging(bool isDragging)1101 virtual void SetIsDragging(bool isDragging) {} 1102 ResetDragging()1103 virtual void ResetDragging() {} 1104 GetSerializedGesture()1105 virtual const SerializedGesture& GetSerializedGesture() const 1106 { 1107 return serializedGesture_; 1108 } 1109 PrintVsyncInfoIfNeed()1110 virtual bool PrintVsyncInfoIfNeed() const 1111 { 1112 return false; 1113 } 1114 StartWindowAnimation()1115 virtual void StartWindowAnimation() {} 1116 StopWindowAnimation()1117 virtual void StopWindowAnimation() {} 1118 AddSyncGeometryNodeTask(std::function<void ()> && task)1119 virtual void AddSyncGeometryNodeTask(std::function<void()>&& task) {} 1120 FlushSyncGeometryNodeTasks()1121 virtual void FlushSyncGeometryNodeTasks() {} 1122 1123 protected: 1124 virtual bool MaybeRelease() override; TryCallNextFrameLayoutCallback()1125 void TryCallNextFrameLayoutCallback() 1126 { 1127 if (isForegroundCalled_ && nextFrameLayoutCallback_) { 1128 isForegroundCalled_ = false; 1129 nextFrameLayoutCallback_(); 1130 LOGI("nextFrameLayoutCallback called"); 1131 } 1132 } 1133 OnDumpInfo(const std::vector<std::string> & params)1134 virtual bool OnDumpInfo(const std::vector<std::string>& params) const 1135 { 1136 return false; 1137 } 1138 virtual void FlushVsync(uint64_t nanoTimestamp, uint32_t frameCount) = 0; 1139 virtual void SetRootRect(double width, double height, double offset = 0.0) = 0; 1140 virtual void FlushPipelineWithoutAnimation() = 0; 1141 1142 virtual void OnVirtualKeyboardHeightChange( 1143 float keyboardHeight, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr) 1144 {} 1145 virtual void OnVirtualKeyboardHeightChange( 1146 float keyboardHeight, double positionY, double height, 1147 const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr) 1148 {} 1149 1150 void UpdateRootSizeAndScale(int32_t width, int32_t height); 1151 SetIsReloading(bool isReloading)1152 void SetIsReloading(bool isReloading) 1153 { 1154 isReloading_ = isReloading; 1155 } 1156 1157 std::function<void()> GetWrappedAnimationCallback(const std::function<void()>& finishCallback); 1158 1159 std::list<configChangedCallback> configChangedCallback_; 1160 std::list<virtualKeyBoardCallback> virtualKeyBoardCallback_; 1161 std::list<foldStatusChangedCallback> foldStatusChangedCallback_; 1162 1163 bool isRebuildFinished_ = false; 1164 bool isJsCard_ = false; 1165 bool isFormRender_ = false; 1166 bool isRightToLeft_ = false; 1167 bool isFullWindow_ = false; 1168 bool isAppWindow_ = true; 1169 bool installationFree_ = false; 1170 bool isSubPipeline_ = false; 1171 bool isReloading_ = false; 1172 1173 bool isJsPlugin_ = false; 1174 1175 std::unordered_map<int32_t, AceVsyncCallback> subWindowVsyncCallbacks_; 1176 std::unordered_map<int32_t, AceVsyncCallback> jsFormVsyncCallbacks_; 1177 int32_t minPlatformVersion_ = 0; 1178 uint32_t windowId_ = 0; 1179 // UIExtensionAbility need component windowID 1180 std::optional<uint32_t> focusWindowId_; 1181 1182 int32_t appLabelId_ = 0; 1183 float fontScale_ = 1.0f; 1184 float designWidthScale_ = 1.0f; 1185 float viewScale_ = 1.0f; 1186 double density_ = 1.0; 1187 double dipScale_ = 1.0; 1188 double rootHeight_ = 0.0; 1189 double rootWidth_ = 0.0; 1190 FrontendType frontendType_; 1191 WindowModal windowModal_ = WindowModal::NORMAL; 1192 1193 Offset pluginOffset_ { 0, 0 }; 1194 Offset pluginEventOffset_ { 0, 0 }; 1195 Color appBgColor_ = Color::WHITE; 1196 1197 std::unique_ptr<DrawDelegate> drawDelegate_; 1198 std::stack<bool> pendingImplicitLayout_; 1199 std::stack<bool> pendingImplicitRender_; 1200 std::stack<bool> pendingFrontendAnimation_; 1201 std::shared_ptr<Window> window_; 1202 RefPtr<TaskExecutor> taskExecutor_; 1203 RefPtr<AssetManager> assetManager_; 1204 WeakPtr<Frontend> weakFrontend_; 1205 int32_t instanceId_ = 0; 1206 RefPtr<EventManager> eventManager_; 1207 RefPtr<ImageCache> imageCache_; 1208 RefPtr<SharedImageManager> sharedImageManager_; 1209 mutable std::shared_mutex imageMtx_; 1210 mutable std::shared_mutex themeMtx_; 1211 mutable std::mutex destructMutex_; 1212 RefPtr<ThemeManager> themeManager_; 1213 RefPtr<DataProviderManagerInterface> dataProviderManager_; 1214 RefPtr<FontManager> fontManager_; 1215 RefPtr<ManagerInterface> textFieldManager_; 1216 RefPtr<PlatformBridge> messageBridge_; 1217 RefPtr<WindowManager> windowManager_; 1218 OnPageShowCallBack onPageShowCallBack_; 1219 AnimationCallback animationCallback_; 1220 ProfilerCallback onVsyncProfiler_; 1221 FinishEventHandler finishEventHandler_; 1222 StartAbilityHandler startAbilityHandler_; 1223 ActionEventHandler actionEventHandler_; 1224 FormLinkInfoUpdateHandler formLinkInfoUpdateHandler_; 1225 RefPtr<PlatformResRegister> platformResRegister_; 1226 1227 WeakPtr<PipelineBase> parentPipeline_; 1228 1229 std::vector<WeakPtr<PipelineBase>> touchPluginPipelineContext_; 1230 std::unordered_map<int32_t, EtsCardTouchEventCallback> etsCardTouchEventCallback_; 1231 1232 RefPtr<Clipboard> clipboard_; 1233 std::function<void(const std::string&)> clipboardCallback_ = nullptr; 1234 Rect displayWindowRectInfo_; 1235 AnimationOption animationOption_; 1236 KeyboardAnimationConfig keyboardAnimationConfig_; 1237 1238 std::function<void()> nextFrameLayoutCallback_ = nullptr; 1239 SharePanelCallback sharePanelCallback_ = nullptr; 1240 std::atomic<bool> isForegroundCalled_ = false; 1241 std::atomic<bool> onFocus_ = true; 1242 uint64_t lastTouchTime_ = 0; 1243 std::map<int32_t, std::string> formLinkInfoMap_; 1244 struct FunctionHash { operatorFunctionHash1245 std::size_t operator()(const std::shared_ptr<std::function<void()>>& functionPtr) const 1246 { 1247 return std::hash<std::function<void()>*>()(functionPtr.get()); 1248 } 1249 }; 1250 std::function<std::string()> onFormRecycle_; 1251 std::function<void(std::string)> onFormRecover_; 1252 1253 std::once_flag displaySyncFlag_; 1254 RefPtr<UIDisplaySyncManager> uiDisplaySyncManager_; 1255 1256 SerializedGesture serializedGesture_; 1257 private: 1258 void DumpFrontend() const; 1259 double ModifyKeyboardHeight(double keyboardHeight) const; 1260 StatusBarEventHandler statusBarBgColorEventHandler_; 1261 PopupEventHandler popupEventHandler_; 1262 MenuEventHandler menuEventHandler_; 1263 ContextMenuEventHandler contextMenuEventHandler_; 1264 RouterBackEventHandler routerBackEventHandler_; 1265 std::list<PopPageSuccessEventHandler> popPageSuccessEventHandler_; 1266 std::list<IsPagePathInvalidEventHandler> isPagePathInvalidEventHandler_; 1267 std::list<DestroyEventHandler> destroyEventHandler_; 1268 std::list<DispatchTouchEventHandler> dispatchTouchEventHandler_; 1269 GetViewScaleCallback getViewScaleCallback_; 1270 // OnRouterChangeCallback is function point, need to be initialized. 1271 OnRouterChangeCallback onRouterChangeCallback_ = nullptr; 1272 PostRTTaskCallback postRTTaskCallback_; 1273 std::function<void(void)> gsVsyncCallback_; 1274 std::unordered_set<std::shared_ptr<std::function<void()>>, FunctionHash> finishFunctions_; 1275 bool isFormAnimationFinishCallback_ = false; 1276 int64_t formAnimationStartTime_ = 0; 1277 bool isFormAnimation_ = false; 1278 bool halfLeading_ = false; 1279 uint64_t vsyncTime_ = 0; 1280 1281 bool delaySurfaceChange_ = false; 1282 int32_t width_ = -1; 1283 int32_t height_ = -1; 1284 WindowSizeChangeReason type_ = WindowSizeChangeReason::UNDEFINED; 1285 std::shared_ptr<Rosen::RSTransaction> rsTransaction_; 1286 1287 ACE_DISALLOW_COPY_AND_MOVE(PipelineBase); 1288 }; 1289 1290 } // namespace OHOS::Ace 1291 1292 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_PIPELINE_PIPELINE_BASE_H 1293