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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_NODE_H 18 19 #include <optional> 20 21 #include "core/components_ng/base/frame_node.h" 22 23 namespace OHOS::Ace::NG { 24 25 class ACE_EXPORT FormNode : public FrameNode { 26 DECLARE_ACE_TYPE(FormNode, FrameNode); 27 28 public: 29 FormNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern, bool isRoot = false) 30 : FrameNode(tag, nodeId, pattern, isRoot) 31 {} 32 ~FormNode() override; 33 34 HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint, 35 TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult, 36 bool isDispatch = false) override; 37 38 static RefPtr<FormNode> GetOrCreateFormNode( 39 const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator); 40 41 void DispatchPointerEvent(const TouchEvent& touchEvent, 42 SerializedGesture& serializedGesture); 43 44 void OnDetachFromMainTree(bool, PipelineContext* = nullptr) override; 45 46 OffsetF GetFormOffset() const; 47 48 void InitializeFormAccessibility(); 49 50 void OnAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId); 51 52 void OnAccessibilityChildTreeDeregister(); 53 54 void OnSetAccessibilityChildTree(int32_t childWindowId, int32_t childTreeId); 55 56 void OnAccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info); 57 58 void NotifyAccessibilityChildTreeRegister(); 59 GetImageId()60 int32_t GetImageId() 61 { 62 if (!imageId_.has_value()) { 63 imageId_ = ElementRegister::GetInstance()->MakeUniqueId(); 64 } 65 return imageId_.value(); 66 } 67 68 void ClearAccessibilityChildTreeRegisterFlag(); 69 private: 70 std::optional<int32_t> imageId_; 71 std::shared_ptr<AccessibilityChildTreeCallback> accessibilityChildTreeCallback_; 72 }; 73 74 } // namespace OHOS::Ace::NG 75 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_NODE_H 76