Switch to NodeFlags (the footprint has not changed)

This commit is contained in:
Manish Goregaokar 2014-11-26 19:50:35 +05:30
parent b20d7d89c1
commit e7ac792ed6
3 changed files with 15 additions and 12 deletions

View file

@ -32,7 +32,7 @@ use dom::htmlcollection::HTMLCollection;
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers}; use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers};
use dom::htmlserializer::serialize; use dom::htmlserializer::serialize;
use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelpers}; use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelpers};
use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator, document_from_node}; use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator, document_from_node, CLICK_IN_PROGRESS};
use dom::node::{window_from_node, LayoutNodeHelpers}; use dom::node::{window_from_node, LayoutNodeHelpers};
use dom::nodelist::NodeList; use dom::nodelist::NodeList;
use dom::virtualmethods::{VirtualMethods, vtable_for}; use dom::virtualmethods::{VirtualMethods, vtable_for};
@ -44,7 +44,7 @@ use servo_util::namespace;
use servo_util::str::{DOMString, LengthOrPercentageOrAuto}; use servo_util::str::{DOMString, LengthOrPercentageOrAuto};
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::cell::{Cell, Ref, RefMut}; use std::cell::{Ref, RefMut};
use std::default::Default; use std::default::Default;
use std::mem; use std::mem;
use string_cache::{Atom, Namespace, QualName}; use string_cache::{Atom, Namespace, QualName};
@ -60,10 +60,6 @@ pub struct Element {
style_attribute: DOMRefCell<Option<style::PropertyDeclarationBlock>>, style_attribute: DOMRefCell<Option<style::PropertyDeclarationBlock>>,
attr_list: MutNullableJS<NamedNodeMap>, attr_list: MutNullableJS<NamedNodeMap>,
class_list: MutNullableJS<DOMTokenList>, class_list: MutNullableJS<DOMTokenList>,
// TODO: find a better place to keep this (#4105)
// https://critic.hoppipolla.co.uk/showcomment?chain=8873
// Perhaps using a Set in Document?
click_in_progress: Cell<bool>,
} }
impl ElementDerived for EventTarget { impl ElementDerived for EventTarget {
@ -182,7 +178,6 @@ impl Element {
attr_list: Default::default(), attr_list: Default::default(),
class_list: Default::default(), class_list: Default::default(),
style_attribute: DOMRefCell::new(None), style_attribute: DOMRefCell::new(None),
click_in_progress: Cell::new(false),
} }
} }
@ -1215,11 +1210,13 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
} }
fn click_in_progress(self) -> bool { fn click_in_progress(self) -> bool {
self.click_in_progress.get() let node: JSRef<Node> = NodeCast::from_ref(self);
node.get_flag(CLICK_IN_PROGRESS)
} }
fn set_click_in_progress(self, click: bool) { fn set_click_in_progress(self, click: bool) {
self.click_in_progress.set(click) let node: JSRef<Node> = NodeCast::from_ref(self);
node.set_flag(CLICK_IN_PROGRESS, click)
} }
// https://html.spec.whatwg.org/multipage/interaction.html#nearest-activatable-element // https://html.spec.whatwg.org/multipage/interaction.html#nearest-activatable-element

View file

@ -124,7 +124,7 @@ impl NodeDerived for EventTarget {
bitflags! { bitflags! {
#[doc = "Flags for node items."] #[doc = "Flags for node items."]
#[jstraceable] #[jstraceable]
flags NodeFlags: u8 { flags NodeFlags: u16 {
#[doc = "Specifies whether this node is in a document."] #[doc = "Specifies whether this node is in a document."]
const IS_IN_DOC = 0x01, const IS_IN_DOC = 0x01,
#[doc = "Specifies whether this node is in hover state."] #[doc = "Specifies whether this node is in hover state."]
@ -143,6 +143,12 @@ bitflags! {
#[doc = "Specifies whether this node has descendants (inclusive of itself) which \ #[doc = "Specifies whether this node has descendants (inclusive of itself) which \
have changed since the last reflow."] have changed since the last reflow."]
const HAS_DIRTY_DESCENDANTS = 0x80, const HAS_DIRTY_DESCENDANTS = 0x80,
// TODO: find a better place to keep this (#4105)
// https://critic.hoppipolla.co.uk/showcomment?chain=8873
// Perhaps using a Set in Document?
#[doc = "Specifies whether or not there is an authentic click in progress on \
this element."]
const CLICK_IN_PROGRESS = 0x100,
} }
} }