Move CSSErrorReporter to script_layout_interface.

This commit is contained in:
Ms2ger 2016-06-16 16:01:50 +01:00
parent 9e2e0ff98c
commit b56821a01f
9 changed files with 16 additions and 4 deletions

View file

@ -12,12 +12,14 @@ path = "lib.rs"
app_units = {version = "0.2.3", features = ["plugins"]}
bitflags = "0.7"
canvas_traits = {path = "../canvas_traits"}
cssparser = {version = "0.5.4", features = ["heap_size", "serde-serialization"]}
euclid = {version = "0.6.4", features = ["plugins"]}
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
ipc-channel = {git = "https://github.com/servo/ipc-channel"}
libc = "0.2"
log = "0.3.5"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
profile_traits = {path = "../profile_traits"}

View file

@ -7,6 +7,7 @@
//! to depend on script.
#![deny(unsafe_code)]
#![feature(box_syntax)]
#![feature(custom_attribute)]
#![feature(custom_derive)]
#![feature(nonzero)]
@ -20,11 +21,14 @@ extern crate app_units;
extern crate bitflags;
extern crate canvas_traits;
extern crate core;
extern crate cssparser;
extern crate euclid;
extern crate gfx_traits;
extern crate heapsize;
extern crate ipc_channel;
extern crate libc;
#[macro_use]
extern crate log;
extern crate msg;
extern crate net_traits;
extern crate profile_traits;
@ -38,6 +42,7 @@ extern crate url;
extern crate util;
pub mod message;
pub mod reporter;
pub mod restyle_damage;
pub mod rpc;
pub mod wrapper_traits;

View file

@ -0,0 +1,44 @@
/* 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 ipc_channel::ipc::IpcSender;
use log;
use msg::constellation_msg::PipelineId;
use script_traits::ConstellationControlMsg;
use std::sync::{Mutex, Arc};
use style::error_reporting::ParseErrorReporter;
#[derive(HeapSizeOf)]
pub struct CSSErrorReporter {
pub pipelineid: PipelineId,
// Arc+Mutex combo is necessary to make this struct Sync,
// which is necessary to fulfill the bounds required by the
// uses of the ParseErrorReporter trait.
#[ignore_heap_size_of = "Arc is defined in libstd"]
pub script_chan: Arc<Mutex<IpcSender<ConstellationControlMsg>>>,
}
impl ParseErrorReporter for CSSErrorReporter {
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
let location = input.source_location(position);
if log_enabled!(log::LogLevel::Info) {
info!("{}:{} {}", location.line, location.column, message)
}
//TODO: report a real filename
let _ = self.script_chan.lock().unwrap().send(
ConstellationControlMsg::ReportCSSError(self.pipelineid,
"".to_owned(),
location.line,
location.column,
message.to_owned()));
}
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
box CSSErrorReporter {
pipelineid: self.pipelineid,
script_chan: self.script_chan.clone(),
}
}
}