mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Migrate to the 2024 edition (#35755)
* Migrate to 2024 edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Allow unsafe_op_in_unsafe_fn lint This lint warns by default in the 2024 edition, but is *way* too noisy for servo. We might enable it in the future, but not now. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Compile using the 2024 edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
eb2ca42824
commit
bb0d08432e
66 changed files with 317 additions and 293 deletions
|
@ -27,6 +27,7 @@ webgpu = ["script_bindings/webgpu", "script_traits/webgpu"]
|
|||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(crown)'] }
|
||||
unsafe_op_in_unsafe_fn = { level = "allow" }
|
||||
|
||||
[dependencies]
|
||||
aes = { workspace = true }
|
||||
|
|
|
@ -438,11 +438,11 @@ impl Extractable for BodyInit {
|
|||
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
|
||||
fn extract(&self, global: &GlobalScope, can_gc: CanGc) -> Fallible<ExtractedBody> {
|
||||
match self {
|
||||
BodyInit::String(ref s) => s.extract(global, can_gc),
|
||||
BodyInit::URLSearchParams(ref usp) => usp.extract(global, can_gc),
|
||||
BodyInit::Blob(ref b) => b.extract(global, can_gc),
|
||||
BodyInit::FormData(ref formdata) => formdata.extract(global, can_gc),
|
||||
BodyInit::ArrayBuffer(ref typedarray) => {
|
||||
BodyInit::String(s) => s.extract(global, can_gc),
|
||||
BodyInit::URLSearchParams(usp) => usp.extract(global, can_gc),
|
||||
BodyInit::Blob(b) => b.extract(global, can_gc),
|
||||
BodyInit::FormData(formdata) => formdata.extract(global, can_gc),
|
||||
BodyInit::ArrayBuffer(typedarray) => {
|
||||
let bytes = typedarray.to_vec();
|
||||
let total_bytes = bytes.len();
|
||||
let stream = ReadableStream::new_from_bytes(global, bytes, can_gc)?;
|
||||
|
@ -453,7 +453,7 @@ impl Extractable for BodyInit {
|
|||
source: BodySource::Object,
|
||||
})
|
||||
},
|
||||
BodyInit::ArrayBufferView(ref typedarray) => {
|
||||
BodyInit::ArrayBufferView(typedarray) => {
|
||||
let bytes = typedarray.to_vec();
|
||||
let total_bytes = bytes.len();
|
||||
let stream = ReadableStream::new_from_bytes(global, bytes, can_gc)?;
|
||||
|
|
|
@ -114,7 +114,7 @@ impl QueuedTaskConversion for DedicatedWorkerScriptMsg {
|
|||
_ => return None,
|
||||
};
|
||||
let script_msg = match common_worker_msg {
|
||||
WorkerScriptMsg::Common(ref script_msg) => script_msg,
|
||||
WorkerScriptMsg::Common(script_msg) => script_msg,
|
||||
_ => return None,
|
||||
};
|
||||
match script_msg {
|
||||
|
|
|
@ -1618,7 +1618,7 @@ impl Element {
|
|||
if *name == local_name!("id") || *name == local_name!("name") {
|
||||
match maybe_attr {
|
||||
None => true,
|
||||
Some(ref attr) => matches!(*attr.value(), AttrValue::Atom(_)),
|
||||
Some(attr) => matches!(*attr.value(), AttrValue::Atom(_)),
|
||||
}
|
||||
} else {
|
||||
true
|
||||
|
|
|
@ -149,8 +149,8 @@ impl FileReaderSharedFunctionality {
|
|||
let resultmime = blob_type.parse::<Mime>().ok();
|
||||
resultmime.and_then(|mime| {
|
||||
mime.params()
|
||||
.find(|(ref k, _)| &mime::CHARSET == k)
|
||||
.and_then(|(_, ref v)| Encoding::for_label(v.as_ref().as_bytes()))
|
||||
.find(|(k, _)| &mime::CHARSET == k)
|
||||
.and_then(|(_, v)| Encoding::for_label(v.as_ref().as_bytes()))
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
@ -95,16 +95,16 @@ fn parse_font_face_descriptors(
|
|||
);
|
||||
|
||||
let FontFaceDescriptors {
|
||||
ref ascentOverride,
|
||||
ref descentOverride,
|
||||
ref display,
|
||||
ref featureSettings,
|
||||
ref lineGapOverride,
|
||||
ref stretch,
|
||||
ref style,
|
||||
ref unicodeRange,
|
||||
ref variationSettings,
|
||||
ref weight,
|
||||
ascentOverride,
|
||||
descentOverride,
|
||||
display,
|
||||
featureSettings,
|
||||
lineGapOverride,
|
||||
stretch,
|
||||
style,
|
||||
unicodeRange,
|
||||
variationSettings,
|
||||
weight,
|
||||
} = input_descriptors;
|
||||
|
||||
let _ = variationSettings; // TODO: Stylo doesn't parse font-variation-settings yet.
|
||||
|
|
|
@ -181,10 +181,8 @@ impl FormDataMethods<crate::DomTypeHolder> for FormData {
|
|||
.iter()
|
||||
.find(|(datum_name, _)| datum_name.0 == name.0)
|
||||
.map(|(_, datum)| match &datum.value {
|
||||
FormDatumValue::String(ref s) => {
|
||||
FileOrUSVString::USVString(USVString(s.to_string()))
|
||||
},
|
||||
FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(b)),
|
||||
FormDatumValue::String(s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
||||
FormDatumValue::File(b) => FileOrUSVString::File(DomRoot::from_ref(b)),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -199,10 +197,10 @@ impl FormDataMethods<crate::DomTypeHolder> for FormData {
|
|||
}
|
||||
|
||||
Some(match &datum.value {
|
||||
FormDatumValue::String(ref s) => {
|
||||
FormDatumValue::String(s) => {
|
||||
FileOrUSVString::USVString(USVString(s.to_string()))
|
||||
},
|
||||
FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(b)),
|
||||
FormDatumValue::File(b) => FileOrUSVString::File(DomRoot::from_ref(b)),
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
|
@ -308,8 +306,8 @@ impl Iterable for FormData {
|
|||
let data = self.data.borrow();
|
||||
let datum = &data.get(n as usize).unwrap().1;
|
||||
match &datum.value {
|
||||
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
||||
FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(b)),
|
||||
FormDatumValue::String(s) => FileOrUSVString::USVString(USVString(s.to_string())),
|
||||
FormDatumValue::File(b) => FileOrUSVString::File(DomRoot::from_ref(b)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1338,7 +1338,7 @@ impl GlobalScope {
|
|||
/// TODO: Also remove them if they do not have an event-listener.
|
||||
/// see <https://github.com/servo/servo/issues/25772>
|
||||
pub(crate) fn perform_a_broadcast_channel_garbage_collection_checkpoint(&self) {
|
||||
let is_empty = if let BroadcastChannelState::Managed(router_id, ref mut channels) =
|
||||
let is_empty = if let BroadcastChannelState::Managed(router_id, channels) =
|
||||
&mut *self.broadcast_channel_state.borrow_mut()
|
||||
{
|
||||
channels.retain(|name, ref mut channels| {
|
||||
|
@ -1552,7 +1552,7 @@ impl GlobalScope {
|
|||
BlobTracker::Blob(weak) => weak.root().is_none(),
|
||||
};
|
||||
if garbage_collected && !blob_info.has_url {
|
||||
if let BlobData::File(ref f) = blob_info.blob_impl.blob_data() {
|
||||
if let BlobData::File(f) = blob_info.blob_impl.blob_data() {
|
||||
self.decrement_file_ref(f.get_id());
|
||||
}
|
||||
false
|
||||
|
@ -1569,7 +1569,7 @@ impl GlobalScope {
|
|||
.borrow_mut()
|
||||
.drain()
|
||||
.for_each(|(_id, blob_info)| {
|
||||
if let BlobData::File(ref f) = blob_info.blob_impl.blob_data() {
|
||||
if let BlobData::File(f) = blob_info.blob_impl.blob_data() {
|
||||
self.decrement_file_ref(f.get_id());
|
||||
}
|
||||
});
|
||||
|
@ -1594,7 +1594,7 @@ impl GlobalScope {
|
|||
.get(blob_id)
|
||||
.expect("get_blob_bytes for an unknown blob.");
|
||||
match blob_info.blob_impl.blob_data() {
|
||||
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
BlobData::Sliced(parent, rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
_ => None,
|
||||
}
|
||||
};
|
||||
|
@ -1615,7 +1615,7 @@ impl GlobalScope {
|
|||
.get(blob_id)
|
||||
.expect("get_blob_bytes_non_sliced called for a unknown blob.");
|
||||
match blob_info.blob_impl.blob_data() {
|
||||
BlobData::File(ref f) => {
|
||||
BlobData::File(f) => {
|
||||
let (buffer, is_new_buffer) = match f.get_cache() {
|
||||
Some(bytes) => (bytes, false),
|
||||
None => {
|
||||
|
@ -1631,7 +1631,7 @@ impl GlobalScope {
|
|||
|
||||
Ok(buffer)
|
||||
},
|
||||
BlobData::Memory(ref s) => Ok(s.clone()),
|
||||
BlobData::Memory(s) => Ok(s.clone()),
|
||||
BlobData::Sliced(_, _) => panic!("This blob doesn't have a parent."),
|
||||
}
|
||||
}
|
||||
|
@ -1649,7 +1649,7 @@ impl GlobalScope {
|
|||
.get(blob_id)
|
||||
.expect("get_blob_bytes_or_file_id for an unknown blob.");
|
||||
match blob_info.blob_impl.blob_data() {
|
||||
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
BlobData::Sliced(parent, rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
_ => None,
|
||||
}
|
||||
};
|
||||
|
@ -1679,11 +1679,11 @@ impl GlobalScope {
|
|||
.get(blob_id)
|
||||
.expect("get_blob_bytes_non_sliced_or_file_id called for a unknown blob.");
|
||||
match blob_info.blob_impl.blob_data() {
|
||||
BlobData::File(ref f) => match f.get_cache() {
|
||||
BlobData::File(f) => match f.get_cache() {
|
||||
Some(bytes) => BlobResult::Bytes(bytes.clone()),
|
||||
None => BlobResult::File(f.get_id(), f.get_size() as usize),
|
||||
},
|
||||
BlobData::Memory(ref s) => BlobResult::Bytes(s.clone()),
|
||||
BlobData::Memory(s) => BlobResult::Bytes(s.clone()),
|
||||
BlobData::Sliced(_, _) => panic!("This blob doesn't have a parent."),
|
||||
}
|
||||
}
|
||||
|
@ -1705,7 +1705,7 @@ impl GlobalScope {
|
|||
.get(blob_id)
|
||||
.expect("get_blob_size called for a unknown blob.");
|
||||
match blob_info.blob_impl.blob_data() {
|
||||
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
BlobData::Sliced(parent, rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
_ => None,
|
||||
}
|
||||
};
|
||||
|
@ -1715,8 +1715,8 @@ impl GlobalScope {
|
|||
.get(&parent_id)
|
||||
.expect("Parent of blob whose size is unknown.");
|
||||
let parent_size = match parent_info.blob_impl.blob_data() {
|
||||
BlobData::File(ref f) => f.get_size(),
|
||||
BlobData::Memory(ref v) => v.len() as u64,
|
||||
BlobData::File(f) => f.get_size(),
|
||||
BlobData::Memory(v) => v.len() as u64,
|
||||
BlobData::Sliced(_, _) => panic!("Blob ancestry should be only one level."),
|
||||
};
|
||||
rel_pos.to_abs_range(parent_size as usize).len() as u64
|
||||
|
@ -1726,8 +1726,8 @@ impl GlobalScope {
|
|||
.get(blob_id)
|
||||
.expect("Blob whose size is unknown.");
|
||||
match blob_info.blob_impl.blob_data() {
|
||||
BlobData::File(ref f) => f.get_size(),
|
||||
BlobData::Memory(ref v) => v.len() as u64,
|
||||
BlobData::File(f) => f.get_size(),
|
||||
BlobData::Memory(v) => v.len() as u64,
|
||||
BlobData::Sliced(_, _) => {
|
||||
panic!("It was previously checked that this blob does not have a parent.")
|
||||
},
|
||||
|
@ -1747,7 +1747,7 @@ impl GlobalScope {
|
|||
blob_info.has_url = true;
|
||||
|
||||
match blob_info.blob_impl.blob_data() {
|
||||
BlobData::Sliced(ref parent, ref rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
BlobData::Sliced(parent, rel_pos) => Some((*parent, rel_pos.clone())),
|
||||
_ => None,
|
||||
}
|
||||
};
|
||||
|
@ -1758,8 +1758,8 @@ impl GlobalScope {
|
|||
.expect("Parent of blob whose url is requested is unknown.");
|
||||
let parent_file_id = self.promote(parent_info, /* set_valid is */ false);
|
||||
let parent_size = match parent_info.blob_impl.blob_data() {
|
||||
BlobData::File(ref f) => f.get_size(),
|
||||
BlobData::Memory(ref v) => v.len() as u64,
|
||||
BlobData::File(f) => f.get_size(),
|
||||
BlobData::Memory(v) => v.len() as u64,
|
||||
BlobData::Sliced(_, _) => panic!("Blob ancestry should be only one level."),
|
||||
};
|
||||
let parent_size = rel_pos.to_abs_range(parent_size as usize).len() as u64;
|
||||
|
@ -1827,7 +1827,7 @@ impl GlobalScope {
|
|||
BlobData::Sliced(_, _) => {
|
||||
panic!("Sliced blobs should use create_sliced_url_id instead of promote.");
|
||||
},
|
||||
BlobData::File(ref f) => {
|
||||
BlobData::File(f) => {
|
||||
if set_valid {
|
||||
let origin = get_blob_origin(&global_url);
|
||||
let (tx, rx) = profile_ipc::channel(self.time_profiler_chan().clone()).unwrap();
|
||||
|
@ -1845,7 +1845,7 @@ impl GlobalScope {
|
|||
return f.get_id();
|
||||
}
|
||||
},
|
||||
BlobData::Memory(ref mut bytes_in) => mem::swap(bytes_in, &mut bytes),
|
||||
BlobData::Memory(bytes_in) => mem::swap(bytes_in, &mut bytes),
|
||||
};
|
||||
|
||||
let origin = get_blob_origin(&global_url);
|
||||
|
|
|
@ -213,7 +213,7 @@ impl VideoFrameRenderer for MediaFrameRenderer {
|
|||
);
|
||||
|
||||
match &mut self.current_frame {
|
||||
Some(ref mut current_frame)
|
||||
Some(current_frame)
|
||||
if current_frame.width == frame.get_width() &&
|
||||
current_frame.height == frame.get_height() =>
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ impl VideoFrameRenderer for MediaFrameRenderer {
|
|||
updates.push(ImageUpdate::DeleteImage(old_image_key));
|
||||
}
|
||||
},
|
||||
Some(ref mut current_frame) => {
|
||||
Some(current_frame) => {
|
||||
self.old_frame = Some(current_frame.image_key);
|
||||
|
||||
let Some(new_image_key) = self.compositor_api.generate_image_key() else {
|
||||
|
@ -971,7 +971,7 @@ impl HTMLMediaElement {
|
|||
Some(ServoUrl::parse(&blob_url).expect("infallible"));
|
||||
self.fetch_request(None, None);
|
||||
},
|
||||
SrcObject::MediaStream(ref stream) => {
|
||||
SrcObject::MediaStream(stream) => {
|
||||
let tracks = &*stream.get_tracks();
|
||||
for (pos, track) in tracks.iter().enumerate() {
|
||||
if self
|
||||
|
@ -1788,7 +1788,7 @@ impl HTMLMediaElement {
|
|||
// fetching where we left.
|
||||
if let Some(ref current_fetch_context) = *self.current_fetch_context.borrow() {
|
||||
match current_fetch_context.cancel_reason() {
|
||||
Some(ref reason) if *reason == CancelReason::Backoff => {
|
||||
Some(reason) if *reason == CancelReason::Backoff => {
|
||||
// XXX(ferjm) Ideally we should just create a fetch request from
|
||||
// where we left. But keeping track of the exact next byte that the
|
||||
// media backend expects is not the easiest task, so I'm simply
|
||||
|
|
|
@ -114,7 +114,9 @@ impl HTMLSelectElement {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#concept-select-option-list
|
||||
pub(crate) fn list_of_options(&self) -> impl Iterator<Item = DomRoot<HTMLOptionElement>> {
|
||||
pub(crate) fn list_of_options(
|
||||
&self,
|
||||
) -> impl Iterator<Item = DomRoot<HTMLOptionElement>> + use<'_> {
|
||||
self.upcast::<Node>().children().flat_map(|node| {
|
||||
if node.is::<HTMLOptionElement>() {
|
||||
let node = DomRoot::downcast::<HTMLOptionElement>(node).unwrap();
|
||||
|
|
|
@ -118,22 +118,20 @@ fn convert_constraints(js: &BooleanOrMediaTrackConstraints) -> Option<MediaTrack
|
|||
match js {
|
||||
BooleanOrMediaTrackConstraints::Boolean(false) => None,
|
||||
BooleanOrMediaTrackConstraints::Boolean(true) => Some(Default::default()),
|
||||
BooleanOrMediaTrackConstraints::MediaTrackConstraints(ref c) => {
|
||||
Some(MediaTrackConstraintSet {
|
||||
height: c.parent.height.as_ref().and_then(convert_culong),
|
||||
width: c.parent.width.as_ref().and_then(convert_culong),
|
||||
aspect: c.parent.aspectRatio.as_ref().and_then(convert_cdouble),
|
||||
frame_rate: c.parent.frameRate.as_ref().and_then(convert_cdouble),
|
||||
sample_rate: c.parent.sampleRate.as_ref().and_then(convert_culong),
|
||||
})
|
||||
},
|
||||
BooleanOrMediaTrackConstraints::MediaTrackConstraints(c) => Some(MediaTrackConstraintSet {
|
||||
height: c.parent.height.as_ref().and_then(convert_culong),
|
||||
width: c.parent.width.as_ref().and_then(convert_culong),
|
||||
aspect: c.parent.aspectRatio.as_ref().and_then(convert_cdouble),
|
||||
frame_rate: c.parent.frameRate.as_ref().and_then(convert_cdouble),
|
||||
sample_rate: c.parent.sampleRate.as_ref().and_then(convert_culong),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_culong(js: &ConstrainULong) -> Option<Constrain<u32>> {
|
||||
match js {
|
||||
ConstrainULong::ClampedUnsignedLong(val) => Some(Constrain::Value(*val)),
|
||||
ConstrainULong::ConstrainULongRange(ref range) => {
|
||||
ConstrainULong::ConstrainULongRange(range) => {
|
||||
if range.parent.min.is_some() || range.parent.max.is_some() {
|
||||
Some(Constrain::Range(ConstrainRange {
|
||||
min: range.parent.min,
|
||||
|
@ -150,7 +148,7 @@ fn convert_culong(js: &ConstrainULong) -> Option<Constrain<u32>> {
|
|||
fn convert_cdouble(js: &ConstrainDouble) -> Option<Constrain<f64>> {
|
||||
match js {
|
||||
ConstrainDouble::Double(val) => Some(Constrain::Value(**val)),
|
||||
ConstrainDouble::ConstrainDoubleRange(ref range) => {
|
||||
ConstrainDouble::ConstrainDoubleRange(range) => {
|
||||
if range.parent.min.is_some() || range.parent.max.is_some() {
|
||||
Some(Constrain::Range(ConstrainRange {
|
||||
min: range.parent.min.map(|x| *x),
|
||||
|
|
|
@ -752,14 +752,18 @@ impl Node {
|
|||
TreeIterator::new(self, shadow_including)
|
||||
}
|
||||
|
||||
pub(crate) fn inclusively_following_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn inclusively_following_siblings(
|
||||
&self,
|
||||
) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: Some(DomRoot::from_ref(self)),
|
||||
next_node: |n| n.GetNextSibling(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn inclusively_preceding_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn inclusively_preceding_siblings(
|
||||
&self,
|
||||
) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: Some(DomRoot::from_ref(self)),
|
||||
next_node: |n| n.GetPreviousSibling(),
|
||||
|
@ -799,14 +803,14 @@ impl Node {
|
|||
.any(|ancestor| &*ancestor == self)
|
||||
}
|
||||
|
||||
pub(crate) fn following_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn following_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: self.GetNextSibling(),
|
||||
next_node: |n| n.GetNextSibling(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn preceding_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn preceding_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: self.GetPreviousSibling(),
|
||||
next_node: |n| n.GetPreviousSibling(),
|
||||
|
@ -827,7 +831,7 @@ impl Node {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn descending_last_children(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn descending_last_children(&self) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: self.GetLastChild(),
|
||||
next_node: |n| n.GetLastChild(),
|
||||
|
@ -1090,7 +1094,7 @@ impl Node {
|
|||
Ok(NodeList::new_simple_list(&window, iter, CanGc::note()))
|
||||
}
|
||||
|
||||
pub(crate) fn ancestors(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn ancestors(&self) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: self.GetParentNode(),
|
||||
next_node: |n| n.GetParentNode(),
|
||||
|
@ -1101,7 +1105,7 @@ impl Node {
|
|||
pub(crate) fn inclusive_ancestors(
|
||||
&self,
|
||||
shadow_including: ShadowIncluding,
|
||||
) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: Some(DomRoot::from_ref(self)),
|
||||
next_node: move |n| {
|
||||
|
@ -1143,21 +1147,21 @@ impl Node {
|
|||
self.is_connected() && self.owner_doc().browsing_context().is_some()
|
||||
}
|
||||
|
||||
pub(crate) fn children(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn children(&self) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: self.GetFirstChild(),
|
||||
next_node: |n| n.GetNextSibling(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn rev_children(&self) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
pub(crate) fn rev_children(&self) -> impl Iterator<Item = DomRoot<Node>> + use<> {
|
||||
SimpleNodeIterator {
|
||||
current: self.GetLastChild(),
|
||||
next_node: |n| n.GetPreviousSibling(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn child_elements(&self) -> impl Iterator<Item = DomRoot<Element>> {
|
||||
pub(crate) fn child_elements(&self) -> impl Iterator<Item = DomRoot<Element>> + use<> {
|
||||
self.children()
|
||||
.filter_map(DomRoot::downcast as fn(_) -> _)
|
||||
.peekable()
|
||||
|
|
|
@ -281,13 +281,13 @@ impl ReadableStream {
|
|||
/// Call into the release steps of the controller,
|
||||
pub(crate) fn perform_release_steps(&self) -> Fallible<()> {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => {
|
||||
Some(ControllerType::Default(controller)) => {
|
||||
let controller = controller
|
||||
.get()
|
||||
.ok_or_else(|| Error::Type("Stream should have controller.".to_string()))?;
|
||||
controller.perform_release_steps()
|
||||
},
|
||||
Some(ControllerType::Byte(ref controller)) => {
|
||||
Some(ControllerType::Byte(controller)) => {
|
||||
let controller = controller
|
||||
.get()
|
||||
.ok_or_else(|| Error::Type("Stream should have controller.".to_string()))?;
|
||||
|
@ -307,11 +307,11 @@ impl ReadableStream {
|
|||
can_gc: CanGc,
|
||||
) {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => controller
|
||||
Some(ControllerType::Default(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.perform_pull_steps(read_request, can_gc),
|
||||
Some(ControllerType::Byte(ref controller)) => controller
|
||||
Some(ControllerType::Byte(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.perform_pull_steps(cx, read_request, can_gc),
|
||||
|
@ -333,7 +333,7 @@ impl ReadableStream {
|
|||
can_gc: CanGc,
|
||||
) {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Byte(ref controller)) => controller
|
||||
Some(ControllerType::Byte(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.perform_pull_into(cx, read_into_request, view, options, can_gc),
|
||||
|
@ -348,7 +348,7 @@ impl ReadableStream {
|
|||
/// <https://streams.spec.whatwg.org/#readable-stream-add-read-request>
|
||||
pub(crate) fn add_read_request(&self, read_request: &ReadRequest) {
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
Some(ReaderType::Default(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
panic!("Attempt to add a read request without having first acquired a reader.");
|
||||
};
|
||||
|
@ -369,7 +369,7 @@ impl ReadableStream {
|
|||
pub(crate) fn add_read_into_request(&self, read_request: &ReadIntoRequest) {
|
||||
match self.reader.borrow().as_ref() {
|
||||
// Assert: stream.[[reader]] implements ReadableStreamBYOBReader.
|
||||
Some(ReaderType::BYOB(ref reader)) => {
|
||||
Some(ReaderType::BYOB(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
unreachable!(
|
||||
"Attempt to add a read into request without having first acquired a reader."
|
||||
|
@ -392,7 +392,7 @@ impl ReadableStream {
|
|||
/// Note: in other use cases this call happens via the controller.
|
||||
pub(crate) fn enqueue_native(&self, bytes: Vec<u8>, can_gc: CanGc) {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => controller
|
||||
Some(ControllerType::Default(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.enqueue_native(bytes, can_gc),
|
||||
|
@ -418,7 +418,7 @@ impl ReadableStream {
|
|||
// Let reader be stream.[[reader]].
|
||||
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
Some(ReaderType::Default(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
// If reader is undefined, return.
|
||||
return;
|
||||
|
@ -427,7 +427,7 @@ impl ReadableStream {
|
|||
// Perform ! ReadableStreamDefaultReaderErrorReadRequests(reader, e).
|
||||
reader.error(e, can_gc);
|
||||
},
|
||||
Some(ReaderType::BYOB(ref reader)) => {
|
||||
Some(ReaderType::BYOB(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
// If reader is undefined, return.
|
||||
return;
|
||||
|
@ -460,7 +460,7 @@ impl ReadableStream {
|
|||
/// <https://streams.spec.whatwg.org/#readable-stream-default-controller-close>
|
||||
pub(crate) fn controller_close_native(&self, can_gc: CanGc) {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => {
|
||||
Some(ControllerType::Default(controller)) => {
|
||||
let _ = controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
|
@ -476,7 +476,7 @@ impl ReadableStream {
|
|||
/// Useful for native source integration only.
|
||||
pub(crate) fn in_memory(&self) -> bool {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => controller
|
||||
Some(ControllerType::Default(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.in_memory(),
|
||||
|
@ -492,7 +492,7 @@ impl ReadableStream {
|
|||
/// Useful for native source integration only.
|
||||
pub(crate) fn get_in_memory_bytes(&self) -> Option<Vec<u8>> {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => controller
|
||||
Some(ControllerType::Default(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.get_in_memory_bytes(),
|
||||
|
@ -536,7 +536,7 @@ impl ReadableStream {
|
|||
|
||||
pub(crate) fn get_default_controller(&self) -> DomRoot<ReadableStreamDefaultController> {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => {
|
||||
Some(ControllerType::Default(controller)) => {
|
||||
controller.get().expect("Stream should have controller.")
|
||||
},
|
||||
_ => {
|
||||
|
@ -549,9 +549,7 @@ impl ReadableStream {
|
|||
|
||||
pub(crate) fn get_default_reader(&self) -> DomRoot<ReadableStreamDefaultReader> {
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
reader.get().expect("Stream should have reader.")
|
||||
},
|
||||
Some(ReaderType::Default(reader)) => reader.get().expect("Stream should have reader."),
|
||||
_ => {
|
||||
unreachable!("Getting default reader for a stream with a non-default reader")
|
||||
},
|
||||
|
@ -565,7 +563,7 @@ impl ReadableStream {
|
|||
/// <https://streams.spec.whatwg.org/#readable-stream-default-reader-read>
|
||||
pub(crate) fn read_a_chunk(&self, can_gc: CanGc) -> Rc<Promise> {
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
Some(ReaderType::Default(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
unreachable!(
|
||||
"Attempt to read stream chunk without having first acquired a reader."
|
||||
|
@ -587,7 +585,7 @@ impl ReadableStream {
|
|||
let reader_ref = self.reader.borrow();
|
||||
|
||||
match reader_ref.as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
Some(ReaderType::Default(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
unreachable!("Attempt to stop reading without having first acquired a reader.");
|
||||
};
|
||||
|
@ -604,8 +602,8 @@ impl ReadableStream {
|
|||
/// <https://streams.spec.whatwg.org/#is-readable-stream-locked>
|
||||
pub(crate) fn is_locked(&self) -> bool {
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => reader.get().is_some(),
|
||||
Some(ReaderType::BYOB(ref reader)) => reader.get().is_some(),
|
||||
Some(ReaderType::Default(reader)) => reader.get().is_some(),
|
||||
Some(ReaderType::BYOB(reader)) => reader.get().is_some(),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
@ -632,21 +630,21 @@ impl ReadableStream {
|
|||
|
||||
pub(crate) fn has_default_reader(&self) -> bool {
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => reader.get().is_some(),
|
||||
Some(ReaderType::Default(reader)) => reader.get().is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn has_byob_reader(&self) -> bool {
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::BYOB(ref reader)) => reader.get().is_some(),
|
||||
Some(ReaderType::BYOB(reader)) => reader.get().is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn has_byte_controller(&self) -> bool {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Byte(ref controller)) => controller.get().is_some(),
|
||||
Some(ControllerType::Byte(controller)) => controller.get().is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -654,7 +652,7 @@ impl ReadableStream {
|
|||
/// <https://streams.spec.whatwg.org/#readable-stream-get-num-read-requests>
|
||||
pub(crate) fn get_num_read_requests(&self) -> usize {
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
Some(ReaderType::Default(reader)) => {
|
||||
let reader = reader
|
||||
.get()
|
||||
.expect("Stream must have a reader when getting the number of read requests.");
|
||||
|
@ -671,7 +669,7 @@ impl ReadableStream {
|
|||
assert!(self.has_byob_reader());
|
||||
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::BYOB(ref reader)) => {
|
||||
Some(ReaderType::BYOB(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
unreachable!(
|
||||
"Stream must have a reader when get num read into requests is called into."
|
||||
|
@ -694,7 +692,7 @@ impl ReadableStream {
|
|||
assert!(self.has_default_reader());
|
||||
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
Some(ReaderType::Default(reader)) => {
|
||||
// step 2 - Let reader be stream.[[reader]].
|
||||
let reader = reader
|
||||
.get()
|
||||
|
@ -735,7 +733,7 @@ impl ReadableStream {
|
|||
|
||||
// Let reader be stream.[[reader]].
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::BYOB(ref reader)) => {
|
||||
Some(ReaderType::BYOB(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
unreachable!(
|
||||
"Stream must have a reader when a read into request is fulfilled."
|
||||
|
@ -776,7 +774,7 @@ impl ReadableStream {
|
|||
self.state.set(ReadableStreamState::Closed);
|
||||
// Let reader be stream.[[reader]].
|
||||
match self.reader.borrow().as_ref() {
|
||||
Some(ReaderType::Default(ref reader)) => {
|
||||
Some(ReaderType::Default(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
// If reader is undefined, return.
|
||||
return;
|
||||
|
@ -784,7 +782,7 @@ impl ReadableStream {
|
|||
// step 5 & 6
|
||||
reader.close(can_gc);
|
||||
},
|
||||
Some(ReaderType::BYOB(ref reader)) => {
|
||||
Some(ReaderType::BYOB(reader)) => {
|
||||
let Some(reader) = reader.get() else {
|
||||
// If reader is undefined, return.
|
||||
return;
|
||||
|
@ -823,7 +821,7 @@ impl ReadableStream {
|
|||
self.close(can_gc);
|
||||
|
||||
// If reader is not undefined and reader implements ReadableStreamBYOBReader,
|
||||
if let Some(ReaderType::BYOB(ref reader)) = self.reader.borrow().as_ref() {
|
||||
if let Some(ReaderType::BYOB(reader)) = self.reader.borrow().as_ref() {
|
||||
if let Some(reader) = reader.get() {
|
||||
// step 6.1, 6.2 & 6.3 of https://streams.spec.whatwg.org/#readable-stream-cancel
|
||||
reader.cancel(can_gc);
|
||||
|
@ -833,11 +831,11 @@ impl ReadableStream {
|
|||
// Let sourceCancelPromise be ! stream.[[controller]].[[CancelSteps]](reason).
|
||||
|
||||
let source_cancel_promise = match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(ref controller)) => controller
|
||||
Some(ControllerType::Default(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.perform_cancel_steps(reason, can_gc),
|
||||
Some(ControllerType::Byte(ref controller)) => controller
|
||||
Some(ControllerType::Byte(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.perform_cancel_steps(reason, can_gc),
|
||||
|
|
|
@ -159,7 +159,7 @@ struct SerializationIterator {
|
|||
stack: Vec<SerializationCommand>,
|
||||
}
|
||||
|
||||
fn rev_children_iter(n: &Node, can_gc: CanGc) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
fn rev_children_iter(n: &Node, can_gc: CanGc) -> impl Iterator<Item = DomRoot<Node>> + use<'_> {
|
||||
if n.downcast::<Element>().is_some_and(|e| e.is_void()) {
|
||||
return Node::new_document_node().rev_children();
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ impl ServoParser {
|
|||
context: &Element,
|
||||
input: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> impl Iterator<Item = DomRoot<Node>> {
|
||||
) -> impl Iterator<Item = DomRoot<Node>> + use<'_> {
|
||||
let context_node = context.upcast::<Node>();
|
||||
let context_document = context_node.owner_doc();
|
||||
let window = context_document.window();
|
||||
|
|
|
@ -65,11 +65,11 @@ impl WebGLFramebufferAttachment {
|
|||
}
|
||||
|
||||
fn root(&self) -> WebGLFramebufferAttachmentRoot {
|
||||
match *self {
|
||||
WebGLFramebufferAttachment::Renderbuffer(ref rb) => {
|
||||
match self {
|
||||
WebGLFramebufferAttachment::Renderbuffer(rb) => {
|
||||
WebGLFramebufferAttachmentRoot::Renderbuffer(DomRoot::from_ref(rb))
|
||||
},
|
||||
WebGLFramebufferAttachment::Texture { ref texture, .. } => {
|
||||
WebGLFramebufferAttachment::Texture { texture, .. } => {
|
||||
WebGLFramebufferAttachmentRoot::Texture(DomRoot::from_ref(texture))
|
||||
},
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ impl WebGLFramebufferAttachment {
|
|||
fn detach(&self) {
|
||||
match self {
|
||||
WebGLFramebufferAttachment::Renderbuffer(rb) => rb.detach_from_framebuffer(),
|
||||
WebGLFramebufferAttachment::Texture { ref texture, .. } => {
|
||||
WebGLFramebufferAttachment::Texture { texture, .. } => {
|
||||
texture.detach_from_framebuffer()
|
||||
},
|
||||
}
|
||||
|
@ -271,11 +271,11 @@ impl WebGLFramebuffer {
|
|||
) -> Result<(), u32> {
|
||||
// Get the size of this attachment.
|
||||
let (format, size) = match attachment {
|
||||
Some(WebGLFramebufferAttachment::Renderbuffer(ref att_rb)) => {
|
||||
Some(WebGLFramebufferAttachment::Renderbuffer(att_rb)) => {
|
||||
(Some(att_rb.internal_format()), att_rb.size())
|
||||
},
|
||||
Some(WebGLFramebufferAttachment::Texture {
|
||||
texture: ref att_tex,
|
||||
texture: att_tex,
|
||||
level,
|
||||
}) => match att_tex.image_info_at_face(0, *level as u32) {
|
||||
Some(info) => (
|
||||
|
|
|
@ -239,7 +239,7 @@ impl GPUDevice {
|
|||
&self,
|
||||
layout: &GPUPipelineLayoutOrGPUAutoLayoutMode,
|
||||
) -> PipelineLayout {
|
||||
if let GPUPipelineLayoutOrGPUAutoLayoutMode::GPUPipelineLayout(ref layout) = layout {
|
||||
if let GPUPipelineLayoutOrGPUAutoLayoutMode::GPUPipelineLayout(layout) = layout {
|
||||
PipelineLayout::Explicit(layout.id().0)
|
||||
} else {
|
||||
let layout_id = self.global().wgpu_id_hub().create_pipeline_layout_id();
|
||||
|
|
|
@ -3097,8 +3097,10 @@ fn is_named_element_with_id_attribute(elem: &Element) -> bool {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
#[no_mangle]
|
||||
#[unsafe(no_mangle)]
|
||||
/// Helper for interactive debugging sessions in lldb/gdb.
|
||||
unsafe extern "C" fn dump_js_stack(cx: *mut RawJSContext) {
|
||||
DumpJSStack(cx, true, false, false);
|
||||
unsafe {
|
||||
DumpJSStack(cx, true, false, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,56 +48,56 @@ pub(crate) enum MixedMessage {
|
|||
impl MixedMessage {
|
||||
pub(crate) fn pipeline_id(&self) -> Option<PipelineId> {
|
||||
match self {
|
||||
MixedMessage::FromConstellation(ref inner_msg) => match *inner_msg {
|
||||
ScriptThreadMessage::StopDelayingLoadEventsMode(id) => Some(id),
|
||||
ScriptThreadMessage::AttachLayout(ref new_layout_info) => new_layout_info
|
||||
MixedMessage::FromConstellation(inner_msg) => match inner_msg {
|
||||
ScriptThreadMessage::StopDelayingLoadEventsMode(id) => Some(*id),
|
||||
ScriptThreadMessage::AttachLayout(new_layout_info) => new_layout_info
|
||||
.parent_info
|
||||
.or(Some(new_layout_info.new_pipeline_id)),
|
||||
ScriptThreadMessage::Resize(id, ..) => Some(id),
|
||||
ScriptThreadMessage::ThemeChange(id, ..) => Some(id),
|
||||
ScriptThreadMessage::ResizeInactive(id, ..) => Some(id),
|
||||
ScriptThreadMessage::UnloadDocument(id) => Some(id),
|
||||
ScriptThreadMessage::ExitPipeline(id, ..) => Some(id),
|
||||
ScriptThreadMessage::Resize(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::ThemeChange(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::ResizeInactive(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::UnloadDocument(id) => Some(*id),
|
||||
ScriptThreadMessage::ExitPipeline(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::ExitScriptThread => None,
|
||||
ScriptThreadMessage::SendInputEvent(id, ..) => Some(id),
|
||||
ScriptThreadMessage::Viewport(id, ..) => Some(id),
|
||||
ScriptThreadMessage::GetTitle(id) => Some(id),
|
||||
ScriptThreadMessage::SetDocumentActivity(id, ..) => Some(id),
|
||||
ScriptThreadMessage::SetThrottled(id, ..) => Some(id),
|
||||
ScriptThreadMessage::SetThrottledInContainingIframe(id, ..) => Some(id),
|
||||
ScriptThreadMessage::NavigateIframe(id, ..) => Some(id),
|
||||
ScriptThreadMessage::PostMessage { target: id, .. } => Some(id),
|
||||
ScriptThreadMessage::UpdatePipelineId(_, _, _, id, _) => Some(id),
|
||||
ScriptThreadMessage::UpdateHistoryState(id, ..) => Some(id),
|
||||
ScriptThreadMessage::RemoveHistoryStates(id, ..) => Some(id),
|
||||
ScriptThreadMessage::FocusIFrame(id, ..) => Some(id),
|
||||
ScriptThreadMessage::WebDriverScriptCommand(id, ..) => Some(id),
|
||||
ScriptThreadMessage::TickAllAnimations(id, ..) => Some(id),
|
||||
ScriptThreadMessage::WebFontLoaded(id, ..) => Some(id),
|
||||
ScriptThreadMessage::SendInputEvent(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::Viewport(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::GetTitle(id) => Some(*id),
|
||||
ScriptThreadMessage::SetDocumentActivity(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::SetThrottled(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::SetThrottledInContainingIframe(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::NavigateIframe(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::PostMessage { target: id, .. } => Some(*id),
|
||||
ScriptThreadMessage::UpdatePipelineId(_, _, _, id, _) => Some(*id),
|
||||
ScriptThreadMessage::UpdateHistoryState(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::RemoveHistoryStates(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::FocusIFrame(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::WebDriverScriptCommand(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::TickAllAnimations(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::WebFontLoaded(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::DispatchIFrameLoadEvent {
|
||||
target: _,
|
||||
parent: id,
|
||||
child: _,
|
||||
} => Some(id),
|
||||
ScriptThreadMessage::DispatchStorageEvent(id, ..) => Some(id),
|
||||
ScriptThreadMessage::ReportCSSError(id, ..) => Some(id),
|
||||
ScriptThreadMessage::Reload(id, ..) => Some(id),
|
||||
ScriptThreadMessage::PaintMetric(id, ..) => Some(id),
|
||||
ScriptThreadMessage::ExitFullScreen(id, ..) => Some(id),
|
||||
} => Some(*id),
|
||||
ScriptThreadMessage::DispatchStorageEvent(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::ReportCSSError(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::Reload(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::PaintMetric(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::ExitFullScreen(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::MediaSessionAction(..) => None,
|
||||
#[cfg(feature = "webgpu")]
|
||||
ScriptThreadMessage::SetWebGPUPort(..) => None,
|
||||
ScriptThreadMessage::SetScrollStates(id, ..) => Some(id),
|
||||
ScriptThreadMessage::SetEpochPaintTime(id, ..) => Some(id),
|
||||
ScriptThreadMessage::SetScrollStates(id, ..) => Some(*id),
|
||||
ScriptThreadMessage::SetEpochPaintTime(id, ..) => Some(*id),
|
||||
},
|
||||
MixedMessage::FromScript(ref inner_msg) => match *inner_msg {
|
||||
MixedMessage::FromScript(inner_msg) => match inner_msg {
|
||||
MainThreadScriptMsg::Common(CommonScriptMsg::Task(_, _, pipeline_id, _)) => {
|
||||
pipeline_id
|
||||
*pipeline_id
|
||||
},
|
||||
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(_)) => None,
|
||||
MainThreadScriptMsg::NavigationResponse { pipeline_id, .. } => Some(pipeline_id),
|
||||
MainThreadScriptMsg::WorkletLoaded(pipeline_id) => Some(pipeline_id),
|
||||
MainThreadScriptMsg::RegisterPaintWorklet { pipeline_id, .. } => Some(pipeline_id),
|
||||
MainThreadScriptMsg::NavigationResponse { pipeline_id, .. } => Some(*pipeline_id),
|
||||
MainThreadScriptMsg::WorkletLoaded(pipeline_id) => Some(*pipeline_id),
|
||||
MainThreadScriptMsg::RegisterPaintWorklet { pipeline_id, .. } => Some(*pipeline_id),
|
||||
MainThreadScriptMsg::Inactive => None,
|
||||
MainThreadScriptMsg::WakeUp => None,
|
||||
},
|
||||
|
@ -396,7 +396,7 @@ impl ScriptThreadReceivers {
|
|||
}
|
||||
#[cfg(not(feature = "webgpu"))]
|
||||
{
|
||||
&crossbeam_channel::never::<()>()
|
||||
crossbeam_channel::never::<()>()
|
||||
}
|
||||
}) -> msg => {
|
||||
#[cfg(feature = "webgpu")]
|
||||
|
|
|
@ -97,7 +97,7 @@ impl NavigationListener {
|
|||
}
|
||||
|
||||
pub(crate) fn http_redirect_metadata(message: &FetchResponseMsg) -> Option<&Metadata> {
|
||||
let FetchResponseMsg::ProcessResponse(_, Ok(ref metadata)) = message else {
|
||||
let FetchResponseMsg::ProcessResponse(_, Ok(metadata)) = message else {
|
||||
return None;
|
||||
};
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ impl FetchResponseListener for StylesheetContext {
|
|||
// else we risk applying the wrong stylesheet when responses come out-of-order.
|
||||
let is_stylesheet_load_applicable = self
|
||||
.request_generation_id
|
||||
.is_none_or(|gen| gen == link.get_request_generation_id());
|
||||
.is_none_or(|generation| generation == link.get_request_generation_id());
|
||||
if is_stylesheet_load_applicable {
|
||||
let shared_lock = document.style_shared_lock().clone();
|
||||
let sheet = Arc::new(Stylesheet::from_bytes(
|
||||
|
@ -314,7 +314,7 @@ impl StylesheetLoader<'_> {
|
|||
.elem
|
||||
.containing_shadow_root()
|
||||
.map(|sr| Trusted::new(&*sr));
|
||||
let gen = self
|
||||
let generation = self
|
||||
.elem
|
||||
.downcast::<HTMLLinkElement>()
|
||||
.map(HTMLLinkElement::get_request_generation_id);
|
||||
|
@ -327,7 +327,7 @@ impl StylesheetLoader<'_> {
|
|||
document: Trusted::new(&*document),
|
||||
shadow_root,
|
||||
origin_clean: true,
|
||||
request_generation_id: gen,
|
||||
request_generation_id: generation,
|
||||
resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource),
|
||||
};
|
||||
|
||||
|
|
|
@ -75,7 +75,10 @@ pub(crate) struct TaskCanceller {
|
|||
|
||||
impl TaskCanceller {
|
||||
/// Returns a wrapped `task` that will be cancelled if the `TaskCanceller` says so.
|
||||
pub(crate) fn wrap_task(&self, task: impl TaskOnce) -> impl TaskOnce {
|
||||
pub(crate) fn wrap_task<T>(&self, task: T) -> impl TaskOnce + use<T>
|
||||
where
|
||||
T: TaskOnce,
|
||||
{
|
||||
CancellableTask {
|
||||
canceller: self.clone(),
|
||||
inner: task,
|
||||
|
|
|
@ -85,7 +85,7 @@ unsafe extern "C" fn get_own_property_descriptor(
|
|||
desc: MutableHandle<PropertyDescriptor>,
|
||||
is_none: *mut bool,
|
||||
) -> bool {
|
||||
let cx = SafeJSContext::from_ptr(cx);
|
||||
let cx = unsafe { SafeJSContext::from_ptr(cx) };
|
||||
|
||||
if id.is_symbol() {
|
||||
if id.get().asBits_ == SymbolId(GetWellKnownSymbol(*cx, SymbolCode::toStringTag)).asBits_ {
|
||||
|
@ -95,7 +95,7 @@ unsafe extern "C" fn get_own_property_descriptor(
|
|||
RustMutableHandle::from_raw(desc),
|
||||
rval.handle(),
|
||||
JSPROP_READONLY.into(),
|
||||
&mut *is_none,
|
||||
unsafe { &mut *is_none },
|
||||
);
|
||||
}
|
||||
return true;
|
||||
|
@ -115,7 +115,7 @@ unsafe extern "C" fn get_own_property_descriptor(
|
|||
}
|
||||
|
||||
let s = if id.is_string() {
|
||||
jsstr_to_string(*cx, id.to_string())
|
||||
unsafe { jsstr_to_string(*cx, id.to_string()) }
|
||||
} else if id.is_int() {
|
||||
// If the property key is an integer index, convert it to a String too.
|
||||
// For indexed access on the window object, which may shadow this, see
|
||||
|
@ -131,16 +131,16 @@ unsafe extern "C" fn get_own_property_descriptor(
|
|||
return true;
|
||||
}
|
||||
|
||||
let window = Root::downcast::<Window>(GlobalScope::from_object(proxy.get()))
|
||||
let window = Root::downcast::<Window>(unsafe { GlobalScope::from_object(proxy.get()) })
|
||||
.expect("global is not a window");
|
||||
if let Some(obj) = window.NamedGetter(s.into()) {
|
||||
rooted!(in(*cx) let mut rval = UndefinedValue());
|
||||
obj.to_jsval(*cx, rval.handle_mut());
|
||||
set_property_descriptor(
|
||||
RustMutableHandle::from_raw(desc),
|
||||
unsafe { RustMutableHandle::from_raw(desc) },
|
||||
rval.handle(),
|
||||
0,
|
||||
&mut *is_none,
|
||||
unsafe { &mut *is_none },
|
||||
);
|
||||
}
|
||||
true
|
||||
|
@ -155,8 +155,10 @@ unsafe extern "C" fn own_property_keys(
|
|||
// TODO is this all we need to return? compare with gecko:
|
||||
// https://searchfox.org/mozilla-central/rev/af78418c4b5f2c8721d1a06486cf4cf0b33e1e8d/dom/base/WindowNamedPropertiesHandler.cpp#175-232
|
||||
// see also https://github.com/whatwg/html/issues/9068
|
||||
rooted!(in(cx) let mut rooted = SymbolId(GetWellKnownSymbol(cx, SymbolCode::toStringTag)));
|
||||
AppendToIdVector(props, rooted.handle().into());
|
||||
unsafe {
|
||||
rooted!(in(cx) let mut rooted = SymbolId(GetWellKnownSymbol(cx, SymbolCode::toStringTag)));
|
||||
AppendToIdVector(props, rooted.handle().into());
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -168,7 +170,9 @@ unsafe extern "C" fn define_property(
|
|||
_desc: Handle<PropertyDescriptor>,
|
||||
result: *mut ObjectOpResult,
|
||||
) -> bool {
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_DEFINE_WINDOW_NAMED_PROPERTY as usize;
|
||||
unsafe {
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_DEFINE_WINDOW_NAMED_PROPERTY as usize;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -179,7 +183,9 @@ unsafe extern "C" fn delete(
|
|||
_id: HandleId,
|
||||
result: *mut ObjectOpResult,
|
||||
) -> bool {
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_DELETE_WINDOW_NAMED_PROPERTY as usize;
|
||||
unsafe {
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_DELETE_WINDOW_NAMED_PROPERTY as usize;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -190,8 +196,10 @@ unsafe extern "C" fn get_prototype_if_ordinary(
|
|||
is_ordinary: *mut bool,
|
||||
proto: MutableHandleObject,
|
||||
) -> bool {
|
||||
*is_ordinary = true;
|
||||
proto.set(js::jsapi::GetStaticPrototype(proxy.get()));
|
||||
unsafe {
|
||||
*is_ordinary = true;
|
||||
proto.set(js::jsapi::GetStaticPrototype(proxy.get()));
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -201,7 +209,9 @@ unsafe extern "C" fn prevent_extensions(
|
|||
_proxy: HandleObject,
|
||||
result: *mut ObjectOpResult,
|
||||
) -> bool {
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_PREVENT_EXTENSIONS as usize;
|
||||
unsafe {
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_PREVENT_EXTENSIONS as usize;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -211,7 +221,9 @@ unsafe extern "C" fn is_extensible(
|
|||
_proxy: HandleObject,
|
||||
extensible: *mut bool,
|
||||
) -> bool {
|
||||
*extensible = true;
|
||||
unsafe {
|
||||
*extensible = true;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue