Skip to content

Commit

Permalink
Remove some usage of unsafe code in History
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Aug 8, 2019
1 parent 51e22fb commit d1282dc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions components/script/dom/history.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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>,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
}
}

0 comments on commit d1282dc

Please sign in to comment.