mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
commit
3c5c2f416b
6 changed files with 27 additions and 26 deletions
|
@ -39,7 +39,7 @@ pub enum Error {
|
|||
/// SyntaxError DOMException
|
||||
Syntax,
|
||||
/// NamespaceError DOMException
|
||||
NamespaceError,
|
||||
Namespace,
|
||||
/// InvalidAccessError DOMException
|
||||
InvalidAccess,
|
||||
/// SecurityError DOMException
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
@ -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()))))
|
||||
|
@ -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()))))
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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};
|
||||
|
@ -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 => {}
|
||||
}
|
||||
|
@ -993,12 +993,12 @@ 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"
|
||||
|
@ -1006,7 +1006,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
(&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);
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
@ -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 => {}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue