mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
CanGc fixes from eventtarget.rs (#33973)
Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
parent
7b392db02f
commit
7fbd2a521e
23 changed files with 108 additions and 81 deletions
|
@ -55,7 +55,7 @@ DOMInterfaces = {
|
||||||
|
|
||||||
'BluetoothRemoteGATTServer': {
|
'BluetoothRemoteGATTServer': {
|
||||||
'inRealms': ['Connect'],
|
'inRealms': ['Connect'],
|
||||||
'canGc': ['GetPrimaryService', 'GetPrimaryServices', 'Connect'],
|
'canGc': ['GetPrimaryService', 'GetPrimaryServices', 'Connect', 'Disconnect'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'BluetoothRemoteGATTService': {
|
'BluetoothRemoteGATTService': {
|
||||||
|
@ -116,7 +116,7 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'ElementInternals': {
|
'ElementInternals': {
|
||||||
'canGc': ['ReportValidity'],
|
'canGc': ['CheckValidity', 'ReportValidity'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'EventSource': {
|
'EventSource': {
|
||||||
|
@ -184,11 +184,7 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLButtonElement': {
|
'HTMLButtonElement': {
|
||||||
'canGc': ['ReportValidity'],
|
'canGc': ['CheckValidity', 'ReportValidity'],
|
||||||
},
|
|
||||||
|
|
||||||
'HTMLCanvasElement': {
|
|
||||||
'canGc': ['CaptureStream', 'GetContext'],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLElement': {
|
'HTMLElement': {
|
||||||
|
@ -196,36 +192,40 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLFieldSetElement': {
|
'HTMLFieldSetElement': {
|
||||||
'canGc': ['ReportValidity'],
|
'canGc': ['CheckValidity', 'ReportValidity'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLFormElement': {
|
'HTMLFormElement': {
|
||||||
'canGc': ['RequestSubmit', 'ReportValidity', 'Submit'],
|
'canGc': ['CheckValidity', 'RequestSubmit', 'ReportValidity', 'Submit'],
|
||||||
},
|
|
||||||
|
|
||||||
'HTMLInputElement': {
|
|
||||||
'canGc': ['ReportValidity', 'SelectFiles'],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLImageElement': {
|
'HTMLImageElement': {
|
||||||
'canGc': ['Width', 'Height', 'Decode'],
|
'canGc': ['Width', 'Height', 'Decode'],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'HTMLInputElement': {
|
||||||
|
'canGc': ['CheckValidity', 'ReportValidity', 'SelectFiles'],
|
||||||
|
},
|
||||||
|
|
||||||
'HTMLMediaElement': {
|
'HTMLMediaElement': {
|
||||||
'canGc': ['Load', 'Pause', 'Play', 'SetSrcObject'],
|
'canGc': ['Load', 'Pause', 'Play', 'SetSrcObject'],
|
||||||
'inRealms': ['Play'],
|
'inRealms': ['Play'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLObjectElement': {
|
'HTMLObjectElement': {
|
||||||
'canGc': ['ReportValidity'],
|
'canGc': ['CheckValidity', 'ReportValidity'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLOutputElement': {
|
'HTMLOutputElement': {
|
||||||
'canGc': ['ReportValidity'],
|
'canGc': ['CheckValidity', 'ReportValidity'],
|
||||||
|
},
|
||||||
|
|
||||||
|
'HTMLCanvasElement': {
|
||||||
|
'canGc': ['CaptureStream', 'GetContext'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLSelectElement': {
|
'HTMLSelectElement': {
|
||||||
'canGc': ['ReportValidity'],
|
'canGc': ['CheckValidity', 'ReportValidity'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLTemplateElement': {
|
'HTMLTemplateElement': {
|
||||||
|
@ -233,7 +233,7 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'HTMLTextAreaElement': {
|
'HTMLTextAreaElement': {
|
||||||
'canGc': ['ReportValidity'],
|
'canGc': ['CheckValidity', 'ReportValidity'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'Location': {
|
'Location': {
|
||||||
|
@ -295,6 +295,10 @@ DOMInterfaces = {
|
||||||
'canGc': ['Query', 'Request', 'Revoke'],
|
'canGc': ['Query', 'Request', 'Revoke'],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'Permissions': {
|
||||||
|
'canGc': ['Query', 'Request', 'Revoke'],
|
||||||
|
},
|
||||||
|
|
||||||
'Promise': {
|
'Promise': {
|
||||||
'spiderMonkeyInterface': True,
|
'spiderMonkeyInterface': True,
|
||||||
},
|
},
|
||||||
|
|
|
@ -110,7 +110,7 @@ struct BluetoothContext<T: AsyncBluetoothListener + DomObject> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AsyncBluetoothListener {
|
pub trait AsyncBluetoothListener {
|
||||||
fn handle_response(&self, result: BluetoothResponse, promise: &Rc<Promise>);
|
fn handle_response(&self, result: BluetoothResponse, promise: &Rc<Promise>, can_gc: CanGc);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> BluetoothContext<T>
|
impl<T> BluetoothContext<T>
|
||||||
|
@ -118,13 +118,16 @@ where
|
||||||
T: AsyncBluetoothListener + DomObject,
|
T: AsyncBluetoothListener + DomObject,
|
||||||
{
|
{
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
fn response(&mut self, response: BluetoothResponseResult) {
|
fn response(&mut self, response: BluetoothResponseResult, can_gc: CanGc) {
|
||||||
let promise = self.promise.take().expect("bt promise is missing").root();
|
let promise = self.promise.take().expect("bt promise is missing").root();
|
||||||
|
|
||||||
// JSAutoRealm needs to be manually made.
|
// JSAutoRealm needs to be manually made.
|
||||||
// Otherwise, Servo will crash.
|
// Otherwise, Servo will crash.
|
||||||
match response {
|
match response {
|
||||||
Ok(response) => self.receiver.root().handle_response(response, &promise),
|
Ok(response) => self
|
||||||
|
.receiver
|
||||||
|
.root()
|
||||||
|
.handle_response(response, &promise, can_gc),
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
||||||
// Step 3 - 4.
|
// Step 3 - 4.
|
||||||
Err(error) => promise.reject_error(Error::from(error)),
|
Err(error) => promise.reject_error(Error::from(error)),
|
||||||
|
@ -259,7 +262,7 @@ pub fn response_async<T: AsyncBluetoothListener + DomObject + 'static>(
|
||||||
{
|
{
|
||||||
fn run_once(self) {
|
fn run_once(self) {
|
||||||
let mut context = self.context.lock().unwrap();
|
let mut context = self.context.lock().unwrap();
|
||||||
context.response(self.action);
|
context.response(self.action, CanGc::note());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +579,7 @@ impl BluetoothMethods for Bluetooth {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsyncBluetoothListener for Bluetooth {
|
impl AsyncBluetoothListener for Bluetooth {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
|
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
|
||||||
// Step 11, 13 - 14.
|
// Step 11, 13 - 14.
|
||||||
|
@ -753,6 +756,7 @@ impl PermissionAlgorithm for Bluetooth {
|
||||||
fn permission_revoke(
|
fn permission_revoke(
|
||||||
_descriptor: &BluetoothPermissionDescriptor,
|
_descriptor: &BluetoothPermissionDescriptor,
|
||||||
status: &BluetoothPermissionResult,
|
status: &BluetoothPermissionResult,
|
||||||
|
can_gc: CanGc,
|
||||||
) {
|
) {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let global = status.global();
|
let global = status.global();
|
||||||
|
@ -775,7 +779,7 @@ impl PermissionAlgorithm for Bluetooth {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Step 2.2 - 2.4
|
// Step 2.2 - 2.4
|
||||||
let _ = device.get_gatt().Disconnect();
|
let _ = device.get_gatt().Disconnect(can_gc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ impl BluetoothDevice {
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#clean-up-the-disconnected-device
|
// https://webbluetoothcg.github.io/web-bluetooth/#clean-up-the-disconnected-device
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
pub fn clean_up_disconnected_device(&self) {
|
pub fn clean_up_disconnected_device(&self, can_gc: CanGc) {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
self.get_gatt().set_connected(false);
|
self.get_gatt().set_connected(false);
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ impl BluetoothDevice {
|
||||||
|
|
||||||
// Step 8.
|
// Step 8.
|
||||||
self.upcast::<EventTarget>()
|
self.upcast::<EventTarget>()
|
||||||
.fire_bubbling_event(atom!("gattserverdisconnected"));
|
.fire_bubbling_event(atom!("gattserverdisconnected"), can_gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#garbage-collect-the-connection
|
// https://webbluetoothcg.github.io/web-bluetooth/#garbage-collect-the-connection
|
||||||
|
@ -317,7 +317,7 @@ impl BluetoothDeviceMethods for BluetoothDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsyncBluetoothListener for BluetoothDevice {
|
impl AsyncBluetoothListener for BluetoothDevice {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-unwatchadvertisements
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-unwatchadvertisements
|
||||||
BluetoothResponse::WatchAdvertisements(_result) => {
|
BluetoothResponse::WatchAdvertisements(_result) => {
|
||||||
|
|
|
@ -25,6 +25,7 @@ use crate::dom::bluetoothdevice::BluetoothDevice;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::permissionstatus::PermissionStatus;
|
use crate::dom::permissionstatus::PermissionStatus;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothpermissionresult
|
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothpermissionresult
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -94,7 +95,7 @@ impl BluetoothPermissionResultMethods for BluetoothPermissionResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsyncBluetoothListener for BluetoothPermissionResult {
|
impl AsyncBluetoothListener for BluetoothPermissionResult {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
|
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
|
||||||
// Step 3, 11, 13 - 14.
|
// Step 3, 11, 13 - 14.
|
||||||
|
|
|
@ -298,7 +298,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
|
impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, can_gc: CanGc) {
|
||||||
let device = self.Service().Device();
|
let device = self.Service().Device();
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
|
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
|
||||||
|
@ -328,7 +328,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
|
||||||
|
|
||||||
// Step 5.5.3.
|
// Step 5.5.3.
|
||||||
self.upcast::<EventTarget>()
|
self.upcast::<EventTarget>()
|
||||||
.fire_bubbling_event(atom!("characteristicvaluechanged"));
|
.fire_bubbling_event(atom!("characteristicvaluechanged"), can_gc);
|
||||||
|
|
||||||
// Step 5.5.4.
|
// Step 5.5.4.
|
||||||
promise.resolve_native(&value);
|
promise.resolve_native(&value);
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsyncBluetoothListener for BluetoothRemoteGATTDescriptor {
|
impl AsyncBluetoothListener for BluetoothRemoteGATTDescriptor {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
||||||
BluetoothResponse::ReadValue(result) => {
|
BluetoothResponse::ReadValue(result) => {
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-disconnect
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-disconnect
|
||||||
fn Disconnect(&self) -> ErrorResult {
|
fn Disconnect(&self, can_gc: CanGc) -> ErrorResult {
|
||||||
// TODO: Step 1: Implement activeAlgorithms internal slot for BluetoothRemoteGATTServer.
|
// TODO: Step 1: Implement activeAlgorithms internal slot for BluetoothRemoteGATTServer.
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
|
@ -104,7 +104,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
self.Device().clean_up_disconnected_device();
|
self.Device().clean_up_disconnected_device(can_gc);
|
||||||
|
|
||||||
// Step 4 - 5:
|
// Step 4 - 5:
|
||||||
self.Device().garbage_collect_the_connection()
|
self.Device().garbage_collect_the_connection()
|
||||||
|
@ -146,7 +146,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
|
impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
||||||
BluetoothResponse::GATTServerConnect(connected) => {
|
BluetoothResponse::GATTServerConnect(connected) => {
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsyncBluetoothListener for BluetoothRemoteGATTService {
|
impl AsyncBluetoothListener for BluetoothRemoteGATTService {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||||
let device = self.Device();
|
let device = self.Device();
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
|
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
|
||||||
|
|
|
@ -746,7 +746,7 @@ impl Document {
|
||||||
// Step 4.6.2 Set document's page showing flag to true.
|
// Step 4.6.2 Set document's page showing flag to true.
|
||||||
document.page_showing.set(true);
|
document.page_showing.set(true);
|
||||||
// Step 4.6.3 Update the visibility state of document to "visible".
|
// Step 4.6.3 Update the visibility state of document to "visible".
|
||||||
document.update_visibility_state(DocumentVisibilityState::Visible);
|
document.update_visibility_state(DocumentVisibilityState::Visible, CanGc::note());
|
||||||
// Step 4.6.4 Fire a page transition event named pageshow at document's relevant
|
// Step 4.6.4 Fire a page transition event named pageshow at document's relevant
|
||||||
// global object with true.
|
// global object with true.
|
||||||
let event = PageTransitionEvent::new(
|
let event = PageTransitionEvent::new(
|
||||||
|
@ -2360,7 +2360,7 @@ impl Document {
|
||||||
.window
|
.window
|
||||||
.dispatch_event_with_target_override(event, can_gc);
|
.dispatch_event_with_target_override(event, can_gc);
|
||||||
// Step 6 Update the visibility state of oldDocument to "hidden".
|
// Step 6 Update the visibility state of oldDocument to "hidden".
|
||||||
self.update_visibility_state(DocumentVisibilityState::Hidden);
|
self.update_visibility_state(DocumentVisibilityState::Hidden, can_gc);
|
||||||
}
|
}
|
||||||
// Step 7
|
// Step 7
|
||||||
if !self.fired_unload.get() {
|
if !self.fired_unload.get() {
|
||||||
|
@ -2721,7 +2721,7 @@ impl Document {
|
||||||
.queue(
|
.queue(
|
||||||
task!(fire_dom_content_loaded_event: move || {
|
task!(fire_dom_content_loaded_event: move || {
|
||||||
let document = document.root();
|
let document = document.root();
|
||||||
document.upcast::<EventTarget>().fire_bubbling_event(atom!("DOMContentLoaded"));
|
document.upcast::<EventTarget>().fire_bubbling_event(atom!("DOMContentLoaded"), CanGc::note());
|
||||||
update_with_current_instant(&document.dom_content_loaded_event_end);
|
update_with_current_instant(&document.dom_content_loaded_event_end);
|
||||||
}),
|
}),
|
||||||
window.upcast(),
|
window.upcast(),
|
||||||
|
@ -4216,7 +4216,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#visibility-state>
|
/// <https://html.spec.whatwg.org/multipage/#visibility-state>
|
||||||
fn update_visibility_state(&self, visibility_state: DocumentVisibilityState) {
|
fn update_visibility_state(&self, visibility_state: DocumentVisibilityState, can_gc: CanGc) {
|
||||||
// Step 1 If document's visibility state equals visibilityState, then return.
|
// Step 1 If document's visibility state equals visibilityState, then return.
|
||||||
if self.visibility_state.get() == visibility_state {
|
if self.visibility_state.get() == visibility_state {
|
||||||
return;
|
return;
|
||||||
|
@ -4255,7 +4255,7 @@ impl Document {
|
||||||
|
|
||||||
// Step 7 Fire an event named visibilitychange at document, with its bubbles attribute initialized to true.
|
// Step 7 Fire an event named visibilitychange at document, with its bubbles attribute initialized to true.
|
||||||
self.upcast::<EventTarget>()
|
self.upcast::<EventTarget>()
|
||||||
.fire_bubbling_event(atom!("visibilitychange"));
|
.fire_bubbling_event(atom!("visibilitychange"), can_gc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,11 +317,11 @@ impl ElementInternalsMethods for ElementInternals {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage#dom-elementinternals-checkvalidity>
|
/// <https://html.spec.whatwg.org/multipage#dom-elementinternals-checkvalidity>
|
||||||
fn CheckValidity(&self) -> Fallible<bool> {
|
fn CheckValidity(&self, can_gc: CanGc) -> Fallible<bool> {
|
||||||
if !self.is_target_form_associated() {
|
if !self.is_target_form_associated() {
|
||||||
return Err(Error::NotSupported);
|
return Err(Error::NotSupported);
|
||||||
}
|
}
|
||||||
Ok(self.check_validity())
|
Ok(self.check_validity(can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage#dom-elementinternals-reportvalidity>
|
/// <https://html.spec.whatwg.org/multipage#dom-elementinternals-reportvalidity>
|
||||||
|
|
|
@ -618,7 +618,7 @@ impl TaskOnce for EventTask {
|
||||||
let target = self.target.root();
|
let target = self.target.root();
|
||||||
let bubbles = self.bubbles;
|
let bubbles = self.bubbles;
|
||||||
let cancelable = self.cancelable;
|
let cancelable = self.cancelable;
|
||||||
target.fire_event_with_params(self.name, bubbles, cancelable);
|
target.fire_event_with_params(self.name, bubbles, cancelable, CanGc::note());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -665,26 +665,38 @@ impl EventTarget {
|
||||||
name,
|
name,
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable,
|
EventCancelable::NotCancelable,
|
||||||
|
CanGc::note(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
pub fn fire_bubbling_event(&self, name: Atom) -> DomRoot<Event> {
|
pub fn fire_bubbling_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> {
|
||||||
self.fire_event_with_params(name, EventBubbles::Bubbles, EventCancelable::NotCancelable)
|
self.fire_event_with_params(
|
||||||
|
name,
|
||||||
|
EventBubbles::Bubbles,
|
||||||
|
EventCancelable::NotCancelable,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
pub fn fire_cancelable_event(&self, name: Atom) -> DomRoot<Event> {
|
pub fn fire_cancelable_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> {
|
||||||
self.fire_event_with_params(
|
self.fire_event_with_params(
|
||||||
name,
|
name,
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::Cancelable,
|
EventCancelable::Cancelable,
|
||||||
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
pub fn fire_bubbling_cancelable_event(&self, name: Atom) -> DomRoot<Event> {
|
pub fn fire_bubbling_cancelable_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> {
|
||||||
self.fire_event_with_params(name, EventBubbles::Bubbles, EventCancelable::Cancelable)
|
self.fire_event_with_params(
|
||||||
|
name,
|
||||||
|
EventBubbles::Bubbles,
|
||||||
|
EventCancelable::Cancelable,
|
||||||
|
can_gc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-event-fire
|
// https://dom.spec.whatwg.org/#concept-event-fire
|
||||||
|
@ -693,8 +705,9 @@ impl EventTarget {
|
||||||
name: Atom,
|
name: Atom,
|
||||||
bubbles: EventBubbles,
|
bubbles: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<Event> {
|
) -> DomRoot<Event> {
|
||||||
let event = Event::new(&self.global(), name, bubbles, cancelable, CanGc::note());
|
let event = Event::new(&self.global(), name, bubbles, cancelable, can_gc);
|
||||||
event.fire(self);
|
event.fire(self);
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,8 +170,8 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.check_validity()
|
self.check_validity(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
||||||
|
|
|
@ -127,8 +127,8 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.check_validity()
|
self.check_validity(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
||||||
|
|
|
@ -629,8 +629,8 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#dom-form-checkvalidity>
|
/// <https://html.spec.whatwg.org/multipage/#dom-form-checkvalidity>
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.static_validation().is_ok()
|
self.static_validation(can_gc).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#dom-form-reportvalidity>
|
/// <https://html.spec.whatwg.org/multipage/#dom-form-reportvalidity>
|
||||||
|
@ -1032,7 +1032,7 @@ impl HTMLFormElement {
|
||||||
/// <https://html.spec.whatwg.org/multipage/#interactively-validate-the-constraints>
|
/// <https://html.spec.whatwg.org/multipage/#interactively-validate-the-constraints>
|
||||||
fn interactive_validation(&self, can_gc: CanGc) -> Result<(), ()> {
|
fn interactive_validation(&self, can_gc: CanGc) -> Result<(), ()> {
|
||||||
// Step 1-2
|
// Step 1-2
|
||||||
let unhandled_invalid_controls = match self.static_validation() {
|
let unhandled_invalid_controls = match self.static_validation(can_gc) {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => return Ok(()),
|
||||||
Err(err) => err,
|
Err(err) => err,
|
||||||
};
|
};
|
||||||
|
@ -1060,7 +1060,7 @@ impl HTMLFormElement {
|
||||||
|
|
||||||
/// Statitically validate the constraints of form elements
|
/// Statitically validate the constraints of form elements
|
||||||
/// <https://html.spec.whatwg.org/multipage/#statically-validate-the-constraints>
|
/// <https://html.spec.whatwg.org/multipage/#statically-validate-the-constraints>
|
||||||
fn static_validation(&self) -> Result<(), Vec<DomRoot<Element>>> {
|
fn static_validation(&self, can_gc: CanGc) -> Result<(), Vec<DomRoot<Element>>> {
|
||||||
let controls = self.controls.borrow();
|
let controls = self.controls.borrow();
|
||||||
// Step 1-3
|
// Step 1-3
|
||||||
let invalid_controls = controls
|
let invalid_controls = controls
|
||||||
|
@ -1087,7 +1087,7 @@ impl HTMLFormElement {
|
||||||
.filter_map(|field| {
|
.filter_map(|field| {
|
||||||
let event = field
|
let event = field
|
||||||
.upcast::<EventTarget>()
|
.upcast::<EventTarget>()
|
||||||
.fire_cancelable_event(atom!("invalid"));
|
.fire_cancelable_event(atom!("invalid"), can_gc);
|
||||||
if !event.DefaultPrevented() {
|
if !event.DefaultPrevented() {
|
||||||
return Some(field);
|
return Some(field);
|
||||||
}
|
}
|
||||||
|
@ -1238,7 +1238,7 @@ impl HTMLFormElement {
|
||||||
|
|
||||||
let event = self
|
let event = self
|
||||||
.upcast::<EventTarget>()
|
.upcast::<EventTarget>()
|
||||||
.fire_bubbling_cancelable_event(atom!("reset"));
|
.fire_bubbling_cancelable_event(atom!("reset"), CanGc::note());
|
||||||
if event.DefaultPrevented() {
|
if event.DefaultPrevented() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1586,8 +1586,8 @@ impl HTMLInputElementMethods for HTMLInputElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.check_validity()
|
self.check_validity(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
||||||
|
@ -1889,8 +1889,8 @@ impl HTMLInputElement {
|
||||||
let filelist = FileList::new(&window, files);
|
let filelist = FileList::new(&window, files);
|
||||||
self.filelist.set(Some(&filelist));
|
self.filelist.set(Some(&filelist));
|
||||||
|
|
||||||
target.fire_bubbling_event(atom!("input"));
|
target.fire_bubbling_event(atom!("input"), can_gc);
|
||||||
target.fire_bubbling_event(atom!("change"));
|
target.fire_bubbling_event(atom!("change"), can_gc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2805,7 +2805,7 @@ impl Activatable for HTMLInputElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps
|
// https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps
|
||||||
fn activation_behavior(&self, _event: &Event, _target: &EventTarget, _can_gc: CanGc) {
|
fn activation_behavior(&self, _event: &Event, _target: &EventTarget, can_gc: CanGc) {
|
||||||
let ty = self.input_type();
|
let ty = self.input_type();
|
||||||
match ty {
|
match ty {
|
||||||
InputType::Submit => {
|
InputType::Submit => {
|
||||||
|
@ -2836,8 +2836,8 @@ impl Activatable for HTMLInputElement {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let target = self.upcast::<EventTarget>();
|
let target = self.upcast::<EventTarget>();
|
||||||
target.fire_bubbling_event(atom!("input"));
|
target.fire_bubbling_event(atom!("input"), can_gc);
|
||||||
target.fire_bubbling_event(atom!("change"));
|
target.fire_bubbling_event(atom!("change"), can_gc);
|
||||||
},
|
},
|
||||||
InputType::File => self.select_files(None, CanGc::note()),
|
InputType::File => self.select_files(None, CanGc::note()),
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
@ -110,8 +110,8 @@ impl HTMLObjectElementMethods for HTMLObjectElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.check_validity()
|
self.check_validity(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
||||||
|
|
|
@ -132,8 +132,8 @@ impl HTMLOutputElementMethods for HTMLOutputElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.check_validity()
|
self.check_validity(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
||||||
|
|
|
@ -391,8 +391,8 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.check_validity()
|
self.check_validity(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
||||||
|
|
|
@ -424,8 +424,8 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-checkvalidity
|
||||||
fn CheckValidity(&self) -> bool {
|
fn CheckValidity(&self, can_gc: CanGc) -> bool {
|
||||||
self.check_validity()
|
self.check_validity(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
// https://html.spec.whatwg.org/multipage/#dom-cva-reportvalidity
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub trait PermissionAlgorithm {
|
||||||
descriptor: &Self::Descriptor,
|
descriptor: &Self::Descriptor,
|
||||||
status: &Self::Status,
|
status: &Self::Status,
|
||||||
);
|
);
|
||||||
fn permission_revoke(descriptor: &Self::Descriptor, status: &Self::Status);
|
fn permission_revoke(descriptor: &Self::Descriptor, status: &Self::Status, can_gc: CanGc);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Operation {
|
enum Operation {
|
||||||
|
@ -139,7 +139,7 @@ impl Permissions {
|
||||||
.remove(&root_desc.name.to_string());
|
.remove(&root_desc.name.to_string());
|
||||||
|
|
||||||
// (Revoke) Step 4.
|
// (Revoke) Step 4.
|
||||||
Bluetooth::permission_revoke(&bluetooth_desc, &result)
|
Bluetooth::permission_revoke(&bluetooth_desc, &result, can_gc)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -171,7 +171,7 @@ impl Permissions {
|
||||||
.remove(&root_desc.name.to_string());
|
.remove(&root_desc.name.to_string());
|
||||||
|
|
||||||
// (Revoke) Step 4.
|
// (Revoke) Step 4.
|
||||||
Permissions::permission_revoke(&root_desc, &status);
|
Permissions::permission_revoke(&root_desc, &status, can_gc);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -270,7 +270,12 @@ impl PermissionAlgorithm for Permissions {
|
||||||
Permissions::permission_query(cx, promise, descriptor, status);
|
Permissions::permission_query(cx, promise, descriptor, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn permission_revoke(_descriptor: &PermissionDescriptor, _status: &PermissionStatus) {}
|
fn permission_revoke(
|
||||||
|
_descriptor: &PermissionDescriptor,
|
||||||
|
_status: &PermissionStatus,
|
||||||
|
_can_gc: CanGc,
|
||||||
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/permissions/#permission-state
|
// https://w3c.github.io/permissions/#permission-state
|
||||||
|
|
|
@ -35,11 +35,11 @@ pub trait Validatable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#check-validity-steps>
|
/// <https://html.spec.whatwg.org/multipage/#check-validity-steps>
|
||||||
fn check_validity(&self) -> bool {
|
fn check_validity(&self, can_gc: CanGc) -> bool {
|
||||||
if self.is_instance_validatable() && !self.satisfies_constraints() {
|
if self.is_instance_validatable() && !self.satisfies_constraints() {
|
||||||
self.as_element()
|
self.as_element()
|
||||||
.upcast::<EventTarget>()
|
.upcast::<EventTarget>()
|
||||||
.fire_cancelable_event(atom!("invalid"));
|
.fire_cancelable_event(atom!("invalid"), can_gc);
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
|
@ -61,7 +61,7 @@ pub trait Validatable {
|
||||||
let event = self
|
let event = self
|
||||||
.as_element()
|
.as_element()
|
||||||
.upcast::<EventTarget>()
|
.upcast::<EventTarget>()
|
||||||
.fire_cancelable_event(atom!("invalid"));
|
.fire_cancelable_event(atom!("invalid"), can_gc);
|
||||||
|
|
||||||
// Step 1.2.
|
// Step 1.2.
|
||||||
if !event.DefaultPrevented() {
|
if !event.DefaultPrevented() {
|
||||||
|
|
|
@ -324,7 +324,7 @@ impl XRSystem {
|
||||||
let xr = xr.root();
|
let xr = xr.root();
|
||||||
let interacting = ScriptThread::is_user_interacting();
|
let interacting = ScriptThread::is_user_interacting();
|
||||||
ScriptThread::set_user_interacting(true);
|
ScriptThread::set_user_interacting(true);
|
||||||
xr.upcast::<EventTarget>().fire_bubbling_event(atom!("sessionavailable"));
|
xr.upcast::<EventTarget>().fire_bubbling_event(atom!("sessionavailable"), CanGc::note());
|
||||||
ScriptThread::set_user_interacting(interacting);
|
ScriptThread::set_user_interacting(interacting);
|
||||||
}),
|
}),
|
||||||
window.upcast(),
|
window.upcast(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue