mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Remove some uses of unused unsafe.
This commit is contained in:
parent
2efbf2230a
commit
69ddb9501b
10 changed files with 45 additions and 60 deletions
|
@ -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.
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue