mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue