зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536871 - Make 'line-height: normal' return the 'normal' keyword from getComputedStyle() on Nightly and Early Beta, for now. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D25119 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e6d794f2b0
Коммит
b301149caa
|
@ -97,7 +97,7 @@ const testMaxWidth = async function(editor) {
|
|||
function getLines(textarea) {
|
||||
const win = textarea.ownerDocument.defaultView;
|
||||
const style = win.getComputedStyle(textarea);
|
||||
return Math.floor(textarea.clientHeight / parseFloat(style.lineHeight));
|
||||
return Math.floor(textarea.clientHeight / parseFloat(style.fontSize));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -652,7 +652,7 @@ asserts(4) == 368155-negative-margins-1.html 368155-negative-margins-1-ref.html
|
|||
== 370629-1.html 370629-1-ref.html
|
||||
== 370629-2.html 370629-2-ref.html
|
||||
== 370692-1.xhtml 370692-1-ref.xhtml
|
||||
== 371041-1.html 371041-1-ref.html
|
||||
pref(layout.css.line-height.normal-as-resolved-value.enabled,false) == 371041-1.html 371041-1-ref.html
|
||||
== 371043-1.html 371043-1-ref.html
|
||||
== 371354-1.html 371354-1-ref.html
|
||||
== 371483-1.html about:blank # assertion test
|
||||
|
|
|
@ -2104,8 +2104,17 @@ bool nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord) {
|
|||
AssertFlushedPendingReflows();
|
||||
|
||||
nscoord blockHeight = NS_UNCONSTRAINEDSIZE;
|
||||
if (StyleText()->mLineHeight.IsMozBlockHeight()) {
|
||||
if (!mInnerFrame) return false;
|
||||
const auto& lh = StyleText()->mLineHeight;
|
||||
|
||||
if (lh.IsNormal() &&
|
||||
StaticPrefs::layout_css_line_height_normal_as_resolved_value_enabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lh.IsMozBlockHeight()) {
|
||||
if (!mInnerFrame) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::IsNonWrapperBlock(mInnerFrame)) {
|
||||
blockHeight = mInnerFrame->GetContentRect().height;
|
||||
|
|
|
@ -5435,6 +5435,34 @@ VARCACHE_PREF(
|
|||
bool, true
|
||||
)
|
||||
|
||||
// Whether the computed value of line-height: normal returns the `normal`
|
||||
// keyword rather than a pixel value based on the first available font.
|
||||
//
|
||||
// Only enabled on Nightly and early beta, at least for now.
|
||||
//
|
||||
// NOTE(emilio): If / when removing this pref, the GETCS_NEEDS_LAYOUT_FLUSH flag
|
||||
// should be removed from line-height (and we should let -moz-block-height
|
||||
// compute to the keyword as well, which shouldn't be observable anyway since
|
||||
// it's an internal value).
|
||||
//
|
||||
// It'd be nice to make numbers compute also to themselves, but it looks like
|
||||
// everybody agrees on turning them into pixels, see the discussion starting
|
||||
// from [1].
|
||||
//
|
||||
// [1]: https://github.com/w3c/csswg-drafts/issues/3749#issuecomment-477287453
|
||||
#ifdef EARLY_BETA_OR_EARLIER
|
||||
#define PREF_VALUE true
|
||||
#else
|
||||
#define PREF_VALUE false
|
||||
#endif
|
||||
VARCACHE_PREF(
|
||||
Live,
|
||||
"layout.css.line-height.normal-as-resolved-value.enabled",
|
||||
layout_css_line_height_normal_as_resolved_value_enabled,
|
||||
bool, PREF_VALUE
|
||||
)
|
||||
#undef PREF_VALUE
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Prefs starting with "media."
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Test: line-height resolved value</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/cssom/#resolved-values">
|
||||
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/3749">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
div { font-size: 16px; }
|
||||
</style>
|
||||
<div style="line-height: normal" data-expected="normal"></div>
|
||||
<div style="line-height: 1" data-expected="16px"></div>
|
||||
<div style="line-height: 10px" data-expected="10px"></div>
|
||||
<div style="line-height: 10%" data-expected="1.6px"></div>
|
||||
<script>
|
||||
for (const e of document.querySelectorAll("div")) {
|
||||
const specified = e.style.lineHeight;
|
||||
test(function() {
|
||||
const expected = e.getAttribute("data-expected");
|
||||
assert_equals(getComputedStyle(e).lineHeight, expected, specified + " should compute to " + expected);
|
||||
}, "line-height: " + specified);
|
||||
}
|
||||
</script>
|
|
@ -26,9 +26,10 @@ select { line-height:100px; }
|
|||
<script>
|
||||
document.body.offsetHeight;
|
||||
var cv = window.getComputedStyle(document.querySelector('select')).lineHeight;
|
||||
if (cv == "normal" || parseInt(cv) > 50) {
|
||||
if (cv != "normal" && parseInt(cv) > 50) {
|
||||
document.body.appendChild(document.createTextNode(
|
||||
"FAIL: got computed line-height '" + cv + "', expected a length <= 50px"));
|
||||
"FAIL: got computed line-height '" + cv + "', " +
|
||||
"expected 'normal' or a length <= 50px"));
|
||||
}</script>
|
||||
|
||||
</body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче