mirror of
https://github.com/servo/servo.git
synced 2025-08-25 23:28:21 +01:00
Revert "Auto merge of #16976 - upsuper:bug1366247, r=nox"
This reverts commit3d40b516c8
, reversing changes made to255387a915
.
This commit is contained in:
parent
cdf52773a1
commit
1f7d48f564
7 changed files with 28 additions and 79 deletions
|
@ -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")
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue