mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix option_as_ref_deref warnings (#31936)
This commit is contained in:
parent
c3b6d40f90
commit
a8976ff00a
7 changed files with 17 additions and 31 deletions
|
@ -88,8 +88,7 @@ impl CanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
pub fn mark_as_dirty(&self) {
|
||||
self.canvas_state
|
||||
.mark_as_dirty(self.canvas.as_ref().map(|c| &**c))
|
||||
self.canvas_state.mark_as_dirty(self.canvas.as_deref())
|
||||
}
|
||||
|
||||
pub fn take_missing_image_urls(&self) -> Vec<ServoUrl> {
|
||||
|
@ -455,7 +454,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||
fn SetStrokeStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
||||
self.canvas_state
|
||||
.set_stroke_style(self.canvas.as_ref().map(|c| &**c), value)
|
||||
.set_stroke_style(self.canvas.as_deref(), value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||
|
|
|
@ -1019,8 +1019,7 @@ impl ElementQueue {
|
|||
self.queue
|
||||
.borrow_mut()
|
||||
.pop_front()
|
||||
.as_ref()
|
||||
.map(Dom::deref)
|
||||
.as_deref()
|
||||
.map(DomRoot::from_ref)
|
||||
}
|
||||
|
||||
|
|
|
@ -791,7 +791,7 @@ impl HTMLFormElement {
|
|||
Some(submitter.target())
|
||||
} else {
|
||||
let form_owner = submitter.form_owner();
|
||||
let form = form_owner.as_ref().map(|form| &**form).unwrap_or(self);
|
||||
let form = form_owner.as_deref().unwrap_or(self);
|
||||
get_element_target(form.upcast::<Element>())
|
||||
};
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ impl OffscreenCanvas {
|
|||
let context = OffscreenCanvasRenderingContext2D::new(
|
||||
&self.global(),
|
||||
self,
|
||||
self.placeholder.as_ref().map(|c| &**c),
|
||||
self.placeholder.as_deref(),
|
||||
);
|
||||
*self.context.borrow_mut() = Some(OffscreenCanvasContext::OffscreenContext2d(
|
||||
Dom::from_ref(&*context),
|
||||
|
|
|
@ -141,7 +141,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
|
||||
fn SetShadowColor(&self, value: DOMString) {
|
||||
self.canvas_state
|
||||
.set_shadow_color(self.htmlcanvas.as_ref().map(|c| &**c), value)
|
||||
.set_shadow_color(self.htmlcanvas.as_deref(), value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||
|
@ -152,7 +152,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||
fn SetStrokeStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
||||
self.canvas_state
|
||||
.set_stroke_style(self.htmlcanvas.as_ref().map(|c| &**c), value)
|
||||
.set_stroke_style(self.htmlcanvas.as_deref(), value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||
|
@ -163,7 +163,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||
fn SetFillStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
||||
self.canvas_state
|
||||
.set_fill_style(self.htmlcanvas.as_ref().map(|c| &**c), value)
|
||||
.set_fill_style(self.htmlcanvas.as_deref(), value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createlineargradient
|
||||
|
@ -250,13 +250,8 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-filltext
|
||||
fn FillText(&self, text: DOMString, x: f64, y: f64, max_width: Option<f64>) {
|
||||
self.canvas_state.fill_text(
|
||||
self.htmlcanvas.as_ref().map(|c| &**c),
|
||||
text,
|
||||
x,
|
||||
y,
|
||||
max_width,
|
||||
)
|
||||
self.canvas_state
|
||||
.fill_text(self.htmlcanvas.as_deref(), text, x, y, max_width)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#textmetrics
|
||||
|
@ -272,7 +267,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
|
||||
fn SetFont(&self, value: DOMString) {
|
||||
self.canvas_state
|
||||
.set_font(self.htmlcanvas.as_ref().map(|c| &**c), value)
|
||||
.set_font(self.htmlcanvas.as_deref(), value)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-textalign
|
||||
|
@ -395,7 +390,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
||||
fn DrawImage(&self, image: CanvasImageSource, dx: f64, dy: f64) -> ErrorResult {
|
||||
self.canvas_state
|
||||
.draw_image(self.htmlcanvas.as_ref().map(|c| &**c), image, dx, dy)
|
||||
.draw_image(self.htmlcanvas.as_deref(), image, dx, dy)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
||||
|
@ -407,14 +402,8 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
dw: f64,
|
||||
dh: f64,
|
||||
) -> ErrorResult {
|
||||
self.canvas_state.draw_image_(
|
||||
self.htmlcanvas.as_ref().map(|c| &**c),
|
||||
image,
|
||||
dx,
|
||||
dy,
|
||||
dw,
|
||||
dh,
|
||||
)
|
||||
self.canvas_state
|
||||
.draw_image_(self.htmlcanvas.as_deref(), image, dx, dy, dw, dh)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
||||
|
@ -431,7 +420,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
|||
dh: f64,
|
||||
) -> ErrorResult {
|
||||
self.canvas_state.draw_image__(
|
||||
self.htmlcanvas.as_ref().map(|c| &**c),
|
||||
self.htmlcanvas.as_deref(),
|
||||
image,
|
||||
sx,
|
||||
sy,
|
||||
|
|
|
@ -74,7 +74,7 @@ impl XRRenderState {
|
|||
self.depth_near.get(),
|
||||
self.depth_far.get(),
|
||||
self.inline_vertical_fov.get(),
|
||||
self.base_layer.get().as_ref().map(|x| &**x),
|
||||
self.base_layer.get().as_deref(),
|
||||
self.layers.borrow().iter().map(|x| &**x).collect(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3359,8 +3359,7 @@ impl ScriptThread {
|
|||
|
||||
let referrer_policy = metadata
|
||||
.headers
|
||||
.as_ref()
|
||||
.map(Serde::deref)
|
||||
.as_deref()
|
||||
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
|
||||
.map(ReferrerPolicy::from);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue