Add pipeline information to CSS error reporting.

This commit is contained in:
GauriGNaik 2015-12-04 19:19:21 -05:00 committed by Josh Matthews
parent 6032f8225b
commit fc81276c8e
27 changed files with 103 additions and 29 deletions

View file

@ -15,6 +15,7 @@ use gfx::display_list::OpaqueNode;
use gfx::font_cache_task::FontCacheTask; use gfx::font_cache_task::FontCacheTask;
use gfx::font_context::FontContext; use gfx::font_context::FontContext;
use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::ipc::{self, IpcSender};
use msg::ParseErrorReporter;
use msg::compositor_msg::LayerId; use msg::compositor_msg::LayerId;
use net_traits::image::base::Image; use net_traits::image::base::Image;
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageResponse, ImageState}; 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::mpsc::{Sender, channel};
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use style::selector_matching::Stylist; use style::selector_matching::Stylist;
use style_traits::ParseErrorReporter;
use url::Url; use url::Url;
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
use util::opts; use util::opts;

View file

@ -10,6 +10,7 @@ use animation;
use context::SharedLayoutContext; use context::SharedLayoutContext;
use data::LayoutDataWrapper; use data::LayoutDataWrapper;
use incremental::{self, RestyleDamage}; use incremental::{self, RestyleDamage};
use msg::ParseErrorReporter;
use script::dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId}; use script::dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId};
use script::layout_interface::Animation; use script::layout_interface::Animation;
use selectors::bloom::BloomFilter; use selectors::bloom::BloomFilter;
@ -27,7 +28,6 @@ use string_cache::{Atom, Namespace};
use style::node::TElementAttributes; use style::node::TElementAttributes;
use style::properties::{ComputedValues, PropertyDeclaration, cascade}; use style::properties::{ComputedValues, PropertyDeclaration, cascade};
use style::selector_matching::{DeclarationBlock, Stylist}; use style::selector_matching::{DeclarationBlock, Stylist};
use style_traits::ParseErrorReporter;
use util::arc_ptr_eq; use util::arc_ptr_eq;
use util::cache::{LRUCache, SimpleHashCache}; use util::cache::{LRUCache, SimpleHashCache};
use util::opts; use util::opts;

View file

@ -34,6 +34,7 @@ use ipc_channel::router::ROUTER;
use layout_debug; use layout_debug;
use layout_traits::LayoutTaskFactory; use layout_traits::LayoutTaskFactory;
use log; use log;
use msg::ParseErrorReporter;
use msg::compositor_msg::{Epoch, LayerId, ScrollPolicy}; use msg::compositor_msg::{Epoch, LayerId, ScrollPolicy};
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask}; 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::media_queries::{Device, MediaType};
use style::selector_matching::{Stylist, USER_OR_USER_AGENT_STYLESHEETS}; use style::selector_matching::{Stylist, USER_OR_USER_AGENT_STYLESHEETS};
use style::stylesheets::{CSSRuleIteratorExt, Stylesheet}; use style::stylesheets::{CSSRuleIteratorExt, Stylesheet};
use style_traits::ParseErrorReporter;
use url::Url; use url::Url;
use util::geometry::MAX_RECT; use util::geometry::MAX_RECT;
use util::ipc::OptionalIpcSender; use util::ipc::OptionalIpcSender;
@ -444,7 +444,7 @@ impl LayoutTask {
resolved_style_response: None, resolved_style_response: None,
offset_parent_response: OffsetParentResponse::empty(), offset_parent_response: OffsetParentResponse::empty(),
})), })),
error_reporter: CSSErrorReporter, error_reporter: CSSErrorReporter { pipelineid: id },
} }
} }

View file

@ -25,6 +25,7 @@ git = "https://github.com/servo/ipc-channel"
path = "../plugins" path = "../plugins"
[dependencies] [dependencies]
cssparser = { version = "0.4", features = [ "serde-serialization" ] }
app_units = {version = "0.1", features = ["plugins"]} app_units = {version = "0.1", features = ["plugins"]}
bitflags = "0.3" bitflags = "0.3"
hyper = { version = "0.7", features = [ "serde-serialization" ] } hyper = { version = "0.7", features = [ "serde-serialization" ] }

View file

@ -11,6 +11,7 @@ extern crate azure;
extern crate bitflags; extern crate bitflags;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
extern crate core_foundation; extern crate core_foundation;
extern crate cssparser;
extern crate euclid; extern crate euclid;
extern crate hyper; extern crate hyper;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
@ -25,3 +26,12 @@ extern crate util;
pub mod compositor_msg; pub mod compositor_msg;
pub mod constellation_msg; pub mod constellation_msg;
pub mod webdriver_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;
}

View file

@ -11,6 +11,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::element::{Element, StylePriority}; use dom::element::{Element, StylePriority};
use dom::node::{Node, NodeDamage, document_from_node, window_from_node}; use dom::node::{Node, NodeDamage, document_from_node, window_from_node};
use dom::window::Window; use dom::window::Window;
use msg::ParseErrorReporter;
use selectors::parser::PseudoElement; use selectors::parser::PseudoElement;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::ToOwned; use std::borrow::ToOwned;
@ -18,7 +19,6 @@ use std::cell::Ref;
use string_cache::Atom; use string_cache::Atom;
use style::properties::{PropertyDeclaration, Shorthand}; use style::properties::{PropertyDeclaration, Shorthand};
use style::properties::{is_supported_property, parse_one_declaration}; use style::properties::{is_supported_property, parse_one_declaration};
use style_traits::ParseErrorReporter;
use util::str::{DOMString, str_join}; use util::str::{DOMString, str_join};
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface

View file

@ -89,6 +89,7 @@ use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl};
use net_traits::CookieSource::NonHTTP; use net_traits::CookieSource::NonHTTP;
use net_traits::{AsyncResponseTarget, PendingAsyncLoad}; use net_traits::{AsyncResponseTarget, PendingAsyncLoad};
use num::ToPrimitive; use num::ToPrimitive;
use script_task::CSSError;
use script_task::{MainThreadScriptMsg, Runnable}; use script_task::{MainThreadScriptMsg, Runnable};
use script_traits::{ScriptMsg as ConstellationMsg, TouchEventType, TouchId, UntrustedNodeAddress}; use script_traits::{ScriptMsg as ConstellationMsg, TouchEventType, TouchId, UntrustedNodeAddress};
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
@ -203,6 +204,8 @@ pub struct Document {
dom_content_loaded_event_start: Cell<u64>, dom_content_loaded_event_start: Cell<u64>,
dom_content_loaded_event_end: Cell<u64>, dom_content_loaded_event_end: Cell<u64>,
dom_complete: Cell<u64>, dom_complete: Cell<u64>,
/// Vector to store CSS errors
css_errors_store: DOMRefCell<Vec<CSSError>>,
} }
impl PartialEq for Document { impl PartialEq for Document {
@ -294,6 +297,10 @@ impl Document {
self.is_html_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 // https://html.spec.whatwg.org/multipage/#fully-active
pub fn is_fully_active(&self) -> bool { pub fn is_fully_active(&self) -> bool {
let browsing_context = self.window.browsing_context(); 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_start: Cell::new(Default::default()),
dom_content_loaded_event_end: Cell::new(Default::default()), dom_content_loaded_event_end: Cell::new(Default::default()),
dom_complete: Cell::new(Default::default()), dom_complete: Cell::new(Default::default()),
css_errors_store: DOMRefCell::new(vec![]),
} }
} }

View file

@ -63,6 +63,7 @@ use html5ever::serialize::SerializeOpts;
use html5ever::serialize::TraversalScope; use html5ever::serialize::TraversalScope;
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks}; use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks};
use msg::ParseErrorReporter;
use selectors::matching::{DeclarationBlock, matches}; use selectors::matching::{DeclarationBlock, matches};
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes}; use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str}; 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::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
use style::values::CSSFloat; use style::values::CSSFloat;
use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage}; use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage};
use style_traits::ParseErrorReporter;
use url::UrlParser; use url::UrlParser;
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
use util::str::{DOMString, LengthOrPercentageOrAuto}; use util::str::{DOMString, LengthOrPercentageOrAuto};

View file

@ -42,6 +42,7 @@ use js::rust::Runtime;
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow}; use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType}; use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType};
use libc; use libc;
use msg::ParseErrorReporter;
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg}; use msg::compositor_msg::{LayerId, ScriptToCompositorMsg};
use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData}; use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; 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::TryRecvError::{Disconnected, Empty};
use std::sync::mpsc::{Sender, channel}; use std::sync::mpsc::{Sender, channel};
use string_cache::Atom; use string_cache::Atom;
use style_traits::ParseErrorReporter;
use time; use time;
use timers::{ActiveTimers, IsInterval, ScheduledCallback, TimerCallback, TimerHandle}; use timers::{ActiveTimers, IsInterval, ScheduledCallback, TimerCallback, TimerHandle};
use url::Url; use url::Url;
@ -1272,7 +1272,7 @@ impl Window {
lchan.send(Msg::GetRPC(rpc_send)).unwrap(); lchan.send(Msg::GetRPC(rpc_send)).unwrap();
rpc_recv.recv().unwrap() rpc_recv.recv().unwrap()
}; };
let error_reporter = CSSErrorReporter; let error_reporter = CSSErrorReporter { pipelineid: id };
let win = box Window { let win = box Window {
eventtarget: EventTarget::new_inherited(), eventtarget: EventTarget::new_inherited(),
script_chan: script_chan, script_chan: script_chan,

View file

@ -4,10 +4,13 @@
use cssparser::{Parser, SourcePosition}; use cssparser::{Parser, SourcePosition};
use log; use log;
use style_traits::ParseErrorReporter; use msg::ParseErrorReporter;
use msg::constellation_msg::PipelineId;
#[derive(JSTraceable, HeapSizeOf)] #[derive(JSTraceable, HeapSizeOf)]
pub struct CSSErrorReporter; pub struct CSSErrorReporter {
pub pipelineid: PipelineId,
}
impl ParseErrorReporter for CSSErrorReporter { impl ParseErrorReporter for CSSErrorReporter {
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) { 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> { fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
let error_reporter = box CSSErrorReporter; let error_reporter = box CSSErrorReporter { pipelineid: self.pipelineid, } ;
return error_reporter; return error_reporter;
} }
fn pipeline(&self) -> PipelineId {
return self.pipelineid;
}
} }

View file

@ -592,6 +592,14 @@ pub unsafe extern "C" fn shadow_check_callback(_cx: *mut JSContext,
DOMProxyShadowsResult::ShadowCheckFailed DOMProxyShadowsResult::ShadowCheckFailed
} }
#[derive(JSTraceable, HeapSizeOf)]
pub struct CSSError {
filename: String,
line: usize,
column: usize,
msg: String
}
impl ScriptTask { impl ScriptTask {
pub fn page_fetch_complete(id: PipelineId, subpage: Option<SubpageId>, metadata: Metadata) pub fn page_fetch_complete(id: PipelineId, subpage: Option<SubpageId>, metadata: Metadata)
-> Option<ParserRoot> { -> Option<ParserRoot> {
@ -1009,7 +1017,9 @@ impl ScriptTask {
ConstellationControlMsg::GetCurrentState(sender, pipeline_id) => { ConstellationControlMsg::GetCurrentState(sender, pipeline_id) => {
let state = self.handle_get_current_state(pipeline_id); let state = self.handle_get_current_state(pipeline_id);
sender.send(state).unwrap(); 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? // script runs?
self.notify_devtools(document.Title(), (*final_url).clone(), (id, None)); 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 { impl Drop for ScriptTask {

View file

@ -151,6 +151,8 @@ pub enum ConstellationControlMsg {
/// The pipeline that contains a frame loading the target pipeline. /// The pipeline that contains a frame loading the target pipeline.
parent: PipelineId 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. /// The type of input represented by a multi-touch event.

View file

@ -1115,6 +1115,7 @@ dependencies = [
"azure 0.2.1 (git+https://github.com/servo/rust-azure)", "azure 0.2.1 (git+https://github.com/servo/rust-azure)",
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "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)", "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)", "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)", "num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1", "plugins 0.0.1",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "euclid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"plugins 0.0.1", "plugins 0.0.1",
"selectors 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "string_cache 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -9,6 +9,9 @@ build = "build.rs"
name = "style" name = "style"
path = "lib.rs" path = "lib.rs"
[dependencies.msg]
path = "../msg"
[dependencies.plugins] [dependencies.plugins]
path = "../plugins" path = "../plugins"

View file

@ -28,6 +28,7 @@ extern crate lazy_static;
extern crate log; extern crate log;
#[macro_use] #[macro_use]
extern crate matches; extern crate matches;
extern crate msg;
extern crate num; extern crate num;
extern crate rustc_serialize; extern crate rustc_serialize;
#[macro_use(state_pseudo_classes)] extern crate selectors; #[macro_use(state_pseudo_classes)] extern crate selectors;

View file

@ -4,8 +4,8 @@
use cssparser::{Parser, SourcePosition}; use cssparser::{Parser, SourcePosition};
use msg::ParseErrorReporter;
use selectors::parser::ParserContext as SelectorParserContext; use selectors::parser::ParserContext as SelectorParserContext;
use style_traits::ParseErrorReporter;
use stylesheets::Origin; use stylesheets::Origin;
use url::{Url, UrlParser}; use url::{Url, UrlParser};
@ -13,7 +13,7 @@ pub struct ParserContext<'a> {
pub stylesheet_origin: Origin, pub stylesheet_origin: Origin,
pub base_url: &'a Url, pub base_url: &'a Url,
pub selector_context: SelectorParserContext, pub selector_context: SelectorParserContext,
pub error_reporter: Box<ParseErrorReporter + Send> pub error_reporter: Box<ParseErrorReporter + Send>,
} }
impl<'a> ParserContext<'a> { impl<'a> ParserContext<'a> {

View file

@ -21,8 +21,8 @@ use util::logical_geometry::{LogicalMargin, PhysicalSide, WritingMode};
use euclid::SideOffsets2D; use euclid::SideOffsets2D;
use euclid::size::Size2D; use euclid::size::Size2D;
use fnv::FnvHasher; use fnv::FnvHasher;
use msg::ParseErrorReporter;
use string_cache::Atom; use string_cache::Atom;
use style_traits::ParseErrorReporter;
use computed_values; use computed_values;
use parser::{ParserContext, log_css_error}; use parser::{ParserContext, log_css_error};
use selectors::matching::DeclarationBlock; use selectors::matching::DeclarationBlock;
@ -130,12 +130,12 @@ pub mod longhands {
use parser::ParserContext; use parser::ParserContext;
use properties::{CSSWideKeyword, DeclaredValue, Shorthand}; use properties::{CSSWideKeyword, DeclaredValue, Shorthand};
% endif % endif
use msg::ParseErrorReporter;
use properties::longhands; use properties::longhands;
use properties::property_bit_field::PropertyBitField; use properties::property_bit_field::PropertyBitField;
use properties::{ComputedValues, PropertyDeclaration}; use properties::{ComputedValues, PropertyDeclaration};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use style_traits::ParseErrorReporter;
use values::computed::ToComputedValue; use values::computed::ToComputedValue;
use values::{computed, specified}; use values::{computed, specified};
use string_cache::Atom; use string_cache::Atom;

View file

@ -5,6 +5,8 @@
use cssparser::{Parser, SourcePosition}; use cssparser::{Parser, SourcePosition};
use log; use log;
use media_queries::{Device, MediaType}; use media_queries::{Device, MediaType};
use msg::ParseErrorReporter;
use msg::constellation_msg::PipelineId;
use node::TElementAttributes; use node::TElementAttributes;
use properties::{PropertyDeclaration, PropertyDeclarationBlock}; use properties::{PropertyDeclaration, PropertyDeclarationBlock};
use restyle_hints::{ElementSnapshot, RestyleHint, DependencySet}; use restyle_hints::{ElementSnapshot, RestyleHint, DependencySet};
@ -16,7 +18,6 @@ use selectors::parser::PseudoElement;
use selectors::states::*; use selectors::states::*;
use smallvec::VecLike; use smallvec::VecLike;
use std::process; use std::process;
use style_traits::ParseErrorReporter;
use style_traits::viewport::ViewportConstraints; use style_traits::viewport::ViewportConstraints;
use stylesheets::{CSSRuleIteratorExt, Origin, Stylesheet}; use stylesheets::{CSSRuleIteratorExt, Origin, Stylesheet};
use url::Url; use url::Url;
@ -27,7 +28,7 @@ use viewport::{MaybeNew, ViewportRuleCascade};
pub type DeclarationBlock = GenericDeclarationBlock<Vec<PropertyDeclaration>>; pub type DeclarationBlock = GenericDeclarationBlock<Vec<PropertyDeclaration>>;
struct StdoutErrorReporter; pub struct StdoutErrorReporter;
impl ParseErrorReporter for StdoutErrorReporter { impl ParseErrorReporter for StdoutErrorReporter {
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) { 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> { fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
box StdoutErrorReporter box StdoutErrorReporter
} }
fn pipeline(&self) -> PipelineId {
return PipelineId::fake_root_pipeline_id();
}
} }
lazy_static! { lazy_static! {

View file

@ -7,6 +7,7 @@ use cssparser::{AtRuleType, RuleListParser};
use encoding::EncodingRef; use encoding::EncodingRef;
use font_face::{FontFaceRule, parse_font_face_block}; use font_face::{FontFaceRule, parse_font_face_block};
use media_queries::{Device, MediaQueryList, parse_media_query_list}; use media_queries::{Device, MediaQueryList, parse_media_query_list};
use msg::ParseErrorReporter;
use parser::{ParserContext, log_css_error}; use parser::{ParserContext, log_css_error};
use properties::{PropertyDeclarationBlock, parse_property_declaration_list}; use properties::{PropertyDeclarationBlock, parse_property_declaration_list};
use selectors::parser::{Selector, parse_selector_list}; use selectors::parser::{Selector, parse_selector_list};
@ -16,7 +17,6 @@ use std::cell::Cell;
use std::iter::Iterator; use std::iter::Iterator;
use std::slice; use std::slice;
use string_cache::{Atom, Namespace}; use string_cache::{Atom, Namespace};
use style_traits::ParseErrorReporter;
use url::Url; use url::Url;
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
use viewport::ViewportRule; use viewport::ViewportRule;

View file

@ -25,8 +25,3 @@ extern crate util;
pub mod values; pub mod values;
pub mod viewport; 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>;
}

2
ports/cef/Cargo.lock generated
View file

@ -1075,6 +1075,7 @@ dependencies = [
"azure 0.2.1 (git+https://github.com/servo/rust-azure)", "azure 0.2.1 (git+https://github.com/servo/rust-azure)",
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "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)", "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)", "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)", "num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1", "plugins 0.0.1",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/gonk/Cargo.lock generated
View file

@ -1051,6 +1051,7 @@ dependencies = [
"azure 0.2.1 (git+https://github.com/servo/rust-azure)", "azure 0.2.1 (git+https://github.com/servo/rust-azure)",
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "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)", "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)", "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)", "num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1", "plugins 0.0.1",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -8,6 +8,9 @@ name = "style_tests"
path = "lib.rs" path = "lib.rs"
doctest = false doctest = false
[dependencies.msg]
path = "../../../components/msg"
[dependencies.plugins] [dependencies.plugins]
path = "../../../components/plugins" path = "../../../components/plugins"

View file

@ -9,6 +9,7 @@
extern crate app_units; extern crate app_units;
extern crate cssparser; extern crate cssparser;
extern crate euclid; extern crate euclid;
extern crate msg;
extern crate selectors; extern crate selectors;
#[macro_use(atom, ns)] extern crate string_cache; #[macro_use(atom, ns)] extern crate string_cache;
extern crate style; extern crate style;

View file

@ -5,11 +5,12 @@
use app_units::Au; use app_units::Au;
use cssparser::{Parser, SourcePosition}; use cssparser::{Parser, SourcePosition};
use euclid::size::Size2D; use euclid::size::Size2D;
use msg::ParseErrorReporter;
use msg::constellation_msg::PipelineId;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use style::media_queries::*; use style::media_queries::*;
use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt}; use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt};
use style::values::specified; use style::values::specified;
use style_traits::ParseErrorReporter;
pub struct CSSErrorReporterTest; pub struct CSSErrorReporterTest;
@ -17,8 +18,10 @@ impl ParseErrorReporter for CSSErrorReporterTest {
fn report_error(&self, _input: &mut Parser, _position: SourcePosition, _message: &str) { fn report_error(&self, _input: &mut Parser, _position: SourcePosition, _message: &str) {
} }
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> { fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
let error_reporter = Box::new(CSSErrorReporterTest); Box::new(CSSErrorReporterTest)
return error_reporter; }
fn pipeline(&self) -> PipelineId {
return PipelineId::fake_root_pipeline_id();
} }
} }

View file

@ -21,7 +21,8 @@ fn test_parse_stylesheet() {
#d1 > .ok { background: blue; } #d1 > .ok { background: blue; }
"; ";
let url = url!("about::test"); 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 { assert_eq!(stylesheet, Stylesheet {
origin: Origin::UserAgent, origin: Origin::UserAgent,
media: None, media: None,

View file

@ -6,6 +6,7 @@ use cssparser::Parser;
use euclid::scale_factor::ScaleFactor; use euclid::scale_factor::ScaleFactor;
use euclid::size::Size2D; use euclid::size::Size2D;
use media_queries::CSSErrorReporterTest; use media_queries::CSSErrorReporterTest;
use msg::ParseErrorReporter;
use style::media_queries::{Device, MediaType}; use style::media_queries::{Device, MediaType};
use style::parser::ParserContext; use style::parser::ParserContext;
use style::stylesheets::{Origin, Stylesheet, CSSRuleIteratorExt}; 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::LengthOrPercentageOrAuto::{self, Auto};
use style::values::specified::ViewportPercentageLength::Vw; use style::values::specified::ViewportPercentageLength::Vw;
use style::viewport::*; use style::viewport::*;
use style_traits::ParseErrorReporter;
use style_traits::viewport::*; use style_traits::viewport::*;
macro_rules! stylesheet { macro_rules! stylesheet {