mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
CanGc fixes and checks in multiple files (#33836)
* CanGc fixes and checks in multiple files Signed-off-by: L Ashwin B <lashwinib@gmail.com> * CanGc fixes in storageevent.rs Signed-off-by: L Ashwin B <lashwinib@gmail.com> --------- Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
parent
2f1862aaf5
commit
1e39787573
9 changed files with 74 additions and 59 deletions
|
@ -183,6 +183,7 @@ DOMInterfaces = {
|
|||
|
||||
'RTCPeerConnection': {
|
||||
'inRealms': ['AddIceCandidate', 'CreateAnswer', 'CreateOffer', 'SetLocalDescription', 'SetRemoteDescription'],
|
||||
'canGc': ['Close'],
|
||||
},
|
||||
|
||||
'Range': {
|
||||
|
|
|
@ -4645,6 +4645,7 @@ impl DocumentMethods for Document {
|
|||
"storageevent" => Ok(DomRoot::upcast(StorageEvent::new_uninitialized(
|
||||
&self.window,
|
||||
"".into(),
|
||||
can_gc,
|
||||
))),
|
||||
"touchevent" => Ok(DomRoot::upcast(TouchEvent::new_uninitialized(
|
||||
&self.window,
|
||||
|
@ -4652,7 +4653,10 @@ impl DocumentMethods for Document {
|
|||
&TouchList::new(&self.window, &[]),
|
||||
&TouchList::new(&self.window, &[]),
|
||||
))),
|
||||
"uievent" | "uievents" => Ok(DomRoot::upcast(UIEvent::new_uninitialized(&self.window))),
|
||||
"uievent" | "uievents" => Ok(DomRoot::upcast(UIEvent::new_uninitialized(
|
||||
&self.window,
|
||||
can_gc,
|
||||
))),
|
||||
_ => Err(Error::NotSupported),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ 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;
|
||||
use crate::script_runtime::{CanGc, JSContext};
|
||||
|
||||
enum PushOrReplace {
|
||||
Push,
|
||||
|
@ -83,7 +83,7 @@ impl History {
|
|||
/// <https://html.spec.whatwg.org/multipage/#history-traversal>
|
||||
/// Steps 5-16
|
||||
#[allow(unsafe_code)]
|
||||
pub fn activate_state(&self, state_id: Option<HistoryStateId>, url: ServoUrl) {
|
||||
pub fn activate_state(&self, state_id: Option<HistoryStateId>, url: ServoUrl, can_gc: CanGc) {
|
||||
// Steps 5
|
||||
let document = self.window.Document();
|
||||
let old_url = document.url().clone();
|
||||
|
@ -139,6 +139,7 @@ impl History {
|
|||
self.window.upcast::<EventTarget>(),
|
||||
&self.window,
|
||||
unsafe { HandleValue::from_raw(self.state.handle()) },
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,16 +69,14 @@ impl PopStateEvent {
|
|||
ev
|
||||
}
|
||||
|
||||
pub fn dispatch_jsval(target: &EventTarget, window: &Window, state: HandleValue) {
|
||||
let event = PopStateEvent::new(
|
||||
window,
|
||||
None,
|
||||
atom!("popstate"),
|
||||
false,
|
||||
false,
|
||||
state,
|
||||
CanGc::note(),
|
||||
);
|
||||
pub fn dispatch_jsval(
|
||||
target: &EventTarget,
|
||||
window: &Window,
|
||||
state: HandleValue,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
let event =
|
||||
PopStateEvent::new(window, None, atom!("popstate"), false, false, state, can_gc);
|
||||
event.upcast::<Event>().fire(target);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -749,7 +749,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
|||
}
|
||||
|
||||
/// <https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close>
|
||||
fn Close(&self) {
|
||||
fn Close(&self, can_gc: CanGc) {
|
||||
// Step 1
|
||||
if self.closed.get() {
|
||||
return;
|
||||
|
@ -765,7 +765,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
|||
|
||||
// Step 6
|
||||
for (_, val) in self.data_channels.borrow().iter() {
|
||||
val.on_state_change(DataChannelState::Closed, CanGc::note());
|
||||
val.on_state_change(DataChannelState::Closed, can_gc);
|
||||
}
|
||||
|
||||
// Step 7-10
|
||||
|
|
|
@ -49,8 +49,12 @@ impl StorageEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(window: &Window, url: DOMString) -> DomRoot<StorageEvent> {
|
||||
Self::new_uninitialized_with_proto(window, None, url, CanGc::note())
|
||||
pub fn new_uninitialized(
|
||||
window: &Window,
|
||||
url: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<StorageEvent> {
|
||||
Self::new_uninitialized_with_proto(window, None, url, can_gc)
|
||||
}
|
||||
|
||||
fn new_uninitialized_with_proto(
|
||||
|
|
|
@ -38,8 +38,8 @@ impl UIEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(window: &Window) -> DomRoot<UIEvent> {
|
||||
Self::new_uninitialized_with_proto(window, None, CanGc::note())
|
||||
pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<UIEvent> {
|
||||
Self::new_uninitialized_with_proto(window, None, can_gc)
|
||||
}
|
||||
|
||||
fn new_uninitialized_with_proto(
|
||||
|
@ -57,16 +57,10 @@ impl UIEvent {
|
|||
cancelable: EventCancelable,
|
||||
view: Option<&Window>,
|
||||
detail: i32,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<UIEvent> {
|
||||
Self::new_with_proto(
|
||||
window,
|
||||
None,
|
||||
type_,
|
||||
can_bubble,
|
||||
cancelable,
|
||||
view,
|
||||
detail,
|
||||
CanGc::note(),
|
||||
window, None, type_, can_bubble, cancelable, view, detail, can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue