Commit bc916f13 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Update 'lighter' and 'bolder' computations to match spec

Update FontDescription::BolderWeight and LighterWeight to match the table
in https://drafts.csswg.org/css-fonts-4/#font-weight-prop .

Bug: 809956
Change-Id: I18cb9a10ef3d86f68113bb0663e5364d0120a739
Reviewed-on: https://chromium-review.googlesource.com/997592
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548741}
parent 8478a8f1
......@@ -2916,7 +2916,6 @@ crbug.com/666993 external/wpt/requestidlecallback/callback-idle-periods.html [ T
# Crashes with DCHECK enabled, but not on normal Release builds.
crbug.com/809935 external/wpt/css/css-fonts/variations/font-style-interpolation.html [ Timeout ]
crbug.com/809956 external/wpt/css/css-fonts/variations/font-weight-lighter-bolder.html [ Failure ]
crbug.com/626703 external/wpt/css/css-ui/text-overflow-011.html [ Failure Crash Pass ]
crbug.com/626703 external/wpt/workers/opaque-origin.html [ Failure Crash Timeout ]
crbug.com/626703 external/wpt/html/rendering/non-replaced-elements/margin-collapsing-quirks/multicol-quirks-mode.html [ Pass Crash ]
......
......@@ -113,30 +113,38 @@ bool FontDescription::operator==(const FontDescription& other) const {
*variation_settings_ == *other.variation_settings_));
}
// Compute a 'lighter' weight per
// https://drafts.csswg.org/css-fonts-4/#font-weight-prop
FontSelectionValue FontDescription::LighterWeight(FontSelectionValue weight) {
// TODO(fs): Adjust to match table in
// https://drafts.csswg.org/css-fonts-4/#font-weight-prop
if (weight < FontSelectionValue(501))
DCHECK(weight >= FontSelectionValue(1) && weight <= FontSelectionValue(1000));
// [1, 100) => No change
if (weight < FontSelectionValue(100))
return weight;
// [100, 550) => 100
if (weight < FontSelectionValue(550))
return FontSelectionValue(100);
if (weight < FontSelectionValue(701))
// [550, 750) => 400
if (weight < FontSelectionValue(750))
return FontSelectionValue(400);
if (weight <= FontSelectionValue(1000))
return FontSelectionValue(700);
NOTREACHED();
return NormalWeightValue();
// [750, 1000] => 700
return FontSelectionValue(700);
}
// Compute a 'bolder' weight per
// https://drafts.csswg.org/css-fonts-4/#font-weight-prop
FontSelectionValue FontDescription::BolderWeight(FontSelectionValue weight) {
// TODO(fs): Adjust to match table in
// https://drafts.csswg.org/css-fonts-4/#font-weight-prop
if (weight < FontSelectionValue(301))
DCHECK(weight >= FontSelectionValue(1) && weight <= FontSelectionValue(1000));
// [1, 350) => 400
if (weight < FontSelectionValue(350))
return FontSelectionValue(400);
if (weight < FontSelectionValue(501))
// [350, 550) => 700
if (weight < FontSelectionValue(550))
return FontSelectionValue(700);
if (weight <= FontSelectionValue(1000))
// [550, 900) => 900
if (weight < FontSelectionValue(900))
return FontSelectionValue(900);
NOTREACHED();
return NormalWeightValue();
// [900, 1000] => No change
return weight;
}
FontDescription::Size FontDescription::LargerSize(const Size& size) {
......
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