mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Handle getBreakableLines in source actor
Co-authored-by: atbrakhi <atbrakhi@igalia.com> Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
5578b9abd2
commit
cfb66702ca
1 changed files with 24 additions and 0 deletions
|
@ -64,6 +64,12 @@ struct SourceContentReply {
|
||||||
source: String,
|
source: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct GetBreakableLinesReply {
|
||||||
|
from: String,
|
||||||
|
lines: Vec<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
impl SourceManager {
|
impl SourceManager {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -157,6 +163,24 @@ impl Actor for SourceActor {
|
||||||
let _ = stream.write_json_packet(&reply);
|
let _ = stream.write_json_packet(&reply);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
},
|
},
|
||||||
|
// Client wants to know which lines can have breakpoints.
|
||||||
|
// Sent when opening a source in the Sources panel, and controls whether the line numbers can be clicked.
|
||||||
|
"getBreakableLines" => {
|
||||||
|
// Tell the client that every line is breakable.
|
||||||
|
// TODO: determine which lines are actually breakable.
|
||||||
|
let line_count = self
|
||||||
|
.content
|
||||||
|
.as_ref()
|
||||||
|
.map_or(0, |content| content.lines().count());
|
||||||
|
let reply = GetBreakableLinesReply {
|
||||||
|
from: self.name(),
|
||||||
|
// Line numbers are one-based.
|
||||||
|
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#source-locations>
|
||||||
|
lines: (1..=line_count).collect(),
|
||||||
|
};
|
||||||
|
let _ = stream.write_json_packet(&reply);
|
||||||
|
ActorMessageStatus::Processed
|
||||||
|
},
|
||||||
_ => ActorMessageStatus::Ignored,
|
_ => ActorMessageStatus::Ignored,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue