feat: display file chosen for input file (#35789)

Signed-off-by: DK Liao <dklassic@gmail.com>
This commit is contained in:
DK Liao 2025-03-10 12:55:38 +09:00 committed by GitHub
parent 34047f8da8
commit ce4ba30992
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 53 additions and 5 deletions

View file

@ -6,6 +6,7 @@ use std::slice::Iter;
use dom_struct::dom_struct;
use super::bindings::root::{LayoutDom, ToLayout};
use crate::dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
use crate::dom::bindings::root::{Dom, DomRoot};
@ -69,3 +70,23 @@ impl FileListMethods<crate::DomTypeHolder> for FileList {
self.Item(index)
}
}
pub(crate) trait LayoutFileListHelpers<'dom> {
fn file_for_layout(&self, index: u32) -> Option<&File>;
fn len(&self) -> usize;
}
#[allow(unsafe_code)]
impl<'dom> LayoutFileListHelpers<'dom> for LayoutDom<'dom, FileList> {
fn len(&self) -> usize {
self.unsafe_get().list.len()
}
fn file_for_layout(&self, index: u32) -> Option<&File> {
let list = &self.unsafe_get().list;
if (index as usize) < list.len() {
Some(unsafe { list[index as usize].to_layout().unsafe_get() })
} else {
None
}
}
}