forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
Integrate xml5ever
Josh Matthews edited this page Sep 17, 2015
·
1 revision
Background information: Servo uses a custom HTML5 parser written in Rust, called html5ever. We currently lack a parser for XML documents, which prevents us from running XHTML tests and implementing a number of APIs that rely on it. xml5ever is an experimental XML5 parser modeled after HTML5, so it should be relatively straightforward to integrate it into Servo and address these needs.
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
- add
xml5ever
as a dependency to thescript
crate using the cargo package manager - add an
xml.rs
tocomponents/script/parse/
with aparse_xml
modeled afterparse_html
fromhtml.rs
(be sure to modifyparse/mod.rs
too) - add a
ServoXMLParser
interface modeled afterServoHTMLParser.webidl
and add whatever stubs are necessary to the newcomponents/script/dom/servoxmlparser.rs
to let it compile (be sure to updatecomponents/script/dom/mod.rs
) - call the new
parse_xml
from the branch inDOMParser::ParseFromString
that implements XML document support indomparser.rs
(this is not expected to do anything except compile successfully, at this point)
Subsequent steps:
- modify
ScriptTask::load
inscript_task.rs
to recognize thetext/xml
content type and callparse_xml
instead ofparse_html
as appropriate, while passing the appropriate flag to theDocument
constructor - implement a
TreeSink
for the XML parser that performs appropriate tree modifications for each action (see the implementation inparse/html.rs
for an excellent model) - implement support in
xmlhttprequest.rs
for XML document responses (see step 7 in https://xhr.spec.whatwg.org/#document-response) - implement
XMLDocument
API by following the documentation and implementing the steps laid out in the specification for theload
method