-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
xml5everas a dependency to thescriptcrate using the cargo package manager - add an
xml.rstocomponents/script/parse/with aparse_xmlmodeled afterparse_htmlfromhtml.rs(be sure to modifyparse/mod.rstoo) - add a
ServoXMLParserinterface modeled afterServoHTMLParser.webidland add whatever stubs are necessary to the newcomponents/script/dom/servoxmlparser.rsto let it compile (be sure to updatecomponents/script/dom/mod.rs) - call the new
parse_xmlfrom the branch inDOMParser::ParseFromStringthat implements XML document support indomparser.rs(this is not expected to do anything except compile successfully, at this point)
Subsequent steps:
- modify
ScriptTask::loadinscript_task.rsto recognize thetext/xmlcontent type and callparse_xmlinstead ofparse_htmlas appropriate, while passing the appropriate flag to theDocumentconstructor - implement a
TreeSinkfor the XML parser that performs appropriate tree modifications for each action (see the implementation inparse/html.rsfor an excellent model) - implement support in
xmlhttprequest.rsfor XML document responses (see step 7 in https://xhr.spec.whatwg.org/#document-response) - implement
XMLDocumentAPI by following the documentation and implementing the steps laid out in the specification for theloadmethod