mirror of
https://github.com/servo/servo.git
synced 2025-08-14 01:45:33 +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
d89bfd5c88
commit
dc6b2f1363
1 changed files with 29 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use base::id::PipelineId;
|
||||
use serde::Serialize;
|
||||
|
@ -77,6 +77,12 @@ struct GetBreakableLinesReply {
|
|||
lines: Vec<usize>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct GetBreakpointPositionsCompressedReply {
|
||||
from: String,
|
||||
positions: BTreeMap<usize, Vec<usize>>,
|
||||
}
|
||||
|
||||
impl SourceManager {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
@ -204,6 +210,28 @@ impl Actor for SourceActor {
|
|||
};
|
||||
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 UTF-16 code units, not Unicode scalar values or grapheme clusters.
|
||||
let column_count = line.encode_utf16().count();
|
||||
// Line number are one-based. Column numbers are zero-based.
|
||||
// FIXME: the docs say column numbers are one-based, but this appears to be incorrect.
|
||||
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#source-locations>
|
||||
positions.insert(line_number + 1, (0..column_count).collect());
|
||||
}
|
||||
}
|
||||
let reply = GetBreakpointPositionsCompressedReply {
|
||||
from: self.name(),
|
||||
positions,
|
||||
};
|
||||
request.reply_final(&reply)?
|
||||
},
|
||||
_ => return Err(ActorError::UnrecognizedPacketType),
|
||||
};
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue