servo: Track async webview focus operations (#38243)

https://github.com/servo/servo/pull/38160 added a webdriver-specific API
to support waiting on focus operations to complete. These changes
replace that with a generalized pattern, where a unique ID is created
for each focus operation and the embedder can receive notifications
about each focus operation when it is complete, regardless of whether
the focus was actually changed.

Testing: Existing test coverage from
https://github.com/servo/servo/pull/38160/ is unchanged.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-07-24 02:01:11 -04:00 committed by GitHub
parent 0b8986c8da
commit be38bd4636
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 99 additions and 77 deletions

View file

@ -380,7 +380,8 @@ impl App {
},
WebDriverCommandMsg::FocusWebView(webview_id, response_sender) => {
if let Some(webview) = running_state.webview_by_id(webview_id) {
webview.focus_from_webdriver(response_sender);
let focus_id = webview.focus();
running_state.set_pending_focus(focus_id, response_sender);
}
},
WebDriverCommandMsg::GetWindowRect(_webview_id, response_sender) => {
@ -478,21 +479,13 @@ impl App {
WebDriverCommandMsg::GoBack(webview_id, load_status_sender) => {
if let Some(webview) = running_state.webview_by_id(webview_id) {
let traversal_id = webview.go_back(1);
running_state.set_pending_traversal(
webview_id,
traversal_id,
load_status_sender,
);
running_state.set_pending_traversal(traversal_id, load_status_sender);
}
},
WebDriverCommandMsg::GoForward(webview_id, load_status_sender) => {
if let Some(webview) = running_state.webview_by_id(webview_id) {
let traversal_id = webview.go_forward(1);
running_state.set_pending_traversal(
webview_id,
traversal_id,
load_status_sender,
);
running_state.set_pending_traversal(traversal_id, load_status_sender);
}
},
// Key events don't need hit test so can be forwarded to constellation for now