servoshell: Migrate to egui-file-dialog from tinyfiledialogs (#34823)

This is the first step toward completely replacing tinyfiledialogs with
an egui-based solution.

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
chickenleaf 2025-02-04 23:54:24 +05:30 committed by GitHub
parent e41b34a1bf
commit 62f1dbebff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 261 additions and 70 deletions

View file

@ -582,7 +582,7 @@ impl FileManagerStore {
patterns: Vec<FilterPattern>,
multiple_files: bool,
embedder_proxy: EmbedderProxy,
) -> Option<Vec<String>> {
) -> Option<Vec<PathBuf>> {
let (ipc_sender, ipc_receiver) = ipc::channel().expect("Failed to create IPC channel!");
embedder_proxy.send(EmbedderMsg::SelectFiles(
webview_id,
@ -605,7 +605,7 @@ impl FileManagerStore {
patterns: Vec<FilterPattern>,
sender: IpcSender<FileManagerResult<SelectedFile>>,
origin: FileOrigin,
opt_test_path: Option<String>,
opt_test_path: Option<PathBuf>,
embedder_proxy: EmbedderProxy,
) {
// Check if the select_files preference is enabled
@ -636,7 +636,7 @@ impl FileManagerStore {
patterns: Vec<FilterPattern>,
sender: IpcSender<FileManagerResult<Vec<SelectedFile>>>,
origin: FileOrigin,
opt_test_paths: Option<Vec<String>>,
opt_test_paths: Option<Vec<PathBuf>>,
embedder_proxy: EmbedderProxy,
) {
// Check if the select_files preference is enabled

View file

@ -49,7 +49,7 @@ fn test_filemanager() {
patterns.clone(),
tx,
origin.clone(),
Some("tests/test.jpeg".to_string()),
Some("tests/test.jpeg".into()),
));
let selected = rx
.recv()

View file

@ -6,7 +6,9 @@ use std::borrow::Cow;
use std::cell::Cell;
use std::cmp::Ordering;
use std::ops::Range;
use std::path::PathBuf;
use std::ptr::NonNull;
use std::str::FromStr;
use std::{f64, ptr};
use dom_struct::dom_struct;
@ -1905,8 +1907,12 @@ impl HTMLInputElement {
let target = self.upcast::<EventTarget>();
if self.Multiple() {
let opt_test_paths =
opt_test_paths.map(|paths| paths.iter().map(|p| p.to_string()).collect());
let opt_test_paths = opt_test_paths.map(|paths| {
paths
.iter()
.filter_map(|p| PathBuf::from_str(p).ok())
.collect()
});
let (chan, recv) = ipc::channel(self.global().time_profiler_chan().clone())
.expect("Error initializing channel");
@ -1930,7 +1936,7 @@ impl HTMLInputElement {
if paths.is_empty() {
return;
} else {
Some(paths[0].to_string()) // neglect other paths
Some(PathBuf::from(paths[0].to_string())) // neglect other paths
}
},
None => None,
@ -2948,6 +2954,7 @@ impl Activatable for HTMLInputElement {
fn filter_from_accept(s: &DOMString) -> Vec<FilterPattern> {
let mut filter = vec![];
for p in split_commas(s) {
let p = p.trim();
if let Some('.') = p.chars().next() {
filter.push(FilterPattern(p[1..].to_string()));
} else if let Some(exts) = mime_guess::get_mime_extensions_str(p) {

View file

@ -5,6 +5,7 @@
pub mod resources;
use std::fmt::{Debug, Error, Formatter};
use std::path::PathBuf;
use base::id::{PipelineId, WebViewId};
use crossbeam_channel::Sender;
@ -213,7 +214,7 @@ pub enum EmbedderMsg {
WebViewId,
Vec<FilterPattern>,
bool,
IpcSender<Option<Vec<String>>>,
IpcSender<Option<Vec<PathBuf>>>,
),
/// Open interface to request permission specified by prompt.
PromptPermission(WebViewId, PermissionPrompt, IpcSender<PermissionRequest>),

View file

@ -141,7 +141,7 @@ pub enum FileManagerThreadMsg {
Vec<FilterPattern>,
IpcSender<FileManagerResult<SelectedFile>>,
FileOrigin,
Option<String>,
Option<PathBuf>,
),
/// Select multiple files. Last field is pre-selected file paths for testing
@ -150,7 +150,7 @@ pub enum FileManagerThreadMsg {
Vec<FilterPattern>,
IpcSender<FileManagerResult<Vec<SelectedFile>>>,
FileOrigin,
Option<Vec<String>>,
Option<Vec<PathBuf>>,
),
/// Read FileID-indexed file in chunks, optionally check URL validity based on boolean flag