mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #18275 - Manishearth:coorddata-unsafe, r=nox
Mark the CoordData traits as unsafe r? @nox <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18275) <!-- Reviewable:end -->
This commit is contained in:
commit
bea11cadf9
1 changed files with 10 additions and 10 deletions
|
@ -20,7 +20,7 @@ impl nsStyleCoord {
|
|||
}
|
||||
}
|
||||
|
||||
impl CoordData for nsStyleCoord {
|
||||
unsafe impl CoordData for nsStyleCoord {
|
||||
#[inline]
|
||||
fn unit(&self) -> nsStyleUnit {
|
||||
unsafe {
|
||||
|
@ -35,7 +35,7 @@ impl CoordData for nsStyleCoord {
|
|||
}
|
||||
}
|
||||
|
||||
impl CoordDataMut for nsStyleCoord {
|
||||
unsafe impl CoordDataMut for nsStyleCoord {
|
||||
unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
|
||||
let unit = self.get_mUnit_mut() as *mut _;
|
||||
let value = self.get_mValue_mut() as *mut _;
|
||||
|
@ -98,7 +98,7 @@ pub struct SidesDataMut<'a> {
|
|||
index: usize,
|
||||
}
|
||||
|
||||
impl<'a> CoordData for SidesData<'a> {
|
||||
unsafe impl<'a> CoordData for SidesData<'a> {
|
||||
#[inline]
|
||||
fn unit(&self) -> nsStyleUnit {
|
||||
unsafe {
|
||||
|
@ -112,7 +112,7 @@ impl<'a> CoordData for SidesData<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl<'a> CoordData for SidesDataMut<'a> {
|
||||
unsafe impl<'a> CoordData for SidesDataMut<'a> {
|
||||
#[inline]
|
||||
fn unit(&self) -> nsStyleUnit {
|
||||
unsafe {
|
||||
|
@ -126,7 +126,7 @@ impl<'a> CoordData for SidesDataMut<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl<'a> CoordDataMut for SidesDataMut<'a> {
|
||||
unsafe impl<'a> CoordDataMut for SidesDataMut<'a> {
|
||||
unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
|
||||
let unit = &mut self.sides.get_mUnits_mut()[self.index] as *mut _;
|
||||
let value = &mut self.sides.get_mValues_mut()[self.index] as *mut _;
|
||||
|
@ -168,7 +168,7 @@ pub struct CornersDataMut<'a> {
|
|||
index: usize,
|
||||
}
|
||||
|
||||
impl<'a> CoordData for CornersData<'a> {
|
||||
unsafe impl<'a> CoordData for CornersData<'a> {
|
||||
fn unit(&self) -> nsStyleUnit {
|
||||
unsafe {
|
||||
self.corners.get_mUnits()[self.index]
|
||||
|
@ -180,7 +180,7 @@ impl<'a> CoordData for CornersData<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl<'a> CoordData for CornersDataMut<'a> {
|
||||
unsafe impl<'a> CoordData for CornersDataMut<'a> {
|
||||
fn unit(&self) -> nsStyleUnit {
|
||||
unsafe {
|
||||
self.corners.get_mUnits()[self.index]
|
||||
|
@ -192,7 +192,7 @@ impl<'a> CoordData for CornersDataMut<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl<'a> CoordDataMut for CornersDataMut<'a> {
|
||||
unsafe impl<'a> CoordDataMut for CornersDataMut<'a> {
|
||||
unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
|
||||
let unit = &mut self.corners.get_mUnits_mut()[self.index] as *mut _;
|
||||
let value = &mut self.corners.get_mValues_mut()[self.index] as *mut _;
|
||||
|
@ -240,7 +240,7 @@ pub enum CoordDataValue {
|
|||
|
||||
|
||||
/// A trait to abstract on top of a mutable `nsStyleCoord`-like object.
|
||||
pub trait CoordDataMut : CoordData {
|
||||
pub unsafe trait CoordDataMut : CoordData {
|
||||
/// Get mutably the unit and the union.
|
||||
///
|
||||
/// This is unsafe since it's possible to modify the unit without changing
|
||||
|
@ -394,7 +394,7 @@ pub trait CoordDataMut : CoordData {
|
|||
}
|
||||
}
|
||||
/// A trait to abstract on top of a `nsStyleCoord`-like object.
|
||||
pub trait CoordData {
|
||||
pub unsafe trait CoordData {
|
||||
/// Get the unit of this object.
|
||||
fn unit(&self) -> nsStyleUnit;
|
||||
/// Get the `nsStyleUnion` for this object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue