mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #7606 - nox:move-typeid, r=jdm
Move the type_id fields to DOMClass Cc @michaelwu. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7606) <!-- Reviewable:end -->
This commit is contained in:
commit
d5ee58caf2
32 changed files with 130 additions and 77 deletions
|
@ -1722,6 +1722,25 @@ class CGNamespace(CGWrapper):
|
|||
return CGNamespace(namespaces[0], inner, public=public)
|
||||
|
||||
|
||||
def EventTargetEnum(desc):
|
||||
protochain = desc.prototypeChain
|
||||
if protochain[0] != "EventTarget" or desc.interface.getExtendedAttribute("Abstract"):
|
||||
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):
|
||||
protoList = ['PrototypeList::ID::' + proto for proto in descriptor.prototypeChain]
|
||||
# Pad out the list to the right length with ID::Count so we
|
||||
|
@ -1734,7 +1753,8 @@ def DOMClass(descriptor):
|
|||
DOMClass {
|
||||
interface_chain: [ %s ],
|
||||
native_hooks: &sNativePropertyHooks,
|
||||
}""" % prototypeChainString
|
||||
type_id: %s,
|
||||
}""" % (prototypeChainString, EventTargetEnum(descriptor))
|
||||
|
||||
|
||||
class CGDOMJSClass(CGThing):
|
||||
|
|
|
@ -223,8 +223,9 @@ class Descriptor(DescriptorProvider):
|
|||
if m.isDeleter():
|
||||
addIndexedOrNamedOperation('Deleter', m)
|
||||
|
||||
iface.setUserData('hasConcreteDescendant', True)
|
||||
iface = iface.parent
|
||||
if iface:
|
||||
iface.setUserData('hasConcreteDescendant', True)
|
||||
|
||||
if self.proxy:
|
||||
iface = self.interface
|
||||
|
|
|
@ -1357,7 +1357,8 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
|
|||
identifier == "ChromeOnly" or
|
||||
identifier == "Unforgeable" or
|
||||
identifier == "UnsafeInPrerendering" or
|
||||
identifier == "LegacyEventInit"):
|
||||
identifier == "LegacyEventInit" or
|
||||
identifier == "Abstract"):
|
||||
# Known extended attributes that do not take values
|
||||
if not attr.noArguments():
|
||||
raise WebIDLError("[%s] must take no arguments" % identifier,
|
||||
|
|
12
components/script/dom/bindings/codegen/parser/abstract.patch
Normal file
12
components/script/dom/bindings/codegen/parser/abstract.patch
Normal file
|
@ -0,0 +1,12 @@
|
|||
--- WebIDL.py
|
||||
+++ WebIDL.py
|
||||
@@ -1357,7 +1357,8 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
|
||||
identifier == "ChromeOnly" or
|
||||
identifier == "Unforgeable" or
|
||||
identifier == "UnsafeInPrerendering" or
|
||||
- identifier == "LegacyEventInit"):
|
||||
+ identifier == "LegacyEventInit" or
|
||||
+ identifier == "Abstract"):
|
||||
# Known extended attributes that do not take values
|
||||
if not attr.noArguments():
|
||||
raise WebIDLError("[%s] must take no arguments" % identifier,
|
|
@ -1,3 +1,4 @@
|
|||
wget https://mxr.mozilla.org/mozilla-central/source/dom/bindings/parser/WebIDL.py?raw=1 -O WebIDL.py
|
||||
patch < external.patch
|
||||
patch < module.patch
|
||||
patch < abstract.patch
|
||||
|
|
|
@ -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.
|
||||
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 js::glue::GetProxyHandlerExtra;
|
||||
|
||||
|
@ -653,12 +653,12 @@ unsafe fn get_dom_class(obj: *mut JSObject) -> Result<DOMClass, ()> {
|
|||
if is_dom_class(&*clasp) {
|
||||
debug!("plain old dom object");
|
||||
let domjsclass: *const DOMJSClass = clasp as *const DOMJSClass;
|
||||
return Ok((*domjsclass).dom_class);
|
||||
return Ok(&(&*domjsclass).dom_class);
|
||||
}
|
||||
if is_dom_proxy(obj) {
|
||||
debug!("proxy dom object");
|
||||
let dom_class: *const DOMClass = GetProxyHandlerExtra(obj) as *const DOMClass;
|
||||
return Ok(*dom_class);
|
||||
return Ok(&*dom_class);
|
||||
}
|
||||
debug!("not a dom object");
|
||||
Err(())
|
||||
|
|
|
@ -15,6 +15,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::trace::trace_object;
|
||||
use dom::browsercontext;
|
||||
use dom::eventtarget::EventTargetTypeId;
|
||||
use dom::window;
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::str::DOMString;
|
||||
|
@ -157,6 +158,9 @@ pub struct DOMClass {
|
|||
/// derivedness.
|
||||
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.
|
||||
pub native_hooks: &'static NativePropertyHooks,
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ impl CharacterDataMethods for CharacterData {
|
|||
}
|
||||
|
||||
/// The different types of CharacterData.
|
||||
#[derive(JSTraceable, Copy, Clone, PartialEq, Debug, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum CharacterDataTypeId {
|
||||
Comment,
|
||||
Text,
|
||||
|
|
|
@ -163,8 +163,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
-> DedicatedWorkerGlobalScope {
|
||||
DedicatedWorkerGlobalScope {
|
||||
workerglobalscope: WorkerGlobalScope::new_inherited(
|
||||
WorkerGlobalScopeTypeId::DedicatedGlobalScope, init, worker_url,
|
||||
runtime, from_devtools_receiver),
|
||||
init, worker_url, runtime, from_devtools_receiver),
|
||||
id: id,
|
||||
receiver: receiver,
|
||||
own_sender: own_sender,
|
||||
|
@ -364,7 +363,7 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
|
|||
impl DedicatedWorkerGlobalScopeDerived for EventTarget {
|
||||
fn is_dedicatedworkerglobalscope(&self) -> bool {
|
||||
match *self.type_id() {
|
||||
EventTargetTypeId::WorkerGlobalScope(WorkerGlobalScopeTypeId::DedicatedGlobalScope) => true,
|
||||
EventTargetTypeId::WorkerGlobalScope(WorkerGlobalScopeTypeId::DedicatedWorkerGlobalScope) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ impl PartialEq for Element {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(JSTraceable, Copy, Clone, PartialEq, Debug, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum ElementTypeId {
|
||||
HTMLElement(HTMLElementTypeId),
|
||||
Element,
|
||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||
use dom::bindings::conversions::get_dom_class;
|
||||
use dom::bindings::error::Error::InvalidState;
|
||||
use dom::bindings::error::{Fallible, report_pending_exception};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
|
@ -45,8 +46,7 @@ pub enum ListenerPhase {
|
|||
Bubbling,
|
||||
}
|
||||
|
||||
#[derive(JSTraceable, Copy, Clone)]
|
||||
#[derive(HeapSizeOf)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum EventTargetTypeId {
|
||||
Node(NodeTypeId),
|
||||
WebSocket,
|
||||
|
@ -132,15 +132,13 @@ pub struct EventListenerEntry {
|
|||
#[dom_struct]
|
||||
pub struct EventTarget {
|
||||
reflector_: Reflector,
|
||||
type_id: EventTargetTypeId,
|
||||
handlers: DOMRefCell<HashMap<DOMString, Vec<EventListenerEntry>, DefaultState<FnvHasher>>>,
|
||||
}
|
||||
|
||||
impl EventTarget {
|
||||
pub fn new_inherited(type_id: EventTargetTypeId) -> EventTarget {
|
||||
pub fn new_inherited() -> EventTarget {
|
||||
EventTarget {
|
||||
reflector_: Reflector::new(),
|
||||
type_id: type_id,
|
||||
handlers: DOMRefCell::new(Default::default()),
|
||||
}
|
||||
}
|
||||
|
@ -159,9 +157,12 @@ impl EventTarget {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
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,
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::bindings::utils::{reflect_dom_object, Reflectable};
|
|||
use dom::blob::Blob;
|
||||
use dom::domexception::{DOMException, DOMErrorName};
|
||||
use dom::event::{EventCancelable, EventBubbles};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::progressevent::ProgressEvent;
|
||||
use encoding::all::UTF_8;
|
||||
use encoding::label::encoding_from_whatwg_label;
|
||||
|
@ -80,7 +80,7 @@ pub struct FileReader {
|
|||
impl FileReader {
|
||||
pub fn new_inherited(global: GlobalRef) -> FileReader {
|
||||
FileReader {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::FileReader),//?
|
||||
eventtarget: EventTarget::new_inherited(),//?
|
||||
global: GlobalField::from_rooted(&global),
|
||||
ready_state: Cell::new(FileReaderReadyState::Empty),
|
||||
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 {
|
||||
HTMLElement,
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(JSTraceable, Copy, Clone, Debug, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum HTMLMediaElementTypeId {
|
||||
HTMLAudioElement = 0,
|
||||
HTMLVideoElement = 1,
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::cmp::max;
|
|||
|
||||
const DEFAULT_COLSPAN: u32 = 1;
|
||||
|
||||
#[derive(JSTraceable, Copy, Clone, Debug, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum HTMLTableCellElementTypeId {
|
||||
HTMLTableDataCellElement = 0,
|
||||
HTMLTableHeaderCellElement = 1,
|
||||
|
|
|
@ -81,9 +81,6 @@ pub struct Node {
|
|||
/// The JavaScript reflector for this node.
|
||||
eventtarget: EventTarget,
|
||||
|
||||
/// The type of node that this is.
|
||||
type_id: NodeTypeId,
|
||||
|
||||
/// The parent of this node.
|
||||
parent_node: MutNullableHeap<JS<Node>>,
|
||||
|
||||
|
@ -284,8 +281,7 @@ impl LayoutDataRef {
|
|||
}
|
||||
|
||||
/// The different types of nodes.
|
||||
#[derive(JSTraceable, Copy, Clone, PartialEq, Debug)]
|
||||
#[derive(HeapSizeOf)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum NodeTypeId {
|
||||
CharacterData(CharacterDataTypeId),
|
||||
DocumentType,
|
||||
|
@ -452,7 +448,7 @@ impl Node {
|
|||
|
||||
/// Returns a string that describes this node.
|
||||
pub fn debug_str(&self) -> String {
|
||||
format!("{:?}", self.type_id)
|
||||
format!("{:?}", self.type_id())
|
||||
}
|
||||
|
||||
pub fn is_in_doc(&self) -> bool {
|
||||
|
@ -461,12 +457,15 @@ impl Node {
|
|||
|
||||
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
|
||||
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
|
||||
pub fn len(&self) -> u32 {
|
||||
match self.type_id {
|
||||
match self.type_id() {
|
||||
NodeTypeId::DocumentType => 0,
|
||||
NodeTypeId::CharacterData(_) => {
|
||||
CharacterDataCast::to_ref(self).unwrap().Length()
|
||||
|
@ -486,12 +485,12 @@ impl Node {
|
|||
|
||||
#[inline]
|
||||
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]
|
||||
pub fn is_doctype(&self) -> bool {
|
||||
self.type_id == NodeTypeId::DocumentType
|
||||
self.type_id() == NodeTypeId::DocumentType
|
||||
}
|
||||
|
||||
pub fn get_flag(&self, flag: NodeFlags) -> bool {
|
||||
|
@ -1026,7 +1025,7 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
|
|||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
|
||||
(*self.unsafe_get()).type_id
|
||||
(*self.unsafe_get()).type_id()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -1393,8 +1392,7 @@ impl Node {
|
|||
|
||||
fn new_(type_id: NodeTypeId, doc: Option<&Document>) -> Node {
|
||||
Node {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Node(type_id)),
|
||||
type_id: type_id,
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
|
||||
parent_node: Default::default(),
|
||||
first_child: Default::default(),
|
||||
|
@ -1833,7 +1831,7 @@ impl Node {
|
|||
}
|
||||
}
|
||||
|
||||
match node.type_id {
|
||||
match node.type_id() {
|
||||
NodeTypeId::Element(_) => {
|
||||
let element = ElementCast::to_ref(node).unwrap();
|
||||
// Step 1.
|
||||
|
@ -1889,7 +1887,7 @@ impl Node {
|
|||
impl NodeMethods for Node {
|
||||
// https://dom.spec.whatwg.org/#dom-node-nodetype
|
||||
fn NodeType(&self) -> u16 {
|
||||
match self.type_id {
|
||||
match self.type_id() {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) =>
|
||||
NodeConstants::TEXT_NODE,
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) =>
|
||||
|
@ -1909,7 +1907,7 @@ impl NodeMethods for Node {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-node-nodename
|
||||
fn NodeName(&self) -> DOMString {
|
||||
match self.type_id {
|
||||
match self.type_id() {
|
||||
NodeTypeId::Element(..) => {
|
||||
let elem: &Element = ElementCast::to_ref(self).unwrap();
|
||||
elem.TagName()
|
||||
|
@ -1937,7 +1935,7 @@ impl NodeMethods for Node {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
||||
fn GetOwnerDocument(&self) -> Option<Root<Document>> {
|
||||
match self.type_id {
|
||||
match self.type_id() {
|
||||
NodeTypeId::CharacterData(..) |
|
||||
NodeTypeId::Element(..) |
|
||||
NodeTypeId::DocumentType |
|
||||
|
@ -1992,19 +1990,30 @@ impl NodeMethods for Node {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||
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
|
||||
fn SetNodeValue(&self, val: Option<DOMString>) {
|
||||
if let NodeTypeId::CharacterData(..) = self.type_id {
|
||||
self.SetTextContent(val)
|
||||
match self.type_id() {
|
||||
NodeTypeId::CharacterData(..) => {
|
||||
self.SetTextContent(val)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||
fn GetTextContent(&self) -> Option<DOMString> {
|
||||
match self.type_id {
|
||||
match self.type_id() {
|
||||
NodeTypeId::DocumentFragment |
|
||||
NodeTypeId::Element(..) => {
|
||||
let content = Node::collect_text_contents(self.traverse_preorder());
|
||||
|
@ -2024,7 +2033,7 @@ impl NodeMethods for Node {
|
|||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||
fn SetTextContent(&self, value: Option<DOMString>) {
|
||||
let value = value.unwrap_or(String::new());
|
||||
match self.type_id {
|
||||
match self.type_id() {
|
||||
NodeTypeId::DocumentFragment |
|
||||
NodeTypeId::Element(..) => {
|
||||
// Step 1-2.
|
||||
|
@ -2065,7 +2074,7 @@ impl NodeMethods for Node {
|
|||
fn ReplaceChild(&self, node: &Node, child: &Node) -> Fallible<Root<Node>> {
|
||||
|
||||
// Step 1.
|
||||
match self.type_id {
|
||||
match self.type_id() {
|
||||
NodeTypeId::Document |
|
||||
NodeTypeId::DocumentFragment |
|
||||
NodeTypeId::Element(..) => (),
|
||||
|
@ -2147,7 +2156,7 @@ impl NodeMethods for Node {
|
|||
}
|
||||
},
|
||||
NodeTypeId::CharacterData(..) => (),
|
||||
NodeTypeId::Document => unreachable!()
|
||||
NodeTypeId::Document => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Abstract]
|
||||
interface CharacterData : Node {
|
||||
[TreatNullAs=EmptyString] attribute DOMString data;
|
||||
readonly attribute unsigned long length;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* https://dom.spec.whatwg.org/#interface-eventtarget
|
||||
*/
|
||||
|
||||
[Abstract]
|
||||
interface EventTarget {
|
||||
void addEventListener(DOMString type,
|
||||
EventListener? listener,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
// https://www.whatwg.org/html/#htmlmediaelement
|
||||
//enum CanPlayTypeResult { "" /* empty string */, "maybe", "probably" };
|
||||
[Abstract]
|
||||
interface HTMLMediaElement : HTMLElement {
|
||||
|
||||
// error state
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://www.whatwg.org/html/#htmltablecellelement
|
||||
[Abstract]
|
||||
interface HTMLTableCellElement : HTMLElement {
|
||||
attribute unsigned long colSpan;
|
||||
// attribute unsigned long rowSpan;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* https://dom.spec.whatwg.org/#interface-node
|
||||
*/
|
||||
|
||||
[Abstract]
|
||||
interface Node : EventTarget {
|
||||
const unsigned short ELEMENT_NODE = 1;
|
||||
const unsigned short ATTRIBUTE_NODE = 2; // historical
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://www.whatwg.org/html/#workerglobalscope
|
||||
//[Exposed=Worker]
|
||||
// https://html.spec.whatwg.org/multipage/#workerglobalscope
|
||||
[Abstract/*, Exposed=Worker*/]
|
||||
interface WorkerGlobalScope : EventTarget {
|
||||
[BinaryName="Self_"] readonly attribute WorkerGlobalScope self;
|
||||
readonly attribute WorkerLocation location;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0.
|
||||
*/
|
||||
|
||||
//[Exposed=(Window,Worker)]
|
||||
[Abstract/*, Exposed=(Window,Worker)*/]
|
||||
interface XMLHttpRequestEventTarget : EventTarget {
|
||||
// event handlers
|
||||
attribute EventHandler onloadstart;
|
||||
|
|
|
@ -20,7 +20,7 @@ use dom::bindings::utils::{reflect_dom_object, Reflectable};
|
|||
use dom::blob::Blob;
|
||||
use dom::closeevent::CloseEvent;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::messageevent::MessageEvent;
|
||||
use script_task::ScriptTaskEventCategory::WebSocketEvent;
|
||||
use script_task::{Runnable, CommonScriptMsg};
|
||||
|
@ -110,7 +110,7 @@ fn establish_a_websocket_connection(resource_url: &Url, net_url: (Host, String,
|
|||
impl WebSocket {
|
||||
fn new_inherited(global: GlobalRef, url: Url) -> WebSocket {
|
||||
WebSocket {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WebSocket),
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
url: url,
|
||||
global: GlobalField::from_rooted(&global),
|
||||
ready_state: Cell::new(WebSocketRequestState::Connecting),
|
||||
|
|
|
@ -1277,7 +1277,7 @@ impl Window {
|
|||
};
|
||||
|
||||
let win = box Window {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Window),
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
script_chan: script_chan,
|
||||
image_cache_chan: image_cache_chan,
|
||||
control_chan: control_chan,
|
||||
|
|
|
@ -17,7 +17,7 @@ use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
|||
use dom::dedicatedworkerglobalscope::{DedicatedWorkerGlobalScope, WorkerScriptMsg};
|
||||
use dom::errorevent::ErrorEvent;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::workerglobalscope::WorkerGlobalScopeInit;
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl Worker {
|
|||
sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>)
|
||||
-> Worker {
|
||||
Worker {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Worker),
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
global: GlobalField::from_rooted(&global),
|
||||
sender: sender,
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::js::{JS, Root, MutNullableHeap};
|
|||
use dom::bindings::utils::Reflectable;
|
||||
use dom::console::Console;
|
||||
use dom::crypto::Crypto;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::window::{base64_atob, base64_btoa};
|
||||
use dom::workerlocation::WorkerLocation;
|
||||
use dom::workernavigator::WorkerNavigator;
|
||||
|
@ -36,9 +36,9 @@ use std::default::Default;
|
|||
use std::rc::Rc;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
#[derive(JSTraceable, Copy, Clone, PartialEq, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum WorkerGlobalScopeTypeId {
|
||||
DedicatedGlobalScope,
|
||||
DedicatedWorkerGlobalScope,
|
||||
}
|
||||
|
||||
pub struct WorkerGlobalScopeInit {
|
||||
|
@ -90,14 +90,13 @@ pub struct WorkerGlobalScope {
|
|||
}
|
||||
|
||||
impl WorkerGlobalScope {
|
||||
pub fn new_inherited(type_id: WorkerGlobalScopeTypeId,
|
||||
init: WorkerGlobalScopeInit,
|
||||
pub fn new_inherited(init: WorkerGlobalScopeInit,
|
||||
worker_url: Url,
|
||||
runtime: Rc<Runtime>,
|
||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>)
|
||||
-> WorkerGlobalScope {
|
||||
WorkerGlobalScope {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WorkerGlobalScope(type_id)),
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
next_worker_id: Cell::new(WorkerId(0)),
|
||||
worker_id: init.worker_id,
|
||||
worker_url: worker_url,
|
||||
|
|
|
@ -155,7 +155,7 @@ pub struct XMLHttpRequest {
|
|||
impl XMLHttpRequest {
|
||||
fn new_inherited(global: GlobalRef) -> XMLHttpRequest {
|
||||
XMLHttpRequest {
|
||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(XMLHttpRequestEventTargetTypeId::XMLHttpRequest),
|
||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(),
|
||||
ready_state: Cell::new(XMLHttpRequestState::Unsent),
|
||||
timeout: Cell::new(0u32),
|
||||
with_credentials: Cell::new(false),
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
|||
use dom::bindings::codegen::InheritTypes::XMLHttpRequestEventTargetDerived;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
|
||||
#[derive(JSTraceable, Copy, Clone, PartialEq, HeapSizeOf)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum XMLHttpRequestEventTargetTypeId {
|
||||
XMLHttpRequest,
|
||||
XMLHttpRequestUpload,
|
||||
|
@ -20,9 +20,9 @@ pub struct XMLHttpRequestEventTarget {
|
|||
}
|
||||
|
||||
impl XMLHttpRequestEventTarget {
|
||||
pub fn new_inherited(type_id: XMLHttpRequestEventTargetTypeId) -> XMLHttpRequestEventTarget {
|
||||
pub fn new_inherited() -> XMLHttpRequestEventTarget {
|
||||
XMLHttpRequestEventTarget {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::XMLHttpRequestEventTarget(type_id))
|
||||
eventtarget: EventTarget::new_inherited()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ pub struct XMLHttpRequestUpload {
|
|||
impl XMLHttpRequestUpload {
|
||||
fn new_inherited() -> XMLHttpRequestUpload {
|
||||
XMLHttpRequestUpload {
|
||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(
|
||||
XMLHttpRequestEventTargetTypeId::XMLHttpRequestUpload)
|
||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(),
|
||||
}
|
||||
}
|
||||
pub fn new(global: GlobalRef) -> Root<XMLHttpRequestUpload> {
|
||||
|
|
|
@ -8,8 +8,10 @@ use dom::bindings::codegen::InheritTypes::*;
|
|||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::HTMLElementTypeId;
|
||||
use dom::htmlmediaelement::HTMLMediaElementTypeId::{HTMLAudioElement, HTMLVideoElement};
|
||||
use dom::htmltablecellelement::HTMLTableCellElementTypeId::{HTMLTableDataCellElement, HTMLTableHeaderCellElement};
|
||||
use dom::htmlmediaelement::HTMLMediaElementTypeId::HTMLAudioElement;
|
||||
use dom::htmlmediaelement::HTMLMediaElementTypeId::HTMLVideoElement;
|
||||
use dom::htmltablecellelement::HTMLTableCellElementTypeId::HTMLTableDataCellElement;
|
||||
use dom::htmltablecellelement::HTMLTableCellElementTypeId::HTMLTableHeaderCellElement;
|
||||
use dom::node::NodeTypeId;
|
||||
use libc;
|
||||
use util::mem::{HeapSizeOf, heap_size_of};
|
||||
|
|
|
@ -38,11 +38,11 @@ macro_rules! sizeof_checker (
|
|||
);
|
||||
|
||||
// Update the sizes here
|
||||
sizeof_checker!(size_event_target, EventTarget, 48);
|
||||
sizeof_checker!(size_node, Node, 184);
|
||||
sizeof_checker!(size_element, Element, 296);
|
||||
sizeof_checker!(size_htmlelement, HTMLElement, 312);
|
||||
sizeof_checker!(size_div, HTMLDivElement, 312);
|
||||
sizeof_checker!(size_span, HTMLSpanElement, 312);
|
||||
sizeof_checker!(size_text, Text, 216);
|
||||
sizeof_checker!(size_characterdata, CharacterData, 216);
|
||||
sizeof_checker!(size_event_target, EventTarget, 40);
|
||||
sizeof_checker!(size_node, Node, 168);
|
||||
sizeof_checker!(size_element, Element, 280);
|
||||
sizeof_checker!(size_htmlelement, HTMLElement, 296);
|
||||
sizeof_checker!(size_div, HTMLDivElement, 296);
|
||||
sizeof_checker!(size_span, HTMLSpanElement, 296);
|
||||
sizeof_checker!(size_text, Text, 200);
|
||||
sizeof_checker!(size_characterdata, CharacterData, 200);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue