Sfoglia il codice sorgente

LibWebView: Remove now-unused PropertyTableModel

Timothy Flynn 1 anno fa
parent
commit
6eadf4a778

+ 0 - 1
Meta/gn/secondary/Userland/Libraries/LibWebView/BUILD.gn

@@ -121,7 +121,6 @@ shared_library("LibWebView") {
     "Database.cpp",
     "History.cpp",
     "InspectorClient.cpp",
-    "PropertyTableModel.cpp",
     "RequestServerAdapter.cpp",
     "SearchEngine.cpp",
     "SourceHighlighter.cpp",

+ 0 - 1
Userland/Libraries/LibWebView/CMakeLists.txt

@@ -6,7 +6,6 @@ set(SOURCES
     Database.cpp
     History.cpp
     InspectorClient.cpp
-    PropertyTableModel.cpp
     RequestServerAdapter.cpp
     SearchEngine.cpp
     SourceHighlighter.cpp

+ 0 - 19
Userland/Libraries/LibWebView/ModelIndex.h

@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-namespace WebView {
-
-struct ModelIndex {
-    bool is_valid() const { return row != -1 && column != -1; }
-
-    int row { -1 };
-    int column { -1 };
-    void const* internal_data { nullptr };
-};
-
-}

+ 0 - 84
Userland/Libraries/LibWebView/PropertyTableModel.cpp

@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
- * Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
- * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <AK/JsonObject.h>
-#include <AK/JsonValue.h>
-#include <AK/QuickSort.h>
-#include <LibWebView/PropertyTableModel.h>
-
-namespace WebView {
-
-PropertyTableModel::PropertyTableModel(Type type, JsonValue const& properties)
-{
-    properties.as_object().for_each_member([&](auto const& property_name, auto const& property_value) {
-        switch (type) {
-        case PropertyTableModel::Type::ARIAProperties:
-            m_values.empend(MUST(String::from_deprecated_string(property_name)), String {});
-
-            property_value.as_object().for_each_member([&](auto const& property_name, auto const& property_value) {
-                m_values.empend(MUST(String::from_deprecated_string(property_name)), MUST(String::from_deprecated_string(property_value.to_deprecated_string())));
-            });
-
-            break;
-
-        case PropertyTableModel::Type::StyleProperties:
-            m_values.empend(MUST(String::from_deprecated_string(property_name)), MUST(String::from_deprecated_string(property_value.to_deprecated_string())));
-            break;
-        }
-    });
-
-    quick_sort(m_values, [](auto const& a, auto const& b) {
-        return a.name < b.name;
-    });
-}
-
-PropertyTableModel::~PropertyTableModel() = default;
-
-int PropertyTableModel::row_count(ModelIndex const&) const
-{
-    return static_cast<int>(m_values.size());
-}
-
-int PropertyTableModel::column_count(ModelIndex const&) const
-{
-    return 2;
-}
-
-ErrorOr<String> PropertyTableModel::column_name(int column_index) const
-{
-    switch (static_cast<Column>(column_index)) {
-    case Column::PropertyName:
-        return "Name"_string;
-    case Column::PropertyValue:
-        return "Value"_string;
-    }
-
-    VERIFY_NOT_REACHED();
-}
-
-ModelIndex PropertyTableModel::index(int row, int column, ModelIndex const&) const
-{
-    return { row, column };
-}
-
-String PropertyTableModel::text_for_display(ModelIndex const& index) const
-{
-    auto const& value = m_values[index.row];
-
-    switch (static_cast<Column>(index.column)) {
-    case Column::PropertyName:
-        return value.name;
-    case Column::PropertyValue:
-        return value.value;
-    }
-
-    VERIFY_NOT_REACHED();
-}
-
-}

+ 0 - 60
Userland/Libraries/LibWebView/PropertyTableModel.h

@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
- * Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
- * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/IterationDecision.h>
-#include <AK/String.h>
-#include <AK/Vector.h>
-#include <LibWebView/ModelIndex.h>
-
-namespace WebView {
-
-class PropertyTableModel {
-public:
-    enum class Type {
-        ARIAProperties,
-        StyleProperties,
-    };
-
-    enum class Column : int {
-        PropertyName,
-        PropertyValue,
-    };
-
-    PropertyTableModel(Type, JsonValue const&);
-    ~PropertyTableModel();
-
-    template<typename Callback>
-    void for_each_property_name(Callback&& callback)
-    {
-        for (size_t i = 0; i < m_values.size(); ++i) {
-            ModelIndex index { static_cast<int>(i), to_underlying(WebView::PropertyTableModel::Column::PropertyName) };
-            auto const& property_name = m_values[i].name;
-
-            if (callback(index, property_name) == IterationDecision::Break)
-                break;
-        }
-    }
-
-    int row_count(ModelIndex const& parent) const;
-    int column_count(ModelIndex const& parent) const;
-    ErrorOr<String> column_name(int) const;
-    ModelIndex index(int row, int column, ModelIndex const& parent) const;
-    String text_for_display(ModelIndex const& index) const;
-
-private:
-    struct Value {
-        String name;
-        String value;
-    };
-    Vector<Value> m_values;
-};
-
-}