ladybird/Userland/Libraries/LibWebView/StylePropertiesModel.h
Linus Groh 6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00

52 lines
1.5 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/JsonObject.h>
#include <LibGUI/Model.h>
#include <LibWeb/CSS/StyleProperties.h>
namespace WebView {
class StylePropertiesModel final : public GUI::Model {
public:
enum Column {
PropertyName,
PropertyValue,
__Count
};
static NonnullRefPtr<StylePropertiesModel> create(StringView properties)
{
auto json_or_error = JsonValue::from_string(properties).release_value_but_fixme_should_propagate_errors();
return adopt_ref(*new StylePropertiesModel(json_or_error.as_object()));
}
virtual ~StylePropertiesModel() override;
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual bool is_searchable() const override { return true; }
virtual Vector<GUI::ModelIndex> matches(StringView, unsigned flags, GUI::ModelIndex const&) override;
private:
explicit StylePropertiesModel(JsonObject);
JsonObject m_properties;
struct Value {
DeprecatedString name;
DeprecatedString value;
};
Vector<Value> m_values;
};
}