haikuwebkit/LayoutTests/css3/font-weight-multiple-select...

44 lines
1.4 KiB
HTML
Raw Permalink Normal View History

Match spec for font-weight: bolder|lighter https://bugs.webkit.org/show_bug.cgi?id=137919 Patch by Tibor Meszaros <tmeszaros.u-szeged@partner.samsung.com> on 2014-10-22 Reviewed by Andreas Kling. This patch is a merge of Blink's Source/WebCore: https://chromiumcodereview.appspot.com/15994009 Currently, bolder and lighter change font-weight in a non-compliant way. The spec (http://www.w3.org/TR/css3-fonts/#bolderlighter) defines exactly what the computed values should be given the inherited weight values, so we should match those. The removed FIXME's for selecting the next lightest/heaviest weight from the used font family seems to refer to behaviour from CSS1 (http://www.w3.org/TR/CSS1/#font-weight), while this is replaced with a simpler procedure for resolving bolder and lighter in font weights in CSS2 (http://www.w3.org/TR/CSS2/fonts.html#propdef-font-weight) and CSS3 (link above). and https://codereview.chromium.org/137813004 According to http://dev.w3.org/csswg/css-fonts/#font-weight-prop, the computed weight of 'lighter' and 'bolder' are based on the inherited 'font-weight', so set that inherited weight before calculating 'lighter' and 'bolder'. Tests: css3/font-weight-multiple-selectors.html css3/font-weight.html * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyFontWeight::applyValue): * platform/graphics/FontDescription.cpp: (WebCore::FontDescription::lighterWeight): (WebCore::FontDescription::bolderWeight): LayoutTests: https://chromiumcodereview.appspot.com/15994009 and https://codereview.chromium.org/137813004 * css3/font-weight-expected.txt: Added. * css3/font-weight-multiple-selectors-expected.txt: Added. * css3/font-weight-multiple-selectors.html: Added. * css3/font-weight.html: Added. Canonical link: https://commits.webkit.org/155818@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175043 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-10-22 11:16:39 +00:00
<html>
<head>
<style>
#outer > div { font-weight: bolder; }
#outer > div#bolder { font-weight: bolder; }
#outer > div#lighter { font-weight: lighter; }
</style>
<script src="../resources/js-test.js"></script>
</head>
<body>
<div id="outer">
<div id="bolder"></div>
<div id="lighter"></div>
</div>
<div id="console"></div>
<script>
description('Test that font-weight: bolder and font-weight: lighter are not cumulative when multiple selectors apply.');
table = [
["100" , "100" , "normal", "100"],
["200" , "200" , "normal", "100"],
["300" , "300" , "normal", "100"],
["400" , "normal", "bold" , "100"],
["normal", "normal", "bold" , "100"],
["500" , "500" , "bold" , "100"],
["600" , "600" , "900" , "normal"],
["700" , "bold" , "900" , "normal"],
["bold" , "bold" , "900" , "normal"],
["800" , "800" , "900" , "bold"],
["900" , "900" , "900" , "bold"],
];
var outer = document.getElementById("outer");
var bolder = document.getElementById("bolder");
var lighter = document.getElementById("lighter");
for(var i=0; i<table.length; i++) {
outer.style.fontWeight = table[i][0];
shouldBeEqualToString('getComputedStyle(outer).fontWeight', table[i][1]);
shouldBeEqualToString('getComputedStyle(bolder).fontWeight', table[i][2]);
shouldBeEqualToString('getComputedStyle(lighter).fontWeight', table[i][3]);
}
</script>
</body>
</html>