1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:27:34 +00:00

LibWebView: Create a TreeModel helper class for DOM/accessibility models

We currently have DOMTreeModel and AccessibilityTreeModel in LibWebView.
These depend on GUI::Model and GUI::ModelIndex, which is the only reason
that the non-Serenity Ladybird chromes require LibGUI. Further, these
classes are very nearly idenitical.

This creates a TreeModel class to provide the base functionality for all
tree-based model types used by all Ladybird chromes. It contains code
common to the DOM / accessibility tree models, and handles the slight
differences between the two (namely, just the formatting of each node's
text for display).

The Qt and Serenity chromes can create thin wrappers around this class
to adapt its interface to their chrome-specific model classes (i.e.
QAbstractItemModel and GUI::Model).
This commit is contained in:
Timothy Flynn 2023-11-04 11:48:23 -04:00 committed by Andreas Kling
parent 2bec281ddc
commit 3999c74237
4 changed files with 280 additions and 0 deletions

View file

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