diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/devtools/protocol.rs | 4 | ||||
-rw-r--r-- | components/gfx/text/glyph.rs | 4 | ||||
-rw-r--r-- | components/gfx/text/shaping/harfbuzz.rs | 6 | ||||
-rw-r--r-- | components/layout/display_list_builder.rs | 3 | ||||
-rw-r--r-- | components/layout/fragment.rs | 23 | ||||
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 7 | ||||
-rw-r--r-- | components/script/dom/cssstyledeclaration.rs | 90 | ||||
-rw-r--r-- | components/script/dom/element.rs | 4 | ||||
-rw-r--r-- | components/script/dom/webidls/CSSStyleDeclaration.webidl | 18 | ||||
-rw-r--r-- | components/script/lib.rs | 1 | ||||
-rw-r--r-- | components/servo/Cargo.toml | 4 | ||||
-rw-r--r-- | components/servo/main.rs | 4 | ||||
-rw-r--r-- | components/style/properties/mod.rs.mako | 34 | ||||
-rw-r--r-- | components/util/cache.rs | 3 | ||||
-rw-r--r-- | components/util/smallvec.rs | 21 |
15 files changed, 107 insertions, 119 deletions
diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index be27eed2ec1..df9078c7bf1 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -2,7 +2,9 @@ * 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/. */ -/// Low-level wire protocol implementation. Currently only supports [JSON packets](https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets). +//! Low-level wire protocol implementation. Currently only supports +//! [JSON packets] +//! (https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets). use serialize::{json, Encodable}; use serialize::json::Json; diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index a991f147bed..06e16c04a79 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -8,6 +8,7 @@ use servo_util::range::{Range, RangeIndex, EachIndex}; use servo_util::geometry::Au; use std::cmp::PartialOrd; +use std::iter::repeat; use std::num::NumCast; use std::mem; use std::u16; @@ -526,7 +527,8 @@ impl<'a> GlyphStore { assert!(length > 0); GlyphStore { - entry_buffer: Vec::from_elem(length as uint, GlyphEntry::initial()), + entry_buffer: repeat(GlyphEntry::initial()).take(length as uint) + .collect(), detail_store: DetailedGlyphStore::new(), is_whitespace: is_whitespace, } diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index cc328ca4f8c..fb5d83b6457 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -43,6 +43,7 @@ use libc::{c_uint, c_int, c_void, c_char}; use servo_util::geometry::Au; use servo_util::range::Range; use std::char; +use std::iter::repeat; use std::mem; use std::cmp; use std::ptr; @@ -295,9 +296,10 @@ impl Shaper { // fast path: all chars are single-byte. if byte_max == char_max { - byte_to_glyph = Vec::from_elem(byte_max as uint, NO_GLYPH); + byte_to_glyph = repeat(NO_GLYPH).take(byte_max as uint).collect(); } else { - byte_to_glyph = Vec::from_elem(byte_max as uint, CONTINUATION_BYTE); + byte_to_glyph = repeat(CONTINUATION_BYTE).take(byte_max as uint) + .collect(); for (i, _) in text.char_indices() { byte_to_glyph[i] = NO_GLYPH; } diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 54725d122b0..2e4ae665ea9 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -44,6 +44,7 @@ use servo_util::geometry::{mod, Au, to_px}; use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize}; use servo_util::opts; use std::default::Default; +use std::iter::repeat; use std::num::FloatMath; use style::computed::{AngleOrCorner, LengthOrPercentage, HorizontalDirection, VerticalDirection}; use style::computed::{Image, LinearGradient}; @@ -881,7 +882,7 @@ impl FragmentDisplayListBuilding for Fragment { renderer.deref().lock().send(SendPixelContents(sender)); receiver.recv() }, - None => Vec::from_elem(width * height * 4, 0xFFu8) + None => repeat(0xFFu8).take(width * height * 4).collect(), }; let canvas_display_item = box ImageDisplayItem { diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 521b000dfcf..8bad0a288b6 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -1256,11 +1256,24 @@ impl Fragment { pub fn find_split_info_by_new_line(&self) -> Option<(SplitInfo, Option<SplitInfo>, Arc<Box<TextRun>> /* TODO(bjz): remove */)> { match self.specific { - SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Generic | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Image(_) | SpecificFragmentInfo::Table | SpecificFragmentInfo::TableCell | - SpecificFragmentInfo::TableRow | SpecificFragmentInfo::TableWrapper => None, - SpecificFragmentInfo::TableColumn(_) => panic!("Table column fragments do not need to split"), - SpecificFragmentInfo::UnscannedText(_) => panic!("Unscanned text fragments should have been scanned by now!"), - SpecificFragmentInfo::InlineBlock(_) | SpecificFragmentInfo::InlineAbsoluteHypothetical(_) => { + SpecificFragmentInfo::Canvas(_) | + SpecificFragmentInfo::Generic | + SpecificFragmentInfo::Iframe(_) | + SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Table | + SpecificFragmentInfo::TableCell | + SpecificFragmentInfo::TableRow | + SpecificFragmentInfo::TableWrapper => { + None + } + SpecificFragmentInfo::TableColumn(_) => { + panic!("Table column fragments do not need to split") + } + SpecificFragmentInfo::UnscannedText(_) => { + panic!("Unscanned text fragments should have been scanned by now!") + } + SpecificFragmentInfo::InlineBlock(_) | + SpecificFragmentInfo::InlineAbsoluteHypothetical(_) => { panic!("Inline blocks or inline absolute hypothetical fragments do not get split") } SpecificFragmentInfo::ScannedText(ref text_fragment_info) => { diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 1cc9c2dc9e8..3d28cf2bdc9 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -4584,11 +4584,12 @@ class CGBindingRoot(CGThing): 'page::JSPageInfo', 'libc', 'servo_util::str::DOMString', - 'std::mem', 'std::cmp', + 'std::iter::repeat', + 'std::mem', + 'std::num', 'std::ptr', 'std::str', - 'std::num', ]) # Add the auto-generated comment. @@ -4885,7 +4886,7 @@ class CallbackMember(CGNativeMember): if self.argCount > 0: replacements["argCount"] = self.argCountStr replacements["argvDecl"] = string.Template( - "let mut argv = Vec::from_elem(${argCount}, UndefinedValue());\n" + "let mut argv = repeat(UndefinedValue()).take(${argCount}).collect::<Vec<_>>();\n" ).substitute(replacements) else: # Avoid weird 0-sized arrays diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 7ddf5260283..b95df387901 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -342,93 +342,5 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> { rval } - css_properties!( - [Color, SetColor, "color"], - [Background, SetBackground, "background"], - [BackgroundColor, SetBackgroundColor, "background-color"], - [BackgroundPosition, SetBackgroundPosition, "background-position"], - [BackgroundImage, SetBackgroundImage, "background-image"], - [BackgroundRepeat, SetBackgroundRepeat, "background-repeat"], - [BackgroundAttachment, SetBackgroundAttachment, "background-attachment"], - [Border, SetBorder, "border"], - [BorderColor, SetBorderColor, "border-color"], - [BorderRadius, SetBorderRadius, "border-radius"], - [BorderStyle, SetBorderStyle, "border-style"], - [BorderWidth, SetBorderWidth, "border-width"], - [BorderBottom, SetBorderBottom, "border-bottom"], - [BorderBottomColor, SetBorderBottomColor, "border-bottom-color"], - [BorderBottomStyle, SetBorderBottomStyle, "border-bottom-style"], - [BorderBottomWidth, SetBorderBottomWidth, "border-bottom-width"], - [BorderLeft, SetBorderLeft, "border-left"], - [BorderLeftColor, SetBorderLeftColor, "border-left-color"], - [BorderLeftStyle, SetBorderLeftStyle, "border-left-style"], - [BorderLeftWidth, SetBorderLeftWidth, "border-left-width"], - [BorderRight, SetBorderRight, "border-right"], - [BorderRightColor, SetBorderRightColor, "border-right-color"], - [BorderRightStyle, SetBorderRightStyle, "border-right-style"], - [BorderRightWidth, SetBorderRightWidth, "border-right-width"], - [BorderTop, SetBorderTop, "border-top"], - [BorderTopColor, SetBorderTopColor, "border-top-color"], - [BorderTopStyle, SetBorderTopStyle, "border-top-style"], - [BorderTopWidth, SetBorderTopWidth, "border-top-width"], - [Content, SetContent, "content"], - [Display, SetDisplay, "display"], - [Opacity, SetOpacity, "opacity"], - [Width, SetWidth, "width"], - [MinWidth, SetMinWidth, "min-width"], - [MaxWidth, SetMaxWidth, "max-width"], - [Height, SetHeight, "height"], - [MinHeight, SetMinHeight, "min-height"], - [MaxHeight, SetMaxHeight, "max-height"], - [Clear, SetClear, "clear"], - [Direction, SetDirection, "direction"], - [LineHeight, SetLineHeight, "line-height"], - [VerticalAlign, SetVerticalAlign, "vertical-align"], - [ListStyle, SetListStyle, "list-style"], - [ListStylePosition, SetListStylePosition, "list-style-position"], - [ListStyleType, SetListStyleType, "list-style-type"], - [ListStyleImage, SetListStyleImage, "list-style-image"], - [Visibility, SetVisibility, "visibility"], - [Cursor, SetCursor, "cursor"], - [BoxShadow, SetBoxShadow, "box-shadow"], - [BoxSizing, SetBoxSizing, "box-sizing"], - [Overflow, SetOverflow, "overflow"], - [OverflowWrap, SetOverflowWrap, "overflow-wrap"], - [TableLayout, SetTableLayout, "table-layout"], - [EmptyCells, SetEmptyCells, "empty-cells"], - [CaptionSide, SetCaptionSide, "caption-side"], - [WhiteSpace, SetWhiteSpace, "white-space"], - [WritingMode, SetWritingMode, "writing-mode"], - [LetterSpacing, SetLetterSpacing, "letter-spacing"], - [WordSpacing, SetWordSpacing, "word-spacing"], - [WordWrap, SetWordWrap, "word-wrap"], - [TextAlign, SetTextAlign, "text-align"], - [TextDecoration, SetTextDecoration, "text-decoration"], - [TextIndent, SetTextIndent, "text-indent"], - [TextOrientation, SetTextOrientation, "text-orientation"], - [TextTransform, SetTextTransform, "text-transform"], - [Font, SetFont, "font"], - [FontFamily, SetFontFamily, "font-family"], - [FontSize, SetFontSize, "font-size"], - [FontStyle, SetFontStyle, "font-style"], - [FontVariant, SetFontVariant, "font-variant"], - [FontWeight, SetFontWeight, "font-weight"], - [Margin, SetMargin, "margin"], - [MarginBottom, SetMarginBottom, "margin-bottom"], - [MarginLeft, SetMarginLeft, "margin-left"], - [MarginRight, SetMarginRight, "margin-right"], - [MarginTop, SetMarginTop, "margin-top"], - [Padding, SetPadding, "padding"], - [PaddingBottom, SetPaddingBottom, "padding-bottom"], - [PaddingLeft, SetPaddingLeft, "padding-left"], - [PaddingRight, SetPaddingRight, "padding-right"], - [PaddingTop, SetPaddingTop, "padding-top"], - [Outline, SetOutline, "outline"], - [Position, SetPosition, "position"], - [Bottom, SetBottom, "bottom"], - [Left, SetLeft, "left"], - [Right, SetRight, "right"], - [Top, SetTop, "top"], - [ZIndex, SetZIndex, "z-index"] - ) + css_properties_accessors!(css_properties) } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 14f48f5f3b6..0735e19299f 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -111,7 +111,9 @@ impl Element { create_element(name, prefix, document, creator) } - pub fn new_inherited(type_id: ElementTypeId, local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: JSRef<Document>) -> Element { + pub fn new_inherited(type_id: ElementTypeId, local_name: DOMString, + namespace: Namespace, prefix: Option<DOMString>, + document: JSRef<Document>) -> Element { Element { node: Node::new_inherited(NodeTypeId::Element(type_id), document), local_name: Atom::from_slice(local_name.as_slice()), diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl index 7f37e44cbbe..afe511b7e1f 100644 --- a/components/script/dom/webidls/CSSStyleDeclaration.webidl +++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl @@ -46,6 +46,8 @@ partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString borderWidth; [TreatNullAs=EmptyString] attribute DOMString borderBottom; [TreatNullAs=EmptyString] attribute DOMString borderBottomColor; + [TreatNullAs=EmptyString] attribute DOMString borderBottomLeftRadius; + [TreatNullAs=EmptyString] attribute DOMString borderBottomRightRadius; [TreatNullAs=EmptyString] attribute DOMString borderBottomStyle; [TreatNullAs=EmptyString] attribute DOMString borderBottomWidth; [TreatNullAs=EmptyString] attribute DOMString borderLeft; @@ -58,6 +60,8 @@ partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString borderRightWidth; [TreatNullAs=EmptyString] attribute DOMString borderTop; [TreatNullAs=EmptyString] attribute DOMString borderTopColor; + [TreatNullAs=EmptyString] attribute DOMString borderTopLeftRadius; + [TreatNullAs=EmptyString] attribute DOMString borderTopRightRadius; [TreatNullAs=EmptyString] attribute DOMString borderTopStyle; [TreatNullAs=EmptyString] attribute DOMString borderTopWidth; @@ -80,10 +84,16 @@ partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString clear; + [TreatNullAs=EmptyString] attribute DOMString clip; + [TreatNullAs=EmptyString] attribute DOMString direction; + [TreatNullAs=EmptyString] attribute DOMString filter; + [TreatNullAs=EmptyString] attribute DOMString lineHeight; + [TreatNullAs=EmptyString] attribute DOMString mixBlendMode; + [TreatNullAs=EmptyString] attribute DOMString verticalAlign; [TreatNullAs=EmptyString] attribute DOMString listStyle; @@ -103,6 +113,7 @@ partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString writingMode; [TreatNullAs=EmptyString] attribute DOMString letterSpacing; + [TreatNullAs=EmptyString] attribute DOMString wordBreak; [TreatNullAs=EmptyString] attribute DOMString wordSpacing; [TreatNullAs=EmptyString] attribute DOMString wordWrap; @@ -110,6 +121,7 @@ partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString textDecoration; [TreatNullAs=EmptyString] attribute DOMString textIndent; [TreatNullAs=EmptyString] attribute DOMString textOrientation; + [TreatNullAs=EmptyString] attribute DOMString textRendering; [TreatNullAs=EmptyString] attribute DOMString textTransform; [TreatNullAs=EmptyString] attribute DOMString font; @@ -132,9 +144,15 @@ partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString paddingTop; [TreatNullAs=EmptyString] attribute DOMString outline; + [TreatNullAs=EmptyString] attribute DOMString outlineColor; + [TreatNullAs=EmptyString] attribute DOMString outlineStyle; + [TreatNullAs=EmptyString] attribute DOMString outlineWidth; + [TreatNullAs=EmptyString] attribute DOMString outlineOffset; [TreatNullAs=EmptyString] attribute DOMString position; + [TreatNullAs=EmptyString] attribute DOMString pointerEvents; + [TreatNullAs=EmptyString] attribute DOMString top; [TreatNullAs=EmptyString] attribute DOMString right; [TreatNullAs=EmptyString] attribute DOMString left; diff --git a/components/script/lib.rs b/components/script/lib.rs index 7593a3b68a3..a3c528df29c 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -35,6 +35,7 @@ extern crate script_traits; extern crate "plugins" as servo_plugins; extern crate "net" as servo_net; extern crate "util" as servo_util; +#[phase(plugin, link)] extern crate style; extern crate "msg" as servo_msg; extern crate url; diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 52bdb2b6f31..f42178bb90f 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -27,8 +27,8 @@ path = "../../tests/contenttest.rs" harness = false [features] -default = ["glfw_app"] -glutin = ["glutin_app"] +default = ["glutin_app"] +glfw = ["glfw_app"] [dependencies.compositing] path = "../compositing" diff --git a/components/servo/main.rs b/components/servo/main.rs index 235b455ab32..81723d64b04 100644 --- a/components/servo/main.rs +++ b/components/servo/main.rs @@ -14,9 +14,9 @@ extern crate servo; extern crate time; extern crate "util" as servo_util; -#[cfg(all(feature = "glutin",not(test)))] +#[cfg(all(feature = "glutin_app",not(test)))] extern crate "glutin_app" as app; -#[cfg(all(feature = "glfw_app",not(test)))] +#[cfg(all(feature = "glfw",not(test)))] extern crate "glfw_app" as app; #[cfg(not(test))] diff --git a/components/style/properties/mod.rs.mako b/components/style/properties/mod.rs.mako index 29f4c17b8a8..5f800fd07e3 100644 --- a/components/style/properties/mod.rs.mako +++ b/components/style/properties/mod.rs.mako @@ -39,14 +39,14 @@ def to_rust_ident(name): name += "_" return name +def to_camel_case(ident): + return re.sub("_([a-z])", lambda m: m.group(1).upper(), ident.strip("_").capitalize()) + class Longhand(object): def __init__(self, name, derived_from=None, experimental=False): self.name = name self.ident = to_rust_ident(name) - self.camel_case, _ = re.subn( - "_([a-z])", - lambda m: m.group(1).upper(), - self.ident.strip("_").capitalize()) + self.camel_case = to_camel_case(self.ident) self.style_struct = THIS_STYLE_STRUCT self.experimental = experimental if derived_from is None: @@ -58,6 +58,8 @@ class Shorthand(object): def __init__(self, name, sub_properties): self.name = name self.ident = to_rust_ident(name) + self.camel_case = to_camel_case(self.ident) + self.derived_from = None self.sub_properties = [LONGHANDS_BY_NAME[s] for s in sub_properties] class StyleStruct(object): @@ -3358,16 +3360,32 @@ pub fn make_inline(style: &ComputedValues) -> ComputedValues { pub fn is_supported_property(property: &str) -> bool { match property { - % for property in SHORTHANDS: - "${property.name}" => true, - % endfor - % for property in LONGHANDS: + % for property in SHORTHANDS + LONGHANDS: "${property.name}" => true, % endfor _ => false, } } +#[macro_export] +macro_rules! css_properties_accessors( + ($macro: ident) => ( + $macro!( + % for property in SHORTHANDS + LONGHANDS: + ## Servo internal CSS properties are not accessible. + ## FIXME: Add BinaryName WebIDL annotation (#4435). + % if property.derived_from is None and property.name != "float": + % if property != LONGHANDS[-1]: + [${property.camel_case}, Set${property.camel_case}, "${property.name}"], + % else: + [${property.camel_case}, Set${property.camel_case}, "${property.name}"] + % endif + % endif + % endfor + ) + ) +) + pub fn longhands_from_shorthand(shorthand: &str) -> Option<Vec<String>> { match shorthand { % for property in SHORTHANDS: diff --git a/components/util/cache.rs b/components/util/cache.rs index 03bd649f777..35390d309bf 100644 --- a/components/util/cache.rs +++ b/components/util/cache.rs @@ -6,6 +6,7 @@ use std::collections::HashMap; use std::collections::hash_map::{Occupied, Vacant}; use rand::Rng; use std::hash::{Hash, sip}; +use std::iter::repeat; use std::rand::task_rng; use std::slice::Items; @@ -148,7 +149,7 @@ impl<K:Clone+PartialEq+Hash,V:Clone> SimpleHashCache<K,V> { pub fn new(cache_size: uint) -> SimpleHashCache<K,V> { let mut r = task_rng(); SimpleHashCache { - entries: Vec::from_elem(cache_size, None), + entries: repeat(None).take(cache_size).collect(), k0: r.gen(), k1: r.gen(), } diff --git a/components/util/smallvec.rs b/components/util/smallvec.rs index 60e22f25a70..e92d3d3eeba 100644 --- a/components/util/smallvec.rs +++ b/components/util/smallvec.rs @@ -531,7 +531,10 @@ pub mod tests { let mut v = SmallVec16::new(); v.push("hello".into_string()); v.push("there".into_string()); - assert_eq!(v.as_slice(), vec!["hello".into_string(), "there".into_string()].as_slice()); + assert_eq!(v.as_slice(), vec![ + "hello".into_string(), + "there".into_string(), + ].as_slice()); } #[test] @@ -541,7 +544,12 @@ pub mod tests { v.push("there".into_string()); v.push("burma".into_string()); v.push("shave".into_string()); - assert_eq!(v.as_slice(), vec!["hello".into_string(), "there".into_string(), "burma".into_string(), "shave".into_string()].as_slice()); + assert_eq!(v.as_slice(), vec![ + "hello".into_string(), + "there".into_string(), + "burma".into_string(), + "shave".into_string(), + ].as_slice()); } #[test] @@ -556,7 +564,14 @@ pub mod tests { v.push("burma".into_string()); v.push("shave".into_string()); assert_eq!(v.as_slice(), vec![ - "hello".into_string(), "there".into_string(), "burma".into_string(), "shave".into_string(), "hello".into_string(), "there".into_string(), "burma".into_string(), "shave".into_string(), + "hello".into_string(), + "there".into_string(), + "burma".into_string(), + "shave".into_string(), + "hello".into_string(), + "there".into_string(), + "burma".into_string(), + "shave".into_string(), ].as_slice()); } } |