1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PIPELINE_CONTEXT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PIPELINE_CONTEXT_H 18 19 #include <list> 20 #include <map> 21 #include <memory> 22 #include <queue> 23 #include <set> 24 #include <unordered_map> 25 #include <utility> 26 27 #include "base/geometry/dimension.h" 28 #include "base/geometry/offset.h" 29 #include "base/geometry/rect.h" 30 #include "base/image/pixel_map.h" 31 #include "base/memory/ace_type.h" 32 #include "base/resource/asset_manager.h" 33 #include "base/resource/data_provider_manager.h" 34 #include "base/resource/shared_image_manager.h" 35 #include "base/thread/task_executor.h" 36 #include "base/utils/macros.h" 37 #include "base/utils/noncopyable.h" 38 #include "core/accessibility/accessibility_manager.h" 39 #include "core/animation/flush_event.h" 40 #include "core/animation/page_transition_listener.h" 41 #include "core/animation/schedule_task.h" 42 #include "core/common/draw_delegate.h" 43 #include "core/common/event_manager.h" 44 #include "core/common/focus_animation_manager.h" 45 #include "core/common/platform_bridge.h" 46 #include "core/common/platform_res_register.h" 47 #include "core/common/window_animation_config.h" 48 #include "core/components/common/properties/color.h" 49 #include "core/components/dialog/dialog_properties.h" 50 #include "core/components/page/page_component.h" 51 #include "core/components/theme/theme_manager.h" 52 #include "core/event/event_trigger.h" 53 #include "core/gestures/gesture_info.h" 54 #include "core/image/image_cache.h" 55 #include "core/pipeline/base/composed_component.h" 56 #include "core/pipeline/base/factories/render_factory.h" 57 #ifndef WEARABLE_PRODUCT 58 #include "core/event/multimodal/multimodal_manager.h" 59 #include "core/event/multimodal/multimodal_subscriber.h" 60 #endif 61 #include "core/common/clipboard/clipboard_proxy.h" 62 63 namespace OHOS::Rosen { 64 class RSUIDirector; 65 } 66 67 namespace OHOS::Ace { 68 69 class OffscreenCanvas; 70 class CardTransitionController; 71 class ComposedElement; 72 class FontManager; 73 class Frontend; 74 enum class FrontendType; 75 class OverlayElement; 76 class RenderNode; 77 class RenderFocusAnimation; 78 class RootElement; 79 class SharedTransitionController; 80 class StageElement; 81 class StackElement; 82 class Window; 83 class Animator; 84 class ManagerInterface; 85 class AccessibilityManager; 86 class RenderContext; 87 struct PageTarget; 88 class DialogComponent; 89 class SelectPopupComponent; 90 class RenderElement; 91 92 struct WindowBlurInfo { 93 float progress_; 94 WindowBlurStyle style_; 95 RRect innerRect_; 96 std::vector<RRect> coords_; 97 }; 98 99 100 using OnRouterChangeCallback = bool (*)(const std::string currentRouterPath); 101 using SubscribeCtrlACallback = std::function<void()>; 102 103 class ACE_EXPORT PipelineContext final : public AceType { 104 DECLARE_ACE_TYPE(PipelineContext, AceType); 105 106 public: 107 static constexpr int32_t DEFAULT_HOVER_ENTER_ANIMATION_ID = -1; 108 using TimeProvider = std::function<int64_t(void)>; 109 using OnPageShowCallBack = std::function<void()>; 110 using AnimationCallback = std::function<void()>; 111 using GetViewScaleCallback = std::function<bool(float&, float&)>; 112 using SurfaceChangedCallbackMap = 113 std::unordered_map<int32_t, std::function<void(int32_t, int32_t, int32_t, int32_t)>>; 114 115 PipelineContext(std::unique_ptr<Window> window, RefPtr<TaskExecutor> taskExecutor, 116 RefPtr<AssetManager> assetManager, RefPtr<PlatformResRegister> platformResRegister, 117 const RefPtr<Frontend>& frontend, int32_t instanceId); 118 PipelineContext(std::unique_ptr<Window> window, RefPtr<TaskExecutor>& taskExecutor, 119 RefPtr<AssetManager> assetManager, const RefPtr<Frontend>& frontend); 120 121 ~PipelineContext() override; 122 123 RefPtr<Element> SetupRootElement(); 124 125 // This is used for subwindow, when the subwindow is created,a new subrootElement will be built 126 RefPtr<Element> SetupSubRootElement(); 127 RefPtr<DialogComponent> ShowDialog(const DialogProperties& dialogProperties, bool isRightToLeft, 128 const std::string& inspectorTag = ""); 129 void CloseContextMenu(); 130 void GetBoundingRectData(int32_t nodeId, Rect& rect); 131 132 RefPtr<OffscreenCanvas> CreateOffscreenCanvas(int32_t width, int32_t height); 133 134 void PushVisibleCallback(int32_t nodeId, double ratio, std::function<void(bool, double)>&& callback); 135 void RemoveVisibleChangeNode(int32_t nodeId); 136 137 void PushPage(const RefPtr<PageComponent>& pageComponent, const RefPtr<StageElement>& stage); 138 void PushPage(const RefPtr<PageComponent>& pageComponent); 139 void PostponePageTransition(); 140 void LaunchPageTransition(); 141 142 bool CanPushPage(); 143 144 bool IsTransitionStop() const; 145 146 void PopPage(); 147 148 void PopToPage(int32_t pageId); 149 150 void RestorePopPage(const RefPtr<PageComponent>& pageComponent); 151 152 bool CanPopPage(); 153 154 void ReplacePage(const RefPtr<PageComponent>& pageComponent, const RefPtr<StageElement>& stage); 155 void ReplacePage(const RefPtr<PageComponent>& pageComponent); 156 157 bool CanReplacePage(); 158 159 bool ClearInvisiblePages(); 160 161 bool CallRouterBackToPopPage(); 162 163 void NotifyAppStorage(const std::string& key, const std::string& value); 164 165 void Dump(const std::vector<std::string>& params) const; 166 167 void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info); 168 169 RefPtr<StackElement> GetLastStack() const; 170 171 RefPtr<PageElement> GetLastPage() const; 172 173 RefPtr<RenderNode> GetLastPageRender() const; 174 175 void AddRouterChangeCallback(const OnRouterChangeCallback& onRouterChangeCallback); 176 177 void onRouterChange(const std::string url); 178 179 void ScheduleUpdate(const RefPtr<ComposedComponent>& composed); 180 181 void AddComposedElement(const ComposeId& id, const RefPtr<ComposedElement>& element); 182 183 void RemoveComposedElement(const ComposeId& id, const RefPtr<ComposedElement>& element); 184 185 void AddDirtyElement(const RefPtr<Element>& dirtyElement); 186 187 void AddNeedRebuildFocusElement(const RefPtr<Element>& focusElement); 188 189 void AddDirtyRenderNode(const RefPtr<RenderNode>& renderNode, bool overlay = false); 190 191 void AddNeedRenderFinishNode(const RefPtr<RenderNode>& renderNode); 192 193 void AddDirtyLayoutNode(const RefPtr<RenderNode>& renderNode); 194 195 void AddPredictLayoutNode(const RefPtr<RenderNode>& renderNode); 196 197 void AddGeometryChangedNode(const RefPtr<RenderNode>& renderNode); 198 199 void AddPreFlushListener(const RefPtr<FlushEvent>& listener); 200 201 void AddPostAnimationFlushListener(const RefPtr<FlushEvent>& listener); 202 203 void AddPostFlushListener(const RefPtr<FlushEvent>& listener); 204 205 void AddPageUpdateTask(std::function<void()>&& task, bool directExecute = false); 206 207 void SetRequestedRotationNode(const WeakPtr<RenderNode>& renderNode); 208 209 void RemoveRequestedRotationNode(const WeakPtr<RenderNode>& renderNode); 210 211 // add schedule task and return the unique mark id. 212 uint32_t AddScheduleTask(const RefPtr<ScheduleTask>& task); 213 214 // remove schedule task by id. 215 void RemoveScheduleTask(uint32_t id); 216 217 // Called by view when touch event received. 218 void OnTouchEvent(const TouchEvent& point); 219 220 // Called by container when key event received. 221 // if return false, then this event needs platform to handle it. 222 bool OnKeyEvent(const KeyEvent& event); 223 224 // Called by view when mouse event received. 225 void OnMouseEvent(const MouseEvent& event); 226 227 // Called by view when axis event received. 228 void OnAxisEvent(const AxisEvent& event); 229 230 // Called by container when rotation event received. 231 // if return false, then this event needs platform to handle it. 232 bool OnRotationEvent(const RotationEvent& event) const; 233 234 // Called by window when received vsync signal. 235 void OnVsyncEvent(uint64_t nanoTimestamp, uint32_t frameCount); 236 237 // Called by view when idle event. 238 void OnIdle(int64_t deadline); 239 240 void OnActionEvent(const std::string& action); 241 242 void OnVirtualKeyboardAreaChange(Rect keyboardArea); 243 244 // Set card position for barrierfree 245 void SetCardViewPosition(int id, float offsetX, float offsetY); 246 247 void SetCardViewAccessibilityParams(const std::string& key, bool focus); 248 249 void FlushPipelineImmediately(); 250 RegisterEventHandler(const RefPtr<AceEventHandler> & handler)251 void RegisterEventHandler(const RefPtr<AceEventHandler>& handler) 252 { 253 eventTrigger_.RegisterEventHandler(handler); 254 } 255 256 template<class... Args> FireAsyncEvent(const EventMarker & marker,Args &&...args)257 void FireAsyncEvent(const EventMarker& marker, Args&&... args) 258 { 259 eventTrigger_.TriggerAsyncEvent(marker, std::forward<Args>(args)...); 260 } 261 262 template<class... Args> FireSyncEvent(const EventMarker & marker,Args &&...args)263 void FireSyncEvent(const EventMarker& marker, Args&&... args) 264 { 265 eventTrigger_.TriggerSyncEvent(marker, std::forward<Args>(args)...); 266 } 267 268 void PostAsyncEvent(TaskExecutor::Task&& task); 269 270 void PostAsyncEvent(const TaskExecutor::Task& task); 271 272 void OnSurfaceChanged( 273 int32_t width, int32_t height, WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED); 274 275 void WindowSizeChangeAnimate(int32_t width, int32_t height, WindowSizeChangeReason type); 276 277 void OnSurfaceDensityChanged(double density); 278 279 void OnSystemBarHeightChanged(double statusBar, double navigationBar); 280 281 void OnSurfaceDestroyed(); 282 283 RefPtr<Frontend> GetFrontend() const; 284 GetFrontendType()285 FrontendType GetFrontendType() const 286 { 287 return frontendType_; 288 } 289 GetTaskExecutor()290 RefPtr<TaskExecutor> GetTaskExecutor() const 291 { 292 return taskExecutor_; 293 } 294 GetAssetManager()295 RefPtr<AssetManager> GetAssetManager() const 296 { 297 return assetManager_; 298 } 299 GetPlatformResRegister()300 RefPtr<PlatformResRegister> GetPlatformResRegister() const 301 { 302 return platformResRegister_; 303 } 304 GetWindow()305 Window* GetWindow() 306 { 307 return window_.get(); 308 } 309 GetWindowModal()310 WindowModal GetWindowModal() const 311 { 312 return windowModal_; 313 } 314 IsFullScreenModal()315 bool IsFullScreenModal() const 316 { 317 return windowModal_ == WindowModal::NORMAL || windowModal_ == WindowModal::SEMI_MODAL_FULL_SCREEN || 318 isFullWindow_; 319 } 320 321 using FinishEventHandler = std::function<void()>; SetFinishEventHandler(FinishEventHandler && listener)322 void SetFinishEventHandler(FinishEventHandler&& listener) 323 { 324 finishEventHandler_ = std::move(listener); 325 } 326 327 using ActionEventHandler = std::function<void(const std::string& action)>; SetActionEventHandler(ActionEventHandler && listener)328 void SetActionEventHandler(ActionEventHandler&& listener) 329 { 330 actionEventHandler_ = std::move(listener); 331 } 332 333 // SemiModal and DialogModal have their own enter/exit animation and will exit after animation done. 334 void Finish(bool autoFinish = true) const; 335 336 void RequestFullWindow(int32_t duration); 337 338 using StatusBarEventHandler = std::function<void(const Color& color)>; SetStatusBarEventHandler(StatusBarEventHandler && listener)339 void SetStatusBarEventHandler(StatusBarEventHandler&& listener) 340 { 341 statusBarBgColorEventHandler_ = std::move(listener); 342 } 343 void NotifyStatusBarBgColor(const Color& color) const; 344 using PopupEventHandler = std::function<void()>; 345 SetPopupEventHandler(PopupEventHandler && listener)346 void SetPopupEventHandler(PopupEventHandler&& listener) 347 { 348 popupEventHandler_ = std::move(listener); 349 } 350 void NotifyPopupDismiss() const; 351 352 using RouterBackEventHandler = std::function<void()>; SetRouterBackEventHandler(RouterBackEventHandler && listener)353 void SetRouterBackEventHandler(RouterBackEventHandler&& listener) 354 { 355 routerBackEventHandler_ = std::move(listener); 356 } 357 void NotifyRouterBackDismiss() const; 358 359 using PopPageSuccessEventHandler = std::function<void(const std::string& pageUrl, const int32_t pageId)>; SetPopPageSuccessEventHandler(PopPageSuccessEventHandler && listener)360 void SetPopPageSuccessEventHandler(PopPageSuccessEventHandler&& listener) 361 { 362 popPageSuccessEventHandler_.push_back(std::move(listener)); 363 } 364 void NotifyPopPageSuccessDismiss(const std::string& pageUrl, const int32_t pageId) const; 365 366 using IsPagePathInvalidEventHandler = std::function<void(bool& isPageInvalid)>; SetIsPagePathInvalidEventHandler(IsPagePathInvalidEventHandler && listener)367 void SetIsPagePathInvalidEventHandler(IsPagePathInvalidEventHandler&& listener) 368 { 369 isPagePathInvalidEventHandler_.push_back(std::move(listener)); 370 } 371 void NotifyIsPagePathInvalidDismiss(bool isPageInvalid) const; 372 373 using DestroyEventHandler = std::function<void()>; SetDestroyHandler(DestroyEventHandler && listener)374 void SetDestroyHandler(DestroyEventHandler&& listener) 375 { 376 destroyEventHandler_.push_back(std::move(listener)); 377 } 378 void NotifyDestroyEventDismiss() const; 379 380 using DispatchTouchEventHandler = std::function<void(const TouchEvent& event)>; SetDispatchTouchEventHandler(DispatchTouchEventHandler && listener)381 void SetDispatchTouchEventHandler(DispatchTouchEventHandler&& listener) 382 { 383 dispatchTouchEventHandler_.push_back(std::move(listener)); 384 } 385 void NotifyDispatchTouchEventDismiss(const TouchEvent& event) const; 386 GetViewScale()387 float GetViewScale() const 388 { 389 return viewScale_; 390 } 391 392 // Get the dp scale which used to covert dp to logic px. GetDipScale()393 double GetDipScale() const 394 { 395 return dipScale_; 396 } 397 GetRootHeight()398 double GetRootHeight() const 399 { 400 return rootHeight_; 401 } 402 RefPtr<RenderNode> DragTestAll(const TouchEvent& point); 403 RefPtr<RenderNode> DragTest(const TouchEvent& point, const RefPtr<RenderNode>& renderNode, int32_t deep); 404 GetRootWidth()405 double GetRootWidth() const 406 { 407 return rootWidth_; 408 } 409 SetRootHeight(double rootHeight)410 void SetRootHeight(double rootHeight) 411 { 412 if (rootHeight > 0.0) { 413 rootHeight_ = rootHeight; 414 } 415 } 416 417 Rect GetRootRect() const; 418 Rect GetStageRect() const; 419 Rect GetPageRect() const; 420 IsSurfaceReady()421 bool IsSurfaceReady() const 422 { 423 return isSurfaceReady_; 424 } 425 426 void ClearImageCache(); 427 428 RefPtr<ImageCache> GetImageCache() const; 429 430 double NormalizeToPx(const Dimension& dimension) const; 431 432 double ConvertPxToVp(const Dimension& dimension) const; 433 434 void ShowFocusAnimation( 435 const RRect& rrect, const Color& color, const Offset& offset, bool isIndented = false) const; 436 437 void ShowFocusAnimation(const RRect& rrect, const Color& color, const Offset& offset, const Rect& clipRect) const; 438 439 void ShowShadow(const RRect& rrect, const Offset& offset) const; 440 441 void ShowShadow(const RRect& rrect, const Offset& offset, const Rect& clipRect) const; 442 443 RefPtr<RenderFocusAnimation> GetRenderFocusAnimation() const; 444 445 void PushFocusAnimation(const RefPtr<Element>& element) const; 446 447 void PushShadow(const RefPtr<Element>& element) const; 448 449 void PopFocusAnimation() const; 450 451 void PopRootFocusAnimation() const; 452 453 void PopShadow() const; 454 455 void CancelFocusAnimation() const; 456 457 void CancelShadow() const; 458 459 void SetUseRootAnimation(bool useRoot); 460 461 void AddDirtyFocus(const RefPtr<FocusNode>& node); 462 463 void RefreshStageFocus(); 464 465 void ShowContainerTitle(bool isShow); 466 467 void BlurWindowWithDrag(bool isBlur); 468 469 RefPtr<StageElement> GetStageElement() const; 470 471 RefPtr<ComposedElement> GetComposedElementById(const ComposeId& id); 472 473 void SendCallbackMessageToFrontend(const std::string& callbackId, const std::string& data); 474 475 void SendEventToFrontend(const EventMarker& eventMarker); 476 477 void SendEventToFrontend(const EventMarker& eventMarker, const std::string& param); 478 479 bool AccessibilityRequestFocus(const ComposeId& id); 480 481 bool RequestFocus(const RefPtr<Element>& targetElement); 482 483 RefPtr<AccessibilityManager> GetAccessibilityManager() const; 484 485 void SendEventToAccessibility(const AccessibilityEvent& accessibilityEvent); 486 487 BaseId::IdType AddPageTransitionListener(const PageTransitionListenable::CallbackFuncType& funcObject); 488 489 const RefPtr<OverlayElement> GetOverlayElement() const; 490 491 void RemovePageTransitionListener(typename BaseId::IdType id); 492 493 void ClearPageTransitionListeners(); 494 495 void Destroy(); 496 GetFontManager()497 const RefPtr<FontManager>& GetFontManager() const 498 { 499 return fontManager_; 500 } 501 502 void RegisterFont(const std::string& familyName, const std::string& familySrc); 503 504 void TryLoadImageInfo(const std::string& src, std::function<void(bool, int32_t, int32_t)>&& loadCallback); 505 506 void SetAnimationCallback(AnimationCallback&& callback); 507 508 bool IsLastPage(); 509 510 void SetRootSize(double density, int32_t width, int32_t height); 511 512 RefPtr<Element> GetDeactivateElement(int32_t componentId) const; 513 514 void ClearDeactivateElements(); 515 516 void AddDeactivateElement(const int32_t id, const RefPtr<Element>& element); 517 GetRenderFactory()518 const RefPtr<RenderFactory>& GetRenderFactory() const 519 { 520 return renderFactory_; 521 } 522 523 #ifndef WEARABLE_PRODUCT 524 void SetMultimodalSubscriber(const RefPtr<MultimodalSubscriber>& multimodalSubscriber); 525 GetMultiModalManager()526 const RefPtr<MultiModalManager>& GetMultiModalManager() const 527 { 528 return multiModalManager_; 529 } 530 #endif 531 532 void SetWindowOnShow(); 533 534 void SetWindowOnHide(); 535 536 void OnShow(); 537 538 void OnHide(); 539 MarkForcedRefresh()540 void MarkForcedRefresh() 541 { 542 needForcedRefresh_ = true; 543 } 544 545 void SetTimeProvider(TimeProvider&& timeProvider); 546 547 uint64_t GetTimeFromExternalTimer(); 548 549 void SetFontScale(float fontScale); 550 551 void AddFontNode(const WeakPtr<RenderNode>& node); 552 553 void RemoveFontNode(const WeakPtr<RenderNode>& node); 554 GetFontScale()555 float GetFontScale() const 556 { 557 return fontScale_; 558 } 559 560 void UpdateFontWeightScale(); 561 562 void LoadSystemFont(const std::function<void()>& onFondsLoaded); 563 564 void NotifyFontNodes(); 565 GetSharedTransitionController()566 const RefPtr<SharedTransitionController>& GetSharedTransitionController() const 567 { 568 return sharedTransitionController_; 569 } 570 GetCardTransitionController()571 const RefPtr<CardTransitionController>& GetCardTransitionController() const 572 { 573 return cardTransitionController_; 574 } 575 576 void SetClickPosition(const Offset& position) const; 577 578 void SetTextFieldManager(const RefPtr<ManagerInterface>& manager); 579 580 void RootLostFocus() const; 581 582 void FlushFocus(); 583 SetIsRightToLeft(bool isRightToLeft)584 void SetIsRightToLeft(bool isRightToLeft) 585 { 586 isRightToLeft_ = isRightToLeft; 587 } 588 IsRightToLeft()589 bool IsRightToLeft() const 590 { 591 return isRightToLeft_; 592 } 593 GetMessageBridge()594 const RefPtr<PlatformBridge>& GetMessageBridge() const 595 { 596 return messageBridge_; 597 } SetMessageBridge(const RefPtr<PlatformBridge> & messageBridge)598 void SetMessageBridge(const RefPtr<PlatformBridge>& messageBridge) 599 { 600 messageBridge_ = messageBridge; 601 } 602 603 void SetOnPageShow(OnPageShowCallBack&& onPageShowCallBack); 604 605 void OnPageShow(); 606 GetStatusBarHeight()607 double GetStatusBarHeight() const 608 { 609 return statusBarHeight_; 610 } 611 GetNavigationBarHeight()612 double GetNavigationBarHeight() const 613 { 614 return navigationBarHeight_; 615 } 616 SetAppearingDuration(int32_t duration)617 void SetAppearingDuration(int32_t duration) 618 { 619 cardAppearingDuration_ = duration; 620 } 621 GetAppearingDuration()622 int32_t GetAppearingDuration() const 623 { 624 return cardAppearingDuration_; 625 } 626 SetWindowModal(WindowModal modal)627 void SetWindowModal(WindowModal modal) 628 { 629 windowModal_ = modal; 630 } 631 SetModalHeight(int32_t height)632 void SetModalHeight(int32_t height) 633 { 634 modalHeight_ = height; 635 } 636 SetModalColor(uint32_t color)637 void SetModalColor(uint32_t color) 638 { 639 modalColor_ = color; 640 } 641 642 void MovePage(const Offset& rootRect, double offsetHeight); 643 SetDrawDelegate(std::unique_ptr<DrawDelegate> delegate)644 void SetDrawDelegate(std::unique_ptr<DrawDelegate> delegate) 645 { 646 drawDelegate_ = std::move(delegate); 647 } 648 SetBuildAfterCallback(const std::function<void ()> & callback)649 void SetBuildAfterCallback(const std::function<void()>& callback) 650 { 651 buildAfterCallback_.emplace_back(callback); 652 } 653 GetThemeManager()654 RefPtr<ThemeManager> GetThemeManager() const 655 { 656 return themeManager_; 657 } 658 SetThemeManager(RefPtr<ThemeManager> theme)659 void SetThemeManager(RefPtr<ThemeManager> theme) 660 { 661 themeManager_ = theme; 662 } 663 664 void SetIsKeyEvent(bool isKeyEvent); 665 IsKeyEvent()666 bool IsKeyEvent() const 667 { 668 return isKeyEvent_; 669 } 670 SetIsJsCard(bool isJsCard)671 void SetIsJsCard(bool isJsCard) 672 { 673 isJsCard_ = isJsCard; 674 } 675 IsJsCard()676 bool IsJsCard() const 677 { 678 return isJsCard_; 679 } 680 SetIsJsPlugin(bool isJsPlugin)681 void SetIsJsPlugin(bool isJsPlugin) 682 { 683 isJsPlugin_ = isJsPlugin; 684 } 685 IsJsPlugin()686 bool IsJsPlugin() const 687 { 688 return isJsPlugin_; 689 } 690 691 void RefreshRootBgColor() const; 692 void AddToHoverList(const RefPtr<RenderNode>& node); 693 694 using UpdateWindowBlurRegionHandler = std::function<void(const std::vector<std::vector<float>>&)>; 695 SetUpdateWindowBlurRegionHandler(UpdateWindowBlurRegionHandler handler)696 void SetUpdateWindowBlurRegionHandler(UpdateWindowBlurRegionHandler handler) 697 { 698 updateWindowBlurRegionHandler_ = std::move(handler); 699 } 700 701 using DragEventHandler = std::function<void(const std::string&, const RefPtr<PixelMap>& pixmap)>; 702 SetDragEventHandler(DragEventHandler && callback)703 void SetDragEventHandler(DragEventHandler&& callback) 704 { 705 dragEventHandler_ = callback; 706 } 707 708 using InitDragEventListener = std::function<void()>; 709 SetInitDragListener(InitDragEventListener && callback)710 void SetInitDragListener(InitDragEventListener&& callback) 711 { 712 initDragEventListener_ = callback; 713 } 714 715 void UpdateWindowBlurRegion( 716 int32_t id, RRect rRect, float progress, WindowBlurStyle style, const std::vector<RRect>& coords); 717 718 void ClearWindowBlurRegion(int32_t id); 719 IsBuildingFirstPage()720 bool IsBuildingFirstPage() const 721 { 722 return buildingFirstPage_; 723 } 724 GetSharedImageManager()725 const RefPtr<SharedImageManager>& GetSharedImageManager() const 726 { 727 return sharedImageManager_; 728 } 729 SetSharedImageManager(const RefPtr<SharedImageManager> & sharedImageManager)730 void SetSharedImageManager(const RefPtr<SharedImageManager>& sharedImageManager) 731 { 732 sharedImageManager_ = sharedImageManager; 733 } 734 735 using UpdateWindowBlurDrawOpHandler = std::function<void(void)>; 736 SetUpdateWindowBlurDrawOpHandler(UpdateWindowBlurDrawOpHandler handler)737 void SetUpdateWindowBlurDrawOpHandler(UpdateWindowBlurDrawOpHandler handler) 738 { 739 updateWindowBlurDrawOpHandler_ = std::move(handler); 740 } 741 742 void NavigatePage(uint8_t type, const PageTarget& target, const std::string& params); 743 744 void ForceLayoutForImplicitAnimation(); 745 746 bool Animate(const AnimationOption& option, const RefPtr<Curve>& curve, 747 const std::function<void()>& propertyCallback, const std::function<void()>& finishCallBack = nullptr); 748 749 void OpenImplicitAnimation(const AnimationOption& option, const RefPtr<Curve>& curve, 750 const std::function<void()>& finishCallBack = nullptr); 751 752 bool CloseImplicitAnimation(); 753 754 void AddKeyFrame(float fraction, const RefPtr<Curve>& curve, const std::function<void()>& propertyCallback); 755 756 void AddKeyFrame(float fraction, const std::function<void()>& propertyCallback); 757 758 void SaveExplicitAnimationOption(const AnimationOption& option); 759 760 void CreateExplicitAnimator(const std::function<void()>& onFinishEvent); 761 762 void ClearExplicitAnimationOption(); 763 764 const AnimationOption GetExplicitAnimationOption() const; 765 766 void FlushBuild(); 767 GetInstanceId()768 int32_t GetInstanceId() const 769 { 770 return instanceId_; 771 } 772 SetUseLiteStyle(bool useLiteStyle)773 void SetUseLiteStyle(bool useLiteStyle) 774 { 775 useLiteStyle_ = useLiteStyle; 776 } 777 UseLiteStyle()778 bool UseLiteStyle() 779 { 780 return useLiteStyle_; 781 } 782 GetDirtyRect()783 const Rect& GetDirtyRect() const 784 { 785 return dirtyRect_; 786 } 787 788 bool GetIsDeclarative() const; 789 IsForbidePlatformQuit()790 bool IsForbidePlatformQuit() const 791 { 792 return forbidePlatformQuit_; 793 } 794 795 void SetForbidePlatformQuit(bool forbidePlatformQuit); 796 797 void SetAppBgColor(const Color& color); 798 GetAppBgColor()799 const Color& GetAppBgColor() const 800 { 801 return appBgColor_; 802 } 803 SetPhotoCachePath(const std::string & photoCachePath)804 void SetPhotoCachePath(const std::string& photoCachePath) 805 { 806 photoCachePath_ = photoCachePath; 807 } 808 GetPhotoCachePath()809 const std::string& GetPhotoCachePath() 810 { 811 return photoCachePath_; 812 } 813 GetMinPlatformVersion()814 int32_t GetMinPlatformVersion() const 815 { 816 return minPlatformVersion_; 817 } SetMinPlatformVersion(int32_t minPlatformVersion)818 void SetMinPlatformVersion(int32_t minPlatformVersion) 819 { 820 minPlatformVersion_ = minPlatformVersion; 821 } 822 SetGetViewScaleCallback(GetViewScaleCallback && callback)823 void SetGetViewScaleCallback(GetViewScaleCallback&& callback) 824 { 825 getViewScaleCallback_ = callback; 826 } 827 GetViewScale(float & scaleX,float & scaleY)828 bool GetViewScale(float& scaleX, float& scaleY) 829 { 830 if (getViewScaleCallback_) { 831 return getViewScaleCallback_(scaleX, scaleY); 832 } 833 return false; 834 } 835 SetScreenOnCallback(std::function<void (std::function<void ()> && func)> && screenOnCallback)836 void SetScreenOnCallback(std::function<void(std::function<void()>&& func)>&& screenOnCallback) 837 { 838 screenOnCallback_ = std::move(screenOnCallback); 839 } 840 SetScreenOffCallback(std::function<void (std::function<void ()> && func)> && screenOffCallback)841 void SetScreenOffCallback(std::function<void(std::function<void()>&& func)>&& screenOffCallback) 842 { 843 screenOffCallback_ = std::move(screenOffCallback); 844 } 845 GetTextFieldManager()846 const RefPtr<ManagerInterface>& GetTextFieldManager() 847 { 848 return textFieldManager_; 849 } 850 851 void AddScreenOnEvent(std::function<void()>&& func); 852 void AddScreenOffEvent(std::function<void()>&& func); 853 void AddAlignDeclarationNode(const RefPtr<RenderNode>& node); 854 void AddLayoutTransitionNode(const RefPtr<RenderNode>& node); 855 std::list<RefPtr<RenderNode>>& GetAlignDeclarationNodeList(); SetQueryIfWindowInScreenCallback(std::function<void ()> && func)856 void SetQueryIfWindowInScreenCallback(std::function<void()>&& func) 857 { 858 queryIfWindowInScreenCallback_ = std::move(func); 859 } SetIsWindowInScreen(bool isWindowInScreen)860 void SetIsWindowInScreen(bool isWindowInScreen) 861 { 862 isWindowInScreen_ = isWindowInScreen; 863 } 864 // This interface posts an async task to do async query and returns the result from previous query. 865 bool IsWindowInScreen(); 866 void NotifyOnPreDraw(); 867 void AddNodesToNotifyOnPreDraw(const RefPtr<RenderNode>& renderNode); 868 869 void UpdateNodesNeedDrawOnPixelMap(); 870 void SearchNodesNeedDrawOnPixelMap(const RefPtr<RenderNode>& renderNode); 871 void NotifyDrawOnPixelMap(); 872 GetRootElement()873 const RefPtr<RootElement>& GetRootElement() const 874 { 875 return rootElement_; 876 } 877 GetDataProviderManager()878 const RefPtr<DataProviderManagerInterface>& GetDataProviderManager() const 879 { 880 return dataProviderManager_; 881 } SetDataProviderManager(const RefPtr<DataProviderManagerInterface> & dataProviderManager)882 void SetDataProviderManager(const RefPtr<DataProviderManagerInterface>& dataProviderManager) 883 { 884 dataProviderManager_ = dataProviderManager; 885 } 886 887 #if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM) SetCurrentUrl(const std::string & url)888 void SetCurrentUrl(const std::string& url) 889 { 890 currentUrl_ = url; 891 } 892 GetCurrentUrl()893 const std::string& GetCurrentUrl() 894 { 895 return currentUrl_; 896 } 897 #endif 898 GetWindowId()899 int32_t GetWindowId() const 900 { 901 return windowId_; 902 } 903 SetWindowId(int32_t windowId)904 void SetWindowId(int32_t windowId) 905 { 906 windowId_ = windowId; 907 } 908 SetAccessibilityEnabled(bool isEnabled)909 void SetAccessibilityEnabled(bool isEnabled) 910 { 911 isAccessibilityEnabled_ = isEnabled; 912 } IsAccessibilityEnabled()913 bool IsAccessibilityEnabled() const 914 { 915 return isAccessibilityEnabled_ || IsVisibleChangeNodeExists(-1); 916 } 917 918 bool IsVisibleChangeNodeExists(NodeId index) const; 919 RegisterSurfaceChangedCallback(std::function<void (int32_t,int32_t,int32_t,int32_t)> && callback)920 int32_t RegisterSurfaceChangedCallback(std::function<void(int32_t, int32_t, int32_t, int32_t)>&& callback) 921 { 922 if (callback) { 923 surfaceChangedCallbackMap_.emplace(++callbackId_, std::move(callback)); 924 return callbackId_; 925 } 926 return 0; 927 } 928 UnregisterSurfaceChangedCallback(int32_t callbackId)929 void UnregisterSurfaceChangedCallback(int32_t callbackId) 930 { 931 surfaceChangedCallbackMap_.erase(callbackId); 932 } 933 void StartSystemDrag(const std::string& str, const RefPtr<PixelMap>& pixmap); 934 void InitDragListener(); 935 void OnDragEvent(int32_t x, int32_t y, DragEventAction action); 936 void SetPreTargetRenderNode(const RefPtr<RenderNode>& preTargetRenderNode); 937 const RefPtr<RenderNode> GetPreTargetRenderNode() const; 938 void SetInitRenderNode(const RefPtr<RenderNode>& initRenderNode); 939 const RefPtr<RenderNode>& GetInitRenderNode() const; 940 SetContextMenu(const RefPtr<Component> & contextMenu)941 void SetContextMenu(const RefPtr<Component>& contextMenu) 942 { 943 contextMenu_ = contextMenu; 944 } 945 GetDensity()946 double GetDensity() const 947 { 948 return density_; 949 } 950 951 void RequestFrame(); 952 953 void SetClipHole(double left, double top, double width, double height); 954 GetTransparentHole()955 const Rect& GetTransparentHole() const 956 { 957 return transparentHole_; 958 } 959 GetHasMeetSubWindowNode()960 bool GetHasMeetSubWindowNode() const 961 { 962 return hasMeetSubWindowNode_; 963 } 964 SetHasMeetSubWindowNode(bool hasMeetSubWindowNode)965 void SetHasMeetSubWindowNode(bool hasMeetSubWindowNode) 966 { 967 hasMeetSubWindowNode_ = hasMeetSubWindowNode; 968 } 969 GetHasClipHole()970 bool GetHasClipHole() const 971 { 972 return hasClipHole_; 973 } 974 SetHasClipHole(bool hasClipHole)975 void SetHasClipHole(bool hasClipHole) 976 { 977 hasClipHole_ = hasClipHole; 978 } 979 GetIsHoleValid()980 bool GetIsHoleValid() const 981 { 982 return isHoleValid_; 983 } 984 SetPluginOffset(const Offset & offset)985 void SetPluginOffset(const Offset& offset) 986 { 987 pluginOffset_ = offset; 988 } 989 GetPluginOffset()990 Offset GetPluginOffset() const 991 { 992 return pluginOffset_; 993 } 994 SetPluginEventOffset(const Offset & offset)995 void SetPluginEventOffset(const Offset& offset) 996 { 997 pluginEventOffset_ = offset; 998 } 999 GetPluginEventOffset()1000 Offset GetPluginEventOffset() const 1001 { 1002 return pluginEventOffset_; 1003 } 1004 1005 void SetTouchPipeline(WeakPtr<PipelineContext> context); 1006 void RemoveTouchPipeline(WeakPtr<PipelineContext> context); 1007 IsRebuildFinished()1008 bool IsRebuildFinished() const 1009 { 1010 return isRebuildFinished_; 1011 } 1012 1013 void SetRSUIDirector(std::shared_ptr<OHOS::Rosen::RSUIDirector> rsUIDirector); 1014 1015 std::shared_ptr<OHOS::Rosen::RSUIDirector> GetRSUIDirector(); 1016 SetOnVsyncProfiler(const std::function<void (const std::string &)> callback)1017 void SetOnVsyncProfiler(const std::function<void(const std::string&)> callback) 1018 { 1019 onVsyncProfiler_ = callback; 1020 } 1021 ResetOnVsyncProfiler()1022 void ResetOnVsyncProfiler() 1023 { 1024 onVsyncProfiler_ = nullptr; 1025 } 1026 IsShiftDown()1027 bool IsShiftDown() const 1028 { 1029 return isShiftDown_; 1030 } 1031 MarkIsShiftDown(bool isShiftDown)1032 void MarkIsShiftDown(bool isShiftDown) 1033 { 1034 isShiftDown_ = isShiftDown; 1035 } 1036 IsCtrlDown()1037 bool IsCtrlDown() const 1038 { 1039 return isCtrlDown_; 1040 } 1041 MarkIsCtrlDown(bool isCtrlDown)1042 void MarkIsCtrlDown(bool isCtrlDown) 1043 { 1044 isCtrlDown_ = isCtrlDown; 1045 } 1046 IsKeyboardA()1047 bool IsKeyboardA() const 1048 { 1049 return isKeyboardA_; 1050 } 1051 MarkIsKeyboardA(bool isKeyboardA)1052 void MarkIsKeyboardA(bool isKeyboardA) 1053 { 1054 isKeyboardA_ = isKeyboardA; 1055 } 1056 1057 void SetShortcutKey(const KeyEvent& event); 1058 GetEventManager()1059 EventManager GetEventManager() const 1060 { 1061 return eventManager_; 1062 } 1063 SubscribeCtrlA(SubscribeCtrlACallback callback)1064 void SubscribeCtrlA(SubscribeCtrlACallback callback) 1065 { 1066 subscribeCtrlA_ = callback; 1067 } 1068 SetWindowMinimizeCallBack(std::function<bool (void)> && callback)1069 void SetWindowMinimizeCallBack(std::function<bool(void)>&& callback) 1070 { 1071 windowMinimizeCallback_ = std::move(callback); 1072 } 1073 SetWindowMaximizeCallBack(std::function<bool (void)> && callback)1074 void SetWindowMaximizeCallBack(std::function<bool(void)>&& callback) 1075 { 1076 windowMaximizeCallback_ = std::move(callback); 1077 } 1078 SetWindowRecoverCallBack(std::function<bool (void)> && callback)1079 void SetWindowRecoverCallBack(std::function<bool(void)>&& callback) 1080 { 1081 windowRecoverCallback_ = std::move(callback); 1082 } 1083 SetWindowCloseCallBack(std::function<bool (void)> && callback)1084 void SetWindowCloseCallBack(std::function<bool(void)>&& callback) 1085 { 1086 windowCloseCallback_ = std::move(callback); 1087 } 1088 SetWindowSplitCallBack(std::function<bool (void)> && callback)1089 void SetWindowSplitCallBack(std::function<bool(void)>&& callback) 1090 { 1091 windowSplitCallback_ = std::move(callback); 1092 } 1093 SetWindowGetModeCallBack(std::function<WindowMode (void)> && callback)1094 void SetWindowGetModeCallBack(std::function<WindowMode(void)>&& callback) 1095 { 1096 windowGetModeCallback_ = std::move(callback); 1097 } 1098 SetWindowStartMoveCallBack(std::function<void (void)> && callback)1099 void SetWindowStartMoveCallBack(std::function<void(void)>&& callback) 1100 { 1101 windowStartMoveCallback_ = std::move(callback); 1102 } 1103 SetGetWindowRectImpl(std::function<Rect ()> && callback)1104 void SetGetWindowRectImpl(std::function<Rect()>&& callback) 1105 { 1106 windowRectImpl_ = std::move(callback); 1107 } 1108 GetCurrentWindowRect()1109 Rect GetCurrentWindowRect() const 1110 { 1111 Rect rect; 1112 if (windowRectImpl_) { 1113 rect = windowRectImpl_(); 1114 } 1115 return rect; 1116 } 1117 FireWindowMinimizeCallBack()1118 bool FireWindowMinimizeCallBack() const 1119 { 1120 if (windowMinimizeCallback_) { 1121 return windowMinimizeCallback_(); 1122 } 1123 return false; 1124 } 1125 FireWindowMaximizeCallBack()1126 bool FireWindowMaximizeCallBack() const 1127 { 1128 if (windowMaximizeCallback_) { 1129 return windowMaximizeCallback_(); 1130 } 1131 return false; 1132 } 1133 FireWindowRecoverCallBack()1134 bool FireWindowRecoverCallBack() const 1135 { 1136 if (windowRecoverCallback_) { 1137 return windowRecoverCallback_(); 1138 } 1139 return false; 1140 } 1141 FireWindowSplitCallBack()1142 bool FireWindowSplitCallBack() const 1143 { 1144 if (windowSplitCallback_) { 1145 return windowSplitCallback_(); 1146 } 1147 return false; 1148 } 1149 FireWindowCloseCallBack()1150 bool FireWindowCloseCallBack() const 1151 { 1152 if (windowCloseCallback_) { 1153 return windowCloseCallback_(); 1154 } 1155 return false; 1156 } 1157 FireWindowStartMoveCallBack()1158 void FireWindowStartMoveCallBack() const 1159 { 1160 if (windowStartMoveCallback_) { 1161 windowStartMoveCallback_(); 1162 } 1163 } 1164 FireWindowGetModeCallBack()1165 WindowMode FireWindowGetModeCallBack() const 1166 { 1167 if (windowGetModeCallback_) { 1168 return windowGetModeCallback_(); 1169 } 1170 return WindowMode::WINDOW_MODE_UNDEFINED; 1171 } 1172 SetAppIconId(int32_t id)1173 void SetAppIconId(int32_t id) 1174 { 1175 appIconId_ = id; 1176 } 1177 GetAppIconId()1178 int32_t GetAppIconId() const 1179 { 1180 return appIconId_; 1181 } 1182 SetAppLabelId(int32_t id)1183 void SetAppLabelId(int32_t id) 1184 { 1185 appLabelId_ = id; 1186 } 1187 GetAppLabelId()1188 int32_t GetAppLabelId() const 1189 { 1190 return appLabelId_; 1191 } 1192 SetClipboardCallback(const std::function<void (const std::string &)> & callback)1193 void SetClipboardCallback(const std::function<void(const std::string&)>& callback) 1194 { 1195 clipboardCallback_ = callback; 1196 } 1197 1198 void ProcessDragEvent( 1199 const RefPtr<RenderNode>& renderNode, const RefPtr<DragEvent>& event, const Point& globalPoint); 1200 void ProcessDragEventEnd( 1201 const RefPtr<RenderNode>& renderNode, const RefPtr<DragEvent>& event, const Point& globalPoint); 1202 1203 void StoreNode(int32_t restoreId, const WeakPtr<RenderElement>& node); 1204 1205 std::unique_ptr<JsonValue> GetStoredNodeInfo(); 1206 1207 void RestoreNodeInfo(std::unique_ptr<JsonValue> nodeInfo); 1208 1209 std::string GetRestoreInfo(int32_t restoreId); 1210 SetIsSubPipeline(bool isSubPipeline)1211 void SetIsSubPipeline(bool isSubPipeline) 1212 { 1213 isSubPipeline_ = isSubPipeline; 1214 } 1215 IsSubPipeline()1216 bool IsSubPipeline() const 1217 { 1218 return isSubPipeline_; 1219 } 1220 GetIsDragStart()1221 bool GetIsDragStart() const 1222 { 1223 return isDragStart_; 1224 } 1225 1226 private: 1227 void FlushVsync(uint64_t nanoTimestamp, uint32_t frameCount); 1228 void FlushPipelineWithoutAnimation(); 1229 void FlushLayout(); 1230 void FlushGeometryProperties(); 1231 void FlushRender(); 1232 void FlushMessages(); 1233 void FlushRenderFinish(); 1234 void FireVisibleChangeEvent(); 1235 void FlushPredictLayout(int64_t deadline); 1236 void FlushAnimation(uint64_t nanoTimestamp); 1237 void FlushPostAnimation(); 1238 void FlushPageUpdateTasks(); 1239 void ProcessPreFlush(); 1240 void ProcessPostFlush(); 1241 void SetRootSizeWithWidthHeight(int32_t width, int32_t height, int32_t offset = 0); 1242 void SetRootRect(double width, double height, double offset = 0.0) const; 1243 void FlushBuildAndLayoutBeforeSurfaceReady(); 1244 void FlushAnimationTasks(); 1245 void DumpAccessibility(const std::vector<std::string>& params) const; 1246 void FlushWindowBlur(); 1247 void MakeThreadStuck(const std::vector<std::string>& params) const; 1248 void DumpFrontend() const; 1249 void ExitAnimation(); 1250 void CreateGeometryTransition(); 1251 void CorrectPosition(); 1252 1253 template<typename T> 1254 struct NodeCompare { operatorNodeCompare1255 bool operator()(const T& nodeLeft, const T& nodeRight) 1256 { 1257 if (nodeLeft->GetDepth() < nodeRight->GetDepth()) { 1258 return true; 1259 } else if (nodeLeft->GetDepth() == nodeRight->GetDepth()) { 1260 return nodeLeft < nodeRight; 1261 } 1262 return false; 1263 } 1264 }; 1265 1266 template<typename T> 1267 struct NodeCompareWeak { operatorNodeCompareWeak1268 bool operator()(const T& nodeLeftWeak, const T& nodeRightWeak) 1269 { 1270 auto nodeLeft = nodeLeftWeak.Upgrade(); 1271 auto nodeRight = nodeRightWeak.Upgrade(); 1272 if (!nodeLeft || !nodeRight) { 1273 return false; 1274 } 1275 auto compare = NodeCompare<decltype(nodeLeft)>(); 1276 return compare(nodeLeft, nodeRight); 1277 } 1278 }; 1279 1280 Rect dirtyRect_; 1281 uint32_t nextScheduleTaskId_ = 0; 1282 std::unordered_map<uint32_t, RefPtr<ScheduleTask>> scheduleTasks_; 1283 std::unordered_map<ComposeId, std::list<RefPtr<ComposedElement>>> composedElementMap_; 1284 std::set<WeakPtr<Element>, NodeCompareWeak<WeakPtr<Element>>> dirtyElements_; 1285 std::set<WeakPtr<Element>, NodeCompareWeak<WeakPtr<Element>>> needRebuildFocusElement_; 1286 std::set<RefPtr<RenderNode>, NodeCompare<RefPtr<RenderNode>>> dirtyRenderNodes_; 1287 std::set<RefPtr<RenderNode>, NodeCompare<RefPtr<RenderNode>>> dirtyRenderNodesInOverlay_; 1288 std::set<RefPtr<RenderNode>, NodeCompare<RefPtr<RenderNode>>> dirtyLayoutNodes_; 1289 std::set<RefPtr<RenderNode>, NodeCompare<RefPtr<RenderNode>>> predictLayoutNodes_; 1290 std::set<RefPtr<RenderNode>, NodeCompare<RefPtr<RenderNode>>> needPaintFinishNodes_; 1291 std::set<RefPtr<RenderNode>, NodeCompare<RefPtr<RenderNode>>> geometryChangedNodes_; 1292 std::set<RefPtr<RenderNode>> nodesToNotifyOnPreDraw_; 1293 std::set<RefPtr<RenderNode>> nodesNeedDrawOnPixelMap_; 1294 std::list<RefPtr<FlushEvent>> postFlushListeners_; 1295 std::list<RefPtr<FlushEvent>> postAnimationFlushListeners_; 1296 std::list<RefPtr<FlushEvent>> preFlushListeners_; 1297 std::unique_ptr<Window> window_; 1298 RefPtr<FocusAnimationManager> focusAnimationManager_; 1299 RefPtr<TaskExecutor> taskExecutor_; 1300 RefPtr<AssetManager> assetManager_; 1301 RefPtr<DataProviderManagerInterface> dataProviderManager_; 1302 RefPtr<PlatformResRegister> platformResRegister_; 1303 RefPtr<RootElement> rootElement_; 1304 RefPtr<FocusNode> dirtyFocusNode_; 1305 RefPtr<FocusNode> dirtyFocusScope_; 1306 WeakPtr<Frontend> weakFrontend_; 1307 RefPtr<ImageCache> imageCache_; 1308 RefPtr<FontManager> fontManager_; 1309 RefPtr<ThemeManager> themeManager_; 1310 RefPtr<SharedImageManager> sharedImageManager_; 1311 std::list<std::function<void()>> buildAfterCallback_; 1312 RefPtr<RenderFactory> renderFactory_; 1313 UpdateWindowBlurRegionHandler updateWindowBlurRegionHandler_; 1314 UpdateWindowBlurDrawOpHandler updateWindowBlurDrawOpHandler_; 1315 DragEventHandler dragEventHandler_; 1316 InitDragEventListener initDragEventListener_; 1317 GetViewScaleCallback getViewScaleCallback_; 1318 std::stack<bool> pendingImplicitLayout_; 1319 1320 Rect transparentHole_; 1321 // use for traversing cliping hole 1322 bool hasMeetSubWindowNode_ = false; 1323 // use for judge clip hole status 1324 bool hasClipHole_ = false; 1325 // judge hole is valid 1326 bool isHoleValid_ = false; 1327 1328 #ifndef WEARABLE_PRODUCT 1329 RefPtr<MultiModalManager> multiModalManager_ = MakeRefPtr<MultiModalManager>(); 1330 #endif 1331 RefPtr<SharedTransitionController> sharedTransitionController_; 1332 RefPtr<CardTransitionController> cardTransitionController_; 1333 EventManager eventManager_; 1334 EventTrigger eventTrigger_; 1335 FinishEventHandler finishEventHandler_; 1336 ActionEventHandler actionEventHandler_; 1337 StatusBarEventHandler statusBarBgColorEventHandler_; 1338 PopupEventHandler popupEventHandler_; 1339 RouterBackEventHandler routerBackEventHandler_; 1340 std::list<PopPageSuccessEventHandler> popPageSuccessEventHandler_; 1341 std::list<IsPagePathInvalidEventHandler> isPagePathInvalidEventHandler_; 1342 std::list<DestroyEventHandler> destroyEventHandler_; 1343 std::list<DispatchTouchEventHandler> dispatchTouchEventHandler_; 1344 1345 RefPtr<ManagerInterface> textFieldManager_; 1346 RefPtr<PlatformBridge> messageBridge_; 1347 WeakPtr<RenderNode> requestedRenderNode_; 1348 // Make page update tasks pending here to avoid block receiving vsync. 1349 std::queue<std::function<void()>> pageUpdateTasks_; 1350 // strong deactivate element and it's id. 1351 std::map<int32_t, RefPtr<Element>> deactivateElements_; 1352 1353 RefPtr<Component> contextMenu_; 1354 // animation frame callback 1355 AnimationCallback animationCallback_; 1356 1357 // window blur region 1358 std::unordered_map<int32_t, WindowBlurInfo> windowBlurRegions_; 1359 1360 std::list<RefPtr<RenderNode>> alignDeclarationNodeList_; 1361 std::set<RefPtr<RenderNode>> layoutTransitionNodeSet_; 1362 1363 std::function<void()> queryIfWindowInScreenCallback_; 1364 std::atomic<bool> isWindowInScreen_ = true; 1365 1366 RefPtr<RenderNode> preTargetRenderNode_; 1367 1368 bool isRightToLeft_ = false; 1369 bool isSurfaceReady_ = false; 1370 float viewScale_ = 1.0f; 1371 float fontScale_ = 1.0f; 1372 double density_ = 1.0; 1373 double dipScale_ = 1.0; 1374 float designWidthScale_ = 1.0; 1375 1376 int32_t cardAppearingDuration_ = 0; 1377 double statusBarHeight_ = 0.0; // dp 1378 double navigationBarHeight_ = 0.0; // dp 1379 double rootHeight_ = 0.0; 1380 double rootWidth_ = 0.0; 1381 bool needForcedRefresh_ = false; 1382 bool isFlushingAnimation_ = false; 1383 bool hasIdleTasks_ = false; 1384 bool isMoving_ = false; 1385 std::atomic<bool> onShow_ = true; 1386 bool isKeyEvent_ = false; 1387 bool needWindowBlurRegionRefresh_ = false; 1388 bool isJsCard_ = false; 1389 bool isJsPlugin_ = false; 1390 bool useLiteStyle_ = false; 1391 bool isFirstLoaded_ = true; 1392 bool isDragStart_ = false; 1393 bool isFirstDrag_ = true; 1394 uint64_t flushAnimationTimestamp_ = 0; 1395 TimeProvider timeProvider_; 1396 OnPageShowCallBack onPageShowCallBack_; 1397 WindowModal windowModal_ = WindowModal::NORMAL; 1398 int32_t modalHeight_ = 0; 1399 int32_t hoverNodeId_ = DEFAULT_HOVER_ENTER_ANIMATION_ID; 1400 uint32_t modalColor_ = 0x00000000; 1401 bool isFullWindow_ = false; 1402 std::list<RefPtr<RenderNode>> hoverNodes_; 1403 std::unique_ptr<DrawDelegate> drawDelegate_; 1404 std::function<void(std::function<void()>&&)> screenOffCallback_; 1405 std::function<void(std::function<void()>&&)> screenOnCallback_; 1406 #if defined(ENABLE_NATIVE_VIEW) 1407 int32_t frameCount_ = 0; 1408 #endif 1409 1410 Color appBgColor_ = Color::WHITE; 1411 int32_t width_ = 0; 1412 int32_t height_ = 0; 1413 bool isFirstPage_ = true; 1414 bool buildingFirstPage_ = false; 1415 bool forbidePlatformQuit_ = false; 1416 FrontendType frontendType_; 1417 int32_t instanceId_ = 0; 1418 int32_t minPlatformVersion_ = 0; 1419 std::string photoCachePath_; 1420 AnimationOption explicitAnimationOption_; 1421 std::map<int32_t, RefPtr<Animator>> explicitAnimators_; 1422 OnRouterChangeCallback OnRouterChangeCallback_ = nullptr; 1423 bool isAccessibilityEnabled_ = false; 1424 #if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM) 1425 std::string currentUrl_; 1426 #endif 1427 int32_t windowId_ = 0; 1428 1429 int32_t callbackId_ = 0; 1430 SurfaceChangedCallbackMap surfaceChangedCallbackMap_; 1431 1432 std::vector<WeakPtr<PipelineContext>> touchPluginPipelineContext_; 1433 Offset pluginOffset_ { 0, 0 }; 1434 Offset pluginEventOffset_ { 0, 0 }; 1435 1436 bool isRebuildFinished_ = false; 1437 std::shared_ptr<OHOS::Rosen::RSUIDirector> rsUIDirector_; 1438 1439 std::function<void(const std::string&)> onVsyncProfiler_; 1440 1441 bool isShiftDown_ = false; 1442 bool isCtrlDown_ = false; 1443 bool isKeyboardA_ = false; 1444 SubscribeCtrlACallback subscribeCtrlA_; 1445 1446 int32_t appLabelId_ = 0; 1447 int32_t appIconId_ = 0; 1448 std::function<bool(void)> windowMinimizeCallback_ = nullptr; 1449 std::function<bool(void)> windowMaximizeCallback_ = nullptr; 1450 std::function<bool(void)> windowRecoverCallback_ = nullptr; 1451 std::function<bool(void)> windowCloseCallback_ = nullptr; 1452 std::function<bool(void)> windowSplitCallback_ = nullptr; 1453 std::function<void(void)> windowStartMoveCallback_ = nullptr; 1454 std::function<WindowMode(void)> windowGetModeCallback_ = nullptr; 1455 std::function<Rect()> windowRectImpl_ = nullptr; 1456 1457 std::function<void(const std::string&)> clipboardCallback_ = nullptr; 1458 Size selectedItemSize_ { 0.0, 0.0 }; 1459 size_t selectedIndex_ = -1; 1460 size_t insertIndex_ = -1; 1461 RefPtr<Clipboard> clipboard_; 1462 RefPtr<RenderNode> initRenderNode_; 1463 std::string customDragInfo_; 1464 Offset pageOffset_; 1465 1466 std::unordered_map<int32_t, WeakPtr<RenderElement>> storeNode_; 1467 std::unordered_map<int32_t, std::string> restoreNodeInfo_; 1468 1469 bool isSubPipeline_ = false; 1470 1471 ACE_DISALLOW_COPY_AND_MOVE(PipelineContext); 1472 }; 1473 1474 } // namespace OHOS::Ace 1475 1476 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_PIPELINE_CONTEXT_H 1477