mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Move EventTargetTypeId/NodeTypeId to DOMClass
This commit is contained in:
parent
8d7ba12f28
commit
941f7dc04b
24 changed files with 149 additions and 74 deletions
|
@ -1430,6 +1430,8 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
Some(NodeTypeId::Document) => {
|
Some(NodeTypeId::Document) => {
|
||||||
(display::T::none, float::T::none, position::T::static_)
|
(display::T::none, float::T::none, position::T::static_)
|
||||||
}
|
}
|
||||||
|
Some(NodeTypeId::Node) => unreachable!(),
|
||||||
|
Some(NodeTypeId::CharacterData(CharacterDataTypeId::CharacterData)) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("building flow for node: {:?} {:?} {:?} {:?}", display, float, positioning, node.type_id());
|
debug!("building flow for node: {:?} {:?} {:?} {:?}", display, float, positioning, node.type_id());
|
||||||
|
@ -1585,6 +1587,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
||||||
Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
|
Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||||
HTMLElementTypeId::HTMLObjectElement))) => self.has_object_data(),
|
HTMLElementTypeId::HTMLObjectElement))) => self.has_object_data(),
|
||||||
Some(NodeTypeId::Element(_)) => false,
|
Some(NodeTypeId::Element(_)) => false,
|
||||||
|
Some(NodeTypeId::Node) => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1722,6 +1722,25 @@ class CGNamespace(CGWrapper):
|
||||||
return CGNamespace(namespaces[0], inner, public=public)
|
return CGNamespace(namespaces[0], inner, public=public)
|
||||||
|
|
||||||
|
|
||||||
|
def EventTargetEnum(desc):
|
||||||
|
protochain = desc.prototypeChain
|
||||||
|
if protochain[0] != "EventTarget":
|
||||||
|
return "None"
|
||||||
|
|
||||||
|
inner = ""
|
||||||
|
name = desc.interface.identifier.name
|
||||||
|
if desc.interface.getUserData("hasConcreteDescendant", False):
|
||||||
|
inner = "(::dom::%s::%sTypeId::%s)" % (name.lower(), name, name)
|
||||||
|
prev_proto = ""
|
||||||
|
for proto in reversed(protochain):
|
||||||
|
if prev_proto != "":
|
||||||
|
inner = "(::dom::%s::%sTypeId::%s%s)" % (proto.lower(), proto, prev_proto, inner)
|
||||||
|
prev_proto = proto
|
||||||
|
if inner == "":
|
||||||
|
return "None"
|
||||||
|
return "Some%s" % inner
|
||||||
|
|
||||||
|
|
||||||
def DOMClass(descriptor):
|
def DOMClass(descriptor):
|
||||||
protoList = ['PrototypeList::ID::' + proto for proto in descriptor.prototypeChain]
|
protoList = ['PrototypeList::ID::' + proto for proto in descriptor.prototypeChain]
|
||||||
# Pad out the list to the right length with ID::Count so we
|
# Pad out the list to the right length with ID::Count so we
|
||||||
|
@ -1734,7 +1753,8 @@ def DOMClass(descriptor):
|
||||||
DOMClass {
|
DOMClass {
|
||||||
interface_chain: [ %s ],
|
interface_chain: [ %s ],
|
||||||
native_hooks: &sNativePropertyHooks,
|
native_hooks: &sNativePropertyHooks,
|
||||||
}""" % prototypeChainString
|
type_id: %s,
|
||||||
|
}""" % (prototypeChainString, EventTargetEnum(descriptor))
|
||||||
|
|
||||||
|
|
||||||
class CGDOMJSClass(CGThing):
|
class CGDOMJSClass(CGThing):
|
||||||
|
|
|
@ -223,8 +223,9 @@ class Descriptor(DescriptorProvider):
|
||||||
if m.isDeleter():
|
if m.isDeleter():
|
||||||
addIndexedOrNamedOperation('Deleter', m)
|
addIndexedOrNamedOperation('Deleter', m)
|
||||||
|
|
||||||
iface.setUserData('hasConcreteDescendant', True)
|
|
||||||
iface = iface.parent
|
iface = iface.parent
|
||||||
|
if iface:
|
||||||
|
iface.setUserData('hasConcreteDescendant', True)
|
||||||
|
|
||||||
if self.proxy:
|
if self.proxy:
|
||||||
iface = self.interface
|
iface = self.interface
|
||||||
|
|
|
@ -645,7 +645,7 @@ pub unsafe fn native_from_reflector<T>(obj: *mut JSObject) -> *const T {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `DOMClass` from `obj`, or `Err(())` if `obj` is not a DOM object.
|
/// Get the `DOMClass` from `obj`, or `Err(())` if `obj` is not a DOM object.
|
||||||
unsafe fn get_dom_class(obj: *mut JSObject) -> Result<DOMClass, ()> {
|
pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<&'static DOMClass, ()> {
|
||||||
use dom::bindings::utils::DOMJSClass;
|
use dom::bindings::utils::DOMJSClass;
|
||||||
use js::glue::GetProxyHandlerExtra;
|
use js::glue::GetProxyHandlerExtra;
|
||||||
|
|
||||||
|
@ -653,12 +653,12 @@ unsafe fn get_dom_class(obj: *mut JSObject) -> Result<DOMClass, ()> {
|
||||||
if is_dom_class(&*clasp) {
|
if is_dom_class(&*clasp) {
|
||||||
debug!("plain old dom object");
|
debug!("plain old dom object");
|
||||||
let domjsclass: *const DOMJSClass = clasp as *const DOMJSClass;
|
let domjsclass: *const DOMJSClass = clasp as *const DOMJSClass;
|
||||||
return Ok((*domjsclass).dom_class);
|
return Ok(&(&*domjsclass).dom_class);
|
||||||
}
|
}
|
||||||
if is_dom_proxy(obj) {
|
if is_dom_proxy(obj) {
|
||||||
debug!("proxy dom object");
|
debug!("proxy dom object");
|
||||||
let dom_class: *const DOMClass = GetProxyHandlerExtra(obj) as *const DOMClass;
|
let dom_class: *const DOMClass = GetProxyHandlerExtra(obj) as *const DOMClass;
|
||||||
return Ok(*dom_class);
|
return Ok(&*dom_class);
|
||||||
}
|
}
|
||||||
debug!("not a dom object");
|
debug!("not a dom object");
|
||||||
Err(())
|
Err(())
|
||||||
|
|
|
@ -15,6 +15,7 @@ use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::trace::trace_object;
|
use dom::bindings::trace::trace_object;
|
||||||
use dom::browsercontext;
|
use dom::browsercontext;
|
||||||
|
use dom::eventtarget::EventTargetTypeId;
|
||||||
use dom::window;
|
use dom::window;
|
||||||
use util::mem::HeapSizeOf;
|
use util::mem::HeapSizeOf;
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
@ -157,6 +158,9 @@ pub struct DOMClass {
|
||||||
/// derivedness.
|
/// derivedness.
|
||||||
pub interface_chain: [PrototypeList::ID; MAX_PROTO_CHAIN_LENGTH],
|
pub interface_chain: [PrototypeList::ID; MAX_PROTO_CHAIN_LENGTH],
|
||||||
|
|
||||||
|
/// The EventTarget type, if this is derived from an EventTarget.
|
||||||
|
pub type_id: Option<EventTargetTypeId>,
|
||||||
|
|
||||||
/// The NativePropertyHooks for the interface associated with this class.
|
/// The NativePropertyHooks for the interface associated with this class.
|
||||||
pub native_hooks: &'static NativePropertyHooks,
|
pub native_hooks: &'static NativePropertyHooks,
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,8 +158,10 @@ impl CharacterDataMethods for CharacterData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The different types of CharacterData.
|
/// The different types of CharacterData.
|
||||||
#[derive(JSTraceable, Copy, Clone, PartialEq, Debug, HeapSizeOf)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
pub enum CharacterDataTypeId {
|
pub enum CharacterDataTypeId {
|
||||||
|
CharacterData,
|
||||||
|
|
||||||
Comment,
|
Comment,
|
||||||
Text,
|
Text,
|
||||||
ProcessingInstruction,
|
ProcessingInstruction,
|
||||||
|
|
|
@ -163,8 +163,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
-> DedicatedWorkerGlobalScope {
|
-> DedicatedWorkerGlobalScope {
|
||||||
DedicatedWorkerGlobalScope {
|
DedicatedWorkerGlobalScope {
|
||||||
workerglobalscope: WorkerGlobalScope::new_inherited(
|
workerglobalscope: WorkerGlobalScope::new_inherited(
|
||||||
WorkerGlobalScopeTypeId::DedicatedGlobalScope, init, worker_url,
|
init, worker_url, runtime, from_devtools_receiver),
|
||||||
runtime, from_devtools_receiver),
|
|
||||||
id: id,
|
id: id,
|
||||||
receiver: receiver,
|
receiver: receiver,
|
||||||
own_sender: own_sender,
|
own_sender: own_sender,
|
||||||
|
@ -364,7 +363,7 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
|
||||||
impl DedicatedWorkerGlobalScopeDerived for EventTarget {
|
impl DedicatedWorkerGlobalScopeDerived for EventTarget {
|
||||||
fn is_dedicatedworkerglobalscope(&self) -> bool {
|
fn is_dedicatedworkerglobalscope(&self) -> bool {
|
||||||
match *self.type_id() {
|
match *self.type_id() {
|
||||||
EventTargetTypeId::WorkerGlobalScope(WorkerGlobalScopeTypeId::DedicatedGlobalScope) => true,
|
EventTargetTypeId::WorkerGlobalScope(WorkerGlobalScopeTypeId::DedicatedWorkerGlobalScope) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl PartialEq for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable, Copy, Clone, PartialEq, Debug, HeapSizeOf)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
pub enum ElementTypeId {
|
pub enum ElementTypeId {
|
||||||
HTMLElement(HTMLElementTypeId),
|
HTMLElement(HTMLElementTypeId),
|
||||||
Element,
|
Element,
|
||||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
||||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||||
|
use dom::bindings::conversions::get_dom_class;
|
||||||
use dom::bindings::error::Error::InvalidState;
|
use dom::bindings::error::Error::InvalidState;
|
||||||
use dom::bindings::error::{Fallible, report_pending_exception};
|
use dom::bindings::error::{Fallible, report_pending_exception};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
|
@ -45,9 +46,10 @@ pub enum ListenerPhase {
|
||||||
Bubbling,
|
Bubbling,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable, Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[derive(HeapSizeOf)]
|
|
||||||
pub enum EventTargetTypeId {
|
pub enum EventTargetTypeId {
|
||||||
|
EventTarget,
|
||||||
|
|
||||||
Node(NodeTypeId),
|
Node(NodeTypeId),
|
||||||
WebSocket,
|
WebSocket,
|
||||||
Window,
|
Window,
|
||||||
|
@ -132,15 +134,13 @@ pub struct EventListenerEntry {
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct EventTarget {
|
pub struct EventTarget {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
type_id: EventTargetTypeId,
|
|
||||||
handlers: DOMRefCell<HashMap<DOMString, Vec<EventListenerEntry>, DefaultState<FnvHasher>>>,
|
handlers: DOMRefCell<HashMap<DOMString, Vec<EventListenerEntry>, DefaultState<FnvHasher>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventTarget {
|
impl EventTarget {
|
||||||
pub fn new_inherited(type_id: EventTargetTypeId) -> EventTarget {
|
pub fn new_inherited() -> EventTarget {
|
||||||
EventTarget {
|
EventTarget {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
type_id: type_id,
|
|
||||||
handlers: DOMRefCell::new(Default::default()),
|
handlers: DOMRefCell::new(Default::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,9 +159,12 @@ impl EventTarget {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[allow(unsafe_code)]
|
||||||
pub fn type_id(&self) -> &EventTargetTypeId {
|
pub fn type_id(&self) -> &EventTargetTypeId {
|
||||||
&self.type_id
|
let domclass = unsafe {
|
||||||
|
get_dom_class(self.reflector_.get_jsobject().get()).unwrap()
|
||||||
|
};
|
||||||
|
domclass.type_id.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_event_with_target(&self,
|
pub fn dispatch_event_with_target(&self,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use dom::bindings::utils::{reflect_dom_object, Reflectable};
|
||||||
use dom::blob::Blob;
|
use dom::blob::Blob;
|
||||||
use dom::domexception::{DOMException, DOMErrorName};
|
use dom::domexception::{DOMException, DOMErrorName};
|
||||||
use dom::event::{EventCancelable, EventBubbles};
|
use dom::event::{EventCancelable, EventBubbles};
|
||||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::progressevent::ProgressEvent;
|
use dom::progressevent::ProgressEvent;
|
||||||
use encoding::all::UTF_8;
|
use encoding::all::UTF_8;
|
||||||
use encoding::label::encoding_from_whatwg_label;
|
use encoding::label::encoding_from_whatwg_label;
|
||||||
|
@ -80,7 +80,7 @@ pub struct FileReader {
|
||||||
impl FileReader {
|
impl FileReader {
|
||||||
pub fn new_inherited(global: GlobalRef) -> FileReader {
|
pub fn new_inherited(global: GlobalRef) -> FileReader {
|
||||||
FileReader {
|
FileReader {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::FileReader),//?
|
eventtarget: EventTarget::new_inherited(),//?
|
||||||
global: GlobalField::from_rooted(&global),
|
global: GlobalField::from_rooted(&global),
|
||||||
ready_state: Cell::new(FileReaderReadyState::Empty),
|
ready_state: Cell::new(FileReaderReadyState::Empty),
|
||||||
error: MutNullableHeap::new(None),
|
error: MutNullableHeap::new(None),
|
||||||
|
|
|
@ -344,7 +344,7 @@ impl VirtualMethods for HTMLElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable, Copy, Clone, Debug, HeapSizeOf)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum HTMLElementTypeId {
|
pub enum HTMLElementTypeId {
|
||||||
HTMLElement,
|
HTMLElement,
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,10 @@ impl HTMLMediaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable, Copy, Clone, Debug, HeapSizeOf)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum HTMLMediaElementTypeId {
|
pub enum HTMLMediaElementTypeId {
|
||||||
|
HTMLMediaElement = -1,
|
||||||
|
|
||||||
HTMLAudioElement = 0,
|
HTMLAudioElement = 0,
|
||||||
HTMLVideoElement = 1,
|
HTMLVideoElement = 1,
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,10 @@ use std::cmp::max;
|
||||||
|
|
||||||
const DEFAULT_COLSPAN: u32 = 1;
|
const DEFAULT_COLSPAN: u32 = 1;
|
||||||
|
|
||||||
#[derive(JSTraceable, Copy, Clone, Debug, HeapSizeOf)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum HTMLTableCellElementTypeId {
|
pub enum HTMLTableCellElementTypeId {
|
||||||
|
HTMLTableCellElement = -1,
|
||||||
|
|
||||||
HTMLTableDataCellElement = 0,
|
HTMLTableDataCellElement = 0,
|
||||||
HTMLTableHeaderCellElement = 1,
|
HTMLTableHeaderCellElement = 1,
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,6 @@ pub struct Node {
|
||||||
/// The JavaScript reflector for this node.
|
/// The JavaScript reflector for this node.
|
||||||
eventtarget: EventTarget,
|
eventtarget: EventTarget,
|
||||||
|
|
||||||
/// The type of node that this is.
|
|
||||||
type_id: NodeTypeId,
|
|
||||||
|
|
||||||
/// The parent of this node.
|
/// The parent of this node.
|
||||||
parent_node: MutNullableHeap<JS<Node>>,
|
parent_node: MutNullableHeap<JS<Node>>,
|
||||||
|
|
||||||
|
@ -284,9 +281,10 @@ impl LayoutDataRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The different types of nodes.
|
/// The different types of nodes.
|
||||||
#[derive(JSTraceable, Copy, Clone, PartialEq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
#[derive(HeapSizeOf)]
|
|
||||||
pub enum NodeTypeId {
|
pub enum NodeTypeId {
|
||||||
|
Node,
|
||||||
|
|
||||||
CharacterData(CharacterDataTypeId),
|
CharacterData(CharacterDataTypeId),
|
||||||
DocumentType,
|
DocumentType,
|
||||||
DocumentFragment,
|
DocumentFragment,
|
||||||
|
@ -452,7 +450,7 @@ impl Node {
|
||||||
|
|
||||||
/// Returns a string that describes this node.
|
/// Returns a string that describes this node.
|
||||||
pub fn debug_str(&self) -> String {
|
pub fn debug_str(&self) -> String {
|
||||||
format!("{:?}", self.type_id)
|
format!("{:?}", self.type_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_in_doc(&self) -> bool {
|
pub fn is_in_doc(&self) -> bool {
|
||||||
|
@ -461,12 +459,15 @@ impl Node {
|
||||||
|
|
||||||
/// 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.
|
||||||
pub fn type_id(&self) -> NodeTypeId {
|
pub fn type_id(&self) -> NodeTypeId {
|
||||||
self.type_id
|
match *self.eventtarget.type_id() {
|
||||||
|
EventTargetTypeId::Node(type_id) => type_id,
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-node-length
|
// https://dom.spec.whatwg.org/#concept-node-length
|
||||||
pub fn len(&self) -> u32 {
|
pub fn len(&self) -> u32 {
|
||||||
match self.type_id {
|
match self.type_id() {
|
||||||
NodeTypeId::DocumentType => 0,
|
NodeTypeId::DocumentType => 0,
|
||||||
NodeTypeId::CharacterData(_) => {
|
NodeTypeId::CharacterData(_) => {
|
||||||
CharacterDataCast::to_ref(self).unwrap().Length()
|
CharacterDataCast::to_ref(self).unwrap().Length()
|
||||||
|
@ -486,12 +487,12 @@ impl Node {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_anchor_element(&self) -> bool {
|
pub fn is_anchor_element(&self) -> bool {
|
||||||
self.type_id == NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement))
|
self.type_id() == NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_doctype(&self) -> bool {
|
pub fn is_doctype(&self) -> bool {
|
||||||
self.type_id == NodeTypeId::DocumentType
|
self.type_id() == NodeTypeId::DocumentType
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_flag(&self, flag: NodeFlags) -> bool {
|
pub fn get_flag(&self, flag: NodeFlags) -> bool {
|
||||||
|
@ -1026,7 +1027,7 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
|
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
|
||||||
(*self.unsafe_get()).type_id
|
(*self.unsafe_get()).type_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1393,8 +1394,7 @@ impl Node {
|
||||||
|
|
||||||
fn new_(type_id: NodeTypeId, doc: Option<&Document>) -> Node {
|
fn new_(type_id: NodeTypeId, doc: Option<&Document>) -> Node {
|
||||||
Node {
|
Node {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Node(type_id)),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
type_id: type_id,
|
|
||||||
|
|
||||||
parent_node: Default::default(),
|
parent_node: Default::default(),
|
||||||
first_child: Default::default(),
|
first_child: Default::default(),
|
||||||
|
@ -1456,6 +1456,8 @@ impl Node {
|
||||||
|
|
||||||
// Step 4-5.
|
// Step 4-5.
|
||||||
match node.type_id() {
|
match node.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
|
NodeTypeId::CharacterData(CharacterDataTypeId::CharacterData) => unreachable!(),
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
||||||
if parent.is_document() {
|
if parent.is_document() {
|
||||||
return Err(HierarchyRequest);
|
return Err(HierarchyRequest);
|
||||||
|
@ -1538,7 +1540,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NodeTypeId::CharacterData(_) => (),
|
NodeTypeId::CharacterData(_) => (),
|
||||||
NodeTypeId::Document => unreachable!(),
|
NodeTypeId::Document | NodeTypeId::Node => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1698,6 +1700,8 @@ impl Node {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
// XXXabinader: clone() for each node as trait?
|
// XXXabinader: clone() for each node as trait?
|
||||||
let copy: Root<Node> = match node.type_id() {
|
let copy: Root<Node> = match node.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
|
NodeTypeId::CharacterData(CharacterDataTypeId::CharacterData) => unreachable!(),
|
||||||
NodeTypeId::DocumentType => {
|
NodeTypeId::DocumentType => {
|
||||||
let doctype: &DocumentType = DocumentTypeCast::to_ref(node).unwrap();
|
let doctype: &DocumentType = DocumentTypeCast::to_ref(node).unwrap();
|
||||||
let doctype = DocumentType::new(doctype.name().clone(),
|
let doctype = DocumentType::new(doctype.name().clone(),
|
||||||
|
@ -1833,7 +1837,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match node.type_id {
|
match node.type_id() {
|
||||||
NodeTypeId::Element(_) => {
|
NodeTypeId::Element(_) => {
|
||||||
let element = ElementCast::to_ref(node).unwrap();
|
let element = ElementCast::to_ref(node).unwrap();
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -1889,7 +1893,9 @@ impl Node {
|
||||||
impl NodeMethods for Node {
|
impl NodeMethods for Node {
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodetype
|
// https://dom.spec.whatwg.org/#dom-node-nodetype
|
||||||
fn NodeType(&self) -> u16 {
|
fn NodeType(&self) -> u16 {
|
||||||
match self.type_id {
|
match self.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
|
NodeTypeId::CharacterData(CharacterDataTypeId::CharacterData) => unreachable!(),
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) =>
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) =>
|
||||||
NodeConstants::TEXT_NODE,
|
NodeConstants::TEXT_NODE,
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) =>
|
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) =>
|
||||||
|
@ -1909,11 +1915,13 @@ impl NodeMethods for Node {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodename
|
// https://dom.spec.whatwg.org/#dom-node-nodename
|
||||||
fn NodeName(&self) -> DOMString {
|
fn NodeName(&self) -> DOMString {
|
||||||
match self.type_id {
|
match self.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
NodeTypeId::Element(..) => {
|
NodeTypeId::Element(..) => {
|
||||||
let elem: &Element = ElementCast::to_ref(self).unwrap();
|
let elem: &Element = ElementCast::to_ref(self).unwrap();
|
||||||
elem.TagName()
|
elem.TagName()
|
||||||
}
|
}
|
||||||
|
NodeTypeId::CharacterData(CharacterDataTypeId::CharacterData) => unreachable!(),
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => "#text".to_owned(),
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => "#text".to_owned(),
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
||||||
let processing_instruction: &ProcessingInstruction =
|
let processing_instruction: &ProcessingInstruction =
|
||||||
|
@ -1937,7 +1945,8 @@ impl NodeMethods for Node {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
// https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
||||||
fn GetOwnerDocument(&self) -> Option<Root<Document>> {
|
fn GetOwnerDocument(&self) -> Option<Root<Document>> {
|
||||||
match self.type_id {
|
match self.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
NodeTypeId::CharacterData(..) |
|
NodeTypeId::CharacterData(..) |
|
||||||
NodeTypeId::Element(..) |
|
NodeTypeId::Element(..) |
|
||||||
NodeTypeId::DocumentType |
|
NodeTypeId::DocumentType |
|
||||||
|
@ -1992,19 +2001,31 @@ impl NodeMethods for Node {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
fn GetNodeValue(&self) -> Option<DOMString> {
|
fn GetNodeValue(&self) -> Option<DOMString> {
|
||||||
CharacterDataCast::to_ref(self).map(|c| c.Data())
|
match self.type_id() {
|
||||||
|
NodeTypeId::CharacterData(..) => {
|
||||||
|
let chardata: &CharacterData = CharacterDataCast::to_ref(self).unwrap();
|
||||||
|
Some(chardata.Data())
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
fn SetNodeValue(&self, val: Option<DOMString>) {
|
fn SetNodeValue(&self, val: Option<DOMString>) {
|
||||||
if let NodeTypeId::CharacterData(..) = self.type_id {
|
match self.type_id() {
|
||||||
self.SetTextContent(val)
|
NodeTypeId::CharacterData(..) => {
|
||||||
|
self.SetTextContent(val)
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||||
fn GetTextContent(&self) -> Option<DOMString> {
|
fn GetTextContent(&self) -> Option<DOMString> {
|
||||||
match self.type_id {
|
match self.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
NodeTypeId::DocumentFragment |
|
NodeTypeId::DocumentFragment |
|
||||||
NodeTypeId::Element(..) => {
|
NodeTypeId::Element(..) => {
|
||||||
let content = Node::collect_text_contents(self.traverse_preorder());
|
let content = Node::collect_text_contents(self.traverse_preorder());
|
||||||
|
@ -2024,7 +2045,8 @@ impl NodeMethods for Node {
|
||||||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||||
fn SetTextContent(&self, value: Option<DOMString>) {
|
fn SetTextContent(&self, value: Option<DOMString>) {
|
||||||
let value = value.unwrap_or(String::new());
|
let value = value.unwrap_or(String::new());
|
||||||
match self.type_id {
|
match self.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
NodeTypeId::DocumentFragment |
|
NodeTypeId::DocumentFragment |
|
||||||
NodeTypeId::Element(..) => {
|
NodeTypeId::Element(..) => {
|
||||||
// Step 1-2.
|
// Step 1-2.
|
||||||
|
@ -2065,7 +2087,7 @@ impl NodeMethods for Node {
|
||||||
fn ReplaceChild(&self, node: &Node, child: &Node) -> Fallible<Root<Node>> {
|
fn ReplaceChild(&self, node: &Node, child: &Node) -> Fallible<Root<Node>> {
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
match self.type_id {
|
match self.type_id() {
|
||||||
NodeTypeId::Document |
|
NodeTypeId::Document |
|
||||||
NodeTypeId::DocumentFragment |
|
NodeTypeId::DocumentFragment |
|
||||||
NodeTypeId::Element(..) => (),
|
NodeTypeId::Element(..) => (),
|
||||||
|
@ -2084,6 +2106,7 @@ impl NodeMethods for Node {
|
||||||
|
|
||||||
// Step 4-5.
|
// Step 4-5.
|
||||||
match node.type_id() {
|
match node.type_id() {
|
||||||
|
NodeTypeId::Node => unreachable!(),
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) if self.is_document() =>
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) if self.is_document() =>
|
||||||
return Err(HierarchyRequest),
|
return Err(HierarchyRequest),
|
||||||
NodeTypeId::DocumentType if !self.is_document() => return Err(HierarchyRequest),
|
NodeTypeId::DocumentType if !self.is_document() => return Err(HierarchyRequest),
|
||||||
|
@ -2147,7 +2170,7 @@ impl NodeMethods for Node {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NodeTypeId::CharacterData(..) => (),
|
NodeTypeId::CharacterData(..) => (),
|
||||||
NodeTypeId::Document => unreachable!()
|
NodeTypeId::Document | NodeTypeId::Node => unreachable!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use dom::bindings::utils::{reflect_dom_object, Reflectable};
|
||||||
use dom::blob::Blob;
|
use dom::blob::Blob;
|
||||||
use dom::closeevent::CloseEvent;
|
use dom::closeevent::CloseEvent;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::messageevent::MessageEvent;
|
use dom::messageevent::MessageEvent;
|
||||||
use script_task::ScriptTaskEventCategory::WebSocketEvent;
|
use script_task::ScriptTaskEventCategory::WebSocketEvent;
|
||||||
use script_task::{Runnable, CommonScriptMsg};
|
use script_task::{Runnable, CommonScriptMsg};
|
||||||
|
@ -110,7 +110,7 @@ fn establish_a_websocket_connection(resource_url: &Url, net_url: (Host, String,
|
||||||
impl WebSocket {
|
impl WebSocket {
|
||||||
fn new_inherited(global: GlobalRef, url: Url) -> WebSocket {
|
fn new_inherited(global: GlobalRef, url: Url) -> WebSocket {
|
||||||
WebSocket {
|
WebSocket {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WebSocket),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
url: url,
|
url: url,
|
||||||
global: GlobalField::from_rooted(&global),
|
global: GlobalField::from_rooted(&global),
|
||||||
ready_state: Cell::new(WebSocketRequestState::Connecting),
|
ready_state: Cell::new(WebSocketRequestState::Connecting),
|
||||||
|
|
|
@ -1288,7 +1288,7 @@ impl Window {
|
||||||
};
|
};
|
||||||
|
|
||||||
let win = box Window {
|
let win = box Window {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Window),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
image_cache_chan: image_cache_chan,
|
image_cache_chan: image_cache_chan,
|
||||||
control_chan: control_chan,
|
control_chan: control_chan,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
||||||
use dom::dedicatedworkerglobalscope::{DedicatedWorkerGlobalScope, WorkerScriptMsg};
|
use dom::dedicatedworkerglobalscope::{DedicatedWorkerGlobalScope, WorkerScriptMsg};
|
||||||
use dom::errorevent::ErrorEvent;
|
use dom::errorevent::ErrorEvent;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::messageevent::MessageEvent;
|
use dom::messageevent::MessageEvent;
|
||||||
use dom::workerglobalscope::WorkerGlobalScopeInit;
|
use dom::workerglobalscope::WorkerGlobalScopeInit;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl Worker {
|
||||||
sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>)
|
sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>)
|
||||||
-> Worker {
|
-> Worker {
|
||||||
Worker {
|
Worker {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Worker),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
global: GlobalField::from_rooted(&global),
|
global: GlobalField::from_rooted(&global),
|
||||||
sender: sender,
|
sender: sender,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::js::{JS, Root, MutNullableHeap};
|
||||||
use dom::bindings::utils::Reflectable;
|
use dom::bindings::utils::Reflectable;
|
||||||
use dom::console::Console;
|
use dom::console::Console;
|
||||||
use dom::crypto::Crypto;
|
use dom::crypto::Crypto;
|
||||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::window::{base64_atob, base64_btoa};
|
use dom::window::{base64_atob, base64_btoa};
|
||||||
use dom::workerlocation::WorkerLocation;
|
use dom::workerlocation::WorkerLocation;
|
||||||
use dom::workernavigator::WorkerNavigator;
|
use dom::workernavigator::WorkerNavigator;
|
||||||
|
@ -36,9 +36,11 @@ use std::default::Default;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::Receiver;
|
use std::sync::mpsc::Receiver;
|
||||||
|
|
||||||
#[derive(JSTraceable, Copy, Clone, PartialEq, HeapSizeOf)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub enum WorkerGlobalScopeTypeId {
|
pub enum WorkerGlobalScopeTypeId {
|
||||||
DedicatedGlobalScope,
|
WorkerGlobalScope,
|
||||||
|
|
||||||
|
DedicatedWorkerGlobalScope,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WorkerGlobalScopeInit {
|
pub struct WorkerGlobalScopeInit {
|
||||||
|
@ -90,14 +92,13 @@ pub struct WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkerGlobalScope {
|
impl WorkerGlobalScope {
|
||||||
pub fn new_inherited(type_id: WorkerGlobalScopeTypeId,
|
pub fn new_inherited(init: WorkerGlobalScopeInit,
|
||||||
init: WorkerGlobalScopeInit,
|
|
||||||
worker_url: Url,
|
worker_url: Url,
|
||||||
runtime: Rc<Runtime>,
|
runtime: Rc<Runtime>,
|
||||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>)
|
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>)
|
||||||
-> WorkerGlobalScope {
|
-> WorkerGlobalScope {
|
||||||
WorkerGlobalScope {
|
WorkerGlobalScope {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WorkerGlobalScope(type_id)),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
next_worker_id: Cell::new(WorkerId(0)),
|
next_worker_id: Cell::new(WorkerId(0)),
|
||||||
worker_id: init.worker_id,
|
worker_id: init.worker_id,
|
||||||
worker_url: worker_url,
|
worker_url: worker_url,
|
||||||
|
|
|
@ -155,7 +155,7 @@ pub struct XMLHttpRequest {
|
||||||
impl XMLHttpRequest {
|
impl XMLHttpRequest {
|
||||||
fn new_inherited(global: GlobalRef) -> XMLHttpRequest {
|
fn new_inherited(global: GlobalRef) -> XMLHttpRequest {
|
||||||
XMLHttpRequest {
|
XMLHttpRequest {
|
||||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(XMLHttpRequestEventTargetTypeId::XMLHttpRequest),
|
eventtarget: XMLHttpRequestEventTarget::new_inherited(),
|
||||||
ready_state: Cell::new(XMLHttpRequestState::Unsent),
|
ready_state: Cell::new(XMLHttpRequestState::Unsent),
|
||||||
timeout: Cell::new(0u32),
|
timeout: Cell::new(0u32),
|
||||||
with_credentials: Cell::new(false),
|
with_credentials: Cell::new(false),
|
||||||
|
|
|
@ -8,8 +8,10 @@ use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
||||||
use dom::bindings::codegen::InheritTypes::XMLHttpRequestEventTargetDerived;
|
use dom::bindings::codegen::InheritTypes::XMLHttpRequestEventTargetDerived;
|
||||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||||
|
|
||||||
#[derive(JSTraceable, Copy, Clone, PartialEq, HeapSizeOf)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub enum XMLHttpRequestEventTargetTypeId {
|
pub enum XMLHttpRequestEventTargetTypeId {
|
||||||
|
XMLHttpRequestEventTarget,
|
||||||
|
|
||||||
XMLHttpRequest,
|
XMLHttpRequest,
|
||||||
XMLHttpRequestUpload,
|
XMLHttpRequestUpload,
|
||||||
}
|
}
|
||||||
|
@ -20,9 +22,9 @@ pub struct XMLHttpRequestEventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XMLHttpRequestEventTarget {
|
impl XMLHttpRequestEventTarget {
|
||||||
pub fn new_inherited(type_id: XMLHttpRequestEventTargetTypeId) -> XMLHttpRequestEventTarget {
|
pub fn new_inherited() -> XMLHttpRequestEventTarget {
|
||||||
XMLHttpRequestEventTarget {
|
XMLHttpRequestEventTarget {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::XMLHttpRequestEventTarget(type_id))
|
eventtarget: EventTarget::new_inherited()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@ pub struct XMLHttpRequestUpload {
|
||||||
impl XMLHttpRequestUpload {
|
impl XMLHttpRequestUpload {
|
||||||
fn new_inherited() -> XMLHttpRequestUpload {
|
fn new_inherited() -> XMLHttpRequestUpload {
|
||||||
XMLHttpRequestUpload {
|
XMLHttpRequestUpload {
|
||||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(
|
eventtarget: XMLHttpRequestEventTarget::new_inherited(),
|
||||||
XMLHttpRequestEventTargetTypeId::XMLHttpRequestUpload)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new(global: GlobalRef) -> Root<XMLHttpRequestUpload> {
|
pub fn new(global: GlobalRef) -> Root<XMLHttpRequestUpload> {
|
||||||
|
|
|
@ -8,8 +8,12 @@ use dom::bindings::codegen::InheritTypes::*;
|
||||||
use dom::element::ElementTypeId;
|
use dom::element::ElementTypeId;
|
||||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||||
use dom::htmlelement::HTMLElementTypeId;
|
use dom::htmlelement::HTMLElementTypeId;
|
||||||
use dom::htmlmediaelement::HTMLMediaElementTypeId::{HTMLAudioElement, HTMLVideoElement};
|
use dom::htmlmediaelement::HTMLMediaElementTypeId::HTMLAudioElement;
|
||||||
use dom::htmltablecellelement::HTMLTableCellElementTypeId::{HTMLTableDataCellElement, HTMLTableHeaderCellElement};
|
use dom::htmlmediaelement::HTMLMediaElementTypeId::HTMLMediaElement;
|
||||||
|
use dom::htmlmediaelement::HTMLMediaElementTypeId::HTMLVideoElement;
|
||||||
|
use dom::htmltablecellelement::HTMLTableCellElementTypeId::HTMLTableCellElement;
|
||||||
|
use dom::htmltablecellelement::HTMLTableCellElementTypeId::HTMLTableDataCellElement;
|
||||||
|
use dom::htmltablecellelement::HTMLTableCellElementTypeId::HTMLTableHeaderCellElement;
|
||||||
use dom::node::NodeTypeId;
|
use dom::node::NodeTypeId;
|
||||||
use libc;
|
use libc;
|
||||||
use util::mem::{HeapSizeOf, heap_size_of};
|
use util::mem::{HeapSizeOf, heap_size_of};
|
||||||
|
@ -245,5 +249,13 @@ pub fn heap_size_of_eventtarget(target: &EventTarget) -> usize {
|
||||||
heap_size_of_self_and_children(DocumentTypeCast::to_ref(target).unwrap()),
|
heap_size_of_self_and_children(DocumentTypeCast::to_ref(target).unwrap()),
|
||||||
&EventTargetTypeId::Node(NodeTypeId::DocumentFragment) =>
|
&EventTargetTypeId::Node(NodeTypeId::DocumentFragment) =>
|
||||||
heap_size_of_self_and_children(DocumentFragmentCast::to_ref(target).unwrap()),
|
heap_size_of_self_and_children(DocumentFragmentCast::to_ref(target).unwrap()),
|
||||||
|
&EventTargetTypeId::EventTarget |
|
||||||
|
&EventTargetTypeId::Node(NodeTypeId::Node) |
|
||||||
|
&EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||||
|
HTMLElementTypeId::HTMLMediaElement(HTMLMediaElement)))) |
|
||||||
|
&EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||||
|
HTMLElementTypeId::HTMLTableCellElement(HTMLTableCellElement)))) => {
|
||||||
|
unreachable!()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,8 @@ impl<'a> Serializable for &'a Node {
|
||||||
traversal_scope: TraversalScope) -> io::Result<()> {
|
traversal_scope: TraversalScope) -> io::Result<()> {
|
||||||
let node = *self;
|
let node = *self;
|
||||||
match (traversal_scope, node.type_id()) {
|
match (traversal_scope, node.type_id()) {
|
||||||
|
(_, NodeTypeId::Node) => unreachable!(),
|
||||||
|
(_, NodeTypeId::CharacterData(CharacterDataTypeId::CharacterData)) => unreachable!(),
|
||||||
(_, NodeTypeId::Element(..)) => {
|
(_, NodeTypeId::Element(..)) => {
|
||||||
let elem = ElementCast::to_ref(node).unwrap();
|
let elem = ElementCast::to_ref(node).unwrap();
|
||||||
let name = QualName::new(elem.namespace().clone(),
|
let name = QualName::new(elem.namespace().clone(),
|
||||||
|
|
|
@ -38,11 +38,11 @@ macro_rules! sizeof_checker (
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update the sizes here
|
// Update the sizes here
|
||||||
sizeof_checker!(size_event_target, EventTarget, 48);
|
sizeof_checker!(size_event_target, EventTarget, 40);
|
||||||
sizeof_checker!(size_node, Node, 184);
|
sizeof_checker!(size_node, Node, 168);
|
||||||
sizeof_checker!(size_element, Element, 296);
|
sizeof_checker!(size_element, Element, 280);
|
||||||
sizeof_checker!(size_htmlelement, HTMLElement, 312);
|
sizeof_checker!(size_htmlelement, HTMLElement, 296);
|
||||||
sizeof_checker!(size_div, HTMLDivElement, 312);
|
sizeof_checker!(size_div, HTMLDivElement, 296);
|
||||||
sizeof_checker!(size_span, HTMLSpanElement, 312);
|
sizeof_checker!(size_span, HTMLSpanElement, 296);
|
||||||
sizeof_checker!(size_text, Text, 216);
|
sizeof_checker!(size_text, Text, 200);
|
||||||
sizeof_checker!(size_characterdata, CharacterData, 216);
|
sizeof_checker!(size_characterdata, CharacterData, 200);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue