Bug 1317179 - [Servo] Use XPCOM string bindings instead of Gecko_Utf8SliceToString.
MozReview-Commit-ID: Ct9K47QiXYl
--- a/servo/components/style/gecko_bindings/bindings.rs
+++ b/servo/components/style/gecko_bindings/bindings.rs
@@ -81,17 +81,16 @@ use gecko_bindings::structs::nsCursorIma
use gecko_bindings::structs::nsFont;
use gecko_bindings::structs::nsIAtom;
use gecko_bindings::structs::nsIDocument;
use gecko_bindings::structs::nsINode;
use gecko_bindings::structs::nsIPrincipal;
use gecko_bindings::structs::nsIURI;
use gecko_bindings::structs::nsMainThreadPtrHolder;
use gecko_bindings::structs::nsRestyleHint;
-use gecko_bindings::structs::nsString;
use gecko_bindings::structs::nsStyleBackground;
unsafe impl Send for nsStyleBackground {}
unsafe impl Sync for nsStyleBackground {}
use gecko_bindings::structs::nsStyleBorder;
unsafe impl Send for nsStyleBorder {}
unsafe impl Sync for nsStyleBorder {}
use gecko_bindings::structs::nsStyleColor;
unsafe impl Send for nsStyleColor {}
@@ -484,20 +483,16 @@ extern "C" {
}
extern "C" {
pub fn Gecko_AtomEqualsUTF8IgnoreCase(aAtom: *mut nsIAtom,
aString:
*const ::std::os::raw::c_char,
aLength: u32) -> bool;
}
extern "C" {
- pub fn Gecko_Utf8SliceToString(aString: *mut nsString, aBuffer: *const u8,
- aBufferLen: usize);
-}
-extern "C" {
pub fn Gecko_FontFamilyList_Clear(aList: *mut FontFamilyList);
}
extern "C" {
pub fn Gecko_FontFamilyList_AppendNamed(aList: *mut FontFamilyList,
aName: *mut nsIAtom);
}
extern "C" {
pub fn Gecko_FontFamilyList_AppendGeneric(list: *mut FontFamilyList,
@@ -1090,17 +1085,17 @@ extern "C" {
RawServoDeclarationBlockBorrowed,
result: *mut nsAString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_SerializeOneValue(declarations:
RawServoDeclarationBlockBorrowed,
property: *const nsIAtom,
is_custom: bool,
- buffer: *mut nsString);
+ buffer: *mut nsAString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_Count(declarations:
RawServoDeclarationBlockBorrowed)
-> u32;
}
extern "C" {
pub fn Servo_DeclarationBlock_GetNthProperty(declarations:
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -32,24 +32,22 @@ use style::gecko_bindings::bindings;
use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockStrong};
use style::gecko_bindings::bindings::{RawServoStyleRuleBorrowed, RawServoStyleRuleStrong};
use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned};
use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed};
use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
use style::gecko_bindings::bindings::{ThreadSafePrincipalHolder, ThreadSafeURIHolder};
use style::gecko_bindings::bindings::{nsACString, nsAString};
-use style::gecko_bindings::bindings::Gecko_Utf8SliceToString;
use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
use style::gecko_bindings::structs;
use style::gecko_bindings::structs::{SheetParsingMode, nsIAtom};
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint};
-use style::gecko_bindings::structs::nsString;
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
use style::parallel;
use style::parser::{ParserContext, ParserContextExtraData};
use style::properties::{CascadeFlags, ComputedValues, Importance, PropertyDeclaration};
use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock};
use style::properties::{apply_declarations, parse_one_declaration};
@@ -560,29 +558,25 @@ pub extern "C" fn Servo_DeclarationBlock
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
declarations.read().to_css(unsafe { result.as_mut().unwrap() }).unwrap();
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SerializeOneValue(
declarations: RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom, is_custom: bool,
- buffer: *mut nsString)
+ buffer: *mut nsAString)
{
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
let property = get_property_name_from_atom(property, is_custom);
let mut string = String::new();
let rv = declarations.read().single_value_to_css(&property, &mut string);
debug_assert!(rv.is_ok());
- // FIXME: Once we have nsString bindings for Servo (bug 1294742), we should be able to drop
- // this and fill in |buffer| directly.
- unsafe {
- Gecko_Utf8SliceToString(buffer, string.as_ptr(), string.len());
- }
+ write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string");
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_Count(declarations: RawServoDeclarationBlockBorrowed) -> u32 {
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
declarations.read().declarations.len() as u32
}