• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "ui/properties/property.h"
17 
18 #include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h"
19 #include "ui/base/ace_type.h"
20 #include "ui/base/referenced.h"
21 #include "ui/base/utils/utils.h"
22 #include "ui/view/frame_node.h"
23 
24 #include "core/components_ng/property/property.h"
25 
26 namespace OHOS::Ace::Kit {
27 
GetNodePtr(const WeakPtr<FrameNode> & weak)28 AceNode* GetNodePtr(const WeakPtr<FrameNode>& weak)
29 {
30     auto node = weak.Upgrade();
31     auto frameNode = AceType::DynamicCast<FrameNodeImpl>(node);
32     CHECK_NULL_RETURN(frameNode, nullptr);
33     auto nodePtr = frameNode->GetAceNodePtr();
34     return nodePtr;
35 }
36 
CleanDirty()37 void Property::CleanDirty()
38 {
39     auto* node = GetNodePtr(host_);
40     CHECK_NULL_VOID(node);
41     auto paintProp = node->GetPaintProperty<NG::Property>();
42     paintProp->CleanDirty();
43     auto layoutProp = node->GetLayoutProperty();
44     layoutProp->CleanDirty();
45 }
46 
UpdateRender()47 void Property::UpdateRender()
48 {
49     auto node = host_.Upgrade();
50     CHECK_NULL_VOID(node);
51     node->MarkDirtyNode(NG::PROPERTY_UPDATE_RENDER);
52     UpdatePaintFlag(NG::PROPERTY_UPDATE_RENDER);
53 }
54 
UpdateMeasure(bool onlySelf)55 void Property::UpdateMeasure(bool onlySelf)
56 {
57     UpdateLayoutFlag(onlySelf ? NG::PROPERTY_UPDATE_MEASURE_SELF : NG::PROPERTY_UPDATE_MEASURE);
58 }
59 
UpdatePaintFlag(NG::PropertyChangeFlag propertyChangeFlag)60 void Property::UpdatePaintFlag(NG::PropertyChangeFlag propertyChangeFlag)
61 {
62     auto* node = GetNodePtr(host_);
63     CHECK_NULL_VOID(node);
64     auto paintProp = node->GetPaintProperty<NG::Property>();
65     paintProp->UpdatePropertyChangeFlag(propertyChangeFlag);
66 }
67 
UpdateLayoutFlag(NG::PropertyChangeFlag propertyChangeFlag)68 void Property::UpdateLayoutFlag(NG::PropertyChangeFlag propertyChangeFlag)
69 {
70     auto* node = GetNodePtr(host_);
71     CHECK_NULL_VOID(node);
72     auto layoutProp = node->GetLayoutProperty();
73     layoutProp->UpdatePropertyChangeFlag(propertyChangeFlag);
74 }
75 
SetHost(const WeakPtr<FrameNode> & host)76 void Property::SetHost(const WeakPtr<FrameNode>& host)
77 {
78     host_ = host;
79 }
80 
81 } // namespace OHOS::Ace::Kit
82