aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-11-13 22:37:45 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-11-15 13:26:24 +0100
commit69ddb9501ba620ce6b34377eb379e4bb576bda3c (patch)
treecb9cf77641de753fb490b7af97205525075ac155 /components
parent2efbf2230a61a2fda1ecc4cd12618177d4ca50cd (diff)
downloadservo-69ddb9501ba620ce6b34377eb379e4bb576bda3c.tar.gz
servo-69ddb9501ba620ce6b34377eb379e4bb576bda3c.zip
style: Remove some uses of unused unsafe.
Diffstat (limited to 'components')
-rw-r--r--components/style/context.rs4
-rw-r--r--components/style/gecko/media_queries.rs20
-rwxr-xr-xcomponents/style/gecko/regen_atoms.py8
-rw-r--r--components/style/gecko/snapshot.rs7
-rw-r--r--components/style/gecko/wrapper.rs18
-rw-r--r--components/style/gecko_bindings/sugar/ns_css_value.rs4
-rw-r--r--components/style/gecko_bindings/sugar/ns_t_array.rs2
-rw-r--r--components/style/gecko_bindings/sugar/ns_timing_function.rs2
-rw-r--r--components/style/gecko_string_cache/mod.rs4
-rw-r--r--components/style/properties/gecko.mako.rs36
10 files changed, 45 insertions, 60 deletions
diff --git a/components/style/context.rs b/components/style/context.rs
index 38af94f7584..a59058dea3d 100644
--- a/components/style/context.rs
+++ b/components/style/context.rs
@@ -488,11 +488,11 @@ impl<E: TElement> SequentialTask<E> {
Unused(_) => unreachable!(),
#[cfg(feature = "gecko")]
UpdateAnimations { el, before_change_style, tasks } => {
- unsafe { el.update_animations(before_change_style, tasks) };
+ el.update_animations(before_change_style, tasks);
}
#[cfg(feature = "gecko")]
PostAnimation { el, tasks } => {
- unsafe { el.process_post_animation(tasks) };
+ el.process_post_animation(tasks);
}
}
}
diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs
index 205a6ca0927..1ee90e2fecf 100644
--- a/components/style/gecko/media_queries.rs
+++ b/components/style/gecko/media_queries.rs
@@ -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.
diff --git a/components/style/gecko/regen_atoms.py b/components/style/gecko/regen_atoms.py
index d1e9280102b..36661215082 100755
--- a/components/style/gecko/regen_atoms.py
+++ b/components/style/gecko/regen_atoms.py
@@ -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]
diff --git a/components/style/gecko/snapshot.rs b/components/style/gecko/snapshot.rs
index f8368d2ae43..862f8ab545b 100644
--- a/components/style/gecko/snapshot.rs
+++ b/components/style/gecko/snapshot.rs
@@ -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() {
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index f25b93b8dec..3a7e09843d6 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -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
diff --git a/components/style/gecko_bindings/sugar/ns_css_value.rs b/components/style/gecko_bindings/sugar/ns_css_value.rs
index dca0ec98751..10bce100905 100644
--- a/components/style/gecko_bindings/sugar/ns_css_value.rs
+++ b/components/style/gecko_bindings/sugar/ns_css_value.rs
@@ -226,9 +226,7 @@ impl nsCSSValue {
/// Panics if the unit is not `eCSSUnit_Degree` `eCSSUnit_Grad`, `eCSSUnit_Turn`
/// or `eCSSUnit_Radian`.
pub fn get_angle(&self) -> Angle {
- unsafe {
- Angle::from_gecko_values(self.float_unchecked(), self.mUnit)
- }
+ Angle::from_gecko_values(self.float_unchecked(), self.mUnit)
}
/// Sets Angle value to this nsCSSValue.
diff --git a/components/style/gecko_bindings/sugar/ns_t_array.rs b/components/style/gecko_bindings/sugar/ns_t_array.rs
index 068e10ddea1..dadda32a300 100644
--- a/components/style/gecko_bindings/sugar/ns_t_array.rs
+++ b/components/style/gecko_bindings/sugar/ns_t_array.rs
@@ -99,7 +99,7 @@ impl<T> nsTArray<T> {
/// This will not leak since it only works on POD types (and thus doesn't assert)
pub unsafe fn set_len_pod(&mut self, len: u32) where T: Copy {
self.ensure_capacity(len as usize);
- let header = unsafe { self.header_mut() };
+ let header = self.header_mut();
header.mLength = len;
}
}
diff --git a/components/style/gecko_bindings/sugar/ns_timing_function.rs b/components/style/gecko_bindings/sugar/ns_timing_function.rs
index 04023e13d71..ea07af54b3f 100644
--- a/components/style/gecko_bindings/sugar/ns_timing_function.rs
+++ b/components/style/gecko_bindings/sugar/ns_timing_function.rs
@@ -35,7 +35,7 @@ impl nsTimingFunction {
self.mType = function_type;
unsafe {
let ref mut gecko_cubic_bezier =
- unsafe { self.__bindgen_anon_1.mFunc.as_mut() };
+ self.__bindgen_anon_1.mFunc.as_mut();
gecko_cubic_bezier.mX1 = x1;
gecko_cubic_bezier.mY1 = y1;
gecko_cubic_bezier.mX2 = x2;
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs
index f0474620052..9e2e4a53420 100644
--- a/components/style/gecko_string_cache/mod.rs
+++ b/components/style/gecko_string_cache/mod.rs
@@ -266,9 +266,7 @@ impl Atom {
#[inline]
pub unsafe fn from_addrefed(ptr: *mut nsAtom) -> Self {
assert!(!ptr.is_null());
- unsafe {
- Atom(WeakAtom::new(ptr))
- }
+ Atom(WeakAtom::new(ptr))
}
/// Convert this atom into an addrefed nsAtom pointer.
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 6cd1b509b06..b18b615bcc0 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -222,7 +222,7 @@ impl ComputedValuesInner {
pseudo_ty: structs::CSSPseudoElementType,
pseudo_tag: *mut structs::nsAtom
) -> Arc<ComputedValues> {
- let arc = unsafe {
+ let arc = {
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _,
parent, pres_context,
@@ -1215,7 +1215,7 @@ pub fn convert_transform(
set_single_transform_function(servo, gecko);
}
}
- unsafe { output.set_move(list) };
+ output.set_move(list);
}
fn clone_single_transform_function(
@@ -2280,7 +2280,7 @@ fn static_assert() {
gecko.assign_utf8(&*servo);
}
- unsafe { self.gecko.mGridTemplateAreas.set_move(refptr.get()) }
+ self.gecko.mGridTemplateAreas.set_move(refptr.get())
}
pub fn copy_grid_template_areas_from(&mut self, other: &Self) {
@@ -2944,7 +2944,7 @@ fn static_assert() {
<%def name="impl_copy_animation_or_transition_value(type, ident, gecko_ffi_name)">
#[allow(non_snake_case)]
pub fn copy_${type}_${ident}_from(&mut self, other: &Self) {
- unsafe { self.gecko.m${type.capitalize()}s.ensure_len(other.gecko.m${type.capitalize()}s.len()) };
+ self.gecko.m${type.capitalize()}s.ensure_len(other.gecko.m${type.capitalize()}s.len());
let count = other.gecko.m${type.capitalize()}${gecko_ffi_name}Count;
self.gecko.m${type.capitalize()}${gecko_ffi_name}Count = count;
@@ -2978,7 +2978,7 @@ fn static_assert() {
let v = v.into_iter();
debug_assert!(v.len() != 0);
let input_len = v.len();
- unsafe { self.gecko.m${type.capitalize()}s.ensure_len(input_len) };
+ self.gecko.m${type.capitalize()}s.ensure_len(input_len);
self.gecko.m${type.capitalize()}${gecko_ffi_name}Count = input_len as u32;
for (gecko, servo) in self.gecko.m${type.capitalize()}s.iter_mut().zip(v.cycle()) {
@@ -3003,7 +3003,7 @@ fn static_assert() {
let v = v.into_iter();
debug_assert!(v.len() != 0);
let input_len = v.len();
- unsafe { self.gecko.m${type.capitalize()}s.ensure_len(input_len) };
+ self.gecko.m${type.capitalize()}s.ensure_len(input_len);
self.gecko.m${type.capitalize()}TimingFunctionCount = input_len as u32;
for (gecko, servo) in self.gecko.m${type.capitalize()}s.iter_mut().zip(v.cycle()) {
@@ -3059,7 +3059,7 @@ fn static_assert() {
debug_assert!(v.len() != 0);
let input_len = v.len();
- unsafe { self.gecko.mAnimations.ensure_len(input_len) };
+ self.gecko.mAnimations.ensure_len(input_len);
self.gecko.mAnimation${gecko_ffi_name}Count = input_len as u32;
@@ -3309,7 +3309,7 @@ fn static_assert() {
let v = v.into_iter();
if v.len() != 0 {
- unsafe { self.gecko.mTransitions.ensure_len(v.len()) };
+ self.gecko.mTransitions.ensure_len(v.len());
self.gecko.mTransitionPropertyCount = v.len() as u32;
for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) {
match servo {
@@ -3365,7 +3365,7 @@ fn static_assert() {
pub fn copy_transition_property_from(&mut self, other: &Self) {
use gecko_bindings::structs::nsCSSPropertyID::eCSSPropertyExtra_variable;
use gecko_bindings::structs::nsCSSPropertyID::eCSSProperty_UNKNOWN;
- unsafe { self.gecko.mTransitions.ensure_len(other.gecko.mTransitions.len()) };
+ self.gecko.mTransitions.ensure_len(other.gecko.mTransitions.len());
let count = other.gecko.mTransitionPropertyCount;
self.gecko.mTransitionPropertyCount = count;
@@ -3397,7 +3397,7 @@ fn static_assert() {
{
let v = v.into_iter();
debug_assert!(v.len() != 0);
- unsafe { self.gecko.mAnimations.ensure_len(v.len()) };
+ self.gecko.mAnimations.ensure_len(v.len());
self.gecko.mAnimationNameCount = v.len() as u32;
for (servo, gecko) in v.zip(self.gecko.mAnimations.iter_mut()) {
@@ -3452,7 +3452,7 @@ fn static_assert() {
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
- unsafe { self.gecko.mAnimations.ensure_len(input_len) };
+ self.gecko.mAnimations.ensure_len(input_len);
self.gecko.mAnimationIterationCountCount = input_len as u32;
for (gecko, servo) in self.gecko.mAnimations.iter_mut().zip(v.cycle()) {
@@ -4002,11 +4002,9 @@ fn static_assert() {
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
unsafe {
let count = other.gecko.${image_layers_field}.mImageCount;
- unsafe {
- Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
- count as usize,
- LayerType::${shorthand.capitalize()});
- }
+ Gecko_EnsureImageLayersLength(&mut self.gecko.${image_layers_field},
+ count as usize,
+ LayerType::${shorthand.capitalize()});
for (layer, other) in self.gecko.${image_layers_field}.mLayers.iter_mut()
.zip(other.gecko.${image_layers_field}.mLayers.iter())
@@ -4204,7 +4202,7 @@ fn static_assert() {
gecko.second.assign_utf8(&servo.1);
}
- unsafe { self.gecko.mQuotes.set_move(refptr.get()) }
+ self.gecko.mQuotes.set_move(refptr.get())
}
pub fn copy_quotes_from(&mut self, other: &Self) {
@@ -5235,7 +5233,7 @@ clip-path
} else if servo.0 == atom!("stroke-opacity") {
self.gecko.mContextPropsBits |= structs::NS_STYLE_CONTEXT_PROPERTY_STROKE_OPACITY as u8;
}
- unsafe { gecko.mRawPtr = servo.0.into_addrefed() }
+ gecko.mRawPtr = servo.0.into_addrefed();
}
}
@@ -5655,7 +5653,7 @@ clip-path
eStyleContentType_Image => {
unsafe {
let gecko_image_request =
- unsafe { &**gecko_content.mContent.mImage.as_ref() };
+ &**gecko_content.mContent.mImage.as_ref();
ContentItem::Url(
SpecifiedUrl::from_image_request(gecko_image_request)
.expect("mContent could not convert to SpecifiedUrl")