Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XPCOM string bindings instead of Gecko_Utf8SliceToString #14404

Merged
merged 1 commit into from Dec 1, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Bug 1317179 - Use XPCOM string bindings instead of Gecko_Utf8SliceToS…

…tring. r=manishearth
  • Loading branch information
BorisChiou committed Nov 29, 2016
commit c45bc93d8f0cde200b48f912b7f62f172ea2c890
@@ -86,7 +86,6 @@ 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 {}
@@ -488,10 +487,6 @@ extern "C" {
*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);
}
@@ -1095,7 +1090,7 @@ extern "C" {
RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom,
is_custom: bool,
buffer: *mut nsString);
buffer: *mut nsAString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_Count(declarations:
@@ -37,14 +37,12 @@ use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedVal
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};
@@ -565,19 +563,15 @@ pub extern "C" fn Servo_DeclarationBlock_GetCssText(declarations: RawServoDeclar
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]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.