mirror of
https://github.com/servo/servo.git
synced 2025-08-24 06:45:33 +01:00
cargo: Bump rustc to 1.89 (#36818)
Update Rustc to 1.89. Reviewable by commit. Leftover work: - #37330 - #38777 --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Co-authored-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
8587536755
commit
3225d19907
126 changed files with 408 additions and 610 deletions
|
@ -135,7 +135,7 @@ impl Repetition {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn source(pattern: &Pattern) -> raqote::Source {
|
||||
pub fn source(pattern: &Pattern) -> raqote::Source<'_> {
|
||||
match pattern {
|
||||
Pattern::Color(a, r, g, b) => raqote::Source::Solid(
|
||||
raqote::SolidSource::from_unpremultiplied_argb(*a, *r, *g, *b),
|
||||
|
|
|
@ -1376,7 +1376,7 @@ impl IOCompositor {
|
|||
}
|
||||
|
||||
/// Get the message receiver for this [`IOCompositor`].
|
||||
pub fn receiver(&self) -> Ref<Receiver<CompositorMsg>> {
|
||||
pub fn receiver(&self) -> Ref<'_, Receiver<CompositorMsg>> {
|
||||
Ref::map(self.global.borrow(), |global| &global.compositor_receiver)
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ impl WebViewRenderer {
|
|||
|
||||
pub(crate) fn set_frame_tree(&mut self, frame_tree: &SendableFrameTree) {
|
||||
let pipeline_id = frame_tree.pipeline.id;
|
||||
let old_pipeline_id = std::mem::replace(&mut self.root_pipeline_id, Some(pipeline_id));
|
||||
let old_pipeline_id = self.root_pipeline_id.replace(pipeline_id);
|
||||
|
||||
if old_pipeline_id != self.root_pipeline_id {
|
||||
debug!(
|
||||
|
|
|
@ -1019,7 +1019,7 @@ where
|
|||
fn fully_active_descendant_browsing_contexts_iter(
|
||||
&self,
|
||||
browsing_context_id: BrowsingContextId,
|
||||
) -> FullyActiveBrowsingContextsIterator {
|
||||
) -> FullyActiveBrowsingContextsIterator<'_> {
|
||||
FullyActiveBrowsingContextsIterator {
|
||||
stack: vec![browsing_context_id],
|
||||
pipelines: &self.pipelines,
|
||||
|
@ -1031,7 +1031,7 @@ where
|
|||
fn fully_active_browsing_contexts_iter(
|
||||
&self,
|
||||
webview_id: WebViewId,
|
||||
) -> FullyActiveBrowsingContextsIterator {
|
||||
) -> FullyActiveBrowsingContextsIterator<'_> {
|
||||
self.fully_active_descendant_browsing_contexts_iter(BrowsingContextId::from(webview_id))
|
||||
}
|
||||
|
||||
|
@ -1039,7 +1039,7 @@ where
|
|||
fn all_descendant_browsing_contexts_iter(
|
||||
&self,
|
||||
browsing_context_id: BrowsingContextId,
|
||||
) -> AllBrowsingContextsIterator {
|
||||
) -> AllBrowsingContextsIterator<'_> {
|
||||
AllBrowsingContextsIterator {
|
||||
stack: vec![browsing_context_id],
|
||||
pipelines: &self.pipelines,
|
||||
|
@ -1157,6 +1157,7 @@ where
|
|||
/// Handles loading pages, navigation, and granting access to the compositor
|
||||
#[servo_tracing::instrument(skip_all)]
|
||||
fn handle_request(&mut self) {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug)]
|
||||
enum Request {
|
||||
PipelineNamespace(PipelineNamespaceRequest),
|
||||
|
@ -3174,7 +3175,8 @@ where
|
|||
);
|
||||
},
|
||||
};
|
||||
let is_parent_private = match self.browsing_contexts.get(&parent_browsing_context_id) {
|
||||
|
||||
match self.browsing_contexts.get(&parent_browsing_context_id) {
|
||||
Some(ctx) => ctx.is_private,
|
||||
None => {
|
||||
return warn!(
|
||||
|
@ -3182,8 +3184,7 @@ where
|
|||
parent_browsing_context_id, browsing_context_id,
|
||||
);
|
||||
},
|
||||
};
|
||||
is_parent_private
|
||||
}
|
||||
};
|
||||
let is_private = is_private || is_parent_private;
|
||||
|
||||
|
|
|
@ -175,42 +175,41 @@ impl PageStyleActor {
|
|||
|
||||
// For each selector (plus an empty one that represents the style attribute)
|
||||
// get all of the rules associated with it.
|
||||
let entries =
|
||||
once(("".into(), usize::MAX))
|
||||
.chain(selectors)
|
||||
.filter_map(move |selector| {
|
||||
let rule = match node_actor.style_rules.borrow_mut().entry(selector) {
|
||||
Entry::Vacant(e) => {
|
||||
let name = registry.new_name("style-rule");
|
||||
let actor = StyleRuleActor::new(
|
||||
name.clone(),
|
||||
node_actor.name(),
|
||||
(!e.key().0.is_empty()).then_some(e.key().clone()),
|
||||
);
|
||||
let rule = actor.applied(registry)?;
|
||||
|
||||
registry.register_later(Box::new(actor));
|
||||
e.insert(name);
|
||||
rule
|
||||
},
|
||||
Entry::Occupied(e) => {
|
||||
let actor = registry.find::<StyleRuleActor>(e.get());
|
||||
actor.applied(registry)?
|
||||
},
|
||||
};
|
||||
if inherited.is_some() && rule.declarations.is_empty() {
|
||||
return None;
|
||||
}
|
||||
once(("".into(), usize::MAX))
|
||||
.chain(selectors)
|
||||
.filter_map(move |selector| {
|
||||
let rule = match node_actor.style_rules.borrow_mut().entry(selector) {
|
||||
Entry::Vacant(e) => {
|
||||
let name = registry.new_name("style-rule");
|
||||
let actor = StyleRuleActor::new(
|
||||
name.clone(),
|
||||
node_actor.name(),
|
||||
(!e.key().0.is_empty()).then_some(e.key().clone()),
|
||||
);
|
||||
let rule = actor.applied(registry)?;
|
||||
|
||||
Some(AppliedEntry {
|
||||
rule,
|
||||
// TODO: Handle pseudo elements
|
||||
pseudo_element: None,
|
||||
is_system: false,
|
||||
inherited: inherited.clone(),
|
||||
})
|
||||
});
|
||||
entries
|
||||
registry.register_later(Box::new(actor));
|
||||
e.insert(name);
|
||||
rule
|
||||
},
|
||||
Entry::Occupied(e) => {
|
||||
let actor = registry.find::<StyleRuleActor>(e.get());
|
||||
actor.applied(registry)?
|
||||
},
|
||||
};
|
||||
if inherited.is_some() && rule.declarations.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(AppliedEntry {
|
||||
rule,
|
||||
// TODO: Handle pseudo elements
|
||||
pseudo_element: None,
|
||||
is_system: false,
|
||||
inherited: inherited.clone(),
|
||||
})
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let msg = GetAppliedReply {
|
||||
|
|
|
@ -320,7 +320,7 @@ impl FontContext {
|
|||
font_key
|
||||
});
|
||||
|
||||
let key = *self
|
||||
*self
|
||||
.webrender_font_instance_keys
|
||||
.write()
|
||||
.entry((font_key, pt_size, variations.clone()))
|
||||
|
@ -334,8 +334,7 @@ impl FontContext {
|
|||
variations,
|
||||
);
|
||||
font_instance_key
|
||||
});
|
||||
key
|
||||
})
|
||||
}
|
||||
|
||||
fn invalidate_font_groups_after_web_font_load(&self) {
|
||||
|
|
|
@ -606,7 +606,7 @@ impl GlyphStore {
|
|||
pub fn iter_glyphs_for_byte_range(
|
||||
&self,
|
||||
range: &Range<ByteIndex>,
|
||||
) -> impl Iterator<Item = GlyphInfo> + use<'_> {
|
||||
) -> impl Iterator<Item = GlyphInfo<'_>> + use<'_> {
|
||||
if range.begin() >= self.len() {
|
||||
panic!("iter_glyphs_for_range: range.begin beyond length!");
|
||||
}
|
||||
|
|
|
@ -431,6 +431,10 @@ impl Serialize for Ser<'_, HeaderMap> {
|
|||
{
|
||||
let mut serializer = serializer.serialize_seq(Some(self.0.len()))?;
|
||||
for v in self.0 {
|
||||
#[allow(
|
||||
clippy::collapsible_if,
|
||||
reason = "let chains are not available in 1.85"
|
||||
)]
|
||||
if self.1 {
|
||||
if let Ok(v) = str::from_utf8(v) {
|
||||
serializer.serialize_element(v)?;
|
||||
|
|
|
@ -1001,7 +1001,7 @@ impl FlexContainer {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle {
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle<'_> {
|
||||
LayoutStyle::Default(&self.style)
|
||||
}
|
||||
}
|
||||
|
@ -2046,7 +2046,7 @@ impl FlexItemBox {
|
|||
content_box_sizes_and_pbm: &ContentBoxSizesAndPBM,
|
||||
config: &FlexContainerConfig,
|
||||
flex_context_getter: &impl Fn() -> &'a FlexContext<'a>,
|
||||
) -> FlexItem {
|
||||
) -> FlexItem<'_> {
|
||||
let flex_axis = config.flex_axis;
|
||||
let style = self.style();
|
||||
let cross_axis_is_item_block_axis = cross_axis_is_item_block_axis(
|
||||
|
|
|
@ -151,6 +151,7 @@ impl FlexContainer {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub(crate) enum FlexLevelBox {
|
||||
FlexItem(FlexItemBox),
|
||||
|
|
|
@ -66,7 +66,7 @@ impl InlineBox {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle {
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle<'_> {
|
||||
LayoutStyle::Default(&self.base.style)
|
||||
}
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ impl IndependentFormattingContext {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle {
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle<'_> {
|
||||
match &self.contents {
|
||||
IndependentFormattingContextContents::Replaced(fc) => fc.layout_style(&self.base),
|
||||
IndependentFormattingContextContents::Flow(fc) => fc.layout_style(&self.base),
|
||||
|
|
|
@ -997,9 +997,11 @@ impl LayoutThread {
|
|||
}
|
||||
|
||||
let root_node = root_element.as_node();
|
||||
let damage_from_environment = viewport_changed
|
||||
.then_some(RestyleDamage::RELAYOUT)
|
||||
.unwrap_or_default();
|
||||
let damage_from_environment = if viewport_changed {
|
||||
RestyleDamage::RELAYOUT
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
let damage = compute_damage_and_repair_style(
|
||||
&layout_context.style_context,
|
||||
root_node.to_threadsafe(),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::iter::repeat;
|
||||
use std::iter::repeat_n;
|
||||
|
||||
use atomic_refcell::AtomicRef;
|
||||
use layout_api::wrapper_traits::ThreadSafeLayoutNode;
|
||||
|
@ -1165,6 +1165,6 @@ fn add_column(
|
|||
shared_background_style: SharedStyle::new(column_info.style.clone()),
|
||||
})
|
||||
});
|
||||
collection.extend(repeat(column.clone()).take(span as usize));
|
||||
collection.extend(repeat_n(column.clone(), span as usize));
|
||||
column
|
||||
}
|
||||
|
|
|
@ -2754,21 +2754,21 @@ impl Table {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn layout_style_for_grid(&self) -> LayoutStyle {
|
||||
pub(crate) fn layout_style_for_grid(&self) -> LayoutStyle<'_> {
|
||||
LayoutStyle::Default(&self.grid_style)
|
||||
}
|
||||
}
|
||||
|
||||
impl TableTrack {
|
||||
#[inline]
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle {
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle<'_> {
|
||||
LayoutStyle::Default(&self.base.style)
|
||||
}
|
||||
}
|
||||
|
||||
impl TableTrackGroup {
|
||||
#[inline]
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle {
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle<'_> {
|
||||
LayoutStyle::Default(&self.base.style)
|
||||
}
|
||||
}
|
||||
|
@ -2806,7 +2806,7 @@ impl TableLayoutStyle<'_> {
|
|||
|
||||
impl TableSlotCell {
|
||||
#[inline]
|
||||
fn layout_style(&self) -> LayoutStyle {
|
||||
fn layout_style(&self) -> LayoutStyle<'_> {
|
||||
self.contents.layout_style(&self.base)
|
||||
}
|
||||
|
||||
|
|
|
@ -576,7 +576,7 @@ impl TaffyContainer {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle {
|
||||
pub(crate) fn layout_style(&self) -> LayoutStyle<'_> {
|
||||
LayoutStyle::Default(&self.style)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ pub(crate) struct TaffyItemBox {
|
|||
pub(crate) taffy_level_box: TaffyItemBoxInner,
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, MallocSizeOf)]
|
||||
pub(crate) enum TaffyItemBoxInner {
|
||||
InFlowBox(IndependentFormattingContext),
|
||||
|
|
|
@ -88,7 +88,7 @@ where
|
|||
node.layout_data().is_none() || !parent_data.damage.is_empty()
|
||||
}
|
||||
|
||||
fn shared_context(&self) -> &SharedStyleContext {
|
||||
fn shared_context(&self) -> &SharedStyleContext<'_> {
|
||||
&self.context.style_context
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ impl GLPlayerExternalImages {
|
|||
}
|
||||
|
||||
impl WebrenderExternalImageApi for GLPlayerExternalImages {
|
||||
fn lock(&mut self, id: u64) -> (ExternalImageSource, Size2D<i32>) {
|
||||
fn lock(&mut self, id: u64) -> (ExternalImageSource<'_>, Size2D<i32>) {
|
||||
// The GLPlayerMsgForward::Lock message inserts a fence in the
|
||||
// GLPlayer command queue.
|
||||
self.glplayer_channel
|
||||
|
|
|
@ -285,7 +285,7 @@ impl Stream for BodyStream {
|
|||
return Poll::Ready(None);
|
||||
}
|
||||
}
|
||||
Poll::Ready(Some(Err(io::Error::new(io::ErrorKind::Other, err))))
|
||||
Poll::Ready(Some(Err(io::Error::other(err))))
|
||||
},
|
||||
None => Poll::Ready(None),
|
||||
}
|
||||
|
|
|
@ -832,7 +832,7 @@ fn create_about_memory(url: ServoUrl, timing_type: ResourceTimingType) -> Respon
|
|||
|
||||
/// Handle a request from the user interface to ignore validation errors for a certificate.
|
||||
fn handle_allowcert_request(request: &mut Request, context: &FetchContext) -> io::Result<()> {
|
||||
let error = |string| Err(io::Error::new(io::ErrorKind::Other, string));
|
||||
let error = |string| Err(io::Error::other(string));
|
||||
|
||||
let body = match request.body.as_mut() {
|
||||
Some(body) => body,
|
||||
|
|
|
@ -49,7 +49,7 @@ pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn replace_host(host: &str) -> Cow<str> {
|
||||
pub fn replace_host(host: &str) -> Cow<'_, str> {
|
||||
HOST_TABLE
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
|
|
@ -2017,7 +2017,7 @@ async fn http_network_fetch(
|
|||
.iter()
|
||||
.map(|header_value| header_value.to_str().unwrap_or(""))
|
||||
.collect();
|
||||
let wildcard_present = header_strings.iter().any(|header_str| *header_str == "*");
|
||||
let wildcard_present = header_strings.contains(&"*");
|
||||
// The spec: https://www.w3.org/TR/resource-timing-2/#sec-timing-allow-origin
|
||||
// says that a header string is either an origin or a wildcard so we can just do a straight
|
||||
// check against the document origin
|
||||
|
|
|
@ -12,6 +12,7 @@ pub enum Column {
|
|||
Version,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct Model {
|
||||
pub name: String,
|
||||
|
|
|
@ -14,6 +14,7 @@ pub enum Column {
|
|||
MultiEntryIndex,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct Model {
|
||||
pub id: i32,
|
||||
|
|
|
@ -48,6 +48,8 @@ use crate::fetch::methods::{
|
|||
};
|
||||
use crate::hosts::replace_host;
|
||||
use crate::http_loader::HttpState;
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
/// Create a tungstenite Request object for the initial HTTP request.
|
||||
/// This request contains `Origin`, `Sec-WebSocket-Protocol`, `Authorization`,
|
||||
/// and `Cookie` headers as appropriate.
|
||||
|
@ -105,6 +107,7 @@ fn create_request(
|
|||
Ok(request)
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
/// Process an HTTP response resulting from a WS handshake.
|
||||
/// This ensures that any `Cookie` or HSTS headers are recognized.
|
||||
/// Returns an error if the protocol selected by the handshake doesn't
|
||||
|
|
|
@ -149,7 +149,7 @@ pub fn flip_y_rgba8_image_inplace(size: Size2D<u32>, pixels: &mut [u8]) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<[u8]> {
|
||||
pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<'_, [u8]> {
|
||||
assert!(!rect.is_empty());
|
||||
assert!(Rect::from_size(size).contains_rect(&rect));
|
||||
assert_eq!(pixels.len() % 4, 0);
|
||||
|
@ -311,7 +311,7 @@ impl RasterImage {
|
|||
self.frames.len() > 1
|
||||
}
|
||||
|
||||
pub fn frames(&self) -> impl Iterator<Item = ImageFrameView> {
|
||||
pub fn frames(&self) -> impl Iterator<Item = ImageFrameView<'_>> {
|
||||
self.frames.iter().map(|frame| ImageFrameView {
|
||||
delay: frame.delay,
|
||||
bytes: self.bytes.get(frame.byte_range.clone()).unwrap(),
|
||||
|
@ -320,7 +320,7 @@ impl RasterImage {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn first_frame(&self) -> ImageFrameView {
|
||||
pub fn first_frame(&self) -> ImageFrameView<'_> {
|
||||
self.frames()
|
||||
.next()
|
||||
.expect("All images should have at least one frame")
|
||||
|
|
|
@ -45,7 +45,7 @@ impl AbstractRange {
|
|||
end_offset: u32,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<AbstractRange> {
|
||||
let abstractrange = reflect_dom_object(
|
||||
reflect_dom_object(
|
||||
Box::new(AbstractRange::new_inherited(
|
||||
start_container,
|
||||
start_offset,
|
||||
|
@ -54,8 +54,7 @@ impl AbstractRange {
|
|||
)),
|
||||
document.window(),
|
||||
can_gc,
|
||||
);
|
||||
abstractrange
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn start(&self) -> &BoundaryPoint {
|
||||
|
|
|
@ -21,7 +21,10 @@ pub(crate) trait WorkerEventLoopMethods {
|
|||
type Event;
|
||||
fn task_queue(&self) -> &TaskQueue<Self::WorkerMsg>;
|
||||
fn handle_event(&self, event: Self::Event, can_gc: CanGc) -> bool;
|
||||
fn handle_worker_post_event(&self, worker: &TrustedWorkerAddress) -> Option<AutoWorkerReset>;
|
||||
fn handle_worker_post_event(
|
||||
&self,
|
||||
worker: &TrustedWorkerAddress,
|
||||
) -> Option<AutoWorkerReset<'_>>;
|
||||
fn from_control_msg(msg: Self::ControlMsg) -> Self::Event;
|
||||
fn from_worker_msg(msg: Self::WorkerMsg) -> Self::Event;
|
||||
fn from_devtools_msg(msg: DevtoolScriptControlMsg) -> Self::Event;
|
||||
|
|
|
@ -198,7 +198,7 @@ impl Attr {
|
|||
&self.identifier
|
||||
}
|
||||
|
||||
pub(crate) fn value(&self) -> Ref<AttrValue> {
|
||||
pub(crate) fn value(&self) -> Ref<'_, AttrValue> {
|
||||
self.value.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ impl AudioBuffer {
|
|||
Some(result)
|
||||
}
|
||||
|
||||
pub(crate) fn get_channels(&self) -> Ref<Option<ServoMediaAudioBuffer>> {
|
||||
pub(crate) fn get_channels(&self) -> Ref<'_, Option<ServoMediaAudioBuffer>> {
|
||||
if self.shared_channels.borrow().is_none() {
|
||||
let channels = self.acquire_contents();
|
||||
if channels.is_some() {
|
||||
|
|
|
@ -531,7 +531,7 @@ impl BaseAudioContextMethods<crate::DomTypeHolder> for BaseAudioContext {
|
|||
task_source.queue(task!(audio_decode_eos: move || {
|
||||
let this = this.root();
|
||||
let decoded_audio = decoded_audio__.lock().unwrap();
|
||||
let length = if decoded_audio.len() >= 1 {
|
||||
let length = if !decoded_audio.is_empty() {
|
||||
decoded_audio[0].len()
|
||||
} else {
|
||||
0
|
||||
|
|
|
@ -887,7 +887,7 @@ impl DataBlock {
|
|||
*cx,
|
||||
range.end - range.start,
|
||||
// SAFETY: This is safe because we have checked there is no overlapping view
|
||||
(*raw)[range.clone()].as_mut_ptr() as _,
|
||||
(&mut (*raw))[range.clone()].as_mut_ptr() as _,
|
||||
Some(free_func),
|
||||
raw as _,
|
||||
)
|
||||
|
|
|
@ -111,7 +111,7 @@ impl<T> DomRefCell<T> {
|
|||
///
|
||||
/// Panics if the value is currently mutably borrowed.
|
||||
#[track_caller]
|
||||
pub(crate) fn borrow(&self) -> Ref<T> {
|
||||
pub(crate) fn borrow(&self) -> Ref<'_, T> {
|
||||
self.value.borrow()
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ impl<T> DomRefCell<T> {
|
|||
///
|
||||
/// Panics if the value is currently borrowed.
|
||||
#[track_caller]
|
||||
pub(crate) fn borrow_mut(&self) -> RefMut<T> {
|
||||
pub(crate) fn borrow_mut(&self) -> RefMut<'_, T> {
|
||||
self.value.borrow_mut()
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ impl<T> DomRefCell<T> {
|
|||
/// # Panics
|
||||
///
|
||||
/// Panics if this is called off the script thread.
|
||||
pub(crate) fn try_borrow(&self) -> Result<Ref<T>, BorrowError> {
|
||||
pub(crate) fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError> {
|
||||
assert_in_script();
|
||||
self.value.try_borrow()
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ impl<T> DomRefCell<T> {
|
|||
/// # Panics
|
||||
///
|
||||
/// Panics if this is called off the script thread.
|
||||
pub(crate) fn try_borrow_mut(&self) -> Result<RefMut<T>, BorrowMutError> {
|
||||
pub(crate) fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError> {
|
||||
assert_in_script();
|
||||
self.value.try_borrow_mut()
|
||||
}
|
||||
|
|
|
@ -114,8 +114,7 @@ impl TrustedPromise {
|
|||
self.owner_thread,
|
||||
live_references as *const _ as *const libc::c_void
|
||||
);
|
||||
// Borrow-check error requires the redundant `let promise = ...; promise` here.
|
||||
let promise = match live_references
|
||||
match live_references
|
||||
.promise_table
|
||||
.borrow_mut()
|
||||
.entry(self.dom_object)
|
||||
|
@ -133,8 +132,7 @@ impl TrustedPromise {
|
|||
promise
|
||||
},
|
||||
Vacant(_) => unreachable!(),
|
||||
};
|
||||
promise
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -64,11 +64,11 @@ pub(crate) trait ToLayout<T> {
|
|||
/// # Safety
|
||||
///
|
||||
/// The `self` parameter to this method must meet all the requirements of [`ptr::NonNull::as_ref`].
|
||||
unsafe fn to_layout(&self) -> LayoutDom<T>;
|
||||
unsafe fn to_layout(&self) -> LayoutDom<'_, T>;
|
||||
}
|
||||
|
||||
impl<T: DomObject> ToLayout<T> for Dom<T> {
|
||||
unsafe fn to_layout(&self) -> LayoutDom<T> {
|
||||
unsafe fn to_layout(&self) -> LayoutDom<'_, T> {
|
||||
assert_in_layout();
|
||||
LayoutDom {
|
||||
value: unsafe { self.as_ptr().as_ref().unwrap() },
|
||||
|
@ -266,7 +266,7 @@ impl<T: DomObject> MutNullableDom<T> {
|
|||
/// Retrieve a copy of the inner optional `Dom<T>` as `LayoutDom<T>`.
|
||||
/// For use by layout, which can't use safe types like Temporary.
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> {
|
||||
pub(crate) unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<'_, T>> {
|
||||
assert_in_layout();
|
||||
unsafe { (*self.ptr.get()).as_ref().map(|js| js.to_layout()) }
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ impl BluetoothExtraPermissionData {
|
|||
self.allowed_devices.borrow_mut().push(allowed_device);
|
||||
}
|
||||
|
||||
fn get_allowed_devices(&self) -> Ref<Vec<AllowedBluetoothDevice>> {
|
||||
fn get_allowed_devices(&self) -> Ref<'_, Vec<AllowedBluetoothDevice>> {
|
||||
self.allowed_devices.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ impl CharacterData {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn data(&self) -> Ref<DOMString> {
|
||||
pub(crate) fn data(&self) -> Ref<'_, DOMString> {
|
||||
self.data.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ impl CSSStyleOwner {
|
|||
let document = el.owner_document();
|
||||
let shared_lock = document.style_shared_lock();
|
||||
let mut attr = el.style_attribute().borrow_mut().take();
|
||||
let result = if attr.is_some() {
|
||||
let lock = attr.as_ref().unwrap();
|
||||
let result = if let Some(lock) = attr.as_ref() {
|
||||
let mut guard = shared_lock.write();
|
||||
let pdb = lock.write_with(&mut guard);
|
||||
f(pdb, &mut changed)
|
||||
|
|
|
@ -591,16 +591,13 @@ impl CustomElementRegistryMethods<crate::DomTypeHolder> for CustomElementRegistr
|
|||
return promise;
|
||||
}
|
||||
|
||||
// Steps 3, 4, 5
|
||||
// Steps 3, 4, 5, 6
|
||||
let existing_promise = self.when_defined.borrow().get(&name).cloned();
|
||||
let promise = existing_promise.unwrap_or_else(|| {
|
||||
existing_promise.unwrap_or_else(|| {
|
||||
let promise = Promise::new_in_current_realm(comp, can_gc);
|
||||
self.when_defined.borrow_mut().insert(name, promise.clone());
|
||||
promise
|
||||
});
|
||||
|
||||
// Step 6
|
||||
promise
|
||||
})
|
||||
}
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-upgrade>
|
||||
fn Upgrade(&self, node: &Node) {
|
||||
|
|
|
@ -85,7 +85,7 @@ impl DataTransfer {
|
|||
Self::new_with_proto(window, None, can_gc, data_store)
|
||||
}
|
||||
|
||||
pub(crate) fn data_store(&self) -> Option<Ref<DragDataStore>> {
|
||||
pub(crate) fn data_store(&self) -> Option<Ref<'_, DragDataStore>> {
|
||||
Ref::filter_map(self.data_store.borrow(), |data_store| data_store.as_ref()).ok()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ impl DataTransferItem {
|
|||
)
|
||||
}
|
||||
|
||||
fn item_kind(&self) -> Option<Ref<Kind>> {
|
||||
fn item_kind(&self) -> Option<Ref<'_, Kind>> {
|
||||
Ref::filter_map(self.data_store.borrow(), |data_store| {
|
||||
data_store
|
||||
.as_ref()
|
||||
|
|
|
@ -232,7 +232,10 @@ impl WorkerEventLoopMethods for DedicatedWorkerGlobalScope {
|
|||
self.handle_mixed_message(event, can_gc)
|
||||
}
|
||||
|
||||
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());
|
||||
Some(ar)
|
||||
}
|
||||
|
|
|
@ -662,12 +662,12 @@ impl Document {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn loader(&self) -> Ref<DocumentLoader> {
|
||||
pub(crate) fn loader(&self) -> Ref<'_, DocumentLoader> {
|
||||
self.loader.borrow()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn loader_mut(&self) -> RefMut<DocumentLoader> {
|
||||
pub(crate) fn loader_mut(&self) -> RefMut<'_, DocumentLoader> {
|
||||
self.loader.borrow_mut()
|
||||
}
|
||||
|
||||
|
@ -1755,7 +1755,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn policy_container(&self) -> Ref<PolicyContainer> {
|
||||
pub(crate) fn policy_container(&self) -> Ref<'_, PolicyContainer> {
|
||||
self.policy_container.borrow()
|
||||
}
|
||||
|
||||
|
@ -2385,14 +2385,14 @@ impl Document {
|
|||
|
||||
/// A reference to the [`IFrameCollection`] of this [`Document`], holding information about
|
||||
/// `<iframe>`s found within it.
|
||||
pub(crate) fn iframes(&self) -> Ref<IFrameCollection> {
|
||||
pub(crate) fn iframes(&self) -> Ref<'_, IFrameCollection> {
|
||||
self.iframes.borrow_mut().validate(self);
|
||||
self.iframes.borrow()
|
||||
}
|
||||
|
||||
/// A mutable reference to the [`IFrameCollection`] of this [`Document`], holding information about
|
||||
/// `<iframe>`s found within it.
|
||||
pub(crate) fn iframes_mut(&self) -> RefMut<IFrameCollection> {
|
||||
pub(crate) fn iframes_mut(&self) -> RefMut<'_, IFrameCollection> {
|
||||
self.iframes.borrow_mut().validate(self);
|
||||
self.iframes.borrow_mut()
|
||||
}
|
||||
|
@ -2411,7 +2411,7 @@ impl Document {
|
|||
.set_navigation_start(navigation_start);
|
||||
}
|
||||
|
||||
pub(crate) fn get_interactive_metrics(&self) -> Ref<ProgressiveWebMetrics> {
|
||||
pub(crate) fn get_interactive_metrics(&self) -> Ref<'_, ProgressiveWebMetrics> {
|
||||
self.interactive_time.borrow()
|
||||
}
|
||||
|
||||
|
@ -2704,11 +2704,11 @@ impl Document {
|
|||
fonts.fulfill_ready_promise_if_needed(can_gc)
|
||||
}
|
||||
|
||||
pub(crate) fn id_map(&self) -> Ref<HashMapTracedValues<Atom, Vec<Dom<Element>>>> {
|
||||
pub(crate) fn id_map(&self) -> Ref<'_, HashMapTracedValues<Atom, Vec<Dom<Element>>>> {
|
||||
self.id_map.borrow()
|
||||
}
|
||||
|
||||
pub(crate) fn name_map(&self) -> Ref<HashMapTracedValues<Atom, Vec<Dom<Element>>>> {
|
||||
pub(crate) fn name_map(&self) -> Ref<'_, HashMapTracedValues<Atom, Vec<Dom<Element>>>> {
|
||||
self.name_map.borrow()
|
||||
}
|
||||
|
||||
|
@ -3676,7 +3676,7 @@ impl Document {
|
|||
.map(|elements| DomRoot::from_ref(&*elements[0]))
|
||||
}
|
||||
|
||||
pub(crate) fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> {
|
||||
pub(crate) fn ensure_pending_restyle(&self, el: &Element) -> RefMut<'_, PendingRestyle> {
|
||||
let map = self.pending_restyles.borrow_mut();
|
||||
RefMut::map(map, |m| {
|
||||
&mut m
|
||||
|
@ -4068,13 +4068,13 @@ impl Document {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn get_elements_with_id(&self, id: &Atom) -> Ref<[Dom<Element>]> {
|
||||
pub(crate) fn get_elements_with_id(&self, id: &Atom) -> Ref<'_, [Dom<Element>]> {
|
||||
Ref::map(self.id_map.borrow(), |map| {
|
||||
map.get(id).map(|vec| &**vec).unwrap_or_default()
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_elements_with_name(&self, name: &Atom) -> Ref<[Dom<Element>]> {
|
||||
pub(crate) fn get_elements_with_name(&self, name: &Atom) -> Ref<'_, [Dom<Element>]> {
|
||||
Ref::map(self.name_map.borrow(), |map| {
|
||||
map.get(name).map(|vec| &**vec).unwrap_or_default()
|
||||
})
|
||||
|
@ -4115,7 +4115,7 @@ impl Document {
|
|||
self.animation_timeline.borrow().current_value()
|
||||
}
|
||||
|
||||
pub(crate) fn animations(&self) -> Ref<Animations> {
|
||||
pub(crate) fn animations(&self) -> Ref<'_, Animations> {
|
||||
self.animations.borrow()
|
||||
}
|
||||
|
||||
|
@ -4159,7 +4159,7 @@ impl Document {
|
|||
self.animations().send_pending_events(self.window(), can_gc);
|
||||
}
|
||||
|
||||
pub(crate) fn image_animation_manager(&self) -> Ref<ImageAnimationManager> {
|
||||
pub(crate) fn image_animation_manager(&self) -> Ref<'_, ImageAnimationManager> {
|
||||
self.image_animation_manager.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ impl DOMMatrixReadOnly {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn matrix(&self) -> Ref<Transform3D<f64>> {
|
||||
pub(crate) fn matrix(&self) -> Ref<'_, Transform3D<f64>> {
|
||||
self.matrix.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -89,10 +89,7 @@ impl DOMTokenList {
|
|||
)),
|
||||
Some(supported_tokens) => {
|
||||
let token = Atom::from(token).to_ascii_lowercase();
|
||||
if supported_tokens
|
||||
.iter()
|
||||
.any(|supported_token| *supported_token == token)
|
||||
{
|
||||
if supported_tokens.contains(&token) {
|
||||
return Ok(true);
|
||||
}
|
||||
Ok(false)
|
||||
|
@ -123,12 +120,8 @@ impl DOMTokenListMethods<crate::DomTypeHolder> for DOMTokenList {
|
|||
/// <https://dom.spec.whatwg.org/#dom-domtokenlist-contains>
|
||||
fn Contains(&self, token: DOMString) -> bool {
|
||||
let token = Atom::from(token);
|
||||
self.attribute().is_some_and(|attr| {
|
||||
attr.value()
|
||||
.as_tokens()
|
||||
.iter()
|
||||
.any(|atom: &Atom| *atom == token)
|
||||
})
|
||||
self.attribute()
|
||||
.is_some_and(|attr| attr.value().as_tokens().contains(&token))
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-domtokenlist-add>
|
||||
|
@ -136,7 +129,7 @@ impl DOMTokenListMethods<crate::DomTypeHolder> for DOMTokenList {
|
|||
let mut atoms = self.element.get_tokenlist_attribute(&self.local_name);
|
||||
for token in &tokens {
|
||||
let token = self.check_token_exceptions(token)?;
|
||||
if !atoms.iter().any(|atom| *atom == token) {
|
||||
if !atoms.contains(&token) {
|
||||
atoms.push(token);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -355,15 +355,15 @@ impl Element {
|
|||
)
|
||||
}
|
||||
|
||||
fn rare_data(&self) -> Ref<Option<Box<ElementRareData>>> {
|
||||
fn rare_data(&self) -> Ref<'_, Option<Box<ElementRareData>>> {
|
||||
self.rare_data.borrow()
|
||||
}
|
||||
|
||||
fn rare_data_mut(&self) -> RefMut<Option<Box<ElementRareData>>> {
|
||||
fn rare_data_mut(&self) -> RefMut<'_, Option<Box<ElementRareData>>> {
|
||||
self.rare_data.borrow_mut()
|
||||
}
|
||||
|
||||
fn ensure_rare_data(&self) -> RefMut<Box<ElementRareData>> {
|
||||
fn ensure_rare_data(&self) -> RefMut<'_, Box<ElementRareData>> {
|
||||
let mut rare_data = self.rare_data.borrow_mut();
|
||||
if rare_data.is_none() {
|
||||
*rare_data = Some(Default::default());
|
||||
|
@ -792,7 +792,7 @@ impl Element {
|
|||
/// Lazily initialize the raredata if it does not exist.
|
||||
pub(crate) fn registered_intersection_observers_mut(
|
||||
&self,
|
||||
) -> RefMut<Vec<IntersectionObserverRegistration>> {
|
||||
) -> RefMut<'_, Vec<IntersectionObserverRegistration>> {
|
||||
RefMut::map(self.ensure_rare_data(), |rare_data| {
|
||||
&mut rare_data.registered_intersection_observers
|
||||
})
|
||||
|
@ -800,8 +800,8 @@ impl Element {
|
|||
|
||||
pub(crate) fn registered_intersection_observers(
|
||||
&self,
|
||||
) -> Option<Ref<Vec<IntersectionObserverRegistration>>> {
|
||||
let rare_data: Ref<_> = self.rare_data.borrow();
|
||||
) -> Option<Ref<'_, Vec<IntersectionObserverRegistration>>> {
|
||||
let rare_data: Ref<'_, _> = self.rare_data.borrow();
|
||||
|
||||
if rare_data.is_none() {
|
||||
return None;
|
||||
|
@ -817,7 +817,7 @@ impl Element {
|
|||
pub(crate) fn get_intersection_observer_registration(
|
||||
&self,
|
||||
observer: &IntersectionObserver,
|
||||
) -> Option<Ref<IntersectionObserverRegistration>> {
|
||||
) -> Option<Ref<'_, IntersectionObserverRegistration>> {
|
||||
if let Some(registrations) = self.registered_intersection_observers() {
|
||||
registrations
|
||||
.iter()
|
||||
|
@ -868,8 +868,7 @@ impl Element {
|
|||
let mut parser_input = CssParserInput::new(media_query);
|
||||
let mut parser = CssParser::new(&mut parser_input);
|
||||
let media_list = MediaList::parse(&context, &mut parser);
|
||||
let result = media_list.evaluate(document.window().layout().device(), quirks_mode);
|
||||
result
|
||||
media_list.evaluate(document.window().layout().device(), quirks_mode)
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/cssom-view/#scroll-a-target-into-view>
|
||||
|
@ -992,7 +991,7 @@ impl Element {
|
|||
if let Some(style) = element.style() {
|
||||
let overflow_x = style.get_box().clone_overflow_x();
|
||||
let overflow_y = style.get_box().clone_overflow_y();
|
||||
return overflow_x.is_scrollable() || overflow_y.is_scrollable();
|
||||
overflow_x.is_scrollable() || overflow_y.is_scrollable()
|
||||
} else {
|
||||
false // Element without style is not a scrolling box
|
||||
}
|
||||
|
@ -1846,7 +1845,7 @@ impl Element {
|
|||
&self.namespace
|
||||
}
|
||||
|
||||
pub(crate) fn prefix(&self) -> Ref<Option<Prefix>> {
|
||||
pub(crate) fn prefix(&self) -> Ref<'_, Option<Prefix>> {
|
||||
self.prefix.borrow()
|
||||
}
|
||||
|
||||
|
@ -1854,7 +1853,7 @@ impl Element {
|
|||
*self.prefix.borrow_mut() = prefix;
|
||||
}
|
||||
|
||||
pub(crate) fn attrs(&self) -> Ref<[Dom<Attr>]> {
|
||||
pub(crate) fn attrs(&self) -> Ref<'_, [Dom<Attr>]> {
|
||||
Ref::map(self.attrs.borrow(), |attrs| &**attrs)
|
||||
}
|
||||
|
||||
|
@ -5216,7 +5215,7 @@ impl Element {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#category-submit
|
||||
pub(crate) fn as_maybe_validatable(&self) -> Option<&dyn Validatable> {
|
||||
let element = match self.upcast::<Node>().type_id() {
|
||||
match self.upcast::<Node>().type_id() {
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLInputElement,
|
||||
)) => {
|
||||
|
@ -5260,8 +5259,7 @@ impl Element {
|
|||
Some(element as &dyn Validatable)
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
element
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_invalid(&self, needs_update: bool, can_gc: CanGc) -> bool {
|
||||
|
|
|
@ -45,7 +45,7 @@ impl FileList {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn iter_files(&self) -> Iter<Dom<File>> {
|
||||
pub(crate) fn iter_files(&self) -> Iter<'_, Dom<File>> {
|
||||
self.list.iter()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -925,7 +925,7 @@ impl GlobalScope {
|
|||
let dom_port = if let MessagePortState::Managed(_id, message_ports) =
|
||||
&mut *self.message_port_state.borrow_mut()
|
||||
{
|
||||
let dom_port = if let Some(managed_port) = message_ports.get_mut(&port_id) {
|
||||
if let Some(managed_port) = message_ports.get_mut(&port_id) {
|
||||
if managed_port.pending {
|
||||
unreachable!("CompleteDisentanglement msg received for a pending port.");
|
||||
}
|
||||
|
@ -940,8 +940,7 @@ impl GlobalScope {
|
|||
// can happen if the port has already been transferred out of this global,
|
||||
// in which case the disentanglement will complete along with the transfer.
|
||||
return;
|
||||
};
|
||||
dom_port
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
@ -2038,8 +2037,8 @@ impl GlobalScope {
|
|||
/// Promote non-Slice blob:
|
||||
/// 1. Memory-based: The bytes in data slice will be transferred to file manager thread.
|
||||
/// 2. File-based: If set_valid, then activate the FileID so it can serve as URL
|
||||
/// Depending on set_valid, the returned FileID can be part of
|
||||
/// valid or invalid Blob URL.
|
||||
/// Depending on set_valid, the returned FileID can be part of
|
||||
/// valid or invalid Blob URL.
|
||||
pub(crate) fn promote(&self, blob_info: &mut BlobInfo, set_valid: bool) -> Uuid {
|
||||
let mut bytes = vec![];
|
||||
let global_url = self.get_url();
|
||||
|
@ -3239,7 +3238,7 @@ impl GlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn dynamic_module_list(&self) -> RefMut<DynamicModuleList> {
|
||||
pub(crate) fn dynamic_module_list(&self) -> RefMut<'_, DynamicModuleList> {
|
||||
self.dynamic_modules.borrow_mut()
|
||||
}
|
||||
|
||||
|
|
|
@ -432,10 +432,7 @@ pub(crate) fn is_forbidden_request_header(name: &str, value: &[u8]) -> bool {
|
|||
// true
|
||||
let lowercase_name = name.to_lowercase();
|
||||
|
||||
if forbidden_header_names
|
||||
.iter()
|
||||
.any(|header| *header == lowercase_name.as_str())
|
||||
{
|
||||
if forbidden_header_names.contains(&lowercase_name.as_str()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
|||
}
|
||||
|
||||
impl HTMLCanvasElement {
|
||||
pub(crate) fn context(&self) -> Option<Ref<RenderingContext>> {
|
||||
pub(crate) fn context(&self) -> Option<Ref<'_, RenderingContext>> {
|
||||
Ref::filter_map(self.context_mode.borrow(), |ctx| ctx.as_ref()).ok()
|
||||
}
|
||||
|
||||
|
|
|
@ -766,8 +766,7 @@ impl HTMLImageElement {
|
|||
) -> Au {
|
||||
let document = self.owner_document();
|
||||
let quirks_mode = document.quirks_mode();
|
||||
let result = source_size_list.evaluate(document.window().layout().device(), quirks_mode);
|
||||
result
|
||||
source_size_list.evaluate(document.window().layout().device(), quirks_mode)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#normalise-the-source-densities>
|
||||
|
@ -859,7 +858,7 @@ impl HTMLImageElement {
|
|||
|
||||
fn init_image_request(
|
||||
&self,
|
||||
request: &mut RefMut<ImageRequest>,
|
||||
request: &mut RefMut<'_, ImageRequest>,
|
||||
url: &ServoUrl,
|
||||
src: &USVString,
|
||||
can_gc: CanGc,
|
||||
|
@ -1308,6 +1307,7 @@ impl HTMLImageElement {
|
|||
// Already a part of the list of available images due to Step 14
|
||||
|
||||
// Step 15.5
|
||||
#[allow(clippy::swap_with_temporary)]
|
||||
mem::swap(&mut this.current_request.borrow_mut(), &mut pending_request);
|
||||
}
|
||||
this.abort_request(State::Unavailable, ImageRequestPhase::Pending, CanGc::note());
|
||||
|
@ -1398,7 +1398,7 @@ impl HTMLImageElement {
|
|||
|
||||
let value = usemap_attr.value();
|
||||
|
||||
if value.len() == 0 || !value.is_char_boundary(1) {
|
||||
if value.is_empty() || !value.is_char_boundary(1) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -1568,7 +1568,7 @@ pub(crate) fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList {
|
|||
}
|
||||
|
||||
fn get_correct_referrerpolicy_from_raw_token(token: &DOMString) -> DOMString {
|
||||
if token == "" {
|
||||
if token.is_empty() {
|
||||
// Empty token is treated as the default referrer policy inside determine_policy_for_token,
|
||||
// so it should remain unchanged.
|
||||
DOMString::new()
|
||||
|
|
|
@ -1168,7 +1168,7 @@ impl HTMLInputElement {
|
|||
}));
|
||||
}
|
||||
|
||||
fn text_shadow_tree(&self, can_gc: CanGc) -> Ref<InputTypeTextShadowTree> {
|
||||
fn text_shadow_tree(&self, can_gc: CanGc) -> Ref<'_, InputTypeTextShadowTree> {
|
||||
let has_text_shadow_tree = self
|
||||
.shadow_tree
|
||||
.borrow()
|
||||
|
@ -1218,7 +1218,7 @@ impl HTMLInputElement {
|
|||
///
|
||||
/// If the input is a shadow host for a different kind of shadow tree then the old
|
||||
/// tree will be removed and a new one will be created.
|
||||
fn color_shadow_tree(&self, can_gc: CanGc) -> Ref<InputTypeColorShadowTree> {
|
||||
fn color_shadow_tree(&self, can_gc: CanGc) -> Ref<'_, InputTypeColorShadowTree> {
|
||||
let has_color_shadow_tree = self
|
||||
.shadow_tree
|
||||
.borrow()
|
||||
|
@ -2510,7 +2510,7 @@ impl HTMLInputElement {
|
|||
}
|
||||
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
fn selection(&self) -> TextControlSelection<Self> {
|
||||
fn selection(&self) -> TextControlSelection<'_, Self> {
|
||||
TextControlSelection::new(self, &self.textinput)
|
||||
}
|
||||
|
||||
|
|
|
@ -1211,7 +1211,7 @@ impl HTMLScriptElement {
|
|||
let type_attr = element.get_attribute(&ns!(), &local_name!("type"));
|
||||
let language_attr = element.get_attribute(&ns!(), &local_name!("language"));
|
||||
|
||||
let script_type = match (
|
||||
match (
|
||||
type_attr.as_ref().map(|t| t.value()),
|
||||
language_attr.as_ref().map(|l| l.value()),
|
||||
) {
|
||||
|
@ -1256,10 +1256,7 @@ impl HTMLScriptElement {
|
|||
None
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/21114
|
||||
script_type
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn set_parser_inserted(&self, parser_inserted: bool) {
|
||||
|
|
|
@ -465,7 +465,7 @@ impl HTMLTextAreaElement {
|
|||
}
|
||||
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
fn selection(&self) -> TextControlSelection<Self> {
|
||||
fn selection(&self) -> TextControlSelection<'_, Self> {
|
||||
TextControlSelection::new(self, &self.textinput)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
|||
if auto_increment {
|
||||
match key_path {
|
||||
Some(StringOrStringSequence::String(path)) => {
|
||||
if path == "" {
|
||||
if path.is_empty() {
|
||||
return Err(Error::InvalidAccess);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -63,7 +63,7 @@ impl ImageBitmap {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn bitmap_data(&self) -> Ref<Option<Snapshot>> {
|
||||
pub(crate) fn bitmap_data(&self) -> Ref<'_, Option<Snapshot>> {
|
||||
self.bitmap_data.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ impl ImageData {
|
|||
|
||||
/// Nothing must change the array on the JS side while the slice is live.
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) unsafe fn get_rect(&self, rect: Rect<u32>) -> Cow<[u8]> {
|
||||
pub(crate) unsafe fn get_rect(&self, rect: Rect<u32>) -> Cow<'_, [u8]> {
|
||||
pixels::rgba8_get_rect(unsafe { self.as_slice() }, self.get_size().to_u32(), rect)
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ impl From<&ServoUrl> for MediaFragmentParser {
|
|||
}
|
||||
|
||||
// 5.1.1 Processing name-value components.
|
||||
fn decode_octets(bytes: &[u8]) -> Vec<(Cow<str>, Cow<str>)> {
|
||||
fn decode_octets(bytes: &[u8]) -> Vec<(Cow<'_, str>, Cow<'_, str>)> {
|
||||
form_urlencoded::parse(bytes)
|
||||
.filter(|(key, _)| matches!(key.as_bytes(), b"t" | b"track" | b"id" | b"xywh"))
|
||||
.collect()
|
||||
|
|
|
@ -62,7 +62,7 @@ impl MediaStream {
|
|||
this
|
||||
}
|
||||
|
||||
pub(crate) fn get_tracks(&self) -> Ref<[Dom<MediaStreamTrack>]> {
|
||||
pub(crate) fn get_tracks(&self) -> Ref<'_, [Dom<MediaStreamTrack>]> {
|
||||
Ref::map(self.tracks.borrow(), |tracks| &**tracks)
|
||||
}
|
||||
|
||||
|
|
|
@ -358,9 +358,7 @@ impl MutationObserverMethods<crate::DomTypeHolder> for MutationObserver {
|
|||
let add_new_observer = {
|
||||
let mut replaced = false;
|
||||
for registered in &mut *target.registered_mutation_observers_mut() {
|
||||
if &*registered.observer as *const MutationObserver !=
|
||||
self as *const MutationObserver
|
||||
{
|
||||
if !std::ptr::eq(&*registered.observer, self) {
|
||||
continue;
|
||||
}
|
||||
// TODO: remove matching transient registered observers
|
||||
|
|
|
@ -596,11 +596,11 @@ impl Iterator for QuerySelectorIterator {
|
|||
}
|
||||
|
||||
impl Node {
|
||||
fn rare_data(&self) -> Ref<Option<Box<NodeRareData>>> {
|
||||
fn rare_data(&self) -> Ref<'_, Option<Box<NodeRareData>>> {
|
||||
self.rare_data.borrow()
|
||||
}
|
||||
|
||||
fn ensure_rare_data(&self) -> RefMut<Box<NodeRareData>> {
|
||||
fn ensure_rare_data(&self) -> RefMut<'_, Box<NodeRareData>> {
|
||||
let mut rare_data = self.rare_data.borrow_mut();
|
||||
if rare_data.is_none() {
|
||||
*rare_data = Some(Default::default());
|
||||
|
@ -621,14 +621,14 @@ impl Node {
|
|||
|
||||
/// Return all registered mutation observers for this node. Lazily initialize the
|
||||
/// raredata if it does not exist.
|
||||
pub(crate) fn registered_mutation_observers_mut(&self) -> RefMut<Vec<RegisteredObserver>> {
|
||||
pub(crate) fn registered_mutation_observers_mut(&self) -> RefMut<'_, Vec<RegisteredObserver>> {
|
||||
RefMut::map(self.ensure_rare_data(), |rare_data| {
|
||||
&mut rare_data.mutation_observers
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn registered_mutation_observers(&self) -> Option<Ref<Vec<RegisteredObserver>>> {
|
||||
let rare_data: Ref<_> = self.rare_data.borrow();
|
||||
pub(crate) fn registered_mutation_observers(&self) -> Option<Ref<'_, Vec<RegisteredObserver>>> {
|
||||
let rare_data: Ref<'_, _> = self.rare_data.borrow();
|
||||
|
||||
if rare_data.is_none() {
|
||||
return None;
|
||||
|
@ -745,7 +745,7 @@ impl Node {
|
|||
self.children_count.get()
|
||||
}
|
||||
|
||||
pub(crate) fn ranges(&self) -> RefMut<WeakRangeVec> {
|
||||
pub(crate) fn ranges(&self) -> RefMut<'_, WeakRangeVec> {
|
||||
RefMut::map(self.ensure_rare_data(), |rare_data| &mut rare_data.ranges)
|
||||
}
|
||||
|
||||
|
@ -2693,7 +2693,7 @@ impl Node {
|
|||
|
||||
/// <https://dom.spec.whatwg.org/multipage/#string-replace-all>
|
||||
pub(crate) fn string_replace_all(string: DOMString, parent: &Node, can_gc: CanGc) {
|
||||
if string.len() == 0 {
|
||||
if string.is_empty() {
|
||||
Node::replace_all(None, parent, can_gc);
|
||||
} else {
|
||||
let text = Text::new(string, &parent.owner_document(), can_gc);
|
||||
|
|
|
@ -101,7 +101,7 @@ impl OffscreenCanvas {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn context(&self) -> Option<Ref<OffscreenRenderingContext>> {
|
||||
pub(crate) fn context(&self) -> Option<Ref<'_, OffscreenRenderingContext>> {
|
||||
Ref::filter_map(self.context.borrow(), |ctx| ctx.as_ref()).ok()
|
||||
}
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ impl Promise {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) fn promise_obj(&self) -> HandleObject {
|
||||
pub(crate) fn promise_obj(&self) -> HandleObject<'_> {
|
||||
let obj = self.reflector().get_jsobject();
|
||||
unsafe {
|
||||
assert!(IsPromiseObject(obj));
|
||||
|
|
|
@ -1486,10 +1486,8 @@ impl ReadableByteStreamController {
|
|||
|
||||
// Let descriptor be controller.[[pendingPullIntos]][0].
|
||||
// Remove descriptor from controller.[[pendingPullIntos]].
|
||||
let descriptor = self.pending_pull_intos.borrow_mut().remove(0);
|
||||
|
||||
// Return descriptor.
|
||||
descriptor
|
||||
self.pending_pull_intos.borrow_mut().remove(0)
|
||||
}
|
||||
|
||||
/// <https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamcontrollerprocessreadrequestsusingqueue>
|
||||
|
|
|
@ -185,7 +185,10 @@ impl WorkerEventLoopMethods for ServiceWorkerGlobalScope {
|
|||
self.handle_mixed_message(event, can_gc)
|
||||
}
|
||||
|
||||
fn handle_worker_post_event(&self, _worker: &TrustedWorkerAddress) -> Option<AutoWorkerReset> {
|
||||
fn handle_worker_post_event(
|
||||
&self,
|
||||
_worker: &TrustedWorkerAddress,
|
||||
) -> Option<AutoWorkerReset<'_>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ impl StaticRange {
|
|||
init: &StaticRangeInit,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<StaticRange> {
|
||||
let staticrange = reflect_dom_object_with_proto(
|
||||
reflect_dom_object_with_proto(
|
||||
Box::new(StaticRange::new_inherited(
|
||||
&init.startContainer,
|
||||
init.startOffset,
|
||||
|
@ -65,8 +65,7 @@ impl StaticRange {
|
|||
document.window(),
|
||||
proto,
|
||||
can_gc,
|
||||
);
|
||||
staticrange
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1092,6 +1092,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto {
|
|||
// These "subtle" structs are proxies for the codegen'd dicts which don't hold a DOMString
|
||||
// so they can be sent safely when running steps in parallel.
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct SubtleAlgorithm {
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -1049,8 +1049,7 @@ impl TransformStreamMethods<crate::DomTypeHolder> for TransformStream {
|
|||
}
|
||||
};
|
||||
let promise = if is_promise {
|
||||
let promise = Promise::new_with_js_promise(result_object.handle(), cx);
|
||||
promise
|
||||
Promise::new_with_js_promise(result_object.handle(), cx)
|
||||
} else {
|
||||
Promise::new_resolved(global, cx, result.get(), can_gc)
|
||||
};
|
||||
|
|
|
@ -260,8 +260,7 @@ impl UnderlyingSourceContainer {
|
|||
}
|
||||
};
|
||||
let promise = if is_promise {
|
||||
let promise = Promise::new_with_js_promise(result_object.handle(), cx);
|
||||
promise
|
||||
Promise::new_with_js_promise(result_object.handle(), cx)
|
||||
} else {
|
||||
let promise = Promise::new(&self.global(), can_gc);
|
||||
promise.resolve_native(&result.get(), can_gc);
|
||||
|
|
|
@ -100,7 +100,7 @@ impl ValidityState {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#custom-validity-error-message
|
||||
pub(crate) fn custom_error_message(&self) -> Ref<DOMString> {
|
||||
pub(crate) fn custom_error_message(&self) -> Ref<'_, DOMString> {
|
||||
self.custom_error_message.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ impl VertexArrayObject {
|
|||
&self.element_array_buffer
|
||||
}
|
||||
|
||||
pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> {
|
||||
pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<'_, VertexAttribData>> {
|
||||
Ref::filter_map(self.vertex_attribs.borrow(), |attribs| {
|
||||
attribs.get(index as usize)
|
||||
})
|
||||
|
|
|
@ -355,7 +355,7 @@ impl WebGL2RenderingContext {
|
|||
&self,
|
||||
pixel_type: u32,
|
||||
format: u32,
|
||||
) -> WebGLResult<ReadPixelsAllowedFormats> {
|
||||
) -> WebGLResult<ReadPixelsAllowedFormats<'_>> {
|
||||
let array_types = match pixel_type {
|
||||
constants::BYTE => &[Type::Int8][..],
|
||||
constants::SHORT => &[Type::Int16][..],
|
||||
|
|
|
@ -196,7 +196,7 @@ impl WebGLExtensions {
|
|||
where
|
||||
F: FnOnce() -> String,
|
||||
{
|
||||
if self.extensions.borrow().len() == 0 {
|
||||
if self.extensions.borrow().is_empty() {
|
||||
let gl_str = cb();
|
||||
self.features.borrow_mut().gl_extensions =
|
||||
FnvHashSet::from_iter(gl_str.split(&[',', ' '][..]).map(|s| s.into()));
|
||||
|
|
|
@ -220,15 +220,15 @@ impl WebGLProgram {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn active_attribs(&self) -> Ref<[ActiveAttribInfo]> {
|
||||
pub(crate) fn active_attribs(&self) -> Ref<'_, [ActiveAttribInfo]> {
|
||||
Ref::map(self.active_attribs.borrow(), |attribs| &**attribs)
|
||||
}
|
||||
|
||||
pub(crate) fn active_uniforms(&self) -> Ref<[ActiveUniformInfo]> {
|
||||
pub(crate) fn active_uniforms(&self) -> Ref<'_, [ActiveUniformInfo]> {
|
||||
Ref::map(self.active_uniforms.borrow(), |uniforms| &**uniforms)
|
||||
}
|
||||
|
||||
pub(crate) fn active_uniform_blocks(&self) -> Ref<[ActiveUniformBlockInfo]> {
|
||||
pub(crate) fn active_uniform_blocks(&self) -> Ref<'_, [ActiveUniformBlockInfo]> {
|
||||
Ref::map(self.active_uniform_blocks.borrow(), |blocks| &**blocks)
|
||||
}
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ impl WebGLRenderingContext {
|
|||
})
|
||||
}
|
||||
|
||||
pub(crate) fn current_vertex_attribs(&self) -> RefMut<Box<[VertexAttrib]>> {
|
||||
pub(crate) fn current_vertex_attribs(&self) -> RefMut<'_, Box<[VertexAttrib]>> {
|
||||
self.current_vertex_attribs.borrow_mut()
|
||||
}
|
||||
|
||||
|
@ -3581,7 +3581,7 @@ impl WebGLRenderingContextMethods<crate::DomTypeHolder> for WebGLRenderingContex
|
|||
param: u32,
|
||||
mut retval: MutableHandleValue,
|
||||
) {
|
||||
let mut get_attrib = |data: Ref<VertexAttribData>| {
|
||||
let mut get_attrib = |data: Ref<'_, VertexAttribData>| {
|
||||
if param == constants::CURRENT_VERTEX_ATTRIB {
|
||||
let attrib = self.current_vertex_attribs.borrow()[index as usize];
|
||||
match attrib {
|
||||
|
|
|
@ -64,7 +64,7 @@ impl WebGLVertexArrayObject {
|
|||
self.array_object.element_array_buffer()
|
||||
}
|
||||
|
||||
pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> {
|
||||
pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<'_, VertexAttribData>> {
|
||||
self.array_object.get_vertex_attrib(index)
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ impl WebGLVertexArrayObjectOES {
|
|||
self.array_object.element_array_buffer()
|
||||
}
|
||||
|
||||
pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> {
|
||||
pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<'_, VertexAttribData>> {
|
||||
self.array_object.get_vertex_attrib(index)
|
||||
}
|
||||
|
||||
|
|
|
@ -429,11 +429,11 @@ impl Window {
|
|||
self.upcast::<GlobalScope>()
|
||||
}
|
||||
|
||||
pub(crate) fn layout(&self) -> Ref<Box<dyn Layout>> {
|
||||
pub(crate) fn layout(&self) -> Ref<'_, Box<dyn Layout>> {
|
||||
self.layout.borrow()
|
||||
}
|
||||
|
||||
pub(crate) fn layout_mut(&self) -> RefMut<Box<dyn Layout>> {
|
||||
pub(crate) fn layout_mut(&self) -> RefMut<'_, Box<dyn Layout>> {
|
||||
self.layout.borrow_mut()
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ impl Window {
|
|||
unsafe { JSContext::from_ptr(self.js_runtime.borrow().as_ref().unwrap().cx()) }
|
||||
}
|
||||
|
||||
pub(crate) fn get_js_runtime(&self) -> Ref<Option<Rc<Runtime>>> {
|
||||
pub(crate) fn get_js_runtime(&self) -> Ref<'_, Option<Rc<Runtime>>> {
|
||||
self.js_runtime.borrow()
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ pub(crate) fn base64_btoa(input: DOMString) -> Fallible<DOMString> {
|
|||
pub(crate) fn base64_atob(input: DOMString) -> Fallible<DOMString> {
|
||||
// "Remove all space characters from input."
|
||||
fn is_html_space(c: char) -> bool {
|
||||
HTML_SPACE_CHARACTERS.iter().any(|&m| m == c)
|
||||
HTML_SPACE_CHARACTERS.contains(&c)
|
||||
}
|
||||
let without_spaces = input
|
||||
.chars()
|
||||
|
@ -1177,7 +1177,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
options: &ImageBitmapOptions,
|
||||
can_gc: CanGc,
|
||||
) -> Rc<Promise> {
|
||||
let p = ImageBitmap::create_image_bitmap(
|
||||
ImageBitmap::create_image_bitmap(
|
||||
self.as_global_scope(),
|
||||
image,
|
||||
0,
|
||||
|
@ -1186,8 +1186,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
None,
|
||||
options,
|
||||
can_gc,
|
||||
);
|
||||
p
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-createimagebitmap>
|
||||
|
@ -1201,7 +1200,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
options: &ImageBitmapOptions,
|
||||
can_gc: CanGc,
|
||||
) -> Rc<Promise> {
|
||||
let p = ImageBitmap::create_image_bitmap(
|
||||
ImageBitmap::create_image_bitmap(
|
||||
self.as_global_scope(),
|
||||
image,
|
||||
sx,
|
||||
|
@ -1210,8 +1209,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
Some(sh),
|
||||
options,
|
||||
can_gc,
|
||||
);
|
||||
p
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-window
|
||||
|
|
|
@ -82,7 +82,7 @@ pub(crate) fn prepare_workerscope_init(
|
|||
devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
||||
worker_id: Option<WorkerId>,
|
||||
) -> WorkerGlobalScopeInit {
|
||||
let init = WorkerGlobalScopeInit {
|
||||
WorkerGlobalScopeInit {
|
||||
resource_threads: global.resource_threads().clone(),
|
||||
mem_profiler_chan: global.mem_profiler_chan().clone(),
|
||||
to_devtools_sender: global.devtools_chan().cloned(),
|
||||
|
@ -94,9 +94,7 @@ pub(crate) fn prepare_workerscope_init(
|
|||
origin: global.origin().immutable().clone(),
|
||||
creation_url: global.creation_url().clone(),
|
||||
inherited_secure_context: Some(global.is_secure_context()),
|
||||
};
|
||||
|
||||
init
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-workerglobalscope-common-interface
|
||||
|
@ -254,7 +252,7 @@ impl WorkerGlobalScope {
|
|||
self.closing.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
pub(crate) fn get_url(&self) -> Ref<ServoUrl> {
|
||||
pub(crate) fn get_url(&self) -> Ref<'_, ServoUrl> {
|
||||
self.worker_url.borrow()
|
||||
}
|
||||
|
||||
|
@ -270,7 +268,7 @@ impl WorkerGlobalScope {
|
|||
self.globalscope.pipeline_id()
|
||||
}
|
||||
|
||||
pub(crate) fn policy_container(&self) -> Ref<PolicyContainer> {
|
||||
pub(crate) fn policy_container(&self) -> Ref<'_, PolicyContainer> {
|
||||
self.policy_container.borrow()
|
||||
}
|
||||
|
||||
|
@ -332,7 +330,7 @@ impl WorkerGlobalScope {
|
|||
}
|
||||
|
||||
/// Get a mutable reference to the [`TimerScheduler`] for this [`ServiceWorkerGlobalScope`].
|
||||
pub(crate) fn timer_scheduler(&self) -> RefMut<TimerScheduler> {
|
||||
pub(crate) fn timer_scheduler(&self) -> RefMut<'_, TimerScheduler> {
|
||||
self.timer_scheduler.borrow_mut()
|
||||
}
|
||||
|
||||
|
@ -560,17 +558,7 @@ impl WorkerGlobalScopeMethods<crate::DomTypeHolder> for WorkerGlobalScope {
|
|||
options: &ImageBitmapOptions,
|
||||
can_gc: CanGc,
|
||||
) -> Rc<Promise> {
|
||||
let p = ImageBitmap::create_image_bitmap(
|
||||
self.upcast(),
|
||||
image,
|
||||
0,
|
||||
0,
|
||||
None,
|
||||
None,
|
||||
options,
|
||||
can_gc,
|
||||
);
|
||||
p
|
||||
ImageBitmap::create_image_bitmap(self.upcast(), image, 0, 0, None, None, options, can_gc)
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-createimagebitmap>
|
||||
|
@ -584,7 +572,7 @@ impl WorkerGlobalScopeMethods<crate::DomTypeHolder> for WorkerGlobalScope {
|
|||
options: &ImageBitmapOptions,
|
||||
can_gc: CanGc,
|
||||
) -> Rc<Promise> {
|
||||
let p = ImageBitmap::create_image_bitmap(
|
||||
ImageBitmap::create_image_bitmap(
|
||||
self.upcast(),
|
||||
image,
|
||||
sx,
|
||||
|
@ -593,8 +581,7 @@ impl WorkerGlobalScopeMethods<crate::DomTypeHolder> for WorkerGlobalScope {
|
|||
Some(sh),
|
||||
options,
|
||||
can_gc,
|
||||
);
|
||||
p
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
|
|
|
@ -841,22 +841,24 @@ impl WritableStream {
|
|||
|
||||
// Let writer be stream.[[writer]].
|
||||
let writer = self.get_writer();
|
||||
if writer.is_some() && backpressure != self.get_backpressure() {
|
||||
|
||||
if let Some(writer) = writer {
|
||||
// If writer is not undefined
|
||||
let writer = writer.expect("Writer is some, as per the above check.");
|
||||
// and backpressure is not stream.[[backpressure]],
|
||||
if backpressure {
|
||||
// If backpressure is true, set writer.[[readyPromise]] to a new promise.
|
||||
let promise = Promise::new(global, can_gc);
|
||||
writer.set_ready_promise(promise);
|
||||
} else {
|
||||
// Otherwise,
|
||||
// Assert: backpressure is false.
|
||||
assert!(!backpressure);
|
||||
// Resolve writer.[[readyPromise]] with undefined.
|
||||
writer.resolve_ready_promise_with_undefined(can_gc);
|
||||
if backpressure != self.get_backpressure() {
|
||||
// and backpressure is not stream.[[backpressure]],
|
||||
if backpressure {
|
||||
// If backpressure is true, set writer.[[readyPromise]] to a new promise.
|
||||
let promise = Promise::new(global, can_gc);
|
||||
writer.set_ready_promise(promise);
|
||||
} else {
|
||||
// Otherwise,
|
||||
// Assert: backpressure is false.
|
||||
assert!(!backpressure);
|
||||
// Resolve writer.[[readyPromise]] with undefined.
|
||||
writer.resolve_ready_promise_with_undefined(can_gc);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Set stream.[[backpressure]] to backpressure.
|
||||
self.set_backpressure(backpressure);
|
||||
|
|
|
@ -564,8 +564,7 @@ impl WritableStreamDefaultController {
|
|||
}
|
||||
};
|
||||
if is_promise {
|
||||
let promise = Promise::new_with_js_promise(result_object.handle(), cx);
|
||||
promise
|
||||
Promise::new_with_js_promise(result_object.handle(), cx)
|
||||
} else {
|
||||
Promise::new_resolved(global, cx, result.get(), can_gc)
|
||||
}
|
||||
|
|
|
@ -1449,7 +1449,7 @@ impl XMLHttpRequest {
|
|||
// Step 2
|
||||
let bytes = self.response.borrow();
|
||||
// Step 3
|
||||
if bytes.len() == 0 {
|
||||
if bytes.is_empty() {
|
||||
return rval.set(NullValue());
|
||||
}
|
||||
// Step 4
|
||||
|
@ -1513,10 +1513,7 @@ impl XMLHttpRequest {
|
|||
let doc = win.Document();
|
||||
let docloader = DocumentLoader::new(&doc.loader());
|
||||
let base = wr.get_url();
|
||||
let parsed_url = match base.join(&self.ResponseURL().0) {
|
||||
Ok(parsed) => Some(parsed),
|
||||
Err(_) => None, // Step 7
|
||||
};
|
||||
let parsed_url = base.join(&self.ResponseURL().0).ok();
|
||||
let content_type = Some(self.final_mime_type());
|
||||
Document::new(
|
||||
win,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::iter::repeat;
|
||||
use std::iter::repeat_n;
|
||||
use std::ptr;
|
||||
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
|
@ -56,7 +56,7 @@ pub fn key_type_to_jsval(
|
|||
result.set(UndefinedValue());
|
||||
},
|
||||
IndexedDBKeyType::Array(a) => {
|
||||
rooted_vec!(let mut values <- repeat(UndefinedValue()).take(a.len()));
|
||||
rooted_vec!(let mut values <- repeat_n(UndefinedValue(), a.len()));
|
||||
for (key, value) in a.iter().zip(unsafe {
|
||||
values
|
||||
.iter_mut()
|
||||
|
|
|
@ -53,7 +53,7 @@ impl<'ld> ServoLayoutDocument<'ld> {
|
|||
self.document.style_shared_lock()
|
||||
}
|
||||
|
||||
pub fn shadow_roots(&self) -> Vec<ServoShadowRoot> {
|
||||
pub fn shadow_roots(&self) -> Vec<ServoShadowRoot<'_>> {
|
||||
unsafe {
|
||||
self.document
|
||||
.shadow_roots()
|
||||
|
|
|
@ -249,7 +249,7 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
|||
.is_some()
|
||||
}
|
||||
|
||||
fn style_attribute(&self) -> Option<ArcBorrow<StyleLocked<PropertyDeclarationBlock>>> {
|
||||
fn style_attribute(&self) -> Option<ArcBorrow<'_, StyleLocked<PropertyDeclarationBlock>>> {
|
||||
unsafe {
|
||||
(*self.element.style_attribute())
|
||||
.as_ref()
|
||||
|
@ -421,7 +421,7 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
|||
unsafe { self.as_node().get_jsmanaged().clear_style_and_layout_data() }
|
||||
}
|
||||
|
||||
unsafe fn ensure_data(&self) -> AtomicRefMut<ElementData> {
|
||||
unsafe fn ensure_data(&self) -> AtomicRefMut<'_, ElementData> {
|
||||
unsafe {
|
||||
self.as_node().get_jsmanaged().initialize_style_data();
|
||||
};
|
||||
|
@ -434,12 +434,12 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
|||
}
|
||||
|
||||
/// Immutably borrows the ElementData.
|
||||
fn borrow_data(&self) -> Option<AtomicRef<ElementData>> {
|
||||
fn borrow_data(&self) -> Option<AtomicRef<'_, ElementData>> {
|
||||
self.get_style_data().map(|data| data.element_data.borrow())
|
||||
}
|
||||
|
||||
/// Mutably borrows the ElementData.
|
||||
fn mutate_data(&self) -> Option<AtomicRefMut<ElementData>> {
|
||||
fn mutate_data(&self) -> Option<AtomicRefMut<'_, ElementData>> {
|
||||
self.get_style_data()
|
||||
.map(|data| data.element_data.borrow_mut())
|
||||
}
|
||||
|
@ -1063,7 +1063,7 @@ impl<'dom> ThreadSafeLayoutElement<'dom> for ServoThreadSafeLayoutElement<'dom>
|
|||
self.element.get_attr(namespace, name)
|
||||
}
|
||||
|
||||
fn style_data(&self) -> AtomicRef<ElementData> {
|
||||
fn style_data(&self) -> AtomicRef<'_, ElementData> {
|
||||
self.element.borrow_data().expect("Unstyled layout node?")
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ use crate::task::TaskBox;
|
|||
use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue};
|
||||
use crate::task_source::TaskSourceName;
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum MixedMessage {
|
||||
FromConstellation(ScriptThreadMessage),
|
||||
|
|
|
@ -105,7 +105,7 @@ impl ModuleObject {
|
|||
pub(crate) struct RethrowError(RootedTraceableBox<Heap<JSVal>>);
|
||||
|
||||
impl RethrowError {
|
||||
fn handle(&self) -> Handle<JSVal> {
|
||||
fn handle(&self) -> Handle<'_, JSVal> {
|
||||
self.0.handle()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ pub(crate) fn notify_about_rejected_promises(global: &GlobalScope) {
|
|||
let cx = GlobalScope::get_cx();
|
||||
unsafe {
|
||||
// Step 2.
|
||||
if global.get_uncaught_rejections().borrow().len() > 0 {
|
||||
if !global.get_uncaught_rejections().borrow().is_empty() {
|
||||
// Step 1.
|
||||
let uncaught_rejections: Vec<TrustedPromise> = global
|
||||
.get_uncaught_rejections()
|
||||
|
|
|
@ -65,7 +65,7 @@ impl TaskCancellers {
|
|||
|
||||
macro_rules! task_source_functions {
|
||||
($self:ident, $task_source:ident, $task_source_name:ident) => {
|
||||
pub(crate) fn $task_source(&$self) -> TaskSource {
|
||||
pub(crate) fn $task_source(&$self) -> TaskSource<'_> {
|
||||
TaskSource {
|
||||
task_manager: $self,
|
||||
name: TaskSourceName::$task_source_name,
|
||||
|
@ -105,7 +105,7 @@ impl TaskManager {
|
|||
self.pipeline_id
|
||||
}
|
||||
|
||||
pub(crate) fn sender(&self) -> Ref<Option<ScriptEventLoopSender>> {
|
||||
pub(crate) fn sender(&self) -> Ref<'_, Option<ScriptEventLoopSender>> {
|
||||
self.sender.borrow()
|
||||
}
|
||||
|
||||
|
|
|
@ -1974,11 +1974,9 @@ fn is_element_in_view(element: &Element, paint_tree: &[DomRoot<Element>]) -> boo
|
|||
// https://w3c.github.io/webdriver/#dfn-pointer-events-are-not-disabled
|
||||
// An element is said to have pointer events disabled
|
||||
// if the resolved value of its "pointer-events" style property is "none".
|
||||
let pointer_events_not_disabled = element
|
||||
element
|
||||
.style()
|
||||
.is_none_or(|style| style.get_inherited_ui().pointer_events != PointerEvents::None);
|
||||
|
||||
pointer_events_not_disabled
|
||||
.is_none_or(|style| style.get_inherited_ui().pointer_events != PointerEvents::None)
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/webdriver/#dfn-pointer-interactable-paint-tree>
|
||||
|
|
|
@ -60,7 +60,7 @@ impl EvaluationCtx {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn subcontext_iter_for_nodes(&self) -> EvalNodesetIter {
|
||||
pub(crate) fn subcontext_iter_for_nodes(&self) -> EvalNodesetIter<'_> {
|
||||
let size = self.predicate_nodes.as_ref().map_or(0, |v| v.len());
|
||||
EvalNodesetIter {
|
||||
ctx: self,
|
||||
|
|
|
@ -62,7 +62,7 @@ impl PartialEq<Value> for Value {
|
|||
(&Value::Nodeset(ref nodes), &Value::Number(val)) |
|
||||
(&Value::Number(val), &Value::Nodeset(ref nodes)) => {
|
||||
let numbers = num_vals(nodes);
|
||||
numbers.iter().any(|n| *n == val)
|
||||
numbers.contains(&val)
|
||||
},
|
||||
(&Value::Nodeset(ref nodes), &Value::String(ref val)) |
|
||||
(&Value::String(ref val), &Value::Nodeset(ref nodes)) => {
|
||||
|
|
|
@ -8322,8 +8322,6 @@ class CallbackMember(CGNativeMember):
|
|||
jsvalIndex = f"{i} + idx"
|
||||
else:
|
||||
jsvalIndex = f"{i}"
|
||||
if arg.optional and not arg.defaultValue:
|
||||
argval += ".unwrap()"
|
||||
|
||||
conversion = wrapForType(
|
||||
"argv_root.handle_mut()", result=argval,
|
||||
|
@ -8340,7 +8338,7 @@ class CallbackMember(CGNativeMember):
|
|||
)
|
||||
elif arg.optional and not arg.defaultValue:
|
||||
conversion = (
|
||||
f"{CGIfWrapper(f'{arg.identifier.name}.is_some()', CGGeneric(conversion)).define()}"
|
||||
f"{CGIfWrapper(f'let Some({arg.identifier.name}) = {arg.identifier.name}', CGGeneric(conversion)).define()}"
|
||||
f" else if argc == {i + 1} {{\n"
|
||||
" // This is our current trailing argument; reduce argc\n"
|
||||
" argc -= 1;\n"
|
||||
|
|
|
@ -47,11 +47,11 @@ impl<'a> From<&'a JSAutoRealm> for InRealm<'a> {
|
|||
}
|
||||
|
||||
impl InRealm<'_> {
|
||||
pub fn already(token: &AlreadyInRealm) -> InRealm {
|
||||
pub fn already(token: &AlreadyInRealm) -> InRealm<'_> {
|
||||
InRealm::Already(token)
|
||||
}
|
||||
|
||||
pub fn entered(token: &JSAutoRealm) -> InRealm {
|
||||
pub fn entered(token: &JSAutoRealm) -> InRealm<'_> {
|
||||
InRealm::Entered(token)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ impl PartialEq for Reflector {
|
|||
impl Reflector {
|
||||
/// Get the reflector.
|
||||
#[inline]
|
||||
pub fn get_jsobject(&self) -> HandleObject {
|
||||
pub fn get_jsobject(&self) -> HandleObject<'_> {
|
||||
// We're rooted, so it's safe to hand out a handle to object in Heap
|
||||
unsafe { HandleObject::from_raw(self.object.handle()) }
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ where
|
|||
Heap<T>: JSTraceable + 'static,
|
||||
T: GCMethods + Copy,
|
||||
{
|
||||
pub fn handle(&self) -> Handle<T> {
|
||||
pub fn handle(&self) -> Handle<'_, T> {
|
||||
self.0.handle()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ impl ConstellationProxy {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn try_send(
|
||||
&self,
|
||||
msg: EmbedderToConstellationMessage,
|
||||
|
|
|
@ -378,16 +378,14 @@ namespace_id! {OffscreenCanvasId, OffscreenCanvasIndex, "OffscreenCanvas"}
|
|||
|
||||
// We provide ids just for unit testing.
|
||||
pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234);
|
||||
#[allow(unsafe_code)]
|
||||
pub const TEST_PIPELINE_INDEX: Index<PipelineIndex> =
|
||||
unsafe { Index(NonZeroU32::new_unchecked(5678), PhantomData) };
|
||||
Index(NonZeroU32::new(5678).unwrap(), PhantomData);
|
||||
pub const TEST_PIPELINE_ID: PipelineId = PipelineId {
|
||||
namespace_id: TEST_NAMESPACE,
|
||||
index: TEST_PIPELINE_INDEX,
|
||||
};
|
||||
#[allow(unsafe_code)]
|
||||
pub const TEST_BROWSING_CONTEXT_INDEX: Index<BrowsingContextIndex> =
|
||||
unsafe { Index(NonZeroU32::new_unchecked(8765), PhantomData) };
|
||||
Index(NonZeroU32::new(8765).unwrap(), PhantomData);
|
||||
pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId = BrowsingContextId {
|
||||
namespace_id: TEST_NAMESPACE,
|
||||
index: TEST_BROWSING_CONTEXT_INDEX,
|
||||
|
|
|
@ -98,7 +98,7 @@ impl BluetoothScanfilterSequence {
|
|||
self.0.iter().any(BluetoothScanfilter::is_empty_or_invalid)
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> Iter<BluetoothScanfilter> {
|
||||
pub fn iter(&self) -> Iter<'_, BluetoothScanfilter> {
|
||||
self.0.iter()
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue