Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy check for FooMethods in components/script/dom/*.rs and color for tidy #6699

Merged
merged 2 commits into from Jul 28, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -98,20 +98,20 @@ 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,
Some(ref bytes) => bytes.len() as u64
}
}

// 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();
@@ -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()
}
@@ -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);
@@ -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;
@@ -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();
@@ -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)
}
@@ -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);
}
@@ -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()
}
@@ -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)
@@ -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)
@@ -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) {
@@ -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
}
}
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.