forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
CSS parse error reporting
Josh Matthews edited this page Sep 17, 2015
·
2 revisions
Background information: Firefox supports remote developer tools - ie. communicating with an arbitrary server that implements a protocol for exposing information about web content. Servo implements a very basic developer tools server that currently supports executing JS remotely and investigating the DOM tree in the document inspector. We want to expand these capabilities by exposing CSS parsing errors.
Initial steps:
- compile Servo and ensure that it runs on
tests/html/about-mozilla.html
- email the mozilla.dev.servo mailing list introducing your group and your progress
- find an interesting site that doesn't crash Servo and attach the developer tools
- define a new trait called
ParseErrorReporter
incomponents/style_traits/lib.rs
with an appropriate method to report an error, and add aerror_reporter
member toParserContext
that uses this - make
log_css_error
incomponents/style/parser.rs
take a&ParserContext
argument and call this method - extract the existing code from
log_css_err
into a new type that implementsParseErrorReporter
incomponents/layout/layout_task.rs
and pass instances of that type to any code that ends up creating aParserContext
value - at this point, Servo should compile and execute almost exactly as before, but where
RUST_LOG=style
used to expose CSS errors, nowRUST_LOG=layout::layout_task
will be required instead.
Subsequent steps:
- Add a
PipelineId
(fromcomponents/msg/constellation_msg.rs
) member toParserContext
, to represent the source of parse errors that occur - Define a new message type in
ConstellationControlMsg
which contains all of the information necessary to report a CSS error (including the pipeline ID), and make this new error reporter communicate with the script thread by sending messages over aSender<ConstellationControlMsg>
value that can be obtained from the code inlayout_task.rs
. - Process the new message type in
components/script/script_task.rs
by:- caching each reported parse error in a vector in
Document
(components/script/dom/document.rs
) - checking the
devtools_wants_updates
flag and sending it to the devtools server if it exists (seenotify_devtools
for a model inscript_task.rs
)
- caching each reported parse error in a vector in
- Retrieve any cached parse errors for a document on request in
handle_get_cached_messages
incomponents/scripts/devtools.rs