mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
Browser+LibWebView: Load and Display ARIA Properites and State
The inspector widget now has a new ARIA tab which displays an individual element's ARIA properties and state. The view itself is pretty basic for now, just being a table- there is definitely room for some better UX here but it's enough for a first cut.
This commit is contained in:
parent
e9840bfd4e
commit
afb07281ad
13 changed files with 179 additions and 17 deletions
49
Userland/Libraries/LibWebView/AriaPropertiesStateModel.h
Normal file
49
Userland/Libraries/LibWebView/AriaPropertiesStateModel.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibGUI/Model.h>
|
||||
|
||||
namespace WebView {
|
||||
|
||||
class AriaPropertiesStateModel final : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
PropertyName,
|
||||
PropertyValue,
|
||||
__Count
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<AriaPropertiesStateModel>> create(StringView properties_state)
|
||||
{
|
||||
auto json_or_error = TRY(JsonValue::from_string(properties_state));
|
||||
return adopt_nonnull_ref_or_enomem(new AriaPropertiesStateModel(json_or_error.as_object()));
|
||||
}
|
||||
|
||||
virtual ~AriaPropertiesStateModel() 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 ErrorOr<String> 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 AriaPropertiesStateModel(JsonObject);
|
||||
|
||||
JsonObject m_properties_state;
|
||||
|
||||
struct Value {
|
||||
DeprecatedString name;
|
||||
DeprecatedString value;
|
||||
};
|
||||
Vector<Value> m_values;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue