mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
script: Make root_from_handle_value
a safe function by accepting SafeJSContext
(#39193)
Change from unsafe pointer of root_from_handle_value to SafeJSContext. #39131 --------- Signed-off-by: JasonHonKL <j2004nol@gmail.com> Signed-off-by: Jason <jason@198-61-252-113-on-nets.com> Signed-off-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Jason <jason@198-61-252-113-on-nets.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
721fc01c30
commit
839878c743
4 changed files with 48 additions and 51 deletions
|
@ -295,70 +295,57 @@ pub(crate) fn evaluate_key_path_on_value(
|
|||
|
||||
// If value is a Blob and identifier is "size"
|
||||
if identifier == "size" {
|
||||
unsafe {
|
||||
if let Ok(blob) = root_from_handlevalue::<Blob>(current_value.handle(), *cx)
|
||||
{
|
||||
// Let value be a Number equal to value’s size.
|
||||
blob.Size().safe_to_jsval(cx, current_value.handle_mut());
|
||||
if let Ok(blob) = root_from_handlevalue::<Blob>(current_value.handle(), cx) {
|
||||
// Let value be a Number equal to value’s size.
|
||||
blob.Size().safe_to_jsval(cx, current_value.handle_mut());
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If value is a Blob and identifier is "type"
|
||||
if identifier == "type" {
|
||||
unsafe {
|
||||
if let Ok(blob) = root_from_handlevalue::<Blob>(current_value.handle(), *cx)
|
||||
{
|
||||
// Let value be a String equal to value’s type.
|
||||
blob.Type().safe_to_jsval(cx, current_value.handle_mut());
|
||||
if let Ok(blob) = root_from_handlevalue::<Blob>(current_value.handle(), cx) {
|
||||
// Let value be a String equal to value’s type.
|
||||
blob.Type().safe_to_jsval(cx, current_value.handle_mut());
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If value is a File and identifier is "name"
|
||||
if identifier == "name" {
|
||||
unsafe {
|
||||
if let Ok(file) = root_from_handlevalue::<File>(current_value.handle(), *cx)
|
||||
{
|
||||
// Let value be a String equal to value’s name.
|
||||
file.name().safe_to_jsval(cx, current_value.handle_mut());
|
||||
if let Ok(file) = root_from_handlevalue::<File>(current_value.handle(), cx) {
|
||||
// Let value be a String equal to value’s name.
|
||||
file.name().safe_to_jsval(cx, current_value.handle_mut());
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If value is a File and identifier is "lastModified"
|
||||
if identifier == "lastModified" {
|
||||
unsafe {
|
||||
if let Ok(file) = root_from_handlevalue::<File>(current_value.handle(), *cx)
|
||||
{
|
||||
// Let value be a Number equal to value’s lastModified.
|
||||
file.LastModified()
|
||||
.safe_to_jsval(cx, current_value.handle_mut());
|
||||
if let Ok(file) = root_from_handlevalue::<File>(current_value.handle(), cx) {
|
||||
// Let value be a Number equal to value’s lastModified.
|
||||
file.LastModified()
|
||||
.safe_to_jsval(cx, current_value.handle_mut());
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If value is a File and identifier is "lastModifiedDate"
|
||||
if identifier == "lastModifiedDate" {
|
||||
unsafe {
|
||||
if let Ok(file) = root_from_handlevalue::<File>(current_value.handle(), *cx)
|
||||
{
|
||||
// Let value be a new Date object with [[DateValue]] internal slot equal to value’s lastModified.
|
||||
let time = ClippedTime {
|
||||
t: file.LastModified() as f64,
|
||||
};
|
||||
if let Ok(file) = root_from_handlevalue::<File>(current_value.handle(), cx) {
|
||||
// Let value be a new Date object with [[DateValue]] internal slot equal to value’s lastModified.
|
||||
let time = ClippedTime {
|
||||
t: file.LastModified() as f64,
|
||||
};
|
||||
unsafe {
|
||||
NewDateObject(*cx, time).safe_to_jsval(cx, current_value.handle_mut());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue