mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Replace many uses of to_ascii_lowercase() by make_ascii_lowercase()
This commit is contained in:
parent
67cbda4be3
commit
105d990845
7 changed files with 32 additions and 23 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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" =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue