mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
replace Fallible<()> with ErrorResult
This commit is contained in:
parent
9b57d8d686
commit
76f57efb58
4 changed files with 20 additions and 20 deletions
|
@ -19,7 +19,7 @@ use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
|
|||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::UnionTypes::HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D;
|
||||
use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::error::{Error, Fallible, ErrorResult};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, LayoutJS, Root};
|
||||
|
@ -277,7 +277,7 @@ impl CanvasRenderingContext2D {
|
|||
dy: f64,
|
||||
dw: Option<f64>,
|
||||
dh: Option<f64>)
|
||||
-> Fallible<()> {
|
||||
-> ErrorResult {
|
||||
let result = match image {
|
||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLCanvasElement(ref canvas) => {
|
||||
self.draw_html_canvas_element(canvas.r(),
|
||||
|
@ -333,7 +333,7 @@ impl CanvasRenderingContext2D {
|
|||
dy: f64,
|
||||
dw: Option<f64>,
|
||||
dh: Option<f64>)
|
||||
-> Fallible<()> {
|
||||
-> ErrorResult {
|
||||
// 1. Check the usability of the image argument
|
||||
if !canvas.is_valid() {
|
||||
return Err(Error::InvalidState);
|
||||
|
@ -408,7 +408,7 @@ impl CanvasRenderingContext2D {
|
|||
dy: f64,
|
||||
dw: f64,
|
||||
dh: f64)
|
||||
-> Fallible<()> {
|
||||
-> ErrorResult {
|
||||
// Establish the source and destination rectangles
|
||||
let (source_rect, dest_rect) = self.adjust_source_dest_rects(image_size,
|
||||
sx,
|
||||
|
@ -742,7 +742,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D,
|
||||
dx: f64,
|
||||
dy: f64)
|
||||
-> Fallible<()> {
|
||||
-> ErrorResult {
|
||||
if !(dx.is_finite() && dy.is_finite()) {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
dy: f64,
|
||||
dw: f64,
|
||||
dh: f64)
|
||||
-> Fallible<()> {
|
||||
-> ErrorResult {
|
||||
if !(dx.is_finite() && dy.is_finite() && dw.is_finite() && dh.is_finite()) {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
dy: f64,
|
||||
dw: f64,
|
||||
dh: f64)
|
||||
-> Fallible<()> {
|
||||
-> ErrorResult {
|
||||
if !(sx.is_finite() && sy.is_finite() && sw.is_finite() && sh.is_finite() &&
|
||||
dx.is_finite() && dy.is_finite() && dw.is_finite() && dh.is_finite()) {
|
||||
return Ok(());
|
||||
|
@ -852,7 +852,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-arc
|
||||
fn Arc(&self, x: f64, y: f64, r: f64, start: f64, end: f64, ccw: bool) -> Fallible<()> {
|
||||
fn Arc(&self, x: f64, y: f64, r: f64, start: f64, end: f64, ccw: bool) -> ErrorResult {
|
||||
if !([x, y, r, start, end].iter().all(|x| x.is_finite())) {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-arcto
|
||||
fn ArcTo(&self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, r: f64) -> Fallible<()> {
|
||||
fn ArcTo(&self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, r: f64) -> ErrorResult {
|
||||
if !([cp1x, cp1y, cp2x, cp2y, r].iter().all(|x| x.is_finite())) {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -1489,7 +1489,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
/// https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML
|
||||
fn SetInnerHTML(&self, value: DOMString) -> Fallible<()> {
|
||||
fn SetInnerHTML(&self, value: DOMString) -> ErrorResult {
|
||||
let context_node = self.upcast::<Node>();
|
||||
// Step 1.
|
||||
let frag = try!(context_node.parse_fragment(value));
|
||||
|
@ -1510,7 +1510,7 @@ impl ElementMethods for Element {
|
|||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
||||
fn SetOuterHTML(&self, value: DOMString) -> Fallible<()> {
|
||||
fn SetOuterHTML(&self, value: DOMString) -> ErrorResult {
|
||||
let context_document = document_from_node(self);
|
||||
let context_node = self.upcast::<Node>();
|
||||
// Step 1.
|
||||
|
|
|
@ -367,7 +367,7 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> Fallible<()> {
|
||||
pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> ErrorResult {
|
||||
if iframe.Mozbrowser() {
|
||||
if iframe.upcast::<Node>().is_in_doc() {
|
||||
let window = window_from_node(iframe);
|
||||
|
@ -468,17 +468,17 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
|
||||
fn GoBack(&self) -> Fallible<()> {
|
||||
fn GoBack(&self) -> ErrorResult {
|
||||
Navigate(self, NavigationDirection::Back)
|
||||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goForward
|
||||
fn GoForward(&self) -> Fallible<()> {
|
||||
fn GoForward(&self) -> ErrorResult {
|
||||
Navigate(self, NavigationDirection::Forward)
|
||||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/reload
|
||||
fn Reload(&self, _hardReload: bool) -> Fallible<()> {
|
||||
fn Reload(&self, _hardReload: bool) -> ErrorResult {
|
||||
if self.Mozbrowser() {
|
||||
if self.upcast::<Node>().is_in_doc() {
|
||||
self.navigate_or_reload_child_browsing_context(None);
|
||||
|
@ -492,7 +492,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/stop
|
||||
fn Stop(&self) -> Fallible<()> {
|
||||
fn Stop(&self) -> ErrorResult {
|
||||
Err(Error::NotSupported)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::WebSocketBinding;
|
|||
use dom::bindings::codegen::Bindings::WebSocketBinding::{BinaryType, WebSocketMethods};
|
||||
use dom::bindings::codegen::UnionTypes::StringOrStringSequence;
|
||||
use dom::bindings::conversions::{ToJSValConvertible};
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::error::{Error, Fallible, ErrorResult};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
|
@ -385,7 +385,7 @@ impl WebSocketMethods for WebSocket {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-send
|
||||
fn Send(&self, data: USVString) -> Fallible<()> {
|
||||
fn Send(&self, data: USVString) -> ErrorResult {
|
||||
|
||||
let data_byte_len = data.0.as_bytes().len() as u64;
|
||||
let send_data = try!(self.send_impl(data_byte_len));
|
||||
|
@ -400,7 +400,7 @@ impl WebSocketMethods for WebSocket {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-send
|
||||
fn Send_(&self, blob: &Blob) -> Fallible<()> {
|
||||
fn Send_(&self, blob: &Blob) -> ErrorResult {
|
||||
|
||||
/* As per https://html.spec.whatwg.org/multipage/#websocket
|
||||
the buffered amount needs to be clamped to u32, even though Blob.Size() is u64
|
||||
|
@ -420,7 +420,7 @@ impl WebSocketMethods for WebSocket {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-websocket-close
|
||||
fn Close(&self, code: Option<u16>, reason: Option<USVString>) -> Fallible<()>{
|
||||
fn Close(&self, code: Option<u16>, reason: Option<USVString>) -> ErrorResult {
|
||||
if let Some(code) = code {
|
||||
//Fail if the supplied code isn't normal and isn't reserved for libraries, frameworks, and applications
|
||||
if code != close_code::NORMAL && (code < 3000 || code > 4999) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue