aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/blob.rs5
-rw-r--r--components/script/dom/cssstyledeclaration.rs18
-rw-r--r--components/script/dom/document.rs7
-rw-r--r--components/script/dom/element.rs10
-rw-r--r--components/script/dom/htmlcollection.rs9
-rw-r--r--components/script/dom/htmlscriptelement.rs4
-rw-r--r--components/script/dom/window.rs2
7 files changed, 32 insertions, 23 deletions
diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs
index f8102dd9acf..7e101dc4070 100644
--- a/components/script/dom/blob.rs
+++ b/components/script/dom/blob.rs
@@ -123,9 +123,10 @@ impl BlobMethods for Blob {
};
let relativeContentType = match contentType {
None => "".to_owned(),
- Some(str) => {
+ Some(mut str) => {
if is_ascii_printable(&str) {
- str.to_ascii_lowercase()
+ str.make_ascii_lowercase();
+ str
} else {
"".to_owned()
}
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index e44e17d39de..c13b65a0a55 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -122,11 +122,12 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
- fn GetPropertyValue(&self, property: DOMString) -> DOMString {
+ fn GetPropertyValue(&self, mut property: DOMString) -> DOMString {
let owner = self.owner.root();
// Step 1
- let property = Atom::from_slice(&property.to_ascii_lowercase());
+ property.make_ascii_lowercase();
+ let property = Atom::from_slice(&property);
if self.readonly {
// Readonly style declarations are used for getComputedStyle.
@@ -165,9 +166,10 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertypriority
- fn GetPropertyPriority(&self, property: DOMString) -> DOMString {
+ fn GetPropertyPriority(&self, mut property: DOMString) -> DOMString {
// Step 1
- let property = Atom::from_slice(&property.to_ascii_lowercase());
+ property.make_ascii_lowercase();
+ let property = Atom::from_slice(&property);
// Step 2
let longhand_properties = longhands_from_shorthand(&property);
@@ -193,7 +195,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
- fn SetProperty(&self, property: DOMString, value: DOMString,
+ fn SetProperty(&self, mut property: DOMString, value: DOMString,
priority: DOMString) -> ErrorResult {
// Step 1
if self.readonly {
@@ -201,7 +203,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// Step 2
- let property = property.to_ascii_lowercase();
+ property.make_ascii_lowercase();
// Step 3
if !is_supported_property(&property) {
@@ -287,14 +289,14 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
- fn RemoveProperty(&self, property: DOMString) -> Fallible<DOMString> {
+ fn RemoveProperty(&self, mut property: DOMString) -> Fallible<DOMString> {
// Step 1
if self.readonly {
return Err(Error::NoModificationAllowed);
}
// Step 2
- let property = property.to_ascii_lowercase();
+ property.make_ascii_lowercase();
// Step 3
let value = self.GetPropertyValue(property.clone());
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 0ff28055e9d..23df1732104 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -1243,7 +1243,7 @@ impl DocumentMethods for Document {
return Err(InvalidCharacter);
}
if self.is_html_document {
- local_name = local_name.to_ascii_lowercase()
+ local_name.make_ascii_lowercase();
}
let name = QualName::new(ns!(HTML), Atom::from_slice(&local_name));
Ok(Element::create(name, None, self, ElementCreator::ScriptCreated))
@@ -1350,10 +1350,11 @@ impl DocumentMethods for Document {
}
// https://dom.spec.whatwg.org/#dom-document-createevent
- fn CreateEvent(&self, interface: DOMString) -> Fallible<Root<Event>> {
+ fn CreateEvent(&self, mut interface: DOMString) -> Fallible<Root<Event>> {
let window = self.window.root();
- match &*interface.to_ascii_lowercase() {
+ interface.make_ascii_lowercase();
+ match &*interface {
"uievents" | "uievent" => Ok(EventCast::from_root(
UIEvent::new_uninitialized(window.r()))),
"mouseevents" | "mouseevent" => Ok(EventCast::from_root(
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 83b7c24ed3a..56312fb6cf3 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -578,12 +578,11 @@ impl Element {
&self.local_name
}
- pub fn parsed_name(&self, name: DOMString) -> Atom {
+ pub fn parsed_name(&self, mut name: DOMString) -> Atom {
if self.html_element_in_html_document() {
- Atom::from_slice(&name.to_ascii_lowercase())
- } else {
- Atom::from_slice(&name)
+ name.make_ascii_lowercase();
}
+ Atom::from_slice(&name)
}
pub fn namespace(&self) -> &Namespace {
@@ -830,7 +829,8 @@ impl Element {
pub fn get_attribute(&self, namespace: &Namespace, local_name: &Atom) -> Option<Root<Attr>> {
let mut attributes = RootedVec::new();
self.get_attributes(local_name, &mut attributes);
- attributes.r().iter()
+ attributes.r().
+ iter()
.find(|attr| attr.namespace() == namespace)
.map(|attr| Root::from_ref(*attr))
}
diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs
index 6aee8645ad8..83458ee0338 100644
--- a/components/script/dom/htmlcollection.rs
+++ b/components/script/dom/htmlcollection.rs
@@ -68,7 +68,7 @@ impl HTMLCollection {
HTMLCollection::create(window, root, box filter)
}
- pub fn by_tag_name(window: &Window, root: &Node, tag: DOMString)
+ pub fn by_tag_name(window: &Window, root: &Node, mut tag: DOMString)
-> Root<HTMLCollection> {
if tag == "*" {
return HTMLCollection::all_elements(window, root, None);
@@ -88,9 +88,12 @@ impl HTMLCollection {
}
}
}
+ let tag_atom = Atom::from_slice(&tag);
+ tag.make_ascii_lowercase();
+ let ascii_lower_tag = Atom::from_slice(&tag);
let filter = TagNameFilter {
- tag: Atom::from_slice(&tag),
- ascii_lower_tag: Atom::from_slice(&tag.to_ascii_lowercase()),
+ tag: tag_atom,
+ ascii_lower_tag: ascii_lower_tag,
};
HTMLCollection::create(window, root, box filter)
}
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 82908e2d78f..84ea5c7d3b4 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -489,7 +489,9 @@ impl HTMLScriptElement {
},
Some(ref s) => {
debug!("script language={}", *s);
- SCRIPT_JS_MIMES.contains(&&*format!("text/{}", s).to_ascii_lowercase())
+ let mut language = format!("text/{}", s);
+ language.make_ascii_lowercase();
+ SCRIPT_JS_MIMES.contains(&&*language)
},
None => {
debug!("no script type or language, inferring js");
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 6fd99de5b4d..c5d5f6ee020 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -587,7 +587,7 @@ impl WindowMethods for Window {
element: &Element,
pseudo: Option<DOMString>) -> Root<CSSStyleDeclaration> {
// Steps 1-4.
- let pseudo = match pseudo.map(|s| s.to_ascii_lowercase()) {
+ let pseudo = match pseudo.map(|mut s| { s.make_ascii_lowercase(); s }) {
Some(ref pseudo) if pseudo == ":before" || pseudo == "::before" =>
Some(PseudoElement::Before),
Some(ref pseudo) if pseudo == ":after" || pseudo == "::after" =>