|
2 | 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT
|
3 | 3 |
|
4 | 4 | use crate::inline_box::InlineBox;
|
5 |
| -use crate::layout::{Alignment, Glyph, LineMetrics, RunMetrics, Style}; |
| 5 | +use crate::layout::{Alignment, ContentWidths, Glyph, LineMetrics, RunMetrics, Style}; |
6 | 6 | use crate::style::Brush;
|
7 | 7 | use crate::util::nearly_zero;
|
8 | 8 | use crate::Font;
|
@@ -201,7 +201,7 @@ pub(crate) struct LayoutData<B: Brush> {
|
201 | 201 | pub(crate) coords: Vec<i16>,
|
202 | 202 |
|
203 | 203 | // Lazily calculated values
|
204 |
| - content_widths: OnceCell<(f32, f32)>, |
| 204 | + content_widths: OnceCell<ContentWidths>, |
205 | 205 |
|
206 | 206 | // Input (/ output of style resolution)
|
207 | 207 | pub(crate) styles: Vec<Style<B>>,
|
@@ -477,13 +477,13 @@ impl<B: Brush> LayoutData<B> {
|
477 | 477 | }
|
478 | 478 | }
|
479 | 479 |
|
480 |
| - pub(crate) fn content_widths(&self) -> (f32, f32) { |
| 480 | + pub(crate) fn content_widths(&self) -> ContentWidths { |
481 | 481 | *self
|
482 | 482 | .content_widths
|
483 | 483 | .get_or_init(|| self.calculate_content_widths())
|
484 | 484 | }
|
485 | 485 |
|
486 |
| - fn calculate_content_widths(&self) -> (f32, f32) { |
| 486 | + fn calculate_content_widths(&self) -> ContentWidths { |
487 | 487 | fn whitespace_advance(cluster: Option<&ClusterData>) -> f32 {
|
488 | 488 | cluster
|
489 | 489 | .filter(|cluster| cluster.info.whitespace().is_space_or_nbsp())
|
@@ -528,6 +528,9 @@ impl<B: Brush> LayoutData<B> {
|
528 | 528 | max_width = max_width.max(running_max_width - trailing_whitespace);
|
529 | 529 | }
|
530 | 530 |
|
531 |
| - (min_width, max_width) |
| 531 | + ContentWidths { |
| 532 | + min: min_width, |
| 533 | + max: max_width, |
| 534 | + } |
532 | 535 | }
|
533 | 536 | }
|
0 commit comments