style: Remove some uses of unused unsafe.

This commit is contained in:
Emilio Cobos Álvarez 2017-11-13 22:37:45 +01:00
parent 2efbf2230a
commit 69ddb9501b
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
10 changed files with 45 additions and 60 deletions

View file

@ -157,18 +157,16 @@ impl Device {
/// Returns the current media type of the device.
pub fn media_type(&self) -> MediaType {
unsafe {
// Gecko allows emulating random media with mIsEmulatingMedia and
// mMediaEmulated.
let context = self.pres_context();
let medium_to_use = if context.mIsEmulatingMedia() != 0 {
context.mMediaEmulated.mRawPtr
} else {
context.mMedium
};
// Gecko allows emulating random media with mIsEmulatingMedia and
// mMediaEmulated.
let context = self.pres_context();
let medium_to_use = if context.mIsEmulatingMedia() != 0 {
context.mMediaEmulated.mRawPtr
} else {
context.mMedium
};
MediaType(CustomIdent(Atom::from(medium_to_use)))
}
MediaType(CustomIdent(Atom::from(medium_to_use)))
}
/// Returns the current viewport size in app units.

View file

@ -195,13 +195,11 @@ cfg_if! {{
'''
RULE_TEMPLATE = ('("{atom}") =>\n '
'{{ '
# FIXME(bholley): Uncomment this when rust 1.14 is released.
# See the comment in components/style/lib.rs.
# ' #[allow(unsafe_code)] #[allow(unused_unsafe)] '
'{{{{ '
'#[allow(unsafe_code)] #[allow(unused_unsafe)]'
'unsafe {{ $crate::string_cache::atom_macro::atom_from_static'
'($crate::string_cache::atom_macro::{name} as *mut _) }}'
' }};')
' }}}};')
MACRO = '''
#[macro_export]

View file

@ -37,9 +37,7 @@ impl SnapshotMap {
debug_assert!(element.has_snapshot());
unsafe {
let element =
unsafe { ::std::mem::transmute::<&E, &GeckoElement>(element) };
let element = ::std::mem::transmute::<&E, &GeckoElement>(element);
bindings::Gecko_GetElementSnapshot(self, element.0).as_ref()
}
}
@ -171,8 +169,7 @@ impl ElementSnapshot for GeckoElementSnapshot {
}
let ptr = unsafe {
bindings::Gecko_SnapshotAtomAttrValue(self,
atom!("id").as_ptr())
bindings::Gecko_SnapshotAtomAttrValue(self, atom!("id").as_ptr())
};
if ptr.is_null() {

View file

@ -402,7 +402,7 @@ impl<'lb> GeckoXBLBinding<'lb> {
}
fn anon_content(&self) -> *const nsIContent {
unsafe { self.0.mContent.raw::<nsIContent>() }
self.0.mContent.raw::<nsIContent>()
}
fn inherits_style(&self) -> bool {
@ -510,8 +510,8 @@ impl<'le> GeckoElement<'le> {
unsafe { Gecko_SetNodeFlags(self.as_node().0, flags) }
}
fn unset_flags(&self, flags: u32) {
unsafe { Gecko_UnsetNodeFlags(self.as_node().0, flags) }
unsafe fn unset_flags(&self, flags: u32) {
Gecko_UnsetNodeFlags(self.as_node().0, flags)
}
/// Returns true if this element has descendants for lazy frame construction.
@ -1224,15 +1224,13 @@ impl<'le> TElement for GeckoElement<'le> {
unsafe fn clear_data(&self) {
let ptr = self.0.mServoData.get();
unsafe {
self.unset_flags(ELEMENT_HAS_SNAPSHOT as u32 |
ELEMENT_HANDLED_SNAPSHOT as u32 |
structs::Element_kAllServoDescendantBits |
NODE_NEEDS_FRAME as u32);
}
self.unset_flags(ELEMENT_HAS_SNAPSHOT as u32 |
ELEMENT_HANDLED_SNAPSHOT as u32 |
structs::Element_kAllServoDescendantBits |
NODE_NEEDS_FRAME as u32);
if !ptr.is_null() {
debug!("Dropping ElementData for {:?}", self);
let data = unsafe { Box::from_raw(self.0.mServoData.get()) };
let data = Box::from_raw(self.0.mServoData.get());
self.0.mServoData.set(ptr::null_mut());
// Perform a mutable borrow of the data in debug builds. This