mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Merge pull request #3418 from saneyuki/untrace
Replace manual Encodable implementation for LayoutDataRef with Untraceable
This commit is contained in:
commit
de67710934
8 changed files with 23 additions and 17 deletions
|
@ -77,20 +77,20 @@ pub trait LayoutDataAccess {
|
|||
impl<'ln> LayoutDataAccess for LayoutNode<'ln> {
|
||||
#[inline(always)]
|
||||
unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> {
|
||||
mem::transmute(self.get().layout_data.borrow_unchecked())
|
||||
mem::transmute(self.get().layout_data.deref().borrow_unchecked())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
||||
unsafe {
|
||||
mem::transmute(self.get().layout_data.borrow())
|
||||
mem::transmute(self.get().layout_data.deref().borrow())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
||||
unsafe {
|
||||
mem::transmute(self.get().layout_data.borrow_mut())
|
||||
mem::transmute(self.get().layout_data.deref().borrow_mut())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -646,7 +646,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
#[inline(always)]
|
||||
pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
||||
unsafe {
|
||||
mem::transmute(self.get().layout_data.borrow())
|
||||
mem::transmute(self.get().layout_data.deref().borrow())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
#[inline(always)]
|
||||
pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
||||
unsafe {
|
||||
mem::transmute(self.get().layout_data.borrow_mut())
|
||||
mem::transmute(self.get().layout_data.deref().borrow_mut())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,12 @@ impl<T> Deref<T> for Untraceable<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> DerefMut<T> for Untraceable<T> {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
|
||||
&mut self.inner
|
||||
}
|
||||
}
|
||||
|
||||
/// Encapsulates a type that can be traced but is boxed in a type we don't
|
||||
/// control (such as `RefCell`).
|
||||
///
|
||||
|
|
|
@ -41,7 +41,7 @@ impl CanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
pub fn recreate(&self, size: Size2D<i32>) {
|
||||
self.renderer.send(Recreate(size));
|
||||
self.renderer.deref().send(Recreate(size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,17 +52,17 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
|||
|
||||
fn FillRect(&self, x: f64, y: f64, width: f64, height: f64) {
|
||||
let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32));
|
||||
self.renderer.send(FillRect(rect));
|
||||
self.renderer.deref().send(FillRect(rect));
|
||||
}
|
||||
|
||||
fn ClearRect(&self, x: f64, y: f64, width: f64, height: f64) {
|
||||
let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32));
|
||||
self.renderer.send(ClearRect(rect));
|
||||
self.renderer.deref().send(ClearRect(rect));
|
||||
}
|
||||
|
||||
fn StrokeRect(&self, x: f64, y: f64, width: f64, height: f64) {
|
||||
let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32));
|
||||
self.renderer.send(StrokeRect(rect));
|
||||
self.renderer.deref().send(StrokeRect(rect));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
let target: JSRef<EventTarget> =
|
||||
EventTargetCast::from_ref(*global);
|
||||
loop {
|
||||
match global.receiver.recv_opt() {
|
||||
match global.receiver.deref().recv_opt() {
|
||||
Ok(DOMMessage(data, nbytes)) => {
|
||||
let mut message = UndefinedValue();
|
||||
unsafe {
|
||||
|
|
|
@ -24,7 +24,7 @@ use dom::bindings::global::{GlobalRef, Window};
|
|||
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, Root, OptionalUnrootable};
|
||||
use dom::bindings::js::{OptionalSettable, TemporaryPushable, OptionalRootedRootable};
|
||||
use dom::bindings::js::{ResultRootable, OptionalRootable};
|
||||
use dom::bindings::trace::Traceable;
|
||||
use dom::bindings::trace::{Traceable, Untraceable};
|
||||
use dom::bindings::utils;
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::characterdata::CharacterData;
|
||||
|
@ -108,7 +108,7 @@ pub struct Node {
|
|||
///
|
||||
/// Must be sent back to the layout task to be destroyed when this
|
||||
/// node is finalized.
|
||||
pub layout_data: LayoutDataRef,
|
||||
pub layout_data: Untraceable<LayoutDataRef>,
|
||||
|
||||
unique_id: RefCell<String>,
|
||||
}
|
||||
|
@ -1041,7 +1041,7 @@ impl Node {
|
|||
|
||||
flags: Traceable::new(RefCell::new(NodeFlags::new(type_id))),
|
||||
|
||||
layout_data: LayoutDataRef::new(),
|
||||
layout_data: Untraceable::new(LayoutDataRef::new()),
|
||||
|
||||
unique_id: RefCell::new("".to_string()),
|
||||
}
|
||||
|
@ -1454,7 +1454,7 @@ impl Node {
|
|||
/// Sends layout data, if any, back to the layout task to be destroyed.
|
||||
unsafe fn reap_layout_data(&mut self) {
|
||||
if self.layout_data.is_present() {
|
||||
let layout_data = mem::replace(&mut self.layout_data, LayoutDataRef::new());
|
||||
let layout_data = mem::replace(self.layout_data.deref_mut(), LayoutDataRef::new());
|
||||
let layout_chan = layout_data.take_chan();
|
||||
match layout_chan {
|
||||
None => {}
|
||||
|
|
|
@ -85,7 +85,7 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> {
|
|||
|
||||
fn Location(&self) -> Temporary<WorkerLocation> {
|
||||
if self.location.get().is_none() {
|
||||
let location = WorkerLocation::new(*self, self.worker_url.clone());
|
||||
let location = WorkerLocation::new(*self, self.worker_url.deref().clone());
|
||||
self.location.assign(Some(location));
|
||||
}
|
||||
Temporary::new(self.location.get().get_ref().clone())
|
||||
|
@ -110,7 +110,7 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> {
|
|||
}
|
||||
};
|
||||
|
||||
match self.js_context.evaluate_script(
|
||||
match self.js_context.deref().evaluate_script(
|
||||
self.reflector().get_jsobject(), source, url.serialize(), 1) {
|
||||
Ok(_) => (),
|
||||
Err(_) => {
|
||||
|
|
|
@ -38,7 +38,7 @@ impl WorkerLocation {
|
|||
|
||||
impl<'a> WorkerLocationMethods for JSRef<'a, WorkerLocation> {
|
||||
fn Href(&self) -> DOMString {
|
||||
self.url.serialize()
|
||||
self.url.deref().serialize()
|
||||
}
|
||||
|
||||
fn Search(&self) -> DOMString {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue