mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Handle getBreakpointPositionsCompressed in source actor
Co-authored-by: atbrakhi <atbrakhi@igalia.com> Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
a7b9f8b2b1
commit
eadce2ebe0
1 changed files with 28 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
use base::id::PipelineId;
|
use base::id::PipelineId;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
@ -69,6 +69,12 @@ struct GetBreakableLinesReply {
|
||||||
lines: Vec<usize>,
|
lines: Vec<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct GetBreakpointPositionsCompressedReply {
|
||||||
|
from: String,
|
||||||
|
positions: BTreeMap<usize, Vec<usize>>,
|
||||||
|
}
|
||||||
|
|
||||||
impl SourceManager {
|
impl SourceManager {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -178,6 +184,27 @@ impl Actor for SourceActor {
|
||||||
};
|
};
|
||||||
request.reply_final(&reply)?
|
request.reply_final(&reply)?
|
||||||
},
|
},
|
||||||
|
// Client wants to know which columns in the line can have breakpoints.
|
||||||
|
// Sent when the user tries to set a breakpoint by clicking a line number in a source.
|
||||||
|
"getBreakpointPositionsCompressed" => {
|
||||||
|
// Tell the client that every column is breakable.
|
||||||
|
// TODO: determine which columns are actually breakable.
|
||||||
|
let mut positions = BTreeMap::default();
|
||||||
|
if let Some(content) = self.content.as_ref() {
|
||||||
|
for (line_number, line) in content.lines().enumerate() {
|
||||||
|
// Column numbers are in Unicode scalar values, not UTF-16 code units or grapheme clusters.
|
||||||
|
let column_count = line.chars().count();
|
||||||
|
// Line and column numbers are one-based.
|
||||||
|
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#source-locations>
|
||||||
|
positions.insert(line_number + 1, (1..=column_count).collect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let reply = GetBreakpointPositionsCompressedReply {
|
||||||
|
from: self.name(),
|
||||||
|
positions,
|
||||||
|
};
|
||||||
|
request.reply_final(&reply)?
|
||||||
|
},
|
||||||
_ => return Err(ActorError::UnrecognizedPacketType),
|
_ => return Err(ActorError::UnrecognizedPacketType),
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue