mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Create source actors from Debugger API notifications
Co-authored-by: atbrakhi <atbrakhi@igalia.com> Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
e2eabd41c9
commit
048d0b0538
13 changed files with 193 additions and 64 deletions
|
@ -2,18 +2,22 @@
|
|||
* 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 base::id::PipelineId;
|
||||
use base::id::{Index, PipelineId, PipelineNamespaceId};
|
||||
use constellation_traits::ScriptToConstellationChan;
|
||||
use crossbeam_channel::Sender;
|
||||
use devtools_traits::ScriptToDevtoolsControlMsg;
|
||||
use devtools_traits::{ScriptToDevtoolsControlMsg, SourceInfo};
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::resources::{self, Resource};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::gc::HandleValue;
|
||||
use js::jsval::{UInt32Value, UndefinedValue};
|
||||
use js::rust::Runtime;
|
||||
use js::rust::wrappers::JS_DefineDebuggerObject;
|
||||
use net_traits::ResourceThreads;
|
||||
use profile_traits::{mem, time};
|
||||
use script_bindings::codegen::GenericBindings::DebuggerGlobalScopeBinding::{
|
||||
DebuggerGlobalScopeMethods, NotifyNewSource,
|
||||
};
|
||||
use script_bindings::realms::InRealm;
|
||||
use script_bindings::reflector::DomObject;
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
|
@ -104,6 +108,10 @@ impl DebuggerGlobalScope {
|
|||
GlobalScope::get_cx()
|
||||
}
|
||||
|
||||
pub(crate) fn as_global_scope(&self) -> &GlobalScope {
|
||||
self.upcast::<GlobalScope>()
|
||||
}
|
||||
|
||||
fn evaluate_js(&self, script: &str, can_gc: CanGc) -> bool {
|
||||
rooted!(in (*Self::get_cx()) let mut rval = UndefinedValue());
|
||||
self.global_scope.evaluate_js_on_global_with_result(
|
||||
|
@ -123,8 +131,20 @@ impl DebuggerGlobalScope {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) fn fire_add_debuggee(&self, can_gc: CanGc, global: &GlobalScope) {
|
||||
let event = DomRoot::upcast::<Event>(DebuggerEvent::new(self.upcast(), global, can_gc));
|
||||
pub(crate) fn fire_add_debuggee(
|
||||
&self,
|
||||
can_gc: CanGc,
|
||||
global: &GlobalScope,
|
||||
pipeline_id: PipelineId,
|
||||
) {
|
||||
let pipeline_id =
|
||||
crate::dom::pipelineid::PipelineId::new(self.upcast(), pipeline_id, can_gc);
|
||||
let event = DomRoot::upcast::<Event>(DebuggerEvent::new(
|
||||
self.upcast(),
|
||||
global,
|
||||
&pipeline_id,
|
||||
can_gc,
|
||||
));
|
||||
assert_eq!(
|
||||
event.fire(self.upcast(), can_gc),
|
||||
EventStatus::NotCanceled,
|
||||
|
@ -132,3 +152,38 @@ impl DebuggerGlobalScope {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl DebuggerGlobalScopeMethods<crate::DomTypeHolder> for DebuggerGlobalScope {
|
||||
// check-tidy: no specs after this line
|
||||
fn NotifyNewSource(&self, args: &NotifyNewSource) {
|
||||
info!(
|
||||
"NotifyNewSource: ({},{}) {} {} {}",
|
||||
args.pipelineId.namespaceId,
|
||||
args.pipelineId.index,
|
||||
args.spidermonkeyId,
|
||||
args.url,
|
||||
args.text
|
||||
);
|
||||
if let Some(devtools_chan) = self.as_global_scope().devtools_chan() {
|
||||
let pipeline_id = PipelineId {
|
||||
namespace_id: PipelineNamespaceId(args.pipelineId.namespaceId),
|
||||
index: Index::new(args.pipelineId.index)
|
||||
.expect("`pipelineId.index` must not be zero"),
|
||||
};
|
||||
let source_info = SourceInfo {
|
||||
url: ServoUrl::parse(args.url.str()).expect("Failed to parse url"),
|
||||
external: true, // TODO
|
||||
worker_id: None, // TODO
|
||||
content: Some(args.text.to_string()),
|
||||
content_type: None, // TODO
|
||||
spidermonkey_id: args.spidermonkeyId,
|
||||
};
|
||||
devtools_chan
|
||||
.send(ScriptToDevtoolsControlMsg::CreateSourceActor(
|
||||
pipeline_id,
|
||||
source_info,
|
||||
))
|
||||
.expect("Failed to send to devtools server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue