mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Make devtools::handle_evaluate_js take a &GlobalScope
This commit is contained in:
parent
9c04eb60bd
commit
5d8979237b
4 changed files with 5 additions and 9 deletions
|
@ -13,7 +13,6 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
|||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstring_to_str};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::Reflectable;
|
||||
|
@ -34,14 +33,14 @@ use uuid::Uuid;
|
|||
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn handle_evaluate_js(global: &GlobalRef, eval: String, reply: IpcSender<EvaluateJSReply>) {
|
||||
pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<EvaluateJSReply>) {
|
||||
// global.get_cx() returns a valid `JSContext` pointer, so this is safe.
|
||||
let result = unsafe {
|
||||
let cx = global.get_cx();
|
||||
let globalhandle = global.reflector().get_jsobject();
|
||||
let _ac = JSAutoCompartment::new(cx, globalhandle.get());
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
global.as_global_scope().evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||
global.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||
|
||||
if rval.is_undefined() {
|
||||
EvaluateJSReply::VoidValue
|
||||
|
|
|
@ -301,10 +301,9 @@ impl DedicatedWorkerGlobalScope {
|
|||
fn handle_event(&self, event: MixedMessage) {
|
||||
match event {
|
||||
MixedMessage::FromDevtools(msg) => {
|
||||
let global_ref = GlobalRef::Worker(self.upcast());
|
||||
match msg {
|
||||
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) =>
|
||||
devtools::handle_evaluate_js(&global_ref, string, sender),
|
||||
devtools::handle_evaluate_js(self.upcast(), string, sender),
|
||||
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
||||
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
||||
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) =>
|
||||
|
|
|
@ -206,10 +206,9 @@ impl ServiceWorkerGlobalScope {
|
|||
fn handle_event(&self, event: MixedMessage) -> bool {
|
||||
match event {
|
||||
MixedMessage::FromDevtools(msg) => {
|
||||
let global_ref = GlobalRef::Worker(self.upcast());
|
||||
match msg {
|
||||
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) =>
|
||||
devtools::handle_evaluate_js(&global_ref, string, sender),
|
||||
devtools::handle_evaluate_js(self.upcast(), string, sender),
|
||||
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
||||
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
||||
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) =>
|
||||
|
|
|
@ -985,8 +985,7 @@ impl ScriptThread {
|
|||
Some(browsing_context) => browsing_context.active_window(),
|
||||
None => return warn!("Message sent to closed pipeline {}.", id),
|
||||
};
|
||||
let global_ref = GlobalRef::Window(window.r());
|
||||
devtools::handle_evaluate_js(&global_ref, s, reply)
|
||||
devtools::handle_evaluate_js(window.upcast(), s, reply)
|
||||
},
|
||||
DevtoolScriptControlMsg::GetRootNode(id, reply) =>
|
||||
devtools::handle_get_root_node(&context, id, reply),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue