diff options
Diffstat (limited to 'components/script/dom')
27 files changed, 338 insertions, 162 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index e497e9a5725..51c29764125 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5186,6 +5186,14 @@ class CGDictionary(CGThing): " }\n" "}\n" "\n" + "impl FromJSValConvertible for ${selfName} {\n" + " type Config = ();\n" + " unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())\n" + " -> Result<${selfName}, ()> {\n" + " ${selfName}::new(cx, value)\n" + " }\n" + "}\n" + "\n" "impl ToJSValConvertible for ${selfName} {\n" " unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {\n" " let obj = RootedObject::new(cx, JS_NewObject(cx, ptr::null()));\n" diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 7bfb6978ee6..2491058750c 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -29,7 +29,6 @@ //! The `no_jsmanaged_fields!()` macro adds an empty implementation of `JSTraceable` to //! a datatype. -use canvas_traits::WebGLError; use canvas_traits::{CanvasGradientStop, LinearGradientStyle, RadialGradientStyle}; use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle, RepetitionStyle}; use cssparser::RGBA; @@ -91,7 +90,7 @@ use style::values::specified::Length; use url::Url; use util::str::{DOMString, LengthOrPercentageOrAuto}; use uuid::Uuid; - +use webrender_traits::WebGLError; /// A trait to allow tracing (only) DOM objects. pub trait JSTraceable { diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index c63b657cd19..d04ea7f11de 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -32,7 +32,6 @@ use script_thread::ScriptThreadEventCategory::WorkerEvent; use script_thread::{ScriptThread, ScriptChan, ScriptPort, StackRootTLS, CommonScriptMsg}; use script_traits::{TimerEvent, TimerSource}; use std::mem::replace; -use std::rc::Rc; use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel}; use url::Url; use util::str::DOMString; @@ -95,10 +94,11 @@ impl ScriptChan for WorkerThreadWorkerChan { } impl ScriptPort for Receiver<(TrustedWorkerAddress, WorkerScriptMsg)> { - fn recv(&self) -> CommonScriptMsg { - match self.recv().unwrap().1 { - WorkerScriptMsg::Common(script_msg) => script_msg, - WorkerScriptMsg::DOMMessage(_) => panic!("unexpected worker event message!"), + fn recv(&self) -> Result<CommonScriptMsg, ()> { + match self.recv().map(|(_, msg)| msg) { + Ok(WorkerScriptMsg::Common(script_msg)) => Ok(script_msg), + Ok(WorkerScriptMsg::DOMMessage(_)) => panic!("unexpected worker event message!"), + Err(_) => Err(()), } } } @@ -158,7 +158,7 @@ impl DedicatedWorkerGlobalScope { worker_url: Url, id: PipelineId, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, - runtime: Rc<Runtime>, + runtime: Runtime, parent_sender: Box<ScriptChan + Send>, own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>, receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>, @@ -185,24 +185,25 @@ impl DedicatedWorkerGlobalScope { worker_url: Url, id: PipelineId, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, - runtime: Rc<Runtime>, + runtime: Runtime, parent_sender: Box<ScriptChan + Send>, own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>, receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>, timer_event_chan: IpcSender<TimerEvent>, timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>) -> Root<DedicatedWorkerGlobalScope> { + let cx = runtime.cx(); let scope = box DedicatedWorkerGlobalScope::new_inherited(init, worker_url, id, from_devtools_receiver, - runtime.clone(), + runtime, parent_sender, own_sender, receiver, timer_event_chan, timer_event_port); - DedicatedWorkerGlobalScopeBinding::Wrap(runtime.cx(), scope) + DedicatedWorkerGlobalScopeBinding::Wrap(cx, scope) } pub fn run_worker_scope(init: WorkerGlobalScopeInit, @@ -235,7 +236,7 @@ impl DedicatedWorkerGlobalScope { } }; - let runtime = Rc::new(ScriptThread::new_rt_and_cx()); + let runtime = ScriptThread::new_rt_and_cx(); let (devtools_mpsc_chan, devtools_mpsc_port) = channel(); ROUTER.route_ipc_receiver_to_mpsc_sender(from_devtools_receiver, devtools_mpsc_chan); @@ -249,7 +250,7 @@ impl DedicatedWorkerGlobalScope { }); let global = DedicatedWorkerGlobalScope::new( - init, url, id, devtools_mpsc_port, runtime.clone(), + init, url, id, devtools_mpsc_port, runtime, parent_sender.clone(), own_sender, receiver, timer_ipc_chan, timer_rx); // FIXME(njn): workers currently don't have a unique ID suitable for using in reporter diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index ddaebcd35bf..eb7e0da8a1b 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -69,6 +69,7 @@ use dom::nodelist::NodeList; use dom::processinginstruction::ProcessingInstruction; use dom::range::Range; use dom::servohtmlparser::{ParserRoot, ParserRef, MutNullableParserField}; +use dom::stylesheetlist::StyleSheetList; use dom::text::Text; use dom::touch::Touch; use dom::touchevent::TouchEvent; @@ -157,7 +158,7 @@ pub struct Document { anchors: MutNullableHeap<JS<HTMLCollection>>, applets: MutNullableHeap<JS<HTMLCollection>>, /// List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed. - stylesheets: DOMRefCell<Option<Vec<Arc<Stylesheet>>>>, + stylesheets: DOMRefCell<Option<Vec<(JS<Node>, Arc<Stylesheet>)>>>, /// Whether the list of stylesheets has changed since the last reflow was triggered. stylesheets_changed_since_reflow: Cell<bool>, ready_state: Cell<DocumentReadyState>, @@ -355,7 +356,7 @@ impl Document { // that workable. match self.GetDocumentElement() { Some(root) => { - root.upcast::<Node>().get_has_dirty_descendants() || + root.upcast::<Node>().has_dirty_descendants() || !self.modified_elements.borrow().is_empty() } None => false, @@ -1466,6 +1467,19 @@ impl Document { let target = node.upcast(); event.fire(target); } + + /// https://html.spec.whatwg.org/multipage/#cookie-averse-document-object + fn is_cookie_averse(&self) -> bool { + /// https://url.spec.whatwg.org/#network-scheme + fn url_has_network_scheme(url: &Url) -> bool { + match &*url.scheme { + "ftp" | "http" | "https" => true, + _ => false, + } + } + + self.browsing_context.is_none() || !url_has_network_scheme(&self.url) + } } #[derive(PartialEq, HeapSizeOf)] @@ -1635,11 +1649,11 @@ impl Document { } /// Returns the list of stylesheets associated with nodes in the document. - pub fn stylesheets(&self) -> Ref<Vec<Arc<Stylesheet>>> { + pub fn stylesheets(&self) -> Vec<Arc<Stylesheet>> { { let mut stylesheets = self.stylesheets.borrow_mut(); if stylesheets.is_none() { - let new_stylesheets: Vec<Arc<Stylesheet>> = self.upcast::<Node>() + *stylesheets = Some(self.upcast::<Node>() .traverse_preorder() .filter_map(|node| { if let Some(node) = node.downcast::<HTMLStyleElement>() { @@ -1650,13 +1664,14 @@ impl Document { node.get_stylesheet() } else { None - } + }.map(|stylesheet| (JS::from_rooted(&node), stylesheet)) }) - .collect(); - *stylesheets = Some(new_stylesheets); + .collect()); }; } - Ref::map(self.stylesheets.borrow(), |t| t.as_ref().unwrap()) + self.stylesheets.borrow().as_ref().unwrap().iter() + .map(|&(_, ref stylesheet)| stylesheet.clone()) + .collect() } /// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document @@ -1723,6 +1738,11 @@ impl Element { } impl DocumentMethods for Document { + // https://drafts.csswg.org/cssom/#dom-document-stylesheets + fn StyleSheets(&self) -> Root<StyleSheetList> { + StyleSheetList::new(&self.window, JS::from_ref(&self)) + } + // https://dom.spec.whatwg.org/#dom-document-implementation fn Implementation(&self) -> Root<DOMImplementation> { self.implementation.or_init(|| DOMImplementation::new(self)) @@ -1767,12 +1787,6 @@ impl DocumentMethods for Document { fn Domain(&self) -> DOMString { // TODO: This should use the effective script origin when it exists let origin = self.window.get_url(); - - if let Some(&Host::Ipv6(ipv6)) = origin.host() { - // Omit square brackets for IPv6 addresses. - return DOMString::from(ipv6.to_string()); - } - DOMString::from(origin.serialize_host().unwrap_or_else(|| "".to_owned())) } @@ -2396,7 +2410,10 @@ impl DocumentMethods for Document { // https://html.spec.whatwg.org/multipage/#dom-document-cookie fn GetCookie(&self) -> Fallible<DOMString> { - // TODO: return empty string for cookie-averse Document + if self.is_cookie_averse() { + return Ok(DOMString::new()); + } + let url = self.url(); if !is_scheme_host_port_tuple(&url) { return Err(Error::Security); @@ -2409,7 +2426,10 @@ impl DocumentMethods for Document { // https://html.spec.whatwg.org/multipage/#dom-document-cookie fn SetCookie(&self, cookie: DOMString) -> ErrorResult { - // TODO: ignore for cookie-averse Document + if self.is_cookie_averse() { + return Ok(()); + } + let url = self.url(); if !is_scheme_host_port_tuple(url) { return Err(Error::Security); diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 677f9acda0e..42fab95947a 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1431,7 +1431,7 @@ impl ElementMethods for Element { // https://drafts.csswg.org/cssom-view/#dom-element-getclientrects fn GetClientRects(&self) -> Root<DOMRectList> { let win = window_from_node(self); - let raw_rects = self.upcast::<Node>().get_content_boxes(); + let raw_rects = self.upcast::<Node>().content_boxes(); let rects = raw_rects.iter().map(|rect| { DOMRect::new(GlobalRef::Window(win.r()), rect.origin.x.to_f64_px(), @@ -1445,7 +1445,7 @@ impl ElementMethods for Element { // https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect fn GetBoundingClientRect(&self) -> Root<DOMRect> { let win = window_from_node(self); - let rect = self.upcast::<Node>().get_bounding_content_box(); + let rect = self.upcast::<Node>().bounding_content_box(); DOMRect::new(GlobalRef::Window(win.r()), rect.origin.x.to_f64_px(), rect.origin.y.to_f64_px(), @@ -1455,32 +1455,32 @@ impl ElementMethods for Element { // https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth fn ScrollWidth(&self) -> i32 { - self.upcast::<Node>().get_scroll_area().size.width + self.upcast::<Node>().scroll_area().size.width } // https://drafts.csswg.org/cssom-view/#dom-element-scrollheight fn ScrollHeight(&self) -> i32 { - self.upcast::<Node>().get_scroll_area().size.height + self.upcast::<Node>().scroll_area().size.height } // https://drafts.csswg.org/cssom-view/#dom-element-clienttop fn ClientTop(&self) -> i32 { - self.upcast::<Node>().get_client_rect().origin.y + self.upcast::<Node>().client_rect().origin.y } // https://drafts.csswg.org/cssom-view/#dom-element-clientleft fn ClientLeft(&self) -> i32 { - self.upcast::<Node>().get_client_rect().origin.x + self.upcast::<Node>().client_rect().origin.x } // https://drafts.csswg.org/cssom-view/#dom-element-clientwidth fn ClientWidth(&self) -> i32 { - self.upcast::<Node>().get_client_rect().size.width + self.upcast::<Node>().client_rect().size.width } // https://drafts.csswg.org/cssom-view/#dom-element-clientheight fn ClientHeight(&self) -> i32 { - self.upcast::<Node>().get_client_rect().size.height + self.upcast::<Node>().client_rect().size.height } /// https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 25e17586f9b..a7bf82ae50e 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -72,7 +72,7 @@ impl HTMLCollection { root: JS::from_ref(root), filter: filter, // Default values for the cache - cached_version: Cell::new(root.get_inclusive_descendants_version()), + cached_version: Cell::new(root.inclusive_descendants_version()), cached_cursor_element: MutNullableHeap::new(None), cached_cursor_index: Cell::new(OptionU32::none()), cached_length: Cell::new(OptionU32::none()), @@ -93,7 +93,7 @@ impl HTMLCollection { fn validate_cache(&self) { // Clear the cache if the root version is different from our cached version let cached_version = self.cached_version.get(); - let curr_version = self.root.get_inclusive_descendants_version(); + let curr_version = self.root.inclusive_descendants_version(); if curr_version != cached_version { // Default values for the cache self.cached_version.set(curr_version); diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index b6a43ad164f..73046e5230d 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -236,7 +236,7 @@ impl HTMLImageElementMethods for HTMLImageElement { // https://html.spec.whatwg.org/multipage/#dom-img-width fn Width(&self) -> u32 { let node = self.upcast::<Node>(); - let rect = node.get_bounding_content_box(); + let rect = node.bounding_content_box(); rect.size.width.to_px() as u32 } @@ -248,7 +248,7 @@ impl HTMLImageElementMethods for HTMLImageElement { // https://html.spec.whatwg.org/multipage/#dom-img-height fn Height(&self) -> u32 { let node = self.upcast::<Node>(); - let rect = node.get_bounding_content_box(); + let rect = node.bounding_content_box(); rect.size.height.to_px() as u32 } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index e14a91ae9d7..e2434d60759 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -200,6 +200,7 @@ impl HTMLInputElement { text_input.selection_begin = Some(text_input.get_text_point_for_absolute_point(start)); text_input.edit_point = text_input.get_text_point_for_absolute_point(end); self.selection_direction.set(*direction); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } } @@ -401,7 +402,7 @@ impl HTMLInputElementMethods for HTMLInputElement { } self.value_changed.set(true); - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); Ok(()) } @@ -586,11 +587,6 @@ fn in_same_group(other: &HTMLInputElement, owner: Option<&HTMLFormElement>, } impl HTMLInputElement { - fn force_relayout(&self) { - let doc = document_from_node(self); - doc.content_changed(self.upcast(), NodeDamage::OtherNodeDamage) - } - fn radio_group_updated(&self, group: Option<&Atom>) { if self.Checked() { broadcast_radio_checked(self, group); @@ -654,7 +650,7 @@ impl HTMLInputElement { self.get_radio_group_name().as_ref()); } - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); //TODO: dispatch change event } @@ -684,7 +680,7 @@ impl HTMLInputElement { .expect("Failed to reset input value to default."); self.value_dirty.set(false); self.value_changed.set(false); - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } } @@ -889,11 +885,11 @@ impl VirtualMethods for HTMLInputElement { ChangeEventRunnable::send(self.upcast::<Node>()); } - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } RedrawSelection => { - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } Nothing => (), diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 0f82919124f..50f34c9ff85 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -91,7 +91,10 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> { } } +// https://html.spec.whatwg.org/multipage/#attr-textarea-cols-value static DEFAULT_COLS: u32 = 20; + +// https://html.spec.whatwg.org/multipage/#attr-textarea-rows-value static DEFAULT_ROWS: u32 = 2; impl HTMLTextAreaElement { @@ -206,7 +209,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement { self.textinput.borrow_mut().set_content(value); self.value_changed.set(true); - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels @@ -230,13 +233,6 @@ impl HTMLTextAreaElement { } -impl HTMLTextAreaElement { - fn force_relayout(&self) { - let doc = document_from_node(self); - doc.content_changed(self.upcast(), NodeDamage::OtherNodeDamage) - } -} - impl VirtualMethods for HTMLTextAreaElement { fn super_type(&self) -> Option<&VirtualMethods> { Some(self.upcast::<HTMLElement>() as &VirtualMethods) @@ -321,11 +317,11 @@ impl VirtualMethods for HTMLTextAreaElement { ChangeEventRunnable::send(self.upcast::<Node>()); } - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } KeyReaction::RedrawSelection => { - self.force_relayout(); + self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } KeyReaction::Nothing => (), diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index ebb8fe91291..662f41dc7a9 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -359,6 +359,8 @@ pub mod servohtmlparser; pub mod servoxmlparser; pub mod storage; pub mod storageevent; +pub mod stylesheet; +pub mod stylesheetlist; pub mod testbinding; pub mod testbindingproxy; pub mod text; diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 730f69f24cd..39ad21a46b6 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -420,7 +420,7 @@ impl Node { self.flags.set(flags); } - pub fn get_has_changed(&self) -> bool { + pub fn has_changed(&self) -> bool { self.get_flag(HAS_CHANGED) } @@ -428,7 +428,7 @@ impl Node { self.set_flag(HAS_CHANGED, state) } - pub fn get_is_dirty(&self) -> bool { + pub fn is_dirty(&self) -> bool { self.get_flag(IS_DIRTY) } @@ -436,7 +436,7 @@ impl Node { self.set_flag(IS_DIRTY, state) } - pub fn get_has_dirty_descendants(&self) -> bool { + pub fn has_dirty_descendants(&self) -> bool { self.get_flag(HAS_DIRTY_DESCENDANTS) } @@ -454,7 +454,7 @@ impl Node { // the document's version, but we do have to deal with the case where the node has moved // document, so may have a higher version count than its owning document. let doc: Root<Node> = Root::upcast(self.owner_doc()); - let version = max(self.get_inclusive_descendants_version(), doc.get_inclusive_descendants_version()) + 1; + let version = max(self.inclusive_descendants_version(), doc.inclusive_descendants_version()) + 1; for ancestor in self.inclusive_ancestors() { ancestor.inclusive_descendants_version.set(version); } @@ -475,14 +475,14 @@ impl Node { NodeDamage::OtherNodeDamage => self.set_has_changed(true), } - if self.get_is_dirty() && !force_ancestors { + if self.is_dirty() && !force_ancestors { return } // 2. Dirty descendants. fn dirty_subtree(node: &Node) { // Stop if this subtree is already dirty. - if node.get_is_dirty() { return } + if node.is_dirty() { return } node.set_flag(IS_DIRTY | HAS_DIRTY_DESCENDANTS, true); @@ -495,13 +495,13 @@ impl Node { // 4. Dirty ancestors. for ancestor in self.ancestors() { - if !force_ancestors && ancestor.get_has_dirty_descendants() { break } + if !force_ancestors && ancestor.has_dirty_descendants() { break } ancestor.set_has_dirty_descendants(true); } } /// The maximum version number of this node's descendants, including itself - pub fn get_inclusive_descendants_version(&self) -> u64 { + pub fn inclusive_descendants_version(&self) -> u64 { self.inclusive_descendants_version.get() } @@ -570,15 +570,15 @@ impl Node { TrustedNodeAddress(&*self as *const Node as *const libc::c_void) } - pub fn get_bounding_content_box(&self) -> Rect<Au> { + pub fn bounding_content_box(&self) -> Rect<Au> { window_from_node(self).content_box_query(self.to_trusted_node_address()) } - pub fn get_content_boxes(&self) -> Vec<Rect<Au>> { + pub fn content_boxes(&self) -> Vec<Rect<Au>> { window_from_node(self).content_boxes_query(self.to_trusted_node_address()) } - pub fn get_client_rect(&self) -> Rect<i32> { + pub fn client_rect(&self) -> Rect<i32> { window_from_node(self).client_rect_query(self.to_trusted_node_address()) } @@ -586,7 +586,7 @@ impl Node { // https://drafts.csswg.org/cssom-view/#dom-element-scrollheight // https://drafts.csswg.org/cssom-view/#dom-element-scrolltop // https://drafts.csswg.org/cssom-view/#dom-element-scrollleft - pub fn get_scroll_area(&self) -> Rect<i32> { + pub fn scroll_area(&self) -> Rect<i32> { // Step 1 let document = self.owner_doc(); // Step 3 @@ -798,15 +798,15 @@ impl Node { } } - pub fn get_unique_id(&self) -> String { + pub fn unique_id(&self) -> String { self.unique_id.borrow().to_simple_string() } pub fn summarize(&self) -> NodeInfo { NodeInfo { - uniqueId: self.get_unique_id(), + uniqueId: self.unique_id(), baseURI: String::from(self.BaseURI()), - parent: self.GetParentNode().map_or("".to_owned(), |node| node.get_unique_id()), + parent: self.GetParentNode().map_or("".to_owned(), |node| node.unique_id()), nodeType: self.NodeType(), namespaceURI: String::new(), //FIXME nodeName: String::from(self.NodeName()), diff --git a/components/script/dom/stylesheet.rs b/components/script/dom/stylesheet.rs new file mode 100644 index 00000000000..490acd997ed --- /dev/null +++ b/components/script/dom/stylesheet.rs @@ -0,0 +1,60 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use dom::bindings::codegen::Bindings::StyleSheetBinding; +use dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods; +use dom::bindings::global::GlobalRef; +use dom::bindings::js::{Root}; +use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::window::Window; +use util::str::DOMString; + + +#[dom_struct] +pub struct StyleSheet { + reflector_: Reflector, + type_: DOMString, + href: Option<DOMString>, + title: Option<DOMString>, +} + +impl StyleSheet { + #[allow(unrooted_must_root)] + fn new_inherited(type_: DOMString, href: Option<DOMString>, title: Option<DOMString>) -> StyleSheet { + StyleSheet { + reflector_: Reflector::new(), + type_: type_, + href: href, + title: title + } + } + + #[allow(unrooted_must_root)] + pub fn new(window: &Window, type_: DOMString, + href: Option<DOMString>, + title: Option<DOMString>) -> Root<StyleSheet> { + reflect_dom_object(box StyleSheet::new_inherited(type_, href, title), + GlobalRef::Window(window), + StyleSheetBinding::Wrap) + } +} + + +impl StyleSheetMethods for StyleSheet { + // https://drafts.csswg.org/cssom/#dom-stylesheet-type + fn Type_(&self) -> DOMString { + self.type_.clone() + } + + // https://drafts.csswg.org/cssom/#dom-stylesheet-href + fn GetHref(&self) -> Option<DOMString> { + self.href.clone() + } + + // https://drafts.csswg.org/cssom/#dom-stylesheet-title + fn GetTitle(&self) -> Option<DOMString> { + self.title.clone() + } +} + diff --git a/components/script/dom/stylesheetlist.rs b/components/script/dom/stylesheetlist.rs new file mode 100644 index 00000000000..d6c58256dc2 --- /dev/null +++ b/components/script/dom/stylesheetlist.rs @@ -0,0 +1,54 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use dom::bindings::codegen::Bindings::StyleSheetListBinding; +use dom::bindings::codegen::Bindings::StyleSheetListBinding::StyleSheetListMethods; +use dom::bindings::global::GlobalRef; +use dom::bindings::js::{JS, Root}; +use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::document::Document; +use dom::stylesheet::StyleSheet; +use dom::window::Window; + +#[dom_struct] +pub struct StyleSheetList { + reflector_: Reflector, + document: JS<Document>, +} + +impl StyleSheetList { + #[allow(unrooted_must_root)] + fn new_inherited(doc: JS<Document>) -> StyleSheetList { + StyleSheetList { + reflector_: Reflector::new(), + document: doc + } + } + + #[allow(unrooted_must_root)] + pub fn new(window: &Window, document: JS<Document>) -> Root<StyleSheetList> { + reflect_dom_object(box StyleSheetList::new_inherited(document), + GlobalRef::Window(window), StyleSheetListBinding::Wrap) + } +} + +impl StyleSheetListMethods for StyleSheetList { + // https://drafts.csswg.org/cssom/#dom-stylesheetlist-length + fn Length(&self) -> u32 { + self.document.stylesheets().len() as u32 + } + + // https://drafts.csswg.org/cssom/#dom-stylesheetlist-item + fn Item(&self, index: u32) -> Option<Root<StyleSheet>> { + None + //TODO Create a new StyleSheet object and return it + } + + // check-tidy: no specs after this line + fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<StyleSheet>>{ + let item = self.Item(index); + *found = item.is_some(); + item + } +} diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index cfb9cdc4810..0fedc762f4c 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLError, WebGLResult}; +use canvas_traits::CanvasMsg; use dom::bindings::codegen::Bindings::WebGLBufferBinding; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; @@ -11,6 +11,7 @@ use dom::bindings::reflector::reflect_dom_object; use dom::webglobject::WebGLObject; use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; +use webrender_traits::{WebGLCommand, WebGLError, WebGLResult}; #[dom_struct] pub struct WebGLBuffer { @@ -39,7 +40,7 @@ impl WebGLBuffer { pub fn maybe_new(global: GlobalRef, renderer: IpcSender<CanvasMsg>) -> Option<Root<WebGLBuffer>> { let (sender, receiver) = ipc::channel().unwrap(); - renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CreateBuffer(sender))).unwrap(); + renderer.send(CanvasMsg::WebGL(WebGLCommand::CreateBuffer(sender))).unwrap(); let result = receiver.recv().unwrap(); result.map(|buffer_id| WebGLBuffer::new(global, renderer, *buffer_id)) @@ -65,7 +66,7 @@ impl WebGLBuffer { } else { self.target.set(Some(target)); } - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BindBuffer(target, self.id))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::BindBuffer(target, self.id))).unwrap(); Ok(()) } @@ -78,7 +79,7 @@ impl WebGLBuffer { } self.capacity.set(data.len()); self.renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BufferData(target, data.to_vec(), usage))) + .send(CanvasMsg::WebGL(WebGLCommand::BufferData(target, data.to_vec(), usage))) .unwrap(); Ok(()) @@ -91,7 +92,7 @@ impl WebGLBuffer { pub fn delete(&self) { if !self.is_deleted.get() { self.is_deleted.set(true); - let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteBuffer(self.id))); + let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteBuffer(self.id))); } } } diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 86ed0e61b30..9dc4d7c16be 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLFramebufferBindingRequest}; +use canvas_traits::{CanvasMsg}; use dom::bindings::codegen::Bindings::WebGLFramebufferBinding; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; @@ -11,6 +11,7 @@ use dom::bindings::reflector::reflect_dom_object; use dom::webglobject::WebGLObject; use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; +use webrender_traits::{WebGLCommand, WebGLFramebufferBindingRequest}; #[dom_struct] pub struct WebGLFramebuffer { @@ -34,7 +35,7 @@ impl WebGLFramebuffer { pub fn maybe_new(global: GlobalRef, renderer: IpcSender<CanvasMsg>) -> Option<Root<WebGLFramebuffer>> { let (sender, receiver) = ipc::channel().unwrap(); - renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CreateFramebuffer(sender))).unwrap(); + renderer.send(CanvasMsg::WebGL(WebGLCommand::CreateFramebuffer(sender))).unwrap(); let result = receiver.recv().unwrap(); result.map(|fb_id| WebGLFramebuffer::new(global, renderer, *fb_id)) @@ -53,14 +54,14 @@ impl WebGLFramebuffer { } pub fn bind(&self, target: u32) { - let cmd = CanvasWebGLMsg::BindFramebuffer(target, WebGLFramebufferBindingRequest::Explicit(self.id)); + let cmd = WebGLCommand::BindFramebuffer(target, WebGLFramebufferBindingRequest::Explicit(self.id)); self.renderer.send(CanvasMsg::WebGL(cmd)).unwrap(); } pub fn delete(&self) { if !self.is_deleted.get() { self.is_deleted.set(true); - let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteFramebuffer(self.id))); + let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteFramebuffer(self.id))); } } } diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 9df581f9afc..338a1e8d46b 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLError, WebGLResult, WebGLParameter}; +use canvas_traits::CanvasMsg; use dom::bindings::codegen::Bindings::WebGLProgramBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::global::GlobalRef; @@ -15,6 +15,7 @@ use dom::webglshader::WebGLShader; use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; use util::str::DOMString; +use webrender_traits::{WebGLCommand, WebGLError, WebGLParameter, WebGLResult}; #[dom_struct] pub struct WebGLProgram { @@ -42,7 +43,7 @@ impl WebGLProgram { pub fn maybe_new(global: GlobalRef, renderer: IpcSender<CanvasMsg>) -> Option<Root<WebGLProgram>> { let (sender, receiver) = ipc::channel().unwrap(); - renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CreateProgram(sender))).unwrap(); + renderer.send(CanvasMsg::WebGL(WebGLCommand::CreateProgram(sender))).unwrap(); let result = receiver.recv().unwrap(); result.map(|program_id| WebGLProgram::new(global, renderer, *program_id)) @@ -63,13 +64,13 @@ impl WebGLProgram { pub fn delete(&self) { if !self.is_deleted.get() { self.is_deleted.set(true); - let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteProgram(self.id))); + let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteProgram(self.id))); } } /// glLinkProgram pub fn link(&self) { - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::LinkProgram(self.id))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::LinkProgram(self.id))).unwrap(); } /// glUseProgram @@ -84,7 +85,7 @@ impl WebGLProgram { _ => return Err(WebGLError::InvalidOperation), } - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::UseProgram(self.id))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::UseProgram(self.id))).unwrap(); Ok(()) } @@ -104,7 +105,7 @@ impl WebGLProgram { shader_slot.set(Some(shader)); - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::AttachShader(self.id, shader.id()))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::AttachShader(self.id, shader.id()))).unwrap(); Ok(()) } @@ -121,7 +122,7 @@ impl WebGLProgram { } self.renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BindAttribLocation(self.id, index, String::from(name)))) + .send(CanvasMsg::WebGL(WebGLCommand::BindAttribLocation(self.id, index, String::from(name)))) .unwrap(); Ok(()) } @@ -139,7 +140,7 @@ impl WebGLProgram { let (sender, receiver) = ipc::channel().unwrap(); self.renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::GetAttribLocation(self.id, String::from(name), sender))) + .send(CanvasMsg::WebGL(WebGLCommand::GetAttribLocation(self.id, String::from(name), sender))) .unwrap(); Ok(receiver.recv().unwrap()) } @@ -157,7 +158,7 @@ impl WebGLProgram { let (sender, receiver) = ipc::channel().unwrap(); self.renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::GetUniformLocation(self.id, String::from(name), sender))) + .send(CanvasMsg::WebGL(WebGLCommand::GetUniformLocation(self.id, String::from(name), sender))) .unwrap(); Ok(receiver.recv().unwrap()) } @@ -165,7 +166,7 @@ impl WebGLProgram { /// glGetProgramParameter pub fn parameter(&self, param_id: u32) -> WebGLResult<WebGLParameter> { let (sender, receiver) = ipc::channel().unwrap(); - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::GetProgramParameter(self.id, param_id, sender))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::GetProgramParameter(self.id, param_id, sender))).unwrap(); receiver.recv().unwrap() } } diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 5257c4782a9..a63bd1c975a 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::{CanvasMsg, CanvasWebGLMsg}; +use canvas_traits::CanvasMsg; use dom::bindings::codegen::Bindings::WebGLRenderbufferBinding; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; @@ -11,6 +11,7 @@ use dom::bindings::reflector::reflect_dom_object; use dom::webglobject::WebGLObject; use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; +use webrender_traits::WebGLCommand; #[dom_struct] pub struct WebGLRenderbuffer { @@ -34,7 +35,7 @@ impl WebGLRenderbuffer { pub fn maybe_new(global: GlobalRef, renderer: IpcSender<CanvasMsg>) -> Option<Root<WebGLRenderbuffer>> { let (sender, receiver) = ipc::channel().unwrap(); - renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CreateRenderbuffer(sender))).unwrap(); + renderer.send(CanvasMsg::WebGL(WebGLCommand::CreateRenderbuffer(sender))).unwrap(); let result = receiver.recv().unwrap(); result.map(|renderbuffer_id| WebGLRenderbuffer::new(global, renderer, *renderbuffer_id)) @@ -53,13 +54,13 @@ impl WebGLRenderbuffer { } pub fn bind(&self, target: u32) { - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BindRenderbuffer(target, self.id))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::BindRenderbuffer(target, self.id))).unwrap(); } pub fn delete(&self) { if !self.is_deleted.get() { self.is_deleted.set(true); - let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteRenderbuffer(self.id))); + let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteRenderbuffer(self.id))); } } } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index c5070cca69e..e614b7afc6f 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use canvas_traits::WebGLError::*; -use canvas_traits::{CanvasCommonMsg, CanvasMsg, CanvasWebGLMsg, WebGLError}; -use canvas_traits::{WebGLFramebufferBindingRequest, WebGLParameter}; +use canvas_traits::{CanvasCommonMsg, CanvasMsg}; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{WebGLRenderingContextMethods}; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{self, WebGLContextAttributes}; @@ -37,6 +35,8 @@ use script_traits::ScriptMsg as ConstellationMsg; use std::cell::Cell; use util::str::DOMString; use util::vec::byte_swap; +use webrender_traits::WebGLError::*; +use webrender_traits::{WebGLCommand, WebGLError, WebGLFramebufferBindingRequest, WebGLParameter}; pub const MAX_UNIFORM_AND_ATTRIBUTE_LEN: usize = 256; @@ -164,7 +164,7 @@ impl WebGLRenderingContext { fn vertex_attrib(&self, indx: u32, x: f32, y: f32, z: f32, w: f32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::VertexAttrib(indx, x, y, z, w))) + .send(CanvasMsg::WebGL(WebGLCommand::VertexAttrib(indx, x, y, z, w))) .unwrap(); } } @@ -185,7 +185,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn DrawingBufferWidth(&self) -> i32 { let (sender, receiver) = ipc::channel().unwrap(); self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawingBufferWidth(sender))) + .send(CanvasMsg::WebGL(WebGLCommand::DrawingBufferWidth(sender))) .unwrap(); receiver.recv().unwrap() } @@ -194,7 +194,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn DrawingBufferHeight(&self) -> i32 { let (sender, receiver) = ipc::channel().unwrap(); self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawingBufferHeight(sender))) + .send(CanvasMsg::WebGL(WebGLCommand::DrawingBufferHeight(sender))) .unwrap(); receiver.recv().unwrap() } @@ -204,7 +204,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn GetBufferParameter(&self, _cx: *mut JSContext, target: u32, parameter: u32) -> JSVal { let (sender, receiver) = ipc::channel().unwrap(); self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::GetBufferParameter(target, parameter, sender))) + .send(CanvasMsg::WebGL(WebGLCommand::GetBufferParameter(target, parameter, sender))) .unwrap(); match handle_potential_webgl_error!(self, receiver.recv().unwrap(), WebGLParameter::Invalid) { WebGLParameter::Int(val) => Int32Value(val), @@ -220,7 +220,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn GetParameter(&self, cx: *mut JSContext, parameter: u32) -> JSVal { let (sender, receiver) = ipc::channel().unwrap(); self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::GetParameter(parameter, sender))) + .send(CanvasMsg::WebGL(WebGLCommand::GetParameter(parameter, sender))) .unwrap(); match handle_potential_webgl_error!(self, receiver.recv().unwrap(), WebGLParameter::Invalid) { WebGLParameter::Int(val) => Int32Value(val), @@ -260,7 +260,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // If the send does not succeed, assume context lost if let Err(_) = self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::GetContextAttributes(sender))) { + .send(CanvasMsg::WebGL(WebGLCommand::GetContextAttributes(sender))) { return None; } let attrs = receiver.recv().unwrap(); @@ -289,37 +289,37 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn ActiveTexture(&self, texture: u32) { - self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::ActiveTexture(texture))).unwrap(); + self.ipc_renderer.send(CanvasMsg::WebGL(WebGLCommand::ActiveTexture(texture))).unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn BlendColor(&self, r: f32, g: f32, b: f32, a: f32) { - self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendColor(r, g, b, a))).unwrap(); + self.ipc_renderer.send(CanvasMsg::WebGL(WebGLCommand::BlendColor(r, g, b, a))).unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn BlendEquation(&self, mode: u32) { - self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendEquation(mode))).unwrap(); + self.ipc_renderer.send(CanvasMsg::WebGL(WebGLCommand::BlendEquation(mode))).unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn BlendEquationSeparate(&self, mode_rgb: u32, mode_alpha: u32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendEquationSeparate(mode_rgb, mode_alpha))) + .send(CanvasMsg::WebGL(WebGLCommand::BlendEquationSeparate(mode_rgb, mode_alpha))) .unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn BlendFunc(&self, src_factor: u32, dest_factor: u32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BlendFunc(src_factor, dest_factor))) + .send(CanvasMsg::WebGL(WebGLCommand::BlendFunc(src_factor, dest_factor))) .unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn BlendFuncSeparate(&self, src_rgb: u32, dest_rgb: u32, src_alpha: u32, dest_alpha: u32) { self.ipc_renderer.send( - CanvasMsg::WebGL(CanvasWebGLMsg::BlendFuncSeparate(src_rgb, dest_rgb, src_alpha, dest_alpha))).unwrap(); + CanvasMsg::WebGL(WebGLCommand::BlendFuncSeparate(src_rgb, dest_rgb, src_alpha, dest_alpha))).unwrap(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 @@ -356,7 +356,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } else { // Unbind the current buffer self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BindBuffer(target, 0))) + .send(CanvasMsg::WebGL(WebGLCommand::BindBuffer(target, 0))) .unwrap() } } @@ -371,7 +371,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { framebuffer.bind(target) } else { // Bind the default framebuffer - let cmd = CanvasWebGLMsg::BindFramebuffer(target, WebGLFramebufferBindingRequest::Default); + let cmd = WebGLCommand::BindFramebuffer(target, WebGLFramebufferBindingRequest::Default); self.ipc_renderer.send(CanvasMsg::WebGL(cmd)).unwrap(); } } @@ -387,7 +387,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } else { // Unbind the currently bound renderbuffer self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BindRenderbuffer(target, 0))) + .send(CanvasMsg::WebGL(WebGLCommand::BindRenderbuffer(target, 0))) .unwrap() } } @@ -409,7 +409,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } else { // Unbind the currently bound texture self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BindTexture(target, 0))) + .send(CanvasMsg::WebGL(WebGLCommand::BindTexture(target, 0))) .unwrap() } } @@ -470,7 +470,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { return self.webgl_error(InvalidValue); } self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::BufferSubData(target, offset as isize, data_vec))) + .send(CanvasMsg::WebGL(WebGLCommand::BufferSubData(target, offset as isize, data_vec))) .unwrap() } else { self.webgl_error(InvalidValue); @@ -496,35 +496,35 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11 fn Clear(&self, mask: u32) { - self.ipc_renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::Clear(mask))).unwrap(); + self.ipc_renderer.send(CanvasMsg::WebGL(WebGLCommand::Clear(mask))).unwrap(); self.mark_as_dirty(); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn ClearColor(&self, red: f32, green: f32, blue: f32, alpha: f32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearColor(red, green, blue, alpha))) + .send(CanvasMsg::WebGL(WebGLCommand::ClearColor(red, green, blue, alpha))) .unwrap() } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn ClearDepth(&self, depth: f32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearDepth(depth as f64))) + .send(CanvasMsg::WebGL(WebGLCommand::ClearDepth(depth as f64))) .unwrap() } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn ClearStencil(&self, stencil: i32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::ClearStencil(stencil))) + .send(CanvasMsg::WebGL(WebGLCommand::ClearStencil(stencil))) .unwrap() } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn ColorMask(&self, r: bool, g: bool, b: bool, a: bool) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::ColorMask(r, g, b, a))) + .send(CanvasMsg::WebGL(WebGLCommand::ColorMask(r, g, b, a))) .unwrap() } @@ -533,7 +533,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { match mode { constants::FRONT | constants::BACK | constants::FRONT_AND_BACK => self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::CullFace(mode))) + .send(CanvasMsg::WebGL(WebGLCommand::CullFace(mode))) .unwrap(), _ => self.webgl_error(InvalidEnum), } @@ -544,7 +544,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { match mode { constants::CW | constants::CCW => self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::FrontFace(mode))) + .send(CanvasMsg::WebGL(WebGLCommand::FrontFace(mode))) .unwrap(), _ => self.webgl_error(InvalidEnum), } @@ -557,7 +557,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { constants::GREATER | constants::NOTEQUAL | constants::GEQUAL | constants::ALWAYS => self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::DepthFunc(func))) + .send(CanvasMsg::WebGL(WebGLCommand::DepthFunc(func))) .unwrap(), _ => self.webgl_error(InvalidEnum), } @@ -566,14 +566,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn DepthMask(&self, flag: bool) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::DepthMask(flag))) + .send(CanvasMsg::WebGL(WebGLCommand::DepthMask(flag))) .unwrap() } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn DepthRange(&self, near: f32, far: f32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::DepthRange(near as f64, far as f64))) + .send(CanvasMsg::WebGL(WebGLCommand::DepthRange(near as f64, far as f64))) .unwrap() } @@ -584,7 +584,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE | constants::SAMPLE_COVERAGE_INVERT | constants::SCISSOR_TEST => self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::Enable(cap))) + .send(CanvasMsg::WebGL(WebGLCommand::Enable(cap))) .unwrap(), _ => self.webgl_error(InvalidEnum), } @@ -597,7 +597,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE | constants::SAMPLE_COVERAGE_INVERT | constants::SCISSOR_TEST => self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::Disable(cap))) + .send(CanvasMsg::WebGL(WebGLCommand::Disable(cap))) .unwrap(), _ => self.webgl_error(InvalidEnum), } @@ -699,7 +699,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { self.webgl_error(InvalidValue); } else { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawArrays(mode, first, count))) + .send(CanvasMsg::WebGL(WebGLCommand::DrawArrays(mode, first, count))) .unwrap(); self.mark_as_dirty(); } @@ -739,7 +739,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { constants::TRIANGLE_STRIP | constants::TRIANGLE_FAN | constants::TRIANGLES => { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::DrawElements(mode, count, type_, offset))) + .send(CanvasMsg::WebGL(WebGLCommand::DrawElements(mode, count, type_, offset))) .unwrap(); self.mark_as_dirty(); }, @@ -750,7 +750,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn EnableVertexAttribArray(&self, attrib_id: u32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::EnableVertexAttribArray(attrib_id))) + .send(CanvasMsg::WebGL(WebGLCommand::EnableVertexAttribArray(attrib_id))) .unwrap() } @@ -825,7 +825,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::Hint(target, mode))) + .send(CanvasMsg::WebGL(WebGLCommand::Hint(target, mode))) .unwrap() } @@ -836,7 +836,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::LineWidth(width))) + .send(CanvasMsg::WebGL(WebGLCommand::LineWidth(width))) .unwrap() } @@ -889,21 +889,21 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::PixelStorei(param_name, param_value))) + .send(CanvasMsg::WebGL(WebGLCommand::PixelStorei(param_name, param_value))) .unwrap() } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn PolygonOffset(&self, factor: f32, units: f32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::PolygonOffset(factor, units))) + .send(CanvasMsg::WebGL(WebGLCommand::PolygonOffset(factor, units))) .unwrap() } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4 fn Scissor(&self, x: i32, y: i32, width: i32, height: i32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::Scissor(x, y, width, height))) + .send(CanvasMsg::WebGL(WebGLCommand::Scissor(x, y, width, height))) .unwrap() } @@ -945,7 +945,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { }; self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::Uniform1f(uniform.id(), val))) + .send(CanvasMsg::WebGL(WebGLCommand::Uniform1f(uniform.id(), val))) .unwrap() } @@ -975,7 +975,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { }; self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::Uniform4f(uniform.id(), x, y, z, w))) + .send(CanvasMsg::WebGL(WebGLCommand::Uniform4f(uniform.id(), x, y, z, w))) .unwrap() } @@ -1086,7 +1086,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { normalized: bool, stride: i32, offset: i64) { if let constants::FLOAT = data_type { let msg = CanvasMsg::WebGL( - CanvasWebGLMsg::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset as u32)); + WebGLCommand::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset as u32)); self.ipc_renderer.send(msg).unwrap() } else { panic!("VertexAttribPointer: Data Type not supported") @@ -1096,7 +1096,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4 fn Viewport(&self, x: i32, y: i32, width: i32, height: i32) { self.ipc_renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::Viewport(x, y, width, height))) + .send(CanvasMsg::WebGL(WebGLCommand::Viewport(x, y, width, height))) .unwrap() } @@ -1170,7 +1170,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { }; // TODO(emilio): Invert axis, convert colorspace, premultiply alpha if requested - let msg = CanvasWebGLMsg::TexImage2D(target, level, internal_format as i32, + let msg = WebGLCommand::TexImage2D(target, level, internal_format as i32, size.width, size.height, format, data_type, pixels); diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 9c4548f1675..03c39b698b0 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -4,7 +4,7 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, ShaderValidator}; -use canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLResult, WebGLParameter}; +use canvas_traits::CanvasMsg; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::WebGLShaderBinding; use dom::bindings::global::GlobalRef; @@ -15,6 +15,7 @@ use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; use std::sync::{ONCE_INIT, Once}; use util::str::DOMString; +use webrender_traits::{WebGLCommand, WebGLParameter, WebGLResult}; #[derive(Clone, Copy, PartialEq, Debug, JSTraceable, HeapSizeOf)] pub enum ShaderCompilationStatus { @@ -63,7 +64,7 @@ impl WebGLShader { renderer: IpcSender<CanvasMsg>, shader_type: u32) -> Option<Root<WebGLShader>> { let (sender, receiver) = ipc::channel().unwrap(); - renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CreateShader(shader_type, sender))).unwrap(); + renderer.send(CanvasMsg::WebGL(WebGLCommand::CreateShader(shader_type, sender))).unwrap(); let result = receiver.recv().unwrap(); result.map(|shader_id| WebGLShader::new(global, renderer, *shader_id, shader_type)) @@ -103,7 +104,7 @@ impl WebGLShader { // NOTE: At this point we should be pretty sure that the compilation in the paint thread // will succeed. // It could be interesting to retrieve the info log from the paint thread though - let msg = CanvasWebGLMsg::CompileShader(self.id, translated_source); + let msg = WebGLCommand::CompileShader(self.id, translated_source); self.renderer.send(CanvasMsg::WebGL(msg)).unwrap(); self.compilation_status.set(ShaderCompilationStatus::Succeeded); }, @@ -122,7 +123,7 @@ impl WebGLShader { pub fn delete(&self) { if !self.is_deleted.get() { self.is_deleted.set(true); - let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteShader(self.id))); + let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteShader(self.id))); } } @@ -134,7 +135,7 @@ impl WebGLShader { /// glGetParameter pub fn parameter(&self, param_id: u32) -> WebGLResult<WebGLParameter> { let (sender, receiver) = ipc::channel().unwrap(); - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::GetShaderParameter(self.id, param_id, sender))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::GetShaderParameter(self.id, param_id, sender))).unwrap(); receiver.recv().unwrap() } diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index e7f645ce235..e40938d84f1 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLError, WebGLResult}; +use canvas_traits::CanvasMsg; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::codegen::Bindings::WebGLTextureBinding; use dom::bindings::global::GlobalRef; @@ -12,6 +12,7 @@ use dom::bindings::reflector::reflect_dom_object; use dom::webglobject::WebGLObject; use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; +use webrender_traits::{WebGLCommand, WebGLError, WebGLResult}; pub enum TexParameterValue { Float(f32), @@ -43,7 +44,7 @@ impl WebGLTexture { pub fn maybe_new(global: GlobalRef, renderer: IpcSender<CanvasMsg>) -> Option<Root<WebGLTexture>> { let (sender, receiver) = ipc::channel().unwrap(); - renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CreateTexture(sender))).unwrap(); + renderer.send(CanvasMsg::WebGL(WebGLCommand::CreateTexture(sender))).unwrap(); let result = receiver.recv().unwrap(); result.map(|texture_id| WebGLTexture::new(global, renderer, *texture_id)) @@ -70,7 +71,7 @@ impl WebGLTexture { self.target.set(Some(target)); } - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BindTexture(target, self.id))).unwrap(); + self.renderer.send(CanvasMsg::WebGL(WebGLCommand::BindTexture(target, self.id))).unwrap(); Ok(()) } @@ -78,7 +79,7 @@ impl WebGLTexture { pub fn delete(&self) { if !self.is_deleted.get() { self.is_deleted.set(true); - let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteTexture(self.id))); + let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteTexture(self.id))); } } @@ -104,7 +105,7 @@ impl WebGLTexture { constants::NEAREST_MIPMAP_LINEAR | constants::LINEAR_MIPMAP_LINEAR => { self.renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::TexParameteri(target, name, int_value))) + .send(CanvasMsg::WebGL(WebGLCommand::TexParameteri(target, name, int_value))) .unwrap(); Ok(()) }, @@ -117,7 +118,7 @@ impl WebGLTexture { constants::NEAREST | constants::LINEAR => { self.renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::TexParameteri(target, name, int_value))) + .send(CanvasMsg::WebGL(WebGLCommand::TexParameteri(target, name, int_value))) .unwrap(); Ok(()) }, @@ -132,7 +133,7 @@ impl WebGLTexture { constants::MIRRORED_REPEAT | constants::REPEAT => { self.renderer - .send(CanvasMsg::WebGL(CanvasWebGLMsg::TexParameteri(target, name, int_value))) + .send(CanvasMsg::WebGL(WebGLCommand::TexParameteri(target, name, int_value))) .unwrap(); Ok(()) }, diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index 6c1814fa43b..845037e430c 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -185,3 +185,8 @@ partial interface Document { partial interface Document { Element? elementFromPoint(double x, double y); }; + +// https://drafts.csswg.org/cssom/#extensions-to-the-document-interface +partial interface Document { + [SameObject] readonly attribute StyleSheetList styleSheets; +}; diff --git a/components/script/dom/webidls/StyleSheet.webidl b/components/script/dom/webidls/StyleSheet.webidl new file mode 100644 index 00000000000..fdb4e875ce2 --- /dev/null +++ b/components/script/dom/webidls/StyleSheet.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// https://drafts.csswg.org/cssom/#the-stylesheet-interface +interface StyleSheet { + readonly attribute DOMString type_; + readonly attribute DOMString? href; + + // readonly attribute (Element or ProcessingInstruction)? ownerNode; + // readonly attribute StyleSheet? parentStyleSheet; + readonly attribute DOMString? title; + + // [SameObject, PutForwards=mediaText] readonly attribute MediaList media; + // attribute boolean disabled; +}; diff --git a/components/script/dom/webidls/StyleSheetList.webidl b/components/script/dom/webidls/StyleSheetList.webidl new file mode 100644 index 00000000000..e743653fde3 --- /dev/null +++ b/components/script/dom/webidls/StyleSheetList.webidl @@ -0,0 +1,11 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// https://drafts.csswg.org/cssom/#the-stylesheetlist-interface +// [ArrayClass] +interface StyleSheetList { + getter StyleSheet? item(unsigned long index); + readonly attribute unsigned long length; +}; diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 4a933dd2b28..9047833bfa8 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -29,6 +29,7 @@ dictionary TestDictionary { any anyValue; object objectValue; TestDictionaryDefaults dict; + sequence<TestDictionaryDefaults> seqDict; }; dictionary TestDictionaryDefaults { diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 1e79620fb29..3884a42b8b7 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -890,7 +890,7 @@ impl Window { let body = self.Document().GetBody(); let (x, y) = match body { Some(e) => { - let content_size = e.upcast::<Node>().get_bounding_content_box(); + let content_size = e.upcast::<Node>().bounding_content_box(); let content_height = content_size.size.height.to_f64_px(); let content_width = content_size.size.width.to_f64_px(); (xfinite.max(0.0f64).min(content_width - width), @@ -996,7 +996,7 @@ impl Window { page_clip_rect: self.page_clip_rect.get(), }, document: self.Document().upcast::<Node>().to_trusted_node_address(), - document_stylesheets: document.stylesheets().clone(), + document_stylesheets: document.stylesheets(), stylesheets_changed: stylesheets_changed, window_size: window_size, script_join_chan: join_chan, diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 7ab29945961..fcc6bbdd151 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -55,8 +55,8 @@ pub struct WorkerGlobalScope { eventtarget: EventTarget, worker_id: WorkerId, worker_url: Url, - #[ignore_heap_size_of = "Defined in std"] - runtime: Rc<Runtime>, + #[ignore_heap_size_of = "Defined in js"] + runtime: Runtime, next_worker_id: Cell<WorkerId>, #[ignore_heap_size_of = "Defined in std"] resource_thread: ResourceThread, @@ -94,7 +94,7 @@ pub struct WorkerGlobalScope { impl WorkerGlobalScope { pub fn new_inherited(init: WorkerGlobalScopeInit, worker_url: Url, - runtime: Rc<Runtime>, + runtime: Runtime, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, timer_event_chan: IpcSender<TimerEvent>) -> WorkerGlobalScope { diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 20a729c70c0..31833912795 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -1337,7 +1337,7 @@ impl XMLHttpRequest { if let Some(script_port) = script_port { loop { - global.process_event(script_port.recv()); + global.process_event(script_port.recv().unwrap()); let context = context.lock().unwrap(); let sync_status = context.sync_status.borrow(); if let Some(ref status) = *sync_status { |