mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
CanGc fixes from constantsourcenode.rs & window.rs (#33931)
Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
parent
c75f6627ba
commit
4d11b2dc84
15 changed files with 216 additions and 156 deletions
|
@ -486,9 +486,9 @@ pub fn handle_request_animation_frame(documents: &Documents, id: PipelineId, act
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_reload(documents: &Documents, id: PipelineId) {
|
||||
pub fn handle_reload(documents: &Documents, id: PipelineId, can_gc: CanGc) {
|
||||
if let Some(win) = documents.find_window(id) {
|
||||
win.Location().reload_without_origin_check();
|
||||
win.Location().reload_without_origin_check(can_gc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -407,11 +407,12 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
}
|
||||
|
||||
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createconstantsource>
|
||||
fn CreateConstantSource(&self) -> Fallible<DomRoot<ConstantSourceNode>> {
|
||||
fn CreateConstantSource(&self, can_gc: CanGc) -> Fallible<DomRoot<ConstantSourceNode>> {
|
||||
ConstantSourceNode::new(
|
||||
self.global().as_window(),
|
||||
self,
|
||||
&ConstantSourceOptions::empty(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ DOMInterfaces = {
|
|||
|
||||
'BaseAudioContext': {
|
||||
'inRealms': ['DecodeAudioData', 'Resume', 'ParseFromString', 'GetBounds', 'GetClientRects'],
|
||||
'canGc': ['CreateChannelMerger', 'CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser', 'CreatePanner', 'CreateChannelSplitter', 'CreateBuffer'],
|
||||
'canGc': ['CreateChannelMerger', 'CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser', 'CreatePanner', 'CreateChannelSplitter', 'CreateBuffer', 'CreateConstantSource'],
|
||||
},
|
||||
|
||||
'Blob': {
|
||||
|
@ -143,6 +143,10 @@ DOMInterfaces = {
|
|||
'inRealms': ['PlayEffect', 'Reset']
|
||||
},
|
||||
|
||||
'History': {
|
||||
'canGc': ['Go'],
|
||||
},
|
||||
|
||||
'HTMLButtonElement': {
|
||||
'canGc': ['ReportValidity'],
|
||||
},
|
||||
|
@ -192,6 +196,10 @@ DOMInterfaces = {
|
|||
'canGc': ['ReportValidity'],
|
||||
},
|
||||
|
||||
'Location': {
|
||||
'canGc': ['Assign', 'Reload', 'Replace', 'SetHash', 'SetHost', 'SetHostname', 'SetHref', 'SetPathname', 'SetPort', 'SetProtocol', 'SetSearch'],
|
||||
},
|
||||
|
||||
'MediaDevices': {
|
||||
'canGc': ['GetUserMedia'],
|
||||
'inRealms': ['GetUserMedia', 'GetClientRects', 'GetBoundingClientRect'],
|
||||
|
@ -293,7 +301,7 @@ DOMInterfaces = {
|
|||
},
|
||||
|
||||
'Window': {
|
||||
'canGc': ['Stop', 'Fetch'],
|
||||
'canGc': ['Stop', 'Fetch', 'Open'],
|
||||
'inRealms': ['Fetch', 'GetOpener'],
|
||||
},
|
||||
|
||||
|
|
|
@ -67,8 +67,9 @@ impl ConstantSourceNode {
|
|||
window: &Window,
|
||||
context: &BaseAudioContext,
|
||||
options: &ConstantSourceOptions,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<ConstantSourceNode>> {
|
||||
Self::new_with_proto(window, None, context, options, CanGc::note())
|
||||
Self::new_with_proto(window, None, context, options, can_gc)
|
||||
}
|
||||
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
|
|
|
@ -756,7 +756,7 @@ impl Document {
|
|||
);
|
||||
let event = event.upcast::<Event>();
|
||||
event.set_trusted(true);
|
||||
window.dispatch_event_with_target_override(event);
|
||||
window.dispatch_event_with_target_override(event, CanGc::note());
|
||||
}),
|
||||
self.window.upcast(),
|
||||
)
|
||||
|
@ -1297,6 +1297,7 @@ impl Document {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub unsafe fn handle_mouse_button_event(
|
||||
&self,
|
||||
button: MouseButton,
|
||||
|
@ -1465,6 +1466,7 @@ impl Document {
|
|||
*self.last_click_info.borrow_mut() = Some((now, click_pos));
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn fire_mouse_event(
|
||||
&self,
|
||||
client_point: Point2D<f32>,
|
||||
|
@ -2271,7 +2273,7 @@ impl Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#prompt-to-unload-a-document
|
||||
pub fn prompt_to_unload(&self, recursive_flag: bool) -> bool {
|
||||
pub fn prompt_to_unload(&self, recursive_flag: bool, can_gc: CanGc) -> bool {
|
||||
// TODO: Step 1, increase the event loop's termination nesting level by 1.
|
||||
// Step 2
|
||||
self.incr_ignore_opens_during_unload_counter();
|
||||
|
@ -2286,7 +2288,8 @@ impl Document {
|
|||
event.set_trusted(true);
|
||||
let event_target = self.window.upcast::<EventTarget>();
|
||||
let has_listeners = event_target.has_listeners_for(&atom!("beforeunload"));
|
||||
self.window.dispatch_event_with_target_override(event);
|
||||
self.window
|
||||
.dispatch_event_with_target_override(event, can_gc);
|
||||
// TODO: Step 6, decrease the event loop's termination nesting level by 1.
|
||||
// Step 7
|
||||
if has_listeners {
|
||||
|
@ -2311,7 +2314,7 @@ impl Document {
|
|||
for iframe in self.iter_iframes() {
|
||||
// TODO: handle the case of cross origin iframes.
|
||||
let document = document_from_node(&*iframe);
|
||||
can_unload = document.prompt_to_unload(true);
|
||||
can_unload = document.prompt_to_unload(true, can_gc);
|
||||
if !document.salvageable() {
|
||||
self.salvageable.set(false);
|
||||
}
|
||||
|
@ -2346,7 +2349,9 @@ impl Document {
|
|||
);
|
||||
let event = event.upcast::<Event>();
|
||||
event.set_trusted(true);
|
||||
let _ = self.window.dispatch_event_with_target_override(event);
|
||||
let _ = self
|
||||
.window
|
||||
.dispatch_event_with_target_override(event, can_gc);
|
||||
// Step 6 Update the visibility state of oldDocument to "hidden".
|
||||
self.update_visibility_state(DocumentVisibilityState::Hidden);
|
||||
}
|
||||
|
@ -2362,7 +2367,9 @@ impl Document {
|
|||
event.set_trusted(true);
|
||||
let event_target = self.window.upcast::<EventTarget>();
|
||||
let has_listeners = event_target.has_listeners_for(&atom!("unload"));
|
||||
let _ = self.window.dispatch_event_with_target_override(&event);
|
||||
let _ = self
|
||||
.window
|
||||
.dispatch_event_with_target_override(&event, can_gc);
|
||||
self.fired_unload.set(true);
|
||||
// Step 9
|
||||
if has_listeners {
|
||||
|
@ -2458,7 +2465,7 @@ impl Document {
|
|||
update_with_current_instant(&document.load_event_start);
|
||||
|
||||
debug!("About to dispatch load for {:?}", document.url());
|
||||
window.dispatch_event_with_target_override(&event);
|
||||
window.dispatch_event_with_target_override(&event, CanGc::note());
|
||||
|
||||
// http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventEnd
|
||||
update_with_current_instant(&document.load_event_end);
|
||||
|
@ -2498,7 +2505,7 @@ impl Document {
|
|||
let event = event.upcast::<Event>();
|
||||
event.set_trusted(true);
|
||||
|
||||
window.dispatch_event_with_target_override(event);
|
||||
window.dispatch_event_with_target_override(event, CanGc::note());
|
||||
}),
|
||||
self.window.upcast(),
|
||||
)
|
||||
|
@ -5415,11 +5422,11 @@ impl DocumentMethods for Document {
|
|||
url: USVString,
|
||||
target: DOMString,
|
||||
features: DOMString,
|
||||
_can_gc: CanGc,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<Option<DomRoot<WindowProxy>>> {
|
||||
self.browsing_context()
|
||||
.ok_or(Error::InvalidAccess)?
|
||||
.open(url, target, features)
|
||||
.open(url, target, features, can_gc)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-write
|
||||
|
|
|
@ -47,6 +47,7 @@ impl FocusEvent {
|
|||
reflect_dom_object_with_proto(Box::new(FocusEvent::new_inherited()), window, proto, can_gc)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
window: &Window,
|
||||
type_: DOMString,
|
||||
|
|
|
@ -313,11 +313,11 @@ impl HistoryMethods for History {
|
|||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-history-go>
|
||||
fn Go(&self, delta: i32) -> ErrorResult {
|
||||
fn Go(&self, delta: i32, can_gc: CanGc) -> ErrorResult {
|
||||
let direction = match delta.cmp(&0) {
|
||||
Ordering::Greater => TraversalDirection::Forward(delta as usize),
|
||||
Ordering::Less => TraversalDirection::Back(-delta as usize),
|
||||
Ordering::Equal => return self.window.Location().Reload(),
|
||||
Ordering::Equal => return self.window.Location().Reload(can_gc),
|
||||
};
|
||||
|
||||
self.traverse_history(direction)
|
||||
|
|
|
@ -1016,6 +1016,7 @@ impl HTMLFormElement {
|
|||
HistoryEntryReplacement::Disabled,
|
||||
false,
|
||||
load_data,
|
||||
CanGc::note(),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ use crate::dom::location::NavigationType;
|
|||
use crate::dom::node::{document_from_node, window_from_node, BindContext, Node, UnbindContext};
|
||||
use crate::dom::virtualmethods::VirtualMethods;
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::CanGc;
|
||||
use crate::timers::OneshotTimerCallback;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -45,11 +46,12 @@ pub struct RefreshRedirectDue {
|
|||
pub window: DomRoot<Window>,
|
||||
}
|
||||
impl RefreshRedirectDue {
|
||||
pub fn invoke(self) {
|
||||
pub fn invoke(self, can_gc: CanGc) {
|
||||
self.window.Location().navigate(
|
||||
self.url.clone(),
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationType::DeclarativeRefresh,
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ use crate::dom::document::Document;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::urlhelper::UrlHelper;
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum NavigationType {
|
||||
|
@ -66,6 +67,7 @@ impl Location {
|
|||
url: ServoUrl,
|
||||
replacement_flag: HistoryEntryReplacement,
|
||||
navigation_type: NavigationType,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
fn incumbent_window() -> DomRoot<Window> {
|
||||
let incumbent_global = GlobalScope::incumbent().expect("no incumbent global object");
|
||||
|
@ -125,7 +127,7 @@ impl Location {
|
|||
None, // Top navigation doesn't inherit secure context
|
||||
);
|
||||
self.window
|
||||
.load_url(replacement_flag, reload_triggered, load_data);
|
||||
.load_url(replacement_flag, reload_triggered, load_data, can_gc);
|
||||
}
|
||||
|
||||
/// Get if this `Location`'s [relevant `Document`][1] is non-null.
|
||||
|
@ -210,7 +212,11 @@ impl Location {
|
|||
|
||||
/// The common algorithm for `Location`'s setters and `Location::Assign`.
|
||||
#[inline]
|
||||
fn setter_common(&self, f: impl FnOnce(ServoUrl) -> Fallible<Option<ServoUrl>>) -> ErrorResult {
|
||||
fn setter_common(
|
||||
&self,
|
||||
f: impl FnOnce(ServoUrl) -> Fallible<Option<ServoUrl>>,
|
||||
can_gc: CanGc,
|
||||
) -> ErrorResult {
|
||||
// Step 1: If this Location object's relevant Document is null, then return.
|
||||
// Step 2: If this Location object's relevant Document's origin is not
|
||||
// same origin-domain with the entry settings object's origin, then
|
||||
|
@ -225,6 +231,7 @@ impl Location {
|
|||
copy_url,
|
||||
HistoryEntryReplacement::Disabled,
|
||||
NavigationType::Normal,
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +242,7 @@ impl Location {
|
|||
/// [`reload()`][1]).
|
||||
///
|
||||
/// [1]: https://html.spec.whatwg.org/multipage/#dom-location-reload
|
||||
pub fn reload_without_origin_check(&self) {
|
||||
pub fn reload_without_origin_check(&self, can_gc: CanGc) {
|
||||
// > When a user requests that the active document of a browsing context
|
||||
// > be reloaded through a user interface element, the user agent should
|
||||
// > navigate the browsing context to the same resource as that
|
||||
|
@ -245,6 +252,7 @@ impl Location {
|
|||
url,
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationType::ReloadByConstellation,
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -256,8 +264,9 @@ impl Location {
|
|||
|
||||
impl LocationMethods for Location {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
||||
fn Assign(&self, url: USVString) -> ErrorResult {
|
||||
self.setter_common(|_copy_url| {
|
||||
fn Assign(&self, url: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|_copy_url| {
|
||||
// Step 3: Parse url relative to the entry settings object. If that failed,
|
||||
// throw a "SyntaxError" DOMException.
|
||||
let base_url = self.entry_settings_object().api_base_url();
|
||||
|
@ -267,22 +276,25 @@ impl LocationMethods for Location {
|
|||
};
|
||||
|
||||
Ok(Some(url))
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-reload
|
||||
fn Reload(&self) -> ErrorResult {
|
||||
fn Reload(&self, can_gc: CanGc) -> ErrorResult {
|
||||
let url = self.get_url_if_same_origin()?;
|
||||
self.navigate(
|
||||
url,
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationType::ReloadByScript,
|
||||
can_gc,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-replace
|
||||
fn Replace(&self, url: USVString) -> ErrorResult {
|
||||
fn Replace(&self, url: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
// Step 1: If this Location object's relevant Document is null, then return.
|
||||
if self.has_document() {
|
||||
// Step 2: Parse url relative to the entry settings object. If that failed,
|
||||
|
@ -298,6 +310,7 @@ impl LocationMethods for Location {
|
|||
url,
|
||||
HistoryEntryReplacement::Enabled,
|
||||
NavigationType::Normal,
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -309,8 +322,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-hash
|
||||
fn SetHash(&self, value: USVString) -> ErrorResult {
|
||||
self.setter_common(|mut copy_url| {
|
||||
fn SetHash(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|mut copy_url| {
|
||||
// Step 4: Let input be the given value with a single leading "#" removed, if any.
|
||||
// Step 5: Set copyURL's fragment to the empty string.
|
||||
// Step 6: Basic URL parse input, with copyURL as url and fragment state as
|
||||
|
@ -328,7 +342,9 @@ impl LocationMethods for Location {
|
|||
|
||||
Ok(Some(copy_url))
|
||||
}
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-host
|
||||
|
@ -337,8 +353,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-host
|
||||
fn SetHost(&self, value: USVString) -> ErrorResult {
|
||||
self.setter_common(|mut copy_url| {
|
||||
fn SetHost(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|mut copy_url| {
|
||||
// Step 4: If copyURL's cannot-be-a-base-URL flag is set, terminate these steps.
|
||||
if copy_url.cannot_be_a_base() {
|
||||
return Ok(None);
|
||||
|
@ -349,7 +366,9 @@ impl LocationMethods for Location {
|
|||
let _ = copy_url.as_mut_url().set_host(Some(&value.0));
|
||||
|
||||
Ok(Some(copy_url))
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-origin
|
||||
|
@ -363,8 +382,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-hostname
|
||||
fn SetHostname(&self, value: USVString) -> ErrorResult {
|
||||
self.setter_common(|mut copy_url| {
|
||||
fn SetHostname(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|mut copy_url| {
|
||||
// Step 4: If copyURL's cannot-be-a-base-URL flag is set, terminate these steps.
|
||||
if copy_url.cannot_be_a_base() {
|
||||
return Ok(None);
|
||||
|
@ -375,7 +395,9 @@ impl LocationMethods for Location {
|
|||
let _ = copy_url.as_mut_url().set_host(Some(&value.0));
|
||||
|
||||
Ok(Some(copy_url))
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-href
|
||||
|
@ -384,7 +406,7 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-href
|
||||
fn SetHref(&self, value: USVString) -> ErrorResult {
|
||||
fn SetHref(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
// Step 1: If this Location object's relevant Document is null, then return.
|
||||
if self.has_document() {
|
||||
// Note: no call to self.check_same_origin_domain()
|
||||
|
@ -400,6 +422,7 @@ impl LocationMethods for Location {
|
|||
url,
|
||||
HistoryEntryReplacement::Disabled,
|
||||
NavigationType::Normal,
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -411,8 +434,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-pathname
|
||||
fn SetPathname(&self, value: USVString) -> ErrorResult {
|
||||
self.setter_common(|mut copy_url| {
|
||||
fn SetPathname(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|mut copy_url| {
|
||||
// Step 4: If copyURL's cannot-be-a-base-URL flag is set, terminate these steps.
|
||||
if copy_url.cannot_be_a_base() {
|
||||
return Ok(None);
|
||||
|
@ -424,7 +448,9 @@ impl LocationMethods for Location {
|
|||
copy_url.as_mut_url().set_path(&value.0);
|
||||
|
||||
Ok(Some(copy_url))
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-port
|
||||
|
@ -433,8 +459,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-port
|
||||
fn SetPort(&self, value: USVString) -> ErrorResult {
|
||||
self.setter_common(|mut copy_url| {
|
||||
fn SetPort(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|mut copy_url| {
|
||||
// Step 4: If copyURL cannot have a username/password/port, then return.
|
||||
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
|
||||
if copy_url.host().is_none() ||
|
||||
|
@ -451,7 +478,9 @@ impl LocationMethods for Location {
|
|||
let _ = url::quirks::set_port(copy_url.as_mut_url(), &value.0);
|
||||
|
||||
Ok(Some(copy_url))
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-protocol
|
||||
|
@ -460,8 +489,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-protocol
|
||||
fn SetProtocol(&self, value: USVString) -> ErrorResult {
|
||||
self.setter_common(|mut copy_url| {
|
||||
fn SetProtocol(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|mut copy_url| {
|
||||
// Step 4: Let possibleFailure be the result of basic URL parsing the given
|
||||
// value, followed by ":", with copyURL as url and scheme start state as
|
||||
// state override.
|
||||
|
@ -483,7 +513,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
Ok(Some(copy_url))
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-search
|
||||
|
@ -492,8 +524,9 @@ impl LocationMethods for Location {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-search
|
||||
fn SetSearch(&self, value: USVString) -> ErrorResult {
|
||||
self.setter_common(|mut copy_url| {
|
||||
fn SetSearch(&self, value: USVString, can_gc: CanGc) -> ErrorResult {
|
||||
self.setter_common(
|
||||
|mut copy_url| {
|
||||
// Step 4: If the given value is the empty string, set copyURL's query to null.
|
||||
// Step 5: Otherwise, run these substeps:
|
||||
// 1. Let input be the given value with a single leading "?" removed, if any.
|
||||
|
@ -508,6 +541,8 @@ impl LocationMethods for Location {
|
|||
});
|
||||
|
||||
Ok(Some(copy_url))
|
||||
})
|
||||
},
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -547,8 +547,8 @@ impl Window {
|
|||
}
|
||||
|
||||
// see note at https://dom.spec.whatwg.org/#concept-event-dispatch step 2
|
||||
pub fn dispatch_event_with_target_override(&self, event: &Event) -> EventStatus {
|
||||
event.dispatch(self.upcast(), true, CanGc::note())
|
||||
pub fn dispatch_event_with_target_override(&self, event: &Event, can_gc: CanGc) -> EventStatus {
|
||||
event.dispatch(self.upcast(), true, can_gc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -688,8 +688,9 @@ impl WindowMethods for Window {
|
|||
url: USVString,
|
||||
target: DOMString,
|
||||
features: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<Option<DomRoot<WindowProxy>>> {
|
||||
self.window_proxy().open(url, target, features)
|
||||
self.window_proxy().open(url, target, features, can_gc)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-opener
|
||||
|
@ -781,7 +782,7 @@ impl WindowMethods for Window {
|
|||
// Steps 2 and 3, prompt to unload for all inclusive descendant navigables.
|
||||
// TODO: We should be prompting for all inclusive descendant navigables,
|
||||
// but we pass false here, which suggests we are not doing that. Why?
|
||||
if document.prompt_to_unload(false) {
|
||||
if document.prompt_to_unload(false, CanGc::note()) {
|
||||
// Step 4, unload.
|
||||
document.unload(false, CanGc::note());
|
||||
|
||||
|
@ -2236,6 +2237,7 @@ impl Window {
|
|||
replace: HistoryEntryReplacement,
|
||||
force_reload: bool,
|
||||
load_data: LoadData,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
let doc = self.Document();
|
||||
// TODO: Important re security. See https://github.com/servo/servo/issues/23373
|
||||
|
@ -2293,7 +2295,7 @@ impl Window {
|
|||
}
|
||||
|
||||
// Step 8
|
||||
if doc.prompt_to_unload(false) {
|
||||
if doc.prompt_to_unload(false, can_gc) {
|
||||
let window_proxy = self.window_proxy();
|
||||
if window_proxy.parent().is_some() {
|
||||
// Step 10
|
||||
|
|
|
@ -54,7 +54,7 @@ use crate::dom::element::Element;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::window::Window;
|
||||
use crate::realms::{enter_realm, AlreadyInRealm, InRealm};
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
|
||||
use crate::script_thread::ScriptThread;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -465,6 +465,7 @@ impl WindowProxy {
|
|||
url: USVString,
|
||||
target: DOMString,
|
||||
features: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<Option<DomRoot<WindowProxy>>> {
|
||||
// Step 4.
|
||||
let non_empty_target = match target.as_ref() {
|
||||
|
@ -527,7 +528,7 @@ impl WindowProxy {
|
|||
} else {
|
||||
HistoryEntryReplacement::Disabled
|
||||
};
|
||||
target_window.load_url(replacement_flag, false, load_data);
|
||||
target_window.load_url(replacement_flag, false, load_data, can_gc);
|
||||
}
|
||||
if noopener {
|
||||
// Step 15 (Dis-owning has been done in create_auxiliary_browsing_context).
|
||||
|
|
|
@ -21,6 +21,7 @@ use crate::dom::htmlformelement::HTMLFormElement;
|
|||
use crate::dom::htmllinkelement::HTMLLinkElement;
|
||||
use crate::dom::node::document_from_node;
|
||||
use crate::dom::types::{Element, GlobalScope};
|
||||
use crate::script_runtime::CanGc;
|
||||
use crate::task_source::TaskSource;
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
@ -432,7 +433,7 @@ pub fn follow_hyperlink(
|
|||
let target = Trusted::new(target_window);
|
||||
let task = task!(navigate_follow_hyperlink: move || {
|
||||
debug!("following hyperlink to {}", load_data.url);
|
||||
target.root().load_url(replace, false, load_data);
|
||||
target.root().load_url(replace, false, load_data, CanGc::note());
|
||||
});
|
||||
target_window
|
||||
.task_manager()
|
||||
|
|
|
@ -2409,7 +2409,7 @@ impl ScriptThread {
|
|||
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) => {
|
||||
self.handle_css_error_reporting(pipeline_id, filename, line, column, msg)
|
||||
},
|
||||
ConstellationControlMsg::Reload(pipeline_id) => self.handle_reload(pipeline_id),
|
||||
ConstellationControlMsg::Reload(pipeline_id) => self.handle_reload(pipeline_id, can_gc),
|
||||
ConstellationControlMsg::ExitPipeline(pipeline_id, discard_browsing_context) => {
|
||||
self.handle_exit_pipeline_msg(pipeline_id, discard_browsing_context, can_gc)
|
||||
},
|
||||
|
@ -2629,7 +2629,7 @@ impl ScriptThread {
|
|||
DevtoolScriptControlMsg::RequestAnimationFrame(id, name) => {
|
||||
devtools::handle_request_animation_frame(&documents, id, name)
|
||||
},
|
||||
DevtoolScriptControlMsg::Reload(id) => devtools::handle_reload(&documents, id),
|
||||
DevtoolScriptControlMsg::Reload(id) => devtools::handle_reload(&documents, id, can_gc),
|
||||
DevtoolScriptControlMsg::GetCssDatabase(reply) => {
|
||||
devtools::handle_get_css_database(reply)
|
||||
},
|
||||
|
@ -4259,10 +4259,10 @@ impl ScriptThread {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_reload(&self, pipeline_id: PipelineId) {
|
||||
fn handle_reload(&self, pipeline_id: PipelineId, can_gc: CanGc) {
|
||||
let window = self.documents.borrow().find_window(pipeline_id);
|
||||
if let Some(window) = window {
|
||||
window.Location().reload_without_origin_check();
|
||||
window.Location().reload_without_origin_check(can_gc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ impl OneshotTimerCallback {
|
|||
OneshotTimerCallback::JsTimer(task) => task.invoke(this, js_timers),
|
||||
OneshotTimerCallback::TestBindingCallback(callback) => callback.invoke(),
|
||||
OneshotTimerCallback::FakeRequestAnimationFrame(callback) => callback.invoke(),
|
||||
OneshotTimerCallback::RefreshRedirectDue(callback) => callback.invoke(),
|
||||
OneshotTimerCallback::RefreshRedirectDue(callback) => callback.invoke(can_gc),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue