diff --git a/devtools/client/shared/test/browser_inplace-editor_maxwidth.js b/devtools/client/shared/test/browser_inplace-editor_maxwidth.js index 2524ff43c9c6..c68666ef7f76 100644 --- a/devtools/client/shared/test/browser_inplace-editor_maxwidth.js +++ b/devtools/client/shared/test/browser_inplace-editor_maxwidth.js @@ -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)); } /** diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index bc2a5915f089..7d5d881e3d58 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -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 diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 7b613ba23d22..cc79361c2825 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -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; diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index d3ba68d5c88c..03ca3afab8fd 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -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." //--------------------------------------------------------------------------- diff --git a/testing/web-platform/tests/css/cssom/getComputedStyle-line-height.html b/testing/web-platform/tests/css/cssom/getComputedStyle-line-height.html new file mode 100644 index 000000000000..089a6d848510 --- /dev/null +++ b/testing/web-platform/tests/css/cssom/getComputedStyle-line-height.html @@ -0,0 +1,23 @@ + + +CSS Test: line-height resolved value + + + + + +
+
+
+
+ diff --git a/testing/web-platform/tests/html/rendering/replaced-elements/the-select-element/select-1-line-height.html b/testing/web-platform/tests/html/rendering/replaced-elements/the-select-element/select-1-line-height.html index e6383f089ffa..605a988e255c 100644 --- a/testing/web-platform/tests/html/rendering/replaced-elements/the-select-element/select-1-line-height.html +++ b/testing/web-platform/tests/html/rendering/replaced-elements/the-select-element/select-1-line-height.html @@ -26,9 +26,10 @@ select { line-height:100px; }