mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update ns[C]String::from -> ns[C]Str::from where possible
This commit is contained in:
parent
cc8b69bae1
commit
c1c98659b9
4 changed files with 10 additions and 12 deletions
|
@ -14,7 +14,7 @@ use gecko_bindings::structs::{CounterStylePtr, nsStyleCoord};
|
||||||
use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
|
use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
|
||||||
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use nsstring::{nsACString, nsCString};
|
use nsstring::{nsACString, nsCStr};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use values::{Auto, Either, ExtremumLength, None_, Normal};
|
use values::{Auto, Either, ExtremumLength, None_, Normal};
|
||||||
use values::computed::{Angle, Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
use values::computed::{Angle, Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
|
@ -465,7 +465,7 @@ impl CounterStyleOrNone {
|
||||||
},
|
},
|
||||||
CounterStyleOrNone::Symbols(symbols_type, symbols) => {
|
CounterStyleOrNone::Symbols(symbols_type, symbols) => {
|
||||||
let symbols: Vec<_> = symbols.0.iter().map(|symbol| match *symbol {
|
let symbols: Vec<_> = symbols.0.iter().map(|symbol| match *symbol {
|
||||||
Symbol::String(ref s) => nsCString::from(s),
|
Symbol::String(ref s) => nsCStr::from(s),
|
||||||
Symbol::Ident(_) => unreachable!("Should not have identifier in symbols()"),
|
Symbol::Ident(_) => unreachable!("Should not have identifier in symbols()"),
|
||||||
}).collect();
|
}).collect();
|
||||||
let symbols: Vec<_> = symbols.iter()
|
let symbols: Vec<_> = symbols.iter()
|
||||||
|
|
|
@ -11,7 +11,7 @@ use gecko_bindings::bindings::Gecko_Atomize;
|
||||||
use gecko_bindings::bindings::Gecko_Atomize16;
|
use gecko_bindings::bindings::Gecko_Atomize16;
|
||||||
use gecko_bindings::bindings::Gecko_ReleaseAtom;
|
use gecko_bindings::bindings::Gecko_ReleaseAtom;
|
||||||
use gecko_bindings::structs::{nsIAtom, nsIAtom_AtomKind};
|
use gecko_bindings::structs::{nsIAtom, nsIAtom_AtomKind};
|
||||||
use nsstring::{nsAString, nsString};
|
use nsstring::{nsAString, nsStr};
|
||||||
use precomputed_hash::PrecomputedHash;
|
use precomputed_hash::PrecomputedHash;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::{Cow, Borrow};
|
use std::borrow::{Cow, Borrow};
|
||||||
|
@ -346,7 +346,7 @@ impl<'a> From<&'a str> for Atom {
|
||||||
impl<'a> From<&'a [u16]> for Atom {
|
impl<'a> From<&'a [u16]> for Atom {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(slice: &[u16]) -> Atom {
|
fn from(slice: &[u16]) -> Atom {
|
||||||
Atom::from(&*nsString::from(slice))
|
Atom::from(&*nsStr::from(slice))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4086,13 +4086,13 @@ fn static_assert() {
|
||||||
|
|
||||||
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) {
|
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) {
|
||||||
use gecko_bindings::bindings::Gecko_SetCounterStyleToString;
|
use gecko_bindings::bindings::Gecko_SetCounterStyleToString;
|
||||||
use nsstring::{nsACString, nsCString};
|
use nsstring::{nsACString, nsCStr};
|
||||||
use self::longhands::list_style_type::computed_value::T;
|
use self::longhands::list_style_type::computed_value::T;
|
||||||
match v {
|
match v {
|
||||||
T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle, device),
|
T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle, device),
|
||||||
T::String(s) => unsafe {
|
T::String(s) => unsafe {
|
||||||
Gecko_SetCounterStyleToString(&mut self.gecko.mCounterStyle,
|
Gecko_SetCounterStyleToString(&mut self.gecko.mCounterStyle,
|
||||||
&nsCString::from(s) as &nsACString)
|
&nsCStr::from(&s) as &nsACString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4679,9 +4679,8 @@ fn static_assert() {
|
||||||
<%call expr="impl_coord_copy('word_spacing', 'mWordSpacing')"></%call>
|
<%call expr="impl_coord_copy('word_spacing', 'mWordSpacing')"></%call>
|
||||||
|
|
||||||
fn clear_text_emphasis_style_if_string(&mut self) {
|
fn clear_text_emphasis_style_if_string(&mut self) {
|
||||||
use nsstring::nsString;
|
|
||||||
if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
|
if self.gecko.mTextEmphasisStyle == structs::NS_STYLE_TEXT_EMPHASIS_STYLE_STRING as u8 {
|
||||||
self.gecko.mTextEmphasisStyleString.assign(&nsString::new());
|
self.gecko.mTextEmphasisStyleString.truncate();
|
||||||
self.gecko.mTextEmphasisStyle = structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8;
|
self.gecko.mTextEmphasisStyle = structs::NS_STYLE_TEXT_EMPHASIS_STYLE_NONE as u8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4797,10 +4796,9 @@ fn static_assert() {
|
||||||
|
|
||||||
fn clear_overflow_sides_if_string(&mut self) {
|
fn clear_overflow_sides_if_string(&mut self) {
|
||||||
use gecko_bindings::structs::nsStyleTextOverflowSide;
|
use gecko_bindings::structs::nsStyleTextOverflowSide;
|
||||||
use nsstring::nsString;
|
|
||||||
fn clear_if_string(side: &mut nsStyleTextOverflowSide) {
|
fn clear_if_string(side: &mut nsStyleTextOverflowSide) {
|
||||||
if side.mType == structs::NS_STYLE_TEXT_OVERFLOW_STRING as u8 {
|
if side.mType == structs::NS_STYLE_TEXT_OVERFLOW_STRING as u8 {
|
||||||
side.mString.assign(&nsString::new());
|
side.mString.truncate();
|
||||||
side.mType = structs::NS_STYLE_TEXT_OVERFLOW_CLIP as u8;
|
side.mType = structs::NS_STYLE_TEXT_OVERFLOW_CLIP as u8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ impl UrlMatchingFunction {
|
||||||
pub fn evaluate(&self, device: &Device) -> bool {
|
pub fn evaluate(&self, device: &Device) -> bool {
|
||||||
use gecko_bindings::bindings::Gecko_DocumentRule_UseForPresentation;
|
use gecko_bindings::bindings::Gecko_DocumentRule_UseForPresentation;
|
||||||
use gecko_bindings::structs::URLMatchingFunction as GeckoUrlMatchingFunction;
|
use gecko_bindings::structs::URLMatchingFunction as GeckoUrlMatchingFunction;
|
||||||
use nsstring::nsCString;
|
use nsstring::nsCStr;
|
||||||
|
|
||||||
let func = match *self {
|
let func = match *self {
|
||||||
UrlMatchingFunction::Url(_) => GeckoUrlMatchingFunction::eURL,
|
UrlMatchingFunction::Url(_) => GeckoUrlMatchingFunction::eURL,
|
||||||
|
@ -147,7 +147,7 @@ impl UrlMatchingFunction {
|
||||||
UrlMatchingFunction::RegExp(_) => GeckoUrlMatchingFunction::eRegExp,
|
UrlMatchingFunction::RegExp(_) => GeckoUrlMatchingFunction::eRegExp,
|
||||||
};
|
};
|
||||||
|
|
||||||
let pattern = nsCString::from(match *self {
|
let pattern = nsCStr::from(match *self {
|
||||||
UrlMatchingFunction::Url(ref url) => url.as_str(),
|
UrlMatchingFunction::Url(ref url) => url.as_str(),
|
||||||
UrlMatchingFunction::UrlPrefix(ref pat) |
|
UrlMatchingFunction::UrlPrefix(ref pat) |
|
||||||
UrlMatchingFunction::Domain(ref pat) |
|
UrlMatchingFunction::Domain(ref pat) |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue