diff --git a/README.md b/README.md index e4eff6eadae..d8c1c865f37 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Servo's build system automatically downloads a snapshot Rust compiler to build i This is normally a specific revision of Rust upstream, but sometimes has a backported patch or two. If you'd like to know the snapshot revision of Rust which we use, see -`./rust-snapshot-hash`. +`rust-snapshot-hash`. ## Building diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 2aeab109398..53c83fc5c39 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -32,7 +32,7 @@ use libc::uintptr_t; use msg::compositor_msg::{LayerId, LayerKind}; use net_traits::image::base::Image; use paint_task::PaintLayer; -use smallvec::SmallVec8; +use smallvec::SmallVec; use std::collections::linked_list::{self, LinkedList}; use std::fmt; use std::slice::Iter; @@ -313,7 +313,7 @@ impl StackingContext { } // Sort positioned children according to z-index. - let mut positioned_children = SmallVec8::new(); + let mut positioned_children: SmallVec<[Arc; 8]> = SmallVec::new(); for kid in display_list.children.iter() { positioned_children.push((*kid).clone()); } diff --git a/components/gfx/font.rs b/components/gfx/font.rs index f263cc8c607..fa60ba65abb 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use euclid::{Point2D, Rect, Size2D}; -use smallvec::SmallVec8; +use smallvec::SmallVec; use std::borrow::ToOwned; use std::mem; use std::slice; @@ -204,11 +204,11 @@ impl Font { } pub struct FontGroup { - pub fonts: SmallVec8>>, + pub fonts: SmallVec<[Rc>; 8]>, } impl FontGroup { - pub fn new(fonts: SmallVec8>>) -> FontGroup { + pub fn new(fonts: SmallVec<[Rc>; 8]>) -> FontGroup { FontGroup { fonts: fonts, } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 1bc555c65d9..5621807827f 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -13,7 +13,7 @@ use font_template::FontTemplateDescriptor; use fnv::FnvHasher; use platform::font::FontHandle; use platform::font_template::FontTemplateData; -use smallvec::SmallVec8; +use smallvec::SmallVec; use string_cache::Atom; use util::cache::HashCache; use util::geometry::Au; @@ -159,7 +159,7 @@ impl FontContext { style.font_style == font_style::T::italic || style.font_style == font_style::T::oblique); - let mut fonts = SmallVec8::new(); + let mut fonts: SmallVec<[Rc>; 8]> = SmallVec::new(); for family in style.font_family.0.iter() { // GWTODO: Check on real pages if this is faster as Vec() or HashMap(). diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 68ccf3c5cd7..466b5fd7ece 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -11,7 +11,7 @@ use context::SharedLayoutContext; use css::node_style::StyledNode; use data::LayoutDataWrapper; use incremental::{self, RestyleDamage}; -use smallvec::SmallVec16; +use smallvec::SmallVec; use wrapper::{LayoutElement, LayoutNode}; use script::dom::characterdata::CharacterDataTypeId; @@ -38,7 +38,7 @@ use util::opts; use util::vec::ForgetfulSink; pub struct ApplicableDeclarations { - pub normal: SmallVec16, + pub normal: SmallVec<[DeclarationBlock; 16]>, pub before: Vec, pub after: Vec, @@ -49,7 +49,7 @@ pub struct ApplicableDeclarations { impl ApplicableDeclarations { pub fn new() -> ApplicableDeclarations { ApplicableDeclarations { - normal: SmallVec16::new(), + normal: SmallVec::new(), before: Vec::new(), after: Vec::new(), normal_shareable: false, @@ -57,7 +57,7 @@ impl ApplicableDeclarations { } pub fn clear(&mut self) { - self.normal = SmallVec16::new(); + self.normal = SmallVec::new(); self.before = Vec::new(); self.after = Vec::new(); self.normal_shareable = false; diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 2b2721b3e99..a5803d2484c 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -13,7 +13,7 @@ use flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, Immutab use flow::{InorderFlowTraversal}; use fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo}; use incremental::{self, RESOLVE_GENERATED_CONTENT}; -use smallvec::SmallVec8; +use smallvec::SmallVec; use text::TextRunScanner; use gfx::display_list::OpaqueNode; @@ -522,7 +522,7 @@ pub fn static_representation(list_style_type: list_style_type::T) -> char { /// Pushes the string that represents the value rendered using the given *alphabetic system* onto /// the accumulator per CSS-COUNTER-STYLES ยง 3.1.4. fn push_alphabetic_representation(mut value: i32, system: &[char], accumulator: &mut String) { - let mut string = SmallVec8::new(); + let mut string: SmallVec<[char; 8]> = SmallVec::new(); while value != 0 { // Step 1. value = value - 1; @@ -545,7 +545,7 @@ fn push_numeric_representation(mut value: i32, system: &[char], accumulator: &mu } // Step 2. - let mut string = SmallVec8::new(); + let mut string: SmallVec<[char; 8]> = SmallVec::new(); while value != 0 { // Step 2.1. string.push(system[(value as usize) % system.len()]); diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index ae3aefe01e6..079f1ecbafc 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -57,7 +57,7 @@ use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask}; use net_traits::storage_task::StorageType; use script_traits::ScriptControlChan; use script_traits::UntrustedNodeAddress; -use smallvec::SmallVec1; +use smallvec::SmallVec; use msg::compositor_msg::ScriptListener; use msg::constellation_msg::ConstellationChan; use net_traits::image::base::Image; @@ -219,7 +219,7 @@ impl JSTraceable for Vec { // XXXManishearth Check if the following three are optimized to no-ops // if e.trace() is a no-op (e.g it is an no_jsmanaged_fields type) -impl JSTraceable for SmallVec1 { +impl JSTraceable for SmallVec<[T; 1]> { #[inline] fn trace(&self, trc: *mut JSTracer) { for e in self.iter() { diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 69575884afe..14fd3ebc06c 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter; use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLBodyElementCast}; -use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLHeadElementCast, ElementCast}; +use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLHeadElementCast, ElementCast, HTMLIFrameElementCast}; use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLAnchorElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementDerived, HTMLAppletElementDerived}; @@ -49,6 +49,7 @@ use dom::htmlcollection::{HTMLCollection, CollectionFilter}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlheadelement::HTMLHeadElement; use dom::htmlhtmlelement::HTMLHtmlElement; +use dom::htmliframeelement::HTMLIFrameElement; use dom::htmlscriptelement::HTMLScriptElement; use dom::location::Location; use dom::mouseevent::MouseEvent; @@ -69,7 +70,7 @@ use layout_interface::{HitTestResponse, MouseOverResponse}; use msg::compositor_msg::ScriptListener; use msg::constellation_msg::AnimationState; use msg::constellation_msg::Msg as ConstellationMsg; -use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyModifiers, MozBrowserEvent}; +use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyModifiers, MozBrowserEvent, SubpageId}; use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL}; use net_traits::CookieSource::NonHTTP; use net_traits::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl}; @@ -287,6 +288,7 @@ pub trait DocumentHelpers<'a> { fn finish_load(self, load: LoadType); fn set_current_parser(self, script: Option<&ServoHTMLParser>); fn get_current_parser(self) -> Option>; + fn find_iframe(self, subpage_id: SubpageId) -> Option>; } impl<'a> DocumentHelpers<'a> for &'a Document { @@ -989,6 +991,13 @@ impl<'a> DocumentHelpers<'a> for &'a Document { fn get_current_parser(self) -> Option> { self.current_parser.get().map(Root::from_rooted) } + + /// Find an iframe element in the document. + fn find_iframe(self, subpage_id: SubpageId) -> Option> { + NodeCast::from_ref(self).traverse_preorder() + .filter_map(HTMLIFrameElementCast::to_root) + .find(|node| node.r().subpage_id() == Some(subpage_id)) + } } pub enum MouseEventType { diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs index fd284e8d1b3..05531d3c10d 100644 --- a/components/script/dom/progressevent.rs +++ b/components/script/dom/progressevent.rs @@ -10,7 +10,7 @@ use dom::bindings::error::Fallible; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::utils::reflect_dom_object; -use dom::event::{Event, EventTypeId}; +use dom::event::{Event, EventTypeId, EventBubbles, EventCancelable}; use util::str::DOMString; #[dom_struct] @@ -37,14 +37,14 @@ impl ProgressEvent { } } pub fn new(global: GlobalRef, type_: DOMString, - can_bubble: bool, cancelable: bool, + can_bubble: EventBubbles, cancelable: EventCancelable, length_computable: bool, loaded: u64, total: u64) -> Root { let ev = reflect_dom_object(box ProgressEvent::new_inherited(length_computable, loaded, total), global, ProgressEventBinding::Wrap); { let event = EventCast::from_ref(ev.r()); - event.InitEvent(type_, can_bubble, cancelable); + event.InitEvent(type_, can_bubble == EventBubbles::Bubbles, cancelable == EventCancelable::Cancelable); } ev } @@ -52,7 +52,10 @@ impl ProgressEvent { type_: DOMString, init: &ProgressEventBinding::ProgressEventInit) -> Fallible> { - let ev = ProgressEvent::new(global, type_, init.parent.bubbles, init.parent.cancelable, + let bubbles = if init.parent.bubbles {EventBubbles::Bubbles} else {EventBubbles::DoesNotBubble}; + let cancelable = if init.parent.cancelable {EventCancelable::Cancelable} + else {EventCancelable::NotCancelable}; + let ev = ProgressEvent::new(global, type_, bubbles, cancelable, init.lengthComputable, init.loaded, init.total); Ok(ev) } diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 823c3eda264..10ad71ab2f2 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -942,7 +942,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest { let global = self.global.root(); let upload_target = self.upload.root(); let progressevent = ProgressEvent::new(global.r(), - type_, false, false, + type_, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable, total.is_some(), loaded, total.unwrap_or(0)); let target = if upload { diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 51937350df2..480514b36b2 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -22,7 +22,7 @@ use document_loader::{LoadType, DocumentLoader, NotifierData}; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState}; -use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, HTMLIFrameElementCast, NodeCast, EventCast}; +use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, NodeCast, EventCast}; use dom::bindings::conversions::FromJSValConvertible; use dom::bindings::conversions::StringificationBehavior; use dom::bindings::js::{JS, RootCollection, trace_roots}; @@ -35,7 +35,7 @@ use dom::document::{Document, IsHTMLDocument, DocumentHelpers, DocumentProgressH DocumentProgressTask, DocumentSource, MouseEventType}; use dom::element::{Element, AttributeHandlers}; use dom::event::{EventHelpers, EventBubbles, EventCancelable}; -use dom::htmliframeelement::{HTMLIFrameElement, HTMLIFrameElementHelpers}; +use dom::htmliframeelement::HTMLIFrameElementHelpers; use dom::uievent::UIEvent; use dom::node::{Node, NodeHelpers, NodeDamage, window_from_node}; use dom::servohtmlparser::{ServoHTMLParser, ParserContext}; @@ -1105,7 +1105,7 @@ impl ScriptTask { let page = borrowed_page.find(parent_pipeline_id).unwrap(); let doc = page.document(); - let frame_element = self.find_iframe(doc.r(), subpage_id); + let frame_element = doc.find_iframe(subpage_id); if let Some(ref frame_element) = frame_element { let element = ElementCast::from_ref(frame_element.r()); @@ -1125,7 +1125,7 @@ impl ScriptTask { let frame_element = borrowed_page.find(parent_pipeline_id).and_then(|page| { let doc = page.document(); - self.find_iframe(doc.r(), subpage_id) + doc.find_iframe(subpage_id) }); if let Some(ref frame_element) = frame_element { @@ -1141,7 +1141,7 @@ impl ScriptTask { let frame_element = borrowed_page.find(containing_pipeline_id).and_then(|page| { let doc = page.document(); - self.find_iframe(doc.r(), old_subpage_id) + doc.find_iframe(old_subpage_id) }); frame_element.r().unwrap().update_subpage_id(new_subpage_id); @@ -1292,7 +1292,7 @@ impl ScriptTask { borrowed_page.as_ref().and_then(|borrowed_page| { borrowed_page.find(parent_id).and_then(|page| { let doc = page.document(); - self.find_iframe(doc.r(), subpage_id) + doc.find_iframe(subpage_id) }) }) }); @@ -1459,16 +1459,6 @@ impl ScriptTask { window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, reason); } - /// Find an iframe element in a provided document. - fn find_iframe(&self, doc: &Document, subpage_id: SubpageId) - -> Option> { - let doc = NodeCast::from_ref(doc); - - doc.traverse_preorder() - .filter_map(HTMLIFrameElementCast::to_root) - .find(|node| node.r().subpage_id() == Some(subpage_id)) - } - /// This is the main entry point for receiving and dispatching DOM events. /// /// TODO: Actually perform DOM event dispatch. @@ -1547,7 +1537,7 @@ impl ScriptTask { let borrowed_page = self.root_page(); let iframe = borrowed_page.find(pipeline_id).and_then(|page| { let doc = page.document(); - self.find_iframe(doc.r(), subpage_id) + doc.find_iframe(subpage_id) }); if let Some(iframe) = iframe.r() { iframe.navigate_child_browsing_context(load_data.url); diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 301c6673b04..3093f8e69c3 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -18,7 +18,7 @@ use parser::{ParserContext, log_css_error}; use properties::{PropertyDeclarationBlock, parse_property_declaration_list}; use media_queries::{Device, MediaQueryList, parse_media_query_list}; use font_face::{FontFaceRule, parse_font_face_block}; -use smallvec::SmallVec2; +use smallvec::SmallVec; use viewport::ViewportRule; @@ -161,13 +161,13 @@ impl Stylesheet { /// conditional group rule will come before its nested rules. pub struct Rules<'a> { // 2 because normal case is likely to be just one level of nesting (@media) - stack: SmallVec2>, + stack: SmallVec<[slice::Iter<'a, CSSRule>; 2]>, device: Option<&'a Device> } impl<'a> Rules<'a> { fn new(iter: slice::Iter<'a, CSSRule>, device: Option<&'a Device>) -> Rules<'a> { - let mut stack = SmallVec2::new(); + let mut stack: SmallVec<[slice::Iter<'a, CSSRule>; 2]> = SmallVec::new(); stack.push(iter); Rules { stack: stack, device: device }