mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Hoist ParseErrorReporter into style and remove the dependency on msg.
The pipeline id stuff is currently unused. If someone needs it, they can add an additional trait bound on their css error reporter to get the pipeline id.
This commit is contained in:
parent
a03747e12b
commit
384cdfcfff
20 changed files with 39 additions and 79 deletions
|
@ -9,9 +9,6 @@ build = "build.rs"
|
|||
name = "style"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies.msg]
|
||||
path = "../msg"
|
||||
|
||||
[dependencies.plugins]
|
||||
path = "../plugins"
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
use animation::Animation;
|
||||
use app_units::Au;
|
||||
use dom::OpaqueNode;
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use euclid::Size2D;
|
||||
use matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
|
||||
use msg::ParseErrorReporter;
|
||||
use selector_matching::Stylist;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
|
|
25
components/style/error_reporting.rs
Normal file
25
components/style/error_reporting.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::{Parser, SourcePosition};
|
||||
use log;
|
||||
|
||||
pub trait ParseErrorReporter {
|
||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str);
|
||||
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync>;
|
||||
}
|
||||
|
||||
pub struct StdoutErrorReporter;
|
||||
impl ParseErrorReporter for StdoutErrorReporter {
|
||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
let location = input.source_location(position);
|
||||
info!("{}:{} {}", location.line, location.column, message)
|
||||
}
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
||||
box StdoutErrorReporter
|
||||
}
|
||||
}
|
|
@ -31,7 +31,6 @@ 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;
|
||||
|
@ -50,6 +49,7 @@ pub mod context;
|
|||
mod custom_properties;
|
||||
pub mod data;
|
||||
pub mod dom;
|
||||
pub mod error_reporting;
|
||||
pub mod font_face;
|
||||
pub mod matching;
|
||||
pub mod media_queries;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
use cssparser::{Parser, SourcePosition};
|
||||
use msg::ParseErrorReporter;
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use selectors::parser::ParserContext as SelectorParserContext;
|
||||
use stylesheets::Origin;
|
||||
use url::Url;
|
||||
|
|
|
@ -16,12 +16,12 @@ use std::sync::Arc;
|
|||
use app_units::Au;
|
||||
use cssparser::{Parser, Color, RGBA, AtRuleParser, DeclarationParser, Delimiter,
|
||||
DeclarationListParser, parse_important, ToCss, TokenSerializationType};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use url::Url;
|
||||
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 computed_values;
|
||||
use parser::{ParserContext, log_css_error};
|
||||
|
@ -130,7 +130,7 @@ pub mod longhands {
|
|||
use parser::ParserContext;
|
||||
use properties::{CSSWideKeyword, DeclaredValue, Shorthand};
|
||||
% endif
|
||||
use msg::ParseErrorReporter;
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use properties::longhands;
|
||||
use properties::property_bit_field::PropertyBitField;
|
||||
use properties::{ComputedValues, PropertyDeclaration};
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
// For lazy_static
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use cssparser::{Parser, SourcePosition};
|
||||
use dom::TElement;
|
||||
use log;
|
||||
use error_reporting::{ParseErrorReporter, StdoutErrorReporter};
|
||||
use media_queries::{Device, MediaType};
|
||||
use msg::ParseErrorReporter;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use restyle_hints::{ElementSnapshot, RestyleHint, DependencySet};
|
||||
use selectors::Element;
|
||||
|
@ -32,25 +29,6 @@ use viewport::{MaybeNew, ViewportRuleCascade};
|
|||
|
||||
pub type DeclarationBlock = GenericDeclarationBlock<Vec<PropertyDeclaration>>;
|
||||
|
||||
pub struct StdoutErrorReporter;
|
||||
|
||||
impl ParseErrorReporter for StdoutErrorReporter {
|
||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
let location = input.source_location(position);
|
||||
info!("{}:{} {}", location.line, location.column, message)
|
||||
}
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
||||
box StdoutErrorReporter
|
||||
}
|
||||
|
||||
fn pipeline(&self) -> PipelineId {
|
||||
PipelineId::fake_root_pipeline_id()
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref USER_OR_USER_AGENT_STYLESHEETS: Vec<Stylesheet> = {
|
||||
let mut stylesheets = vec!();
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, decode_stylesheet_bytes};
|
||||
use cssparser::{AtRuleType, RuleListParser};
|
||||
use encoding::EncodingRef;
|
||||
use error_reporting::ParseErrorReporter;
|
||||
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};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue