mirror of
https://github.com/servo/servo.git
synced 2025-06-28 19:13:41 +01:00
Replace a large tuple return type with a new struct
This commit is contained in:
parent
038f83fbc5
commit
607df04849
1 changed files with 26 additions and 12 deletions
|
@ -120,8 +120,11 @@ impl InlineFormattingContext {
|
||||||
add!(last_fragment, inline_end);
|
add!(last_fragment, inline_end);
|
||||||
},
|
},
|
||||||
InlineLevelBox::TextRun(text_run) => {
|
InlineLevelBox::TextRun(text_run) => {
|
||||||
let (_, _, _, runs, break_at_start) =
|
let BreakAndShapeResult {
|
||||||
text_run.break_and_shape(layout_context);
|
runs,
|
||||||
|
break_at_start,
|
||||||
|
..
|
||||||
|
} = text_run.break_and_shape(layout_context);
|
||||||
if break_at_start {
|
if break_at_start {
|
||||||
self.line_break_opportunity()
|
self.line_break_opportunity()
|
||||||
}
|
}
|
||||||
|
@ -486,11 +489,16 @@ fn layout_atomic<'box_tree>(
|
||||||
.push(Fragment::Box(fragment));
|
.push(Fragment::Box(fragment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct BreakAndShapeResult {
|
||||||
|
font_ascent: Au,
|
||||||
|
font_line_gap: Au,
|
||||||
|
font_key: FontInstanceKey,
|
||||||
|
runs: Vec<GlyphRun>,
|
||||||
|
break_at_start: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl TextRun {
|
impl TextRun {
|
||||||
fn break_and_shape(
|
fn break_and_shape(&self, layout_context: &LayoutContext) -> BreakAndShapeResult {
|
||||||
&self,
|
|
||||||
layout_context: &LayoutContext,
|
|
||||||
) -> (Au, Au, FontInstanceKey, Vec<GlyphRun>, bool) {
|
|
||||||
use gfx::font::ShapingFlags;
|
use gfx::font::ShapingFlags;
|
||||||
use style::computed_values::text_rendering::T as TextRendering;
|
use style::computed_values::text_rendering::T as TextRendering;
|
||||||
use style::computed_values::word_break::T as WordBreak;
|
use style::computed_values::word_break::T as WordBreak;
|
||||||
|
@ -537,20 +545,26 @@ impl TextRun {
|
||||||
&mut None,
|
&mut None,
|
||||||
);
|
);
|
||||||
|
|
||||||
(
|
BreakAndShapeResult {
|
||||||
font.metrics.ascent,
|
font_ascent: font.metrics.ascent,
|
||||||
font.metrics.line_gap,
|
font_line_gap: font.metrics.line_gap,
|
||||||
font.font_key,
|
font_key: font.font_key,
|
||||||
runs,
|
runs,
|
||||||
break_at_start,
|
break_at_start,
|
||||||
)
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(&self, layout_context: &LayoutContext, ifc: &mut InlineFormattingContextState) {
|
fn layout(&self, layout_context: &LayoutContext, ifc: &mut InlineFormattingContextState) {
|
||||||
use style::values::generics::text::LineHeight;
|
use style::values::generics::text::LineHeight;
|
||||||
|
|
||||||
let (font_ascent, font_line_gap, font_key, runs, _) = self.break_and_shape(layout_context);
|
let BreakAndShapeResult {
|
||||||
|
font_ascent,
|
||||||
|
font_line_gap,
|
||||||
|
font_key,
|
||||||
|
runs,
|
||||||
|
break_at_start: _,
|
||||||
|
} = self.break_and_shape(layout_context);
|
||||||
let font_size = self.parent_style.get_font().font_size.size.0;
|
let font_size = self.parent_style.get_font().font_size.size.0;
|
||||||
let mut runs = runs.iter();
|
let mut runs = runs.iter();
|
||||||
loop {
|
loop {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue