1/* 2 * Copyright (c) 2023 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 16class FrameNode { 17 private renderNode_: RenderNode; 18 private baseNode_ : BaseNode; 19 protected nodePtr_ : number | null; 20 constructor(uiContext: UIContext, type: string) { 21 this.renderNode_ = new RenderNode('FrameNode'); 22 if (type === 'BuilderNode') { 23 return; 24 } 25 this.baseNode_ = new BaseNode(uiContext); 26 this.nodePtr_ = this.baseNode_.createRenderNode(this); 27 this.renderNode_.setNodePtr(this.nodePtr_); 28 this.renderNode_.setBaseNode(this.baseNode_); 29 } 30 getRenderNode(): RenderNode | null { 31 if ( 32 this.renderNode_ !== undefined && 33 this.renderNode_ !== null && 34 this.renderNode_.getNodePtr() !== null 35 ) { 36 return this.renderNode_; 37 } 38 return null; 39 } 40 setNodePtr(nodePtr: number | null) { 41 this.nodePtr_ = nodePtr; 42 this.renderNode_.setNodePtr(nodePtr); 43 } 44 setBaseNode(baseNode: BaseNode | null) { 45 this.baseNode_ = baseNode; 46 this.renderNode_.setBaseNode(baseNode); 47 } 48 getNodePtr(): number | null { 49 return this.nodePtr_; 50 } 51 dispose() { 52 this.baseNode_.dispose() 53 } 54} 55