mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Remove some usage of unsafe code in History
This commit is contained in:
parent
51e22fbc26
commit
d1282dc8cc
1 changed files with 10 additions and 10 deletions
|
@ -18,9 +18,9 @@ use crate::dom::globalscope::GlobalScope;
|
|||
use crate::dom::hashchangeevent::HashChangeEvent;
|
||||
use crate::dom::popstateevent::PopStateEvent;
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use crate::script_runtime::JSContext;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{Heap, JSContext};
|
||||
use js::jsapi::Heap;
|
||||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use js::rust::HandleValue;
|
||||
use msg::constellation_msg::{HistoryStateId, TraversalDirection};
|
||||
|
@ -165,7 +165,7 @@ impl History {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-history-replacestate
|
||||
fn push_or_replace_state(
|
||||
&self,
|
||||
cx: *mut JSContext,
|
||||
cx: JSContext,
|
||||
data: HandleValue,
|
||||
_title: DOMString,
|
||||
url: Option<USVString>,
|
||||
|
@ -185,7 +185,7 @@ impl History {
|
|||
// TODO: Step 4
|
||||
|
||||
// Step 5
|
||||
let serialized_data = StructuredCloneData::write(cx, data)?.move_to_arraybuffer();
|
||||
let serialized_data = StructuredCloneData::write(*cx, data)?.move_to_arraybuffer();
|
||||
|
||||
let new_url: ServoUrl = match url {
|
||||
// Step 6
|
||||
|
@ -265,7 +265,7 @@ impl History {
|
|||
|
||||
// Step 11
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
rooted!(in(cx) let mut state = UndefinedValue());
|
||||
rooted!(in(*cx) let mut state = UndefinedValue());
|
||||
StructuredCloneData::Vector(serialized_data).read(&global_scope, state.handle_mut());
|
||||
|
||||
// Step 12
|
||||
|
@ -280,7 +280,7 @@ impl History {
|
|||
|
||||
impl HistoryMethods for History {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-history-state
|
||||
fn GetState(&self, _cx: SafeJSContext) -> Fallible<JSVal> {
|
||||
fn GetState(&self, _cx: JSContext) -> Fallible<JSVal> {
|
||||
if !self.window.Document().is_fully_active() {
|
||||
return Err(Error::Security);
|
||||
}
|
||||
|
@ -329,22 +329,22 @@ impl HistoryMethods for History {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-history-pushstate
|
||||
fn PushState(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
cx: JSContext,
|
||||
data: HandleValue,
|
||||
title: DOMString,
|
||||
url: Option<USVString>,
|
||||
) -> ErrorResult {
|
||||
self.push_or_replace_state(*cx, data, title, url, PushOrReplace::Push)
|
||||
self.push_or_replace_state(cx, data, title, url, PushOrReplace::Push)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-history-replacestate
|
||||
fn ReplaceState(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
cx: JSContext,
|
||||
data: HandleValue,
|
||||
title: DOMString,
|
||||
url: Option<USVString>,
|
||||
) -> ErrorResult {
|
||||
self.push_or_replace_state(*cx, data, title, url, PushOrReplace::Replace)
|
||||
self.push_or_replace_state(cx, data, title, url, PushOrReplace::Replace)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue