mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Add AsHandleValue trait to Heap<Value> and make Heap values rooted (#38024)
Encapsulates the unsafe conversion from Heap<Value> to HandleValue<'a>, and reducing repetitive unsafe code at call. fix #37258
This commit is contained in:
parent
9416251cab
commit
04ec710e60
17 changed files with 204 additions and 146 deletions
|
@ -115,7 +115,7 @@ pub(crate) enum FileReaderReadyState {
|
|||
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
pub(crate) enum FileReaderResult {
|
||||
ArrayBuffer(#[ignore_malloc_size_of = "mozjs"] Heap<JSVal>),
|
||||
ArrayBuffer(#[ignore_malloc_size_of = "mozjs"] RootedTraceableBox<Heap<JSVal>>),
|
||||
String(DOMString),
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,8 @@ impl FileReader {
|
|||
.is_ok()
|
||||
);
|
||||
|
||||
*result.borrow_mut() = Some(FileReaderResult::ArrayBuffer(Heap::default()));
|
||||
*result.borrow_mut() =
|
||||
Some(FileReaderResult::ArrayBuffer(RootedTraceableBox::default()));
|
||||
|
||||
if let Some(FileReaderResult::ArrayBuffer(ref mut heap)) = *result.borrow_mut() {
|
||||
heap.set(jsval::ObjectValue(array_buffer.get()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue