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

Low hanging Dromaeo fruit #6900

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -399,8 +399,9 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite

impl ToJSValConvertible for str {
fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
let mut string_utf16: Vec<u16> = Vec::with_capacity(self.len());
unsafe {
let string_utf16: Vec<u16> = self.utf16_units().collect();
string_utf16.extend(self.utf16_units());
let jsstr = JS_NewUCStringCopyN(cx, string_utf16.as_ptr() as *const i16,
string_utf16.len() as libc::size_t);
if jsstr.is_null() {
@@ -893,8 +893,8 @@ impl Element {
}

pub fn set_attribute(&self, name: &Atom, value: AttrValue) {
assert!(&**name == name.to_ascii_lowercase());
assert!(!name.contains(":"));
debug_assert!(&**name == name.to_ascii_lowercase());
debug_assert!(!name.contains(":"));

self.set_first_matching_attribute(
name.clone(), value, name.clone(), ns!(""), None,
@@ -989,13 +989,13 @@ impl Element {
}

pub fn set_atomic_attribute(&self, local_name: &Atom, value: DOMString) {
assert!(&**local_name == local_name.to_ascii_lowercase());
debug_assert!(&**local_name == local_name.to_ascii_lowercase());
let value = AttrValue::from_atomic(value);
self.set_attribute(local_name, value);
}

pub fn has_attribute(&self, local_name: &Atom) -> bool {
assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
debug_assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
self.attrs.borrow().iter().map(JS::root).any(|attr| {
attr.r().local_name() == local_name && attr.r().namespace() == &ns!("")
})
@@ -1011,7 +1011,7 @@ impl Element {
}

pub fn get_url_attribute(&self, local_name: &Atom) -> DOMString {
assert!(&**local_name == local_name.to_ascii_lowercase());
debug_assert!(&**local_name == local_name.to_ascii_lowercase());
if !self.has_attribute(local_name) {
return "".to_owned();
}
@@ -1036,7 +1036,7 @@ impl Element {
}
}
pub fn set_string_attribute(&self, local_name: &Atom, value: DOMString) {
assert!(&**local_name == local_name.to_ascii_lowercase());
debug_assert!(&**local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::String(value));
}

@@ -1050,17 +1050,17 @@ impl Element {
}

pub fn set_tokenlist_attribute(&self, local_name: &Atom, value: DOMString) {
assert!(&**local_name == local_name.to_ascii_lowercase());
debug_assert!(&**local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::from_serialized_tokenlist(value));
}

pub fn set_atomic_tokenlist_attribute(&self, local_name: &Atom, tokens: Vec<Atom>) {
assert!(&**local_name == local_name.to_ascii_lowercase());
debug_assert!(&**local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::from_atomic_tokens(tokens));
}

pub fn get_uint_attribute(&self, local_name: &Atom, default: u32) -> u32 {
assert!(local_name.chars().all(|ch| {
debug_assert!(local_name.chars().all(|ch| {
!ch.is_ascii() || ch.to_ascii_lowercase() == ch
}));
let attribute = self.get_attribute(&ns!(""), local_name);
@@ -1075,8 +1075,9 @@ impl Element {
None => default,
}
}

pub fn set_uint_attribute(&self, local_name: &Atom, value: u32) {
assert!(&**local_name == local_name.to_ascii_lowercase());
debug_assert!(&**local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::UInt(value.to_string(), value));
}
}
@@ -33,15 +33,19 @@ interface Element : Node {

[Constant]
readonly attribute NamedNodeMap attributes;
[Pure]
DOMString? getAttribute(DOMString name);
[Pure]
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
[Throws]
void setAttribute(DOMString name, DOMString value);
[Throws]
void setAttributeNS(DOMString? namespace, DOMString name, DOMString value);
void removeAttribute(DOMString name);
void removeAttributeNS(DOMString? namespace, DOMString localName);
[Pure]
boolean hasAttribute(DOMString name);
[Pure]
boolean hasAttributeNS(DOMString? namespace, DOMString localName);

[Throws]
@@ -50,8 +54,11 @@ interface Element : Node {
[Throws]
boolean matches(DOMString selectors);

[Pure]
HTMLCollection getElementsByTagName(DOMString localName);
[Pure]
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
[Pure]
HTMLCollection getElementsByClassName(DOMString classNames);
};

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.