forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
Devtools CSS errors
jdm edited this page Oct 7, 2014
·
1 revision
- make ErrorLoggerIterator store a pipeline ID and Sender and send errors on it when encountered
- add pipeline and sender arguments to all components/style/ functions that transitively use ErrorLoggerIterator
- from non-style callers, obtain a channel to the script task and route the errors to it
- make the script task hand off received CSS parser errors to the proper page given the pipeline
- store the error in the page, send a message to the devtools server
- make the devtools server send a message to retrieve cached errors for a given pipeline
- handle the message in the script task by retrieving the cached errors
- send the result to the devtools client
09:48 <jdm> so we need to send CSS parser errors to the developer tools
09:49 <jdm> here is my plan for how to do that:
09:50 <jdm> make ErrorLoggerIterator a real struct with an optional Sender<> type
09:50 <jdm> and define a struct that contains the message and source location properties we need to send
09:51 <jdm> that's the type we're going to send with the Sender
09:52 <jdm> make a constructor for ErrorLoggerIterator that takes a sender argument
09:52 <jdm> add a sender argument to log_css_error, and pass the new field when calling it
09:52 <jdm> (this all takes place in http://mxr.mozilla.org/servo/source/components/style/errors.rs)
09:54 <jdm> then you need to update every place that uses ErrorLoggerIterator to use the constructor and pass the new sender: http://mxr.mozilla.org/servo/search?string=in+errorloggeriterator%28&find=&findi=&filter=^%5B^\0%5D*%24&hitlimit=&tree=servo
09:54 <jdm> so each of those functions will need to take a new sender argument
09:55 <jdm> and you'll need to keep doing for each function you change
09:55 <jdm> eventually you'll change a method like http://mxr.mozilla.org/servo/source/components/style/stylesheets.rs#63 that is used in other places
09:55 <jdm> like http://mxr.mozilla.org/servo/source/components/script/dom/htmlstyleelement.rs#59
09:57 <jdm> so then you need to create a new sender and receiver using std::comm::channel
09:58 <jdm> and create a new task that just calls receiver.recv() and sends the result to the script task
09:58 <jdm> by getting a window using window_from_node(self), then using window.script_chan
09:59 <jdm> you'll need to define a new message type in ScriptMsg: http://mxr.mozilla.org/servo/source/components/script/script_task.rs#78
09:59 <jdm> it will be something CSSParserError([the type you defined in the beginning])
09:59 <jdm> *something like
10:01 <jdm> then you can handle it in http://mxr.mozilla.org/servo/source/components/script/script_task.rs#484
10:01 <jdm> in the handler you'll want to send a message using self.devtools_chan: http://mxr.mozilla.org/servo/source/components/script/script_task.rs#164
10:02 <jdm> and you'll add a new message to http://mxr.mozilla.org/servo/source/components/devtools_traits/lib.rs#80
10:03 <jdm> you'll also want to store the new error somewhere
10:03 <jdm> it can be in a vector in ScriptTask for now
10:04 <jdm> you'll need to add a message to http://mxr.mozilla.org/servo/source/components/devtools_traits/lib.rs#69 like GetLoggedCSSErrors
10:04 <jdm> then handle it http://mxr.mozilla.org/servo/source/components/script/script_task.rs#484
10:04 <jdm> it can retrieve the errors you've stored in ScriptTask
10:05 <jdm> and then you'll make http://mxr.mozilla.org/servo/source/components/devtools/actors/console.rs#127 send the new message and process the results
10:06 <jdm> and I think that's it :P