mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
clippy: Fix many warnings in components/script
(#31717)
* Fix Several clippy warnings * Fix Build errors * Fix Unused import * Fix requested changes * Fix rustfmt * Minor fixes --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
676f655647
commit
01ca220f83
41 changed files with 200 additions and 212 deletions
|
@ -370,7 +370,7 @@ impl CanvasState {
|
|||
return Err(Error::InvalidState);
|
||||
}
|
||||
|
||||
self.draw_html_canvas_element(&canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
self.draw_html_canvas_element(canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
},
|
||||
CanvasImageSource::OffscreenCanvas(ref canvas) => {
|
||||
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
|
||||
|
@ -378,7 +378,7 @@ impl CanvasState {
|
|||
return Err(Error::InvalidState);
|
||||
}
|
||||
|
||||
self.draw_offscreen_canvas(&canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
self.draw_offscreen_canvas(canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
},
|
||||
CanvasImageSource::HTMLImageElement(ref image) => {
|
||||
// https://html.spec.whatwg.org/multipage/#drawing-images
|
||||
|
|
|
@ -502,7 +502,7 @@ impl ServoParser {
|
|||
if let Some(partial_bom) = bom_sniff.as_mut() {
|
||||
if partial_bom.len() + chunk.len() >= 3 {
|
||||
partial_bom.extend(chunk.iter().take(3 - partial_bom.len()).copied());
|
||||
if let Some((encoding, _)) = Encoding::for_bom(&partial_bom) {
|
||||
if let Some((encoding, _)) = Encoding::for_bom(partial_bom) {
|
||||
self.document.set_encoding(encoding);
|
||||
}
|
||||
drop(bom_sniff);
|
||||
|
@ -568,7 +568,7 @@ impl ServoParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
self.tokenize(|tokenizer| tokenizer.feed(&mut *self.network_input.borrow_mut()));
|
||||
self.tokenize(|tokenizer| tokenizer.feed(&mut self.network_input.borrow_mut()));
|
||||
|
||||
if self.suspended.get() {
|
||||
return;
|
||||
|
@ -606,7 +606,7 @@ impl ServoParser {
|
|||
assert!(!self.aborted.get());
|
||||
|
||||
self.document.reflow_if_reflow_timer_expired();
|
||||
let script = match feed(&mut *self.tokenizer.borrow_mut()) {
|
||||
let script = match feed(&mut self.tokenizer.borrow_mut()) {
|
||||
TokenizerResult::Done => return,
|
||||
TokenizerResult::Script(script) => script,
|
||||
};
|
||||
|
@ -887,7 +887,7 @@ impl FetchResponseListener for ParserContext {
|
|||
self.is_synthesized_document = true;
|
||||
let page = resources::read_string(Resource::BadCertHTML);
|
||||
let page = page.replace("${reason}", &reason);
|
||||
let encoded_bytes = general_purpose::STANDARD_NO_PAD.encode(&bytes);
|
||||
let encoded_bytes = general_purpose::STANDARD_NO_PAD.encode(bytes);
|
||||
let page = page.replace("${bytes}", encoded_bytes.as_str());
|
||||
let page =
|
||||
page.replace("${secret}", &net_traits::PRIVILEGED_SECRET.to_string());
|
||||
|
@ -978,7 +978,7 @@ impl FetchResponseListener for ParserContext {
|
|||
if let Some(pushed_index) = self.pushed_entry_index {
|
||||
let document = &parser.document;
|
||||
let performance_entry =
|
||||
PerformanceNavigationTiming::new(&document.global(), 0, 0, &document);
|
||||
PerformanceNavigationTiming::new(&document.global(), 0, 0, document);
|
||||
document
|
||||
.global()
|
||||
.performance()
|
||||
|
@ -1008,7 +1008,7 @@ impl FetchResponseListener for ParserContext {
|
|||
|
||||
//TODO nav_start and nav_start_precise
|
||||
let performance_entry =
|
||||
PerformanceNavigationTiming::new(&document.global(), 0, 0, &document);
|
||||
PerformanceNavigationTiming::new(&document.global(), 0, 0, document);
|
||||
self.pushed_entry_index = document
|
||||
.global()
|
||||
.performance()
|
||||
|
@ -1141,7 +1141,7 @@ impl TreeSink for Sink {
|
|||
}
|
||||
|
||||
fn create_comment(&mut self, text: StrTendril) -> Dom<Node> {
|
||||
let comment = Comment::new(DOMString::from(String::from(text)), &*self.document, None);
|
||||
let comment = Comment::new(DOMString::from(String::from(text)), &self.document, None);
|
||||
Dom::from_ref(comment.upcast())
|
||||
}
|
||||
|
||||
|
@ -1207,7 +1207,7 @@ impl TreeSink for Sink {
|
|||
}
|
||||
|
||||
fn append(&mut self, parent: &Dom<Node>, child: NodeOrText<Dom<Node>>) {
|
||||
insert(&parent, None, child, self.parsing_algorithm);
|
||||
insert(parent, None, child, self.parsing_algorithm);
|
||||
}
|
||||
|
||||
fn append_based_on_parent_node(
|
||||
|
@ -1276,7 +1276,7 @@ impl TreeSink for Sink {
|
|||
|
||||
fn reparent_children(&mut self, node: &Dom<Node>, new_parent: &Dom<Node>) {
|
||||
while let Some(ref child) = node.GetFirstChild() {
|
||||
new_parent.AppendChild(&child).unwrap();
|
||||
new_parent.AppendChild(child).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,10 +78,10 @@ impl ShadowRoot {
|
|||
}
|
||||
|
||||
pub fn detach(&self) {
|
||||
self.document.unregister_shadow_root(&self);
|
||||
self.document.unregister_shadow_root(self);
|
||||
let node = self.upcast::<Node>();
|
||||
node.set_containing_shadow_root(None);
|
||||
Node::complete_remove_subtree(&node, &UnbindContext::new(node, None, None, None));
|
||||
Node::complete_remove_subtree(node, &UnbindContext::new(node, None, None, None));
|
||||
self.host.set(None);
|
||||
}
|
||||
|
||||
|
@ -188,9 +188,7 @@ impl ShadowRootMethods for ShadowRoot {
|
|||
) {
|
||||
Some(e) => {
|
||||
let retargeted_node = self.upcast::<Node>().retarget(e.upcast::<Node>());
|
||||
retargeted_node
|
||||
.downcast::<Element>()
|
||||
.map(|n| DomRoot::from_ref(n))
|
||||
retargeted_node.downcast::<Element>().map(DomRoot::from_ref)
|
||||
},
|
||||
None => None,
|
||||
}
|
||||
|
@ -207,10 +205,7 @@ impl ShadowRootMethods for ShadowRoot {
|
|||
.iter()
|
||||
{
|
||||
let retargeted_node = self.upcast::<Node>().retarget(e.upcast::<Node>());
|
||||
if let Some(element) = retargeted_node
|
||||
.downcast::<Element>()
|
||||
.map(|n| DomRoot::from_ref(n))
|
||||
{
|
||||
if let Some(element) = retargeted_node.downcast::<Element>().map(DomRoot::from_ref) {
|
||||
elements.push(element);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -873,8 +873,8 @@ impl TestBindingMethods for TestBinding {
|
|||
prefs::pref_map()
|
||||
.get(pref_name.as_ref())
|
||||
.as_str()
|
||||
.map(|s| DOMString::from(s))
|
||||
.unwrap_or_else(|| DOMString::new())
|
||||
.map(DOMString::from)
|
||||
.unwrap_or_else(DOMString::new)
|
||||
}
|
||||
fn PrefControlledAttributeDisabled(&self) -> bool {
|
||||
false
|
||||
|
|
|
@ -89,7 +89,7 @@ impl TextMethods for Text {
|
|||
node.ranges()
|
||||
.move_to_following_text_sibling_above(node, offset, new_node.upcast());
|
||||
// Steps 7.4-5.
|
||||
parent.ranges().increment_at(&parent, node.index() + 1);
|
||||
parent.ranges().increment_at(parent, node.index() + 1);
|
||||
}
|
||||
// Step 8.
|
||||
cdata.DeleteData(offset, count).unwrap();
|
||||
|
|
|
@ -126,7 +126,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
|
|||
self.set_range(
|
||||
Some(self.start()),
|
||||
Some(self.end()),
|
||||
direction.map(|d| SelectionDirection::from(d)),
|
||||
direction.map(SelectionDirection::from),
|
||||
None,
|
||||
);
|
||||
Ok(())
|
||||
|
@ -305,7 +305,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
|
|||
.task_manager()
|
||||
.user_interaction_task_source()
|
||||
.queue_event(
|
||||
&self.element.upcast::<EventTarget>(),
|
||||
self.element.upcast::<EventTarget>(),
|
||||
atom!("select"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
|
|
|
@ -55,7 +55,7 @@ impl TextEncoderMethods for TextEncoder {
|
|||
let encoded = input.0.as_bytes();
|
||||
|
||||
rooted!(in(*cx) let mut js_object = ptr::null_mut::<JSObject>());
|
||||
create_buffer_source(cx, &encoded, js_object.handle_mut())
|
||||
create_buffer_source(cx, encoded, js_object.handle_mut())
|
||||
.expect("Converting input to uint8 array should never fail")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ impl TextTrack {
|
|||
|
||||
pub fn get_cues(&self) -> DomRoot<TextTrackCueList> {
|
||||
self.cue_list
|
||||
.or_init(|| TextTrackCueList::new(&self.global().as_window(), &[]))
|
||||
.or_init(|| TextTrackCueList::new(self.global().as_window(), &[]))
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &str {
|
||||
|
@ -131,7 +131,7 @@ impl TextTrackMethods for TextTrack {
|
|||
fn GetActiveCues(&self) -> Option<DomRoot<TextTrackCueList>> {
|
||||
// XXX implement active cues logic
|
||||
// https://github.com/servo/servo/issues/22314
|
||||
Some(TextTrackCueList::new(&self.global().as_window(), &[]))
|
||||
Some(TextTrackCueList::new(self.global().as_window(), &[]))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-texttrack-addcue
|
||||
|
|
|
@ -66,7 +66,7 @@ impl TextTrackList {
|
|||
.task_manager()
|
||||
.media_element_task_source_with_canceller();
|
||||
|
||||
let idx = match self.find(&track) {
|
||||
let idx = match self.find(track) {
|
||||
Some(t) => t,
|
||||
None => return,
|
||||
};
|
||||
|
@ -89,7 +89,7 @@ impl TextTrackList {
|
|||
event.upcast::<Event>().fire(this.upcast::<EventTarget>());
|
||||
}
|
||||
}),
|
||||
&canceller,
|
||||
canceller,
|
||||
);
|
||||
track.add_track_list(self);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ impl TrackEvent {
|
|||
track: &Option<VideoTrackOrAudioTrackOrTextTrack>,
|
||||
) -> DomRoot<TrackEvent> {
|
||||
let te = reflect_dom_object_with_proto(
|
||||
Box::new(TrackEvent::new_inherited(&track)),
|
||||
Box::new(TrackEvent::new_inherited(track)),
|
||||
global,
|
||||
proto,
|
||||
);
|
||||
|
|
|
@ -317,7 +317,7 @@ impl TreeWalker {
|
|||
// return null."
|
||||
None => return Ok(None),
|
||||
Some(ref parent)
|
||||
if self.is_root_node(&parent) || self.is_current_node(&parent) =>
|
||||
if self.is_root_node(parent) || self.is_current_node(parent) =>
|
||||
{
|
||||
return Ok(None);
|
||||
},
|
||||
|
@ -382,7 +382,7 @@ impl TreeWalker {
|
|||
match node.GetParentNode() {
|
||||
// "4. If node is null or is root, return null."
|
||||
None => return Ok(None),
|
||||
Some(ref n) if self.is_root_node(&n) => return Ok(None),
|
||||
Some(ref n) if self.is_root_node(n) => return Ok(None),
|
||||
// "5. Filter node and if the return value is FILTER_ACCEPT, then return null."
|
||||
Some(n) => {
|
||||
node = n;
|
||||
|
|
|
@ -31,7 +31,7 @@ pub fn load_script(head: &HTMLHeadElement) {
|
|||
rooted!(in(*cx) let mut rval = UndefinedValue());
|
||||
|
||||
let path = PathBuf::from(&path_str);
|
||||
let mut files = read_dir(&path)
|
||||
let mut files = read_dir(path)
|
||||
.expect("Bad path passed to --userscripts")
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.path())
|
||||
|
@ -52,7 +52,7 @@ pub fn load_script(head: &HTMLHeadElement) {
|
|||
&file.to_string_lossy(),
|
||||
rval.handle_mut(),
|
||||
1,
|
||||
ScriptFetchOptions::default_classic_script(&global),
|
||||
ScriptFetchOptions::default_classic_script(global),
|
||||
global.api_base_url(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ impl VertexArrayObject {
|
|||
}
|
||||
|
||||
pub fn ever_bound(&self) -> bool {
|
||||
return self.ever_bound.get();
|
||||
self.ever_bound.get()
|
||||
}
|
||||
|
||||
pub fn set_ever_bound(&self) {
|
||||
|
|
|
@ -35,12 +35,12 @@ impl VideoTrack {
|
|||
) -> VideoTrack {
|
||||
VideoTrack {
|
||||
reflector_: Reflector::new(),
|
||||
id: id.into(),
|
||||
kind: kind.into(),
|
||||
label: label.into(),
|
||||
language: language.into(),
|
||||
id,
|
||||
kind,
|
||||
label,
|
||||
language,
|
||||
selected: Cell::new(false),
|
||||
track_list: DomRefCell::new(track_list.map(|t| Dom::from_ref(t))),
|
||||
track_list: DomRefCell::new(track_list.map(Dom::from_ref)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ impl VideoTrack {
|
|||
}
|
||||
|
||||
pub fn selected(&self) -> bool {
|
||||
self.selected.get().clone()
|
||||
self.selected.get()
|
||||
}
|
||||
|
||||
pub fn set_selected(&self, value: bool) {
|
||||
|
|
|
@ -32,7 +32,7 @@ impl VideoTrackList {
|
|||
VideoTrackList {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
tracks: DomRefCell::new(tracks.iter().map(|track| Dom::from_ref(&**track)).collect()),
|
||||
media_element: media_element.map(|m| Dom::from_ref(m)),
|
||||
media_element: media_element.map(Dom::from_ref),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ impl VideoTrackListMethods for VideoTrackList {
|
|||
if let Some(idx) = self.selected_index() {
|
||||
return idx as i32;
|
||||
}
|
||||
return -1;
|
||||
-1
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#handler-tracklist-onchange
|
||||
|
|
|
@ -1151,7 +1151,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
constants::FRAMEBUFFER | constants::DRAW_FRAMEBUFFER => {
|
||||
self.base.get_draw_framebuffer_slot()
|
||||
},
|
||||
constants::READ_FRAMEBUFFER => &self.base.get_read_framebuffer_slot(),
|
||||
constants::READ_FRAMEBUFFER => self.base.get_read_framebuffer_slot(),
|
||||
_ => {
|
||||
self.base.webgl_error(InvalidEnum);
|
||||
return NullValue();
|
||||
|
@ -1164,14 +1164,14 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
handle_potential_webgl_error!(
|
||||
self.base,
|
||||
self.get_specific_fb_attachment_param(cx, &fb, target, attachment, pname),
|
||||
return NullValue()
|
||||
NullValue()
|
||||
)
|
||||
} else {
|
||||
// The default framebuffer is bound to the target
|
||||
handle_potential_webgl_error!(
|
||||
self.base,
|
||||
self.get_default_fb_attachment_param(attachment, pname),
|
||||
return NullValue()
|
||||
NullValue()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1243,7 +1243,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
},
|
||||
_ => return self.base.BindBuffer(target, buffer),
|
||||
};
|
||||
self.base.bind_buffer_maybe(&slot, target, buffer);
|
||||
self.base.bind_buffer_maybe(slot, target, buffer);
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6>
|
||||
|
@ -1264,14 +1264,14 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
self.base.bind_framebuffer_to(
|
||||
target,
|
||||
framebuffer,
|
||||
&self.base.get_read_framebuffer_slot(),
|
||||
self.base.get_read_framebuffer_slot(),
|
||||
);
|
||||
}
|
||||
if bind_draw {
|
||||
self.base.bind_framebuffer_to(
|
||||
target,
|
||||
framebuffer,
|
||||
&self.base.get_draw_framebuffer_slot(),
|
||||
self.base.get_draw_framebuffer_slot(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1348,7 +1348,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
|
||||
let data_end = byte_offset + copy_bytes;
|
||||
let data: &[u8] = unsafe { &data.as_slice()[byte_offset..data_end] };
|
||||
handle_potential_webgl_error!(self.base, bound_buffer.buffer_data(target, &data, usage));
|
||||
handle_potential_webgl_error!(self.base, bound_buffer.buffer_data(target, data, usage));
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5>
|
||||
|
@ -1743,19 +1743,19 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
return;
|
||||
}
|
||||
self.current_vao().unbind_buffer(buffer);
|
||||
self.unbind_from(&self.base.array_buffer_slot(), &buffer);
|
||||
self.unbind_from(&self.bound_copy_read_buffer, &buffer);
|
||||
self.unbind_from(&self.bound_copy_write_buffer, &buffer);
|
||||
self.unbind_from(&self.bound_pixel_pack_buffer, &buffer);
|
||||
self.unbind_from(&self.bound_pixel_unpack_buffer, &buffer);
|
||||
self.unbind_from(&self.bound_transform_feedback_buffer, &buffer);
|
||||
self.unbind_from(&self.bound_uniform_buffer, &buffer);
|
||||
self.unbind_from(self.base.array_buffer_slot(), buffer);
|
||||
self.unbind_from(&self.bound_copy_read_buffer, buffer);
|
||||
self.unbind_from(&self.bound_copy_write_buffer, buffer);
|
||||
self.unbind_from(&self.bound_pixel_pack_buffer, buffer);
|
||||
self.unbind_from(&self.bound_pixel_unpack_buffer, buffer);
|
||||
self.unbind_from(&self.bound_transform_feedback_buffer, buffer);
|
||||
self.unbind_from(&self.bound_uniform_buffer, buffer);
|
||||
|
||||
for binding in self.indexed_uniform_buffer_bindings.iter() {
|
||||
self.unbind_from(&binding.buffer, &buffer);
|
||||
self.unbind_from(&binding.buffer, buffer);
|
||||
}
|
||||
for binding in self.indexed_transform_feedback_buffer_bindings.iter() {
|
||||
self.unbind_from(&binding.buffer, &buffer);
|
||||
self.unbind_from(&binding.buffer, buffer);
|
||||
}
|
||||
|
||||
buffer.mark_for_deletion(Operation::Infallible);
|
||||
|
@ -2941,12 +2941,16 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
) -> Fallible<()> {
|
||||
let pixel_unpack_buffer = match self.bound_pixel_unpack_buffer.get() {
|
||||
Some(pixel_unpack_buffer) => pixel_unpack_buffer,
|
||||
None => return Ok(self.base.webgl_error(InvalidOperation)),
|
||||
None => {
|
||||
self.base.webgl_error(InvalidOperation);
|
||||
return Ok(());
|
||||
},
|
||||
};
|
||||
|
||||
if let Some(tf_buffer) = self.bound_transform_feedback_buffer.get() {
|
||||
if pixel_unpack_buffer == tf_buffer {
|
||||
return Ok(self.base.webgl_error(InvalidOperation));
|
||||
self.base.webgl_error(InvalidOperation);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3013,7 +3017,8 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
source: ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement,
|
||||
) -> Fallible<()> {
|
||||
if self.bound_pixel_unpack_buffer.get().is_some() {
|
||||
return Ok(self.base.webgl_error(InvalidOperation));
|
||||
self.base.webgl_error(InvalidOperation);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let validator = TexImage2DValidator::new(
|
||||
|
@ -3082,11 +3087,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
src_offset: u32,
|
||||
) -> Fallible<()> {
|
||||
if self.bound_pixel_unpack_buffer.get().is_some() {
|
||||
return Ok(self.base.webgl_error(InvalidOperation));
|
||||
self.base.webgl_error(InvalidOperation);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if type_ == constants::FLOAT_32_UNSIGNED_INT_24_8_REV {
|
||||
return Ok(self.base.webgl_error(InvalidOperation));
|
||||
self.base.webgl_error(InvalidOperation);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let validator = TexImage2DValidator::new(
|
||||
|
@ -3122,7 +3129,8 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
let src_byte_offset = src_offset as usize * src_elem_size;
|
||||
|
||||
if src_data.len() <= src_byte_offset {
|
||||
return Ok(self.base.webgl_error(InvalidOperation));
|
||||
self.base.webgl_error(InvalidOperation);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let buff = IpcSharedMemory::from_bytes(unsafe { &src_data.as_slice()[src_byte_offset..] });
|
||||
|
@ -3142,7 +3150,8 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
};
|
||||
|
||||
if expected_byte_length as usize > buff.len() {
|
||||
return Ok(self.base.webgl_error(InvalidOperation));
|
||||
self.base.webgl_error(InvalidOperation);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let size = Size2D::new(width, height);
|
||||
|
@ -3212,7 +3221,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
constants::FRAMEBUFFER | constants::DRAW_FRAMEBUFFER => {
|
||||
self.base.get_draw_framebuffer_slot()
|
||||
},
|
||||
constants::READ_FRAMEBUFFER => &self.base.get_read_framebuffer_slot(),
|
||||
constants::READ_FRAMEBUFFER => self.base.get_read_framebuffer_slot(),
|
||||
_ => {
|
||||
self.base.webgl_error(InvalidEnum);
|
||||
return 0;
|
||||
|
@ -3246,7 +3255,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
constants::FRAMEBUFFER | constants::DRAW_FRAMEBUFFER => {
|
||||
self.base.get_draw_framebuffer_slot()
|
||||
},
|
||||
constants::READ_FRAMEBUFFER => &self.base.get_read_framebuffer_slot(),
|
||||
constants::READ_FRAMEBUFFER => self.base.get_read_framebuffer_slot(),
|
||||
_ => return self.base.webgl_error(InvalidEnum),
|
||||
};
|
||||
|
||||
|
@ -4411,7 +4420,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
}
|
||||
|
||||
if let Some(fb) = self.base.get_read_framebuffer_slot().get() {
|
||||
handle_potential_webgl_error!(self.base, fb.set_read_buffer(src), return)
|
||||
handle_potential_webgl_error!(self.base, fb.set_read_buffer(src))
|
||||
} else {
|
||||
match src {
|
||||
constants::NONE | constants::BACK => {},
|
||||
|
@ -4426,7 +4435,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
/// <https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.11>
|
||||
fn DrawBuffers(&self, buffers: Vec<u32>) {
|
||||
if let Some(fb) = self.base.get_draw_framebuffer_slot().get() {
|
||||
handle_potential_webgl_error!(self.base, fb.set_draw_buffers(buffers), return)
|
||||
handle_potential_webgl_error!(self.base, fb.set_draw_buffers(buffers))
|
||||
} else {
|
||||
if buffers.len() != 1 {
|
||||
return self.base.webgl_error(InvalidOperation);
|
||||
|
|
|
@ -215,13 +215,13 @@ impl WebGLExtensions {
|
|||
self.extensions
|
||||
.borrow()
|
||||
.iter()
|
||||
.filter(|ref v| {
|
||||
.filter(|v| {
|
||||
if let WebGLExtensionSpec::Specific(version) = v.1.spec() {
|
||||
if self.webgl_version != version {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
v.1.is_supported(&self)
|
||||
v.1.is_supported(self)
|
||||
})
|
||||
.map(|ref v| v.1.name())
|
||||
.collect()
|
||||
|
|
|
@ -62,10 +62,10 @@ impl WebGLFramebufferAttachment {
|
|||
fn root(&self) -> WebGLFramebufferAttachmentRoot {
|
||||
match *self {
|
||||
WebGLFramebufferAttachment::Renderbuffer(ref rb) => {
|
||||
WebGLFramebufferAttachmentRoot::Renderbuffer(DomRoot::from_ref(&rb))
|
||||
WebGLFramebufferAttachmentRoot::Renderbuffer(DomRoot::from_ref(rb))
|
||||
},
|
||||
WebGLFramebufferAttachment::Texture { ref texture, .. } => {
|
||||
WebGLFramebufferAttachmentRoot::Texture(DomRoot::from_ref(&texture))
|
||||
WebGLFramebufferAttachmentRoot::Texture(DomRoot::from_ref(texture))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ impl WebGLFramebuffer {
|
|||
let attachment = attachment.borrow();
|
||||
let constraints = color_constraints.clone();
|
||||
if let Err(errnum) =
|
||||
self.check_attachment_constraints(&*attachment, constraints, &mut fb_size)
|
||||
self.check_attachment_constraints(&attachment, constraints, &mut fb_size)
|
||||
{
|
||||
return self.status.set(errnum);
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ impl WebGLProgram {
|
|||
.active_attribs
|
||||
.borrow()
|
||||
.iter()
|
||||
.find(|attrib| attrib.name == &*name)
|
||||
.find(|attrib| attrib.name == *name)
|
||||
.map_or(-1, |attrib| attrib.location);
|
||||
Ok(location)
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ impl WebGLProgram {
|
|||
|
||||
let validation_errors = names
|
||||
.iter()
|
||||
.map(|name| validate_glsl_name(&name))
|
||||
.map(|name| validate_glsl_name(name))
|
||||
.collect::<Vec<_>>();
|
||||
let first_validation_error = validation_errors.iter().find(|result| result.is_err());
|
||||
if let Some(error) = first_validation_error {
|
||||
|
|
|
@ -137,7 +137,7 @@ where
|
|||
T: TypedArrayElementCreator,
|
||||
{
|
||||
rooted!(in(cx) let mut rval = ptr::null_mut::<JSObject>());
|
||||
<TypedArray<T, *mut JSObject>>::create(cx, CreateWith::Slice(&value), rval.handle_mut())
|
||||
<TypedArray<T, *mut JSObject>>::create(cx, CreateWith::Slice(value), rval.handle_mut())
|
||||
.unwrap();
|
||||
ObjectValue(rval.get())
|
||||
}
|
||||
|
@ -563,10 +563,10 @@ impl WebGLRenderingContext {
|
|||
|
||||
pub fn get_current_framebuffer_size(&self) -> Option<(i32, i32)> {
|
||||
match self.bound_draw_framebuffer.get() {
|
||||
Some(fb) => return fb.size(),
|
||||
Some(fb) => fb.size(),
|
||||
|
||||
// The window system framebuffer is bound
|
||||
None => return Some((self.DrawingBufferWidth(), self.DrawingBufferHeight())),
|
||||
None => Some((self.DrawingBufferWidth(), self.DrawingBufferHeight())),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -736,7 +736,7 @@ impl WebGLRenderingContext {
|
|||
|
||||
// NOTE: width and height are positive or zero due to validate()
|
||||
if height == 0 {
|
||||
return Ok(0);
|
||||
Ok(0)
|
||||
} else {
|
||||
// We need to be careful here to not count unpack
|
||||
// alignment at the end of the image, otherwise (for
|
||||
|
@ -744,7 +744,7 @@ impl WebGLRenderingContext {
|
|||
// GL_ALPHA/GL_UNSIGNED_BYTE texture would throw an error.
|
||||
let cpp = element_size * components / components_per_element;
|
||||
let stride = (width * cpp + unpacking_alignment - 1) & !(unpacking_alignment - 1);
|
||||
return Ok(stride * (height - 1) + width * cpp);
|
||||
Ok(stride * (height - 1) + width * cpp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2442,7 +2442,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
},
|
||||
_ => return self.webgl_error(InvalidEnum),
|
||||
};
|
||||
self.bind_buffer_maybe(&slot, target, buffer);
|
||||
self.bind_buffer_maybe(slot, target, buffer);
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||
|
@ -3074,7 +3074,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
Ok(ret) => Some(ret),
|
||||
Err(e) => {
|
||||
self.webgl_error(e);
|
||||
return None;
|
||||
None
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -3805,7 +3805,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
constants::FRONT | constants::BACK | constants::FRONT_AND_BACK => {
|
||||
self.send_command(WebGLCommand::StencilMaskSeparate(face, mask))
|
||||
},
|
||||
_ => return self.webgl_error(InvalidEnum),
|
||||
_ => self.webgl_error(InvalidEnum),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4258,7 +4258,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>,
|
||||
) -> ErrorResult {
|
||||
if !self.extension_manager.is_tex_type_enabled(data_type) {
|
||||
return Ok(self.webgl_error(InvalidEnum));
|
||||
self.webgl_error(InvalidEnum);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let validator = TexImage2DValidator::new(
|
||||
|
@ -4289,10 +4290,16 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
};
|
||||
|
||||
if !internal_format.compatible_data_types().contains(&data_type) {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
return {
|
||||
self.webgl_error(InvalidOperation);
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
if texture.is_immutable() {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
return {
|
||||
self.webgl_error(InvalidOperation);
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
|
||||
let unpacking_alignment = self.texture_unpacking_alignment.get();
|
||||
|
@ -4325,7 +4332,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
// type, and pixel storage parameters, generates an
|
||||
// INVALID_OPERATION error."
|
||||
if buff.len() < expected_byte_length as usize {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
return {
|
||||
self.webgl_error(InvalidOperation);
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
|
||||
let size = Size2D::new(width, height);
|
||||
|
@ -4372,7 +4382,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
source: TexImageSource,
|
||||
) -> ErrorResult {
|
||||
if !self.extension_manager.is_tex_type_enabled(data_type) {
|
||||
return Ok(self.webgl_error(InvalidEnum));
|
||||
self.webgl_error(InvalidEnum);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let pixels = match self.get_image_pixels(source)? {
|
||||
|
@ -4407,10 +4418,16 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
};
|
||||
|
||||
if !internal_format.compatible_data_types().contains(&data_type) {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
return {
|
||||
self.webgl_error(InvalidOperation);
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
if texture.is_immutable() {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
return {
|
||||
self.webgl_error(InvalidOperation);
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
|
||||
if !self.validate_filterable_texture(
|
||||
|
@ -4504,7 +4521,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
// type, and pixel storage parameters, generates an
|
||||
// INVALID_OPERATION error."
|
||||
if buff.len() < expected_byte_length as usize {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
return {
|
||||
self.webgl_error(InvalidOperation);
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
|
||||
self.tex_sub_image_2d(
|
||||
|
@ -4589,8 +4609,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
}
|
||||
|
||||
match self.bound_draw_framebuffer.get() {
|
||||
Some(fb) => return fb.check_status(),
|
||||
None => return constants::FRAMEBUFFER_COMPLETE,
|
||||
Some(fb) => fb.check_status(),
|
||||
None => constants::FRAMEBUFFER_COMPLETE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4959,7 +4979,7 @@ pub trait Size2DExt {
|
|||
|
||||
impl Size2DExt for Size2D<u32> {
|
||||
fn to_u64(&self) -> Size2D<u64> {
|
||||
return Size2D::new(self.width as u64, self.height as u64);
|
||||
Size2D::new(self.width as u64, self.height as u64)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,7 +431,7 @@ impl WebGLTexture {
|
|||
}
|
||||
|
||||
pub fn image_info_for_target(&self, target: &TexImageTarget, level: u32) -> Option<ImageInfo> {
|
||||
let face_index = self.face_index_for_target(&target);
|
||||
let face_index = self.face_index_for_target(target);
|
||||
self.image_info_at_face(face_index, level)
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ fn close_the_websocket_connection(
|
|||
code: code,
|
||||
reason: Some(reason),
|
||||
};
|
||||
let _ = task_source.queue_with_canceller(close_task, &canceller);
|
||||
let _ = task_source.queue_with_canceller(close_task, canceller);
|
||||
}
|
||||
|
||||
fn fail_the_websocket_connection(
|
||||
|
@ -97,7 +97,7 @@ fn fail_the_websocket_connection(
|
|||
code: Some(close_code::ABNORMAL),
|
||||
reason: None,
|
||||
};
|
||||
let _ = task_source.queue_with_canceller(close_task, &canceller);
|
||||
let _ = task_source.queue_with_canceller(close_task, canceller);
|
||||
}
|
||||
|
||||
#[dom_struct]
|
||||
|
|
|
@ -573,7 +573,7 @@ pub fn base64_btoa(input: DOMString) -> Fallible<DOMString> {
|
|||
let config =
|
||||
base64::engine::general_purpose::GeneralPurposeConfig::new().with_encode_padding(true);
|
||||
let engine = base64::engine::GeneralPurpose::new(&base64::alphabet::STANDARD, config);
|
||||
Ok(DOMString::from(engine.encode(&octets)))
|
||||
Ok(DOMString::from(engine.encode(octets)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ pub fn base64_atob(input: DOMString) -> Fallible<DOMString> {
|
|||
.with_decode_allow_trailing_bits(true);
|
||||
let engine = base64::engine::GeneralPurpose::new(&base64::alphabet::STANDARD, config);
|
||||
|
||||
let data = engine.decode(&input).map_err(|_| Error::InvalidCharacter)?;
|
||||
let data = engine.decode(input).map_err(|_| Error::InvalidCharacter)?;
|
||||
Ok(data.iter().map(|&b| b as char).collect::<String>().into())
|
||||
}
|
||||
|
||||
|
@ -790,7 +790,7 @@ impl WindowMethods for Window {
|
|||
});
|
||||
self.task_manager()
|
||||
.dom_manipulation_task_source()
|
||||
.queue(task, &self.upcast::<GlobalScope>())
|
||||
.queue(task, self.upcast::<GlobalScope>())
|
||||
.expect("Queuing window_close_browsing_context task to work");
|
||||
}
|
||||
}
|
||||
|
@ -1337,7 +1337,7 @@ impl WindowMethods for Window {
|
|||
init: RootedTraceableBox<RequestInit>,
|
||||
comp: InRealm,
|
||||
) -> Rc<Promise> {
|
||||
fetch::Fetch(&self.upcast(), input, init, comp)
|
||||
fetch::Fetch(self.upcast(), input, init, comp)
|
||||
}
|
||||
|
||||
fn TestRunner(&self) -> DomRoot<TestRunner> {
|
||||
|
@ -1540,7 +1540,7 @@ impl WindowMethods for Window {
|
|||
if a.1 == b.1 {
|
||||
// This can happen if an img has an id different from its name,
|
||||
// spec does not say which string to put first.
|
||||
a.0.cmp(&b.0)
|
||||
a.0.cmp(b.0)
|
||||
} else if a.1.upcast::<Node>().is_before(b.1.upcast::<Node>()) {
|
||||
cmp::Ordering::Less
|
||||
} else {
|
||||
|
@ -1594,7 +1594,7 @@ impl Window {
|
|||
let target_origin = match target_origin.0[..].as_ref() {
|
||||
"*" => None,
|
||||
"/" => Some(source_origin.clone()),
|
||||
url => match ServoUrl::parse(&url) {
|
||||
url => match ServoUrl::parse(url) {
|
||||
Ok(url) => Some(url.origin().clone()),
|
||||
Err(_) => return Err(Error::Syntax),
|
||||
},
|
||||
|
@ -2188,14 +2188,14 @@ impl Window {
|
|||
#[allow(unsafe_code)]
|
||||
pub fn init_window_proxy(&self, window_proxy: &WindowProxy) {
|
||||
assert!(self.window_proxy.get().is_none());
|
||||
self.window_proxy.set(Some(&window_proxy));
|
||||
self.window_proxy.set(Some(window_proxy));
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn init_document(&self, document: &Document) {
|
||||
assert!(self.document.get().is_none());
|
||||
assert!(document.window() == self);
|
||||
self.document.set(Some(&document));
|
||||
self.document.set(Some(document));
|
||||
if !self.unminify_js {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ impl WindowProxy {
|
|||
SetProxyReservedSlot(
|
||||
js_proxy.get(),
|
||||
0,
|
||||
&PrivateValue((&*window_proxy).as_void_ptr()),
|
||||
&PrivateValue((*window_proxy).as_void_ptr()),
|
||||
);
|
||||
|
||||
// Notify the JS engine about the new window proxy binding.
|
||||
|
@ -459,7 +459,7 @@ impl WindowProxy {
|
|||
}
|
||||
rooted!(in(cx) let mut val = UndefinedValue());
|
||||
unsafe { opener_proxy.to_jsval(cx, val.handle_mut()) };
|
||||
return val.get();
|
||||
val.get()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#window-open-steps
|
||||
|
@ -1036,7 +1036,7 @@ unsafe extern "C" fn get_prototype_if_ordinary(
|
|||
// non-wrapper object *must* report non-ordinary, even if static [[Prototype]]
|
||||
// usually means ordinary.
|
||||
*is_ordinary = false;
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
static PROXY_HANDLER: ProxyTraps = ProxyTraps {
|
||||
|
|
|
@ -275,7 +275,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
|||
let (url, source) = match fetch::load_whole_resource(
|
||||
request,
|
||||
&global_scope.resource_threads().sender(),
|
||||
&global_scope,
|
||||
global_scope,
|
||||
) {
|
||||
Err(_) => return Err(Error::Network),
|
||||
Ok((metadata, bytes)) => (metadata.final_url, String::from_utf8(bytes).unwrap()),
|
||||
|
@ -467,7 +467,7 @@ impl WorkerGlobalScope {
|
|||
let dedicated = self.downcast::<DedicatedWorkerGlobalScope>();
|
||||
let service_worker = self.downcast::<ServiceWorkerGlobalScope>();
|
||||
if let Some(dedicated) = dedicated {
|
||||
return dedicated.script_chan();
|
||||
dedicated.script_chan()
|
||||
} else if let Some(service_worker) = service_worker {
|
||||
return service_worker.script_chan();
|
||||
} else {
|
||||
|
@ -510,7 +510,7 @@ impl WorkerGlobalScope {
|
|||
pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) {
|
||||
let dedicated = self.downcast::<DedicatedWorkerGlobalScope>();
|
||||
if let Some(dedicated) = dedicated {
|
||||
return dedicated.new_script_pair();
|
||||
dedicated.new_script_pair()
|
||||
} else {
|
||||
panic!("need to implement a sender for SharedWorker/ServiceWorker")
|
||||
}
|
||||
|
|
|
@ -698,7 +698,7 @@ impl WorkletThread {
|
|||
fn perform_a_worklet_task(&self, worklet_id: WorkletId, task: WorkletTask) {
|
||||
match self.global_scopes.get(&worklet_id) {
|
||||
Some(global) => global.perform_a_worklet_task(task),
|
||||
None => return warn!("No such worklet as {:?}.", worklet_id),
|
||||
None => warn!("No such worklet as {:?}.", worklet_id),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ impl WorkletThread {
|
|||
let global =
|
||||
self.get_worklet_global_scope(pipeline_id, worklet_id, global_type, base_url);
|
||||
self.fetch_and_invoke_a_worklet_script(
|
||||
&*global,
|
||||
&global,
|
||||
pipeline_id,
|
||||
origin,
|
||||
script_url,
|
||||
|
|
|
@ -463,7 +463,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
let value = trim_http_whitespace(&value);
|
||||
|
||||
// Step 4
|
||||
if !is_token(&name) || !is_field_value(&value) {
|
||||
if !is_token(&name) || !is_field_value(value) {
|
||||
return Err(Error::Syntax);
|
||||
}
|
||||
let name_lower = name.to_lower();
|
||||
|
@ -578,7 +578,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
// Step 4 (first half)
|
||||
let mut extracted_or_serialized = match data {
|
||||
Some(DocumentOrXMLHttpRequestBodyInit::Document(ref doc)) => {
|
||||
let bytes = Vec::from(serialize_document(&doc)?.as_ref());
|
||||
let bytes = Vec::from(serialize_document(doc)?.as_ref());
|
||||
let content_type = if doc.is_html_document() {
|
||||
"text/html;charset=UTF-8"
|
||||
} else {
|
||||
|
@ -1436,7 +1436,7 @@ impl XMLHttpRequest {
|
|||
|
||||
// Step 12
|
||||
self.response_xml.set(Some(&temp_doc));
|
||||
return self.response_xml.get();
|
||||
self.response_xml.get()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -1620,7 +1620,7 @@ impl XMLHttpRequest {
|
|||
// 8. Return encoding.
|
||||
override_charset
|
||||
.or(response_charset)
|
||||
.and_then(|charset| Encoding::for_label(&charset.as_bytes()))
|
||||
.and_then(|charset| Encoding::for_label(charset.as_bytes()))
|
||||
}
|
||||
|
||||
/// <https://xhr.spec.whatwg.org/#response-mime-type>
|
||||
|
@ -1641,7 +1641,7 @@ impl XMLHttpRequest {
|
|||
if self.override_mime_type.borrow().is_some() {
|
||||
self.override_mime_type.borrow().clone()
|
||||
} else {
|
||||
return self.response_mime_type();
|
||||
self.response_mime_type()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ impl XRInputSourceMethods for XRInputSource {
|
|||
if self.info.supports_grip {
|
||||
Some(self.grip_space.or_init(|| {
|
||||
let global = self.global();
|
||||
XRSpace::new_inputspace(&global, &self.session, &self, true)
|
||||
XRSpace::new_inputspace(&global, &self.session, self, true)
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
|
@ -125,7 +125,7 @@ impl XRInputSourceMethods for XRInputSource {
|
|||
if let Some(ref hand) = self.info.hand_support {
|
||||
Some(
|
||||
self.hand
|
||||
.or_init(|| XRHand::new(&self.global(), &self, hand.clone())),
|
||||
.or_init(|| XRHand::new(&self.global(), self, hand.clone())),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -46,7 +46,7 @@ impl XRInputSourceArray {
|
|||
input_sources.iter().find(|i| i.id() == info.id).is_none(),
|
||||
"Should never add a duplicate input id!"
|
||||
);
|
||||
let input = XRInputSource::new(&global, &session, info.clone());
|
||||
let input = XRInputSource::new(&global, session, info.clone());
|
||||
input_sources.push(Dom::from_ref(&input));
|
||||
added.push(input);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ impl XRInputSourceArray {
|
|||
&[]
|
||||
};
|
||||
input_sources.retain(|i| i.id() != id);
|
||||
let input = XRInputSource::new(&global, &session, info);
|
||||
let input = XRInputSource::new(&global, session, info);
|
||||
input_sources.push(Dom::from_ref(&input));
|
||||
|
||||
let added = [input];
|
||||
|
|
|
@ -55,7 +55,7 @@ impl XRReferenceSpace {
|
|||
offset: &XRRigidTransform,
|
||||
) -> DomRoot<XRReferenceSpace> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRReferenceSpace::new_inherited(session, &offset, ty)),
|
||||
Box::new(XRReferenceSpace::new_inherited(session, offset, ty)),
|
||||
global,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ impl XRSessionEvent {
|
|||
session: &XRSession,
|
||||
) -> DomRoot<XRSessionEvent> {
|
||||
let trackevent = reflect_dom_object_with_proto(
|
||||
Box::new(XRSessionEvent::new_inherited(&session)),
|
||||
Box::new(XRSessionEvent::new_inherited(session)),
|
||||
global,
|
||||
proto,
|
||||
);
|
||||
|
|
|
@ -72,7 +72,7 @@ impl XRTestMethods for XRTest {
|
|||
let p = Promise::new(&global);
|
||||
|
||||
let origin = if let Some(ref o) = init.viewerOrigin {
|
||||
match get_origin(&o) {
|
||||
match get_origin(o) {
|
||||
Ok(origin) => Some(origin),
|
||||
Err(e) => {
|
||||
p.reject_error(e);
|
||||
|
|
|
@ -57,7 +57,7 @@ impl XRView {
|
|||
viewport_index: usize,
|
||||
to_base: &BaseTransform,
|
||||
) -> DomRoot<XRView> {
|
||||
let transform: RigidTransform3D<f32, V, BaseSpace> = view.transform.then(&to_base);
|
||||
let transform: RigidTransform3D<f32, V, BaseSpace> = view.transform.then(to_base);
|
||||
let transform = XRRigidTransform::new(global, cast_transform(transform));
|
||||
|
||||
reflect_dom_object(
|
||||
|
|
|
@ -54,45 +54,26 @@ impl XRViewerPose {
|
|||
0,
|
||||
&to_base,
|
||||
)),
|
||||
Views::Mono(view) => views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&view,
|
||||
XREye::None,
|
||||
0,
|
||||
&to_base,
|
||||
)),
|
||||
Views::Mono(view) => {
|
||||
views.push(XRView::new(global, session, view, XREye::None, 0, &to_base))
|
||||
},
|
||||
Views::Stereo(left, right) => {
|
||||
views.push(XRView::new(global, session, left, XREye::Left, 0, &to_base));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&left,
|
||||
XREye::Left,
|
||||
0,
|
||||
&to_base,
|
||||
));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&right,
|
||||
right,
|
||||
XREye::Right,
|
||||
1,
|
||||
&to_base,
|
||||
));
|
||||
},
|
||||
Views::StereoCapture(left, right, third_eye) => {
|
||||
views.push(XRView::new(global, session, left, XREye::Left, 0, &to_base));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&left,
|
||||
XREye::Left,
|
||||
0,
|
||||
&to_base,
|
||||
));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&right,
|
||||
right,
|
||||
XREye::Right,
|
||||
1,
|
||||
&to_base,
|
||||
|
@ -100,7 +81,7 @@ impl XRViewerPose {
|
|||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&third_eye,
|
||||
third_eye,
|
||||
XREye::None,
|
||||
2,
|
||||
&to_base,
|
||||
|
@ -110,44 +91,30 @@ impl XRViewerPose {
|
|||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&front,
|
||||
front,
|
||||
XREye::None,
|
||||
0,
|
||||
&to_base,
|
||||
));
|
||||
views.push(XRView::new(global, session, left, XREye::None, 1, &to_base));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&left,
|
||||
XREye::None,
|
||||
1,
|
||||
&to_base,
|
||||
));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&right,
|
||||
right,
|
||||
XREye::None,
|
||||
2,
|
||||
&to_base,
|
||||
));
|
||||
views.push(XRView::new(global, session, &top, XREye::None, 3, &to_base));
|
||||
views.push(XRView::new(global, session, top, XREye::None, 3, &to_base));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&bottom,
|
||||
bottom,
|
||||
XREye::None,
|
||||
4,
|
||||
&to_base,
|
||||
));
|
||||
views.push(XRView::new(
|
||||
global,
|
||||
session,
|
||||
&back,
|
||||
XREye::None,
|
||||
5,
|
||||
&to_base,
|
||||
));
|
||||
views.push(XRView::new(global, session, back, XREye::None, 5, &to_base));
|
||||
},
|
||||
};
|
||||
let transform: RigidTransform3D<f32, Viewer, BaseSpace> =
|
||||
|
|
|
@ -165,7 +165,7 @@ impl XRWebGLLayer {
|
|||
}
|
||||
|
||||
pub fn session(&self) -> &XRSession {
|
||||
&self.xr_layer.session()
|
||||
self.xr_layer.session()
|
||||
}
|
||||
|
||||
pub fn size(&self) -> Size2D<u32, Viewport> {
|
||||
|
|
|
@ -154,7 +154,7 @@ impl ModuleIdentity {
|
|||
},
|
||||
ModuleIdentity::ScriptId(script_id) => {
|
||||
let inline_module_map = global.get_inline_module_map().borrow();
|
||||
inline_module_map.get(&script_id).unwrap().clone()
|
||||
inline_module_map.get(script_id).unwrap().clone()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ impl ModuleTree {
|
|||
}
|
||||
|
||||
let all_ready_descendants = ModuleTree::recursive_check_descendants(
|
||||
&descendant_module,
|
||||
descendant_module,
|
||||
module_map,
|
||||
discovered_urls,
|
||||
);
|
||||
|
@ -322,14 +322,14 @@ impl ModuleTree {
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
fn has_all_ready_descendants(&self, global: &GlobalScope) -> bool {
|
||||
let module_map = global.get_module_map().borrow();
|
||||
let mut discovered_urls = HashSet::new();
|
||||
|
||||
return ModuleTree::recursive_check_descendants(&self, &module_map.0, &mut discovered_urls);
|
||||
ModuleTree::recursive_check_descendants(&self, &module_map.0, &mut discovered_urls)
|
||||
}
|
||||
|
||||
// We just leverage the power of Promise to run the task for `finish` the owner.
|
||||
|
@ -460,7 +460,7 @@ impl ModuleTree {
|
|||
debug!("module script of {} compile done", url);
|
||||
|
||||
self.resolve_requested_module_specifiers(
|
||||
&global,
|
||||
global,
|
||||
module_script.handle().into_handle(),
|
||||
url.clone(),
|
||||
)
|
||||
|
@ -584,7 +584,7 @@ impl ModuleTree {
|
|||
|
||||
if url.is_err() {
|
||||
let specifier_error =
|
||||
gen_type_error(&global, "Wrong module specifier".to_owned());
|
||||
gen_type_error(global, "Wrong module specifier".to_owned());
|
||||
|
||||
return Err(specifier_error);
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ impl ModuleTree {
|
|||
}
|
||||
|
||||
// Step 3.
|
||||
return ServoUrl::parse_with_base(Some(url), &specifier_str.clone());
|
||||
ServoUrl::parse_with_base(Some(url), &specifier_str.clone())
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#finding-the-first-parse-error>
|
||||
|
@ -663,7 +663,7 @@ impl ModuleTree {
|
|||
|
||||
// 8-3.
|
||||
let (child_network_error, child_parse_error) =
|
||||
descendant_module.find_first_parse_error(&global, discovered_urls);
|
||||
descendant_module.find_first_parse_error(global, discovered_urls);
|
||||
|
||||
// Due to network error's priority higher than parse error,
|
||||
// we will return directly when we meet a network error.
|
||||
|
@ -682,7 +682,7 @@ impl ModuleTree {
|
|||
}
|
||||
|
||||
// Step 9.
|
||||
return (None, parse_error);
|
||||
(None, parse_error)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -790,7 +790,7 @@ impl ModuleTree {
|
|||
/// step 4-7.
|
||||
fn advance_finished_and_link(&self, global: &GlobalScope) {
|
||||
{
|
||||
if !self.has_all_ready_descendants(&global) {
|
||||
if !self.has_all_ready_descendants(global) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ impl ModuleTree {
|
|||
// fetches, then it means we don't need to notify it.
|
||||
let parent_identities = self.parent_identities.borrow();
|
||||
for parent_identity in parent_identities.iter() {
|
||||
let parent_tree = parent_identity.get_module_tree(&global);
|
||||
let parent_tree = parent_identity.get_module_tree(global);
|
||||
|
||||
let incomplete_count_before_remove = {
|
||||
let incomplete_urls = parent_tree.get_incomplete_fetch_urls().borrow();
|
||||
|
@ -815,14 +815,14 @@ impl ModuleTree {
|
|||
|
||||
if incomplete_count_before_remove > 0 {
|
||||
parent_tree.remove_incomplete_fetch_url(self.url.clone());
|
||||
parent_tree.advance_finished_and_link(&global);
|
||||
parent_tree.advance_finished_and_link(global);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut discovered_urls: HashSet<ServoUrl> = HashSet::new();
|
||||
let (network_error, rethrow_error) =
|
||||
self.find_first_parse_error(&global, &mut discovered_urls);
|
||||
self.find_first_parse_error(global, &mut discovered_urls);
|
||||
|
||||
match (network_error, rethrow_error) {
|
||||
(Some(network_error), _) => {
|
||||
|
@ -831,7 +831,7 @@ impl ModuleTree {
|
|||
(None, None) => {
|
||||
let module_record = self.get_record().borrow();
|
||||
if let Some(record) = &*module_record {
|
||||
let instantiated = self.instantiate_module_tree(&global, record.handle());
|
||||
let instantiated = self.instantiate_module_tree(global, record.handle());
|
||||
|
||||
if let Err(exception) = instantiated {
|
||||
self.set_rethrow_error(exception);
|
||||
|
@ -931,9 +931,9 @@ impl ModuleOwner {
|
|||
.upcast::<Element>()
|
||||
.has_attribute(&local_name!("async"));
|
||||
|
||||
if !asynch && (&*script.root()).get_parser_inserted() {
|
||||
if !asynch && (*script.root()).get_parser_inserted() {
|
||||
document.deferred_script_loaded(&*script.root(), load);
|
||||
} else if !asynch && !(&*script.root()).get_non_blocking() {
|
||||
} else if !asynch && !(*script.root()).get_non_blocking() {
|
||||
document.asap_in_order_script_loaded(&*script.root(), load);
|
||||
} else {
|
||||
document.asap_script_loaded(&*script.root(), load);
|
||||
|
@ -1021,7 +1021,6 @@ impl ModuleOwner {
|
|||
warn!("failed to finish dynamic module import");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1343,7 @@ fn fetch_an_import_module_script_graph(
|
|||
// Step 2.
|
||||
if url.is_err() {
|
||||
let specifier_error =
|
||||
unsafe { gen_type_error(&global, "Wrong module specifier".to_owned()) };
|
||||
unsafe { gen_type_error(global, "Wrong module specifier".to_owned()) };
|
||||
return Err(specifier_error);
|
||||
}
|
||||
|
||||
|
|
|
@ -686,9 +686,7 @@ unsafe extern "C" fn get_size(obj: *mut JSObject) -> usize {
|
|||
let mut ops = MallocSizeOfOps::new(servo_allocator::usable_size, None, None);
|
||||
(v.malloc_size_of)(&mut ops, dom_object)
|
||||
},
|
||||
Err(_e) => {
|
||||
return 0;
|
||||
},
|
||||
Err(_e) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,7 +918,7 @@ impl StreamConsumer {
|
|||
pub fn consume_chunk(&self, stream: &[u8]) -> bool {
|
||||
unsafe {
|
||||
let stream_ptr = stream.as_ptr();
|
||||
return StreamConsumerConsumeChunk(self.0, stream_ptr, stream.len());
|
||||
StreamConsumerConsumeChunk(self.0, stream_ptr, stream.len())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1039,7 @@ unsafe extern "C" fn consume_stream(
|
|||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
|
@ -299,7 +299,7 @@ impl QueuedTaskConversion for MainThreadScriptMsg {
|
|||
};
|
||||
match script_msg {
|
||||
CommonScriptMsg::Task(_category, _boxed, _pipeline_id, task_source) => {
|
||||
Some(&task_source)
|
||||
Some(task_source)
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ impl ScriptChan for SendableMainThreadScriptChan {
|
|||
}
|
||||
|
||||
fn clone(&self) -> Box<dyn ScriptChan + Send> {
|
||||
Box::new(SendableMainThreadScriptChan((&self.0).clone()))
|
||||
Box::new(SendableMainThreadScriptChan((self.0).clone()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ impl ScriptChan for MainThreadScriptChan {
|
|||
}
|
||||
|
||||
fn clone(&self) -> Box<dyn ScriptChan + Send> {
|
||||
Box::new(MainThreadScriptChan((&self.0).clone()))
|
||||
Box::new(MainThreadScriptChan((self.0).clone()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -907,7 +907,7 @@ impl ScriptThread {
|
|||
pub fn is_mutation_observer_microtask_queued() -> bool {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
return script_thread.mutation_observer_microtask_queued.get();
|
||||
script_thread.mutation_observer_microtask_queued.get()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2183,7 +2183,7 @@ impl ScriptThread {
|
|||
match msg {
|
||||
DevtoolScriptControlMsg::EvaluateJS(id, s, reply) => match documents.find_window(id) {
|
||||
Some(window) => devtools::handle_evaluate_js(window.upcast(), s, reply),
|
||||
None => return warn!("Message sent to closed pipeline {}.", id),
|
||||
None => warn!("Message sent to closed pipeline {}.", id),
|
||||
},
|
||||
DevtoolScriptControlMsg::GetRootNode(id, reply) => {
|
||||
devtools::handle_get_root_node(&*documents, id, reply)
|
||||
|
@ -2659,7 +2659,7 @@ impl ScriptThread {
|
|||
) {
|
||||
let window = self.documents.borrow().find_window(pipeline_id);
|
||||
match window {
|
||||
None => return warn!("postMessage after target pipeline {} closed.", pipeline_id),
|
||||
None => warn!("postMessage after target pipeline {} closed.", pipeline_id),
|
||||
Some(window) => {
|
||||
// FIXME: synchronously talks to constellation.
|
||||
// send the required info as part of postmessage instead.
|
||||
|
@ -3811,7 +3811,7 @@ impl ScriptThread {
|
|||
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
||||
if size_type == WindowSizeType::Resize {
|
||||
let uievent = UIEvent::new(
|
||||
&window,
|
||||
window,
|
||||
DOMString::from("resize"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable,
|
||||
|
@ -4003,13 +4003,13 @@ impl ScriptThread {
|
|||
let window = self.documents.borrow().find_window(pipeline_id);
|
||||
if let Some(window) = window {
|
||||
let entry = PerformancePaintTiming::new(
|
||||
&window.upcast::<GlobalScope>(),
|
||||
window.upcast::<GlobalScope>(),
|
||||
metric_type,
|
||||
metric_value,
|
||||
);
|
||||
window
|
||||
.Performance()
|
||||
.queue_entry(&entry.upcast::<PerformanceEntry>());
|
||||
.queue_entry(entry.upcast::<PerformanceEntry>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ impl ServiceWorkerManager {
|
|||
|
||||
pub fn get_matching_scope(&self, load_url: &ServoUrl) -> Option<ServoUrl> {
|
||||
for scope in self.registrations.keys() {
|
||||
if longest_prefix_match(&scope, load_url) {
|
||||
if longest_prefix_match(scope, load_url) {
|
||||
return Some(scope.clone());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ impl FetchResponseListener for StylesheetContext {
|
|||
},
|
||||
StylesheetContextSource::Import(ref stylesheet) => {
|
||||
Stylesheet::update_from_bytes(
|
||||
&stylesheet,
|
||||
stylesheet,
|
||||
&data,
|
||||
protocol_encoding_label,
|
||||
Some(environment_encoding),
|
||||
|
|
|
@ -220,7 +220,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
|
|||
(false, false) => {
|
||||
// Cycle through non-priority task sources, taking one throttled task from each.
|
||||
let task_source = task_source_cycler.next().unwrap();
|
||||
let throttled_queue = match throttled.get_mut(&task_source) {
|
||||
let throttled_queue = match throttled.get_mut(task_source) {
|
||||
Some(queue) => queue,
|
||||
None => continue,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue