diff options
27 files changed, 103 insertions, 29 deletions
diff --git a/components/layout/context.rs b/components/layout/context.rs index dcfece7f618..1520afd4c43 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -15,6 +15,7 @@ use gfx::display_list::OpaqueNode; use gfx::font_cache_task::FontCacheTask; use gfx::font_context::FontContext; use ipc_channel::ipc::{self, IpcSender}; +use msg::ParseErrorReporter; use msg::compositor_msg::LayerId; use net_traits::image::base::Image; use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageResponse, ImageState}; @@ -27,7 +28,6 @@ use std::rc::Rc; use std::sync::mpsc::{Sender, channel}; use std::sync::{Arc, Mutex, RwLock}; use style::selector_matching::Stylist; -use style_traits::ParseErrorReporter; use url::Url; use util::mem::HeapSizeOf; use util::opts; diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index cebb9463495..7036038369c 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -10,6 +10,7 @@ use animation; use context::SharedLayoutContext; use data::LayoutDataWrapper; use incremental::{self, RestyleDamage}; +use msg::ParseErrorReporter; use script::dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId}; use script::layout_interface::Animation; use selectors::bloom::BloomFilter; @@ -27,7 +28,6 @@ use string_cache::{Atom, Namespace}; use style::node::TElementAttributes; use style::properties::{ComputedValues, PropertyDeclaration, cascade}; use style::selector_matching::{DeclarationBlock, Stylist}; -use style_traits::ParseErrorReporter; use util::arc_ptr_eq; use util::cache::{LRUCache, SimpleHashCache}; use util::opts; diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index b1cad3cbd4a..35a78594034 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -34,6 +34,7 @@ use ipc_channel::router::ROUTER; use layout_debug; use layout_traits::LayoutTaskFactory; use log; +use msg::ParseErrorReporter; use msg::compositor_msg::{Epoch, LayerId, ScrollPolicy}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask}; @@ -65,7 +66,6 @@ use style::computed_values::{filter, mix_blend_mode}; use style::media_queries::{Device, MediaType}; use style::selector_matching::{Stylist, USER_OR_USER_AGENT_STYLESHEETS}; use style::stylesheets::{CSSRuleIteratorExt, Stylesheet}; -use style_traits::ParseErrorReporter; use url::Url; use util::geometry::MAX_RECT; use util::ipc::OptionalIpcSender; @@ -444,7 +444,7 @@ impl LayoutTask { resolved_style_response: None, offset_parent_response: OffsetParentResponse::empty(), })), - error_reporter: CSSErrorReporter, + error_reporter: CSSErrorReporter { pipelineid: id }, } } diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml index 74106e9eaba..18c92809975 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -25,6 +25,7 @@ git = "https://github.com/servo/ipc-channel" path = "../plugins" [dependencies] +cssparser = { version = "0.4", features = [ "serde-serialization" ] } app_units = {version = "0.1", features = ["plugins"]} bitflags = "0.3" hyper = { version = "0.7", features = [ "serde-serialization" ] } diff --git a/components/msg/lib.rs b/components/msg/lib.rs index ca8383225fd..0d88a456917 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -11,6 +11,7 @@ extern crate azure; extern crate bitflags; #[cfg(target_os = "macos")] extern crate core_foundation; +extern crate cssparser; extern crate euclid; extern crate hyper; #[cfg(target_os = "macos")] @@ -25,3 +26,12 @@ extern crate util; pub mod compositor_msg; pub mod constellation_msg; pub mod webdriver_msg; + +use constellation_msg::PipelineId; +use cssparser::{Parser, SourcePosition}; + +pub trait ParseErrorReporter { + fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str); + fn clone(&self) -> Box<ParseErrorReporter + Send + Sync>; + fn pipeline(&self) -> PipelineId; +} diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 64b6f738d2f..cbffda3e834 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -11,6 +11,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::element::{Element, StylePriority}; use dom::node::{Node, NodeDamage, document_from_node, window_from_node}; use dom::window::Window; +use msg::ParseErrorReporter; use selectors::parser::PseudoElement; use std::ascii::AsciiExt; use std::borrow::ToOwned; @@ -18,7 +19,6 @@ use std::cell::Ref; use string_cache::Atom; use style::properties::{PropertyDeclaration, Shorthand}; use style::properties::{is_supported_property, parse_one_declaration}; -use style_traits::ParseErrorReporter; use util::str::{DOMString, str_join}; // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 299df8d592d..1d7c7c43eb3 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -89,6 +89,7 @@ use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl}; use net_traits::CookieSource::NonHTTP; use net_traits::{AsyncResponseTarget, PendingAsyncLoad}; use num::ToPrimitive; +use script_task::CSSError; use script_task::{MainThreadScriptMsg, Runnable}; use script_traits::{ScriptMsg as ConstellationMsg, TouchEventType, TouchId, UntrustedNodeAddress}; use std::ascii::AsciiExt; @@ -203,6 +204,8 @@ pub struct Document { dom_content_loaded_event_start: Cell<u64>, dom_content_loaded_event_end: Cell<u64>, dom_complete: Cell<u64>, + /// Vector to store CSS errors + css_errors_store: DOMRefCell<Vec<CSSError>>, } impl PartialEq for Document { @@ -294,6 +297,10 @@ impl Document { self.is_html_document } + pub fn report_css_error(&self, css_error: CSSError) { + self.css_errors_store.borrow_mut().push(css_error); + } + // https://html.spec.whatwg.org/multipage/#fully-active pub fn is_fully_active(&self) -> bool { let browsing_context = self.window.browsing_context(); @@ -1495,6 +1502,7 @@ impl Document { dom_content_loaded_event_start: Cell::new(Default::default()), dom_content_loaded_event_end: Cell::new(Default::default()), dom_complete: Cell::new(Default::default()), + css_errors_store: DOMRefCell::new(vec![]), } } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index e47879051e7..3a7e7f861f2 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -63,6 +63,7 @@ use html5ever::serialize::SerializeOpts; use html5ever::serialize::TraversalScope; use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks}; +use msg::ParseErrorReporter; use selectors::matching::{DeclarationBlock, matches}; use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes}; use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str}; @@ -80,7 +81,6 @@ use style::properties::longhands::{self, background_image, border_spacing, font_ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; use style::values::CSSFloat; use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage}; -use style_traits::ParseErrorReporter; use url::UrlParser; use util::mem::HeapSizeOf; use util::str::{DOMString, LengthOrPercentageOrAuto}; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index a0ca6cfa432..0c0b1c01445 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -42,6 +42,7 @@ use js::rust::Runtime; use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow}; use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType}; use libc; +use msg::ParseErrorReporter; use msg::compositor_msg::{LayerId, ScriptToCompositorMsg}; use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; @@ -71,7 +72,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::TryRecvError::{Disconnected, Empty}; use std::sync::mpsc::{Sender, channel}; use string_cache::Atom; -use style_traits::ParseErrorReporter; use time; use timers::{ActiveTimers, IsInterval, ScheduledCallback, TimerCallback, TimerHandle}; use url::Url; @@ -1272,7 +1272,7 @@ impl Window { lchan.send(Msg::GetRPC(rpc_send)).unwrap(); rpc_recv.recv().unwrap() }; - let error_reporter = CSSErrorReporter; + let error_reporter = CSSErrorReporter { pipelineid: id }; let win = box Window { eventtarget: EventTarget::new_inherited(), script_chan: script_chan, diff --git a/components/script/reporter.rs b/components/script/reporter.rs index 16958201103..1ad6ee9987e 100644 --- a/components/script/reporter.rs +++ b/components/script/reporter.rs @@ -4,10 +4,13 @@ use cssparser::{Parser, SourcePosition}; use log; -use style_traits::ParseErrorReporter; +use msg::ParseErrorReporter; +use msg::constellation_msg::PipelineId; #[derive(JSTraceable, HeapSizeOf)] -pub struct CSSErrorReporter; +pub struct CSSErrorReporter { + pub pipelineid: PipelineId, +} impl ParseErrorReporter for CSSErrorReporter { fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) { @@ -19,7 +22,10 @@ impl ParseErrorReporter for CSSErrorReporter { } fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> { - let error_reporter = box CSSErrorReporter; + let error_reporter = box CSSErrorReporter { pipelineid: self.pipelineid, } ; return error_reporter; } + fn pipeline(&self) -> PipelineId { + return self.pipelineid; + } } diff --git a/components/script/script_task.rs b/components/script/script_task.rs index c4efab48169..3c54259fc3e 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -592,6 +592,14 @@ pub unsafe extern "C" fn shadow_check_callback(_cx: *mut JSContext, DOMProxyShadowsResult::ShadowCheckFailed } +#[derive(JSTraceable, HeapSizeOf)] +pub struct CSSError { + filename: String, + line: usize, + column: usize, + msg: String +} + impl ScriptTask { pub fn page_fetch_complete(id: PipelineId, subpage: Option<SubpageId>, metadata: Metadata) -> Option<ParserRoot> { @@ -1009,7 +1017,9 @@ impl ScriptTask { ConstellationControlMsg::GetCurrentState(sender, pipeline_id) => { let state = self.handle_get_current_state(pipeline_id); sender.send(state).unwrap(); - } + }, + ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) => + self.handle_css_error_reporting(pipeline_id, filename, line, column, msg), } } @@ -2054,6 +2064,24 @@ impl ScriptTask { // script runs? self.notify_devtools(document.Title(), (*final_url).clone(), (id, None)); } + + fn handle_css_error_reporting(&self, pipeline_id: PipelineId, filename: String, + line: usize, column: usize, msg: String) { + let parent_page = self.root_page(); + let page = match parent_page.find(pipeline_id) { + Some(page) => page, + None => return, + }; + + let document = page.document(); + let css_error = CSSError { + filename: filename, + line: line, + column: column, + msg: msg + }; + document.report_css_error(css_error); + } } impl Drop for ScriptTask { diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 09aeef32785..159fe3c5549 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -151,6 +151,8 @@ pub enum ConstellationControlMsg { /// The pipeline that contains a frame loading the target pipeline. parent: PipelineId }, + /// Report an error from a CSS parser for the given pipeline + ReportCSSError(PipelineId, String, usize, usize, String), } /// The type of input represented by a multi-touch event. diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 17ab2908c95..397c5589f29 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -1115,6 +1115,7 @@ dependencies = [ "azure 0.2.1 (git+https://github.com/servo/rust-azure)", "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "io-surface 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1772,6 +1773,7 @@ dependencies = [ "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "msg 0.0.1", "num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1792,6 +1794,7 @@ dependencies = [ "app_units 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "msg 0.0.1", "plugins 0.0.1", "selectors 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index a89e2a1e95d..27d0e8a5fb1 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -9,6 +9,9 @@ build = "build.rs" name = "style" path = "lib.rs" +[dependencies.msg] +path = "../msg" + [dependencies.plugins] path = "../plugins" diff --git a/components/style/lib.rs b/components/style/lib.rs index f9b2953d453..4baa68eeca5 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -28,6 +28,7 @@ extern crate lazy_static; extern crate log; #[macro_use] extern crate matches; +extern crate msg; extern crate num; extern crate rustc_serialize; #[macro_use(state_pseudo_classes)] extern crate selectors; diff --git a/components/style/parser.rs b/components/style/parser.rs index 870d761d611..83e380ad94d 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -4,8 +4,8 @@ use cssparser::{Parser, SourcePosition}; +use msg::ParseErrorReporter; use selectors::parser::ParserContext as SelectorParserContext; -use style_traits::ParseErrorReporter; use stylesheets::Origin; use url::{Url, UrlParser}; @@ -13,7 +13,7 @@ pub struct ParserContext<'a> { pub stylesheet_origin: Origin, pub base_url: &'a Url, pub selector_context: SelectorParserContext, - pub error_reporter: Box<ParseErrorReporter + Send> + pub error_reporter: Box<ParseErrorReporter + Send>, } impl<'a> ParserContext<'a> { diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index e6ec877904a..6e9e4949644 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -21,8 +21,8 @@ use util::logical_geometry::{LogicalMargin, PhysicalSide, WritingMode}; use euclid::SideOffsets2D; use euclid::size::Size2D; use fnv::FnvHasher; +use msg::ParseErrorReporter; use string_cache::Atom; -use style_traits::ParseErrorReporter; use computed_values; use parser::{ParserContext, log_css_error}; use selectors::matching::DeclarationBlock; @@ -130,12 +130,12 @@ pub mod longhands { use parser::ParserContext; use properties::{CSSWideKeyword, DeclaredValue, Shorthand}; % endif + use msg::ParseErrorReporter; use properties::longhands; use properties::property_bit_field::PropertyBitField; use properties::{ComputedValues, PropertyDeclaration}; use std::collections::HashMap; use std::sync::Arc; - use style_traits::ParseErrorReporter; use values::computed::ToComputedValue; use values::{computed, specified}; use string_cache::Atom; diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index f87754d137e..4dae08ce9bd 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -5,6 +5,8 @@ use cssparser::{Parser, SourcePosition}; use log; use media_queries::{Device, MediaType}; +use msg::ParseErrorReporter; +use msg::constellation_msg::PipelineId; use node::TElementAttributes; use properties::{PropertyDeclaration, PropertyDeclarationBlock}; use restyle_hints::{ElementSnapshot, RestyleHint, DependencySet}; @@ -16,7 +18,6 @@ use selectors::parser::PseudoElement; use selectors::states::*; use smallvec::VecLike; use std::process; -use style_traits::ParseErrorReporter; use style_traits::viewport::ViewportConstraints; use stylesheets::{CSSRuleIteratorExt, Origin, Stylesheet}; use url::Url; @@ -27,7 +28,7 @@ use viewport::{MaybeNew, ViewportRuleCascade}; pub type DeclarationBlock = GenericDeclarationBlock<Vec<PropertyDeclaration>>; -struct StdoutErrorReporter; +pub struct StdoutErrorReporter; impl ParseErrorReporter for StdoutErrorReporter { fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) { @@ -40,6 +41,10 @@ impl ParseErrorReporter for StdoutErrorReporter { fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> { box StdoutErrorReporter } + + fn pipeline(&self) -> PipelineId { + return PipelineId::fake_root_pipeline_id(); + } } lazy_static! { diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 109f3bb8565..8da4bc5e94a 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -7,6 +7,7 @@ use cssparser::{AtRuleType, RuleListParser}; use encoding::EncodingRef; use font_face::{FontFaceRule, parse_font_face_block}; use media_queries::{Device, MediaQueryList, parse_media_query_list}; +use msg::ParseErrorReporter; use parser::{ParserContext, log_css_error}; use properties::{PropertyDeclarationBlock, parse_property_declaration_list}; use selectors::parser::{Selector, parse_selector_list}; @@ -16,7 +17,6 @@ use std::cell::Cell; use std::iter::Iterator; use std::slice; use string_cache::{Atom, Namespace}; -use style_traits::ParseErrorReporter; use url::Url; use util::mem::HeapSizeOf; use viewport::ViewportRule; diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index 6d088cc7e0d..5a56874514d 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -25,8 +25,3 @@ extern crate util; pub mod values; pub mod viewport; -use cssparser::{Parser, SourcePosition}; -pub trait ParseErrorReporter { - fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str); - fn clone(&self) -> Box<ParseErrorReporter + Send + Sync>; -} diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 59786711aef..7d015b0343d 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -1075,6 +1075,7 @@ dependencies = [ "azure 0.2.1 (git+https://github.com/servo/rust-azure)", "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "io-surface 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1724,6 +1725,7 @@ dependencies = [ "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "msg 0.0.1", "num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index b531d36088c..9c937c7e715 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -1051,6 +1051,7 @@ dependencies = [ "azure 0.2.1 (git+https://github.com/servo/rust-azure)", "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "io-surface 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1698,6 +1699,7 @@ dependencies = [ "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "msg 0.0.1", "num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml index 86b331249a9..0db53235f76 100644 --- a/tests/unit/style/Cargo.toml +++ b/tests/unit/style/Cargo.toml @@ -8,6 +8,9 @@ name = "style_tests" path = "lib.rs" doctest = false +[dependencies.msg] +path = "../../../components/msg" + [dependencies.plugins] path = "../../../components/plugins" diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs index a405d76108d..ffbc02bccf8 100644 --- a/tests/unit/style/lib.rs +++ b/tests/unit/style/lib.rs @@ -9,6 +9,7 @@ extern crate app_units; extern crate cssparser; extern crate euclid; +extern crate msg; extern crate selectors; #[macro_use(atom, ns)] extern crate string_cache; extern crate style; diff --git a/tests/unit/style/media_queries.rs b/tests/unit/style/media_queries.rs index c0c4b4a3f5e..bc14ccab671 100644 --- a/tests/unit/style/media_queries.rs +++ b/tests/unit/style/media_queries.rs @@ -5,11 +5,12 @@ use app_units::Au; use cssparser::{Parser, SourcePosition}; use euclid::size::Size2D; +use msg::ParseErrorReporter; +use msg::constellation_msg::PipelineId; use std::borrow::ToOwned; use style::media_queries::*; use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt}; use style::values::specified; -use style_traits::ParseErrorReporter; pub struct CSSErrorReporterTest; @@ -17,9 +18,11 @@ impl ParseErrorReporter for CSSErrorReporterTest { fn report_error(&self, _input: &mut Parser, _position: SourcePosition, _message: &str) { } fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> { - let error_reporter = Box::new(CSSErrorReporterTest); - return error_reporter; + Box::new(CSSErrorReporterTest) } + fn pipeline(&self) -> PipelineId { + return PipelineId::fake_root_pipeline_id(); + } } fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaQueryList, &str) { diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index d18c3db3c1c..a929f487bc4 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -21,7 +21,8 @@ fn test_parse_stylesheet() { #d1 > .ok { background: blue; } "; let url = url!("about::test"); - let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent, Box::new(CSSErrorReporterTest)); + let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent, + Box::new(CSSErrorReporterTest)); assert_eq!(stylesheet, Stylesheet { origin: Origin::UserAgent, media: None, diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs index f23346b53fb..08ac70dfca5 100644 --- a/tests/unit/style/viewport.rs +++ b/tests/unit/style/viewport.rs @@ -6,6 +6,7 @@ use cssparser::Parser; use euclid::scale_factor::ScaleFactor; use euclid::size::Size2D; use media_queries::CSSErrorReporterTest; +use msg::ParseErrorReporter; use style::media_queries::{Device, MediaType}; use style::parser::ParserContext; use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt}; @@ -13,7 +14,6 @@ use style::values::specified::Length::{self, ViewportPercentage}; use style::values::specified::LengthOrPercentageOrAuto::{self, Auto}; use style::values::specified::ViewportPercentageLength::Vw; use style::viewport::*; -use style_traits::ParseErrorReporter; use style_traits::viewport::*; macro_rules! stylesheet { |