diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-01-12 02:35:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-12 02:35:09 -0500 |
commit | dbba9ea453c5cb235f55b2ccaa87782b6c22a5cb (patch) | |
tree | babeb9df30d717dd0e5c2adfc8814c2c2136e389 /components/script/dom/bindings | |
parent | 63cb13f5fa5f52d3574eb0da883f881b52e208ff (diff) | |
parent | 03396011282d527c0fc5e530925877902199e053 (diff) | |
download | servo-dbba9ea453c5cb235f55b2ccaa87782b6c22a5cb.tar.gz servo-dbba9ea453c5cb235f55b2ccaa87782b6c22a5cb.zip |
Auto merge of #25468 - gterzian:add_generic_to_frozen_array, r=Manishearth
Add generic to frozen array
<!-- Please describe your changes on the following line: -->
https://github.com/servo/servo/pull/25467#discussion_r364575071
Depends on https://github.com/servo/servo/pull/25467
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/bindings')
-rw-r--r-- | components/script/dom/bindings/utils.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index e344e9ae279..56b2112e498 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -10,10 +10,8 @@ use crate::dom::bindings::codegen::PrototypeList::{MAX_PROTO_CHAIN_LENGTH, PROTO use crate::dom::bindings::conversions::{jsstring_to_str, private_from_proto_check}; use crate::dom::bindings::error::throw_invalid_this; use crate::dom::bindings::inheritance::TopTypeId; -use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::bindings::trace::trace_object; -use crate::dom::messageport::MessagePort; use crate::dom::windowproxy; use crate::script_runtime::JSContext as SafeJSContext; use js::conversions::{jsstr_to_string, ToJSValConvertible}; @@ -126,12 +124,9 @@ impl Clone for DOMJSClass { unsafe impl Sync for DOMJSClass {} /// Returns a JSVal representing a frozen array of ports -pub fn message_ports_to_frozen_array( - message_ports: &[DomRoot<MessagePort>], - cx: SafeJSContext, -) -> JSVal { +pub fn to_frozen_array<T: ToJSValConvertible>(convertibles: &[T], cx: SafeJSContext) -> JSVal { rooted!(in(*cx) let mut ports = UndefinedValue()); - unsafe { message_ports.to_jsval(*cx, ports.handle_mut()) }; + unsafe { convertibles.to_jsval(*cx, ports.handle_mut()) }; rooted!(in(*cx) let obj = ports.to_object()); unsafe { JS_FreezeObject(*cx, RawHandleObject::from(obj.handle())) }; |