Bug 1551065 - Properly discard empty lines for -webkit-line-clamp. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 13 May 2019 09:14:33 +0000
changeset 532402 430b79a1444fd6935ea68abfbdb7a53d8e572b78
parent 532401 0867f9a289a712042a2d915be5142ae6d9fcd616
child 532403 4b8f9814a1ea6f412d1f02c2701096b048cd0707
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1551065
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551065 - Properly discard empty lines for -webkit-line-clamp. r=heycam That being said, this code is clearly not getting hit, are we 100% sure that this is interoperable with what WebKit / Blink do? Differential Revision: https://phabricator.services.mozilla.com/D30830
layout/generic/nsBlockFrame.cpp
testing/web-platform/tests/css/css-overflow/webkit-line-clamp-033.html
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -1671,16 +1671,17 @@ static nsLineBox* FindLineClampTarget(ns
                "Should have been removed earlier in nsBlockFrame::Reflow");
     MOZ_ASSERT(!iter.GetCurrentFrame()->HasAnyStateBits(
                    NS_BLOCK_HAS_LINE_CLAMP_ELLIPSIS),
                "Should have been removed earlier in nsBlockReflow::Reflow");
 
     // Don't count a line that only has collapsible white space (as might exist
     // after calling e.g. getBoxQuads).
     if (line->IsEmpty()) {
+      iter.Next();
       continue;
     }
 
     if (aLineNumber == 0) {
       // We already previously found our target line, and now we have
       // confirmed that there is another line after it.
       foundFollowingLine = true;
       break;
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overflow/webkit-line-clamp-033.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Overflow: -webkit-line-clamp with an empty line</title>
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
+<link rel="help" href="https://drafts.csswg.org/css-overflow-3/#webkit-line-clamp">
+<link rel="match" href="about:blank">
+<style>
+.clamp {
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 3;
+  font: 16px / 32px serif;
+  white-space: pre;
+  background-color: yellow;
+  padding: 0 4px;
+  overflow: hidden; /* can be removed once implementations update their old -webkit-line-clamp implementations */
+}
+</style>
+<div class="clamp"><div><span></span></div></div>