clippy: Fix needless borrow warnings (#31813)

This commit is contained in:
Oluwatobi Sofela 2024-03-21 18:48:54 +01:00 committed by GitHub
parent 694e86ecff
commit 3e63f8d6ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 151 additions and 157 deletions

View file

@ -453,7 +453,7 @@ impl Extractable for BodyInit {
BodyInit::ArrayBuffer(ref typedarray) => { BodyInit::ArrayBuffer(ref typedarray) => {
let bytes = typedarray.to_vec(); let bytes = typedarray.to_vec();
let total_bytes = bytes.len(); let total_bytes = bytes.len();
let stream = ReadableStream::new_from_bytes(&global, bytes); let stream = ReadableStream::new_from_bytes(global, bytes);
Ok(ExtractedBody { Ok(ExtractedBody {
stream, stream,
total_bytes: Some(total_bytes), total_bytes: Some(total_bytes),
@ -464,7 +464,7 @@ impl Extractable for BodyInit {
BodyInit::ArrayBufferView(ref typedarray) => { BodyInit::ArrayBufferView(ref typedarray) => {
let bytes = typedarray.to_vec(); let bytes = typedarray.to_vec();
let total_bytes = bytes.len(); let total_bytes = bytes.len();
let stream = ReadableStream::new_from_bytes(&global, bytes); let stream = ReadableStream::new_from_bytes(global, bytes);
Ok(ExtractedBody { Ok(ExtractedBody {
stream, stream,
total_bytes: Some(total_bytes), total_bytes: Some(total_bytes),
@ -497,7 +497,7 @@ impl Extractable for Vec<u8> {
fn extract(&self, global: &GlobalScope) -> Fallible<ExtractedBody> { fn extract(&self, global: &GlobalScope) -> Fallible<ExtractedBody> {
let bytes = self.clone(); let bytes = self.clone();
let total_bytes = self.len(); let total_bytes = self.len();
let stream = ReadableStream::new_from_bytes(&global, bytes); let stream = ReadableStream::new_from_bytes(global, bytes);
Ok(ExtractedBody { Ok(ExtractedBody {
stream, stream,
total_bytes: Some(total_bytes), total_bytes: Some(total_bytes),
@ -531,7 +531,7 @@ impl Extractable for DOMString {
let bytes = self.as_bytes().to_owned(); let bytes = self.as_bytes().to_owned();
let total_bytes = bytes.len(); let total_bytes = bytes.len();
let content_type = Some(DOMString::from("text/plain;charset=UTF-8")); let content_type = Some(DOMString::from("text/plain;charset=UTF-8"));
let stream = ReadableStream::new_from_bytes(&global, bytes); let stream = ReadableStream::new_from_bytes(global, bytes);
Ok(ExtractedBody { Ok(ExtractedBody {
stream, stream,
total_bytes: Some(total_bytes), total_bytes: Some(total_bytes),
@ -550,7 +550,7 @@ impl Extractable for FormData {
"multipart/form-data;boundary={}", "multipart/form-data;boundary={}",
boundary boundary
))); )));
let stream = ReadableStream::new_from_bytes(&global, bytes); let stream = ReadableStream::new_from_bytes(global, bytes);
Ok(ExtractedBody { Ok(ExtractedBody {
stream, stream,
total_bytes: Some(total_bytes), total_bytes: Some(total_bytes),
@ -567,7 +567,7 @@ impl Extractable for URLSearchParams {
let content_type = Some(DOMString::from( let content_type = Some(DOMString::from(
"application/x-www-form-urlencoded;charset=UTF-8", "application/x-www-form-urlencoded;charset=UTF-8",
)); ));
let stream = ReadableStream::new_from_bytes(&global, bytes); let stream = ReadableStream::new_from_bytes(global, bytes);
Ok(ExtractedBody { Ok(ExtractedBody {
stream, stream,
total_bytes: Some(total_bytes), total_bytes: Some(total_bytes),

View file

@ -46,7 +46,7 @@ pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<E
"<eval>", "<eval>",
rval.handle_mut(), rval.handle_mut(),
1, 1,
ScriptFetchOptions::default_classic_script(&global), ScriptFetchOptions::default_classic_script(global),
global.api_base_url(), global.api_base_url(),
); );

View file

@ -206,7 +206,7 @@ impl Attr {
(Some(old), None) => { (Some(old), None) => {
// Already gone from the list of attributes of old owner. // Already gone from the list of attributes of old owner.
assert!( assert!(
old.get_attribute(&ns, &self.identifier.local_name) old.get_attribute(ns, &self.identifier.local_name)
.as_deref() != .as_deref() !=
Some(self) Some(self)
) )

View file

@ -58,7 +58,7 @@ impl AudioBufferSourceNode {
)?; )?;
let node_id = source_node.node().node_id(); let node_id = source_node.node().node_id();
let playback_rate = AudioParam::new( let playback_rate = AudioParam::new(
&window, window,
context, context,
node_id, node_id,
AudioNodeType::AudioBufferSourceNode, AudioNodeType::AudioBufferSourceNode,
@ -69,7 +69,7 @@ impl AudioBufferSourceNode {
f32::MAX, f32::MAX,
); );
let detune = AudioParam::new( let detune = AudioParam::new(
&window, window,
context, context,
node_id, node_id,
AudioNodeType::AudioBufferSourceNode, AudioNodeType::AudioBufferSourceNode,

View file

@ -86,7 +86,7 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
window.task_manager().dom_manipulation_task_source().queue_simple_event( window.task_manager().dom_manipulation_task_source().queue_simple_event(
this.upcast(), this.upcast(),
atom!("ended"), atom!("ended"),
&window window
); );
}), }),
&canceller, &canceller,

View file

@ -331,7 +331,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
fn Listener(&self) -> DomRoot<AudioListener> { fn Listener(&self) -> DomRoot<AudioListener> {
let global = self.global(); let global = self.global();
let window = global.as_window(); let window = global.as_window();
self.listener.or_init(|| AudioListener::new(&window, self)) self.listener.or_init(|| AudioListener::new(window, self))
} }
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-onstatechange // https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-onstatechange
@ -339,33 +339,29 @@ impl BaseAudioContextMethods for BaseAudioContext {
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createoscillator> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createoscillator>
fn CreateOscillator(&self) -> Fallible<DomRoot<OscillatorNode>> { fn CreateOscillator(&self) -> Fallible<DomRoot<OscillatorNode>> {
OscillatorNode::new( OscillatorNode::new(self.global().as_window(), self, &OscillatorOptions::empty())
&self.global().as_window(),
&self,
&OscillatorOptions::empty(),
)
} }
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-creategain>
fn CreateGain(&self) -> Fallible<DomRoot<GainNode>> { fn CreateGain(&self) -> Fallible<DomRoot<GainNode>> {
GainNode::new(&self.global().as_window(), &self, &GainOptions::empty()) GainNode::new(self.global().as_window(), self, &GainOptions::empty())
} }
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createpanner> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createpanner>
fn CreatePanner(&self) -> Fallible<DomRoot<PannerNode>> { fn CreatePanner(&self) -> Fallible<DomRoot<PannerNode>> {
PannerNode::new(&self.global().as_window(), &self, &PannerOptions::empty()) PannerNode::new(self.global().as_window(), self, &PannerOptions::empty())
} }
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createanalyser> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createanalyser>
fn CreateAnalyser(&self) -> Fallible<DomRoot<AnalyserNode>> { fn CreateAnalyser(&self) -> Fallible<DomRoot<AnalyserNode>> {
AnalyserNode::new(&self.global().as_window(), &self, &AnalyserOptions::empty()) AnalyserNode::new(self.global().as_window(), self, &AnalyserOptions::empty())
} }
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbiquadfilter> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbiquadfilter>
fn CreateBiquadFilter(&self) -> Fallible<DomRoot<BiquadFilterNode>> { fn CreateBiquadFilter(&self) -> Fallible<DomRoot<BiquadFilterNode>> {
BiquadFilterNode::new( BiquadFilterNode::new(
&self.global().as_window(), self.global().as_window(),
&self, self,
&BiquadFilterOptions::empty(), &BiquadFilterOptions::empty(),
) )
} }
@ -373,8 +369,8 @@ impl BaseAudioContextMethods for BaseAudioContext {
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createstereopanner> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createstereopanner>
fn CreateStereoPanner(&self) -> Fallible<DomRoot<StereoPannerNode>> { fn CreateStereoPanner(&self) -> Fallible<DomRoot<StereoPannerNode>> {
StereoPannerNode::new( StereoPannerNode::new(
&self.global().as_window(), self.global().as_window(),
&self, self,
&StereoPannerOptions::empty(), &StereoPannerOptions::empty(),
) )
} }
@ -382,8 +378,8 @@ impl BaseAudioContextMethods for BaseAudioContext {
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createconstantsource> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createconstantsource>
fn CreateConstantSource(&self) -> Fallible<DomRoot<ConstantSourceNode>> { fn CreateConstantSource(&self) -> Fallible<DomRoot<ConstantSourceNode>> {
ConstantSourceNode::new( ConstantSourceNode::new(
&self.global().as_window(), self.global().as_window(),
&self, self,
&ConstantSourceOptions::empty(), &ConstantSourceOptions::empty(),
) )
} }
@ -392,14 +388,14 @@ impl BaseAudioContextMethods for BaseAudioContext {
fn CreateChannelMerger(&self, count: u32) -> Fallible<DomRoot<ChannelMergerNode>> { fn CreateChannelMerger(&self, count: u32) -> Fallible<DomRoot<ChannelMergerNode>> {
let mut opts = ChannelMergerOptions::empty(); let mut opts = ChannelMergerOptions::empty();
opts.numberOfInputs = count; opts.numberOfInputs = count;
ChannelMergerNode::new(&self.global().as_window(), &self, &opts) ChannelMergerNode::new(self.global().as_window(), self, &opts)
} }
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelsplitter> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelsplitter>
fn CreateChannelSplitter(&self, count: u32) -> Fallible<DomRoot<ChannelSplitterNode>> { fn CreateChannelSplitter(&self, count: u32) -> Fallible<DomRoot<ChannelSplitterNode>> {
let mut opts = ChannelSplitterOptions::empty(); let mut opts = ChannelSplitterOptions::empty();
opts.numberOfOutputs = count; opts.numberOfOutputs = count;
ChannelSplitterNode::new(&self.global().as_window(), &self, &opts) ChannelSplitterNode::new(self.global().as_window(), self, &opts)
} }
/// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer> /// <https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer>
@ -417,7 +413,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
return Err(Error::NotSupported); return Err(Error::NotSupported);
} }
Ok(AudioBuffer::new( Ok(AudioBuffer::new(
&self.global().as_window(), self.global().as_window(),
number_of_channels, number_of_channels,
length, length,
*sample_rate, *sample_rate,
@ -428,8 +424,8 @@ impl BaseAudioContextMethods for BaseAudioContext {
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffersource // https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffersource
fn CreateBufferSource(&self) -> Fallible<DomRoot<AudioBufferSourceNode>> { fn CreateBufferSource(&self) -> Fallible<DomRoot<AudioBufferSourceNode>> {
AudioBufferSourceNode::new( AudioBufferSourceNode::new(
&self.global().as_window(), self.global().as_window(),
&self, self,
&AudioBufferSourceOptions::empty(), &AudioBufferSourceOptions::empty(),
) )
} }
@ -507,7 +503,7 @@ impl BaseAudioContextMethods for BaseAudioContext {
0 0
}; };
let buffer = AudioBuffer::new( let buffer = AudioBuffer::new(
&this.global().as_window(), this.global().as_window(),
decoded_audio.len() as u32 /* number of channels */, decoded_audio.len() as u32 /* number of channels */,
length as u32, length as u32,
this.sample_rate, this.sample_rate,

View file

@ -145,7 +145,7 @@ unsafe fn html_constructor(
// Step 6 // Step 6
rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>()); rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
get_desired_proto(cx, &call_args, proto_id, creator, prototype.handle_mut())?; get_desired_proto(cx, call_args, proto_id, creator, prototype.handle_mut())?;
let entry = definition.construction_stack.borrow().last().cloned(); let entry = definition.construction_stack.borrow().last().cloned();
let result = match entry { let result = match entry {

View file

@ -121,7 +121,7 @@ where
if self.0.reflector().get_jsobject().is_null() { if self.0.reflector().get_jsobject().is_null() {
self.0.trace(tracer); self.0.trace(tracer);
} else { } else {
trace_reflector(tracer, "on stack", &self.0.reflector()); trace_reflector(tracer, "on stack", self.0.reflector());
} }
} }
} }
@ -718,7 +718,7 @@ where
F: FnOnce() -> DomRoot<T>, F: FnOnce() -> DomRoot<T>,
{ {
assert_in_script(); assert_in_script();
&self.ptr.get_or_init(|| Dom::from_ref(&cb())) self.ptr.get_or_init(|| Dom::from_ref(&cb()))
} }
} }

View file

@ -65,7 +65,7 @@ unsafe fn read_blob(
&mut index as *mut u32 &mut index as *mut u32
)); ));
let storage_key = StorageKey { index, name_space }; let storage_key = StorageKey { index, name_space };
if <Blob as Serializable>::deserialize(&owner, &mut sc_holder, storage_key.clone()).is_ok() { if <Blob as Serializable>::deserialize(owner, sc_holder, storage_key.clone()).is_ok() {
let blobs = match sc_holder { let blobs = match sc_holder {
StructuredDataHolder::Read { blobs, .. } => blobs, StructuredDataHolder::Read { blobs, .. } => blobs,
_ => panic!("Unexpected variant of StructuredDataHolder"), _ => panic!("Unexpected variant of StructuredDataHolder"),
@ -171,7 +171,7 @@ unsafe extern "C" fn read_transfer_callback(
let owner = GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof)); let owner = GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof));
if let Ok(_) = <MessagePort as Transferable>::transfer_receive( if let Ok(_) = <MessagePort as Transferable>::transfer_receive(
&owner, &owner,
&mut sc_holder, sc_holder,
extra_data, extra_data,
return_object, return_object,
) { ) {
@ -195,7 +195,7 @@ unsafe extern "C" fn write_transfer_callback(
*tag = StructuredCloneTags::MessagePort as u32; *tag = StructuredCloneTags::MessagePort as u32;
*ownership = TransferableOwnership::SCTAG_TMO_CUSTOM; *ownership = TransferableOwnership::SCTAG_TMO_CUSTOM;
let mut sc_holder = &mut *(closure as *mut StructuredDataHolder); let mut sc_holder = &mut *(closure as *mut StructuredDataHolder);
if let Ok(data) = port.transfer(&mut sc_holder) { if let Ok(data) = port.transfer(sc_holder) {
*extra_data = data; *extra_data = data;
return true; return true;
} }

View file

@ -178,7 +178,7 @@ impl Bluetooth {
// Step 2.4. // Step 2.4.
for filter in filters { for filter in filters {
// Step 2.4.1. // Step 2.4.1.
match canonicalize_filter(&filter) { match canonicalize_filter(filter) {
// Step 2.4.2. // Step 2.4.2.
Ok(f) => uuid_filters.push(f), Ok(f) => uuid_filters.push(f),
Err(e) => { Err(e) => {
@ -576,7 +576,7 @@ impl AsyncBluetoothListener for Bluetooth {
&self.global(), &self.global(),
DOMString::from(device.id.clone()), DOMString::from(device.id.clone()),
device.name.map(DOMString::from), device.name.map(DOMString::from),
&self, self,
); );
device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device)); device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device));
@ -667,7 +667,7 @@ impl PermissionAlgorithm for Bluetooth {
// Step 6.2.1. // Step 6.2.1.
for filter in filters { for filter in filters {
match canonicalize_filter(&filter) { match canonicalize_filter(filter) {
Ok(f) => scan_filters.push(f), Ok(f) => scan_filters.push(f),
Err(error) => return promise.reject_error(error), Err(error) => return promise.reject_error(error),
} }

View file

@ -99,7 +99,7 @@ impl BluetoothDevice {
let (ref service_map_ref, _, _) = self.attribute_instance_map; let (ref service_map_ref, _, _) = self.attribute_instance_map;
let mut service_map = service_map_ref.borrow_mut(); let mut service_map = service_map_ref.borrow_mut();
if let Some(existing_service) = service_map.get(&service.instance_id) { if let Some(existing_service) = service_map.get(&service.instance_id) {
return DomRoot::from_ref(&existing_service); return DomRoot::from_ref(existing_service);
} }
let bt_service = BluetoothRemoteGATTService::new( let bt_service = BluetoothRemoteGATTService::new(
&server.global(), &server.global(),
@ -120,7 +120,7 @@ impl BluetoothDevice {
let (_, ref characteristic_map_ref, _) = self.attribute_instance_map; let (_, ref characteristic_map_ref, _) = self.attribute_instance_map;
let mut characteristic_map = characteristic_map_ref.borrow_mut(); let mut characteristic_map = characteristic_map_ref.borrow_mut();
if let Some(existing_characteristic) = characteristic_map.get(&characteristic.instance_id) { if let Some(existing_characteristic) = characteristic_map.get(&characteristic.instance_id) {
return DomRoot::from_ref(&existing_characteristic); return DomRoot::from_ref(existing_characteristic);
} }
let properties = BluetoothCharacteristicProperties::new( let properties = BluetoothCharacteristicProperties::new(
&service.global(), &service.global(),
@ -167,7 +167,7 @@ impl BluetoothDevice {
let (_, _, ref descriptor_map_ref) = self.attribute_instance_map; let (_, _, ref descriptor_map_ref) = self.attribute_instance_map;
let mut descriptor_map = descriptor_map_ref.borrow_mut(); let mut descriptor_map = descriptor_map_ref.borrow_mut();
if let Some(existing_descriptor) = descriptor_map.get(&descriptor.instance_id) { if let Some(existing_descriptor) = descriptor_map.get(&descriptor.instance_id) {
return DomRoot::from_ref(&existing_descriptor); return DomRoot::from_ref(existing_descriptor);
} }
let bt_descriptor = BluetoothRemoteGATTDescriptor::new( let bt_descriptor = BluetoothRemoteGATTDescriptor::new(
&characteristic.global(), &characteristic.global(),

View file

@ -105,7 +105,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
if let Some(ref existing_device) = device_instance_map.get(&device.id) { if let Some(ref existing_device) = device_instance_map.get(&device.id) {
// https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission // https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission
// Step 3. // Step 3.
self.set_devices(vec![Dom::from_ref(&*existing_device)]); self.set_devices(vec![Dom::from_ref(*existing_device)]);
// https://w3c.github.io/permissions/#dom-permissions-request // https://w3c.github.io/permissions/#dom-permissions-request
// Step 8. // Step 8.

View file

@ -294,13 +294,13 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTCharacteristic {
BluetoothResponse::GetDescriptors(descriptors_vec, single) => { BluetoothResponse::GetDescriptors(descriptors_vec, single) => {
if single { if single {
promise.resolve_native( promise.resolve_native(
&device.get_or_create_descriptor(&descriptors_vec[0], &self), &device.get_or_create_descriptor(&descriptors_vec[0], self),
); );
return; return;
} }
let mut descriptors = vec![]; let mut descriptors = vec![];
for descriptor in descriptors_vec { for descriptor in descriptors_vec {
let bt_descriptor = device.get_or_create_descriptor(&descriptor, &self); let bt_descriptor = device.get_or_create_descriptor(&descriptor, self);
descriptors.push(bt_descriptor); descriptors.push(bt_descriptor);
} }
promise.resolve_native(&descriptors); promise.resolve_native(&descriptors);

View file

@ -162,12 +162,12 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTServer {
BluetoothResponse::GetPrimaryServices(services_vec, single) => { BluetoothResponse::GetPrimaryServices(services_vec, single) => {
let device = self.Device(); let device = self.Device();
if single { if single {
promise.resolve_native(&device.get_or_create_service(&services_vec[0], &self)); promise.resolve_native(&device.get_or_create_service(&services_vec[0], self));
return; return;
} }
let mut services = vec![]; let mut services = vec![];
for service in services_vec { for service in services_vec {
let bt_service = device.get_or_create_service(&service, &self); let bt_service = device.get_or_create_service(&service, self);
services.push(bt_service); services.push(bt_service);
} }
promise.resolve_native(&services); promise.resolve_native(&services);

View file

@ -157,14 +157,14 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTService {
BluetoothResponse::GetCharacteristics(characteristics_vec, single) => { BluetoothResponse::GetCharacteristics(characteristics_vec, single) => {
if single { if single {
promise.resolve_native( promise.resolve_native(
&device.get_or_create_characteristic(&characteristics_vec[0], &self), &device.get_or_create_characteristic(&characteristics_vec[0], self),
); );
return; return;
} }
let mut characteristics = vec![]; let mut characteristics = vec![];
for characteristic in characteristics_vec { for characteristic in characteristics_vec {
let bt_characteristic = let bt_characteristic =
device.get_or_create_characteristic(&characteristic, &self); device.get_or_create_characteristic(&characteristic, self);
characteristics.push(bt_characteristic); characteristics.push(bt_characteristic);
} }
promise.resolve_native(&characteristics); promise.resolve_native(&characteristics);

View file

@ -44,17 +44,17 @@ impl CharacterData {
pub fn clone_with_data(&self, data: DOMString, document: &Document) -> DomRoot<Node> { pub fn clone_with_data(&self, data: DOMString, document: &Document) -> DomRoot<Node> {
match self.upcast::<Node>().type_id() { match self.upcast::<Node>().type_id() {
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => { NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => {
DomRoot::upcast(Comment::new(data, &document, None)) DomRoot::upcast(Comment::new(data, document, None))
}, },
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => { NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
let pi = self.downcast::<ProcessingInstruction>().unwrap(); let pi = self.downcast::<ProcessingInstruction>().unwrap();
DomRoot::upcast(ProcessingInstruction::new(pi.Target(), data, &document)) DomRoot::upcast(ProcessingInstruction::new(pi.Target(), data, document))
}, },
NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::CDATASection)) => { NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::CDATASection)) => {
DomRoot::upcast(CDATASection::new(data, &document)) DomRoot::upcast(CDATASection::new(data, document))
}, },
NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::Text)) => { NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::Text)) => {
DomRoot::upcast(Text::new(data, &document)) DomRoot::upcast(Text::new(data, document))
}, },
_ => unreachable!(), _ => unreachable!(),
} }

View file

@ -55,7 +55,7 @@ impl CryptoMethods for Crypto {
if data.len() > 65536 { if data.len() > 65536 {
return Err(Error::QuotaExceeded); return Err(Error::QuotaExceeded);
} }
self.rng.borrow_mut().fill_bytes(&mut data); self.rng.borrow_mut().fill_bytes(data);
let underlying_object = unsafe { input.underlying_object() }; let underlying_object = unsafe { input.underlying_object() };
TypedArray::<ArrayBufferViewU8, *mut JSObject>::from(*underlying_object) TypedArray::<ArrayBufferViewU8, *mut JSObject>::from(*underlying_object)
.map_err(|_| Error::JSFailed) .map_err(|_| Error::JSFailed)

View file

@ -128,7 +128,7 @@ impl CSSRuleList {
)?; )?;
let parent_stylesheet = &*self.parent_stylesheet; let parent_stylesheet = &*self.parent_stylesheet;
let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule); let dom_rule = CSSRule::new_specific(window, parent_stylesheet, new_rule);
self.dom_rules self.dom_rules
.borrow_mut() .borrow_mut()
.insert(index, MutNullableDom::new(Some(&*dom_rule))); .insert(index, MutNullableDom::new(Some(&*dom_rule)));

View file

@ -73,7 +73,7 @@ impl CSSStyleOwner {
let lock = attr.as_ref().unwrap(); let lock = attr.as_ref().unwrap();
let mut guard = shared_lock.write(); let mut guard = shared_lock.write();
let mut pdb = lock.write_with(&mut guard); let mut pdb = lock.write_with(&mut guard);
let result = f(&mut pdb, &mut changed); let result = f(pdb, &mut changed);
result result
} else { } else {
let mut pdb = PropertyDeclarationBlock::new(); let mut pdb = PropertyDeclarationBlock::new();

View file

@ -433,7 +433,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
// Step 1 // Step 1
if !is_valid_custom_element_name(&name) { if !is_valid_custom_element_name(&name) {
let promise = Promise::new_in_current_realm(comp); let promise = Promise::new_in_current_realm(comp);
promise.reject_native(&DOMException::new(&global_scope, DOMErrorName::SyntaxError)); promise.reject_native(&DOMException::new(global_scope, DOMErrorName::SyntaxError));
return promise; return promise;
} }

View file

@ -121,7 +121,7 @@ impl QueuedTaskConversion for DedicatedWorkerScriptMsg {
}; };
match script_msg { match script_msg {
CommonScriptMsg::Task(_category, _boxed, _pipeline_id, source_name) => { CommonScriptMsg::Task(_category, _boxed, _pipeline_id, source_name) => {
Some(&source_name) Some(source_name)
}, },
_ => None, _ => None,
} }
@ -218,7 +218,7 @@ impl WorkerEventLoopMethods for DedicatedWorkerGlobalScope {
} }
fn handle_worker_post_event(&self, worker: &TrustedWorkerAddress) -> Option<AutoWorkerReset> { fn handle_worker_post_event(&self, worker: &TrustedWorkerAddress) -> Option<AutoWorkerReset> {
let ar = AutoWorkerReset::new(&self, worker.clone()); let ar = AutoWorkerReset::new(self, worker.clone());
Some(ar) Some(ar)
} }
@ -431,7 +431,7 @@ impl DedicatedWorkerGlobalScope {
let (metadata, bytes) = match load_whole_resource( let (metadata, bytes) = match load_whole_resource(
request, request,
&global_scope.resource_threads().sender(), &global_scope.resource_threads().sender(),
&global_scope, global_scope,
) { ) {
Err(_) => { Err(_) => {
println!("error loading script {}", serialized_worker_url); println!("error loading script {}", serialized_worker_url);

View file

@ -229,7 +229,7 @@ impl DissimilarOriginWindow {
let target_origin = match target_origin.0[..].as_ref() { let target_origin = match target_origin.0[..].as_ref() {
"*" => None, "*" => None,
"/" => Some(source_origin.clone()), "/" => Some(source_origin.clone()),
url => match ServoUrl::parse(&url) { url => match ServoUrl::parse(url) {
Ok(url) => Some(url.origin().clone()), Ok(url) => Some(url.origin().clone()),
Err(_) => return Err(Error::Syntax), Err(_) => return Err(Error::Syntax),
}, },

View file

@ -715,7 +715,7 @@ impl Document {
event.set_trusted(true); event.set_trusted(true);
// FIXME(nox): Why are errors silenced here? // FIXME(nox): Why are errors silenced here?
let _ = window.dispatch_event_with_target_override( let _ = window.dispatch_event_with_target_override(
&event, event,
); );
}), }),
self.window.upcast(), self.window.upcast(),
@ -1920,7 +1920,7 @@ impl Document {
.and_then(DomRoot::downcast::<HTMLBodyElement>) .and_then(DomRoot::downcast::<HTMLBodyElement>)
{ {
let body = body.upcast::<Element>(); let body = body.upcast::<Element>();
let value = body.parse_attribute(&ns!(), &local_name, value); let value = body.parse_attribute(&ns!(), local_name, value);
body.set_attribute(local_name, value); body.set_attribute(local_name, value);
} }
} }
@ -2162,7 +2162,7 @@ impl Document {
event.set_trusted(true); event.set_trusted(true);
let event_target = self.window.upcast::<EventTarget>(); let event_target = self.window.upcast::<EventTarget>();
let has_listeners = event_target.has_listeners_for(&atom!("beforeunload")); 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);
// TODO: Step 6, decrease the event loop's termination nesting level by 1. // TODO: Step 6, decrease the event loop's termination nesting level by 1.
// Step 7 // Step 7
if has_listeners { if has_listeners {
@ -2218,13 +2218,13 @@ impl Document {
); );
let event = event.upcast::<Event>(); let event = event.upcast::<Event>();
event.set_trusted(true); event.set_trusted(true);
let _ = self.window.dispatch_event_with_target_override(&event); let _ = self.window.dispatch_event_with_target_override(event);
// TODO Step 6, document visibility steps. // TODO Step 6, document visibility steps.
} }
// Step 7 // Step 7
if !self.fired_unload.get() { if !self.fired_unload.get() {
let event = Event::new( let event = Event::new(
&self.window.upcast(), self.window.upcast(),
atom!("unload"), atom!("unload"),
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::Cancelable, EventCancelable::Cancelable,
@ -2373,7 +2373,7 @@ impl Document {
// FIXME(nox): Why are errors silenced here? // FIXME(nox): Why are errors silenced here?
let _ = window.dispatch_event_with_target_override( let _ = window.dispatch_event_with_target_override(
&event, event,
); );
}), }),
self.window.upcast(), self.window.upcast(),
@ -3441,7 +3441,7 @@ impl Document {
maybe_node maybe_node
.iter() .iter()
.flat_map(|node| node.traverse_preorder(ShadowIncluding::No)) .flat_map(|node| node.traverse_preorder(ShadowIncluding::No))
.filter(|node| callback(&node)) .filter(|node| callback(node))
.count() as u32 .count() as u32
} }
@ -3455,7 +3455,7 @@ impl Document {
maybe_node maybe_node
.iter() .iter()
.flat_map(|node| node.traverse_preorder(ShadowIncluding::No)) .flat_map(|node| node.traverse_preorder(ShadowIncluding::No))
.filter(|node| callback(&node)) .filter(|node| callback(node))
.nth(index as usize) .nth(index as usize)
.map(|n| DomRoot::from_ref(&*n)) .map(|n| DomRoot::from_ref(&*n))
} }
@ -3538,7 +3538,7 @@ impl Document {
pub fn get_element_by_id(&self, id: &Atom) -> Option<DomRoot<Element>> { pub fn get_element_by_id(&self, id: &Atom) -> Option<DomRoot<Element>> {
self.id_map self.id_map
.borrow() .borrow()
.get(&id) .get(id)
.map(|ref elements| DomRoot::from_ref(&*(*elements)[0])) .map(|ref elements| DomRoot::from_ref(&*(*elements)[0]))
} }
@ -4292,7 +4292,7 @@ impl DocumentMethods for Document {
let value = AttrValue::String("".to_owned()); let value = AttrValue::String("".to_owned());
Ok(Attr::new( Ok(Attr::new(
&self, self,
name.clone(), name.clone(),
value, value,
name, name,
@ -4312,7 +4312,7 @@ impl DocumentMethods for Document {
let value = AttrValue::String("".to_owned()); let value = AttrValue::String("".to_owned());
let qualified_name = LocalName::from(qualified_name); let qualified_name = LocalName::from(qualified_name);
Ok(Attr::new( Ok(Attr::new(
&self, self,
local_name, local_name,
value, value,
qualified_name, qualified_name,
@ -4425,7 +4425,7 @@ impl DocumentMethods for Document {
// FIXME(#25136): devicemotionevent, deviceorientationevent // FIXME(#25136): devicemotionevent, deviceorientationevent
// FIXME(#7529): dragevent // FIXME(#7529): dragevent
"events" | "event" | "htmlevents" | "svgevents" => { "events" | "event" | "htmlevents" | "svgevents" => {
Ok(Event::new_uninitialized(&self.window.upcast())) Ok(Event::new_uninitialized(self.window.upcast()))
}, },
"focusevent" => Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))), "focusevent" => Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))),
"hashchangeevent" => Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized( "hashchangeevent" => Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized(
@ -4986,7 +4986,7 @@ impl DocumentMethods for Document {
if a.1 == b.1 { if a.1 == b.1 {
// This can happen if an img has an id different from its name, // This can happen if an img has an id different from its name,
// spec does not say which string to put first. // spec does not say which string to put first.
a.0.cmp(&b.0) a.0.cmp(b.0)
} else if a.1.upcast::<Node>().is_before(b.1.upcast::<Node>()) { } else if a.1.upcast::<Node>().is_before(b.1.upcast::<Node>()) {
Ordering::Less Ordering::Less
} else { } else {

View file

@ -259,7 +259,7 @@ impl DocumentOrShadowRoot {
self, to_unregister, id self, to_unregister, id
); );
let mut id_map = id_map.borrow_mut(); let mut id_map = id_map.borrow_mut();
let is_empty = match id_map.get_mut(&id) { let is_empty = match id_map.get_mut(id) {
None => false, None => false,
Some(elements) => { Some(elements) => {
let position = elements let position = elements
@ -271,7 +271,7 @@ impl DocumentOrShadowRoot {
}, },
}; };
if is_empty { if is_empty {
id_map.remove(&id); id_map.remove(id);
} }
} }

View file

@ -85,7 +85,7 @@ impl DOMMatrix {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> { pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> {
dommatrixinit_to_matrix(&other).map(|(is2D, matrix)| Self::new(global, is2D, matrix)) dommatrixinit_to_matrix(other).map(|(is2D, matrix)| Self::new(global, is2D, matrix))
} }
pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot<Self> { pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot<Self> {
@ -347,7 +347,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.multiply_self(other) .multiply_self(other)
// Step 4. // Step 4.
.and(Ok(DomRoot::from_ref(&self))) .and(Ok(DomRoot::from_ref(self)))
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself
@ -356,7 +356,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.pre_multiply_self(other) .pre_multiply_self(other)
// Step 4. // Step 4.
.and(Ok(DomRoot::from_ref(&self))) .and(Ok(DomRoot::from_ref(self)))
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself
@ -365,7 +365,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.translate_self(tx, ty, tz); .translate_self(tx, ty, tz);
// Step 3. // Step 3.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself
@ -382,7 +382,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.scale_self(scaleX, scaleY, scaleZ, originX, originY, originZ); .scale_self(scaleX, scaleY, scaleZ, originX, originY, originZ);
// Step 7. // Step 7.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself
@ -397,7 +397,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.scale_3d_self(scale, originX, originY, originZ); .scale_3d_self(scale, originX, originY, originZ);
// Step 5. // Step 5.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself
@ -406,7 +406,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.rotate_self(rotX, rotY, rotZ); .rotate_self(rotX, rotY, rotZ);
// Step 8. // Step 8.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself
@ -415,7 +415,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.rotate_from_vector_self(x, y); .rotate_from_vector_self(x, y);
// Step 2. // Step 2.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself
@ -424,7 +424,7 @@ impl DOMMatrixMethods for DOMMatrix {
self.upcast::<DOMMatrixReadOnly>() self.upcast::<DOMMatrixReadOnly>()
.rotate_axis_angle_self(x, y, z, angle); .rotate_axis_angle_self(x, y, z, angle);
// Step 3. // Step 3.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself
@ -432,7 +432,7 @@ impl DOMMatrixMethods for DOMMatrix {
// Step 1. // Step 1.
self.upcast::<DOMMatrixReadOnly>().skew_x_self(sx); self.upcast::<DOMMatrixReadOnly>().skew_x_self(sx);
// Step 2. // Step 2.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself
@ -440,7 +440,7 @@ impl DOMMatrixMethods for DOMMatrix {
// Step 1. // Step 1.
self.upcast::<DOMMatrixReadOnly>().skew_y_self(sy); self.upcast::<DOMMatrixReadOnly>().skew_y_self(sy);
// Step 2. // Step 2.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself
@ -448,6 +448,6 @@ impl DOMMatrixMethods for DOMMatrix {
// Steps 1-2. // Steps 1-2.
self.upcast::<DOMMatrixReadOnly>().invert_self(); self.upcast::<DOMMatrixReadOnly>().invert_self();
// Step 3. // Step 3.
DomRoot::from_ref(&self) DomRoot::from_ref(self)
} }
} }

View file

@ -102,7 +102,7 @@ impl DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> { pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> {
dommatrixinit_to_matrix(&other).map(|(is2D, matrix)| Self::new(global, is2D, matrix)) dommatrixinit_to_matrix(other).map(|(is2D, matrix)| Self::new(global, is2D, matrix))
} }
pub fn matrix(&self) -> Ref<Transform3D<f64>> { pub fn matrix(&self) -> Ref<Transform3D<f64>> {
@ -196,7 +196,7 @@ impl DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself
pub fn multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> { pub fn multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> {
// Step 1. // Step 1.
dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| { dommatrixinit_to_matrix(other).map(|(is2D, other_matrix)| {
// Step 2. // Step 2.
let mut matrix = self.matrix.borrow_mut(); let mut matrix = self.matrix.borrow_mut();
*matrix = other_matrix.then(&matrix); *matrix = other_matrix.then(&matrix);
@ -211,7 +211,7 @@ impl DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself
pub fn pre_multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> { pub fn pre_multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> {
// Step 1. // Step 1.
dommatrixinit_to_matrix(&other).map(|(is2D, other_matrix)| { dommatrixinit_to_matrix(other).map(|(is2D, other_matrix)| {
// Step 2. // Step 2.
let mut matrix = self.matrix.borrow_mut(); let mut matrix = self.matrix.borrow_mut();
*matrix = matrix.then(&other_matrix); *matrix = matrix.then(&other_matrix);
@ -631,7 +631,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> { fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> {
DOMMatrix::from_readonly(&self.global(), self).MultiplySelf(&other) DOMMatrix::from_readonly(&self.global(), self).MultiplySelf(other)
} }
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
@ -731,9 +731,9 @@ fn create_3d_matrix(entries: &[f64]) -> Transform3D<f64> {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence
pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Transform3D<f64>)> { pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Transform3D<f64>)> {
if entries.len() == 6 { if entries.len() == 6 {
Ok((true, create_2d_matrix(&entries))) Ok((true, create_2d_matrix(entries)))
} else if entries.len() == 16 { } else if entries.len() == 16 {
Ok((false, create_3d_matrix(&entries))) Ok((false, create_3d_matrix(entries)))
} else { } else {
let err_msg = format!("Expected 6 or 16 entries, but found {}.", entries.len()); let err_msg = format!("Expected 6 or 16 entries, but found {}.", entries.len());
Err(error::Error::Type(err_msg.to_owned())) Err(error::Error::Type(err_msg.to_owned()))

View file

@ -133,7 +133,7 @@ impl DOMTokenListMethods for DOMTokenList {
fn Add(&self, tokens: Vec<DOMString>) -> ErrorResult { fn Add(&self, tokens: Vec<DOMString>) -> ErrorResult {
let mut atoms = self.element.get_tokenlist_attribute(&self.local_name); let mut atoms = self.element.get_tokenlist_attribute(&self.local_name);
for token in &tokens { for token in &tokens {
let token = self.check_token_exceptions(&token)?; let token = self.check_token_exceptions(token)?;
if !atoms.iter().any(|atom| *atom == token) { if !atoms.iter().any(|atom| *atom == token) {
atoms.push(token); atoms.push(token);
} }
@ -146,7 +146,7 @@ impl DOMTokenListMethods for DOMTokenList {
fn Remove(&self, tokens: Vec<DOMString>) -> ErrorResult { fn Remove(&self, tokens: Vec<DOMString>) -> ErrorResult {
let mut atoms = self.element.get_tokenlist_attribute(&self.local_name); let mut atoms = self.element.get_tokenlist_attribute(&self.local_name);
for token in &tokens { for token in &tokens {
let token = self.check_token_exceptions(&token)?; let token = self.check_token_exceptions(token)?;
atoms atoms
.iter() .iter()
.position(|atom| *atom == token) .position(|atom| *atom == token)

View file

@ -1585,7 +1585,7 @@ impl Element {
.attrs .attrs
.borrow() .borrow()
.iter() .iter()
.find(|attr| find(&attr)) .find(|attr| find(attr))
.map(|js| DomRoot::from_ref(&**js)); .map(|js| DomRoot::from_ref(&**js));
if let Some(attr) = attr { if let Some(attr) = attr {
attr.set_value(value, self); attr.set_value(value, self);
@ -1625,7 +1625,7 @@ impl Element {
where where
F: Fn(&Attr) -> bool, F: Fn(&Attr) -> bool,
{ {
let idx = self.attrs.borrow().iter().position(|attr| find(&attr)); let idx = self.attrs.borrow().iter().position(|attr| find(attr));
idx.map(|idx| { idx.map(|idx| {
let attr = DomRoot::from_ref(&*(*self.attrs.borrow())[idx]); let attr = DomRoot::from_ref(&*(*self.attrs.borrow())[idx]);
self.will_mutate_attr(&attr); self.will_mutate_attr(&attr);
@ -1803,9 +1803,9 @@ impl Element {
} }
}, },
AdjacentPosition::AfterBegin => { AdjacentPosition::AfterBegin => {
Node::pre_insert(node, &self_node, self_node.GetFirstChild().as_deref()).map(Some) Node::pre_insert(node, self_node, self_node.GetFirstChild().as_deref()).map(Some)
}, },
AdjacentPosition::BeforeEnd => Node::pre_insert(node, &self_node, None).map(Some), AdjacentPosition::BeforeEnd => Node::pre_insert(node, self_node, None).map(Some),
AdjacentPosition::AfterEnd => { AdjacentPosition::AfterEnd => {
if let Some(parent) = self_node.GetParentNode() { if let Some(parent) = self_node.GetParentNode() {
Node::pre_insert(node, &parent, self_node.GetNextSibling().as_deref()).map(Some) Node::pre_insert(node, &parent, self_node.GetNextSibling().as_deref()).map(Some)
@ -2222,7 +2222,7 @@ impl ElementMethods for Element {
self.attrs.borrow_mut()[position] = Dom::from_ref(attr); self.attrs.borrow_mut()[position] = Dom::from_ref(attr);
old_attr.set_owner(None); old_attr.set_owner(None);
if attr.namespace() == &ns!() { if attr.namespace() == &ns!() {
vtable.attribute_mutated(&attr, AttributeMutation::Set(Some(&old_attr.value()))); vtable.attribute_mutated(attr, AttributeMutation::Set(Some(&old_attr.value())));
} }
// Step 6. // Step 6.
@ -3076,7 +3076,7 @@ impl VirtualMethods for Element {
let doc = document_from_node(self); let doc = document_from_node(self);
if let Some(ref shadow_root) = self.shadow_root() { if let Some(ref shadow_root) = self.shadow_root() {
doc.register_shadow_root(&shadow_root); doc.register_shadow_root(shadow_root);
let shadow_root = shadow_root.upcast::<Node>(); let shadow_root = shadow_root.upcast::<Node>();
shadow_root.set_flag(NodeFlags::IS_CONNECTED, context.tree_connected); shadow_root.set_flag(NodeFlags::IS_CONNECTED, context.tree_connected);
for node in shadow_root.children() { for node in shadow_root.children() {
@ -3124,7 +3124,7 @@ impl VirtualMethods for Element {
let doc = document_from_node(self); let doc = document_from_node(self);
if let Some(ref shadow_root) = self.shadow_root() { if let Some(ref shadow_root) = self.shadow_root() {
doc.unregister_shadow_root(&shadow_root); doc.unregister_shadow_root(shadow_root);
let shadow_root = shadow_root.upcast::<Node>(); let shadow_root = shadow_root.upcast::<Node>();
shadow_root.set_flag(NodeFlags::IS_CONNECTED, false); shadow_root.set_flag(NodeFlags::IS_CONNECTED, false);
for node in shadow_root.children() { for node in shadow_root.children() {
@ -3358,7 +3358,7 @@ impl<'a> SelectorsElement for DomRoot<Element> {
} }
fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool { fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool {
Element::has_class(&**self, &name, case_sensitivity) Element::has_class(&**self, name, case_sensitivity)
} }
fn is_html_element_in_html_document(&self) -> bool { fn is_html_element_in_html_document(&self) -> bool {

View file

@ -214,7 +214,7 @@ impl Event {
// related to shadow DOM requirements that aren't otherwise // related to shadow DOM requirements that aren't otherwise
// implemented right now. The path also needs to contain // implemented right now. The path also needs to contain
// various flags instead of just bare event targets. // various flags instead of just bare event targets.
let path = self.construct_event_path(&target); let path = self.construct_event_path(target);
rooted_vec!(let event_path <- path.into_iter()); rooted_vec!(let event_path <- path.into_iter());
// Step 5.4 // Step 5.4
@ -333,7 +333,7 @@ impl Event {
if !self.DefaultPrevented() { if !self.DefaultPrevented() {
if let Some(target) = self.GetTarget() { if let Some(target) = self.GetTarget() {
if let Some(node) = target.downcast::<Node>() { if let Some(node) = target.downcast::<Node>() {
let vtable = vtable_for(&node); let vtable = vtable_for(node);
vtable.handle_event(self); vtable.handle_event(self);
} }
} }
@ -712,7 +712,7 @@ fn inner_invoke(
// Step 2.5. // Step 2.5.
if let CompiledEventListener::Listener(event_listener) = listener { if let CompiledEventListener::Listener(event_listener) = listener {
object.remove_listener_if_once(&event.type_(), &event_listener); object.remove_listener_if_once(&event.type_(), event_listener);
} }
// Step 2.6 // Step 2.6

View file

@ -258,7 +258,7 @@ impl EventSourceContext {
task!(dispatch_the_event_source_event: move || { task!(dispatch_the_event_source_event: move || {
let event_source = event_source.root(); let event_source = event_source.root();
if event_source.ready_state.get() != ReadyState::Closed { if event_source.ready_state.get() != ReadyState::Closed {
event.root().upcast::<Event>().fire(&event_source.upcast()); event.root().upcast::<Event>().fire(event_source.upcast());
} }
}), }),
&global, &global,
@ -387,7 +387,7 @@ impl FetchResponseListener for EventSourceContext {
} }
while !input.is_empty() { while !input.is_empty() {
match utf8::decode(&input) { match utf8::decode(input) {
Ok(s) => { Ok(s) => {
self.parse(s.chars()); self.parse(s.chars());
return; return;

View file

@ -207,7 +207,7 @@ impl Gamepad {
} }
pub fn notify_event(&self, event_type: GamepadEventType) { pub fn notify_event(&self, event_type: GamepadEventType) {
let event = GamepadEvent::new_with_type(&self.global(), event_type, &self); let event = GamepadEvent::new_with_type(&self.global(), event_type, self);
event event
.upcast::<Event>() .upcast::<Event>()
.fire(self.global().as_window().upcast::<EventTarget>()); .fire(self.global().as_window().upcast::<EventTarget>());

View file

@ -57,7 +57,7 @@ impl GamepadEvent {
gamepad: &Gamepad, gamepad: &Gamepad,
) -> DomRoot<GamepadEvent> { ) -> DomRoot<GamepadEvent> {
let ev = reflect_dom_object_with_proto( let ev = reflect_dom_object_with_proto(
Box::new(GamepadEvent::new_inherited(&gamepad)), Box::new(GamepadEvent::new_inherited(gamepad)),
global, global,
proto, proto,
); );
@ -78,7 +78,7 @@ impl GamepadEvent {
GamepadEventType::Disconnected => "gamepaddisconnected", GamepadEventType::Disconnected => "gamepaddisconnected",
}; };
GamepadEvent::new(&global, name.into(), false, false, &gamepad) GamepadEvent::new(global, name.into(), false, false, gamepad)
} }
// https://w3c.github.io/gamepad/#gamepadevent-interface // https://w3c.github.io/gamepad/#gamepadevent-interface

View file

@ -1085,7 +1085,7 @@ impl GlobalScope {
let target_global = this.root(); let target_global = this.root();
target_global.route_task_to_port(port_id, task); target_global.route_task_to_port(port_id, task);
}), }),
&self, self,
); );
} }
} }
@ -1259,7 +1259,7 @@ impl GlobalScope {
MessageEvent::dispatch_error(&*destination.upcast(), &global); MessageEvent::dispatch_error(&*destination.upcast(), &global);
} }
}), }),
&self, self,
); );
}); });
} }
@ -1300,7 +1300,7 @@ impl GlobalScope {
// Substep 6 // Substep 6
// Dispatch the event, using the dom message-port. // Dispatch the event, using the dom message-port.
MessageEvent::dispatch_jsval( MessageEvent::dispatch_jsval(
&dom_port.upcast(), dom_port.upcast(),
self, self,
message_clone.handle(), message_clone.handle(),
Some(&origin.ascii_serialization()), Some(&origin.ascii_serialization()),
@ -1309,7 +1309,7 @@ impl GlobalScope {
); );
} else { } else {
// Step 4, fire messageerror event. // Step 4, fire messageerror event.
MessageEvent::dispatch_error(&dom_port.upcast(), self); MessageEvent::dispatch_error(dom_port.upcast(), self);
} }
} }
} }
@ -1531,7 +1531,7 @@ impl GlobalScope {
let target_global = this.root(); let target_global = this.root();
target_global.maybe_add_pending_ports(); target_global.maybe_add_pending_ports();
}), }),
&self, self,
); );
} else { } else {
// If this is a newly-created port, let the constellation immediately know. // If this is a newly-created port, let the constellation immediately know.
@ -1671,7 +1671,7 @@ impl GlobalScope {
let blob_state = self.blob_state.borrow(); let blob_state = self.blob_state.borrow();
if let BlobState::Managed(blobs_map) = &*blob_state { if let BlobState::Managed(blobs_map) = &*blob_state {
let blob_info = blobs_map let blob_info = blobs_map
.get(&blob_id) .get(blob_id)
.expect("get_blob_bytes for an unknown blob."); .expect("get_blob_bytes for an unknown blob.");
match blob_info.blob_impl.blob_data() { match blob_info.blob_impl.blob_data() {
BlobData::Sliced(ref parent, ref rel_pos) => { BlobData::Sliced(ref parent, ref rel_pos) => {
@ -1698,7 +1698,7 @@ impl GlobalScope {
let blob_state = self.blob_state.borrow(); let blob_state = self.blob_state.borrow();
if let BlobState::Managed(blobs_map) = &*blob_state { if let BlobState::Managed(blobs_map) = &*blob_state {
let blob_info = blobs_map let blob_info = blobs_map
.get(&blob_id) .get(blob_id)
.expect("get_blob_bytes_non_sliced called for a unknown blob."); .expect("get_blob_bytes_non_sliced called for a unknown blob.");
match blob_info.blob_impl.blob_data() { match blob_info.blob_impl.blob_data() {
BlobData::File(ref f) => { BlobData::File(ref f) => {
@ -1736,7 +1736,7 @@ impl GlobalScope {
let blob_state = self.blob_state.borrow(); let blob_state = self.blob_state.borrow();
if let BlobState::Managed(blobs_map) = &*blob_state { if let BlobState::Managed(blobs_map) = &*blob_state {
let blob_info = blobs_map let blob_info = blobs_map
.get(&blob_id) .get(blob_id)
.expect("get_blob_bytes_or_file_id for an unknown blob."); .expect("get_blob_bytes_or_file_id for an unknown blob.");
match blob_info.blob_impl.blob_data() { match blob_info.blob_impl.blob_data() {
BlobData::Sliced(ref parent, ref rel_pos) => { BlobData::Sliced(ref parent, ref rel_pos) => {
@ -1772,7 +1772,7 @@ impl GlobalScope {
let blob_state = self.blob_state.borrow(); let blob_state = self.blob_state.borrow();
if let BlobState::Managed(blobs_map) = &*blob_state { if let BlobState::Managed(blobs_map) = &*blob_state {
let blob_info = blobs_map let blob_info = blobs_map
.get(&blob_id) .get(blob_id)
.expect("get_blob_bytes_non_sliced_or_file_id called for a unknown blob."); .expect("get_blob_bytes_non_sliced_or_file_id called for a unknown blob.");
match blob_info.blob_impl.blob_data() { match blob_info.blob_impl.blob_data() {
BlobData::File(ref f) => match f.get_cache() { BlobData::File(ref f) => match f.get_cache() {
@ -1794,7 +1794,7 @@ impl GlobalScope {
let blob_state = self.blob_state.borrow(); let blob_state = self.blob_state.borrow();
if let BlobState::Managed(blobs_map) = &*blob_state { if let BlobState::Managed(blobs_map) = &*blob_state {
let blob_info = blobs_map let blob_info = blobs_map
.get(&blob_id) .get(blob_id)
.expect("get_blob_type_string called for a unknown blob."); .expect("get_blob_type_string called for a unknown blob.");
blob_info.blob_impl.type_string() blob_info.blob_impl.type_string()
} else { } else {
@ -1808,7 +1808,7 @@ impl GlobalScope {
if let BlobState::Managed(blobs_map) = &*blob_state { if let BlobState::Managed(blobs_map) = &*blob_state {
let parent = { let parent = {
let blob_info = blobs_map let blob_info = blobs_map
.get(&blob_id) .get(blob_id)
.expect("get_blob_size called for a unknown blob."); .expect("get_blob_size called for a unknown blob.");
match blob_info.blob_impl.blob_data() { match blob_info.blob_impl.blob_data() {
BlobData::Sliced(ref parent, ref rel_pos) => { BlobData::Sliced(ref parent, ref rel_pos) => {
@ -1830,9 +1830,7 @@ impl GlobalScope {
rel_pos.to_abs_range(parent_size as usize).len() as u64 rel_pos.to_abs_range(parent_size as usize).len() as u64
}, },
None => { None => {
let blob_info = blobs_map let blob_info = blobs_map.get(blob_id).expect("Blob whose size is unknown.");
.get(&blob_id)
.expect("Blob whose size is unknown.");
match blob_info.blob_impl.blob_data() { match blob_info.blob_impl.blob_data() {
BlobData::File(ref f) => f.get_size(), BlobData::File(ref f) => f.get_size(),
BlobData::Memory(ref v) => v.len() as u64, BlobData::Memory(ref v) => v.len() as u64,
@ -1852,7 +1850,7 @@ impl GlobalScope {
if let BlobState::Managed(blobs_map) = &mut *blob_state { if let BlobState::Managed(blobs_map) = &mut *blob_state {
let parent = { let parent = {
let blob_info = blobs_map let blob_info = blobs_map
.get_mut(&blob_id) .get_mut(blob_id)
.expect("get_blob_url_id called for a unknown blob."); .expect("get_blob_url_id called for a unknown blob.");
// Keep track of blobs with outstanding URLs. // Keep track of blobs with outstanding URLs.
@ -1878,13 +1876,13 @@ impl GlobalScope {
}; };
let parent_size = rel_pos.to_abs_range(parent_size as usize).len() as u64; let parent_size = rel_pos.to_abs_range(parent_size as usize).len() as u64;
let blob_info = blobs_map let blob_info = blobs_map
.get_mut(&blob_id) .get_mut(blob_id)
.expect("Blob whose url is requested is unknown."); .expect("Blob whose url is requested is unknown.");
self.create_sliced_url_id(blob_info, &parent_file_id, &rel_pos, parent_size) self.create_sliced_url_id(blob_info, &parent_file_id, &rel_pos, parent_size)
}, },
None => { None => {
let blob_info = blobs_map let blob_info = blobs_map
.get_mut(&blob_id) .get_mut(blob_id)
.expect("Blob whose url is requested is unknown."); .expect("Blob whose url is requested is unknown.");
self.promote(blob_info, /* set_valid is */ true) self.promote(blob_info, /* set_valid is */ true)
}, },
@ -2797,7 +2795,7 @@ impl GlobalScope {
.map(|data| data.to_vec()) .map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]); .unwrap_or_else(|| vec![0; size.area() as usize * 4]);
let image_bitmap = ImageBitmap::new(&self, size.width, size.height).unwrap(); let image_bitmap = ImageBitmap::new(self, size.width, size.height).unwrap();
image_bitmap.set_bitmap_data(data); image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean()); image_bitmap.set_origin_clean(canvas.origin_is_clean());
@ -2817,7 +2815,7 @@ impl GlobalScope {
.map(|data| data.to_vec()) .map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]); .unwrap_or_else(|| vec![0; size.area() as usize * 4]);
let image_bitmap = ImageBitmap::new(&self, size.width, size.height).unwrap(); let image_bitmap = ImageBitmap::new(self, size.width, size.height).unwrap();
image_bitmap.set_bitmap_data(data); image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean()); image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap)); p.resolve_native(&(image_bitmap));

View file

@ -248,7 +248,7 @@ impl AsyncWGPUListener for GPUAdapter {
let device = GPUDevice::new( let device = GPUDevice::new(
&self.global(), &self.global(),
self.channel.clone(), self.channel.clone(),
&self, self,
Heap::default(), Heap::default(),
descriptor.features, descriptor.features,
descriptor.limits, descriptor.limits,

View file

@ -146,7 +146,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
GPUComputePassEncoder::new( GPUComputePassEncoder::new(
&self.global(), &self.global(),
self.channel.clone(), self.channel.clone(),
&self, self,
compute_pass, compute_pass,
descriptor.parent.label.clone().unwrap_or_default(), descriptor.parent.label.clone().unwrap_or_default(),
) )
@ -245,7 +245,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
&self.global(), &self.global(),
self.channel.clone(), self.channel.clone(),
render_pass, render_pass,
&self, self,
descriptor.parent.label.clone().unwrap_or_default(), descriptor.parent.label.clone().unwrap_or_default(),
) )
} }

View file

@ -418,7 +418,7 @@ impl GPUDeviceMethods for GPUDevice {
&self.global(), &self.global(),
self.channel.clone(), self.channel.clone(),
buffer, buffer,
&self, self,
state, state,
descriptor.size, descriptor.size,
map_info, map_info,
@ -733,7 +733,7 @@ impl GPUDeviceMethods for GPUDevice {
compute_pipeline, compute_pipeline,
descriptor.parent.parent.label.clone().unwrap_or_default(), descriptor.parent.parent.label.clone().unwrap_or_default(),
bgls, bgls,
&self, self,
) )
} }
@ -776,7 +776,7 @@ impl GPUDeviceMethods for GPUDevice {
GPUCommandEncoder::new( GPUCommandEncoder::new(
&self.global(), &self.global(),
self.channel.clone(), self.channel.clone(),
&self, self,
encoder, encoder,
descriptor.parent.label.clone().unwrap_or_default(), descriptor.parent.label.clone().unwrap_or_default(),
) )
@ -836,7 +836,7 @@ impl GPUDeviceMethods for GPUDevice {
GPUTexture::new( GPUTexture::new(
&self.global(), &self.global(),
texture, texture,
&self, self,
self.channel.clone(), self.channel.clone(),
size, size,
descriptor.mipLevelCount, descriptor.mipLevelCount,
@ -1047,7 +1047,7 @@ impl GPUDeviceMethods for GPUDevice {
render_pipeline, render_pipeline,
descriptor.parent.parent.label.clone().unwrap_or_default(), descriptor.parent.parent.label.clone().unwrap_or_default(),
bgls, bgls,
&self, self,
) )
} }
@ -1095,7 +1095,7 @@ impl GPUDeviceMethods for GPUDevice {
GPURenderBundleEncoder::new( GPURenderBundleEncoder::new(
&self.global(), &self.global(),
render_bundle_encoder, render_bundle_encoder,
&self, self,
self.channel.clone(), self.channel.clone(),
descriptor.parent.parent.label.clone().unwrap_or_default(), descriptor.parent.parent.label.clone().unwrap_or_default(),
) )

View file

@ -185,7 +185,7 @@ impl GPUTextureMethods for GPUTexture {
GPUTextureView::new( GPUTextureView::new(
&self.global(), &self.global(),
texture_view, texture_view,
&self, self,
descriptor.parent.label.clone().unwrap_or_default(), descriptor.parent.label.clone().unwrap_or_default(),
) )
} }

View file

@ -54,7 +54,7 @@ impl History {
state.set(NullValue()); state.set(NullValue());
History { History {
reflector_: Reflector::new(), reflector_: Reflector::new(),
window: Dom::from_ref(&window), window: Dom::from_ref(window),
state, state,
state_id: Cell::new(None), state_id: Cell::new(None),
} }
@ -121,7 +121,7 @@ impl History {
}; };
let global_scope = self.window.upcast::<GlobalScope>(); let global_scope = self.window.upcast::<GlobalScope>();
rooted!(in(*GlobalScope::get_cx()) let mut state = UndefinedValue()); rooted!(in(*GlobalScope::get_cx()) let mut state = UndefinedValue());
if let Err(_) = structuredclone::read(&global_scope, data, state.handle_mut()) { if let Err(_) = structuredclone::read(global_scope, data, state.handle_mut()) {
warn!("Error reading structuredclone data"); warn!("Error reading structuredclone data");
} }
self.state.set(state.get()); self.state.set(state.get());
@ -270,7 +270,7 @@ impl History {
// Step 11 // Step 11
let global_scope = self.window.upcast::<GlobalScope>(); let global_scope = self.window.upcast::<GlobalScope>();
rooted!(in(*cx) let mut state = UndefinedValue()); rooted!(in(*cx) let mut state = UndefinedValue());
if let Err(_) = structuredclone::read(&global_scope, serialized_data, state.handle_mut()) { if let Err(_) = structuredclone::read(global_scope, serialized_data, state.handle_mut()) {
warn!("Error reading structuredclone data"); warn!("Error reading structuredclone data");
} }

View file

@ -289,7 +289,7 @@ impl HTMLCanvasElement {
match WebGLContextAttributes::new(cx, options) { match WebGLContextAttributes::new(cx, options) {
Ok(ConversionResult::Success(ref attrs)) => Some(From::from(attrs)), Ok(ConversionResult::Success(ref attrs)) => Some(From::from(attrs)),
Ok(ConversionResult::Failure(ref error)) => { Ok(ConversionResult::Failure(ref error)) => {
throw_type_error(*cx, &error); throw_type_error(*cx, error);
None None
}, },
_ => { _ => {

View file

@ -292,7 +292,7 @@ impl HTMLCollection {
after after
.following_nodes(&self.root) .following_nodes(&self.root)
.filter_map(DomRoot::downcast) .filter_map(DomRoot::downcast)
.filter(move |element| self.filter.filter(&element, &self.root)) .filter(move |element| self.filter.filter(element, &self.root))
} }
pub fn elements_iter<'a>(&'a self) -> impl Iterator<Item = DomRoot<Element>> + 'a { pub fn elements_iter<'a>(&'a self) -> impl Iterator<Item = DomRoot<Element>> + 'a {
@ -308,7 +308,7 @@ impl HTMLCollection {
before before
.preceding_nodes(&self.root) .preceding_nodes(&self.root)
.filter_map(DomRoot::downcast) .filter_map(DomRoot::downcast)
.filter(move |element| self.filter.filter(&element, &self.root)) .filter(move |element| self.filter.filter(element, &self.root))
} }
pub fn root_node(&self) -> DomRoot<Node> { pub fn root_node(&self) -> DomRoot<Node> {

View file

@ -492,7 +492,7 @@ impl HTMLElementMethods for HTMLElement {
} }
let br = HTMLBRElement::new(local_name!("br"), None, &document, None); let br = HTMLBRElement::new(local_name!("br"), None, &document, None);
fragment.upcast::<Node>().AppendChild(&br.upcast()).unwrap(); fragment.upcast::<Node>().AppendChild(br.upcast()).unwrap();
}, },
_ => { _ => {
text.push(ch); text.push(ch);
@ -550,7 +550,7 @@ fn append_text_node_to_fragment(document: &Document, fragment: &DocumentFragment
let text = Text::new(DOMString::from(text), document); let text = Text::new(DOMString::from(text), document);
fragment fragment
.upcast::<Node>() .upcast::<Node>()
.AppendChild(&text.upcast()) .AppendChild(text.upcast())
.unwrap(); .unwrap();
} }
@ -691,7 +691,7 @@ impl HTMLElement {
.iter() .iter()
.filter_map(|attr| { .filter_map(|attr| {
let raw_name = attr.local_name(); let raw_name = attr.local_name();
to_camel_case(&raw_name) to_camel_case(raw_name)
}) })
.collect() .collect()
} }

View file

@ -178,7 +178,7 @@ impl HTMLFormElement {
self.controls self.controls
.borrow() .borrow()
.iter() .iter()
.filter(|n| HTMLFormElement::filter_for_radio_list(mode, &*n, name)) .filter(|n| HTMLFormElement::filter_for_radio_list(mode, *n, name))
.nth(index as usize) .nth(index as usize)
.and_then(|n| Some(DomRoot::from_ref(n.upcast::<Node>()))) .and_then(|n| Some(DomRoot::from_ref(n.upcast::<Node>())))
} }
@ -281,12 +281,12 @@ impl HTMLFormElementMethods for HTMLFormElement {
let submit_button = match element { let submit_button = match element {
HTMLElementTypeId::HTMLInputElement => FormSubmitter::InputElement( HTMLElementTypeId::HTMLInputElement => FormSubmitter::InputElement(
&submitter_element submitter_element
.downcast::<HTMLInputElement>() .downcast::<HTMLInputElement>()
.expect("Failed to downcast submitter elem to HTMLInputElement."), .expect("Failed to downcast submitter elem to HTMLInputElement."),
), ),
HTMLElementTypeId::HTMLButtonElement => FormSubmitter::ButtonElement( HTMLElementTypeId::HTMLButtonElement => FormSubmitter::ButtonElement(
&submitter_element submitter_element
.downcast::<HTMLButtonElement>() .downcast::<HTMLButtonElement>()
.expect("Failed to downcast submitter elem to HTMLButtonElement."), .expect("Failed to downcast submitter elem to HTMLButtonElement."),
), ),
@ -317,7 +317,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
}, },
None => { None => {
// Step 2 // Step 2
FormSubmitter::FormElement(&self) FormSubmitter::FormElement(self)
}, },
}; };
// Step 3 // Step 3
@ -849,7 +849,7 @@ impl HTMLFormElement {
load_data load_data
.headers .headers
.typed_insert(ContentType::from(mime::APPLICATION_WWW_FORM_URLENCODED)); .typed_insert(ContentType::from(mime::APPLICATION_WWW_FORM_URLENCODED));
self.mutate_action_url(&mut form_data, load_data, encoding, &target_window); self.mutate_action_url(&mut form_data, load_data, encoding, target_window);
}, },
// https://html.spec.whatwg.org/multipage/#submit-body // https://html.spec.whatwg.org/multipage/#submit-body
("http", FormMethod::FormPost) | ("https", FormMethod::FormPost) => { ("http", FormMethod::FormPost) | ("https", FormMethod::FormPost) => {