mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
codegen: use FromJSValConvertible
trait for Promise
(#36966)
Before it was only used when converting to a `Record`, using it all the times allow us to remove two methods. Plus added a helper method in CodegenRust.py to avoid repeated code. Testing: a successful build and existing tests should cover the changes. Fixes: #36410 --------- Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
parent
d780fb7695
commit
c37d5572fd
6 changed files with 27 additions and 118 deletions
|
@ -3,10 +3,8 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::thread::LocalKey;
|
||||
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::glue::JSPrincipalsCallbacks;
|
||||
use js::jsapi::{CallArgs, HandleObject as RawHandleObject, JSContext as RawJSContext, JSObject};
|
||||
use js::rust::{HandleObject, MutableHandleObject};
|
||||
|
@ -78,14 +76,6 @@ pub trait GlobalScopeHelpers<D: DomTypes> {
|
|||
unsafe fn from_object(obj: *mut JSObject) -> DomRoot<D::GlobalScope>;
|
||||
fn from_reflector(reflector: &impl DomObject, realm: InRealm) -> DomRoot<D::GlobalScope>;
|
||||
|
||||
/// # Safety
|
||||
/// `obj` must point to a valid, non-null JSObject.
|
||||
/// `cx` must point to a valid, non-null RawJSContext.
|
||||
unsafe fn from_object_maybe_wrapped(
|
||||
obj: *mut JSObject,
|
||||
cx: *mut RawJSContext,
|
||||
) -> DomRoot<D::GlobalScope>;
|
||||
|
||||
fn origin(&self) -> &MutableOrigin;
|
||||
|
||||
fn incumbent() -> Option<DomRoot<D::GlobalScope>>;
|
||||
|
@ -101,15 +91,6 @@ pub trait DocumentHelpers {
|
|||
fn ensure_safe_to_run_script_or_layout(&self);
|
||||
}
|
||||
|
||||
/// Operations that must be invoked from the generated bindings.
|
||||
pub trait PromiseHelpers<D: crate::DomTypes> {
|
||||
fn new_resolved(
|
||||
global: &D::GlobalScope,
|
||||
cx: JSContext,
|
||||
value: impl ToJSValConvertible,
|
||||
) -> Rc<D::Promise>;
|
||||
}
|
||||
|
||||
pub trait ServoInternalsHelpers {
|
||||
fn is_servo_internal(cx: JSContext, global: HandleObject) -> bool;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue