LibWebView: Clear the Inspector DOM/accessibility trees upon reset

This prevents rendering stale trees while navigating to a new page. The
old non-WebView inspector widgets behaved this way.
This commit is contained in:
Timothy Flynn 2023-12-10 09:32:26 -05:00 committed by Andreas Kling
parent 60c7ff9db1
commit 41ffc69c9d
2 changed files with 16 additions and 2 deletions

View file

@ -85,6 +85,19 @@ const scrollToElement = element => {
window.scrollTo(0, position);
};
inspector.reset = () => {
let domTree = document.getElementById("dom-tree");
domTree.innerHTML = "";
let accessibilityTree = document.getElementById("accessibility-tree");
accessibilityTree.innerHTML = "";
selectedDOMNode = null;
pendingEditDOMNode = null;
inspector.clearConsoleOutput();
};
inspector.loadDOMTree = tree => {
let domTree = document.getElementById("dom-tree");
domTree.innerHTML = atob(tree);

View file

@ -181,12 +181,13 @@ void InspectorClient::inspect()
void InspectorClient::reset()
{
static constexpr auto script = "inspector.reset();"sv;
m_inspector_web_view.run_javascript(script);
m_body_node_id.clear();
m_pending_selection.clear();
m_dom_tree_loaded = false;
clear_console_output();
m_highest_notified_message_index = -1;
m_highest_received_message_index = -1;
m_waiting_for_messages = false;