mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Use internal mutability for Node.flags.
This commit is contained in:
parent
bb0cbb0a74
commit
6df6a7d512
2 changed files with 18 additions and 19 deletions
|
@ -11,12 +11,13 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, TextCast, NodeCast, Elem
|
||||||
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, NodeBase, NodeDerived};
|
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, NodeBase, NodeDerived};
|
||||||
use dom::bindings::codegen::InheritTypes::{ProcessingInstructionCast, EventTargetCast};
|
use dom::bindings::codegen::InheritTypes::{ProcessingInstructionCast, EventTargetCast};
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeConstants;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeConstants;
|
||||||
|
use dom::bindings::error::{ErrorResult, Fallible, NotFound, HierarchyRequest, Syntax};
|
||||||
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, Root, OptionalUnrootable};
|
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, Root, OptionalUnrootable};
|
||||||
use dom::bindings::js::{OptionalSettable, TemporaryPushable, OptionalRootedRootable};
|
use dom::bindings::js::{OptionalSettable, TemporaryPushable, OptionalRootedRootable};
|
||||||
use dom::bindings::js::{ResultRootable, OptionalRootable};
|
use dom::bindings::js::{ResultRootable, OptionalRootable};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::trace::Untraceable;
|
||||||
use dom::bindings::error::{ErrorResult, Fallible, NotFound, HierarchyRequest, Syntax};
|
|
||||||
use dom::bindings::utils;
|
use dom::bindings::utils;
|
||||||
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::characterdata::{CharacterData, CharacterDataMethods};
|
use dom::characterdata::{CharacterData, CharacterDataMethods};
|
||||||
use dom::comment::Comment;
|
use dom::comment::Comment;
|
||||||
use dom::document::{Document, DocumentMethods, DocumentHelpers, HTMLDocument, NonHTMLDocument};
|
use dom::document::{Document, DocumentMethods, DocumentHelpers, HTMLDocument, NonHTMLDocument};
|
||||||
|
@ -86,7 +87,7 @@ pub struct Node {
|
||||||
pub child_list: Cell<Option<JS<NodeList>>>,
|
pub child_list: Cell<Option<JS<NodeList>>>,
|
||||||
|
|
||||||
/// A bitfield of flags for node items.
|
/// A bitfield of flags for node items.
|
||||||
flags: NodeFlags,
|
flags: Untraceable<RefCell<NodeFlags>>,
|
||||||
|
|
||||||
/// Layout information. Only the layout task may touch this data.
|
/// Layout information. Only the layout task may touch this data.
|
||||||
///
|
///
|
||||||
|
@ -382,7 +383,7 @@ pub trait NodeHelpers {
|
||||||
fn is_anchor_element(&self) -> bool;
|
fn is_anchor_element(&self) -> bool;
|
||||||
|
|
||||||
fn get_hover_state(&self) -> bool;
|
fn get_hover_state(&self) -> bool;
|
||||||
fn set_hover_state(&mut self, state: bool);
|
fn set_hover_state(&self, state: bool);
|
||||||
|
|
||||||
fn dump(&self);
|
fn dump(&self);
|
||||||
fn dump_indent(&self, indent: uint);
|
fn dump_indent(&self, indent: uint);
|
||||||
|
@ -430,7 +431,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_in_doc(&self) -> bool {
|
fn is_in_doc(&self) -> bool {
|
||||||
self.deref().flags.contains(IsInDoc)
|
self.deref().flags.deref().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.
|
||||||
|
@ -489,14 +490,14 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_hover_state(&self) -> bool {
|
fn get_hover_state(&self) -> bool {
|
||||||
self.flags.contains(InHoverState)
|
self.flags.deref().borrow().contains(InHoverState)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_hover_state(&mut self, state: bool) {
|
fn set_hover_state(&self, state: bool) {
|
||||||
if state {
|
if state {
|
||||||
self.flags.insert(InHoverState);
|
self.flags.deref().borrow_mut().insert(InHoverState);
|
||||||
} else {
|
} else {
|
||||||
self.flags.remove(InHoverState);
|
self.flags.deref().borrow_mut().remove(InHoverState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +707,7 @@ pub trait RawLayoutNodeHelpers {
|
||||||
|
|
||||||
impl RawLayoutNodeHelpers for Node {
|
impl RawLayoutNodeHelpers for Node {
|
||||||
unsafe fn get_hover_state_for_layout(&self) -> bool {
|
unsafe fn get_hover_state_for_layout(&self) -> bool {
|
||||||
self.flags.contains(InHoverState)
|
self.flags.deref().borrow().contains(InHoverState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +917,7 @@ impl Node {
|
||||||
owner_doc: Cell::new(doc.unrooted()),
|
owner_doc: Cell::new(doc.unrooted()),
|
||||||
child_list: Cell::new(None),
|
child_list: Cell::new(None),
|
||||||
|
|
||||||
flags: NodeFlags::new(type_id),
|
flags: Untraceable::new(RefCell::new(NodeFlags::new(type_id))),
|
||||||
|
|
||||||
layout_data: LayoutDataRef::new(),
|
layout_data: LayoutDataRef::new(),
|
||||||
}
|
}
|
||||||
|
@ -1110,9 +1111,9 @@ impl Node {
|
||||||
for node in nodes.mut_iter() {
|
for node in nodes.mut_iter() {
|
||||||
parent.add_child(node, child);
|
parent.add_child(node, child);
|
||||||
if parent.is_in_doc() {
|
if parent.is_in_doc() {
|
||||||
node.flags.insert(IsInDoc);
|
node.flags.deref().borrow_mut().insert(IsInDoc);
|
||||||
} else {
|
} else {
|
||||||
node.flags.remove(IsInDoc);
|
node.flags.deref().borrow_mut().remove(IsInDoc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1197,9 +1198,7 @@ impl Node {
|
||||||
// Step 8.
|
// Step 8.
|
||||||
parent.remove_child(node);
|
parent.remove_child(node);
|
||||||
|
|
||||||
// FIXME(2513): remove this `node_alias` when in fix mozilla#2513
|
node.deref().flags.deref().borrow_mut().remove(IsInDoc);
|
||||||
let mut node_alias = node.clone();
|
|
||||||
node_alias.deref_mut().flags.remove(IsInDoc);
|
|
||||||
|
|
||||||
// Step 9.
|
// Step 9.
|
||||||
match suppress_observers {
|
match suppress_observers {
|
||||||
|
|
|
@ -1161,8 +1161,8 @@ impl ScriptTask {
|
||||||
match *mouse_over_targets {
|
match *mouse_over_targets {
|
||||||
Some(ref mut mouse_over_targets) => {
|
Some(ref mut mouse_over_targets) => {
|
||||||
for node in mouse_over_targets.mut_iter() {
|
for node in mouse_over_targets.mut_iter() {
|
||||||
let mut node = node.root();
|
let node = node.root();
|
||||||
node.set_hover_state(false);
|
node.deref().set_hover_state(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
|
@ -1176,7 +1176,7 @@ impl ScriptTask {
|
||||||
|
|
||||||
let maybe_node = temp_node.root().ancestors().find(|node| node.is_element());
|
let maybe_node = temp_node.root().ancestors().find(|node| node.is_element());
|
||||||
match maybe_node {
|
match maybe_node {
|
||||||
Some(mut node) => {
|
Some(node) => {
|
||||||
node.set_hover_state(true);
|
node.set_hover_state(true);
|
||||||
|
|
||||||
match *mouse_over_targets {
|
match *mouse_over_targets {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue