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