ソースを参照

Add browser legacy bgcolor attributes

Johannes Zellner 1 週間 前
親
コミット
1324c4c402

+ 3 - 2
AGENTS.md

@@ -811,7 +811,8 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   the browser both use it.  `browser_html.c/h` is a tolerant HTML tree + the
   CSS subset: external `<link rel=stylesheet>` sheets (in document order,
   inline `<style>` last), tag/class/id and descendant/child selectors,
-  colours/`rgba()`, solid backgrounds and `background-image` with
+  colours/`rgba()`, legacy `bgcolor` attributes, solid backgrounds and
+  `background-image` with
   `repeat`/`position`/`size` (`auto` keeps the legacy stretch, `cover` and
   `contain` scale the image), plus the `background` shorthand URL,
   font size (`px`/`%`/`em`/`rem`, resolved against the parent for `em`/`%`),
@@ -831,7 +832,7 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   `@font-face` loads one regular TTF per family from a local path or HTTP URL
   (the browser fetches remote faces before layout).  The compatibility
   ladder is `testdata/browser/compat/`
-  (`make compat-serve`); pages 010–044 and 030a pass (036a needs the
+  (`make compat-serve`); pages 010–045 and 030a pass (036a needs the
   POST echo server).  Inline
   `<svg>` subtrees and closed `<details>` are skipped (not renderable), and
   `<video>` gets a placeholder box.  The default page canvas follows

+ 12 - 0
browser_html.c

@@ -6766,6 +6766,18 @@ void br_style_for(struct br_doc *d, unsigned int node,
 		break;
 	}
 
+	/* Legacy bgcolor attributes (tables/cells/body) are presentational
+	 * hints; author CSS still wins because it is applied below. */
+	{
+		unsigned short bgc;
+		const char *bga = br_find_attr(d, node, "bgcolor");
+
+		if (bga && parse_color(bga, s_len(bga), &bgc)) {
+			out->bg = bgc;
+			out->has_bg = 1;
+		}
+	}
+
 	/* presentational <font color>: author CSS below still wins */
 	if (d->nodes[node].color_off) {
 		unsigned short c;

ファイルの差分が大きいため隠しています
+ 1 - 1
docs/userland.html


+ 35 - 0
testdata/browser/compat/045-bgcolor.html

@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>045 bgcolor attribute</title>
+<style>
+html, body { margin: 0; padding: 0; background: #ffffff; color: #202020; }
+body { font-family: sans-serif; font-size: 13px; padding: 10px; }
+h1 { font-size: 20px; margin: 0 0 6px 0; }
+p { margin: 0 0 10px 0; }
+.pane { float: left; width: 440px; margin-left: 10px; }
+.label { background: #eeeeee; padding: 4px 6px; margin-bottom: 4px; }
+table { border: 1px solid #999999; border-collapse: collapse; }
+td { padding: 8px; }
+</style>
+</head>
+<body>
+<h1>045 &middot; legacy bgcolor</h1>
+<p>A uses the HTML bgcolor attributes; B uses CSS backgrounds with the same colours.</p>
+<div class="pane">
+  <div class="label">A &middot; bgcolor attribute</div>
+  <table bgcolor="#f6f6ef" width="260">
+    <tr><td bgcolor="#ff6600">header cell</td><td bgcolor="#3366cc">blue cell</td></tr>
+    <tr><td>body cell</td><td bgcolor="#33aa55">green cell</td></tr>
+  </table>
+</div>
+<div class="pane">
+  <div class="label">B &middot; CSS background-color</div>
+  <table style="background-color: #f6f6ef" width="260">
+    <tr><td style="background-color: #ff6600">header cell</td><td style="background-color: #3366cc">blue cell</td></tr>
+    <tr><td>body cell</td><td style="background-color: #33aa55">green cell</td></tr>
+  </table>
+</div>
+</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-044 and 030a pass.  036a needs the POST echo server:
+Status: 010-045 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

@@ -67,6 +67,7 @@ a { color: #0645ad; }
 <tr><td>042</td><td><a href="042-computed-style.html">computed style</a></td><td>getComputedStyle values and the display:none case</td><td class="pass">PASS</td></tr>
 <tr><td>043</td><td><a href="043-relative-zindex.html">relative z-index</a></td><td>z-index on position: relative overrides DOM paint order</td><td class="pass">PASS</td></tr>
 <tr><td>044</td><td><a href="044-overflow-hidden.html">overflow hidden</a></td><td>a block larger than its parent is clipped</td><td class="pass">PASS</td></tr>
+<tr><td>045</td><td><a href="045-bgcolor.html">legacy bgcolor</a></td><td>table/cell bgcolor matches CSS backgrounds</td><td class="pass">PASS</td></tr>
 </table>
 </body>
 </html>

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません