pub struct ViewJSContextGuard<'a> { /* private fields */ }Expand description
An RAII implementation of a “scoped lock” of a pixel buffer for Javascript Context
of View.
When this structure is dropped (falls out of scope), the lock will be unlocked.
This struct is created by View::lock_js_context.
This can be used as Deref to access the underlying JSContext.
Methods from Deref<Target = JSContext>§
Sourcepub fn global_object(&self) -> JSObject<'_>
pub fn global_object(&self) -> JSObject<'_>
Get the global object for this context.
Sourcepub fn global_context(&self) -> JSContext
pub fn global_context(&self) -> JSContext
Get the global context for this context.
Sourcepub fn name(&self) -> Option<JSString>
pub fn name(&self) -> Option<JSString>
Get the name of this context.
A JSGlobalContext’s name is exposed when inspecting the context to make it easier to identify the context you would like to inspect.
The context may not have a name, in which case this method will return None.
Sourcepub fn is_inspectable(&self) -> bool
pub fn is_inspectable(&self) -> bool
Gets whether the context is inspectable in Web Inspector.
Sourcepub fn check_script_syntax(&self, script: &str) -> Result<bool, JSValue<'_>>
pub fn check_script_syntax(&self, script: &str) -> Result<bool, JSValue<'_>>
Checks for syntax errors in a string of JavaScript.
true if the script is syntactically correct, otherwise false.
Sourcepub fn garbage_collect(&self)
pub fn garbage_collect(&self)
Performs a JavaScript garbage collection.
JavaScript values that are on the machine stack, in a register,
protected by JSValueProtect, set as the global object of an execution context,
or reachable from any such value will not be collected.
During JavaScript execution, you are not required to call this function; the JavaScript engine will garbage collect as needed. JavaScript values created within a context group are automatically destroyed when the last reference to the context group is released.