mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
bindings: Return errors in Result rather than setting an out parameter
Fixes #909.
This commit is contained in:
parent
4b0680a136
commit
73c1a12f30
73 changed files with 891 additions and 550 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::codegen::DOMParserBinding;
|
||||
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
||||
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache, CacheableWrapper};
|
||||
use dom::bindings::utils::{DOMString, Fallible, WrapperCache, CacheableWrapper};
|
||||
use dom::document::{AbstractDocument, Document, XML};
|
||||
use dom::element::HTMLHtmlElementTypeId;
|
||||
use dom::htmldocument::HTMLDocument;
|
||||
|
@ -33,15 +33,14 @@ impl DOMParser {
|
|||
parser
|
||||
}
|
||||
|
||||
pub fn Constructor(owner: @mut Window, _rv: &mut ErrorResult) -> @mut DOMParser {
|
||||
DOMParser::new(owner)
|
||||
pub fn Constructor(owner: @mut Window) -> Fallible<@mut DOMParser> {
|
||||
Ok(DOMParser::new(owner))
|
||||
}
|
||||
|
||||
pub fn ParseFromString(&self,
|
||||
_s: &DOMString,
|
||||
ty: DOMParserBinding::SupportedType,
|
||||
_rv: &mut ErrorResult)
|
||||
-> AbstractDocument {
|
||||
ty: DOMParserBinding::SupportedType)
|
||||
-> Fallible<AbstractDocument> {
|
||||
unsafe {
|
||||
let root = @HTMLHtmlElement {
|
||||
parent: HTMLElement::new(HTMLHtmlElementTypeId, ~"html")
|
||||
|
@ -52,10 +51,10 @@ impl DOMParser {
|
|||
|
||||
match ty {
|
||||
Text_html => {
|
||||
HTMLDocument::new(root, None)
|
||||
Ok(HTMLDocument::new(root, None))
|
||||
}
|
||||
Text_xml => {
|
||||
AbstractDocument::as_abstract(cx, @mut Document::new(root, None, XML))
|
||||
Ok(AbstractDocument::as_abstract(cx, @mut Document::new(root, None, XML)))
|
||||
}
|
||||
_ => {
|
||||
fail!("unsupported document type")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue