mirror of
https://github.com/servo/servo.git
synced 2025-06-14 19:34:29 +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) {
|
pub fn mark_as_dirty(&self) {
|
||||||
self.canvas_state
|
self.canvas_state.mark_as_dirty(self.canvas.as_deref())
|
||||||
.mark_as_dirty(self.canvas.as_ref().map(|c| &**c))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_missing_image_urls(&self) -> Vec<ServoUrl> {
|
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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||||
fn SetStrokeStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
fn SetStrokeStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
||||||
self.canvas_state
|
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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||||
|
|
|
@ -1019,8 +1019,7 @@ impl ElementQueue {
|
||||||
self.queue
|
self.queue
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.pop_front()
|
.pop_front()
|
||||||
.as_ref()
|
.as_deref()
|
||||||
.map(Dom::deref)
|
|
||||||
.map(DomRoot::from_ref)
|
.map(DomRoot::from_ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -791,7 +791,7 @@ impl HTMLFormElement {
|
||||||
Some(submitter.target())
|
Some(submitter.target())
|
||||||
} else {
|
} else {
|
||||||
let form_owner = submitter.form_owner();
|
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>())
|
get_element_target(form.upcast::<Element>())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ impl OffscreenCanvas {
|
||||||
let context = OffscreenCanvasRenderingContext2D::new(
|
let context = OffscreenCanvasRenderingContext2D::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
self,
|
self,
|
||||||
self.placeholder.as_ref().map(|c| &**c),
|
self.placeholder.as_deref(),
|
||||||
);
|
);
|
||||||
*self.context.borrow_mut() = Some(OffscreenCanvasContext::OffscreenContext2d(
|
*self.context.borrow_mut() = Some(OffscreenCanvasContext::OffscreenContext2d(
|
||||||
Dom::from_ref(&*context),
|
Dom::from_ref(&*context),
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor
|
||||||
fn SetShadowColor(&self, value: DOMString) {
|
fn SetShadowColor(&self, value: DOMString) {
|
||||||
self.canvas_state
|
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
|
// 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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||||
fn SetStrokeStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
fn SetStrokeStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
||||||
self.canvas_state
|
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
|
// 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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle
|
||||||
fn SetFillStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
fn SetFillStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
||||||
self.canvas_state
|
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
|
// 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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-filltext
|
||||||
fn FillText(&self, text: DOMString, x: f64, y: f64, max_width: Option<f64>) {
|
fn FillText(&self, text: DOMString, x: f64, y: f64, max_width: Option<f64>) {
|
||||||
self.canvas_state.fill_text(
|
self.canvas_state
|
||||||
self.htmlcanvas.as_ref().map(|c| &**c),
|
.fill_text(self.htmlcanvas.as_deref(), text, x, y, max_width)
|
||||||
text,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
max_width,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#textmetrics
|
// 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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
|
||||||
fn SetFont(&self, value: DOMString) {
|
fn SetFont(&self, value: DOMString) {
|
||||||
self.canvas_state
|
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
|
// 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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
||||||
fn DrawImage(&self, image: CanvasImageSource, dx: f64, dy: f64) -> ErrorResult {
|
fn DrawImage(&self, image: CanvasImageSource, dx: f64, dy: f64) -> ErrorResult {
|
||||||
self.canvas_state
|
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
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
||||||
|
@ -407,14 +402,8 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
||||||
dw: f64,
|
dw: f64,
|
||||||
dh: f64,
|
dh: f64,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
self.canvas_state.draw_image_(
|
self.canvas_state
|
||||||
self.htmlcanvas.as_ref().map(|c| &**c),
|
.draw_image_(self.htmlcanvas.as_deref(), image, dx, dy, dw, dh)
|
||||||
image,
|
|
||||||
dx,
|
|
||||||
dy,
|
|
||||||
dw,
|
|
||||||
dh,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage
|
||||||
|
@ -431,7 +420,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
||||||
dh: f64,
|
dh: f64,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
self.canvas_state.draw_image__(
|
self.canvas_state.draw_image__(
|
||||||
self.htmlcanvas.as_ref().map(|c| &**c),
|
self.htmlcanvas.as_deref(),
|
||||||
image,
|
image,
|
||||||
sx,
|
sx,
|
||||||
sy,
|
sy,
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl XRRenderState {
|
||||||
self.depth_near.get(),
|
self.depth_near.get(),
|
||||||
self.depth_far.get(),
|
self.depth_far.get(),
|
||||||
self.inline_vertical_fov.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(),
|
self.layers.borrow().iter().map(|x| &**x).collect(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3359,8 +3359,7 @@ impl ScriptThread {
|
||||||
|
|
||||||
let referrer_policy = metadata
|
let referrer_policy = metadata
|
||||||
.headers
|
.headers
|
||||||
.as_ref()
|
.as_deref()
|
||||||
.map(Serde::deref)
|
|
||||||
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
|
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
|
||||||
.map(ReferrerPolicy::from);
|
.map(ReferrerPolicy::from);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue