text: Refactor EditText.line_text
This refactor takes advantage of the new layout structure to simplify code.
This commit is contained in:
parent
bfbd2dbd19
commit
adea7ae743
|
@ -1916,23 +1916,18 @@ impl<'gc> EditText<'gc> {
|
|||
pub fn line_text(self, line: usize) -> Option<WString> {
|
||||
let read = self.0.read();
|
||||
let line = read.layout.lines().get(line)?;
|
||||
let text = read.text_spans.text();
|
||||
|
||||
let mut text = WString::new();
|
||||
for layout_box in read.layout.boxes_iter() {
|
||||
if layout_box.bounds().offset_y() < line.offset()
|
||||
|| layout_box.bounds().extent_y() > line.extent()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut line_text = WString::new();
|
||||
for layout_box in line.boxes_iter() {
|
||||
if let LayoutContent::Text { start, end, .. } = layout_box.content() {
|
||||
if let Some(box_tex) = read.text_spans.text().slice(*start..*end) {
|
||||
text.push_str(box_tex);
|
||||
if let Some(box_tex) = text.slice(*start..*end) {
|
||||
line_text.push_str(box_tex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some(text)
|
||||
Some(line_text)
|
||||
}
|
||||
|
||||
fn execute_avm1_asfunction(
|
||||
|
|
Loading…
Reference in New Issue