Add spec links

This commit is contained in:
Bogdan Cuza 2015-07-21 18:53:01 +03:00 committed by Bogdan
parent f039827dcd
commit 233a769c67
61 changed files with 284 additions and 87 deletions

View file

@ -98,7 +98,7 @@ impl<'a> BlobHelpers for &'a Blob {
}
impl<'a> BlobMethods for &'a Blob {
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-size
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-size
fn Size(self) -> u64{
match self.bytes {
None => 0,
@ -106,12 +106,12 @@ impl<'a> BlobMethods for &'a Blob {
}
}
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-type
// https://dev.w3.org/2006/webapi/FileAPI/#dfn-type
fn Type(self) -> DOMString {
self.typeString.clone()
}
// http://dev.w3.org/2006/webapi/FileAPI/#slice-method-algo
// https://dev.w3.org/2006/webapi/FileAPI/#slice-method-algo
fn Slice(self, start: Option<i64>, end: Option<i64>,
contentType: Option<DOMString>) -> Root<Blob> {
let size: i64 = self.Size().to_i64().unwrap();

View file

@ -69,14 +69,17 @@ impl CloseEvent {
}
impl<'a> CloseEventMethods for &'a CloseEvent {
// https://html.spec.whatwg.org/multipage/#dom-closeevent-wasclean
fn WasClean(self) -> bool {
self.wasClean
}
// https://html.spec.whatwg.org/multipage/#dom-closeevent-code
fn Code(self) -> u16 {
self.code
}
// https://html.spec.whatwg.org/multipage/#dom-closeevent-reason
fn Reason(self) -> DOMString {
self.reason.clone()
}

View file

@ -40,6 +40,7 @@ impl<'a> ConsoleMethods for &'a Console {
}
}
// https://developer.mozilla.org/en-US/docs/Web/API/Console
fn Debug(self, messages: Vec<DOMString>) {
for message in messages {
println!("{}", message);

View file

@ -41,8 +41,8 @@ impl Crypto {
}
impl<'a> CryptoMethods for &'a Crypto {
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#Crypto-method-getRandomValues
#[allow(unsafe_code)]
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#Crypto-method-getRandomValues
fn GetRandomValues(self, _cx: *mut JSContext, input: *mut JSObject)
-> Fallible<*mut JSObject> {
let mut length = 0;

View file

@ -92,7 +92,7 @@ impl<'a> PrivateCSSStyleDeclarationHelpers for &'a CSSStyleDeclaration {
}
impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-length
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-length
fn Length(self) -> u32 {
let owner = self.owner.root();
let elem = ElementCast::from_ref(owner.r());
@ -103,7 +103,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
len as u32
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-item
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-item
fn Item(self, index: u32) -> DOMString {
let index = index as usize;
let owner = self.owner.root();
@ -124,7 +124,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
result.unwrap_or("".to_owned())
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
fn GetPropertyValue(self, property: DOMString) -> DOMString {
// Step 1
let property = Atom::from_slice(&property.to_ascii_lowercase());
@ -159,7 +159,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
}
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
fn GetPropertyPriority(self, property: DOMString) -> DOMString {
// Step 1
let property = Atom::from_slice(&property.to_ascii_lowercase());
@ -183,7 +183,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
"".to_owned()
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
fn SetProperty(self, property: DOMString, value: DOMString,
priority: DOMString) -> ErrorResult {
// Step 1
@ -244,7 +244,7 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
Ok(())
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertypriority
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertypriority
fn SetPropertyPriority(self, property: DOMString, priority: DOMString) -> ErrorResult {
// Step 1
if self.readonly {
@ -287,12 +287,12 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
Ok(())
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult {
self.SetProperty(property, value, "".to_owned())
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
fn RemoveProperty(self, property: DOMString) -> Fallible<DOMString> {
// Step 1
if self.readonly {
@ -326,17 +326,17 @@ impl<'a> CSSStyleDeclarationMethods for &'a CSSStyleDeclaration {
Ok(value)
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn CssFloat(self) -> DOMString {
self.GetPropertyValue("float".to_owned())
}
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn SetCssFloat(self, value: DOMString) -> ErrorResult {
self.SetPropertyValue("float".to_owned(), value)
}
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
// https://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
fn IndexedGetter(self, index: u32, found: &mut bool) -> DOMString {
let rval = self.Item(index);
*found = index < self.Length();

View file

@ -1738,10 +1738,12 @@ impl<'a> DocumentMethods for &'a Document {
Ok(())
}
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
fn BgColor(self) -> DOMString {
self.get_body_attribute(&atom!("bgcolor"))
}
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
fn SetBgColor(self, value: DOMString) {
self.set_body_attribute(&atom!("bgcolor"), value)
}

View file

@ -34,34 +34,42 @@ impl DOMPoint {
}
impl<'a> DOMPointMethods for &'a DOMPoint {
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
fn X(self) -> f64 {
self.point.X()
}
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
fn SetX(self, value: f64) {
self.point.SetX(value);
}
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
fn Y(self) -> f64 {
self.point.Y()
}
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
fn SetY(self, value: f64) {
self.point.SetY(value);
}
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
fn Z(self) -> f64 {
self.point.Z()
}
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
fn SetZ(self, value: f64) {
self.point.SetZ(value);
}
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
fn W(self) -> f64 {
self.point.W()
}
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
fn SetW(self, value: f64) {
self.point.SetW(value);
}

View file

@ -41,22 +41,22 @@ impl DOMPointReadOnly {
}
impl<'a> DOMPointReadOnlyMethods for &'a DOMPointReadOnly {
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x
fn X(self) -> f64 {
self.x.get()
}
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-y
fn Y(self) -> f64 {
self.y.get()
}
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z
fn Z(self) -> f64 {
self.z.get()
}
// http://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w
fn W(self) -> f64 {
self.w.get()
}

View file

@ -41,27 +41,33 @@ impl DOMRect {
}
impl<'a> DOMRectMethods for &'a DOMRect {
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-top
fn Top(self) -> Finite<f32> {
Finite::wrap(self.top)
}
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-bottom
fn Bottom(self) -> Finite<f32> {
Finite::wrap(self.bottom)
}
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-left
fn Left(self) -> Finite<f32> {
Finite::wrap(self.left)
}
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-right
fn Right(self) -> Finite<f32> {
Finite::wrap(self.right)
}
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-width
fn Width(self) -> Finite<f32> {
let result = (self.right - self.left).abs();
Finite::wrap(result)
}
// https://drafts.fxtf.org/geometry/#dom-domrectreadonly-height
fn Height(self) -> Finite<f32> {
let result = (self.bottom - self.top).abs();
Finite::wrap(result)

View file

@ -33,10 +33,12 @@ impl DOMRectList {
}
impl<'a> DOMRectListMethods for &'a DOMRectList {
// https://drafts.fxtf.org/geometry/#dom-domrectlist-length
fn Length(self) -> u32 {
self.rects.len() as u32
}
// https://drafts.fxtf.org/geometry/#dom-domrectlist-item
fn Item(self, index: u32) -> Option<Root<DOMRect>> {
let rects = &self.rects;
if index < rects.len() as u32 {
@ -46,6 +48,7 @@ impl<'a> DOMRectListMethods for &'a DOMRectList {
}
}
// check-tidy: no specs after this line
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<DOMRect>> {
*found = index < self.rects.len() as u32;
self.Item(index)

View file

@ -35,20 +35,24 @@ impl DOMStringMap {
// https://html.spec.whatwg.org/#domstringmap
impl<'a> DOMStringMapMethods for &'a DOMStringMap {
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-additem
fn NamedCreator(self, name: DOMString, value: DOMString) -> ErrorResult {
self.NamedSetter(name, value)
}
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-removeitem
fn NamedDeleter(self, name: DOMString) {
let element = self.element.root();
element.r().delete_custom_attr(name)
}
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-setitem
fn NamedSetter(self, name: DOMString, value: DOMString) -> ErrorResult {
let element = self.element.root();
element.r().set_custom_attr(name, value)
}
// https://html.spec.whatwg.org/multipage/#dom-domstringmap-nameditem
fn NamedGetter(self, name: DOMString, found: &mut bool) -> DOMString {
let element = self.element.root();
match element.r().get_custom_attr(name) {

View file

@ -82,12 +82,6 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
})
}
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<DOMString> {
let item = self.Item(index);
*found = item.is_some();
item
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
fn Contains(self, token: DOMString) -> Fallible<bool> {
self.check_token_exceptions(&token).map(|token| {
@ -160,4 +154,11 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
let tokenlist = self.element.root().r().get_tokenlist_attribute(&self.local_name);
str_join(&tokenlist, "\x20")
}
// check-tidy: no specs after this line
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<DOMString> {
let item = self.Item(index);
*found = item.is_some();
item
}
}

View file

@ -1291,7 +1291,7 @@ impl<'a> ElementMethods for &'a Element {
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
}
// http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
fn GetClientRects(self) -> Root<DOMRectList> {
let win = window_from_node(self);
let node = NodeCast::from_ref(self);
@ -1304,7 +1304,7 @@ impl<'a> ElementMethods for &'a Element {
DOMRectList::new(win.r(), rects)
}
// http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
fn GetBoundingClientRect(self) -> Root<DOMRect> {
let win = window_from_node(self);
let node = NodeCast::from_ref(self);
@ -1317,21 +1317,25 @@ impl<'a> ElementMethods for &'a Element {
rect.origin.x + rect.size.width)
}
// https://drafts.csswg.org/cssom-view/#dom-element-clienttop
fn ClientTop(self) -> i32 {
let node = NodeCast::from_ref(self);
node.get_client_rect().origin.y
}
// https://drafts.csswg.org/cssom-view/#dom-element-clientleft
fn ClientLeft(self) -> i32 {
let node = NodeCast::from_ref(self);
node.get_client_rect().origin.x
}
// https://drafts.csswg.org/cssom-view/#dom-element-clientwidth
fn ClientWidth(self) -> i32 {
let node = NodeCast::from_ref(self);
node.get_client_rect().size.width
}
// https://drafts.csswg.org/cssom-view/#dom-element-clientheight
fn ClientHeight(self) -> i32 {
let node = NodeCast::from_ref(self);
node.get_client_rect().size.height

View file

@ -114,22 +114,27 @@ impl ErrorEvent {
}
impl<'a> ErrorEventMethods for &'a ErrorEvent {
// https://html.spec.whatwg.org/multipage/#dom-errorevent-lineno
fn Lineno(self) -> u32 {
self.lineno.get()
}
// https://html.spec.whatwg.org/multipage/#dom-errorevent-colno
fn Colno(self) -> u32 {
self.colno.get()
}
// https://html.spec.whatwg.org/multipage/#dom-errorevent-message
fn Message(self) -> DOMString {
self.message.borrow().clone()
}
// https://html.spec.whatwg.org/multipage/#dom-errorevent-filename
fn Filename(self) -> DOMString {
self.filename.borrow().clone()
}
// https://html.spec.whatwg.org/multipage/#dom-errorevent-error
fn Error(self, _cx: *mut JSContext) -> JSVal {
self.error.get()
}

View file

@ -288,6 +288,7 @@ impl<'a> EventTargetHelpers for &'a EventTarget {
}
impl<'a> EventTargetMethods for &'a EventTarget {
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
fn AddEventListener(self,
ty: DOMString,
listener: Option<Rc<EventListener>>,
@ -313,6 +314,7 @@ impl<'a> EventTargetMethods for &'a EventTarget {
}
}
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
fn RemoveEventListener(self,
ty: DOMString,
listener: Option<Rc<EventListener>>,
@ -336,6 +338,7 @@ impl<'a> EventTargetMethods for &'a EventTarget {
}
}
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
fn DispatchEvent(self, event: &Event) -> Fallible<bool> {
if event.dispatching() || !event.initialized() {
return Err(InvalidState);

View file

@ -40,6 +40,7 @@ impl File {
}
impl<'a> FileMethods for &'a File {
// https://w3c.github.io/FileAPI/#dfn-name
fn Name(self) -> DOMString {
self.name.clone()
}

View file

@ -280,7 +280,7 @@ impl<'a> FileReaderMethods for &'a FileReader {
event_handler!(loadend, GetOnloadend, SetOnloadend);
//TODO https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer
//https://w3c.github.io/FileAPI/#dfn-readAsDataURL
// https://w3c.github.io/FileAPI/#dfn-readAsDataURL
fn ReadAsDataURL(self, blob: &Blob) -> ErrorResult {
let global = self.global.root();
// Step 1
@ -340,14 +340,17 @@ impl<'a> FileReaderMethods for &'a FileReader {
self.dispatch_progress_event("loadend".to_owned(), 0, None);
}
// https://w3c.github.io/FileAPI/#dfn-error
fn GetError(self) -> Option<Root<DOMException>> {
self.error.get().map(|error| error.root())
}
// https://w3c.github.io/FileAPI/#dfn-result
fn GetResult(self) -> Option<DOMString> {
self.result.borrow().clone()
}
// https://w3c.github.io/FileAPI/#dfn-readyState
fn ReadyState(self) -> u16 {
self.ready_state.get() as u16
}

View file

@ -58,6 +58,7 @@ impl FormData {
impl<'a> FormDataMethods for &'a FormData {
#[allow(unrooted_must_root)]
// https://xhr.spec.whatwg.org/#dom-formdata-append
fn Append(self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
let file = FormDatum::FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
let mut data = self.data.borrow_mut();
@ -69,6 +70,7 @@ impl<'a> FormDataMethods for &'a FormData {
}
}
// https://xhr.spec.whatwg.org/#dom-formdata-append
fn Append_(self, name: DOMString, value: DOMString) {
let mut data = self.data.borrow_mut();
match data.entry(name) {
@ -77,11 +79,13 @@ impl<'a> FormDataMethods for &'a FormData {
}
}
// https://xhr.spec.whatwg.org/#dom-formdata-delete
fn Delete(self, name: DOMString) {
self.data.borrow_mut().remove(&name);
}
#[allow(unsafe_code)]
// https://xhr.spec.whatwg.org/#dom-formdata-get
fn Get(self, name: DOMString) -> Option<FileOrString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let data = self.data.borrow();
@ -97,18 +101,22 @@ impl<'a> FormDataMethods for &'a FormData {
}
}
// https://xhr.spec.whatwg.org/#dom-formdata-has
fn Has(self, name: DOMString) -> bool {
self.data.borrow().contains_key(&name)
}
// https://xhr.spec.whatwg.org/#dom-formdata-set
fn Set_(self, name: DOMString, value: DOMString) {
self.data.borrow_mut().insert(name, vec!(FormDatum::StringData(value)));
}
#[allow(unrooted_must_root)]
// https://xhr.spec.whatwg.org/#dom-formdata-set
fn Set(self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
let file = FormDatum::FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
self.data.borrow_mut().insert(name, vec!(file));
}
fn Set_(self, name: DOMString, value: DOMString) {
self.data.borrow_mut().insert(name, vec!(FormDatum::StringData(value)));
}
}
trait PrivateFormDataHelpers{

View file

@ -78,16 +78,19 @@ impl<'a> VirtualMethods for &'a HTMLAnchorElement {
}
impl<'a> HTMLAnchorElementMethods for &'a HTMLAnchorElement {
// https://html.spec.whatwg.org/multipage/#dom-a-text
fn Text(self) -> DOMString {
let node = NodeCast::from_ref(self);
node.GetTextContent().unwrap()
}
// https://html.spec.whatwg.org/multipage/#dom-a-text
fn SetText(self, value: DOMString) {
let node = NodeCast::from_ref(self);
node.SetTextContent(Some(value))
}
// https://html.spec.whatwg.org/multipage/#dom-a-rellist
fn RelList(self) -> Root<DOMTokenList> {
self.rel_list.or_init(|| {
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))

View file

@ -67,6 +67,7 @@ impl<'a> VirtualMethods for &'a HTMLAreaElement {
}
impl<'a> HTMLAreaElementMethods for &'a HTMLAreaElement {
// https://html.spec.whatwg.org/multipage/#dom-area-rellist
fn RelList(self) -> Root<DOMTokenList> {
self.rel_list.or_init(|| {
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))

View file

@ -66,16 +66,17 @@ impl HTMLBodyElement {
}
impl<'a> HTMLBodyElementMethods for &'a HTMLBodyElement {
// https://html.spec.whatwg.org/#dom-body-bgcolor
// https://html.spec.whatwg.org/multipage#dom-body-bgcolor
make_getter!(BgColor, "bgcolor");
make_setter!(SetBgColor, "bgcolor");
// https://html.spec.whatwg.org/multipage/#the-body-element
fn GetOnunload(self) -> Option<Rc<EventHandlerNonNull>> {
let win = window_from_node(self);
win.r().GetOnunload()
}
// https://html.spec.whatwg.org/multipage/#the-body-element
fn SetOnunload(self, listener: Option<Rc<EventHandlerNonNull>>) {
let win = window_from_node(self);
win.r().SetOnunload(listener)

View file

@ -72,6 +72,7 @@ impl HTMLButtonElement {
}
impl<'a> HTMLButtonElementMethods for &'a HTMLButtonElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())

View file

@ -215,24 +215,29 @@ impl<'a> HTMLCanvasElementHelpers for &'a HTMLCanvasElement {
}
impl<'a> HTMLCanvasElementMethods for &'a HTMLCanvasElement {
// https://html.spec.whatwg.org/multipage/#dom-canvas-width
fn Width(self) -> u32 {
self.width.get()
}
// https://html.spec.whatwg.org/multipage/#dom-canvas-width
fn SetWidth(self, width: u32) {
let elem = ElementCast::from_ref(self);
elem.set_uint_attribute(&atom!("width"), width)
}
// https://html.spec.whatwg.org/multipage/#dom-canvas-height
fn Height(self) -> u32 {
self.height.get()
}
// https://html.spec.whatwg.org/multipage/#dom-canvas-height
fn SetHeight(self, height: u32) {
let elem = ElementCast::from_ref(self);
elem.set_uint_attribute(&atom!("height"), height)
}
// https://html.spec.whatwg.org/multipage/#dom-canvas-getcontext
fn GetContext(self,
cx: *mut JSContext,
id: DOMString,

View file

@ -229,12 +229,14 @@ impl<'a> HTMLCollectionMethods for &'a HTMLCollection {
}
}
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<Element>> {
let maybe_elem = self.Item(index);
*found = maybe_elem.is_some();
maybe_elem
}
// check-tidy: no specs after this line
fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option<Root<Element>> {
let maybe_elem = self.NamedItem(name);
*found = maybe_elem.is_some();

View file

@ -49,6 +49,7 @@ impl HTMLDataListElement {
}
impl<'a> HTMLDataListElementMethods for &'a HTMLDataListElement {
// https://html.spec.whatwg.org/multipage/#dom-datalist-options
fn Options(self) -> Root<HTMLCollection> {
#[derive(JSTraceable)]
struct HTMLDataListOptionsFilter;

View file

@ -131,6 +131,7 @@ impl<'a> PrivateHTMLElementHelpers for &'a HTMLElement {
}
impl<'a> HTMLElementMethods for &'a HTMLElement {
// https://html.spec.whatwg.org/multipage/#the-style-attribute
fn Style(self) -> Root<CSSStyleDeclaration> {
self.style_decl.or_init(|| {
let global = window_from_node(self);
@ -155,6 +156,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
self.dataset.or_init(|| DOMStringMap::new(self))
}
// https://html.spec.whatwg.org/multipage/#handler-onload
fn GetOnload(self) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let win = window_from_node(self);
@ -165,6 +167,7 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
}
}
// https://html.spec.whatwg.org/multipage/#handler-onload
fn SetOnload(self, listener: Option<Rc<EventHandlerNonNull>>) {
if self.is_body_or_frameset() {
let win = window_from_node(self);

View file

@ -71,6 +71,7 @@ impl<'a> HTMLFieldSetElementMethods for &'a HTMLFieldSetElement {
HTMLCollection::create(window.r(), node, filter)
}
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())

View file

@ -254,26 +254,31 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> F
}
impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
fn Src(self) -> DOMString {
let element = ElementCast::from_ref(self);
element.get_string_attribute(&atom!("src"))
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
fn SetSrc(self, src: DOMString) {
let element = ElementCast::from_ref(self);
element.set_url_attribute(&atom!("src"), src)
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
fn Sandbox(self) -> DOMString {
let element = ElementCast::from_ref(self);
element.get_string_attribute(&atom!("sandbox"))
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
fn SetSandbox(self, sandbox: DOMString) {
let element = ElementCast::from_ref(self);
element.set_tokenlist_attribute(&atom!("sandbox"), sandbox);
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
fn GetContentWindow(self) -> Option<Root<Window>> {
self.subpage_id.get().and_then(|subpage_id| {
let window = window_from_node(self);
@ -286,6 +291,7 @@ impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
})
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
fn GetContentDocument(self) -> Option<Root<Document>> {
self.GetContentWindow().and_then(|window| {
let self_url = match self.get_url() {
@ -319,6 +325,7 @@ impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
}
}
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn SetMozbrowser(self, value: bool) -> ErrorResult {
if opts::experimental_enabled() {
let element = ElementCast::from_ref(self);

View file

@ -220,33 +220,39 @@ impl<'a> HTMLImageElementMethods for &'a HTMLImageElement {
make_bool_getter!(IsMap);
// https://html.spec.whatwg.org/multipage/#dom-img-ismap
fn SetIsMap(self, is_map: bool) {
let element = ElementCast::from_ref(self);
element.set_string_attribute(&atom!("ismap"), is_map.to_string())
}
// https://html.spec.whatwg.org/multipage/#dom-img-width
fn Width(self) -> u32 {
let node = NodeCast::from_ref(self);
let rect = node.get_bounding_content_box();
rect.size.width.to_px() as u32
}
// https://html.spec.whatwg.org/multipage/#dom-img-width
fn SetWidth(self, width: u32) {
let elem = ElementCast::from_ref(self);
elem.set_uint_attribute(&atom!("width"), width)
}
// https://html.spec.whatwg.org/multipage/#dom-img-height
fn Height(self) -> u32 {
let node = NodeCast::from_ref(self);
let rect = node.get_bounding_content_box();
rect.size.height.to_px() as u32
}
// https://html.spec.whatwg.org/multipage/#dom-img-height
fn SetHeight(self, height: u32) {
let elem = ElementCast::from_ref(self);
elem.set_uint_attribute(&atom!("height"), height)
}
// https://html.spec.whatwg.org/multipage/#dom-img-naturalwidth
fn NaturalWidth(self) -> u32 {
let image = self.image.borrow();
@ -256,6 +262,7 @@ impl<'a> HTMLImageElementMethods for &'a HTMLImageElement {
}
}
// https://html.spec.whatwg.org/multipage/#dom-img-naturalheight
fn NaturalHeight(self) -> u32 {
let image = self.image.borrow();
@ -265,6 +272,7 @@ impl<'a> HTMLImageElementMethods for &'a HTMLImageElement {
}
}
// https://html.spec.whatwg.org/multipage/#dom-img-complete
fn Complete(self) -> bool {
let image = self.image.borrow();
image.is_some()

View file

@ -231,6 +231,7 @@ impl<'a> HTMLLinkElementMethods for &'a HTMLLinkElement {
make_getter!(Type);
make_setter!(SetType, "type");
// https://html.spec.whatwg.org/multipage/#dom-link-rellist
fn RelList(self) -> Root<DOMTokenList> {
self.rel_list.or_init(|| {
DOMTokenList::new(ElementCast::from_ref(self), &atom!("rel"))

View file

@ -85,6 +85,7 @@ pub fn is_image_data(uri: &str) -> bool {
}
impl<'a> HTMLObjectElementMethods for &'a HTMLObjectElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())

View file

@ -47,6 +47,7 @@ impl HTMLOutputElement {
}
impl<'a> HTMLOutputElementMethods for &'a HTMLOutputElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())

View file

@ -59,12 +59,14 @@ impl HTMLSelectElement {
}
impl<'a> HTMLSelectElementMethods for &'a HTMLSelectElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())
}
// Note: this function currently only exists for test_union.html.
// https://html.spec.whatwg.org/multipage/#dom-select-add
fn Add(self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) {
}

View file

@ -65,7 +65,7 @@ impl HTMLTableElement {
}
impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
// https://www.whatwg.org/html/#dom-table-caption
// https://html.spec.whatwg.org/multipage/#dom-table-caption
fn GetCaption(self) -> Option<Root<HTMLTableCaptionElement>> {
let node = NodeCast::from_ref(self);
node.children()
@ -75,7 +75,7 @@ impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
.next()
}
// https://www.whatwg.org/html/#dom-table-caption
// https://html.spec.whatwg.org/multipage/#dom-table-caption
fn SetCaption(self, new_caption: Option<&HTMLTableCaptionElement>) {
let node = NodeCast::from_ref(self);

View file

@ -761,6 +761,7 @@ impl KeyEventProperties {
}
impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
// https://w3c.github.io/uievents/#widl-KeyboardEvent-initKeyboardEvent
fn InitKeyboardEvent(self,
typeArg: DOMString,
canBubbleArg: bool,
@ -783,38 +784,47 @@ impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
self.repeat.set(repeat);
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-key
fn Key(self) -> DOMString {
self.key_string.borrow().clone()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-code
fn Code(self) -> DOMString {
self.code.borrow().clone()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-location
fn Location(self) -> u32 {
self.location.get()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-ctrlKey
fn CtrlKey(self) -> bool {
self.ctrl.get()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-shiftKey
fn ShiftKey(self) -> bool {
self.shift.get()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-altKey
fn AltKey(self) -> bool {
self.alt.get()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-metaKey
fn MetaKey(self) -> bool {
self.meta.get()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-repeat
fn Repeat(self) -> bool {
self.repeat.get()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-isComposing
fn IsComposing(self) -> bool {
self.is_composing.get()
}
@ -832,14 +842,17 @@ impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
}
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-charCode
fn CharCode(self) -> u32 {
self.char_code.get().unwrap_or(0)
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-keyCode
fn KeyCode(self) -> u32 {
self.key_code.get()
}
// https://w3c.github.io/uievents/#widl-KeyboardEvent-which
fn Which(self) -> u32 {
self.char_code.get().unwrap_or(self.KeyCode())
}

View file

@ -90,14 +90,17 @@ impl MessageEvent {
}
impl<'a> MessageEventMethods for &'a MessageEvent {
// https://html.spec.whatwg.org/multipage/#dom-messageevent-data
fn Data(self, _cx: *mut JSContext) -> JSVal {
self.data.get()
}
// https://html.spec.whatwg.org/multipage/#dom-messageevent-origin
fn Origin(self) -> DOMString {
self.origin.clone()
}
// https://html.spec.whatwg.org/multipage/#dom-messageevent-lasteventid
fn LastEventId(self) -> DOMString {
self.lastEventId.clone()
}

View file

@ -116,42 +116,52 @@ impl MouseEvent {
}
impl<'a> MouseEventMethods for &'a MouseEvent {
// https://w3c.github.io/uievents/#widl-MouseEvent-screenX
fn ScreenX(self) -> i32 {
self.screen_x.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-screenY
fn ScreenY(self) -> i32 {
self.screen_y.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-clientX
fn ClientX(self) -> i32 {
self.client_x.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-clientY
fn ClientY(self) -> i32 {
self.client_y.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-ctrlKey
fn CtrlKey(self) -> bool {
self.ctrl_key.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-shiftKey
fn ShiftKey(self) -> bool {
self.shift_key.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-altKey
fn AltKey(self) -> bool {
self.alt_key.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-metaKey
fn MetaKey(self) -> bool {
self.meta_key.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-button
fn Button(self) -> i16 {
self.button.get()
}
// https://w3c.github.io/uievents/#widl-MouseEvent-relatedTarget
fn GetRelatedTarget(self) -> Option<Root<EventTarget>> {
self.related_target.get().map(Root::from_rooted)
}
@ -160,6 +170,7 @@ impl<'a> MouseEventMethods for &'a MouseEvent {
// - https://github.com/servo/servo/issues/6643
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1186125
// This returns the same result as current gecko.
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
fn Which(self) -> i32 {
if opts::experimental_enabled() {
(self.button.get() + 1) as i32
@ -168,6 +179,7 @@ impl<'a> MouseEventMethods for &'a MouseEvent {
}
}
// https://w3c.github.io/uievents/#widl-MouseEvent-initMouseEvent
fn InitMouseEvent(self,
typeArg: DOMString,
canBubbleArg: bool,

View file

@ -91,12 +91,14 @@ impl<'a> NamedNodeMapMethods for &'a NamedNodeMap {
owner.remove_attribute(&ns, &Atom::from_slice(&local_name)).ok_or(Error::NotFound)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-item
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<Attr>> {
let item = self.Item(index);
*found = item.is_some();
item
}
// check-tidy: no specs after this line
fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option<Root<Attr>> {
let item = self.GetNamedItem(name);
*found = item.is_some();

View file

@ -31,30 +31,37 @@ impl Navigator {
}
impl<'a> NavigatorMethods for &'a Navigator {
// https://html.spec.whatwg.org/multipage/#dom-navigator-product
fn Product(self) -> DOMString {
navigatorinfo::Product()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled
fn TaintEnabled(self) -> bool {
navigatorinfo::TaintEnabled()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appname
fn AppName(self) -> DOMString {
navigatorinfo::AppName()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appcodename
fn AppCodeName(self) -> DOMString {
navigatorinfo::AppCodeName()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-platform
fn Platform(self) -> DOMString {
navigatorinfo::Platform()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
fn UserAgent(self) -> DOMString {
navigatorinfo::UserAgent()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion
fn AppVersion(self) -> DOMString {
navigatorinfo::AppVersion()
}

View file

@ -73,6 +73,7 @@ impl<'a> NodeListMethods for &'a NodeList {
}
}
// https://dom.spec.whatwg.org/#dom-nodelist-item
fn IndexedGetter(self, index: u32, found: &mut bool) -> Option<Root<Node>> {
let item = self.Item(index);
*found = item.is_some();

View file

@ -44,6 +44,7 @@ impl Performance {
}
impl<'a> PerformanceMethods for &'a Performance {
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute
fn Timing(self) -> Root<PerformanceTiming> {
self.timing.root()
}

View file

@ -39,6 +39,8 @@ impl PerformanceTiming {
}
impl<'a> PerformanceTimingMethods for &'a PerformanceTiming {
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
// NavigationTiming/Overview.html#dom-performancetiming-navigationstart
fn NavigationStart(self) -> u64 {
self.navigationStart
}

View file

@ -62,12 +62,17 @@ impl ProgressEvent {
}
impl<'a> ProgressEventMethods for &'a ProgressEvent {
// https://xhr.spec.whatwg.org/#dom-progressevent-lengthcomputable
fn LengthComputable(self) -> bool {
self.length_computable
}
// https://xhr.spec.whatwg.org/#dom-progressevent-loaded
fn Loaded(self) -> u64{
self.loaded
}
// https://xhr.spec.whatwg.org/#dom-progressevent-total
fn Total(self) -> u64 {
self.total
}

View file

@ -95,22 +95,22 @@ impl<'a> RangeHelpers<'a> for &'a Range {
}
impl<'a> RangeMethods for &'a Range {
// http://dom.spec.whatwg.org/#dom-range-startcontainer
// https://dom.spec.whatwg.org/#dom-range-startcontainer
fn StartContainer(self) -> Root<Node> {
self.inner().borrow().start.node()
}
/// http://dom.spec.whatwg.org/#dom-range-startoffset
// https://dom.spec.whatwg.org/#dom-range-startoffset
fn StartOffset(self) -> u32 {
self.inner().borrow().start.offset
}
/// http://dom.spec.whatwg.org/#dom-range-endcontainer
// https://dom.spec.whatwg.org/#dom-range-endcontainer
fn EndContainer(self) -> Root<Node> {
self.inner().borrow().end.node()
}
/// http://dom.spec.whatwg.org/#dom-range-endoffset
// https://dom.spec.whatwg.org/#dom-range-endoffset
fn EndOffset(self) -> u32 {
self.inner().borrow().end.offset
}
@ -448,7 +448,7 @@ impl<'a> RangeMethods for &'a Range {
Ok(fragment)
}
// http://dom.spec.whatwg.org/#dom-range-detach
// https://dom.spec.whatwg.org/#dom-range-detach
fn Detach(self) {
// This method intentionally left blank.
}

View file

@ -29,10 +29,12 @@ impl Screen {
}
impl<'a> ScreenMethods for &'a Screen {
// https://drafts.csswg.org/cssom-view/#dom-screen-colordepth
fn ColorDepth(self) -> u32 {
24
}
// https://drafts.csswg.org/cssom-view/#dom-screen-pixeldepth
fn PixelDepth(self) -> u32 {
24
}

View file

@ -58,6 +58,7 @@ impl Storage {
}
impl<'a> StorageMethods for &'a Storage {
// https://html.spec.whatwg.org/multipage/#dom-storage-length
fn Length(self) -> u32 {
let (sender, receiver) = ipc::channel().unwrap();
@ -65,6 +66,7 @@ impl<'a> StorageMethods for &'a Storage {
receiver.recv().unwrap() as u32
}
// https://html.spec.whatwg.org/multipage/#dom-storage-key
fn Key(self, index: u32) -> Option<DOMString> {
let (sender, receiver) = ipc::channel().unwrap();
@ -72,6 +74,7 @@ impl<'a> StorageMethods for &'a Storage {
receiver.recv().unwrap()
}
// https://html.spec.whatwg.org/multipage/#dom-storage-getitem
fn GetItem(self, name: DOMString) -> Option<DOMString> {
let (sender, receiver) = ipc::channel().unwrap();
@ -80,12 +83,7 @@ impl<'a> StorageMethods for &'a Storage {
receiver.recv().unwrap()
}
fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option<DOMString> {
let item = self.GetItem(name);
*found = item.is_some();
item
}
// https://html.spec.whatwg.org/multipage/#dom-storage-setitem
fn SetItem(self, name: DOMString, value: DOMString) {
let (sender, receiver) = ipc::channel().unwrap();
@ -97,14 +95,7 @@ impl<'a> StorageMethods for &'a Storage {
}
}
fn NamedSetter(self, name: DOMString, value: DOMString) {
self.SetItem(name, value);
}
fn NamedCreator(self, name: DOMString, value: DOMString) {
self.SetItem(name, value);
}
// https://html.spec.whatwg.org/multipage/#dom-storage-removeitem
fn RemoveItem(self, name: DOMString) {
let (sender, receiver) = ipc::channel().unwrap();
@ -115,10 +106,7 @@ impl<'a> StorageMethods for &'a Storage {
}
}
fn NamedDeleter(self, name: DOMString) {
self.RemoveItem(name);
}
// https://html.spec.whatwg.org/multipage/#dom-storage-clear
fn Clear(self) {
let (sender, receiver) = ipc::channel().unwrap();
@ -127,6 +115,25 @@ impl<'a> StorageMethods for &'a Storage {
self.broadcast_change_notification(None, None, None);
}
}
// check-tidy: no specs after this line
fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option<DOMString> {
let item = self.GetItem(name);
*found = item.is_some();
item
}
fn NamedSetter(self, name: DOMString, value: DOMString) {
self.SetItem(name, value);
}
fn NamedCreator(self, name: DOMString, value: DOMString) {
self.SetItem(name, value);
}
fn NamedDeleter(self, name: DOMString) {
self.RemoveItem(name);
}
}
trait PrivateStorageHelpers {

View file

@ -88,24 +88,28 @@ impl StorageEvent {
}
impl<'a> StorageEventMethods for &'a StorageEvent {
// https://html.spec.whatwg.org/multipage/#dom-storageevent-key
fn GetKey(self) -> Option<DOMString> {
self.key.borrow().clone()
}
// https://html.spec.whatwg.org/multipage/#dom-storageevent-oldvalue
fn GetOldValue(self) -> Option<DOMString> {
self.oldValue.borrow().clone()
}
// https://html.spec.whatwg.org/multipage/#dom-storageevent-newvalue
fn GetNewValue(self) -> Option<DOMString> {
self.newValue.borrow().clone()
}
// https://html.spec.whatwg.org/multipage/#dom-storageevent-url
fn Url(self) -> DOMString {
self.url.borrow().clone()
}
// https://html.spec.whatwg.org/multipage/#dom-storageevent-storagearea
fn GetStorageArea(self) -> Option<Root<Storage>> {
self.storageArea.get().map(Root::from_rooted)
}
}

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// check-tidy: no specs after this line
use dom::bindings::codegen::Bindings::TestBindingBinding::TestBindingMethods;
use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnum;
use dom::bindings::codegen::Bindings::TestBindingBinding::TestEnum::_empty;

View file

@ -1,6 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// check-tidy: no specs after this line
use dom::bindings::codegen::Bindings::TestBindingProxyBinding::TestBindingProxyMethods;
use dom::bindings::utils::Reflector;
use util::str::DOMString;

View file

@ -73,15 +73,18 @@ impl TextDecoder {
impl<'a> TextDecoderMethods for &'a TextDecoder {
// https://encoding.spec.whatwg.org/#dom-textdecoder-encoding
fn Encoding(self) -> DOMString {
self.encoding.whatwg_name().unwrap().to_owned()
}
// https://encoding.spec.whatwg.org/#dom-textdecoder-fatal
fn Fatal(self) -> bool {
self.fatal
}
#[allow(unsafe_code)]
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
fn Decode(self, _cx: *mut JSContext, input: Option<*mut JSObject>)
-> Fallible<USVString> {
let input = match input {
@ -108,5 +111,4 @@ impl<'a> TextDecoderMethods for &'a TextDecoder {
Err(_) => Err(Error::Type("Decoding failed".to_owned())),
}
}
}

View file

@ -75,8 +75,8 @@ impl<'a> TextEncoderMethods for &'a TextEncoder {
self.encoding.clone()
}
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
#[allow(unsafe_code)]
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
fn Encode(self, cx: *mut JSContext, input: USVString) -> *mut JSObject {
unsafe {
let encoded = self.encoder.encode(&input.0, EncoderTrap::Strict).unwrap();

View file

@ -77,16 +77,17 @@ impl UIEvent {
}
impl<'a> UIEventMethods for &'a UIEvent {
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-UIEvent-view
// https://w3c.github.io/uievents/#widl-UIEvent-view
fn GetView(self) -> Option<Root<Window>> {
self.view.get().map(Root::from_rooted)
}
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-UIEvent-detail
// https://w3c.github.io/uievents/#widl-UIEvent-detail
fn Detail(self) -> i32 {
self.detail.get()
}
// https://w3c.github.io/uievents/#widl-UIEvent-initUIEvent
fn InitUIEvent(self,
type_: DOMString,
can_bubble: bool,

View file

@ -35,14 +35,17 @@ impl WebGLActiveInfo {
}
impl<'a> WebGLActiveInfoMethods for &'a WebGLActiveInfo {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
fn Size(self) -> i32 {
self.size
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
fn Type(self) -> u32 {
self.ty
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.11.1
fn Name(self) -> DOMString {
self.name.clone()
}

View file

@ -276,8 +276,8 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
#[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
fn BufferData(self, _cx: *mut JSContext, target: u32, data: Option<*mut JSObject>, usage: u32) {
let data = match data {
Some(data) => data,
@ -345,9 +345,9 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
WebGLProgram::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
// TODO(ecoal95): Check if constants are cross-platform or if we must make a translation
// between WebGL constants and native ones.
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn CreateShader(self, shader_type: u32) -> Option<Root<WebGLShader>> {
WebGLShader::maybe_new(self.global.root().r(), self.ipc_renderer.clone(), shader_type)
}
@ -474,8 +474,8 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
#[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform4fv(self,
_cx: *mut JSContext,
uniform: Option<&WebGLUniformLocation>,

View file

@ -39,14 +39,17 @@ impl WebGLShaderPrecisionFormat {
}
impl<'a> WebGLShaderPrecisionFormatMethods for &'a WebGLShaderPrecisionFormat {
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
fn RangeMin(self) -> i32 {
self.range_min
}
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
fn RangeMax(self) -> i32 {
self.range_max
}
// https://www.khronos.org/registry/webgl/specs/1.0/#5.12.1
fn Precision(self) -> i32 {
self.precision
}

View file

@ -172,14 +172,17 @@ impl<'a> WebSocketMethods for &'a WebSocket {
event_handler!(close, GetOnclose, SetOnclose);
event_handler!(error, GetOnerror, SetOnerror);
// https://html.spec.whatwg.org/multipage/#dom-websocket-url
fn Url(self) -> DOMString {
self.url.serialize()
}
// https://html.spec.whatwg.org/multipage/#dom-websocket-readystate
fn ReadyState(self) -> u16 {
self.ready_state.get() as u16
}
// https://html.spec.whatwg.org/multipage/#dom-websocket-send
fn Send(self, data: Option<USVString>) -> Fallible<()> {
match self.ready_state.get() {
WebSocketRequestState::Connecting => {
@ -206,6 +209,7 @@ impl<'a> WebSocketMethods for &'a WebSocket {
return Ok(())
}
// https://html.spec.whatwg.org/multipage/#dom-websocket-close
fn Close(self, code: Option<u16>, reason: Option<USVString>) -> Fallible<()>{
fn send_close(this: &WebSocket) {
this.ready_state.set(WebSocketRequestState::Closing);

View file

@ -339,10 +339,12 @@ impl<'a> WindowMethods for &'a Window {
println!("ALERT: {}", s);
}
// https://html.spec.whatwg.org/multipage/#dom-window-close
fn Close(self) {
self.script_chan.send(ScriptMsg::ExitWindow(self.id.clone())).unwrap();
}
// https://html.spec.whatwg.org/multipage/#dom-document-0
fn Document(self) -> Root<Document> {
self.browsing_context().as_ref().unwrap().active_document()
}
@ -362,10 +364,12 @@ impl<'a> WindowMethods for &'a Window {
self.local_storage.or_init(|| Storage::new(&GlobalRef::Window(self), StorageType::Local))
}
// https://developer.mozilla.org/en-US/docs/Web/API/Console
fn Console(self) -> Root<Console> {
self.console.or_init(|| Console::new(GlobalRef::Window(self)))
}
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto
fn Crypto(self) -> Root<Crypto> {
self.crypto.or_init(|| Crypto::new(GlobalRef::Window(self)))
}
@ -430,10 +434,12 @@ impl<'a> WindowMethods for &'a Window {
self.ClearTimeout(handle);
}
// https://html.spec.whatwg.org/multipage/#dom-window
fn Window(self) -> Root<Window> {
Root::from_ref(self)
}
// https://html.spec.whatwg.org/multipage/#dom-self
fn Self_(self) -> Root<Window> {
self.Window()
}
@ -457,6 +463,8 @@ impl<'a> WindowMethods for &'a Window {
window
}
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
// NavigationTiming/Overview.html#sec-window.performance-attribute
fn Performance(self) -> Root<Performance> {
self.performance.or_init(|| {
Performance::new(self, self.navigation_start,
@ -468,29 +476,17 @@ impl<'a> WindowMethods for &'a Window {
event_handler!(unload, GetOnunload, SetOnunload);
error_event_handler!(error, GetOnerror, SetOnerror);
// https://developer.mozilla.org/en-US/docs/Web/API/Window/screen
fn Screen(self) -> Root<Screen> {
self.screen.or_init(|| Screen::new(self))
}
fn Debug(self, message: DOMString) {
debug!("{}", message);
}
#[allow(unsafe_code)]
fn Gc(self) {
unsafe {
JS_GC(JS_GetRuntime(self.get_cx()));
}
}
fn Trap(self) {
breakpoint();
}
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
fn Btoa(self, btoa: DOMString) -> Fallible<DOMString> {
base64_btoa(btoa)
}
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-atob
fn Atob(self, atob: DOMString) -> Fallible<DOMString> {
base64_atob(atob)
}
@ -513,6 +509,22 @@ impl<'a> WindowMethods for &'a Window {
doc.r().cancel_animation_frame(ident);
}
// check-tidy: no specs after this line
fn Debug(self, message: DOMString) {
debug!("{}", message);
}
#[allow(unsafe_code)]
fn Gc(self) {
unsafe {
JS_GC(JS_GetRuntime(self.get_cx()));
}
}
fn Trap(self) {
breakpoint();
}
fn WebdriverCallback(self, cx: *mut JSContext, val: HandleValue) {
let rv = jsval_to_webdriver(cx, val);
let opt_chan = self.webdriver_script_chan.borrow_mut().take();

View file

@ -138,6 +138,7 @@ impl Worker {
}
impl<'a> WorkerMethods for &'a Worker {
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
fn PostMessage(self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
let data = try!(StructuredCloneData::write(cx, message));
let address = Trusted::new(cx, self, self.global.root().r().script_chan().clone());

View file

@ -173,22 +173,27 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
self.navigator.or_init(|| WorkerNavigator::new(self))
}
// https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/console
fn Console(self) -> Root<Console> {
self.console.or_init(|| Console::new(GlobalRef::Worker(self)))
}
// https://html.spec.whatwg.org/multipage/#dfn-Crypto
fn Crypto(self) -> Root<Crypto> {
self.crypto.or_init(|| Crypto::new(GlobalRef::Worker(self)))
}
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
fn Btoa(self, btoa: DOMString) -> Fallible<DOMString> {
base64_btoa(btoa)
}
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-atob
fn Atob(self, atob: DOMString) -> Fallible<DOMString> {
base64_atob(atob)
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
fn SetTimeout(self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
args,
@ -198,6 +203,7 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
self.script_chan())
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
fn SetTimeout_(self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
args,
@ -207,10 +213,12 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
self.script_chan())
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-clearinterval
fn ClearTimeout(self, handle: i32) {
self.timers.clear_timeout_or_interval(handle);
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
fn SetInterval(self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
self.timers.set_timeout_or_interval(TimerCallback::FunctionTimerCallback(callback),
args,
@ -220,6 +228,7 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
self.script_chan())
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
fn SetInterval_(self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
self.timers.set_timeout_or_interval(TimerCallback::StringTimerCallback(callback),
args,
@ -229,6 +238,7 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
self.script_chan())
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-clearinterval
fn ClearInterval(self, handle: i32) {
self.ClearTimeout(handle);
}

View file

@ -32,30 +32,37 @@ impl WorkerNavigator {
}
impl<'a> WorkerNavigatorMethods for &'a WorkerNavigator {
// https://html.spec.whatwg.org/multipage/#dom-navigator-product
fn Product(self) -> DOMString {
navigatorinfo::Product()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-taintenabled
fn TaintEnabled(self) -> bool {
navigatorinfo::TaintEnabled()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appname
fn AppName(self) -> DOMString {
navigatorinfo::AppName()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appcodename
fn AppCodeName(self) -> DOMString {
navigatorinfo::AppCodeName()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-platform
fn Platform(self) -> DOMString {
navigatorinfo::Platform()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-useragent
fn UserAgent(self) -> DOMString {
navigatorinfo::UserAgent()
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-appversion
fn AppVersion(self) -> DOMString {
navigatorinfo::AppVersion()
}

View file

@ -662,8 +662,8 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
}
}
// https://xhr.spec.whatwg.org/#the-response-attribute
#[allow(unsafe_code)]
// https://xhr.spec.whatwg.org/#the-response-attribute
fn Response(self, cx: *mut JSContext) -> JSVal {
let mut rval = RootedValue::new(cx, UndefinedValue());
match self.response_type.get() {