libservo: Integrate context menu into the show_embedder_control API (#40402)

This PR integrates showing context menus into the
`WebViewDelegate::show_embedder_control` API. In addition,
`ContextMenuItem` and `ContextMenuAction` data types are exposed which
abstract away the different components of the context menu. Later
changes will implement this API for servoshell as well as add
element-specific actions such as "Select All" and "Copy Image URL".

Testing: This change adds a WebView API test.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
Martin Robinson
2025-11-04 22:08:04 +01:00
committed by GitHub
parent 6ec242580c
commit 2c77d9d8a1
11 changed files with 262 additions and 97 deletions

View File

@@ -9,7 +9,6 @@ use std::mem;
use std::rc::Rc;
use std::time::{Duration, Instant};
use base::generic_channel;
use constellation_traits::{KeyboardScroll, ScriptToConstellationMessage};
use embedder_traits::{
Cursor, EditingActionEvent, EmbedderMsg, GamepadEvent as EmbedderGamepadEvent,
@@ -763,15 +762,10 @@ impl DocumentEventHandler {
// Step 4. If result is true, then show the UA context menu
if result {
let (sender, receiver) =
generic_channel::channel().expect("Failed to create IPC channel.");
self.window.send_to_embedder(EmbedderMsg::ShowContextMenu(
self.window.webview_id(),
sender,
None,
vec![],
));
let _ = receiver.recv().unwrap();
self.window
.Document()
.embedder_controls()
.show_context_menu(hit_test_result);
};
}