# HG changeset patch # User Xidorn Quan # Date 1546159039 0 # Node ID a22cf2ec4f2dbfa6f860ba317c24ee1079d24653 # Parent 15fd28b89842fb048e199519f86bb40e9d6c0b13 Bug 1516829 - Replace trim_{left,right}* with trim_{start,end}*. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D15496 diff --git a/servo/components/style/attr.rs b/servo/components/style/attr.rs --- a/servo/components/style/attr.rs +++ b/servo/components/style/attr.rs @@ -527,17 +527,17 @@ pub fn parse_legacy_color(mut input: &st /// Parses a [dimension value][dim]. If unparseable, `Auto` is returned. /// /// [dim]: https://html.spec.whatwg.org/multipage/#rules-for-parsing-dimension-values // TODO: this function can be rewritten to return Result pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { // Steps 1 & 2 are not relevant // Step 3 - value = value.trim_left_matches(HTML_SPACE_CHARACTERS); + value = value.trim_start_matches(HTML_SPACE_CHARACTERS); // Step 4 if value.is_empty() { return LengthOrPercentageOrAuto::Auto } // Step 5 if value.starts_with('+') { diff --git a/servo/components/style/values/computed/font.rs b/servo/components/style/values/computed/font.rs --- a/servo/components/style/values/computed/font.rs +++ b/servo/components/style/values/computed/font.rs @@ -707,17 +707,17 @@ impl ToCss for FontLanguageOverride { let mut buf = [0; 4]; BigEndian::write_u32(&mut buf, self.0); // Safe because we ensure it's ASCII during computing let slice = if cfg!(debug_assertions) { str::from_utf8(&buf).unwrap() } else { unsafe { str::from_utf8_unchecked(&buf) } }; - slice.trim_right().to_css(dest) + slice.trim_end().to_css(dest) } } #[cfg(feature = "gecko")] impl From for FontLanguageOverride { fn from(bits: u32) -> FontLanguageOverride { FontLanguageOverride(bits) } diff --git a/servo/components/style/values/specified/position.rs b/servo/components/style/values/specified/position.rs --- a/servo/components/style/values/specified/position.rs +++ b/servo/components/style/values/specified/position.rs @@ -661,17 +661,17 @@ pub struct NamedArea { /// Tokenize the string into a list of the tokens, /// using longest-match semantics struct TemplateAreasTokenizer<'a>(&'a str); impl<'a> Iterator for TemplateAreasTokenizer<'a> { type Item = Result, ()>; fn next(&mut self) -> Option { - let rest = self.0.trim_left_matches(HTML_SPACE_CHARACTERS); + let rest = self.0.trim_start_matches(HTML_SPACE_CHARACTERS); if rest.is_empty() { return None; } if rest.starts_with('.') { self.0 = &rest[rest.find(|c| c != '.').unwrap_or(rest.len())..]; return Some(Ok(None)); } if !rest.starts_with(is_name_code_point) { diff --git a/servo/components/style_derive/cg.rs b/servo/components/style_derive/cg.rs --- a/servo/components/style_derive/cg.rs +++ b/servo/components/style_derive/cg.rs @@ -376,17 +376,17 @@ pub fn where_predicate( parse_quote!(#bounded_ty: #trait_ref) } /// Transforms "FooBar" to "foo-bar". /// /// If the first Camel segment is "Moz", "Webkit", or "Servo", the result string /// is prepended with "-". pub fn to_css_identifier(mut camel_case: &str) -> String { - camel_case = camel_case.trim_right_matches('_'); + camel_case = camel_case.trim_end_matches('_'); let mut first = true; let mut result = String::with_capacity(camel_case.len()); while let Some(segment) = split_camel_segment(&mut camel_case) { if first { match segment { "Moz" | "Webkit" | "Servo" => first = false, _ => {}, }