mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
clippy: Fix a few clippy problems in components/scripts/dom
(#31905)
* option_as_ref_deref * fix
This commit is contained in:
parent
1bc63801e7
commit
5aae820f6d
3 changed files with 10 additions and 12 deletions
|
@ -7,7 +7,6 @@
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::mem::drop;
|
use std::mem::drop;
|
||||||
use std::ops::Deref;
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl Blob {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let type_string = normalize_type_string(&blobPropertyBag.type_.to_string());
|
let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
|
||||||
let blob_impl = BlobImpl::new_from_bytes(bytes, type_string);
|
let blob_impl = BlobImpl::new_from_bytes(bytes, type_string);
|
||||||
|
|
||||||
Ok(Blob::new_with_proto(global, proto, blob_impl))
|
Ok(Blob::new_with_proto(global, proto, blob_impl))
|
||||||
|
@ -125,7 +125,7 @@ impl Serializable for Blob {
|
||||||
let new_blob_id = blob_impl.blob_id();
|
let new_blob_id = blob_impl.blob_id();
|
||||||
|
|
||||||
// 2. Store the object at a given key.
|
// 2. Store the object at a given key.
|
||||||
let blobs = blob_impls.get_or_insert_with(|| HashMap::new());
|
let blobs = blob_impls.get_or_insert_with(HashMap::new);
|
||||||
blobs.insert(new_blob_id, blob_impl);
|
blobs.insert(new_blob_id, blob_impl);
|
||||||
|
|
||||||
let PipelineNamespaceId(name_space) = new_blob_id.namespace_id;
|
let PipelineNamespaceId(name_space) = new_blob_id.namespace_id;
|
||||||
|
@ -242,7 +242,7 @@ impl BlobMethods for Blob {
|
||||||
content_type: Option<DOMString>,
|
content_type: Option<DOMString>,
|
||||||
) -> DomRoot<Blob> {
|
) -> DomRoot<Blob> {
|
||||||
let type_string =
|
let type_string =
|
||||||
normalize_type_string(&content_type.unwrap_or(DOMString::from("")).to_string());
|
normalize_type_string(content_type.unwrap_or(DOMString::from("")).as_ref());
|
||||||
let rel_pos = RelativePos::from_opts(start, end);
|
let rel_pos = RelativePos::from_opts(start, end);
|
||||||
let blob_impl = BlobImpl::new_sliced(rel_pos, self.blob_id, type_string);
|
let blob_impl = BlobImpl::new_sliced(rel_pos, self.blob_id, type_string);
|
||||||
Blob::new(&self.global(), blob_impl)
|
Blob::new(&self.global(), blob_impl)
|
||||||
|
|
|
@ -295,7 +295,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
// 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
|
self.canvas_state
|
||||||
.fill_text(self.canvas.as_ref().map(|c| &**c), text, x, y, max_width);
|
.fill_text(self.canvas.as_deref(), text, x, y, max_width);
|
||||||
self.mark_as_dirty();
|
self.mark_as_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,8 +311,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
|
|
||||||
// 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.canvas.as_deref(), value)
|
||||||
.set_font(self.canvas.as_ref().map(|c| &**c), value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-textalign
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-textalign
|
||||||
|
@ -348,7 +347,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
// 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.canvas.as_ref().map(|c| &**c), image, dx, dy)
|
.draw_image(self.canvas.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
|
||||||
|
@ -361,7 +360,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
dh: f64,
|
dh: f64,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
self.canvas_state
|
self.canvas_state
|
||||||
.draw_image_(self.canvas.as_ref().map(|c| &**c), image, dx, dy, dw, dh)
|
.draw_image_(self.canvas.as_deref(), 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
|
||||||
|
@ -378,7 +377,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
dh: f64,
|
dh: f64,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
self.canvas_state.draw_image__(
|
self.canvas_state.draw_image__(
|
||||||
self.canvas.as_ref().map(|c| &**c),
|
self.canvas.as_deref(),
|
||||||
image,
|
image,
|
||||||
sx,
|
sx,
|
||||||
sy,
|
sy,
|
||||||
|
@ -472,7 +471,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 SetFillStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
fn SetFillStyle(&self, value: StringOrCanvasGradientOrCanvasPattern) {
|
||||||
self.canvas_state
|
self.canvas_state
|
||||||
.set_fill_style(self.canvas.as_ref().map(|c| &**c), value)
|
.set_fill_style(self.canvas.as_deref(), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||||
|
@ -653,7 +652,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
// 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.canvas.as_ref().map(|c| &**c), value)
|
.set_shadow_color(self.canvas.as_deref(), value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue