mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove Traceable/Untraceable from node.rs
This commit is contained in:
parent
5c8a45d74e
commit
a8f96ddfb2
3 changed files with 27 additions and 25 deletions
|
@ -77,20 +77,20 @@ pub trait LayoutDataAccess {
|
||||||
impl<'ln> LayoutDataAccess for LayoutNode<'ln> {
|
impl<'ln> LayoutDataAccess for LayoutNode<'ln> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> {
|
unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> {
|
||||||
mem::transmute(self.get().layout_data.deref().borrow_unchecked())
|
mem::transmute(self.get().layout_data.borrow_unchecked())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.get().layout_data.deref().borrow())
|
mem::transmute(self.get().layout_data.borrow())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.get().layout_data.deref().borrow_mut())
|
mem::transmute(self.get().layout_data.borrow_mut())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -667,7 +667,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.get().layout_data.deref().borrow())
|
mem::transmute(self.get().layout_data.borrow())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.get().layout_data.deref().borrow_mut())
|
mem::transmute(self.get().layout_data.borrow_mut())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ use dom::bindings::global;
|
||||||
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, Root};
|
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, Root};
|
||||||
use dom::bindings::js::{OptionalSettable, TemporaryPushable, OptionalRootedRootable};
|
use dom::bindings::js::{OptionalSettable, TemporaryPushable, OptionalRootedRootable};
|
||||||
use dom::bindings::js::{ResultRootable, OptionalRootable, MutNullableJS};
|
use dom::bindings::js::{ResultRootable, OptionalRootable, MutNullableJS};
|
||||||
use dom::bindings::trace::{Traceable, Untraceable};
|
use dom::bindings::trace::JSTraceable;
|
||||||
use dom::bindings::utils;
|
use dom::bindings::utils;
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::characterdata::CharacterData;
|
use dom::characterdata::CharacterData;
|
||||||
|
@ -53,7 +53,7 @@ use servo_util::geometry::Au;
|
||||||
use servo_util::str::{DOMString, null_str_as_empty};
|
use servo_util::str::{DOMString, null_str_as_empty};
|
||||||
use style::{parse_selector_list_from_str, matches};
|
use style::{parse_selector_list_from_str, matches};
|
||||||
|
|
||||||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
use js::jsapi::{JSContext, JSObject, JSTracer, JSRuntime};
|
||||||
use js::jsfriendapi;
|
use js::jsfriendapi;
|
||||||
use libc;
|
use libc;
|
||||||
use libc::uintptr_t;
|
use libc::uintptr_t;
|
||||||
|
@ -102,13 +102,13 @@ pub struct Node {
|
||||||
child_list: MutNullableJS<NodeList>,
|
child_list: MutNullableJS<NodeList>,
|
||||||
|
|
||||||
/// A bitfield of flags for node items.
|
/// A bitfield of flags for node items.
|
||||||
flags: Traceable<RefCell<NodeFlags>>,
|
flags: RefCell<NodeFlags>,
|
||||||
|
|
||||||
/// Layout information. Only the layout task may touch this data.
|
/// Layout information. Only the layout task may touch this data.
|
||||||
///
|
///
|
||||||
/// Must be sent back to the layout task to be destroyed when this
|
/// Must be sent back to the layout task to be destroyed when this
|
||||||
/// node is finalized.
|
/// node is finalized.
|
||||||
pub layout_data: Untraceable<LayoutDataRef>,
|
pub layout_data: LayoutDataRef,
|
||||||
|
|
||||||
unique_id: RefCell<String>,
|
unique_id: RefCell<String>,
|
||||||
}
|
}
|
||||||
|
@ -189,6 +189,8 @@ pub struct LayoutDataRef {
|
||||||
pub data_cell: RefCell<Option<LayoutData>>,
|
pub data_cell: RefCell<Option<LayoutData>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
untraceable!(LayoutDataRef)
|
||||||
|
|
||||||
impl LayoutDataRef {
|
impl LayoutDataRef {
|
||||||
pub fn new() -> LayoutDataRef {
|
pub fn new() -> LayoutDataRef {
|
||||||
LayoutDataRef {
|
LayoutDataRef {
|
||||||
|
@ -453,7 +455,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_in_doc(self) -> bool {
|
fn is_in_doc(self) -> bool {
|
||||||
self.deref().flags.deref().borrow().contains(IsInDoc)
|
self.deref().flags.borrow().contains(IsInDoc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
|
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
|
||||||
|
@ -512,38 +514,38 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_hover_state(self) -> bool {
|
fn get_hover_state(self) -> bool {
|
||||||
self.flags.deref().borrow().contains(InHoverState)
|
self.flags.borrow().contains(InHoverState)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_hover_state(self, state: bool) {
|
fn set_hover_state(self, state: bool) {
|
||||||
if state {
|
if state {
|
||||||
self.flags.deref().borrow_mut().insert(InHoverState);
|
self.flags.borrow_mut().insert(InHoverState);
|
||||||
} else {
|
} else {
|
||||||
self.flags.deref().borrow_mut().remove(InHoverState);
|
self.flags.borrow_mut().remove(InHoverState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_disabled_state(self) -> bool {
|
fn get_disabled_state(self) -> bool {
|
||||||
self.flags.deref().borrow().contains(InDisabledState)
|
self.flags.borrow().contains(InDisabledState)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_disabled_state(self, state: bool) {
|
fn set_disabled_state(self, state: bool) {
|
||||||
if state {
|
if state {
|
||||||
self.flags.deref().borrow_mut().insert(InDisabledState);
|
self.flags.borrow_mut().insert(InDisabledState);
|
||||||
} else {
|
} else {
|
||||||
self.flags.deref().borrow_mut().remove(InDisabledState);
|
self.flags.borrow_mut().remove(InDisabledState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_enabled_state(self) -> bool {
|
fn get_enabled_state(self) -> bool {
|
||||||
self.flags.deref().borrow().contains(InEnabledState)
|
self.flags.borrow().contains(InEnabledState)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_enabled_state(self, state: bool) {
|
fn set_enabled_state(self, state: bool) {
|
||||||
if state {
|
if state {
|
||||||
self.flags.deref().borrow_mut().insert(InEnabledState);
|
self.flags.borrow_mut().insert(InEnabledState);
|
||||||
} else {
|
} else {
|
||||||
self.flags.deref().borrow_mut().remove(InEnabledState);
|
self.flags.borrow_mut().remove(InEnabledState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,9 +1036,9 @@ impl Node {
|
||||||
owner_doc: MutNullableJS::new(doc),
|
owner_doc: MutNullableJS::new(doc),
|
||||||
child_list: Default::default(),
|
child_list: Default::default(),
|
||||||
|
|
||||||
flags: Traceable::new(RefCell::new(NodeFlags::new(type_id))),
|
flags: RefCell::new(NodeFlags::new(type_id)),
|
||||||
|
|
||||||
layout_data: Untraceable::new(LayoutDataRef::new()),
|
layout_data: LayoutDataRef::new(),
|
||||||
|
|
||||||
unique_id: RefCell::new("".to_string()),
|
unique_id: RefCell::new("".to_string()),
|
||||||
}
|
}
|
||||||
|
@ -1236,9 +1238,9 @@ impl Node {
|
||||||
let is_in_doc = parent.is_in_doc();
|
let is_in_doc = parent.is_in_doc();
|
||||||
for kid in node.traverse_preorder() {
|
for kid in node.traverse_preorder() {
|
||||||
if is_in_doc {
|
if is_in_doc {
|
||||||
kid.flags.deref().borrow_mut().insert(IsInDoc);
|
kid.flags.borrow_mut().insert(IsInDoc);
|
||||||
} else {
|
} else {
|
||||||
kid.flags.deref().borrow_mut().remove(IsInDoc);
|
kid.flags.borrow_mut().remove(IsInDoc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1325,7 +1327,7 @@ impl Node {
|
||||||
// Step 8.
|
// Step 8.
|
||||||
parent.remove_child(node);
|
parent.remove_child(node);
|
||||||
|
|
||||||
node.deref().flags.deref().borrow_mut().remove(IsInDoc);
|
node.deref().flags.borrow_mut().remove(IsInDoc);
|
||||||
|
|
||||||
// Step 9.
|
// Step 9.
|
||||||
match suppress_observers {
|
match suppress_observers {
|
||||||
|
@ -1449,7 +1451,7 @@ impl Node {
|
||||||
/// Sends layout data, if any, back to the layout task to be destroyed.
|
/// Sends layout data, if any, back to the layout task to be destroyed.
|
||||||
unsafe fn reap_layout_data(&mut self) {
|
unsafe fn reap_layout_data(&mut self) {
|
||||||
if self.layout_data.is_present() {
|
if self.layout_data.is_present() {
|
||||||
let layout_data = mem::replace(self.layout_data.deref_mut(), LayoutDataRef::new());
|
let layout_data = mem::replace(&mut self.layout_data, LayoutDataRef::new());
|
||||||
let layout_chan = layout_data.take_chan();
|
let layout_chan = layout_data.take_chan();
|
||||||
match layout_chan {
|
match layout_chan {
|
||||||
None => {}
|
None => {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue