Skip to content
Permalink
Browse files

servo_arc cleanups for publishing.

  • Loading branch information
Manishearth authored and emilio committed Sep 18, 2018
1 parent 22da3c2 commit 84ca681a788bf730ba142be408239c6f5c92b2ba
Showing with 229 additions and 154 deletions.
  1. +8 −4 components/selectors/tree.rs
  2. +202 −140 components/servo_arc/lib.rs
  3. +9 −7 components/style/rule_tree/mod.rs
  4. +10 −3 components/style/sharing/mod.rs
@@ -8,18 +8,22 @@
use attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use matching::{ElementSelectorFlags, MatchingContext};
use parser::SelectorImpl;
use servo_arc::NonZeroPtrMut;
use std::fmt::Debug;
use std::ptr::NonNull;

/// Opaque representation of an Element, for identity comparisons. We use
/// NonZeroPtrMut to get the NonZero optimization.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct OpaqueElement(NonZeroPtrMut<()>);
pub struct OpaqueElement(NonNull<()>);

unsafe impl Send for OpaqueElement {}

impl OpaqueElement {
/// Creates a new OpaqueElement from an arbitrarily-typed pointer.
pub fn new<T>(ptr: *const T) -> Self {
OpaqueElement(NonZeroPtrMut::new(ptr as *const () as *mut ()))
pub fn new<T>(ptr: &T) -> Self {
unsafe {
OpaqueElement(NonNull::new_unchecked(ptr as *const T as *const () as *mut ()))
}
}
}

0 comments on commit 84ca681

Please sign in to comment.
You can’t perform that action at this time.