Repository: servo/servo
File: components/layout/display_list/mod.rs (Rust)

Code before:
) -> (Vec<GlyphInstance>, Au) {
    let mut glyphs = vec![];
    let mut largest_advance = Au::zero();

    for run in glyph_runs {
        for glyph in run.glyphs() {
            if !run.is_whitespace() || include_whitespace {
                let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
                let point = LayoutPoint::new(
                    baseline_origin.x.to_f32_px() + glyph_offset.x.to_f32_px(),
                    baseline_origin.y.to_f32_px() + glyph_offset.y.to_f32_px(),
                );
                let glyph_instance = GlyphInstance {
                    index: glyph.id(),
                    point,
                };
                glyphs.push(glyph_instance);
            }

            if glyph.char_is_word_separator() {
                baseline_origin.x += justification_adjustment;
            }

            let advance = glyph.advance();
            baseline_origin.x += advance;
            largest_advance = largest_advance.max(advance);
        }
    }
    (glyphs, largest_advance)
}

/// Given a set of corner radii for a rectangle, this function returns the corresponding radii
/// for the [outer rectangle][`Rect::outer_rect`] resulting from expanding the original
/// rectangle by the given offsets.
fn offset_radii(mut radii: BorderRadius, offsets: LayoutSideOffsets) -> BorderRadius {
    let expand = |radius: &mut f32, offset: f32| {
        // For negative offsets, just shrink the radius by that amount.
        if offset < 0.0 {
            *radius = (*radius + offset).max(0.0);
            return;
        }

        // For positive offsets, expand the radius by that amount. But only if the
        // radius is positive, in order to preserve sharp corners.
        // TODO: this behavior is not continuous, we should use this algorithm instead:
        // https://github.com/w3c/csswg-drafts/issues/7103#issuecomment-3357331922
        if *radius > 0.0 {
            *radius += offset;
        }
    };
    if offsets.left != 0.0 {

Review comment (suggestion):
Nit:

```suggestion
            largest_advance.max_assign(advance)
```

Code after:
) -> (Vec<GlyphInstance>, Au) {
    let mut glyphs = vec![];
    let mut largest_advance = Au::zero();

    for run in glyph_runs {
        for glyph in run.glyphs() {
            if !run.is_whitespace() || include_whitespace {
                let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
                let point = LayoutPoint::new(
                    baseline_origin.x.to_f32_px() + glyph_offset.x.to_f32_px(),
                    baseline_origin.y.to_f32_px() + glyph_offset.y.to_f32_px(),
                );
                let glyph_instance = GlyphInstance {
                    index: glyph.id(),
                    point,
                };
                glyphs.push(glyph_instance);
            }

            if glyph.char_is_word_separator() {
                baseline_origin.x += justification_adjustment;
            }

            let advance = glyph.advance();
            baseline_origin.x += advance;
            largest_advance.max_assign(advance);
        }
    }
    (glyphs, largest_advance)
}

/// Given a set of corner radii for a rectangle, this function returns the corresponding radii
/// for the [outer rectangle][`Rect::outer_rect`] resulting from expanding the original
/// rectangle by the given offsets.
fn offset_radii(mut radii: BorderRadius, offsets: LayoutSideOffsets) -> BorderRadius {
    let expand = |radius: &mut f32, offset: f32| {
        // For negative offsets, just shrink the radius by that amount.
        if offset < 0.0 {
            *radius = (*radius + offset).max(0.0);
            return;
        }

        // For positive offsets, expand the radius by that amount. But only if the
        // radius is positive, in order to preserve sharp corners.
        // TODO: this behavior is not continuous, we should use this algorithm instead:
        // https://github.com/w3c/csswg-drafts/issues/7103#issuecomment-3357331922
        if *radius > 0.0 {
            *radius += offset;
        }
    };
    if offsets.left != 0.0 {