mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Move WebIDL methods to traits implemented by JSRef types.
This commit is contained in:
parent
dfdda0098a
commit
76783b029e
106 changed files with 3644 additions and 1912 deletions
|
@ -64,9 +64,15 @@ impl Reflectable for DOMException {
|
|||
}
|
||||
}
|
||||
|
||||
impl DOMException {
|
||||
pub trait DOMExceptionMethods {
|
||||
fn Code(&self) -> u16;
|
||||
fn Name(&self) -> DOMString;
|
||||
fn Message(&self) -> DOMString;
|
||||
}
|
||||
|
||||
impl<'a> DOMExceptionMethods for JSRef<'a, DOMException> {
|
||||
// http://dom.spec.whatwg.org/#dom-domexception-code
|
||||
pub fn Code(&self) -> u16 {
|
||||
fn Code(&self) -> u16 {
|
||||
match self.code {
|
||||
// http://dom.spec.whatwg.org/#concept-throw
|
||||
EncodingError => 0,
|
||||
|
@ -75,12 +81,12 @@ impl DOMException {
|
|||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#error-names-0
|
||||
pub fn Name(&self) -> DOMString {
|
||||
fn Name(&self) -> DOMString {
|
||||
self.code.to_str()
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#error-names-0
|
||||
pub fn Message(&self) -> DOMString {
|
||||
fn Message(&self) -> DOMString {
|
||||
match self.code {
|
||||
IndexSizeError => ~"The index is not in the allowed range.",
|
||||
HierarchyRequestError => ~"The operation would yield an incorrect node tree.",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue