text: Move lower_from_text_spans to module level
This commit is contained in:
parent
43b2cced0a
commit
d2f5b78503
|
@ -21,6 +21,7 @@ use crate::display_object::{DisplayObjectBase, DisplayObjectPtr};
|
|||
use crate::drawing::Drawing;
|
||||
use crate::events::{ClipEvent, ClipEventResult, TextControlCode};
|
||||
use crate::font::{round_down_to_pixel, FontType, Glyph, TextRenderSettings};
|
||||
use crate::html;
|
||||
use crate::html::{
|
||||
BoxBounds, FormatSpans, LayoutBox, LayoutContent, LayoutMetrics, Position, TextFormat,
|
||||
};
|
||||
|
@ -287,7 +288,7 @@ impl<'gc> EditText<'gc> {
|
|||
FontType::Device
|
||||
};
|
||||
|
||||
let (layout, intrinsic_bounds) = LayoutBox::lower_from_text_spans(
|
||||
let (layout, intrinsic_bounds) = html::lower_from_text_spans(
|
||||
&text_spans,
|
||||
context,
|
||||
swf_movie.clone(),
|
||||
|
@ -848,7 +849,7 @@ impl<'gc> EditText<'gc> {
|
|||
FontType::Embedded
|
||||
};
|
||||
|
||||
let (new_layout, intrinsic_bounds) = LayoutBox::lower_from_text_spans(
|
||||
let (new_layout, intrinsic_bounds) = html::lower_from_text_spans(
|
||||
&edit_text.text_spans,
|
||||
context,
|
||||
movie,
|
||||
|
|
|
@ -7,7 +7,7 @@ mod text_format;
|
|||
|
||||
pub use dimensions::BoxBounds;
|
||||
pub use dimensions::Position;
|
||||
pub use layout::{LayoutBox, LayoutContent, LayoutMetrics};
|
||||
pub use layout::{lower_from_text_spans, LayoutBox, LayoutContent, LayoutMetrics};
|
||||
pub use stylesheet::{transform_dashes_to_camel_case, CssStream};
|
||||
pub use text_format::{FormatSpans, TextDisplay, TextFormat, TextSpan};
|
||||
|
||||
|
|
|
@ -807,12 +807,13 @@ impl<'gc> LayoutBox<'gc> {
|
|||
content: LayoutContent::Drawing(drawing),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct a new layout hierarchy from text spans.
|
||||
///
|
||||
/// The returned bounds will include both the text bounds itself, as well
|
||||
/// as left and right margins on any of the lines.
|
||||
pub fn lower_from_text_spans(
|
||||
pub fn lower_from_text_spans<'gc>(
|
||||
fs: &FormatSpans,
|
||||
context: &mut UpdateContext<'_, 'gc>,
|
||||
movie: Arc<SwfMovie>,
|
||||
|
@ -867,10 +868,8 @@ impl<'gc> LayoutBox<'gc> {
|
|||
) {
|
||||
// This ensures that the space causing the line break
|
||||
// is included in the line it broke.
|
||||
let next_breakpoint = string_utils::next_char_boundary(
|
||||
text,
|
||||
last_breakpoint + breakpoint,
|
||||
);
|
||||
let next_breakpoint =
|
||||
string_utils::next_char_boundary(text, last_breakpoint + breakpoint);
|
||||
|
||||
// If text doesn't fit at the start of a line, it
|
||||
// won't fit on the next either, abort and put the
|
||||
|
@ -943,6 +942,7 @@ impl<'gc> LayoutBox<'gc> {
|
|||
layout_context.end_layout(context, fs, font_type)
|
||||
}
|
||||
|
||||
impl<'gc> LayoutBox<'gc> {
|
||||
pub fn bounds(&self) -> BoxBounds<Twips> {
|
||||
self.bounds
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue