Revert "Auto merge of #16976 - upsuper:bug1366247, r=nox"

This reverts commit 3d40b516c8, reversing
changes made to 255387a915.
This commit is contained in:
Emilio Cobos Álvarez 2017-05-21 21:29:50 +02:00
parent cdf52773a1
commit 1f7d48f564
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 28 additions and 79 deletions

View file

@ -1,48 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! little helpers for `already_AddRefed`.
use gecko_bindings::structs::already_AddRefed;
use std::marker::PhantomData;
use std::mem;
impl<T> already_AddRefed<T> {
/// Create an already_AddRefed from an addrefed pointer.
#[inline]
pub unsafe fn new(ptr: *mut T) -> Option<Self> {
if !ptr.is_null() {
Some(Self::new_unchecked(ptr))
} else {
None
}
}
/// Create an already_AddRefed from an non-nullable addrefed pointer.
#[inline]
pub unsafe fn new_unchecked(ptr: *mut T) -> Self {
debug_assert!(!ptr.is_null());
already_AddRefed {
mRawPtr: ptr,
_phantom_0: PhantomData,
}
}
/// Take the addrefed pointer from this struct.
#[inline]
pub fn take(self) -> *mut T {
let ptr = self.mRawPtr;
mem::forget(self);
ptr
}
}
#[cfg(debug_assertions)]
impl<T> Drop for already_AddRefed<T> {
fn drop(&mut self) {
// We really should instead mark already_AddRefed must_use, but
// we cannot currently, which is servo/rust-bindgen#710.
unreachable!("Destructor shouldn't be called, otherwise we are leaking")
}
}

View file

@ -4,7 +4,6 @@
//! Rust sugar and convenience methods for Gecko types.
mod already_addrefed;
mod ns_com_ptr;
mod ns_compatibility;
mod ns_css_shadow_array;

View file

@ -152,7 +152,7 @@ impl nsCSSValue {
/// Set to an atom identifier value
pub fn set_atom_ident(&mut self, s: Atom) {
unsafe { bindings::Gecko_CSSValue_SetAtomIdent(self, s.into()) }
unsafe { bindings::Gecko_CSSValue_SetAtomIdent(self, s.into_addrefed()) }
}
/// Set to a font format