1 /*
2 * Copyright (c) 2021 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 "frameworks/bridge/common/dom/dom_svg_circle.h"
17
18 namespace OHOS::Ace::Framework {
19
DOMSvgCircle(NodeId nodeId,const std::string & nodeName)20 DOMSvgCircle::DOMSvgCircle(NodeId nodeId, const std::string& nodeName) : DOMSvgBase(nodeId, nodeName) {}
21
22
GetSpecializedComponent()23 RefPtr<Component> DOMSvgCircle::GetSpecializedComponent()
24 {
25 return circleComponent_;
26 }
27
OnChildNodeAdded(const RefPtr<DOMNode> & child,int32_t slot)28 void DOMSvgCircle::OnChildNodeAdded(const RefPtr<DOMNode>& child, int32_t slot)
29 {
30 circleComponent_->InsertChild(slot, child->GetSpecializedComponent());
31 }
32
OnMounted(const RefPtr<DOMNode> & parentNode)33 void DOMSvgCircle::OnMounted(const RefPtr<DOMNode>& parentNode)
34 {
35 DOMSvgBase::InheritAttrs(parentNode);
36 }
37
PrepareSpecializedComponent()38 void DOMSvgCircle::PrepareSpecializedComponent()
39 {
40 if (!circleComponent_) {
41 circleComponent_ = AceType::MakeRefPtr<SvgCircleComponent>();
42 }
43 auto declaration = AceType::DynamicCast<SvgCircleDeclaration>(declaration_);
44 if (declaration) {
45 circleComponent_->SetDeclaration(declaration);
46 }
47 }
48
49 } // namespace OHOS::Ace::Framework
50