aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/Cargo.toml3
-rw-r--r--components/script/dom/cssstyledeclaration.rs3
-rw-r--r--components/script/dom/element.rs4
-rw-r--r--components/script/dom/htmllinkelement.rs8
-rw-r--r--components/script/dom/htmlstyleelement.rs2
-rw-r--r--components/script/dom/window.rs12
-rw-r--r--components/script/lib.rs2
-rw-r--r--components/script/reporter.rs25
8 files changed, 52 insertions, 7 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index 04c9e98bed5..f30c63db4a0 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -36,6 +36,9 @@ path = "../devtools_traits"
[dependencies.style]
path = "../style"
+[dependencies.style_traits]
+path = "../style_traits"
+
[dependencies.canvas]
path = "../canvas"
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index 14285dc4c2e..64b6f738d2f 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -18,6 +18,7 @@ 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
@@ -240,7 +241,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 6
let window = window_from_node(&*self.owner);
- let declarations = parse_one_declaration(&property, &value, &window.get_url());
+ let declarations = parse_one_declaration(&property, &value, &window.get_url(), window.css_error_reporter());
// Step 7
let declarations = if let Ok(declarations) = declarations {
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 92ac3c8e1b2..f7640d3e7ff 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -80,6 +80,7 @@ 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};
@@ -1514,7 +1515,8 @@ impl VirtualMethods for Element {
// Modifying the `style` attribute might change style.
*self.style_attribute.borrow_mut() =
mutation.new_value(attr).map(|value| {
- parse_style_attribute(&value, &doc.base_url())
+ let win = window_from_node(self);
+ parse_style_attribute(&value, &doc.base_url(), win.css_error_reporter())
});
if node.is_in_doc() {
doc.content_changed(node, NodeDamage::NodeStyleDamaged);
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index b0954796b8d..2687d758948 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -281,13 +281,17 @@ impl AsyncResponseListener for StylesheetContext {
let environment_encoding = UTF_8 as EncodingRef;
let protocol_encoding_label = metadata.charset.as_ref().map(|s| &**s);
let final_url = metadata.final_url;
+
+ let elem = self.elem.root();
+ let win = window_from_node(&*elem);
+
let mut sheet = Stylesheet::from_bytes(&data, final_url, protocol_encoding_label,
- Some(environment_encoding), Origin::Author);
+ Some(environment_encoding), Origin::Author,
+ win.css_error_reporter());
let media = self.media.take().unwrap();
sheet.set_media(Some(media));
let sheet = Arc::new(sheet);
- let elem = self.elem.root();
let elem = elem.r();
let document = document_from_node(elem);
let document = document.r();
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs
index 42c4d0315ac..8eba6b5982f 100644
--- a/components/script/dom/htmlstyleelement.rs
+++ b/components/script/dom/htmlstyleelement.rs
@@ -58,7 +58,7 @@ impl HTMLStyleElement {
};
let data = node.GetTextContent().expect("Element.textContent must be a string");
- let mut sheet = Stylesheet::from_str(&data, url, Origin::Author);
+ let mut sheet = Stylesheet::from_str(&data, url, Origin::Author, win.css_error_reporter());
let mut css_parser = CssParser::new(&mq_str);
let media = parse_media_query_list(&mut css_parser);
sheet.set_media(Some(media));
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 2910632a76f..f8af9be77b5 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -52,6 +52,7 @@ use net_traits::storage_task::{StorageTask, StorageType};
use num::traits::ToPrimitive;
use page::Page;
use profile_traits::mem;
+use reporter::CSSErrorReporter;
use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
use script_task::{ScriptChan, ScriptPort, MainThreadScriptMsg, RunnableWrapper};
use script_task::{SendableMainThreadScriptChan, MainThreadScriptChan};
@@ -70,6 +71,7 @@ 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;
@@ -216,6 +218,8 @@ pub struct Window {
/// A flag to prevent async events from attempting to interact with this window.
#[ignore_heap_size_of = "defined in std"]
ignore_further_async_events: Arc<AtomicBool>,
+
+ error_reporter: CSSErrorReporter,
}
impl Window {
@@ -289,6 +293,10 @@ impl Window {
pub fn storage_task(&self) -> StorageTask {
self.storage_task.clone()
}
+
+ pub fn css_error_reporter(&self) -> Box<ParseErrorReporter + Send> {
+ return self.error_reporter.clone();
+ }
}
// https://html.spec.whatwg.org/multipage/#atob
@@ -1243,7 +1251,7 @@ impl Window {
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
rpc_recv.recv().unwrap()
};
-
+ let error_reporter = CSSErrorReporter;
let win = box Window {
eventtarget: EventTarget::new_inherited(),
script_chan: script_chan,
@@ -1288,8 +1296,8 @@ impl Window {
devtools_markers: DOMRefCell::new(HashSet::new()),
devtools_wants_updates: Cell::new(false),
webdriver_script_chan: DOMRefCell::new(None),
-
ignore_further_async_events: Arc::new(AtomicBool::new(false)),
+ error_reporter: error_reporter
};
WindowBinding::Wrap(runtime.cx(), win)
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 0d0278f7172..4f1d9f66cd0 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -42,6 +42,7 @@ extern crate log;
extern crate profile_traits;
#[macro_use]
extern crate style;
+extern crate style_traits;
#[macro_use]
extern crate util;
extern crate angle;
@@ -90,6 +91,7 @@ mod mem;
mod network_listener;
pub mod page;
pub mod parse;
+pub mod reporter;
#[allow(unsafe_code)]
pub mod script_task;
pub mod textinput;
diff --git a/components/script/reporter.rs b/components/script/reporter.rs
new file mode 100644
index 00000000000..16958201103
--- /dev/null
+++ b/components/script/reporter.rs
@@ -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;
+use style_traits::ParseErrorReporter;
+
+#[derive(JSTraceable, HeapSizeOf)]
+pub struct CSSErrorReporter;
+
+impl ParseErrorReporter for CSSErrorReporter {
+ fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
+ if log_enabled!(log::LogLevel::Info) {
+ let location = input.source_location(position);
+ // TODO eventually this will got into a "web console" or something.
+ info!("{}:{} {}", location.line, location.column, message)
+ }
+ }
+
+ fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
+ let error_reporter = box CSSErrorReporter;
+ return error_reporter;
+ }
+}