Jelajahi Sumber

Map legacy -webkit-box display to block

The line-clamp idiom used by tagesschau teasers must lay out as a normal block; otherwise its text can collapse to zero height. Adds ladder 060.
Johannes Zellner 1 Minggu lalu
induk
melakukan
80f115360f

+ 8 - 0
browser_html.c

@@ -3155,6 +3155,14 @@ static int parse_display(const char *s, unsigned int len)
 		return BR_DISPLAY_FLEX;
 	if (i == 11 && ci_eq_n(s, "inline-flex", 11))
 		return BR_DISPLAY_FLEX;
+	/* Legacy -webkit-box is the line-clamp idiom; render it as a normal
+	 * block instead of an inline box. */
+	if (i == 11 && ci_eq_n(s, "-webkit-box", 11))
+		return BR_DISPLAY_BLOCK;
+	if (i == 8 && ci_eq_n(s, "-moz-box", 8))
+		return BR_DISPLAY_BLOCK;
+	if (i == 11 && ci_eq_n(s, "-ms-flexbox", 11))
+		return BR_DISPLAY_FLEX;
 	if (i == 5 && ci_eq_n(s, "table", 5))
 		return BR_DISPLAY_BLOCK;
 	if (i == 10 && ci_eq_n(s, "table-cell", 10))

+ 38 - 0
testdata/browser/compat/060-webkit-box.html

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>060 legacy -webkit-box</title>
+<style>
+  body { background: #ffffff; color: #202020; font-family: sans-serif;
+         margin: 12px; font-size: 18px; }
+  #box { display: -webkit-box; -webkit-box-orient: vertical;
+         -webkit-line-clamp: 2; width: 260px; overflow: hidden;
+         background: #eeeeff; font-size: 24px; }
+  #result { background: #ffc8c8; color: #000000; padding: 8px;
+            margin-top: 12px; }
+</style>
+</head>
+<body>
+<h1>060 &mdash; legacy -webkit-box</h1>
+<p>The line-clamp idiom must render as a normal block so the text keeps its
+   height and remains visible.</p>
+<div id="box"><span>alpha beta</span><span>gamma delta</span></div>
+<div id="result">checking...</div>
+<script>
+setTimeout(function () {
+  var b = document.getElementById('box');
+  var r = b.getBoundingClientRect();
+  var d = getComputedStyle(b).display;
+  var ok = d === 'block' && r.height > 10 && r.width > 200;
+  var out = document.getElementById('result');
+  if (out) {
+    out.style.background = ok ? '#c8f0c8' : '#ffc8c8';
+    out.textContent = (ok ? 'WEBKIT-BOX-OK ' : 'WEBKIT-BOX-FAIL ') +
+                      'display=' + d + ' ' + Math.round(r.width) + 'x' +
+                      Math.round(r.height);
+  }
+}, 300);
+</script>
+</body>
+</html>

+ 1 - 1
testdata/browser/compat/README

@@ -17,7 +17,7 @@ Serve this directory from the host and open it on the board:
   browser http://<host>:8000/            # board
   browser http://10.0.2.2:8000/         # QEMU with -netdev user
 
-Status: 010-059 and 030a pass.  036a needs the POST echo server:
+Status: 010-060 and 030a pass.  036a needs the POST echo server:
 
   python3 testdata/browser/compat/post_server.py
   browser /floppy1/036a.htm      # action is http://10.0.2.2:8765/echo

+ 1 - 0
testdata/browser/compat/index.html

@@ -82,6 +82,7 @@ a { color: #0645ad; }
 <tr><td>057</td><td><a href="057-flex-outer-width.html">flex outer widths</a></td><td>margins/padding in flex item widths, default nowrap</td><td class="pass">PASS</td></tr>
 <tr><td>058</td><td><a href="058-svg-viewbox-fill.html">SVG viewBox and fill</a></td><td>fractional viewBox, percentage rect and fill attribute</td><td class="pass">PASS</td></tr>
 <tr><td>059</td><td><a href="059-absolute-image.html">absolute image</a></td><td>poster fills its positioned ancestor, percentage width</td><td class="pass">PASS</td></tr>
+<tr><td>060</td><td><a href="060-webkit-box.html">legacy -webkit-box</a></td><td>line-clamp display renders as a block</td><td class="pass">PASS</td></tr>
 </table>
 </body>
 </html>