1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 17:55:06 +00:00

LibWebView: Make DOMTreeModel usable outside of SerenityOS

Two issues made this class unusable on other platforms:
- Hardcoded /res paths to icons
- It required a GUI::TreeView for palette access

This patch simply patches out those features on non-Serenity systemsf
for now.
This commit is contained in:
Andreas Kling 2022-09-25 12:11:02 +02:00
parent 34c232def7
commit 05985b51f2
2 changed files with 23 additions and 7 deletions

View file

@ -20,7 +20,13 @@ public:
static NonnullRefPtr<DOMTreeModel> create(StringView dom_tree, GUI::TreeView& tree_view)
{
auto json_or_error = JsonValue::from_string(dom_tree).release_value_but_fixme_should_propagate_errors();
return adopt_ref(*new DOMTreeModel(json_or_error.as_object(), tree_view));
return adopt_ref(*new DOMTreeModel(json_or_error.as_object(), &tree_view));
}
static NonnullRefPtr<DOMTreeModel> create(StringView dom_tree)
{
auto json_or_error = JsonValue::from_string(dom_tree).release_value_but_fixme_should_propagate_errors();
return adopt_ref(*new DOMTreeModel(json_or_error.as_object(), nullptr));
}
virtual ~DOMTreeModel() override;
@ -34,7 +40,7 @@ public:
GUI::ModelIndex index_for_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> pseudo_element) const;
private:
DOMTreeModel(JsonObject, GUI::TreeView&);
DOMTreeModel(JsonObject, GUI::TreeView*);
ALWAYS_INLINE JsonObject const* get_parent(JsonObject const& o) const
{
@ -52,7 +58,7 @@ private:
void map_dom_nodes_to_parent(JsonObject const* parent, JsonObject const* child);
GUI::TreeView& m_tree_view;
GUI::TreeView* m_tree_view { nullptr };
GUI::Icon m_document_icon;
GUI::Icon m_element_icon;
GUI::Icon m_text_icon;