Bläddra i källkod

LibWebView: Remove the now-unused LibGUI model implementations

Timothy Flynn 1 år sedan
förälder
incheckning
cc316de0ee

+ 0 - 121
Userland/Libraries/LibWebView/AccessibilityTreeModel.cpp

@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibWebView/AccessibilityTreeModel.h>
-
-namespace WebView {
-
-AccessibilityTreeModel::AccessibilityTreeModel(JsonObject accessibility_tree, GUI::TreeView* tree_view)
-    : m_tree_view(tree_view)
-    , m_accessibility_tree(move(accessibility_tree))
-{
-    map_accessibility_nodes_to_parent(nullptr, &m_accessibility_tree);
-}
-
-AccessibilityTreeModel::~AccessibilityTreeModel() = default;
-
-GUI::ModelIndex AccessibilityTreeModel::index(int row, int column, GUI::ModelIndex const& parent) const
-{
-    if (!parent.is_valid()) {
-        return create_index(row, column, &m_accessibility_tree);
-    }
-
-    auto const& parent_node = *static_cast<JsonObject const*>(parent.internal_data());
-    auto children = get_children(parent_node);
-    if (!children.has_value())
-        return create_index(row, column, &m_accessibility_tree);
-
-    auto const& child_node = children->at(row).as_object();
-    return create_index(row, column, &child_node);
-}
-
-GUI::ModelIndex AccessibilityTreeModel::parent_index(GUI::ModelIndex const& index) const
-{
-    if (!index.is_valid())
-        return {};
-
-    auto const& node = *static_cast<JsonObject const*>(index.internal_data());
-
-    auto const* parent_node = get_parent(node);
-    if (!parent_node)
-        return {};
-
-    // If the parent is the root document, we know it has index 0, 0
-    if (parent_node == &m_accessibility_tree) {
-        return create_index(0, 0, parent_node);
-    }
-
-    // Otherwise, we need to find the grandparent, to find the index of parent within that
-    auto const* grandparent_node = get_parent(*parent_node);
-    VERIFY(grandparent_node);
-
-    auto grandparent_children = get_children(*grandparent_node);
-    if (!grandparent_children.has_value())
-        return {};
-
-    for (size_t grandparent_child_index = 0; grandparent_child_index < grandparent_children->size(); ++grandparent_child_index) {
-        auto const& child = grandparent_children->at(grandparent_child_index).as_object();
-        if (&child == parent_node)
-            return create_index(grandparent_child_index, 0, parent_node);
-    }
-
-    return {};
-}
-
-int AccessibilityTreeModel::row_count(GUI::ModelIndex const& index) const
-{
-    if (!index.is_valid())
-        return 1;
-
-    auto const& node = *static_cast<JsonObject const*>(index.internal_data());
-    auto children = get_children(node);
-    return children.has_value() ? children->size() : 0;
-}
-
-int AccessibilityTreeModel::column_count(const GUI::ModelIndex&) const
-{
-    return 1;
-}
-
-GUI::Variant AccessibilityTreeModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const
-{
-    auto const& node = *static_cast<JsonObject const*>(index.internal_data());
-    auto type = node.get_deprecated_string("type"sv).value_or("unknown"sv);
-
-    if (role == GUI::ModelRole::Display) {
-        if (type == "text")
-            return node.get_deprecated_string("text"sv).value();
-
-        auto node_role = node.get_deprecated_string("role"sv).value();
-        if (type != "element")
-            return node_role;
-
-        auto name = node.get_deprecated_string("name"sv).value_or("");
-        auto description = node.get_deprecated_string("description"sv).value_or("");
-
-        StringBuilder builder;
-        builder.append(node_role.to_lowercase());
-        builder.appendff(" name: \"{}\", description: \"{}\"", name, description);
-        return builder.to_deprecated_string();
-    }
-    return {};
-}
-
-void AccessibilityTreeModel::map_accessibility_nodes_to_parent(JsonObject const* parent, JsonObject const* node)
-{
-    m_accessibility_node_to_parent_map.set(node, parent);
-
-    auto children = get_children(*node);
-    if (!children.has_value())
-        return;
-
-    children->for_each([&](auto const& child) {
-        auto const& child_node = child.as_object();
-        map_accessibility_nodes_to_parent(node, &child_node);
-    });
-}
-
-}

+ 0 - 59
Userland/Libraries/LibWebView/AccessibilityTreeModel.h

@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/JsonObject.h>
-#include <LibGUI/Model.h>
-#include <LibWeb/CSS/Selector.h>
-
-namespace WebView {
-
-class AccessibilityTreeModel final : public GUI::Model {
-public:
-    static NonnullRefPtr<AccessibilityTreeModel> create(StringView accessibility_tree, GUI::TreeView& tree_view)
-    {
-        auto json_or_error = JsonValue::from_string(accessibility_tree).release_value_but_fixme_should_propagate_errors();
-        return adopt_ref(*new AccessibilityTreeModel(json_or_error.as_object(), &tree_view));
-    }
-
-    static NonnullRefPtr<AccessibilityTreeModel> create(StringView accessibility_tree)
-    {
-        auto json_or_error = JsonValue::from_string(accessibility_tree).release_value_but_fixme_should_propagate_errors();
-        return adopt_ref(*new AccessibilityTreeModel(json_or_error.as_object(), nullptr));
-    }
-
-    virtual ~AccessibilityTreeModel() override;
-
-    virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
-    virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
-    virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
-    virtual GUI::ModelIndex index(int row, int column, GUI::ModelIndex const& parent = GUI::ModelIndex()) const override;
-    virtual GUI::ModelIndex parent_index(GUI::ModelIndex const&) const override;
-
-private:
-    AccessibilityTreeModel(JsonObject, GUI::TreeView*);
-
-    ALWAYS_INLINE JsonObject const* get_parent(JsonObject const& o) const
-    {
-        auto parent_node = m_accessibility_node_to_parent_map.get(&o);
-        VERIFY(parent_node.has_value());
-        return *parent_node;
-    }
-
-    ALWAYS_INLINE static Optional<JsonArray const&> const get_children(JsonObject const& o)
-    {
-        return o.get_array("children"sv);
-    }
-
-    void map_accessibility_nodes_to_parent(JsonObject const* parent, JsonObject const* child);
-
-    GUI::TreeView* m_tree_view { nullptr };
-    JsonObject m_accessibility_tree;
-    HashMap<JsonObject const*, JsonObject const*> m_accessibility_node_to_parent_map;
-};
-
-}

+ 0 - 77
Userland/Libraries/LibWebView/AriaPropertiesStateModel.cpp

@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "AriaPropertiesStateModel.h"
-
-namespace WebView {
-
-AriaPropertiesStateModel::AriaPropertiesStateModel(JsonObject properties_state)
-    : m_properties_state(move(properties_state))
-{
-    m_properties_state.for_each_member([&](auto property_name, JsonValue const& values) {
-        Value value;
-        value.name = property_name;
-        value.value = "";
-        m_values.append(value);
-        values.as_object().for_each_member([&](auto property_name, auto& property_value) {
-            Value value;
-            value.name = property_name;
-            value.value = property_value.to_deprecated_string();
-            m_values.append(value);
-        });
-    });
-}
-
-AriaPropertiesStateModel::~AriaPropertiesStateModel() = default;
-
-int AriaPropertiesStateModel::row_count(GUI::ModelIndex const&) const
-{
-    return m_values.size();
-}
-
-ErrorOr<String> AriaPropertiesStateModel::column_name(int column_index) const
-{
-    switch (column_index) {
-    case Column::PropertyName:
-        return "Name"_string;
-    case Column::PropertyValue:
-        return "Value"_string;
-    default:
-        return Error::from_string_view("Unexpected column index"sv);
-    }
-}
-
-GUI::Variant AriaPropertiesStateModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const
-{
-    auto& value = m_values[index.row()];
-    if (role == GUI::ModelRole::Display) {
-        if (index.column() == Column::PropertyName)
-            return value.name;
-        if (index.column() == Column::PropertyValue)
-            return value.value;
-    }
-
-    return {};
-}
-
-Vector<GUI::ModelIndex> AriaPropertiesStateModel::matches(AK::StringView searching, unsigned int flags, GUI::ModelIndex const& parent)
-{
-    if (m_values.is_empty())
-        return {};
-    Vector<GUI::ModelIndex> found_indices;
-    for (auto it = m_values.begin(); !it.is_end(); ++it) {
-        GUI::ModelIndex index = this->index(it.index(), Column::PropertyName, parent);
-        if (!string_matches(data(index, GUI::ModelRole::Display).as_string(), searching, flags))
-            continue;
-
-        found_indices.append(index);
-        if (flags & FirstMatchOnly)
-            break;
-    }
-    return found_indices;
-}
-
-}

+ 0 - 49
Userland/Libraries/LibWebView/AriaPropertiesStateModel.h

@@ -1,49 +0,0 @@
-/*
- * 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;
-};
-
-}

+ 2 - 6
Userland/Libraries/LibWebView/CMakeLists.txt

@@ -1,18 +1,14 @@
 include(${SerenityOS_SOURCE_DIR}/Meta/CMake/public_suffix.cmake)
 include(${SerenityOS_SOURCE_DIR}/Meta/CMake/public_suffix.cmake)
 
 
 set(SOURCES
 set(SOURCES
-    AccessibilityTreeModel.cpp
-    AriaPropertiesStateModel.cpp
     ConsoleClient.cpp
     ConsoleClient.cpp
     CookieJar.cpp
     CookieJar.cpp
     Database.cpp
     Database.cpp
-    DOMTreeModel.cpp
     History.cpp
     History.cpp
     PropertyTableModel.cpp
     PropertyTableModel.cpp
     RequestServerAdapter.cpp
     RequestServerAdapter.cpp
     SearchEngine.cpp
     SearchEngine.cpp
     SourceHighlighter.cpp
     SourceHighlighter.cpp
-    StylePropertiesModel.cpp
     TreeModel.cpp
     TreeModel.cpp
     URL.cpp
     URL.cpp
     UserAgent.cpp
     UserAgent.cpp
@@ -49,11 +45,11 @@ set(GENERATED_SOURCES
 )
 )
 
 
 serenity_lib(LibWebView webview)
 serenity_lib(LibWebView webview)
-target_link_libraries(LibWebView PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibProtocol LibJS LibWeb LibSQL)
+target_link_libraries(LibWebView PRIVATE LibCore LibFileSystem LibGfx LibIPC LibProtocol LibJS LibWeb LibSQL)
 target_compile_definitions(LibWebView PRIVATE ENABLE_PUBLIC_SUFFIX=$<BOOL:${ENABLE_PUBLIC_SUFFIX_DOWNLOAD}>)
 target_compile_definitions(LibWebView PRIVATE ENABLE_PUBLIC_SUFFIX=$<BOOL:${ENABLE_PUBLIC_SUFFIX_DOWNLOAD}>)
 
 
 if (SERENITYOS)
 if (SERENITYOS)
-    target_link_libraries(LibWebView PRIVATE LibFileSystemAccessClient)
+    target_link_libraries(LibWebView PRIVATE LibFileSystemAccessClient LibGUI)
 endif()
 endif()
 
 
 if (NOT SERENITYOS)
 if (NOT SERENITYOS)

+ 0 - 230
Userland/Libraries/LibWebView/DOMTreeModel.cpp

@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2018-2020, Adam Hodgen <ant1441@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "DOMTreeModel.h"
-#include <AK/JsonObject.h>
-#include <AK/StringBuilder.h>
-#include <LibGUI/TreeView.h>
-#include <LibGfx/Palette.h>
-#include <ctype.h>
-
-namespace WebView {
-
-DOMTreeModel::DOMTreeModel(JsonObject dom_tree, GUI::TreeView* tree_view)
-    : m_tree_view(tree_view)
-    , m_dom_tree(move(dom_tree))
-{
-    // FIXME: Get these from the outside somehow instead of hard-coding paths here.
-#ifdef AK_OS_SERENITY
-    m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"sv).release_value_but_fixme_should_propagate_errors());
-    m_element_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors());
-    m_text_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors());
-#endif
-
-    map_dom_nodes_to_parent(nullptr, &m_dom_tree);
-}
-
-DOMTreeModel::~DOMTreeModel() = default;
-
-GUI::ModelIndex DOMTreeModel::index(int row, int column, const GUI::ModelIndex& parent) const
-{
-    if (!parent.is_valid()) {
-        return create_index(row, column, &m_dom_tree);
-    }
-
-    auto const& parent_node = *static_cast<JsonObject const*>(parent.internal_data());
-    auto children = get_children(parent_node);
-    if (!children.has_value())
-        return create_index(row, column, &m_dom_tree);
-
-    auto const& child_node = children->at(row).as_object();
-    return create_index(row, column, &child_node);
-}
-
-GUI::ModelIndex DOMTreeModel::parent_index(const GUI::ModelIndex& index) const
-{
-    // FIXME: Handle the template element (child elements are not stored in it, all of its children are in its document fragment "content")
-    //        Probably in the JSON generation in Node.cpp?
-    if (!index.is_valid())
-        return {};
-
-    auto const& node = *static_cast<JsonObject const*>(index.internal_data());
-
-    auto const* parent_node = get_parent(node);
-    if (!parent_node)
-        return {};
-
-    // If the parent is the root document, we know it has index 0, 0
-    if (parent_node == &m_dom_tree) {
-        return create_index(0, 0, parent_node);
-    }
-
-    // Otherwise, we need to find the grandparent, to find the index of parent within that
-    auto const* grandparent_node = get_parent(*parent_node);
-    VERIFY(grandparent_node);
-
-    auto grandparent_children = get_children(*grandparent_node);
-    if (!grandparent_children.has_value())
-        return {};
-
-    for (size_t grandparent_child_index = 0; grandparent_child_index < grandparent_children->size(); ++grandparent_child_index) {
-        auto const& child = grandparent_children->at(grandparent_child_index).as_object();
-        if (&child == parent_node)
-            return create_index(grandparent_child_index, 0, parent_node);
-    }
-
-    return {};
-}
-
-int DOMTreeModel::row_count(const GUI::ModelIndex& index) const
-{
-    if (!index.is_valid())
-        return 1;
-
-    auto const& node = *static_cast<JsonObject const*>(index.internal_data());
-    auto children = get_children(node);
-    return children.has_value() ? children->size() : 0;
-}
-
-int DOMTreeModel::column_count(const GUI::ModelIndex&) const
-{
-    return 1;
-}
-
-static DeprecatedString with_whitespace_collapsed(StringView string)
-{
-    StringBuilder builder;
-    for (size_t i = 0; i < string.length(); ++i) {
-        if (isspace(string[i])) {
-            builder.append(' ');
-            while (i < string.length()) {
-                if (isspace(string[i])) {
-                    ++i;
-                    continue;
-                }
-                builder.append(string[i]);
-                break;
-            }
-            continue;
-        }
-        builder.append(string[i]);
-    }
-    return builder.to_deprecated_string();
-}
-
-GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
-{
-    auto const& node = *static_cast<JsonObject const*>(index.internal_data());
-    auto node_name = node.get_deprecated_string("name"sv).value_or({});
-    auto type = node.get_deprecated_string("type"sv).value_or("unknown");
-
-    // FIXME: This FIXME can go away when we fix the one below.
-#ifdef AK_OS_SERENITY
-    if (role == GUI::ModelRole::ForegroundColor) {
-        // FIXME: Allow models to return a foreground color *role*.
-        //        Then we won't need to have a GUI::TreeView& member anymore.
-        if (type == "comment"sv || type == "shadow-root"sv)
-            return m_tree_view->palette().syntax_comment();
-        if (type == "pseudo-element"sv)
-            return m_tree_view->palette().syntax_type();
-        if (!node.get_bool("visible"sv).value_or(true))
-            return m_tree_view->palette().syntax_comment();
-        return {};
-    }
-#endif
-
-    // FIXME: This FIXME can go away when the icons are provided from the outside (see constructor).
-#ifdef AK_OS_SERENITY
-    if (role == GUI::ModelRole::Icon) {
-        if (type == "document")
-            return m_document_icon;
-        if (type == "element")
-            return m_element_icon;
-        // FIXME: More node type icons?
-        return m_text_icon;
-    }
-#endif
-
-    if (role == GUI::ModelRole::Display) {
-        if (type == "text")
-            return with_whitespace_collapsed(node.get_deprecated_string("text"sv).value());
-        if (type == "comment"sv)
-            return DeprecatedString::formatted("<!--{}-->", node.get_deprecated_string("data"sv).value());
-        if (type == "shadow-root"sv)
-            return DeprecatedString::formatted("{} ({})", node_name, node.get_deprecated_string("mode"sv).value());
-        if (type != "element")
-            return node_name;
-
-        StringBuilder builder;
-        builder.append('<');
-        builder.append(node_name.to_lowercase());
-        if (node.has("attributes"sv)) {
-            auto attributes = node.get_object("attributes"sv).value();
-            attributes.for_each_member([&builder](auto& name, JsonValue const& value) {
-                builder.append(' ');
-                builder.append(name);
-                builder.append('=');
-                builder.append('"');
-                builder.append(value.to_deprecated_string());
-                builder.append('"');
-            });
-        }
-        builder.append('>');
-        return builder.to_deprecated_string();
-    }
-    return {};
-}
-
-void DOMTreeModel::map_dom_nodes_to_parent(JsonObject const* parent, JsonObject const* node)
-{
-    m_dom_node_to_parent_map.set(node, parent);
-    m_node_id_to_dom_node_map.set(node->get_i32("id"sv).value_or(0), node);
-
-    auto children = get_children(*node);
-    if (!children.has_value())
-        return;
-
-    children->for_each([&](auto const& child) {
-        auto const& child_node = child.as_object();
-        map_dom_nodes_to_parent(node, &child_node);
-    });
-}
-
-GUI::ModelIndex DOMTreeModel::index_for_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> pseudo_element) const
-{
-    auto node = m_node_id_to_dom_node_map.get(node_id).value_or(nullptr);
-    if (node) {
-        if (pseudo_element.has_value()) {
-            // Find pseudo-element child of the node.
-            auto node_children = get_children(*node);
-            for (size_t i = 0; i < node_children->size(); i++) {
-                auto& child = node_children->at(i).as_object();
-                if (!child.has("pseudo-element"sv))
-                    continue;
-
-                auto child_pseudo_element = child.get_i32("pseudo-element"sv);
-                if (child_pseudo_element == to_underlying(pseudo_element.value()))
-                    return create_index(i, 0, &child);
-            }
-        } else {
-            auto* parent = get_parent(*node);
-            if (!parent)
-                return {};
-            auto parent_children = get_children(*parent);
-            for (size_t i = 0; i < parent_children->size(); i++) {
-                if (&parent_children->at(i).as_object() == node) {
-                    return create_index(i, 0, node);
-                }
-            }
-        }
-    }
-
-    dbgln("Didn't find index for node {}, pseudo-element {}!", node_id, pseudo_element.has_value() ? Web::CSS::pseudo_element_name(pseudo_element.value()) : "NONE"sv);
-    return {};
-}
-
-}

+ 0 - 68
Userland/Libraries/LibWebView/DOMTreeModel.h

@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2018-2020, Adam Hodgen <ant1441@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/HashMap.h>
-#include <AK/JsonObject.h>
-#include <LibGUI/Model.h>
-#include <LibWeb/CSS/Selector.h>
-#include <LibWeb/Forward.h>
-
-namespace WebView {
-
-class DOMTreeModel final : public GUI::Model {
-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));
-    }
-
-    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;
-
-    virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
-    virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
-    virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
-    virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override;
-    virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
-
-    GUI::ModelIndex index_for_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> pseudo_element) const;
-
-private:
-    DOMTreeModel(JsonObject, GUI::TreeView*);
-
-    ALWAYS_INLINE JsonObject const* get_parent(JsonObject const& o) const
-    {
-        auto parent_node = m_dom_node_to_parent_map.get(&o);
-        VERIFY(parent_node.has_value());
-        return *parent_node;
-    }
-
-    ALWAYS_INLINE static Optional<JsonArray const&> const get_children(JsonObject const& o)
-    {
-        return o.get_array("children"sv);
-    }
-
-    void map_dom_nodes_to_parent(JsonObject const* parent, JsonObject const* child);
-
-    GUI::TreeView* m_tree_view { nullptr };
-    GUI::Icon m_document_icon;
-    GUI::Icon m_element_icon;
-    GUI::Icon m_text_icon;
-    JsonObject m_dom_tree;
-    HashMap<JsonObject const*, JsonObject const*> m_dom_node_to_parent_map;
-    HashMap<i32, JsonObject const*> m_node_id_to_dom_node_map;
-};
-
-}

+ 0 - 74
Userland/Libraries/LibWebView/StylePropertiesModel.cpp

@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "StylePropertiesModel.h"
-#include <AK/QuickSort.h>
-
-namespace WebView {
-
-StylePropertiesModel::StylePropertiesModel(JsonObject properties)
-    : m_properties(move(properties))
-{
-    m_properties.for_each_member([&](auto& property_name, auto& property_value) {
-        Value value;
-        value.name = property_name;
-        value.value = property_value.to_deprecated_string();
-        m_values.append(value);
-    });
-
-    quick_sort(m_values, [](auto& a, auto& b) { return a.name < b.name; });
-}
-
-StylePropertiesModel::~StylePropertiesModel() = default;
-
-int StylePropertiesModel::row_count(GUI::ModelIndex const&) const
-{
-    return m_values.size();
-}
-
-ErrorOr<String> StylePropertiesModel::column_name(int column_index) const
-{
-    switch (column_index) {
-    case Column::PropertyName:
-        return "Name"_string;
-    case Column::PropertyValue:
-        return "Value"_string;
-    default:
-        VERIFY_NOT_REACHED();
-    }
-}
-
-GUI::Variant StylePropertiesModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const
-{
-    auto& value = m_values[index.row()];
-    if (role == GUI::ModelRole::Display) {
-        if (index.column() == Column::PropertyName)
-            return value.name;
-        if (index.column() == Column::PropertyValue)
-            return value.value;
-    }
-    return {};
-}
-
-Vector<GUI::ModelIndex> StylePropertiesModel::matches(StringView searching, unsigned flags, GUI::ModelIndex const& parent)
-{
-    if (m_values.is_empty())
-        return {};
-    Vector<GUI::ModelIndex> found_indices;
-    for (auto it = m_values.begin(); !it.is_end(); ++it) {
-        GUI::ModelIndex index = this->index(it.index(), Column::PropertyName, parent);
-        if (!string_matches(data(index, GUI::ModelRole::Display).as_string(), searching, flags))
-            continue;
-
-        found_indices.append(index);
-        if (flags & FirstMatchOnly)
-            break;
-    }
-    return found_indices;
-}
-
-}

+ 0 - 51
Userland/Libraries/LibWebView/StylePropertiesModel.h

@@ -1,51 +0,0 @@
-/*
- * 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 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 StylePropertiesModel(JsonObject);
-
-    JsonObject m_properties;
-
-    struct Value {
-        DeprecatedString name;
-        DeprecatedString value;
-    };
-    Vector<Value> m_values;
-};
-
-}