• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_PAINT_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_PAINT_PROPERTY_H
18 
19 #include "core/components_ng/base/inspector_filter.h"
20 #include "core/components_ng/render/paint_property.h"
21 
22 namespace OHOS::Ace::NG {
23 class WebPaintProperty : public PaintProperty {
24     DECLARE_ACE_TYPE(WebPaintProperty, PaintProperty);
25 
26 public:
27     WebPaintProperty() = default;
28     ~WebPaintProperty() override = default;
29 
Clone()30     RefPtr<PaintProperty> Clone() const override
31     {
32         auto paintProperty = MakeRefPtr<WebPaintProperty>();
33         paintProperty->UpdatePaintProperty(this);
34         return paintProperty;
35     }
36 
Reset()37     void Reset() override
38     {
39         PaintProperty::Reset();
40     }
41 
ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter)42     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override
43     {
44         PaintProperty::ToJsonValue(json, filter);
45         json->PutFixedAttr("content", webPaintData_.value_or("null").c_str(), filter, FIXED_ATTR_CONTENT);
46     }
47 
ToTreeJson(std::unique_ptr<JsonValue> & json,const InspectorConfig & config)48     void ToTreeJson(std::unique_ptr<JsonValue>& json, const InspectorConfig& config) const override
49     {
50         PaintProperty::ToTreeJson(json, config);
51         json->Put(TreeKey::CONTENT, webPaintData_.value_or("null").c_str());
52     }
53 
SetWebPaintData(const std::string & webData)54     void SetWebPaintData(const std::string& webData)
55     {
56         if (webPaintData_ != webData) {
57             webPaintData_ = webData;
58         }
59     }
60 
GetWebPaintData()61     std::string GetWebPaintData()
62     {
63         return webPaintData_.value_or("");
64     }
65 
66 private:
67     std::optional<std::string> webPaintData_;
68 };
69 } // namespace OHOS::Ace::NG
70 
71 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_PAINT_PROPERTY_H
72