• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_VIEW_MEASURE_LAYOUT_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_VIEW_MEASURE_LAYOUT_H
18 
19 #include <utility>
20 
21 #include "base/memory/ace_type.h"
22 #include "core/components_ng/layout/layout_wrapper.h"
23 #include "frameworks/bridge/declarative_frontend/engine/js_ref_ptr.h"
24 
25 namespace OHOS::Ace::Framework {
26 
27 class ACE_EXPORT ViewMeasureLayout : AceType {
28     DECLARE_ACE_TYPE(ViewMeasureLayout, AceType);
29 
30 public:
31     ViewMeasureLayout() = default;
~ViewMeasureLayout()32     ~ViewMeasureLayout() override
33     {
34         LOGD("Destroy: ViewMeasureLayout");
35     }
36 
37 #ifdef USE_ARK_ENGINE
38     static panda::Local<panda::JSValueRef> JSMeasure(panda::JsiRuntimeCallInfo* info);
39     static panda::Local<panda::JSValueRef> JSLayout(panda::JsiRuntimeCallInfo* info);
40 
SetMeasureChildren(std::list<RefPtr<NG::LayoutWrapper>> children)41     static void SetMeasureChildren(std::list<RefPtr<NG::LayoutWrapper>> children)
42     {
43         measureChildren_ = std::move(children);
44         iterMeasureChildren_ = measureChildren_.begin();
45     }
46 
SetLayoutChildren(std::list<RefPtr<NG::LayoutWrapper>> children)47     static void SetLayoutChildren(std::list<RefPtr<NG::LayoutWrapper>> children)
48     {
49         layoutChildren_ = std::move(children);
50         iterLayoutChildren_ = layoutChildren_.begin();
51     }
52 
SetDefaultMeasureConstraint(NG::LayoutConstraintF constraint)53     static void SetDefaultMeasureConstraint(NG::LayoutConstraintF constraint)
54     {
55         measureDefaultConstraint_ = constraint;
56     }
57 
58 private:
59     static thread_local std::list<RefPtr<NG::LayoutWrapper>> measureChildren_;
60     static thread_local std::list<RefPtr<NG::LayoutWrapper>>::iterator iterMeasureChildren_;
61     static thread_local std::list<RefPtr<NG::LayoutWrapper>> layoutChildren_;
62     static thread_local std::list<RefPtr<NG::LayoutWrapper>>::iterator iterLayoutChildren_;
63     static thread_local NG::LayoutConstraintF measureDefaultConstraint_;
64 #endif
65 };
66 
67 } // namespace OHOS::Ace::Framework
68 
69 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_VIEW_MEASURE_LAYOUT_H