mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
feat: display file chosen for input file (#35789)
Signed-off-by: DK Liao <dklassic@gmail.com>
This commit is contained in:
parent
34047f8da8
commit
ce4ba30992
3 changed files with 53 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue