Commit cdbca9b9 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Fix access of 'from-font' underline thickness

FontMetrics::UnderlineThickness() returns an Optional<float>, but this
code was dereferencing the value without checking if there was one
(using value()). This made the following check of the Optional<>
dead/redundant.

Instead receive the Optional<> without dereferencing it. Also use
value_or(...) to return the auto value or the specified value depending
on if the latter exists or not.

Bug: 785230
Change-Id: Id85ac107600ef26f2edc738048abe657b9db3bf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2238932Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#777292}
parent 3dc68f2d
...@@ -361,12 +361,9 @@ float ComputeDecorationThickness(const ComputedStyle* style, ...@@ -361,12 +361,9 @@ float ComputeDecorationThickness(const ComputedStyle* style,
if (style_thickness.IsFromFont()) { if (style_thickness.IsFromFont()) {
base::Optional<float> underline_thickness_font_metric = base::Optional<float> underline_thickness_font_metric =
font_data->GetFontMetrics().UnderlineThickness().value(); font_data->GetFontMetrics().UnderlineThickness();
return std::max(1.f, underline_thickness_font_metric.value_or(
if (!underline_thickness_font_metric) auto_underline_thickness));
return auto_underline_thickness;
return std::max(1.f, underline_thickness_font_metric.value());
} }
DCHECK(!style_thickness.IsFromFont()); DCHECK(!style_thickness.IsFromFont());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment