Skip to content

Commit

Permalink
Auto merge of #5529 - ehegnes:issue-5521, r=jdm
Browse files Browse the repository at this point in the history
Fixes #5521
  • Loading branch information
bors-servo committed Apr 6, 2015
2 parents c070ad6 + e398725 commit 3c5c2f4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
12 changes: 6 additions & 6 deletions components/script/dom/bindings/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub enum Error {
/// SyntaxError DOMException
Syntax,
/// NamespaceError DOMException
NamespaceError,
Namespace,
/// InvalidAccessError DOMException
InvalidAccess,
/// SecurityError DOMException
Expand All @@ -53,10 +53,10 @@ pub enum Error {
/// DataCloneError DOMException
DataClone,
/// NoModificationAllowedError DOMException
NoModificationAllowedError,
NoModificationAllowed,

/// TypeError JavaScript Error
TypeError(DOMString),
Type(DOMString),

/// A JavaScript exception is already pending.
JSFailed,
Expand All @@ -81,15 +81,15 @@ pub fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef,
Error::NotSupported => DOMErrorName::NotSupportedError,
Error::InvalidState => DOMErrorName::InvalidStateError,
Error::Syntax => DOMErrorName::SyntaxError,
Error::NamespaceError => DOMErrorName::NamespaceError,
Error::Namespace => DOMErrorName::NamespaceError,
Error::InvalidAccess => DOMErrorName::InvalidAccessError,
Error::Security => DOMErrorName::SecurityError,
Error::Network => DOMErrorName::NetworkError,
Error::Abort => DOMErrorName::AbortError,
Error::Timeout => DOMErrorName::TimeoutError,
Error::DataClone => DOMErrorName::DataCloneError,
Error::NoModificationAllowedError => DOMErrorName::NoModificationAllowedError,
Error::TypeError(message) => {
Error::NoModificationAllowed => DOMErrorName::NoModificationAllowedError,
Error::Type(message) => {
throw_type_error(cx, &message);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/canvasrenderingcontext2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasWin
use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
use dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrCanvasRenderingContext2D;
use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern;
use dom::bindings::error::Error::{IndexSize, NotSupported, TypeError};
use dom::bindings::error::Error::{IndexSize, NotSupported, Type};
use dom::bindings::error::Fallible;
use dom::bindings::global::{GlobalRef, GlobalField};
use dom::bindings::js::{JS, JSRef, LayoutJS, Temporary};
Expand Down Expand Up @@ -628,7 +628,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
let y1 = *y1;

if [x0, y0, x1, y1].iter().any(|x| x.is_nan() || x.is_infinite()) {
return Err(TypeError("One of the arguments of createLinearGradient() is not a finite floating-point value.".to_owned()));
return Err(Type("One of the arguments of createLinearGradient() is not a finite floating-point value.".to_owned()));
}
Ok(CanvasGradient::new(self.global.root().r(),
CanvasGradientStyle::Linear(LinearGradientStyle::new(x0, y0, x1, y1, Vec::new()))))
Expand All @@ -644,7 +644,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
let r1 = *r1;

if [x0, y0, r0, x1, y1, r1].iter().any(|x| x.is_nan() || x.is_infinite()) {
return Err(TypeError("One of the arguments of createRadialGradient() is not a finite floating-point value.".to_owned()));
return Err(Type("One of the arguments of createRadialGradient() is not a finite floating-point value.".to_owned()));
}
Ok(CanvasGradient::new(self.global.root().r(),
CanvasGradientStyle::Radial(RadialGradientStyle::new(x0, y0, r0, x1, y1, r1, Vec::new()))))
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/cssstyledeclaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
priority: DOMString) -> ErrorResult {
// Step 1
if self.readonly {
return Err(Error::NoModificationAllowedError);
return Err(Error::NoModificationAllowed);
}

// Step 2
Expand Down Expand Up @@ -247,7 +247,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
fn SetPropertyPriority(self, property: DOMString, priority: DOMString) -> ErrorResult {
// Step 1
if self.readonly {
return Err(Error::NoModificationAllowedError);
return Err(Error::NoModificationAllowed);
}

// Step 2
Expand Down Expand Up @@ -295,7 +295,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
fn RemoveProperty(self, property: DOMString) -> Fallible<DOMString> {
// Step 1
if self.readonly {
return Err(Error::NoModificationAllowedError);
return Err(Error::NoModificationAllowed);
}

// Step 2
Expand Down
10 changes: 5 additions & 5 deletions components/script/dom/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use dom::bindings::codegen::InheritTypes::{HTMLFormElementDerived, HTMLImageElem
use dom::bindings::codegen::InheritTypes::{HTMLScriptElementDerived};
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{NotSupported, InvalidCharacter, Security};
use dom::bindings::error::Error::{HierarchyRequest, NamespaceError};
use dom::bindings::error::Error::{HierarchyRequest, Namespace};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable};
use dom::bindings::js::{OptionalRootable, RootedReference};
Expand Down Expand Up @@ -983,7 +983,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
},
Name => {
debug!("Not a valid qualified element name");
return Err(NamespaceError);
return Err(Namespace);
},
QName => {}
}
Expand All @@ -993,20 +993,20 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// throw if prefix is not null and namespace is null
(&ns!(""), Some(_), _) => {
debug!("Namespace can't be null with a non-null prefix");
return Err(NamespaceError);
return Err(Namespace);
},
// throw if prefix is "xml" and namespace is not the XML namespace
(_, Some(ref prefix), _) if "xml" == *prefix && ns != ns!(XML) => {
debug!("Namespace must be the xml namespace if the prefix is 'xml'");
return Err(NamespaceError);
return Err(Namespace);
},
// throw if namespace is the XMLNS namespace and neither qualifiedName nor prefix is
// "xmlns"
(&ns!(XMLNS), Some(ref prefix), _) if "xmlns" == *prefix => {},
(&ns!(XMLNS), _, "xmlns") => {},
(&ns!(XMLNS), _, _) => {
debug!("The prefix or the qualified name must be 'xmlns' if namespace is the XMLNS namespace ");
return Err(NamespaceError);
return Err(Namespace);
},
_ => {}
}
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/domimplementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::DOMImplementationBinding::DOMImplementatio
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::InheritTypes::NodeCast;
use dom::bindings::error::Fallible;
use dom::bindings::error::Error::{InvalidCharacter, NamespaceError};
use dom::bindings::error::Error::{InvalidCharacter, Namespace};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, JSRef, Root, Temporary, OptionalRootable};
use dom::bindings::utils::{Reflector, reflect_dom_object};
Expand Down Expand Up @@ -57,7 +57,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
// Step 1.
InvalidXMLName => Err(InvalidCharacter),
// Step 2.
Name => Err(NamespaceError),
Name => Err(Namespace),
// Step 3.
QName => {
let document = self.document.root();
Expand Down
15 changes: 8 additions & 7 deletions components/script/dom/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use dom::bindings::codegen::InheritTypes::{HTMLTableSectionElementDerived, NodeC
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast;
use dom::bindings::codegen::InheritTypes::HTMLFormElementDerived;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{NamespaceError, InvalidCharacter, Syntax};
use dom::bindings::error::Error;
use dom::bindings::error::Error::{InvalidCharacter, Syntax};
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable};
use dom::bindings::js::OptionalRootable;
use dom::bindings::trace::RootedVec;
Expand Down Expand Up @@ -1045,7 +1046,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
// Step 2.
InvalidXMLName => return Err(InvalidCharacter),
// Step 3.
Name => return Err(NamespaceError),
Name => return Err(Error::Namespace),
QName => {}
}

Expand All @@ -1055,17 +1056,17 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
if let Some(ref prefix_str) = prefix {
// Step 5.
if namespace == ns!("") {
return Err(NamespaceError);
return Err(Error::Namespace);
}

// Step 6.
if "xml" == *prefix_str && namespace != ns!(XML) {
return Err(NamespaceError);
return Err(Error::Namespace);
}

// Step 7b.
if "xmlns" == *prefix_str && namespace != ns!(XMLNS) {
return Err(NamespaceError);
return Err(Error::Namespace);
}
}

Expand All @@ -1075,12 +1076,12 @@ impl<'a> ElementMethods for JSRef<'a, Element> {

// Step 7a.
if xmlns == name && namespace != ns!(XMLNS) {
return Err(NamespaceError);
return Err(Error::Namespace);
}

// Step 8.
if namespace == ns!(XMLNS) && xmlns != name && Some("xmlns") != prefix {
return Err(NamespaceError);
return Err(Error::Namespace);
}

// Step 9.
Expand Down

0 comments on commit 3c5c2f4

Please sign in to comment.