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 SetWebPaintData(const std::string & webData)48 void SetWebPaintData(const std::string& webData) 49 { 50 if (webPaintData_ != webData) { 51 webPaintData_ = webData; 52 } 53 } 54 GetWebPaintData()55 std::string GetWebPaintData() 56 { 57 return webPaintData_.value_or(""); 58 } 59 60 private: 61 std::optional<std::string> webPaintData_; 62 }; 63 } // namespace OHOS::Ace::NG 64 65 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WEB_WEB_PAINT_PROPERTY_H 66