Skip to content

Commit

Permalink
text: Remove layout line & layout box interior bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Nov 4, 2024
1 parent b267fbd commit 937b2fd
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 57 deletions.
2 changes: 0 additions & 2 deletions core/src/debug_ui/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,7 @@ impl DisplayObjectWindow {
("Text Exterior", LayoutDebugBoxesFlag::TEXT_EXTERIOR),
("Text", LayoutDebugBoxesFlag::TEXT),
("Line", LayoutDebugBoxesFlag::LINE),
("Line Interior", LayoutDebugBoxesFlag::LINE_INTERIOR),
("Box", LayoutDebugBoxesFlag::BOX),
("Box Interior", LayoutDebugBoxesFlag::BOX_INTERIOR),
("Character", LayoutDebugBoxesFlag::CHAR),
] {
let old_value = object.layout_debug_boxes_flag(flag);
Expand Down
12 changes: 0 additions & 12 deletions core/src/display_object/edit_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,21 +906,11 @@ impl<'gc> EditText<'gc> {
}
}
}
if flags.contains(LayoutDebugBoxesFlag::BOX_INTERIOR) {
for lbox in layout.boxes_iter() {
context.draw_rect_outline(Color::RED, lbox.interior_bounds().into(), Twips::ONE);
}
}
if flags.contains(LayoutDebugBoxesFlag::BOX) {
for lbox in layout.boxes_iter() {
context.draw_rect_outline(Color::RED, lbox.bounds().into(), Twips::ONE);
}
}
if flags.contains(LayoutDebugBoxesFlag::LINE_INTERIOR) {
for line in layout.lines() {
context.draw_rect_outline(Color::BLUE, line.interior_bounds().into(), Twips::ONE);
}
}
if flags.contains(LayoutDebugBoxesFlag::LINE) {
for line in layout.lines() {
context.draw_rect_outline(Color::BLUE, line.bounds().into(), Twips::ONE);
Expand Down Expand Up @@ -2781,9 +2771,7 @@ bitflags::bitflags! {
const TEXT_EXTERIOR = 1 << 1;
const TEXT = 1 << 2;
const LINE = 1 << 3;
const LINE_INTERIOR = 1 << 4;
const BOX = 1 << 5;
const BOX_INTERIOR = 1 << 6;
const CHAR = 1 << 7;
}
}
Expand Down
43 changes: 0 additions & 43 deletions core/src/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {

//Flash ignores trailing spaces when aligning lines, so should we
if self.current_line_span.align != swf::TextAlign::Left {
linebox.interior_bounds = linebox
.interior_bounds
.with_size(font.measure(text.trim_end(), params).into());
linebox.bounds = linebox
.bounds
.with_width(font.measure(text.trim_end(), params).0);
Expand Down Expand Up @@ -336,11 +333,9 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
left_adjustment + align_adjustment + (interim_adjustment * box_count),
baseline_adjustment,
));
layout_box.interior_bounds += position;
layout_box.bounds += position;
} else if layout_box.is_bullet() {
let position = Position::from((Twips::ZERO, baseline_adjustment));
layout_box.interior_bounds += position;
layout_box.bounds += position;
}

Expand Down Expand Up @@ -369,12 +364,6 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
let boxes = mem::take(&mut self.boxes);
let first_box = boxes.first().unwrap();
let start = first_box.start();
let interior_bounds = boxes
.iter()
.filter(|b| b.is_text_box())
.fold(first_box.interior_bounds, |bounds, b| {
bounds + b.interior_bounds
});
let bounds = boxes
.iter()
.filter(|b| b.is_text_box())
Expand All @@ -389,7 +378,6 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {

self.lines.push(LayoutLine {
index: self.current_line_index,
interior_bounds,
bounds,
start,
end,
Expand Down Expand Up @@ -626,7 +614,6 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
let box_origin = self.cursor - (Twips::ZERO, ascent).into();

let mut new_box = LayoutBox::from_text(text, start, end, font, span);
new_box.interior_bounds = BoxBounds::from_position_and_size(box_origin, text_size);
new_box.bounds = BoxBounds::from_position_and_size(
box_origin,
Size::from((text_size.width(), ascent + descent)),
Expand Down Expand Up @@ -665,7 +652,6 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {

let pos = self.last_box_end_position();
let mut new_bullet = LayoutBox::from_bullet(pos, bullet_font, span);
new_bullet.interior_bounds = BoxBounds::from_position_and_size(box_origin, text_size);
new_bullet.bounds = BoxBounds::from_position_and_size(
box_origin,
Size::from((text_size.width(), ascent + descent)),
Expand Down Expand Up @@ -868,16 +854,6 @@ pub struct LayoutLine<'gc> {
#[collect(require_static)]
bounds: BoxBounds<Twips>,

/// Interior line bounds.
///
/// It is a union of interior bounds of all layout
/// boxes contained within this line.
///
/// TODO This probably shouldn't be used, we should
/// always prefer bounds, not interior_bounds.
#[collect(require_static)]
interior_bounds: BoxBounds<Twips>,

/// The start position of the line (inclusive).
start: usize,

Expand Down Expand Up @@ -910,10 +886,6 @@ impl<'gc> LayoutLine<'gc> {
self.bounds
}

pub fn interior_bounds(&self) -> BoxBounds<Twips> {
self.interior_bounds
}

pub fn start(&self) -> usize {
self.start
}
Expand Down Expand Up @@ -1000,14 +972,6 @@ pub struct LayoutBox<'gc> {
#[collect(require_static)]
bounds: BoxBounds<Twips>,

/// The rectangle corresponding to the bounds of the rendered content,
/// i.e. the smallest rectangle that contains all glyphs.
///
/// TODO Currently, only text boxes have meaningful bounds.
/// TODO [KJ] Can't we replace it with bounds?
#[collect(require_static)]
interior_bounds: BoxBounds<Twips>,

/// What content is contained by the content box.
content: LayoutContent<'gc>,
}
Expand Down Expand Up @@ -1137,7 +1101,6 @@ impl<'gc> LayoutBox<'gc> {
});

Self {
interior_bounds: Default::default(),
bounds: Default::default(),
content: LayoutContent::Text {
start,
Expand All @@ -1156,7 +1119,6 @@ impl<'gc> LayoutBox<'gc> {
let params = EvalParameters::from_span(span);

Self {
interior_bounds: Default::default(),
bounds: Default::default(),
content: LayoutContent::Bullet {
position,
Expand All @@ -1171,7 +1133,6 @@ impl<'gc> LayoutBox<'gc> {
/// Construct a drawing.
pub fn from_drawing(position: usize, drawing: Drawing) -> Self {
Self {
interior_bounds: Default::default(),
bounds: Default::default(),
content: LayoutContent::Drawing { position, drawing },
}
Expand Down Expand Up @@ -1313,10 +1274,6 @@ impl<'gc> LayoutBox<'gc> {
self.bounds
}

pub fn interior_bounds(&self) -> BoxBounds<Twips> {
self.interior_bounds
}

pub fn content(&self) -> &LayoutContent<'gc> {
&self.content
}
Expand Down

0 comments on commit 937b2fd

Please sign in to comment.