Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stylo: Fuse ServoStyleContext and ServoComputedValues #17767

Merged
merged 16 commits into from Jul 18, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

stylo: Replace real ComputedValues with bindgenned ComputedValues2

  • Loading branch information
Manishearth committed Jul 18, 2017
commit 5d7874303793ddfe78217b83db343f7706c78ad2
@@ -771,11 +771,30 @@ impl<T: 'static> RawOffsetArc<T> {
// Forward the result.
result
}

/// If uniquely owned, provide a mutable reference
/// Else create a copy, and mutate that
pub fn make_mut(&mut self) -> &mut T where T: Clone {
unsafe {
// extract the RawOffsetArc as an owned variable
let this = ptr::read(self);
// treat it as a real Arc
let mut arc = Arc::from_raw_offset(this);
// obtain the mutable reference. Cast away the lifetime
// This may mutate `arc`
let ret = Arc::make_mut(&mut arc) as *mut _;
// Store the possibly-mutated arc back inside, after converting
// it to a RawOffsetArc again
ptr::write(self, Arc::into_raw_offset(arc));
&mut *ret
}
}
}

impl<T: 'static> Arc<T> {
/// Converts an Arc into a RawOffsetArc. This consumes the Arc, so the refcount
/// is not modified.
#[inline]
pub fn into_raw_offset(a: Self) -> RawOffsetArc<T> {
RawOffsetArc {
ptr: NonZeroPtrMut::new(Arc::into_raw(a) as *mut T),
@@ -784,6 +803,7 @@ impl<T: 'static> Arc<T> {

/// Converts a RawOffsetArc into an Arc. This consumes the RawOffsetArc, so the refcount
/// is not modified.
#[inline]
pub fn from_raw_offset(a: RawOffsetArc<T>) -> Self {
let ptr = a.ptr.ptr();
mem::forget(a);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.