mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Consistently name enum members in dom::bindings::error::Error
Fixes #5521
This commit is contained in:
parent
b63fb0c0a7
commit
e398725242
6 changed files with 27 additions and 26 deletions
|
@ -39,7 +39,7 @@ pub enum Error {
|
||||||
/// SyntaxError DOMException
|
/// SyntaxError DOMException
|
||||||
Syntax,
|
Syntax,
|
||||||
/// NamespaceError DOMException
|
/// NamespaceError DOMException
|
||||||
NamespaceError,
|
Namespace,
|
||||||
/// InvalidAccessError DOMException
|
/// InvalidAccessError DOMException
|
||||||
InvalidAccess,
|
InvalidAccess,
|
||||||
/// SecurityError DOMException
|
/// SecurityError DOMException
|
||||||
|
@ -53,10 +53,10 @@ pub enum Error {
|
||||||
/// DataCloneError DOMException
|
/// DataCloneError DOMException
|
||||||
DataClone,
|
DataClone,
|
||||||
/// NoModificationAllowedError DOMException
|
/// NoModificationAllowedError DOMException
|
||||||
NoModificationAllowedError,
|
NoModificationAllowed,
|
||||||
|
|
||||||
/// TypeError JavaScript Error
|
/// TypeError JavaScript Error
|
||||||
TypeError(DOMString),
|
Type(DOMString),
|
||||||
|
|
||||||
/// A JavaScript exception is already pending.
|
/// A JavaScript exception is already pending.
|
||||||
JSFailed,
|
JSFailed,
|
||||||
|
@ -81,15 +81,15 @@ pub fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef,
|
||||||
Error::NotSupported => DOMErrorName::NotSupportedError,
|
Error::NotSupported => DOMErrorName::NotSupportedError,
|
||||||
Error::InvalidState => DOMErrorName::InvalidStateError,
|
Error::InvalidState => DOMErrorName::InvalidStateError,
|
||||||
Error::Syntax => DOMErrorName::SyntaxError,
|
Error::Syntax => DOMErrorName::SyntaxError,
|
||||||
Error::NamespaceError => DOMErrorName::NamespaceError,
|
Error::Namespace => DOMErrorName::NamespaceError,
|
||||||
Error::InvalidAccess => DOMErrorName::InvalidAccessError,
|
Error::InvalidAccess => DOMErrorName::InvalidAccessError,
|
||||||
Error::Security => DOMErrorName::SecurityError,
|
Error::Security => DOMErrorName::SecurityError,
|
||||||
Error::Network => DOMErrorName::NetworkError,
|
Error::Network => DOMErrorName::NetworkError,
|
||||||
Error::Abort => DOMErrorName::AbortError,
|
Error::Abort => DOMErrorName::AbortError,
|
||||||
Error::Timeout => DOMErrorName::TimeoutError,
|
Error::Timeout => DOMErrorName::TimeoutError,
|
||||||
Error::DataClone => DOMErrorName::DataCloneError,
|
Error::DataClone => DOMErrorName::DataCloneError,
|
||||||
Error::NoModificationAllowedError => DOMErrorName::NoModificationAllowedError,
|
Error::NoModificationAllowed => DOMErrorName::NoModificationAllowedError,
|
||||||
Error::TypeError(message) => {
|
Error::Type(message) => {
|
||||||
throw_type_error(cx, &message);
|
throw_type_error(cx, &message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasWin
|
||||||
use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
|
use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods;
|
||||||
use dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrCanvasRenderingContext2D;
|
use dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrCanvasRenderingContext2D;
|
||||||
use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern;
|
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::error::Fallible;
|
||||||
use dom::bindings::global::{GlobalRef, GlobalField};
|
use dom::bindings::global::{GlobalRef, GlobalField};
|
||||||
use dom::bindings::js::{JS, JSRef, LayoutJS, Temporary};
|
use dom::bindings::js::{JS, JSRef, LayoutJS, Temporary};
|
||||||
|
@ -628,7 +628,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
||||||
let y1 = *y1;
|
let y1 = *y1;
|
||||||
|
|
||||||
if [x0, y0, x1, y1].iter().any(|x| x.is_nan() || x.is_infinite()) {
|
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(),
|
Ok(CanvasGradient::new(self.global.root().r(),
|
||||||
CanvasGradientStyle::Linear(LinearGradientStyle::new(x0, y0, x1, y1, Vec::new()))))
|
CanvasGradientStyle::Linear(LinearGradientStyle::new(x0, y0, x1, y1, Vec::new()))))
|
||||||
|
@ -644,7 +644,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
||||||
let r1 = *r1;
|
let r1 = *r1;
|
||||||
|
|
||||||
if [x0, y0, r0, x1, y1, r1].iter().any(|x| x.is_nan() || x.is_infinite()) {
|
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(),
|
Ok(CanvasGradient::new(self.global.root().r(),
|
||||||
CanvasGradientStyle::Radial(RadialGradientStyle::new(x0, y0, r0, x1, y1, r1, Vec::new()))))
|
CanvasGradientStyle::Radial(RadialGradientStyle::new(x0, y0, r0, x1, y1, r1, Vec::new()))))
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
||||||
priority: DOMString) -> ErrorResult {
|
priority: DOMString) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if self.readonly {
|
if self.readonly {
|
||||||
return Err(Error::NoModificationAllowedError);
|
return Err(Error::NoModificationAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -247,7 +247,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
||||||
fn SetPropertyPriority(self, property: DOMString, priority: DOMString) -> ErrorResult {
|
fn SetPropertyPriority(self, property: DOMString, priority: DOMString) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if self.readonly {
|
if self.readonly {
|
||||||
return Err(Error::NoModificationAllowedError);
|
return Err(Error::NoModificationAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -295,7 +295,7 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
||||||
fn RemoveProperty(self, property: DOMString) -> Fallible<DOMString> {
|
fn RemoveProperty(self, property: DOMString) -> Fallible<DOMString> {
|
||||||
// Step 1
|
// Step 1
|
||||||
if self.readonly {
|
if self.readonly {
|
||||||
return Err(Error::NoModificationAllowedError);
|
return Err(Error::NoModificationAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
|
@ -21,7 +21,7 @@ use dom::bindings::codegen::InheritTypes::{HTMLFormElementDerived, HTMLImageElem
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLScriptElementDerived};
|
use dom::bindings::codegen::InheritTypes::{HTMLScriptElementDerived};
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
use dom::bindings::error::{ErrorResult, Fallible};
|
||||||
use dom::bindings::error::Error::{NotSupported, InvalidCharacter, Security};
|
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::global::GlobalRef;
|
||||||
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable};
|
use dom::bindings::js::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable};
|
||||||
use dom::bindings::js::{OptionalRootable, RootedReference};
|
use dom::bindings::js::{OptionalRootable, RootedReference};
|
||||||
|
@ -983,7 +983,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
},
|
},
|
||||||
Name => {
|
Name => {
|
||||||
debug!("Not a valid qualified element name");
|
debug!("Not a valid qualified element name");
|
||||||
return Err(NamespaceError);
|
return Err(Namespace);
|
||||||
},
|
},
|
||||||
QName => {}
|
QName => {}
|
||||||
}
|
}
|
||||||
|
@ -993,12 +993,12 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
// throw if prefix is not null and namespace is null
|
// throw if prefix is not null and namespace is null
|
||||||
(&ns!(""), Some(_), _) => {
|
(&ns!(""), Some(_), _) => {
|
||||||
debug!("Namespace can't be null with a non-null prefix");
|
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
|
// throw if prefix is "xml" and namespace is not the XML namespace
|
||||||
(_, Some(ref prefix), _) if "xml" == *prefix && ns != ns!(XML) => {
|
(_, Some(ref prefix), _) if "xml" == *prefix && ns != ns!(XML) => {
|
||||||
debug!("Namespace must be the xml namespace if the prefix is '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
|
// throw if namespace is the XMLNS namespace and neither qualifiedName nor prefix is
|
||||||
// "xmlns"
|
// "xmlns"
|
||||||
|
@ -1006,7 +1006,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
(&ns!(XMLNS), _, "xmlns") => {},
|
(&ns!(XMLNS), _, "xmlns") => {},
|
||||||
(&ns!(XMLNS), _, _) => {
|
(&ns!(XMLNS), _, _) => {
|
||||||
debug!("The prefix or the qualified name must be 'xmlns' if namespace is the XMLNS namespace ");
|
debug!("The prefix or the qualified name must be 'xmlns' if namespace is the XMLNS namespace ");
|
||||||
return Err(NamespaceError);
|
return Err(Namespace);
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::DOMImplementationBinding::DOMImplementatio
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::NodeCast;
|
use dom::bindings::codegen::InheritTypes::NodeCast;
|
||||||
use dom::bindings::error::Fallible;
|
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::global::GlobalRef;
|
||||||
use dom::bindings::js::{JS, JSRef, Root, Temporary, OptionalRootable};
|
use dom::bindings::js::{JS, JSRef, Root, Temporary, OptionalRootable};
|
||||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||||
|
@ -57,7 +57,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
InvalidXMLName => Err(InvalidCharacter),
|
InvalidXMLName => Err(InvalidCharacter),
|
||||||
// Step 2.
|
// Step 2.
|
||||||
Name => Err(NamespaceError),
|
Name => Err(Namespace),
|
||||||
// Step 3.
|
// Step 3.
|
||||||
QName => {
|
QName => {
|
||||||
let document = self.document.root();
|
let document = self.document.root();
|
||||||
|
|
|
@ -26,7 +26,8 @@ use dom::bindings::codegen::InheritTypes::{HTMLTableSectionElementDerived, NodeC
|
||||||
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast;
|
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast;
|
||||||
use dom::bindings::codegen::InheritTypes::HTMLFormElementDerived;
|
use dom::bindings::codegen::InheritTypes::HTMLFormElementDerived;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible};
|
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::{MutNullableJS, JS, JSRef, LayoutJS, Temporary, TemporaryPushable};
|
||||||
use dom::bindings::js::OptionalRootable;
|
use dom::bindings::js::OptionalRootable;
|
||||||
use dom::bindings::trace::RootedVec;
|
use dom::bindings::trace::RootedVec;
|
||||||
|
@ -1020,7 +1021,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
InvalidXMLName => return Err(InvalidCharacter),
|
InvalidXMLName => return Err(InvalidCharacter),
|
||||||
// Step 3.
|
// Step 3.
|
||||||
Name => return Err(NamespaceError),
|
Name => return Err(Error::Namespace),
|
||||||
QName => {}
|
QName => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,17 +1031,17 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
if let Some(ref prefix_str) = prefix {
|
if let Some(ref prefix_str) = prefix {
|
||||||
// Step 5.
|
// Step 5.
|
||||||
if namespace == ns!("") {
|
if namespace == ns!("") {
|
||||||
return Err(NamespaceError);
|
return Err(Error::Namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
if "xml" == *prefix_str && namespace != ns!(XML) {
|
if "xml" == *prefix_str && namespace != ns!(XML) {
|
||||||
return Err(NamespaceError);
|
return Err(Error::Namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 7b.
|
// Step 7b.
|
||||||
if "xmlns" == *prefix_str && namespace != ns!(XMLNS) {
|
if "xmlns" == *prefix_str && namespace != ns!(XMLNS) {
|
||||||
return Err(NamespaceError);
|
return Err(Error::Namespace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1050,12 +1051,12 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
|
|
||||||
// Step 7a.
|
// Step 7a.
|
||||||
if xmlns == name && namespace != ns!(XMLNS) {
|
if xmlns == name && namespace != ns!(XMLNS) {
|
||||||
return Err(NamespaceError);
|
return Err(Error::Namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 8.
|
// Step 8.
|
||||||
if namespace == ns!(XMLNS) && xmlns != name && Some("xmlns") != prefix {
|
if namespace == ns!(XMLNS) && xmlns != name && Some("xmlns") != prefix {
|
||||||
return Err(NamespaceError);
|
return Err(Error::Namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 9.
|
// Step 9.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue