Skip to content
Permalink
Browse files

style: Add ToShmem impl for UrlExtraData.

  • Loading branch information...
heycam authored and emilio committed Mar 30, 2019
1 parent 41f6e67 commit 1f966535ac71bf64fe2d944edeeef854d72cda45
Showing with 22 additions and 1 deletion.
  1. +22 −1 components/style/stylesheets/mod.rs
@@ -37,8 +37,9 @@ use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
use servo_arc::Arc;
use std::fmt;
#[cfg(feature = "gecko")]
use std::mem;
use std::mem::{self, ManuallyDrop};
use style_traits::ParsingMode;
use to_shmem::{SharedMemoryBuilder, ToShmem};

pub use self::counter_style_rule::CounterStyleRule;
pub use self::document_rule::DocumentRule;
@@ -101,6 +102,26 @@ impl Drop for UrlExtraData {
}
}

#[cfg(feature = "gecko")]
impl ToShmem for UrlExtraData {
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> {
if self.0 & 1 == 0 {
let shared_extra_datas = unsafe { &structs::URLExtraData_sShared };
let self_ptr = self.as_ref() as *const _ as *mut _;
let sheet_id = shared_extra_datas
.iter()
.position(|r| r.mRawPtr == self_ptr)
.expect(
"ToShmem failed for UrlExtraData: expected sheet's URLExtraData to be in \
URLExtraData::sShared",
);
ManuallyDrop::new(UrlExtraData((sheet_id << 1) | 1))
} else {
ManuallyDrop::new(UrlExtraData(self.0))
}
}
}

#[cfg(feature = "gecko")]
impl UrlExtraData {
/// Create a new UrlExtraData wrapping a pointer to the specified Gecko

0 comments on commit 1f96653

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