1 /* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_FRAME_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_FRAME_NODE_H 18 19 #include <functional> 20 #include <list> 21 #include <utility> 22 23 #include "base/geometry/ng/offset_t.h" 24 #include "base/geometry/ng/point_t.h" 25 #include "base/geometry/ng/rect_t.h" 26 #include "base/geometry/ng/vector.h" 27 #include "base/memory/ace_type.h" 28 #include "base/memory/referenced.h" 29 #include "base/thread/cancelable_callback.h" 30 #include "base/thread/task_executor.h" 31 #include "base/utils/macros.h" 32 #include "base/utils/utils.h" 33 #include "core/accessibility/accessibility_utils.h" 34 #include "core/common/recorder/exposure_processor.h" 35 #include "core/common/resource/resource_configuration.h" 36 #include "core/components/common/layout/constants.h" 37 #include "core/components_ng/base/extension_handler.h" 38 #include "core/components_ng/base/frame_scene_status.h" 39 #include "core/components_ng/base/geometry_node.h" 40 #include "core/components_ng/base/modifier.h" 41 #include "core/components_ng/base/ui_node.h" 42 #include "core/components_ng/event/event_hub.h" 43 #include "core/components_ng/event/focus_hub.h" 44 #include "core/components_ng/event/gesture_event_hub.h" 45 #include "core/components_ng/event/input_event_hub.h" 46 #include "core/components_ng/event/target_component.h" 47 #include "core/components_ng/layout/layout_property.h" 48 #include "core/components_ng/property/accessibility_property.h" 49 #include "core/components_ng/property/layout_constraint.h" 50 #include "core/components_ng/property/property.h" 51 #include "core/components_ng/render/paint_property.h" 52 #include "core/components_ng/render/paint_wrapper.h" 53 #include "core/components_ng/render/render_context.h" 54 #include "core/components_v2/inspector/inspector_constants.h" 55 #include "core/components_v2/inspector/inspector_node.h" 56 57 namespace OHOS::Accessibility { 58 class AccessibilityElementInfo; 59 class AccessibilityEventInfo; 60 } // namespace OHOS::Accessibility 61 62 namespace OHOS::Ace::NG { 63 class InspectorFilter; 64 class PipelineContext; 65 class Pattern; 66 class StateModifyTask; 67 class UITask; 68 struct DirtySwapConfig; 69 70 struct CacheVisibleRectResult { 71 OffsetF windowOffset = OffsetF(); 72 RectF visibleRect = RectF(); 73 RectF innerVisibleRect = RectF(); 74 VectorF cumulativeScale = {1.0f, 1.0f}; 75 RectF frameRect = RectF(); 76 RectF innerBoundaryRect = RectF(); 77 }; 78 79 // FrameNode will display rendering region in the screen. 80 class ACE_FORCE_EXPORT FrameNode : public UINode, public LayoutWrapper { 81 DECLARE_ACE_TYPE(FrameNode, UINode, LayoutWrapper); 82 83 private: 84 class FrameProxy; 85 86 public: 87 // create a new child element with new element tree. 88 static RefPtr<FrameNode> CreateFrameNodeWithTree( 89 const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern); 90 91 static RefPtr<FrameNode> GetOrCreateFrameNode( 92 const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator); 93 94 static RefPtr<FrameNode> GetOrCreateCommonNode(const std::string& tag, int32_t nodeId, bool isLayoutNode, 95 const std::function<RefPtr<Pattern>(void)>& patternCreator); 96 97 // create a new element with new pattern. 98 static RefPtr<FrameNode> CreateFrameNode( 99 const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern, bool isRoot = false); 100 101 static RefPtr<FrameNode> CreateCommonNode(const std::string& tag, int32_t nodeId, bool isLayoutNode, 102 const RefPtr<Pattern>& pattern, bool isRoot = false); 103 104 // get element with nodeId from node map. 105 static RefPtr<FrameNode> GetFrameNode(const std::string& tag, int32_t nodeId); 106 107 static void ProcessOffscreenNode(const RefPtr<FrameNode>& node); 108 // avoid use creator function, use CreateFrameNode 109 110 FrameNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern, 111 bool isRoot = false, bool isLayoutNode = false); 112 113 ~FrameNode() override; 114 FrameCount()115 int32_t FrameCount() const override 116 { 117 return 1; 118 } 119 CurrentFrameCount()120 int32_t CurrentFrameCount() const override 121 { 122 return 1; 123 } 124 SetCheckboxFlag(const bool checkboxFlag)125 void SetCheckboxFlag(const bool checkboxFlag) 126 { 127 checkboxFlag_ = checkboxFlag; 128 } 129 GetCheckboxFlag()130 bool GetCheckboxFlag() const 131 { 132 return checkboxFlag_; 133 } 134 SetDisallowDropForcedly(bool isDisallowDropForcedly)135 void SetDisallowDropForcedly(bool isDisallowDropForcedly) 136 { 137 isDisallowDropForcedly_ = isDisallowDropForcedly; 138 } 139 GetDisallowDropForcedly()140 bool GetDisallowDropForcedly() const 141 { 142 return isDisallowDropForcedly_; 143 } 144 145 void OnInspectorIdUpdate(const std::string& id) override; 146 147 void UpdateGeometryTransition() override; 148 149 struct ZIndexComparator { operatorZIndexComparator150 bool operator()(const WeakPtr<FrameNode>& weakLeft, const WeakPtr<FrameNode>& weakRight) const 151 { 152 auto left = weakLeft.Upgrade(); 153 auto right = weakRight.Upgrade(); 154 if (left && right) { 155 return left->GetRenderContext()->GetZIndexValue(ZINDEX_DEFAULT_VALUE) < 156 right->GetRenderContext()->GetZIndexValue(ZINDEX_DEFAULT_VALUE); 157 } 158 return false; 159 } 160 }; 161 GetFrameChildren()162 const std::multiset<WeakPtr<FrameNode>, ZIndexComparator>& GetFrameChildren() const 163 { 164 return frameChildren_; 165 } 166 167 void InitializePatternAndContext(); 168 169 virtual void MarkModifyDone(); 170 171 void MarkDirtyNode(PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL) override; 172 173 void ProcessFreezeNode(); 174 175 void OnFreezeStateChange() override; 176 ProcessPropertyDiff()177 void ProcessPropertyDiff() 178 { 179 if (isPropertyDiffMarked_) { 180 MarkModifyDone(); 181 MarkDirtyNode(); 182 isPropertyDiffMarked_ = false; 183 } 184 } 185 186 void FlushUpdateAndMarkDirty() override; 187 188 void MarkNeedFrameFlushDirty(PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL) override 189 { 190 MarkDirtyNode(extraFlag); 191 } 192 193 void OnMountToParentDone(); 194 195 void AfterMountToParent() override; 196 197 bool GetIsLayoutNode(); 198 199 bool GetIsFind(); 200 201 void SetIsFind(bool isFind); 202 203 void GetOneDepthVisibleFrame(std::list<RefPtr<FrameNode>>& children); 204 205 void GetOneDepthVisibleFrameWithOffset(std::list<RefPtr<FrameNode>>& children, OffsetF& offset); 206 207 void UpdateLayoutConstraint(const MeasureProperty& calcLayoutConstraint); 208 209 RefPtr<LayoutWrapperNode> CreateLayoutWrapper(bool forceMeasure = false, bool forceLayout = false) override; 210 211 RefPtr<LayoutWrapperNode> UpdateLayoutWrapper( 212 RefPtr<LayoutWrapperNode> layoutWrapper, bool forceMeasure = false, bool forceLayout = false); 213 214 void CreateLayoutTask(bool forceUseMainThread = false); 215 216 std::optional<UITask> CreateRenderTask(bool forceUseMainThread = false); 217 218 void SwapDirtyLayoutWrapperOnMainThread(const RefPtr<LayoutWrapper>& dirty); 219 220 // Clear the user callback. 221 void ClearUserOnAreaChange(); 222 223 void SetOnAreaChangeCallback(OnAreaChangedFunc&& callback); 224 225 void TriggerOnAreaChangeCallback(uint64_t nanoTimestamp); 226 227 void OnConfigurationUpdate(const ConfigurationChange& configurationChange) override; 228 SetVisibleAreaUserCallback(const std::vector<double> & ratios,const VisibleCallbackInfo & callback)229 void SetVisibleAreaUserCallback(const std::vector<double>& ratios, const VisibleCallbackInfo& callback) 230 { 231 eventHub_->SetVisibleAreaRatiosAndCallback(callback, ratios, true); 232 } 233 234 void CleanVisibleAreaUserCallback(bool isApproximate = false) 235 { 236 if (isApproximate) { 237 eventHub_->CleanVisibleAreaCallback(true, isApproximate); 238 } else { 239 eventHub_->CleanVisibleAreaCallback(true, false); 240 } 241 } 242 243 void SetVisibleAreaInnerCallback(const std::vector<double>& ratios, const VisibleCallbackInfo& callback, 244 bool isCalculateInnerClip = false) 245 { 246 isCalculateInnerVisibleRectClip_ = isCalculateInnerClip; 247 eventHub_->SetVisibleAreaRatiosAndCallback(callback, ratios, false); 248 } 249 250 void SetIsCalculateInnerClip(bool isCalculateInnerClip = false) 251 { 252 isCalculateInnerVisibleRectClip_ = isCalculateInnerClip; 253 } 254 CleanVisibleAreaInnerCallback()255 void CleanVisibleAreaInnerCallback() 256 { 257 eventHub_->CleanVisibleAreaCallback(false); 258 } 259 260 void TriggerVisibleAreaChangeCallback(uint64_t timestamp, bool forceDisappear = false); 261 262 void SetOnSizeChangeCallback(OnSizeChangedFunc&& callback); 263 264 void AddInnerOnSizeChangeCallback(int32_t id, OnSizeChangedFunc&& callback); 265 266 void SetJSFrameNodeOnSizeChangeCallback(OnSizeChangedFunc&& callback); 267 268 void TriggerOnSizeChangeCallback(); 269 270 void SetGeometryNode(const RefPtr<GeometryNode>& node); 271 GetRenderContext()272 const RefPtr<RenderContext>& GetRenderContext() const 273 { 274 return renderContext_; 275 } 276 277 const RefPtr<Pattern>& GetPattern() const; 278 279 template<typename T> GetPatternPtr()280 T* GetPatternPtr() const 281 { 282 return reinterpret_cast<T*>(RawPtr(pattern_)); 283 } 284 285 template<typename T> GetPattern()286 RefPtr<T> GetPattern() const 287 { 288 return DynamicCast<T>(pattern_); 289 } 290 291 template<typename T> GetAccessibilityProperty()292 RefPtr<T> GetAccessibilityProperty() const 293 { 294 return DynamicCast<T>(accessibilityProperty_); 295 } 296 297 template<typename T> GetLayoutPropertyPtr()298 T* GetLayoutPropertyPtr() const 299 { 300 return reinterpret_cast<T*>(RawPtr(layoutProperty_)); 301 } 302 303 template<typename T> GetLayoutProperty()304 RefPtr<T> GetLayoutProperty() const 305 { 306 return DynamicCast<T>(layoutProperty_); 307 } 308 309 template<typename T> GetPaintPropertyPtr()310 T* GetPaintPropertyPtr() const 311 { 312 return reinterpret_cast<T*>(RawPtr(paintProperty_)); 313 } 314 315 template<typename T> GetPaintProperty()316 RefPtr<T> GetPaintProperty() const 317 { 318 return DynamicCast<T>(paintProperty_); 319 } 320 321 template<typename T> GetEventHub()322 RefPtr<T> GetEventHub() const 323 { 324 return DynamicCast<T>(eventHub_); 325 } 326 GetOrCreateGestureEventHub()327 RefPtr<GestureEventHub> GetOrCreateGestureEventHub() const 328 { 329 return eventHub_->GetOrCreateGestureEventHub(); 330 } 331 GetOrCreateInputEventHub()332 RefPtr<InputEventHub> GetOrCreateInputEventHub() const 333 { 334 return eventHub_->GetOrCreateInputEventHub(); 335 } 336 337 RefPtr<FocusHub> GetOrCreateFocusHub() const; 338 GetFocusHub()339 const RefPtr<FocusHub>& GetFocusHub() const 340 { 341 return eventHub_->GetFocusHub(); 342 } 343 HasVirtualNodeAccessibilityProperty()344 bool HasVirtualNodeAccessibilityProperty() override 345 { 346 if (accessibilityProperty_ && accessibilityProperty_->GetAccessibilityVirtualNodePtr()) { 347 return true; 348 } 349 return false; 350 } 351 GetFocusType()352 FocusType GetFocusType() const 353 { 354 FocusType type = FocusType::DISABLE; 355 auto focusHub = GetFocusHub(); 356 if (focusHub) { 357 type = focusHub->GetFocusType(); 358 } 359 return type; 360 } 361 362 void PostIdleTask(std::function<void(int64_t deadline, bool canUseLongPredictTask)>&& task); 363 364 void AddJudgeToTargetComponent(RefPtr<TargetComponent>& targetComponent); 365 366 // If return true, will prevent TouchTest Bubbling to parent and brother nodes. 367 HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint, 368 TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult, 369 bool isDispatch = false) override; 370 371 HitTestResult MouseTest(const PointF& globalPoint, const PointF& parentLocalPoint, MouseTestResult& onMouseResult, 372 MouseTestResult& onHoverResult, RefPtr<FrameNode>& hoverNode) override; 373 374 HitTestResult AxisTest( 375 const PointF& globalPoint, const PointF& parentLocalPoint, AxisTestResult& onAxisResult) override; 376 377 void AnimateHoverEffect(bool isHovered) const; 378 379 bool IsAtomicNode() const override; 380 381 void MarkNeedSyncRenderTree(bool needRebuild = false) override; 382 383 void RebuildRenderContextTree() override; 384 385 bool IsContextTransparent() override; 386 IsVisible()387 bool IsVisible() const 388 { 389 return layoutProperty_->GetVisibility().value_or(VisibleType::VISIBLE) == VisibleType::VISIBLE; 390 } 391 IsPrivacySensitive()392 bool IsPrivacySensitive() const 393 { 394 return isPrivacySensitive_; 395 } 396 SetPrivacySensitive(bool flag)397 void SetPrivacySensitive(bool flag) 398 { 399 isPrivacySensitive_ = flag; 400 } 401 402 void ChangeSensitiveStyle(bool isSensitive); 403 404 void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override; 405 406 void FromJson(const std::unique_ptr<JsonValue>& json) override; 407 408 RefPtr<FrameNode> GetAncestorNodeOfFrame(bool checkBoundary = false) const; 409 GetNodeName()410 std::string& GetNodeName() 411 { 412 return nodeName_; 413 } 414 SetNodeName(std::string & nodeName)415 void SetNodeName(std::string& nodeName) 416 { 417 nodeName_ = nodeName; 418 } 419 420 void OnWindowShow() override; 421 422 void OnWindowHide() override; 423 424 void OnWindowFocused() override; 425 426 void OnWindowUnfocused() override; 427 428 void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) override; 429 430 void OnNotifyMemoryLevel(int32_t level) override; 431 432 // call by recycle framework. 433 void OnRecycle() override; 434 void OnReuse() override; 435 436 OffsetF GetOffsetRelativeToWindow() const; 437 438 OffsetF GetPositionToScreen(); 439 440 OffsetF GetPositionToParentWithTransform() const; 441 442 OffsetF GetPositionToScreenWithTransform(); 443 444 OffsetF GetPositionToWindowWithTransform(bool fromBottom = false) const; 445 446 OffsetF GetTransformRelativeOffset() const; 447 448 RectF GetTransformRectRelativeToWindow() const; 449 450 OffsetF GetPaintRectOffset(bool excludeSelf = false) const; 451 452 OffsetF GetPaintRectOffsetNG(bool excludeSelf = false) const; 453 454 bool GetRectPointToParentWithTransform(std::vector<Point>& pointList, const RefPtr<FrameNode>& parent) const; 455 456 RectF GetPaintRectToWindowWithTransform(); 457 458 OffsetF GetPaintRectCenter(bool checkWindowBoundary = true) const; 459 460 std::pair<OffsetF, bool> GetPaintRectGlobalOffsetWithTranslate(bool excludeSelf = false) const; 461 462 OffsetF GetPaintRectOffsetToPage() const; 463 464 RectF GetPaintRectWithTransform() const; 465 466 VectorF GetTransformScale() const; 467 468 void AdjustGridOffset(); 469 IsInternal()470 bool IsInternal() const 471 { 472 return isInternal_; 473 } 474 SetInternal()475 void SetInternal() 476 { 477 isInternal_ = true; 478 } 479 480 int32_t GetAllDepthChildrenCount(); 481 482 void OnAccessibilityEvent( 483 AccessibilityEventType eventType, WindowsContentChangeTypes windowsContentChangeType = 484 WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_INVALID) const; 485 486 void OnAccessibilityEventForVirtualNode(AccessibilityEventType eventType, int64_t accessibilityId); 487 488 void OnAccessibilityEvent( 489 AccessibilityEventType eventType, std::string beforeText, std::string latestContent); 490 491 void OnAccessibilityEvent( 492 AccessibilityEventType eventType, int64_t stackNodeId, WindowsContentChangeTypes windowsContentChangeType); 493 494 void OnAccessibilityEvent( 495 AccessibilityEventType eventType, std::string textAnnouncedForAccessibility); 496 void MarkNeedRenderOnly(); 497 498 void OnDetachFromMainTree(bool recursive, PipelineContext* context) override; 499 void OnAttachToMainTree(bool recursive) override; 500 void OnAttachToBuilderNode(NodeStatus nodeStatus) override; 501 bool RenderCustomChild(int64_t deadline) override; 502 void TryVisibleChangeOnDescendant(VisibleType preVisibility, VisibleType currentVisibility) override; 503 void NotifyVisibleChange(VisibleType preVisibility, VisibleType currentVisibility); PushDestroyCallback(std::function<void ()> && callback)504 void PushDestroyCallback(std::function<void()>&& callback) 505 { 506 destroyCallbacks_.emplace_back(callback); 507 } 508 PushDestroyCallbackWithTag(std::function<void ()> && callback,std::string tag)509 void PushDestroyCallbackWithTag(std::function<void()>&& callback, std::string tag) 510 { 511 destroyCallbacksMap_[tag] = callback; 512 } 513 GetDestroyCallback()514 std::list<std::function<void()>> GetDestroyCallback() const 515 { 516 return destroyCallbacks_; 517 } 518 SetColorModeUpdateCallback(const std::function<void ()> && callback)519 void SetColorModeUpdateCallback(const std::function<void()>&& callback) 520 { 521 colorModeUpdateCallback_ = callback; 522 } 523 SetNDKColorModeUpdateCallback(const std::function<void (int32_t)> && callback)524 void SetNDKColorModeUpdateCallback(const std::function<void(int32_t)>&& callback) 525 { 526 ndkColorModeUpdateCallback_ = callback; 527 colorMode_ = SystemProperties::GetColorMode(); 528 } 529 SetNDKFontUpdateCallback(const std::function<void (float,float)> && callback)530 void SetNDKFontUpdateCallback(const std::function<void(float, float)>&& callback) 531 { 532 ndkFontUpdateCallback_ = callback; 533 } 534 535 bool MarkRemoving() override; 536 537 void AddHotZoneRect(const DimensionRect& hotZoneRect) const; 538 void RemoveLastHotZoneRect() const; 539 540 virtual bool IsOutOfTouchTestRegion(const PointF& parentLocalPoint, const TouchEvent& touchEvent); 541 IsLayoutDirtyMarked()542 bool IsLayoutDirtyMarked() const 543 { 544 return isLayoutDirtyMarked_; 545 } 546 SetLayoutDirtyMarked(bool marked)547 void SetLayoutDirtyMarked(bool marked) 548 { 549 isLayoutDirtyMarked_ = marked; 550 } 551 HasPositionProp()552 bool HasPositionProp() const 553 { 554 CHECK_NULL_RETURN(renderContext_, false); 555 return renderContext_->HasPosition() || renderContext_->HasOffset() || renderContext_->HasPositionEdges() || 556 renderContext_->HasOffsetEdges() || renderContext_->HasAnchor(); 557 } 558 559 // The function is only used for fast preview. FastPreviewUpdateChildDone()560 void FastPreviewUpdateChildDone() override 561 { 562 OnMountToParentDone(); 563 } 564 IsExclusiveEventForChild()565 bool IsExclusiveEventForChild() const 566 { 567 return exclusiveEventForChild_; 568 } 569 SetExclusiveEventForChild(bool exclusiveEventForChild)570 void SetExclusiveEventForChild(bool exclusiveEventForChild) 571 { 572 exclusiveEventForChild_ = exclusiveEventForChild; 573 } 574 SetDraggable(bool draggable)575 void SetDraggable(bool draggable) 576 { 577 draggable_ = draggable; 578 userSet_ = true; 579 customerSet_ = false; 580 } 581 SetCustomerDraggable(bool draggable)582 void SetCustomerDraggable(bool draggable) 583 { 584 draggable_ = draggable; 585 userSet_ = true; 586 customerSet_ = true; 587 } 588 SetDragPreviewOptions(const DragPreviewOption & previewOption)589 void SetDragPreviewOptions(const DragPreviewOption& previewOption) 590 { 591 previewOption_ = previewOption; 592 previewOption_.onApply = std::move(previewOption.onApply); 593 } 594 SetOptionsAfterApplied(const OptionsAfterApplied & optionsAfterApplied)595 void SetOptionsAfterApplied(const OptionsAfterApplied& optionsAfterApplied) 596 { 597 previewOption_.options = optionsAfterApplied; 598 } 599 GetDragPreviewOption()600 DragPreviewOption GetDragPreviewOption() const 601 { 602 return previewOption_; 603 } 604 SetBackgroundFunction(std::function<RefPtr<UINode> ()> && buildFunc)605 void SetBackgroundFunction(std::function<RefPtr<UINode>()>&& buildFunc) 606 { 607 builderFunc_ = std::move(buildFunc); 608 backgroundNode_ = nullptr; 609 } 610 IsDraggable()611 bool IsDraggable() const 612 { 613 return draggable_; 614 } 615 IsLayoutComplete()616 bool IsLayoutComplete() const 617 { 618 return isLayoutComplete_; 619 } 620 IsUserSet()621 bool IsUserSet() const 622 { 623 return userSet_; 624 } 625 IsCustomerSet()626 bool IsCustomerSet() const 627 { 628 return customerSet_; 629 } 630 SetAllowDrop(const std::set<std::string> & allowDrop)631 void SetAllowDrop(const std::set<std::string>& allowDrop) 632 { 633 allowDrop_ = allowDrop; 634 } 635 GetAllowDrop()636 const std::set<std::string>& GetAllowDrop() const 637 { 638 return allowDrop_; 639 } 640 SetDrawModifier(const RefPtr<NG::DrawModifier> & drawModifier)641 void SetDrawModifier(const RefPtr<NG::DrawModifier>& drawModifier) 642 { 643 if (!extensionHandler_) { 644 extensionHandler_ = MakeRefPtr<ExtensionHandler>(); 645 extensionHandler_->AttachFrameNode(this); 646 } 647 extensionHandler_->SetDrawModifier(drawModifier); 648 } 649 650 bool IsSupportDrawModifier(); 651 SetDragPreview(const NG::DragDropInfo & info)652 void SetDragPreview(const NG::DragDropInfo& info) 653 { 654 dragPreviewInfo_ = info; 655 } 656 GetDragPreview()657 const DragDropInfo& GetDragPreview() const 658 { 659 return dragPreviewInfo_; 660 } 661 SetOverlayNode(const RefPtr<FrameNode> & overlayNode)662 void SetOverlayNode(const RefPtr<FrameNode>& overlayNode) 663 { 664 overlayNode_ = overlayNode; 665 } 666 GetOverlayNode()667 RefPtr<FrameNode> GetOverlayNode() const 668 { 669 return overlayNode_; 670 } 671 672 RefPtr<FrameNode> FindChildByPosition(float x, float y); 673 674 RefPtr<NodeAnimatablePropertyBase> GetAnimatablePropertyFloat(const std::string& propertyName) const; 675 static RefPtr<FrameNode> FindChildByName(const RefPtr<FrameNode>& parentNode, const std::string& nodeName); 676 void CreateAnimatablePropertyFloat(const std::string& propertyName, float value, 677 const std::function<void(float)>& onCallbackEvent, const PropertyUnit& propertyType = PropertyUnit::UNKNOWN); 678 void DeleteAnimatablePropertyFloat(const std::string& propertyName); 679 void UpdateAnimatablePropertyFloat(const std::string& propertyName, float value); 680 void CreateAnimatableArithmeticProperty(const std::string& propertyName, RefPtr<CustomAnimatableArithmetic>& value, 681 std::function<void(const RefPtr<CustomAnimatableArithmetic>&)>& onCallbackEvent); 682 void UpdateAnimatableArithmeticProperty(const std::string& propertyName, RefPtr<CustomAnimatableArithmetic>& value); 683 684 void SetHitTestMode(HitTestMode mode); 685 HitTestMode GetHitTestMode() const override; 686 687 TouchResult GetOnChildTouchTestRet(const std::vector<TouchTestInfo>& touchInfo); 688 OnChildTouchTestFunc GetOnTouchTestFunc(); 689 void CollectTouchInfos( 690 const PointF& globalPoint, const PointF& parentRevertPoint, std::vector<TouchTestInfo>& touchInfos); 691 RefPtr<FrameNode> GetDispatchFrameNode(const TouchResult& touchRes); 692 693 std::string ProvideRestoreInfo(); 694 695 static std::vector<RefPtr<FrameNode>> GetNodesById(const std::unordered_set<int32_t>& set); 696 static std::vector<FrameNode*> GetNodesPtrById(const std::unordered_set<int32_t>& set); 697 698 double GetPreviewScaleVal() const; 699 700 bool IsPreviewNeedScale() const; 701 SetViewPort(RectF viewPort)702 void SetViewPort(RectF viewPort) 703 { 704 viewPort_ = viewPort; 705 } 706 GetSelfViewPort()707 std::optional<RectF> GetSelfViewPort() const 708 { 709 return viewPort_; 710 } 711 712 std::optional<RectF> GetViewPort() const; 713 714 // Frame Rate Controller(FRC) decides FrameRateRange by scene, speed and scene status 715 // speed is measured by millimeter/second 716 void AddFRCSceneInfo(const std::string& scene, float speed, SceneStatus status); 717 718 OffsetF GetParentGlobalOffsetDuringLayout() const; OnSetCacheCount(int32_t cacheCount,const std::optional<LayoutConstraintF> & itemConstraint)719 void OnSetCacheCount(int32_t cacheCount, const std::optional<LayoutConstraintF>& itemConstraint) override {}; 720 721 // layoutwrapper function override 722 const RefPtr<LayoutAlgorithmWrapper>& GetLayoutAlgorithm(bool needReset = false) override; 723 724 void Measure(const std::optional<LayoutConstraintF>& parentConstraint) override; 725 726 // Called to perform layout children. 727 void Layout() override; 728 GetTotalChildCount()729 int32_t GetTotalChildCount() const override 730 { 731 return UINode::TotalChildCount(); 732 } 733 GetTotalChildCountWithoutExpanded()734 int32_t GetTotalChildCountWithoutExpanded() const 735 { 736 return UINode::CurrentFrameCount(); 737 } 738 GetGeometryNode()739 const RefPtr<GeometryNode>& GetGeometryNode() const override 740 { 741 return geometryNode_; 742 } 743 SetLayoutProperty(const RefPtr<LayoutProperty> & layoutProperty)744 void SetLayoutProperty(const RefPtr<LayoutProperty>& layoutProperty) 745 { 746 layoutProperty_ = layoutProperty; 747 layoutProperty_->SetHost(WeakClaim(this)); 748 } 749 GetLayoutProperty()750 const RefPtr<LayoutProperty>& GetLayoutProperty() const override 751 { 752 return layoutProperty_; 753 } 754 755 RefPtr<LayoutWrapper> GetOrCreateChildByIndex( 756 uint32_t index, bool addToRenderTree = true, bool isCache = false) override; 757 RefPtr<LayoutWrapper> GetChildByIndex(uint32_t index, bool isCache = false) override; 758 759 FrameNode* GetFrameNodeChildByIndex(uint32_t index, bool isCache = false, bool isExpand = true); 760 /** 761 * @brief Get the index of Child among all FrameNode children of [this]. 762 * Handles intermediate SyntaxNodes like LazyForEach. 763 * 764 * @param child pointer to the Child FrameNode. 765 * @return index of Child, or -1 if not found. 766 */ 767 int32_t GetChildTrueIndex(const RefPtr<LayoutWrapper>& child) const; 768 uint32_t GetChildTrueTotalCount() const; 769 ChildrenListWithGuard GetAllChildrenWithBuild(bool addToRenderTree = true) override; 770 void RemoveChildInRenderTree(uint32_t index) override; 771 void RemoveAllChildInRenderTree() override; 772 void DoRemoveChildInRenderTree(uint32_t index, bool isAll) override; 773 void SetActiveChildRange(int32_t start, int32_t end, int32_t cacheStart = 0, int32_t cacheEnd = 0) override; 774 void SetActiveChildRange(const std::optional<ActiveChildSets>& activeChildSets, 775 const std::optional<ActiveChildRange>& activeChildRange = std::nullopt) override; 776 void DoSetActiveChildRange(int32_t start, int32_t end, int32_t cacheStart, int32_t cacheEnd) override; 777 void RecycleItemsByIndex(int32_t start, int32_t end) override; GetHostTag()778 const std::string& GetHostTag() const override 779 { 780 return GetTag(); 781 } 782 783 void UpdateFocusState(); 784 bool SelfOrParentExpansive(); 785 bool SelfExpansive(); 786 bool SelfExpansiveToKeyboard(); 787 bool ParentExpansive(); 788 IsActive()789 bool IsActive() const override 790 { 791 return isActive_; 792 } 793 794 void SetActive(bool active = true, bool needRebuildRenderContext = false) override; 795 GetAccessibilityVisible()796 bool GetAccessibilityVisible() const 797 { 798 return accessibilityVisible_; 799 } 800 SetAccessibilityVisible(const bool accessibilityVisible)801 void SetAccessibilityVisible(const bool accessibilityVisible) 802 { 803 accessibilityVisible_ = accessibilityVisible; 804 } 805 IsOutOfLayout()806 bool IsOutOfLayout() const override 807 { 808 return renderContext_->HasPosition() || renderContext_->HasPositionEdges(); 809 } 810 811 bool SkipMeasureContent() const override; 812 float GetBaselineDistance() const override; 813 void SetCacheCount( 814 int32_t cacheCount = 0, const std::optional<LayoutConstraintF>& itemConstraint = std::nullopt) override; 815 816 void SyncGeometryNode(bool needSyncRsNode, const DirtySwapConfig& config); 817 RefPtr<UINode> GetFrameChildByIndex( 818 uint32_t index, bool needBuild, bool isCache = false, bool addToRenderTree = false) override; 819 RefPtr<UINode> GetFrameChildByIndexWithoutExpanded(uint32_t index) override; 820 bool CheckNeedForceMeasureAndLayout() override; 821 822 bool SetParentLayoutConstraint(const SizeF& size) const override; 823 void ForceSyncGeometryNode(); 824 825 template<typename T> FindFocusChildNodeOfClass()826 RefPtr<T> FindFocusChildNodeOfClass() 827 { 828 const auto& children = GetChildren(); 829 for (auto iter = children.rbegin(); iter != children.rend(); ++iter) { 830 auto& child = *iter; 831 auto target = DynamicCast<FrameNode>(child->FindChildNodeOfClass<T>()); 832 if (target) { 833 auto focusEvent = target->eventHub_->GetFocusHub(); 834 if (focusEvent && focusEvent->IsCurrentFocus()) { 835 return AceType::DynamicCast<T>(target); 836 } 837 } 838 } 839 840 if (AceType::InstanceOf<T>(this)) { 841 auto target = DynamicCast<FrameNode>(this); 842 if (target) { 843 auto focusEvent = target->eventHub_->GetFocusHub(); 844 if (focusEvent && focusEvent->IsCurrentFocus()) { 845 return Claim(AceType::DynamicCast<T>(this)); 846 } 847 } 848 } 849 return nullptr; 850 } 851 852 virtual std::vector<RectF> GetResponseRegionList(const RectF& rect, int32_t sourceType); 853 bool InResponseRegionList(const PointF& parentLocalPoint, const std::vector<RectF>& responseRegionList) const; 854 IsFirstBuilding()855 bool IsFirstBuilding() const 856 { 857 return isFirstBuilding_; 858 } 859 MarkBuildDone()860 void MarkBuildDone() 861 { 862 isFirstBuilding_ = false; 863 } 864 GetLocalMatrix()865 Matrix4 GetLocalMatrix() const 866 { 867 return localMat_; 868 } 869 OffsetF GetOffsetInScreen(); 870 OffsetF GetOffsetInSubwindow(const OffsetF& subwindowOffset); 871 RefPtr<PixelMap> GetPixelMap(); 872 RefPtr<FrameNode> GetPageNode(); 873 RefPtr<FrameNode> GetFirstAutoFillContainerNode(); 874 RefPtr<FrameNode> GetNodeContainer(); 875 RefPtr<ContentModifier> GetContentModifier(); 876 GetExtensionHandler()877 ExtensionHandler* GetExtensionHandler() const 878 { 879 return RawPtr(extensionHandler_); 880 } 881 SetExtensionHandler(const RefPtr<ExtensionHandler> & handler)882 void SetExtensionHandler(const RefPtr<ExtensionHandler>& handler) 883 { 884 extensionHandler_ = handler; 885 if (extensionHandler_) { 886 extensionHandler_->AttachFrameNode(this); 887 } 888 } 889 890 void NotifyFillRequestSuccess(RefPtr<ViewDataWrap> viewDataWrap, 891 RefPtr<PageNodeInfoWrap> nodeWrap, AceAutoFillType autoFillType); 892 void NotifyFillRequestFailed(int32_t errCode, const std::string& fillContent = "", bool isPopup = false); 893 894 int32_t GetUiExtensionId(); 895 int64_t WrapExtensionAbilityId(int64_t extensionOffset, int64_t abilityId); 896 void SearchExtensionElementInfoByAccessibilityIdNG( 897 int64_t elementId, int32_t mode, int64_t offset, std::list<Accessibility::AccessibilityElementInfo>& output); 898 void SearchElementInfosByTextNG(int64_t elementId, const std::string& text, int64_t offset, 899 std::list<Accessibility::AccessibilityElementInfo>& output); 900 void FindFocusedExtensionElementInfoNG( 901 int64_t elementId, int32_t focusType, int64_t offset, Accessibility::AccessibilityElementInfo& output); 902 void FocusMoveSearchNG( 903 int64_t elementId, int32_t direction, int64_t offset, Accessibility::AccessibilityElementInfo& output); 904 bool TransferExecuteAction( 905 int64_t elementId, const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t offset); 906 907 bool GetMonopolizeEvents() const; 908 909 std::vector<RectF> GetResponseRegionListForRecognizer(int32_t sourceType); 910 911 std::vector<RectF> GetResponseRegionListForTouch(const RectF& rect); 912 913 void GetResponseRegionListByTraversal(std::vector<RectF>& responseRegionList); 914 IsWindowBoundary()915 bool IsWindowBoundary() const 916 { 917 return isWindowBoundary_; 918 } 919 920 void SetWindowBoundary(bool isWindowBoundary = true) 921 { 922 isWindowBoundary_ = isWindowBoundary; 923 } 924 SetIsMeasureBoundary(bool isMeasureBoundary)925 void SetIsMeasureBoundary(bool isMeasureBoundary) 926 { 927 isMeasureBoundary_ = isMeasureBoundary; 928 } 929 930 void InitLastArea(); 931 932 OffsetF CalculateCachedTransformRelativeOffset(uint64_t nanoTimestamp); 933 934 RectF GetRectWithRender(); 935 RectF GetRectWithFrame(); 936 937 void PaintDebugBoundary(bool flag) override; 938 static std::pair<float, float> ContextPositionConvertToPX( 939 const RefPtr<RenderContext>& context, const SizeF& percentReference); 940 941 void AttachContext(PipelineContext* context, bool recursive = false) override; 942 void DetachContext(bool recursive = false) override; 943 bool CheckAncestorPageShow(); SetRemoveCustomProperties(std::function<void ()> func)944 void SetRemoveCustomProperties(std::function<void()> func) 945 { 946 if (!removeCustomProperties_) { 947 removeCustomProperties_ = func; 948 } 949 } 950 951 void SetExposureProcessor(const RefPtr<Recorder::ExposureProcessor>& processor); 952 953 void GetVisibleRect(RectF& visibleRect, RectF& frameRect) const; 954 void GetVisibleRectWithClip(RectF& visibleRect, RectF& visibleInnerRect, RectF& frameRect); 955 GetIsGeometryTransitionIn()956 bool GetIsGeometryTransitionIn() const 957 { 958 return isGeometryTransitionIn_; 959 } 960 SetIsGeometryTransitionIn(bool isGeometryTransitionIn)961 void SetIsGeometryTransitionIn(bool isGeometryTransitionIn) 962 { 963 isGeometryTransitionIn_ = isGeometryTransitionIn; 964 } 965 SetGeometryTransitionInRecursive(bool isGeometryTransitionIn)966 void SetGeometryTransitionInRecursive(bool isGeometryTransitionIn) override 967 { 968 SetIsGeometryTransitionIn(isGeometryTransitionIn); 969 UINode::SetGeometryTransitionInRecursive(isGeometryTransitionIn); 970 } 971 AddPredictLayoutNode(const RefPtr<FrameNode> & node)972 void AddPredictLayoutNode(const RefPtr<FrameNode>& node) 973 { 974 predictLayoutNode_.emplace_back(node); 975 } 976 CheckAccessibilityLevelNo()977 bool CheckAccessibilityLevelNo() const { 978 return false; 979 } 980 981 void UpdateAccessibilityNodeRect(); 982 GetVirtualNodeTransformRectRelativeToWindow()983 RectF GetVirtualNodeTransformRectRelativeToWindow() 984 { 985 auto parentUinode = GetVirtualNodeParent().Upgrade(); 986 CHECK_NULL_RETURN(parentUinode, RectF {}); 987 auto parentFrame = AceType::DynamicCast<FrameNode>(parentUinode); 988 CHECK_NULL_RETURN(parentFrame, RectF {}); 989 auto parentRect = parentFrame->GetTransformRectRelativeToWindow(); 990 auto currentRect = GetTransformRectRelativeToWindow(); 991 currentRect.SetTop(currentRect.Top() + parentRect.Top()); 992 currentRect.SetLeft(currentRect.Left() + parentRect.Left()); 993 return currentRect; 994 } 995 HasAccessibilityVirtualNode(bool hasAccessibilityVirtualNode)996 void HasAccessibilityVirtualNode(bool hasAccessibilityVirtualNode) 997 { 998 hasAccessibilityVirtualNode_ = hasAccessibilityVirtualNode; 999 } 1000 SetIsUseTransitionAnimator(bool isUseTransitionAnimator)1001 void SetIsUseTransitionAnimator(bool isUseTransitionAnimator) 1002 { 1003 isUseTransitionAnimator_ = isUseTransitionAnimator; 1004 } 1005 GetIsUseTransitionAnimator()1006 bool GetIsUseTransitionAnimator() 1007 { 1008 return isUseTransitionAnimator_; 1009 } 1010 1011 void ProcessAccessibilityVirtualNode(); 1012 void SetSuggestOpIncMarked(bool flag); 1013 bool GetSuggestOpIncMarked(); 1014 void SetCanSuggestOpInc(bool flag); 1015 bool GetCanSuggestOpInc(); 1016 void SetApplicationRenderGroupMarked(bool flag); 1017 bool GetApplicationRenderGroupMarked(); 1018 void SetSuggestOpIncActivatedOnce(); 1019 bool GetSuggestOpIncActivatedOnce(); 1020 bool MarkSuggestOpIncGroup(bool suggest, bool calc); 1021 void SetOpIncGroupCheckedThrough(bool flag); 1022 bool GetOpIncGroupCheckedThrough(); 1023 void SetOpIncCheckedOnce(); 1024 bool GetOpIncCheckedOnce(); 1025 void MarkAndCheckNewOpIncNode(); 1026 ChildrenListWithGuard GetAllChildren(); 1027 OPINC_TYPE_E FindSuggestOpIncNode(std::string& path, const SizeF& boundary, int32_t depth); 1028 // Notified by render context when any transform attributes updated, 1029 // this flag will be used to refresh the transform matrix cache if it's dirty NotifyTransformInfoChanged()1030 void NotifyTransformInfoChanged() 1031 { 1032 isLocalRevertMatrixAvailable_ = false; 1033 } 1034 1035 // this method will check the cache state and return the cached revert matrix preferentially, 1036 // but the caller can pass in true to forcible refresh the cache 1037 Matrix4& GetOrRefreshRevertMatrixFromCache(bool forceRefresh = false); 1038 1039 // apply the matrix to the given point specified by dst 1040 static void MapPointTo(PointF& dst, Matrix4& matrix); 1041 GetChangeInfoFlag()1042 FrameNodeChangeInfoFlag GetChangeInfoFlag() 1043 { 1044 return changeInfoFlag_; 1045 } 1046 1047 void ClearSubtreeLayoutAlgorithm(bool includeSelf = true, bool clearEntireTree = false) override; 1048 ClearChangeInfoFlag()1049 void ClearChangeInfoFlag() 1050 { 1051 changeInfoFlag_ = FRAME_NODE_CHANGE_INFO_NONE; 1052 } 1053 1054 void OnSyncGeometryFrameFinish(const RectF& paintRect); 1055 void AddFrameNodeChangeInfoFlag(FrameNodeChangeInfoFlag changeFlag = FRAME_NODE_CHANGE_INFO_NONE); 1056 void RegisterNodeChangeListener(); 1057 void UnregisterNodeChangeListener(); 1058 void ProcessFrameNodeChangeFlag(); 1059 void OnNodeTransformInfoUpdate(bool changed); 1060 void OnNodeTransitionInfoUpdate(); 1061 uint32_t GetWindowPatternType() const; 1062 ResetLayoutAlgorithm()1063 void ResetLayoutAlgorithm() 1064 { 1065 layoutAlgorithm_.Reset(); 1066 } 1067 HasLayoutAlgorithm()1068 bool HasLayoutAlgorithm() 1069 { 1070 return layoutAlgorithm_ != nullptr; 1071 } 1072 GetDragHitTestBlock()1073 bool GetDragHitTestBlock() const 1074 { 1075 return dragHitTestBlock_; 1076 } 1077 SetDragHitTestBlock(bool dragHitTestBlock)1078 void SetDragHitTestBlock(bool dragHitTestBlock) 1079 { 1080 dragHitTestBlock_ = dragHitTestBlock; 1081 } 1082 void GetInspectorValue() override; 1083 void NotifyWebPattern(bool isRegister) override; 1084 1085 void NotifyChange(int32_t changeIdx, int32_t count, int64_t id, NotificationType notificationType) override; 1086 1087 void ChildrenUpdatedFrom(int32_t index); GetChildrenUpdated()1088 int32_t GetChildrenUpdated() const 1089 { 1090 return childrenUpdatedFrom_; 1091 } 1092 1093 void SetJSCustomProperty(std::function<bool()> func, std::function<std::string(const std::string&)> getFunc); 1094 bool GetJSCustomProperty(const std::string& key, std::string& value); 1095 bool GetCapiCustomProperty(const std::string& key, std::string& value); 1096 1097 void AddCustomProperty(const std::string& key, const std::string& value); 1098 void RemoveCustomProperty(const std::string& key); 1099 1100 LayoutConstraintF GetLayoutConstraint() const; 1101 GetTargetComponent()1102 WeakPtr<TargetComponent> GetTargetComponent() const 1103 { 1104 return targetComponent_; 1105 } 1106 SetExposeInnerGestureFlag(bool exposeInnerGestureFlag)1107 void SetExposeInnerGestureFlag(bool exposeInnerGestureFlag) 1108 { 1109 exposeInnerGestureFlag_ = exposeInnerGestureFlag; 1110 } 1111 GetExposeInnerGestureFlag()1112 bool GetExposeInnerGestureFlag() const 1113 { 1114 return exposeInnerGestureFlag_; 1115 } 1116 1117 protected: 1118 void DumpInfo() override; 1119 void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override; 1120 1121 std::list<std::function<void()>> destroyCallbacks_; 1122 std::unordered_map<std::string, std::function<void()>> destroyCallbacksMap_; 1123 1124 private: 1125 void MarkDirtyNode( 1126 bool isMeasureBoundary, bool isRenderBoundary, PropertyChangeFlag extraFlag = PROPERTY_UPDATE_NORMAL); 1127 OPINC_TYPE_E IsOpIncValidNode(const SizeF& boundary, int32_t childNumber = 0); 1128 static int GetValidLeafChildNumber(const RefPtr<FrameNode>& host, int32_t thresh); 1129 void MarkNeedRender(bool isRenderBoundary); 1130 bool IsNeedRequestParentMeasure() const; 1131 void UpdateLayoutPropertyFlag() override; 1132 void ForceUpdateLayoutPropertyFlag(PropertyChangeFlag propertyChangeFlag) override; 1133 void AdjustParentLayoutFlag(PropertyChangeFlag& flag) override; 1134 /** 1135 * @brief try to mark Parent dirty with flag PROPERTY_UPDATE_BY_CHILD_REQUEST. 1136 * 1137 * @return true if Parent is successfully marked dirty. 1138 */ 1139 virtual bool RequestParentDirty(); 1140 1141 void UpdateChildrenLayoutWrapper(const RefPtr<LayoutWrapperNode>& self, bool forceMeasure, bool forceLayout); 1142 void AdjustLayoutWrapperTree(const RefPtr<LayoutWrapperNode>& parent, bool forceMeasure, bool forceLayout) override; 1143 1144 OffsetF GetParentGlobalOffset() const; 1145 1146 RefPtr<PaintWrapper> CreatePaintWrapper(); 1147 void LayoutOverlay(); 1148 1149 void OnGenerateOneDepthVisibleFrame(std::list<RefPtr<FrameNode>>& visibleList) override; 1150 void OnGenerateOneDepthVisibleFrameWithTransition(std::list<RefPtr<FrameNode>>& visibleList) override; 1151 void OnGenerateOneDepthVisibleFrameWithOffset( 1152 std::list<RefPtr<FrameNode>>& visibleList, OffsetF& offset) override; 1153 void OnGenerateOneDepthAllFrame(std::list<RefPtr<FrameNode>>& allList) override; 1154 1155 bool IsMeasureBoundary(); 1156 bool IsRenderBoundary(); 1157 1158 bool OnRemoveFromParent(bool allowTransition) override; 1159 bool RemoveImmediately() const override; 1160 1161 bool IsPaintRectWithTransformValid(); 1162 1163 // dump self info. 1164 void DumpDragInfo(); 1165 void DumpOverlayInfo(); 1166 void DumpCommonInfo(); 1167 void DumpSimplifyCommonInfo(std::unique_ptr<JsonValue>& json); 1168 void DumpSimplifySafeAreaInfo(std::unique_ptr<JsonValue>& json); 1169 void DumpSimplifyOverlayInfo(std::unique_ptr<JsonValue>& json); 1170 void DumpBorder(const std::unique_ptr<NG::BorderWidthProperty>& border, std::string label, 1171 std::unique_ptr<JsonValue>& json); 1172 void DumpPadding(const std::unique_ptr<NG::PaddingProperty>& border, std::string label, 1173 std::unique_ptr<JsonValue>& json); 1174 void DumpSafeAreaInfo(); 1175 void DumpAlignRulesInfo(); 1176 void DumpExtensionHandlerInfo(); 1177 void DumpAdvanceInfo() override; 1178 void DumpViewDataPageNode(RefPtr<ViewDataWrap> viewDataWrap, bool needsRecordData = false) override; 1179 void DumpOnSizeChangeInfo(); 1180 bool CheckAutoSave() override; 1181 void MouseToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const; 1182 void TouchToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const; 1183 void GeometryNodeToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const; 1184 1185 bool GetTouchable() const; 1186 bool OnLayoutFinish(bool& needSyncRsNode, DirtySwapConfig& config); 1187 1188 void ProcessVisibleAreaChangeEvent(const RectF& visibleRect, const RectF& frameRect, 1189 const std::vector<double>& visibleAreaRatios, VisibleCallbackInfo& visibleAreaCallback, bool isUser); 1190 void ProcessAllVisibleCallback(const std::vector<double>& visibleAreaUserRatios, 1191 VisibleCallbackInfo& visibleAreaUserCallback, double currentVisibleRatio, 1192 double lastVisibleRatio, bool isThrottled = false, bool isInner = false); 1193 void ProcessThrottledVisibleCallback(); 1194 bool IsFrameDisappear(); 1195 bool IsFrameDisappear(uint64_t timestamp); 1196 bool IsFrameAncestorDisappear(uint64_t timestamp); 1197 void ThrottledVisibleTask(); 1198 1199 void OnPixelRoundFinish(const SizeF& pixelGridRoundSize); 1200 1201 double CalculateCurrentVisibleRatio(const RectF& visibleRect, const RectF& renderRect); 1202 1203 // set costom background layoutConstraint 1204 void SetBackgroundLayoutConstraint(const RefPtr<FrameNode>& customNode); 1205 1206 void GetPercentSensitive(); 1207 void UpdatePercentSensitive(); 1208 1209 void AddFrameNodeSnapshot(bool isHit, int32_t parentId, std::vector<RectF> responseRegionList, EventTreeType type); 1210 1211 int32_t GetNodeExpectedRate(); 1212 1213 void RecordExposureInner(); 1214 1215 OffsetF CalculateOffsetRelativeToWindow(uint64_t nanoTimestamp); 1216 1217 const std::pair<uint64_t, OffsetF>& GetCachedGlobalOffset() const; 1218 1219 void SetCachedGlobalOffset(const std::pair<uint64_t, OffsetF>& timestampOffset); 1220 1221 const std::pair<uint64_t, OffsetF>& GetCachedTransformRelativeOffset() const; 1222 1223 void SetCachedTransformRelativeOffset(const std::pair<uint64_t, OffsetF>& timestampOffset); 1224 1225 HitTestMode TriggerOnTouchIntercept(const TouchEvent& touchEvent); 1226 1227 void TriggerShouldParallelInnerWith( 1228 const ResponseLinkResult& currentRecognizers, const ResponseLinkResult& responseLinkRecognizers); 1229 1230 void AddTouchEventAllFingersInfo(TouchEventInfo& event, const TouchEvent& touchEvent); 1231 1232 RectF ApplyFrameNodeTranformToRect(const RectF& rect, const RefPtr<FrameNode>& parent) const; 1233 1234 CacheVisibleRectResult GetCacheVisibleRect(uint64_t timestamp); 1235 1236 CacheVisibleRectResult CalculateCacheVisibleRect(CacheVisibleRectResult& parentCacheVisibleRect, 1237 const RefPtr<FrameNode>& parentUi, RectF& rectToParent, VectorF scale, uint64_t timestamp); 1238 1239 void NotifyConfigurationChangeNdk(const ConfigurationChange& configurationChange); 1240 1241 bool AllowVisibleAreaCheck() const; 1242 1243 void ResetPredictNodes(); 1244 1245 bool ProcessMouseTestHit(const PointF& globalPoint, const PointF& localPoint, 1246 TouchRestrict& touchRestrict, TouchTestResult& newComingTargets); 1247 1248 // sort in ZIndex. 1249 std::multiset<WeakPtr<FrameNode>, ZIndexComparator> frameChildren_; 1250 RefPtr<GeometryNode> geometryNode_ = MakeRefPtr<GeometryNode>(); 1251 1252 std::function<void()> colorModeUpdateCallback_; 1253 std::function<void(int32_t)> ndkColorModeUpdateCallback_; 1254 std::function<void(float, float)> ndkFontUpdateCallback_; 1255 RefPtr<AccessibilityProperty> accessibilityProperty_; 1256 bool hasAccessibilityVirtualNode_ = false; 1257 RefPtr<LayoutProperty> layoutProperty_; 1258 RefPtr<PaintProperty> paintProperty_; 1259 RefPtr<RenderContext> renderContext_ = RenderContext::Create(); 1260 RefPtr<EventHub> eventHub_; 1261 RefPtr<Pattern> pattern_; 1262 1263 RefPtr<ExtensionHandler> extensionHandler_; 1264 1265 RefPtr<FrameNode> backgroundNode_; 1266 std::function<RefPtr<UINode>()> builderFunc_; 1267 std::unique_ptr<RectF> lastFrameRect_; 1268 std::unique_ptr<OffsetF> lastParentOffsetToWindow_; 1269 std::unique_ptr<RectF> lastFrameNodeRect_; 1270 std::set<std::string> allowDrop_; 1271 const static std::set<std::string> layoutTags_; 1272 std::function<void()> removeCustomProperties_; 1273 std::function<std::string(const std::string& key)> getCustomProperty_; 1274 std::optional<RectF> viewPort_; 1275 NG::DragDropInfo dragPreviewInfo_; 1276 1277 RefPtr<LayoutAlgorithmWrapper> layoutAlgorithm_; 1278 RefPtr<GeometryNode> oldGeometryNode_; 1279 std::optional<bool> skipMeasureContent_; 1280 std::unique_ptr<FrameProxy> frameProxy_; 1281 WeakPtr<TargetComponent> targetComponent_; 1282 1283 bool needSyncRenderTree_ = false; 1284 1285 bool isPropertyDiffMarked_ = false; 1286 bool isLayoutDirtyMarked_ = false; 1287 bool isRenderDirtyMarked_ = false; 1288 bool isMeasureBoundary_ = false; 1289 bool hasPendingRequest_ = false; 1290 bool isPrivacySensitive_ = false; 1291 1292 // for container, this flag controls only the last child in touch area is consuming event. 1293 bool exclusiveEventForChild_ = false; 1294 bool isActive_ = false; 1295 bool accessibilityVisible_ = true; 1296 bool isResponseRegion_ = false; 1297 bool isLayoutComplete_ = false; 1298 bool isFirstBuilding_ = true; 1299 1300 double lastVisibleRatio_ = 0.0; 1301 double lastInnerVisibleRatio_ = 0.0; 1302 double lastVisibleCallbackRatio_ = 0.0; 1303 double lastInnerVisibleCallbackRatio_ = 0.0; 1304 double lastThrottledVisibleRatio_ = 0.0; 1305 double lastThrottledVisibleCbRatio_ = 0.0; 1306 int64_t lastThrottledTriggerTime_ = 0; 1307 bool throttledCallbackOnTheWay_ = false; 1308 1309 // internal node such as Text in Button CreateWithLabel 1310 // should not seen by preview inspector or accessibility 1311 bool isInternal_ = false; 1312 1313 std::string nodeName_; 1314 1315 ColorMode colorMode_ = ColorMode::LIGHT; 1316 1317 bool draggable_ = false; 1318 bool userSet_ = false; 1319 bool customerSet_ = false; 1320 bool isWindowBoundary_ = false; 1321 uint8_t suggestOpIncByte_ = 0; 1322 uint64_t getCacheNanoTime_ = 0; 1323 RectF prePaintRect_; 1324 1325 std::map<std::string, RefPtr<NodeAnimatablePropertyBase>> nodeAnimatablePropertyMap_; 1326 Matrix4 localMat_ = Matrix4::CreateIdentity(); 1327 // this is just used for the hit test process of event handling, do not used for other purpose 1328 Matrix4 localRevertMatrix_ = Matrix4::CreateIdentity(); 1329 // control the localMat_ and localRevertMatrix_ available or not, set to false when any transform info is set 1330 bool isLocalRevertMatrixAvailable_ = false; 1331 bool isFind_ = false; 1332 1333 bool isRestoreInfoUsed_ = false; 1334 bool checkboxFlag_ = false; 1335 bool isDisallowDropForcedly_ = false; 1336 bool isGeometryTransitionIn_ = false; 1337 bool isLayoutNode_ = false; 1338 bool isCalculateInnerVisibleRectClip_ = false; 1339 bool dragHitTestBlock_ = false; 1340 1341 bool isUseTransitionAnimator_ = false; 1342 1343 bool exposeInnerGestureFlag_ = false; 1344 1345 RefPtr<FrameNode> overlayNode_; 1346 1347 std::unordered_map<std::string, int32_t> sceneRateMap_; 1348 1349 std::unordered_map<std::string, std::string> customPropertyMap_; 1350 1351 RefPtr<Recorder::ExposureProcessor> exposureProcessor_; 1352 1353 std::pair<uint64_t, OffsetF> cachedGlobalOffset_ = { 0, OffsetF() }; 1354 std::pair<uint64_t, OffsetF> cachedTransformRelativeOffset_ = { 0, OffsetF() }; 1355 std::pair<uint64_t, bool> cachedIsFrameDisappear_ = { 0, false }; 1356 std::pair<uint64_t, CacheVisibleRectResult> cachedVisibleRectResult_ = { 0, CacheVisibleRectResult() }; 1357 1358 DragPreviewOption previewOption_ { true, false, false, false, false, false, true, { .isShowBadge = true } }; 1359 struct onSizeChangeDumpInfo { 1360 int64_t onSizeChangeTimeStamp; 1361 RectF lastFrameRect; 1362 RectF currFrameRect; 1363 }; 1364 std::vector<onSizeChangeDumpInfo> onSizeChangeDumpInfos; 1365 std::list<WeakPtr<FrameNode>> predictLayoutNode_; 1366 FrameNodeChangeInfoFlag changeInfoFlag_ = FRAME_NODE_CHANGE_INFO_NONE; 1367 std::optional<RectF> syncedFramePaintRect_; 1368 1369 int32_t childrenUpdatedFrom_ = -1; 1370 1371 friend class RosenRenderContext; 1372 friend class RenderContext; 1373 friend class Pattern; 1374 1375 ACE_DISALLOW_COPY_AND_MOVE(FrameNode); 1376 }; 1377 } // namespace OHOS::Ace::NG 1378 1379 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_BASE_FRAME_NODE_H 1380