Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.4k
CSS parse error reporting
Josh Matthews edited this pageSep 17, 2015 ·2 revisions
Background information: Firefox supportsremote 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 themozilla.dev.servo mailing list introducing your group and your progress
- find an interesting site that doesn't crash Servo andattach the developer tools
- define a new trait called
ParseErrorReporterincomponents/style_traits/lib.rswith an appropriate method to report an error, and add aerror_reportermember toParserContextthat uses this - make
log_css_errorincomponents/style/parser.rstake a&ParserContextargument and call this method - extract the existing code from
log_css_errinto a new type that implementsParseErrorReporterincomponents/layout/layout_task.rsand pass instances of that type to any code that ends up creating aParserContextvalue - at this point, Servo should compile and execute almost exactly as before, but where
RUST_LOG=styleused to expose CSS errors, nowRUST_LOG=layout::layout_taskwill 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
ConstellationControlMsgwhich 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.rsby:- caching each reported parse error in a vector in
Document(components/script/dom/document.rs) - checking the
devtools_wants_updatesflag and sending it to the devtools server if it exists (seenotify_devtoolsfor 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_messagesincomponents/scripts/devtools.rs