Skip to content

Commit

Permalink
Auto merge of #10566 - xudifsd:error-result, r=Ms2ger
Browse files Browse the repository at this point in the history
replace Fallible<()> with ErrorResult

Fixes #10541

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10566)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Apr 13, 2016
2 parents 4f63319 + 76f57ef commit 697300b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions components/script/dom/canvasrenderingcontext2d.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(());
}
Expand All @@ -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(());
}
Expand All @@ -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(());
Expand Down Expand Up @@ -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(());
}
Expand All @@ -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(());
}
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/element.rs
Expand Up @@ -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));
Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions components/script/dom/htmliframeelement.rs
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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)
}

Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/websocket.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 697300b

Please sign in to comment.