Bug 1358966 - Use assign_utf8 to set servo's string into nsAString. r?emilio
MozReview-Commit-ID: oOaEgOeMEu
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -550,17 +550,18 @@ pub extern "C" fn Servo_AnimationValue_S
buffer: *mut nsAString)
{
let uncomputed_value = AnimationValue::as_arc(&value).uncompute();
let mut string = String::new();
let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal)
.single_value_to_css(&get_property_id_from_nscsspropertyid!(property, ()), &mut string);
debug_assert!(rv.is_ok());
- write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string");
+ let buffer = unsafe { buffer.as_mut().unwrap() };
+ buffer.assign_utf8(&string);
}
#[no_mangle]
pub extern "C" fn Servo_AnimationValue_GetOpacity(value: RawServoAnimationValueBorrowed)
-> f32
{
let value = AnimationValue::as_arc(&value);
if let AnimationValue::Opacity(opacity) = **value {
@@ -1648,17 +1649,18 @@ pub extern "C" fn Servo_DeclarationBlock
property_id: nsCSSPropertyID, buffer: *mut nsAString)
{
let property_id = get_property_id_from_nscsspropertyid!(property_id, ());
read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
let mut string = String::new();
let rv = decls.single_value_to_css(&property_id, &mut string);
debug_assert!(rv.is_ok());
- write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string");
+ let buffer = unsafe { buffer.as_mut().unwrap() };
+ buffer.assign_utf8(&string);
})
}
#[no_mangle]
pub extern "C" fn Servo_SerializeFontValueForCanvas(
declarations: RawServoDeclarationBlockBorrowed,
buffer: *mut nsAString) {
use style::properties::shorthands::font;
@@ -1671,17 +1673,18 @@ pub extern "C" fn Servo_SerializeFontVal
return;
}
};
let mut string = String::new();
let rv = longhands.to_css_for_canvas(&mut string);
debug_assert!(rv.is_ok());
- write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string");
+ let buffer = unsafe { buffer.as_mut().unwrap() };
+ buffer.assign_utf8(&string);
})
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_Count(declarations: RawServoDeclarationBlockBorrowed) -> u32 {
read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
decls.declarations().len() as u32
})