mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix computed values of 'font-weight' to report integers for bold (like for normal) and to report usable values for bolder/lighter. (Bug 173331, Bug 77882) r=bzbarsky
This commit is contained in:
parent
d2de4eeb32
commit
d7d8f0ef43
@ -1257,14 +1257,17 @@ nsComputedDOMStyle::GetFontWeight(nsIDOMCSSValue** aValue)
|
||||
|
||||
const nsStyleFont* font = GetStyleFont();
|
||||
|
||||
// XXX This doesn't deal with bolder/lighter very well.
|
||||
const nsCSSKeyword enum_weight =
|
||||
nsCSSProps::ValueToKeywordEnum(font->mFont.weight,
|
||||
nsCSSProps::kFontWeightKTable);
|
||||
if (enum_weight != eCSSKeyword_UNKNOWN) {
|
||||
val->SetIdent(enum_weight);
|
||||
} else {
|
||||
PRUint16 weight = font->mFont.weight;
|
||||
if (weight % 100 == 0) {
|
||||
val->SetNumber(font->mFont.weight);
|
||||
} else if (weight % 100 > 50) {
|
||||
// FIXME: This doesn't represent the full range of computed values,
|
||||
// but at least it's legal CSS.
|
||||
val->SetIdent(eCSSKeyword_lighter);
|
||||
} else {
|
||||
// FIXME: This doesn't represent the full range of computed values,
|
||||
// but at least it's legal CSS.
|
||||
val->SetIdent(eCSSKeyword_bolder);
|
||||
}
|
||||
|
||||
return CallQueryInterface(val, aValue);
|
||||
|
@ -1361,7 +1361,7 @@ var gCSSProperties = {
|
||||
inherited: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "normal", "400" ],
|
||||
other_values: [ "bold", "100", "200", "300", "500", "600", "700", "800", "900" ],
|
||||
other_values: [ "bold", "100", "200", "300", "500", "600", "700", "800", "900", "bolder", "lighter" ],
|
||||
invalid_values: [ "107", "399", "401", "699", "710" ]
|
||||
},
|
||||
"height": {
|
||||
|
@ -460,21 +460,20 @@ function test_font_weight(prop) {
|
||||
|
||||
div.style.setProperty("-moz-transition-property", "none", "");
|
||||
div.style.setProperty(prop, "normal", "");
|
||||
is(cs.getPropertyValue(prop), "normal",
|
||||
is(cs.getPropertyValue(prop), "400",
|
||||
"font-weight property " + prop + ": computed value before transition");
|
||||
div.style.setProperty("-moz-transition-property", prop, "");
|
||||
div.style.setProperty(prop, "900", "");
|
||||
is(cs.getPropertyValue(prop), "600",
|
||||
"font-weight property " + prop + ": interpolation of font-weights");
|
||||
div.style.setProperty(prop, "lighter", "");
|
||||
// We currently get 399; mark this as todo.
|
||||
todo_is(cs.getPropertyValue(prop), "lighter",
|
||||
is(cs.getPropertyValue(prop), "lighter",
|
||||
"font-weight property " + prop + ": can't interpolate bolder/lighter");
|
||||
div.style.setProperty(prop, "700", "");
|
||||
is(cs.getPropertyValue(prop), "bold",
|
||||
is(cs.getPropertyValue(prop), "700",
|
||||
"font-weight property " + prop + ": computed value before transition");
|
||||
div.style.setProperty(prop, "100", "");
|
||||
is(cs.getPropertyValue(prop), "normal",
|
||||
is(cs.getPropertyValue(prop), "400",
|
||||
"font-weight property " + prop + ": interpolation of font-weights");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user