From 0e3c54c1911ba2c3bf305ee04f04fcd9bf2fc2fe Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 25 Sep 2017 23:30:24 +0200 Subject: Rename dom::bindings::js to dom::bindings::root --- components/script/dom/promisenativehandler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 59fe1d7425b..756b9b84022 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::Root; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; -- cgit v1.2.3 From f87c2a8d7616112ca924e30292db2d244cf87eec Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 26 Sep 2017 01:53:40 +0200 Subject: Rename Root to DomRoot In a later PR, DomRoot will become a type alias of Root>, where Root will be able to handle all the things that need to be rooted that have a stable traceable address that doesn't move for the whole lifetime of the root. Stay tuned. --- components/script/dom/promisenativehandler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 756b9b84022..56c65c9a801 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::bindings::root::Root; +use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -26,7 +26,7 @@ impl PromiseNativeHandler { pub fn new(global: &GlobalScope, resolve: Option>, reject: Option>) - -> Root { + -> DomRoot { reflect_dom_object(box PromiseNativeHandler { reflector: Reflector::new(), resolve: resolve, -- cgit v1.2.3 From aa15dc269f41503d81ad44cd7e85d69e6f4aeac7 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 16 Oct 2017 14:35:30 +0200 Subject: Remove use of unstable box syntax. http://www.robohornet.org gives a score of 101.36 on master, and 102.68 with this PR. The latter is slightly better, but probably within noise level. So it looks like this PR does not affect DOM performance. This is expected since `Box::new` is defined as: ```rust impl Box { #[inline(always)] pub fn new(x: T) -> Box { box x } } ``` With inlining, it should compile to the same as box syntax. --- components/script/dom/promisenativehandler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 56c65c9a801..4ed9b4b30b4 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -27,11 +27,11 @@ impl PromiseNativeHandler { resolve: Option>, reject: Option>) -> DomRoot { - reflect_dom_object(box PromiseNativeHandler { + reflect_dom_object(Box::new(PromiseNativeHandler { reflector: Reflector::new(), resolve: resolve, reject: reject, - }, global, PromiseNativeHandlerBinding::Wrap) + }), global, PromiseNativeHandlerBinding::Wrap) } fn callback(callback: &Option>, cx: *mut JSContext, v: HandleValue) { -- cgit v1.2.3 From 4506f0d30cbbb02df32e9c16135ef288ad6b7e2e Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 18 Oct 2017 10:42:01 +1100 Subject: Replace all uses of the `heapsize` crate with `malloc_size_of`. Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`. `malloc_size_of` is better -- it handles various cases that `heapsize` does not -- so this patch changes Servo to use `malloc_size_of`. This patch makes the following changes to the `malloc_size_of` crate. - Adds `MallocSizeOf` trait implementations for numerous types, some built-in (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`). - Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't support that operation. - For `HashSet`/`HashMap`, falls back to a computed estimate when `enclosing_size_of_op` isn't available. - Adds an extern "C" `malloc_size_of` function that does the actual heap measurement; this is based on the same functions from the `heapsize` crate. This patch makes the following changes elsewhere. - Converts all the uses of `heapsize` to instead use `malloc_size_of`. - Disables the "heapsize"/"heap_size" feature for the external crates that provide it. - Removes the `HeapSizeOf` implementation from `hashglobe`. - Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of` doesn't derive those types, unlike `heapsize`. --- components/script/dom/promisenativehandler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 4ed9b4b30b4..d87589ccaa8 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -8,10 +8,10 @@ use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; -use heapsize::HeapSizeOf; use js::jsapi::{JSContext, HandleValue}; +use malloc_size_of::MallocSizeOf; -pub trait Callback: JSTraceable + HeapSizeOf { +pub trait Callback: JSTraceable + MallocSizeOf { fn callback(&self, cx: *mut JSContext, v: HandleValue); } -- cgit v1.2.3 From 356c57e628255ed338b32246ce5e7de75da621f0 Mon Sep 17 00:00:00 2001 From: Marcin Mielniczuk Date: Wed, 28 Mar 2018 21:28:30 +0200 Subject: Adapt Servo for mozjs 0.6 and the changes introduced in servo/rust-mozjs#393 --- components/script/dom/promisenativehandler.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index d87589ccaa8..123fbfead26 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -8,7 +8,8 @@ use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; -use js::jsapi::{JSContext, HandleValue}; +use js::jsapi::JSContext; +use js::rust::HandleValue; use malloc_size_of::MallocSizeOf; pub trait Callback: JSTraceable + MallocSizeOf { -- cgit v1.2.3 From c37a345dc9f4dda6ea29c42f96f6c7201c42cbac Mon Sep 17 00:00:00 2001 From: chansuke Date: Tue, 18 Sep 2018 23:24:15 +0900 Subject: Format script component --- components/script/dom/promisenativehandler.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 123fbfead26..fa54d454b1a 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -24,15 +24,20 @@ pub struct PromiseNativeHandler { } impl PromiseNativeHandler { - pub fn new(global: &GlobalScope, - resolve: Option>, - reject: Option>) - -> DomRoot { - reflect_dom_object(Box::new(PromiseNativeHandler { - reflector: Reflector::new(), - resolve: resolve, - reject: reject, - }), global, PromiseNativeHandlerBinding::Wrap) + pub fn new( + global: &GlobalScope, + resolve: Option>, + reject: Option>, + ) -> DomRoot { + reflect_dom_object( + Box::new(PromiseNativeHandler { + reflector: Reflector::new(), + resolve: resolve, + reject: reject, + }), + global, + PromiseNativeHandlerBinding::Wrap, + ) } fn callback(callback: &Option>, cx: *mut JSContext, v: HandleValue) { -- cgit v1.2.3 From 45f7199eee82c66637ec68287eafa40a651001c4 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 1 Nov 2018 23:45:06 +0100 Subject: `cargo fix --edition` --- components/script/dom/promisenativehandler.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index fa54d454b1a..3ebb8c58b79 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -2,11 +2,11 @@ * 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/. */ -use dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; -use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::bindings::root::DomRoot; -use dom::bindings::trace::JSTraceable; -use dom::globalscope::GlobalScope; +use crate::dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; +use crate::dom::bindings::reflector::{Reflector, reflect_dom_object}; +use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::trace::JSTraceable; +use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; use js::jsapi::JSContext; use js::rust::HandleValue; -- cgit v1.2.3 From 9e92eb205a2a12fe0be883e42cb7f82deebc9031 Mon Sep 17 00:00:00 2001 From: Pyfisch Date: Tue, 6 Nov 2018 20:38:02 +0100 Subject: Reorder imports --- components/script/dom/promisenativehandler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 3ebb8c58b79..8358de2f49e 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; -use crate::dom::bindings::reflector::{Reflector, reflect_dom_object}; +use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::trace::JSTraceable; use crate::dom::globalscope::GlobalScope; -- cgit v1.2.3 From 2012be4a8bd97f2fd69f986c8fffb1af1eec21dc Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 1 Nov 2018 21:43:04 +0100 Subject: `cargo fix --edition-idioms` --- components/script/dom/promisenativehandler.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 8358de2f49e..f9c2dba5f66 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -26,8 +26,8 @@ pub struct PromiseNativeHandler { impl PromiseNativeHandler { pub fn new( global: &GlobalScope, - resolve: Option>, - reject: Option>, + resolve: Option>, + reject: Option>, ) -> DomRoot { reflect_dom_object( Box::new(PromiseNativeHandler { @@ -40,7 +40,7 @@ impl PromiseNativeHandler { ) } - fn callback(callback: &Option>, cx: *mut JSContext, v: HandleValue) { + fn callback(callback: &Option>, cx: *mut JSContext, v: HandleValue) { if let Some(ref callback) = *callback { callback.callback(cx, v) } -- cgit v1.2.3 From a1a14459c141afc6ac6771b8a6c9ca374537edf2 Mon Sep 17 00:00:00 2001 From: Jan Andre Ikenmeyer Date: Mon, 19 Nov 2018 14:47:12 +0100 Subject: Update MPL license to https (part 3) --- components/script/dom/promisenativehandler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index f9c2dba5f66..85f08d776e5 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -1,6 +1,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/. */ + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; -- cgit v1.2.3 From 1d38bc041967b88838ed7b006aab9908e2f24474 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 19 Jun 2019 16:07:13 +0200 Subject: Fix some new warnings --- components/script/dom/promisenativehandler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 85f08d776e5..147aad57fd5 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -19,8 +19,8 @@ pub trait Callback: JSTraceable + MallocSizeOf { #[dom_struct] pub struct PromiseNativeHandler { reflector: Reflector, - resolve: Option>, - reject: Option>, + resolve: Option>, + reject: Option>, } impl PromiseNativeHandler { -- cgit v1.2.3 From 3ea6d87bcc37167464e856949a4b9b77d0e9318a Mon Sep 17 00:00:00 2001 From: YUAN LYU Date: Fri, 20 Mar 2020 22:14:18 -0400 Subject: Add trait DomObjectWrap to provide WRAP function --- components/script/dom/promisenativehandler.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 147aad57fd5..c7e0ded5b4d 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::trace::JSTraceable; @@ -36,7 +35,6 @@ impl PromiseNativeHandler { reject: reject, }), global, - PromiseNativeHandlerBinding::Wrap, ) } -- cgit v1.2.3 From 8a3bf880e98a946e45d4659b09a80b032b5d1734 Mon Sep 17 00:00:00 2001 From: Tipowol Date: Sun, 5 Apr 2020 19:54:30 +0200 Subject: Add InRealm argument to Callback trait --- components/script/dom/promisenativehandler.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index c7e0ded5b4d..217bcc851c2 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -6,13 +6,14 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::trace::JSTraceable; use crate::dom::globalscope::GlobalScope; +use crate::realms::InRealm; use dom_struct::dom_struct; use js::jsapi::JSContext; use js::rust::HandleValue; use malloc_size_of::MallocSizeOf; pub trait Callback: JSTraceable + MallocSizeOf { - fn callback(&self, cx: *mut JSContext, v: HandleValue); + fn callback(&self, cx: *mut JSContext, v: HandleValue, realm: InRealm); } #[dom_struct] @@ -38,17 +39,22 @@ impl PromiseNativeHandler { ) } - fn callback(callback: &Option>, cx: *mut JSContext, v: HandleValue) { + fn callback( + callback: &Option>, + cx: *mut JSContext, + v: HandleValue, + realm: InRealm, + ) { if let Some(ref callback) = *callback { - callback.callback(cx, v) + callback.callback(cx, v, realm) } } - pub fn resolved_callback(&self, cx: *mut JSContext, v: HandleValue) { - PromiseNativeHandler::callback(&self.resolve, cx, v) + pub fn resolved_callback(&self, cx: *mut JSContext, v: HandleValue, realm: InRealm) { + PromiseNativeHandler::callback(&self.resolve, cx, v, realm) } - pub fn rejected_callback(&self, cx: *mut JSContext, v: HandleValue) { - PromiseNativeHandler::callback(&self.reject, cx, v) + pub fn rejected_callback(&self, cx: *mut JSContext, v: HandleValue, realm: InRealm) { + PromiseNativeHandler::callback(&self.reject, cx, v, realm) } } -- cgit v1.2.3 From bd5796c90b8e8e066a32e7da9cfa5251d1559046 Mon Sep 17 00:00:00 2001 From: Gregory Terzian Date: Sat, 29 Feb 2020 11:59:10 +0800 Subject: integrate readablestream with fetch and blob --- components/script/dom/promisenativehandler.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'components/script/dom/promisenativehandler.rs') diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 217bcc851c2..a5039d1f0b6 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -7,13 +7,14 @@ use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::trace::JSTraceable; use crate::dom::globalscope::GlobalScope; use crate::realms::InRealm; +use crate::script_runtime::JSContext as SafeJSContext; use dom_struct::dom_struct; use js::jsapi::JSContext; use js::rust::HandleValue; use malloc_size_of::MallocSizeOf; pub trait Callback: JSTraceable + MallocSizeOf { - fn callback(&self, cx: *mut JSContext, v: HandleValue, realm: InRealm); + fn callback(&self, cx: SafeJSContext, v: HandleValue, realm: InRealm); } #[dom_struct] @@ -39,12 +40,14 @@ impl PromiseNativeHandler { ) } + #[allow(unsafe_code)] fn callback( callback: &Option>, cx: *mut JSContext, v: HandleValue, realm: InRealm, ) { + let cx = unsafe { SafeJSContext::from_ptr(cx) }; if let Some(ref callback) = *callback { callback.callback(cx, v, realm) } -- cgit v1.2.3