LibWebView: Add simple ID tracking to WebViews

For Firefox DevTools, we will need to track WebViews by a numerical ID.
Here, we just increment a static 64-bit counter. We can switch to using
IDAllocator if we ever have an issue with this.

This patch adds such an ID to the views and a couple of APIs to access
WebViews after creation.
This commit is contained in:
Timothy Flynn 2025-02-15 08:06:36 -05:00 committed by Tim Flynn
commit 3904765c4f
Notes: github-actions[bot] 2025-02-19 13:47:36 +00:00
2 changed files with 33 additions and 1 deletions

View file

@ -43,6 +43,11 @@ public:
String fonts_json;
};
static void for_each_view(Function<IterationDecision(ViewImplementation&)>);
static Optional<ViewImplementation&> find_view_by_id(u64);
u64 view_id() const { return m_view_id; }
void set_url(Badge<WebContentClient>, URL::URL url) { m_url = move(url); }
URL::URL const& url() const { return m_url; }
@ -304,6 +309,10 @@ protected:
size_t m_number_of_elements_playing_audio { 0 };
Web::HTML::MuteState m_mute_state { Web::HTML::MuteState::Unmuted };
// FIXME: Reconcile this ID with `page_id`. The latter is only unique per WebContent connection, whereas the view ID
// is required to be globally unique for Firefox DevTools.
u64 m_view_id { 0 };
};
}