Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upspecialized constructors for singly-exposed DOM types #14160
Conversation
highfive
commented
Nov 10, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Nov 10, 2016
|
Thanks for your contribution! |
| globalName = list(self.exposureSet)[0] | ||
| downcast = """let global = global.downcast::<dom::{}::{}>().unwrap();\n""" | ||
| downcast = downcast.format(globalName.lower(), | ||
| globalName[0].upper() + globalName[1:]) |
This comment has been minimized.
This comment has been minimized.
nox
Nov 10, 2016
Member
Could you explain what these two lines are supposed to do? Also you may want to look at MakeNativeName in Configuration.py.
This comment has been minimized.
This comment has been minimized.
ajnirp
Nov 11, 2016
Author
Contributor
This is for the case when a DOM type is exposed to exactly one global. In that case, we downcast global from GlobalScope to that particular struct.
Thank you for pointing out MakeNativeName! I have fixed it.
| @@ -3170,7 +3170,7 @@ def __init__(self, errorResult, arguments, argsPre, returnType, | |||
|
|
|||
| if isFallible: | |||
| if static: | |||
| glob = "&global" | |||
| glob = "global.upcast::<GlobalScope>()" | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ajnirp
Nov 11, 2016
Author
Contributor
It's needed to prevent compile errors in the call to throw_dom_exception that gets generated from CGCallGenerator::__init__(). Without this change, we end up passing a reference to a GlobalScope-derived struct as the 2nd parameter to throw_dom_exception whereas it expects to see a &GlobalScope.
| @@ -82,6 +83,8 @@ impl WebGLContextEvent { | |||
|
|
|||
| let cancelable = EventCancelable::from(init.parent.cancelable); | |||
|
|
|||
| let global = window.upcast::<GlobalScope>(); | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| type_: DOMString, | ||
| init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> { | ||
| let global = worker.upcast::<GlobalScope>(); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ajnirp
Nov 11, 2016
Author
Contributor
I think this should be &ServiceWorkerGlobalScope, based on ExtendableEvent.webidl Updated!
| type_: DOMString, | ||
| init: &ExtendableMessageEventBinding::ExtendableMessageEventInit) | ||
| -> Fallible<Root<ExtendableMessageEvent>> { | ||
| let global = worker.upcast::<GlobalScope>(); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ajnirp
Nov 11, 2016
Author
Contributor
Likewise, I think this should be &ServiceWorkerGlobalScope as well. Updated!
This comment has been minimized.
This comment has been minimized.
| @@ -40,12 +42,14 @@ impl DOMMatrixReadOnly { | |||
| } | |||
|
|
|||
| // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly | |||
| pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Self>> { | |||
| pub fn Constructor(window: &Window) -> Fallible<Root<Self>> { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ajnirp
Nov 11, 2016
Author
Contributor
To address this, I uncommented the Exposed=(Window,Worker) lines in the WebIDLs for DOMMatrix{ReadOnly} and removed the up/down casting in their .rs files. Is this okay?
1b0a6c7
to
1736be7
| preamble = """let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n""" | ||
| if len(self.exposureSet) == 1: | ||
| globalName = list(self.exposureSet)[0] | ||
| downcast = """let global = global.downcast::<dom::{}::{}>().unwrap();\n""" |
This comment has been minimized.
This comment has been minimized.
nox
Nov 11, 2016
Member
I think you can just do:
let downcast = "global.downcast::<%s>().unwrap();" % descriptor.path| type_: DOMString, | ||
| init: &ExtendableMessageEventBinding::ExtendableMessageEventInit) | ||
| -> Fallible<Root<ExtendableMessageEvent>> { | ||
| let global = worker.upcast::<GlobalScope>(); |
This comment has been minimized.
This comment has been minimized.
| Constructor(sequence<unrestricted double> numberSequence) | ||
| // Exposed=(Window,Worker) | ||
| Constructor(sequence<unrestricted double> numberSequence), | ||
| Exposed=(Window,Worker) |
This comment has been minimized.
This comment has been minimized.
|
|
1736be7
to
f0c0d6a
f0c0d6a
to
c1a6e02
|
Carried in #14376, thanks for your contribution! |
ajnirp commentedNov 10, 2016
•
edited by larsbergstrom
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is