mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Implement DOMImplementation::createDocumentType
Implementation according to spec: http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype Closes #1489.
This commit is contained in:
parent
c876335d22
commit
0d35d4932b
3 changed files with 35 additions and 3 deletions
|
@ -3,7 +3,11 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::DOMImplementationBinding;
|
||||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
||||
use dom::bindings::utils::{DOMString, Reflector, Reflectable, reflect_dom_object};
|
||||
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
|
||||
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
|
||||
use dom::documenttype::DocumentType;
|
||||
use dom::node::AbstractNode;
|
||||
use dom::window::Window;
|
||||
|
||||
pub struct DOMImplementation {
|
||||
|
@ -34,3 +38,20 @@ impl Reflectable for DOMImplementation {
|
|||
&mut self.reflector_
|
||||
}
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#domimplementation
|
||||
impl DOMImplementation {
|
||||
// http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
|
||||
pub fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible<AbstractNode> {
|
||||
// FIXME: To be removed in https://github.com/mozilla/servo/issues/1498
|
||||
let force_quirks : bool = false;
|
||||
match xml_name_type(qname) {
|
||||
// Step 1.
|
||||
InvalidXMLName => Err(InvalidCharacter),
|
||||
// Step 2.
|
||||
Name => Err(NamespaceError),
|
||||
// Step 3.
|
||||
QName => Ok(DocumentType::new(qname, Some(pubid), Some(sysid), force_quirks, self.owner.Document()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue