Skip to content

Commit

Permalink
text: Remove line parameter from EditText::layout_metrics
Browse files Browse the repository at this point in the history
After implementing line_metrics, there's no need for
a line parameter in layout_metrics.
  • Loading branch information
kjarosh committed Oct 27, 2024
1 parent 8d986d7 commit dd776d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/src/avm1/globals/text_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ fn get_text_extent<'gc>(

let result = ScriptObject::new(activation.gc(), None);
let metrics = temp_edittext
.layout_metrics(None)
.layout_metrics()
.expect("All text boxes should have at least one line at all times");

result.set_data(
Expand Down
17 changes: 6 additions & 11 deletions core/src/display_object/edit_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use crate::vminterface::{AvmObject, Instantiator};
use chrono::DateTime;
use chrono::Utc;
use core::fmt;
use either::Either;
use gc_arena::{Collect, Gc, GcCell, Mutation};
use ruffle_render::commands::CommandHandler;
use ruffle_render::quality::StageQuality;
Expand Down Expand Up @@ -1912,19 +1911,15 @@ impl<'gc> EditText<'gc> {
self.0.read().layout.lines().len()
}

/// Calculate the layout metrics for a given line.
/// Calculate the layout metrics.
///
/// Returns `None` if the line does not exist or there is not enough data
/// about the line to calculate metrics with.
pub fn layout_metrics(self, line: Option<usize>) -> Option<LayoutMetrics> {
/// Returns `None` if there is not enough data
/// about the layout to calculate metrics with.
pub fn layout_metrics(self) -> Option<LayoutMetrics> {
let layout = &self.0.read().layout;
let line = line.and_then(|line| layout.lines().get(line));

let (boxes, union_bounds) = if let Some(line) = line {
(Either::Left(line.boxes_iter()), line.interior_bounds())
} else {
(Either::Right(layout.boxes_iter()), layout.bounds())
};
let boxes = layout.boxes_iter();
let union_bounds = layout.bounds();

let mut first_font = None;
let mut first_format = None;
Expand Down

0 comments on commit dd776d9

Please sign in to comment.