mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Support arbitrary protos when wrapping DOM objects with constructors.
This commit is contained in:
parent
d9600ff50f
commit
dbff26bce0
197 changed files with 2028 additions and 586 deletions
|
@ -6147,9 +6147,7 @@ let global = DomRoot::downcast::<dom::types::%s>(global).unwrap();
|
|||
else:
|
||||
name = self.constructor.identifier.name
|
||||
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
||||
args = ["&global"]
|
||||
if self.descriptor.interface.identifier.name == "EventTarget":
|
||||
args += ["desired_proto.handle()"]
|
||||
args = ["&global", "Some(desired_proto.handle())"]
|
||||
constructorCall = CGMethodCall(args, nativeName, True,
|
||||
self.descriptor, self.constructor)
|
||||
return CGList([preamble, constructorCall])
|
||||
|
|
|
@ -225,10 +225,12 @@ unsafe fn html_constructor(
|
|||
None => {
|
||||
// Step 8.1
|
||||
let name = QualName::new(None, ns!(html), definition.local_name.clone());
|
||||
// Any prototype used to create these elements will be overwritten before returning
|
||||
// from this function, so we don't bother overwriting the defaults here.
|
||||
let element = if definition.is_autonomous() {
|
||||
DomRoot::upcast(HTMLElement::new(name.local, None, &*document))
|
||||
DomRoot::upcast(HTMLElement::new(name.local, None, &*document, None))
|
||||
} else {
|
||||
create_native_html_element(name, None, &*document, ElementCreator::ScriptCreated)
|
||||
create_native_html_element(name, None, &*document, ElementCreator::ScriptCreated, None)
|
||||
};
|
||||
|
||||
// Step 8.2 is performed in the generated caller code.
|
||||
|
|
|
@ -26,13 +26,13 @@ where
|
|||
unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, None, obj) }
|
||||
}
|
||||
|
||||
pub fn reflect_dom_object2<T, U>(obj: Box<T>, global: &U, proto: HandleObject) -> DomRoot<T>
|
||||
pub fn reflect_dom_object2<T, U>(obj: Box<T>, global: &U, proto: Option<HandleObject>) -> DomRoot<T>
|
||||
where
|
||||
T: DomObject + DomObjectWrap,
|
||||
U: DerivedFrom<GlobalScope>,
|
||||
{
|
||||
let global_scope = global.upcast();
|
||||
unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, Some(proto), obj) }
|
||||
unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, proto, obj) }
|
||||
}
|
||||
|
||||
/// A struct to store a reference to the reflector of a DOM object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue