mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Add pipeline information to CSS error reporting.
This commit is contained in:
parent
6032f8225b
commit
fc81276c8e
27 changed files with 103 additions and 29 deletions
|
@ -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
|
||||
|
|
|
@ -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![]),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue