Ver Fonte

Add browser transform scale and rotate

Johannes Zellner há 1 semana atrás
pai
commit
e0f0991d57

+ 9 - 6
AGENTS.md

@@ -821,15 +821,16 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   `width`/`height` with `min`/`max` and `box-sizing: border-box`,
   `margin: 0 auto`, `calc(percent ± px)`, `white-space: nowrap`,
   `position: relative`/`absolute`/`fixed`/`sticky`, `right`/`bottom`,
-  `z-index`, `transform: translate`, flex rows with `justify-content`/
-  `align-items`, two-column grids, table colspan and percentage columns,
-  and basic `float: left/right` columns.
+  `z-index`, `transform: translate`/`scale`/`rotate` with
+  `transform-origin` (paint-time box and inline-image transforms), flex rows
+  with `justify-content`/`align-items`, two-column grids, table colspan and
+  percentage columns, and basic `float: left/right` columns.
   `@media (min-width/max-width)` blocks are evaluated against the browser
   canvas width when the page is parsed; `@import`/`@keyframes` are skipped.
   `@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–038 and 030a pass (036a needs the
+  (`make compat-serve`); pages 010–039 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
@@ -1546,8 +1547,10 @@ and the WM falls back to polling (`io_keyboard_irq_masked()`).
     than computed style.  Libraries that need those APIs (jQuery plugins
     beyond Bootstrap's tooltip, Angular apps that use `$http`) still log
     errors even though the static page renders.  CSS also lacks multiple
-    background layers, `background-attachment`, the rest of `transform`
-    (`translate` only), sticky beyond the top edge, border-radius clipping
+    background layers, `background-attachment`, 3D/perspective transforms
+    and transformed text/descendants (`scale`/`rotate` paint the element box
+    and inline images; layout geometry is unchanged), sticky beyond the top
+    edge, border-radius clipping
     of descendant content, gradients/box-shadow/transitions (a gradient
     background falls back to its last solid colour), or CSS `color-mix`.
     A non-uniform `background-size` uses the width scale for both axes.

+ 190 - 2
browser.c

@@ -12,6 +12,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <math.h>
 #include <ucmd_heap.h>
 
 #include "ucmd_lib.h"
@@ -175,6 +176,10 @@ struct lay_run {
 	unsigned short iw, ih;
 	unsigned short w;
 	unsigned char font_px, bold, italic, mono, underline, font_face;
+	unsigned char transform_scale;
+	unsigned char origin_x_kind, origin_y_kind;
+	signed short scale_x, scale_y, rotate_x100;
+	signed short origin_x, origin_y;
 	unsigned char has_lit;
 	unsigned int form;          /* node + 1, 0 = not a control */
 	unsigned char form_kind;
@@ -3033,6 +3038,171 @@ static void draw_border_box(struct ngui *ui, struct ngui_rect r,
 			       st->border_c[1]);
 }
 
+static void transform_origin(const struct br_style *st, int w, int h,
+			    int *ox, int *oy)
+{
+	*ox = st->origin_x_kind ? w * st->origin_x / 100 : st->origin_x;
+	*oy = st->origin_y_kind ? h * st->origin_y / 100 : st->origin_y;
+}
+
+static unsigned short blend_rgb565(unsigned short d, unsigned short s,
+				   unsigned int a)
+{
+	unsigned int dr, dg, db, sr, sg, sb;
+
+	if (a >= 255)
+		return s;
+	dr = (d >> 11) & 31;
+	dg = (d >> 5) & 63;
+	db = d & 31;
+	sr = (s >> 11) & 31;
+	sg = (s >> 5) & 63;
+	sb = s & 31;
+	dr = (dr * (255 - a) + sr * a) / 255;
+	dg = (dg * (255 - a) + sg * a) / 255;
+	db = (db * (255 - a) + sb * a) / 255;
+	return (unsigned short)((dr << 11) | (dg << 5) | db);
+}
+
+/* Paint a solid box through scale()/rotate() around transform-origin.  This
+ * transforms the element's own background box; text and descendants keep
+ * their layout (documented approximation). */
+static void fill_transformed_rect(struct ngui *gui, struct ngui_rect box,
+				  unsigned short color,
+				  const struct br_style *st)
+{
+	double sx = st->scale_x / 100.0;
+	double sy = st->scale_y / 100.0;
+	double th = st->rotate_x100 / 100.0 * 3.14159265358979 / 180.0;
+	double c = cos(th), sn = sin(th);
+	int ox, oy, minx, miny, maxx, maxy, x, y;
+	double ax, ay;
+	double px[4], py[4];
+	int cx1, cy1, cx2, cy2, i;
+
+	if (sx == 0)
+		sx = 0.01;
+	if (sy == 0)
+		sy = 0.01;
+	transform_origin(st, box.w, box.h, &ox, &oy);
+	ax = box.x + ox;
+	ay = box.y + oy;
+	px[0] = -ox; py[0] = -oy;
+	px[1] = box.w - ox; py[1] = -oy;
+	px[2] = box.w - ox; py[2] = box.h - oy;
+	px[3] = -ox; py[3] = box.h - oy;
+	minx = miny = 1000000;
+	maxx = maxy = -1000000;
+	for (i = 0; i < 4; i++) {
+		double rx = (px[i] * sx) * c - (py[i] * sy) * sn;
+		double ry = (px[i] * sx) * sn + (py[i] * sy) * c;
+		int dx = (int)(ax + rx), dy = (int)(ay + ry);
+
+		if (dx < minx) minx = dx;
+		if (dx > maxx) maxx = dx;
+		if (dy < miny) miny = dy;
+		if (dy > maxy) maxy = dy;
+	}
+	cx1 = page_rect.x > 0 ? page_rect.x : 0;
+	cy1 = page_rect.y > 0 ? page_rect.y : 0;
+	cx2 = page_rect.x + page_rect.w - 12;
+	cy2 = page_rect.y + page_rect.h;
+	if (cx2 > gui->w) cx2 = gui->w;
+	if (cy2 > gui->h) cy2 = gui->h;
+	if (minx < cx1) minx = cx1;
+	if (miny < cy1) miny = cy1;
+	if (maxx > cx2 - 1) maxx = cx2 - 1;
+	if (maxy > cy2 - 1) maxy = cy2 - 1;
+	for (y = miny; y <= maxy; y++) {
+		for (x = minx; x <= maxx; x++) {
+			double dx = x + 0.5 - ax, dy = y + 0.5 - ay;
+			double rx = dx * c + dy * sn;
+			double ry = -dx * sn + dy * c;
+			double bx = rx / sx + ox;
+			double by = ry / sy + oy;
+
+			if (bx >= 0 && bx < box.w && by >= 0 && by < box.h)
+				gui->px[y * gui->w + x] = color;
+		}
+	}
+}
+
+static void draw_image_transformed(struct ngui *gui,
+				   const struct img_image *im,
+				   int x, int y, int w, int h,
+				   int sx100, int sy100, int rot100,
+				   int origin_x, int origin_y,
+				   int origin_x_kind, int origin_y_kind)
+{
+	double sx = sx100 / 100.0, sy = sy100 / 100.0;
+	double th = rot100 / 100.0 * 3.14159265358979 / 180.0;
+	double c = cos(th), sn = sin(th);
+	int ox, oy, minx, miny, maxx, maxy, px, py, i;
+	double ax, ay;
+	double bx[4], by[4];
+	int cx1, cy1, cx2, cy2;
+
+	if (!im || !im->px || w <= 0 || h <= 0 || sx == 0 || sy == 0)
+		return;
+	ox = origin_x_kind ? w * origin_x / 100 : origin_x;
+	oy = origin_y_kind ? h * origin_y / 100 : origin_y;
+	ax = x + ox;
+	ay = y + oy;
+	bx[0] = -ox; by[0] = -oy;
+	bx[1] = w - ox; by[1] = -oy;
+	bx[2] = w - ox; by[2] = h - oy;
+	bx[3] = -ox; by[3] = h - oy;
+	minx = miny = 1000000;
+	maxx = maxy = -1000000;
+	for (i = 0; i < 4; i++) {
+		double rx = (bx[i] * sx) * c - (by[i] * sy) * sn;
+		double ry = (bx[i] * sx) * sn + (by[i] * sy) * c;
+		int dx = (int)(ax + rx), dy = (int)(ay + ry);
+
+		if (dx < minx) minx = dx;
+		if (dx > maxx) maxx = dx;
+		if (dy < miny) miny = dy;
+		if (dy > maxy) maxy = dy;
+	}
+	cx1 = page_rect.x > 0 ? page_rect.x : 0;
+	cy1 = page_rect.y > 0 ? page_rect.y : 0;
+	cx2 = page_rect.x + page_rect.w - 12;
+	cy2 = page_rect.y + page_rect.h;
+	if (cx2 > gui->w) cx2 = gui->w;
+	if (cy2 > gui->h) cy2 = gui->h;
+	if (minx < cx1) minx = cx1;
+	if (miny < cy1) miny = cy1;
+	if (maxx > cx2 - 1) maxx = cx2 - 1;
+	if (maxy > cy2 - 1) maxy = cy2 - 1;
+	for (py = miny; py <= maxy; py++) {
+		for (px = minx; px <= maxx; px++) {
+			double dx = px + 0.5 - ax, dy = py + 0.5 - ay;
+			double rx = dx * c + dy * sn;
+			double ry = -dx * sn + dy * c;
+			double fx = rx / sx + ox;
+			double fy = ry / sy + oy;
+			int ix, iy;
+			unsigned int si, a;
+			unsigned short src;
+
+			if (fx < 0 || fx >= w || fy < 0 || fy >= h)
+				continue;
+			ix = (int)(fx * (double)im->w / w);
+			iy = (int)(fy * (double)im->h / h);
+			if (ix < 0 || ix >= (int)im->w ||
+			    iy < 0 || iy >= (int)im->h)
+				continue;
+			si = (unsigned int)iy * im->w + (unsigned int)ix;
+			src = im->px[si];
+			a = im->alpha ? im->alpha[si] : 255;
+			gui->px[py * gui->w + px] =
+				a >= 255 ? src :
+				blend_rgb565(gui->px[py * gui->w + px],
+					     src, a);
+		}
+	}
+}
+
 static void draw_bg_image(struct lay *l, struct ngui_rect box,
 			  unsigned int node, const struct br_style *st)
 {
@@ -3308,7 +3478,14 @@ static void flush_line(struct lay *l)
 						  r->mono);
 			} else if (r->img >= 0) {
 				struct br_image *bi = &images[r->img];
-				if (bi->state == 1) {
+				if (bi->state == 1 && r->transform_scale) {
+					draw_image_transformed(l->ui, &bi->img,
+						x, ry, r->iw, r->ih,
+						r->scale_x, r->scale_y,
+						r->rotate_x100, r->origin_x,
+						r->origin_y, r->origin_x_kind,
+						r->origin_y_kind);
+				} else if (bi->state == 1) {
 					struct img_blit b;
 					b.dst = l->ui->px;
 					b.dst_w = l->ui->w;
@@ -3622,6 +3799,14 @@ static void add_image_run(struct lay *l, unsigned int node,
 		r->italic = st->italic;
 		r->mono = st->mono;
 		r->font_face = st->font_face;
+		r->transform_scale = st->transform_scale;
+		r->scale_x = st->scale_x;
+		r->scale_y = st->scale_y;
+		r->rotate_x100 = st->rotate_x100;
+		r->origin_x = st->origin_x;
+		r->origin_y = st->origin_y;
+		r->origin_x_kind = st->origin_x_kind;
+		r->origin_y_kind = st->origin_y_kind;
 		r->underline = 0;
 	}
 	if (node < BR_MAX_NODES) {
@@ -4372,7 +4557,10 @@ static void layout_block(struct lay *l, unsigned int node,
 		int rbr = css_radius(st, 2, box.w, box.h);
 		int rbl = css_radius(st, 3, box.w, box.h);
 
-		if (rtl || rtr || rbr || rbl) {
+		if (st->transform_scale) {
+			if (st->has_bg)
+				fill_transformed_rect(l->ui, box, st->bg, st);
+		} else if (rtl || rtr || rbr || rbl) {
 			if (st->has_bg) {
 				int bw = st->border_w[0];
 

+ 198 - 17
browser_html.c

@@ -2305,6 +2305,8 @@ enum {
 	PROP_RIGHT, PROP_BOTTOM, PROP_RIGHT_SET, PROP_BOTTOM_SET,
 	PROP_ZINDEX, PROP_ZSET,
 	PROP_TRANSFORM_X, PROP_TRANSFORM_Y, PROP_TRANSFORM_SET,
+	PROP_TRANSFORM_PAINT, PROP_SCALE_X, PROP_SCALE_Y, PROP_ROTATE,
+	PROP_ORIGIN_X_KIND, PROP_ORIGIN_X, PROP_ORIGIN_Y_KIND, PROP_ORIGIN_Y,
 	PROP_VIS_HIDDEN, PROP_OPACITY_HIDDEN, PROP_OVERFLOW_HIDDEN,
 	PROP_COUNT
 };
@@ -3294,6 +3296,119 @@ static void add_bg_size(struct br_decl *out, unsigned int *nout,
 	(void)kh;
 }
 
+static int parse_fixed_100(const char *s, unsigned int len,
+			   unsigned int *pos, signed short *out)
+{
+	unsigned int i = *pos;
+	long whole = 0, frac = 0;
+	int neg = 0, digits = 0, fd = 0;
+
+	while (i < len && is_space(s[i]))
+		i++;
+	if (i < len && (s[i] == '-' || s[i] == '+')) {
+		neg = s[i] == '-';
+		i++;
+	}
+	while (i < len && s[i] >= '0' && s[i] <= '9') {
+		whole = whole * 10 + (s[i] - '0');
+		if (whole > 327)
+			whole = 327;
+		digits = 1;
+		i++;
+	}
+	if (i < len && s[i] == '.') {
+		i++;
+		while (i < len && s[i] >= '0' && s[i] <= '9') {
+			if (fd < 2) {
+				frac = frac * 10 + (s[i] - '0');
+				fd++;
+			}
+			i++;
+		}
+	}
+	if (!digits)
+		return 0;
+	while (fd++ < 2)
+		frac *= 10;
+	*out = (signed short)((whole * 100 + frac) * (neg ? -1 : 1));
+	*pos = i;
+	return 1;
+}
+
+static int find_fn(const char *v, unsigned int len, const char *name,
+		   unsigned int *arg)
+{
+	unsigned int n = s_len(name), i;
+
+	for (i = 0; i + n <= len; i++) {
+		unsigned int j;
+
+		if (!ci_eq_n(v + i, name, n))
+			continue;
+		j = i + n;
+		while (j < len && is_space(v[j]))
+			j++;
+		if (j < len && v[j] == '(') {
+			*arg = j + 1;
+			return 1;
+		}
+	}
+	return 0;
+}
+
+static void add_transform_origin(struct br_decl *out, unsigned int *nout,
+				 const char *s, unsigned int len,
+				 int important)
+{
+	unsigned int pos = 0, ts, te;
+	signed short val[2] = { 50, 50 };
+	unsigned char kind[2] = { 1, 1 };
+	int vert[2] = { 0, 0 }, n = 0;
+
+	while (n < 2 && next_token(s, len, &pos, &ts, &te)) {
+		signed short v;
+		int is_vert;
+
+		if (bg_keyword(s + ts, te - ts, &v, &is_vert)) {
+			val[n] = v;
+			kind[n] = 1;
+			vert[n] = is_vert;
+		} else if (bg_number(s + ts, te - ts, &v, &kind[n])) {
+			val[n] = v;
+			vert[n] = 0;
+		} else {
+			n++;
+			continue;
+		}
+		n++;
+	}
+	if (n == 1) {
+		if (vert[0]) {
+			decl_add(out, nout, PROP_ORIGIN_X_KIND, 1, important);
+			decl_add(out, nout, PROP_ORIGIN_X, 50, important);
+			decl_add(out, nout, PROP_ORIGIN_Y_KIND, kind[0],
+				 important);
+			decl_add(out, nout, PROP_ORIGIN_Y, val[0], important);
+		} else {
+			decl_add(out, nout, PROP_ORIGIN_X_KIND, kind[0],
+				 important);
+			decl_add(out, nout, PROP_ORIGIN_X, val[0], important);
+			decl_add(out, nout, PROP_ORIGIN_Y_KIND, 1, important);
+			decl_add(out, nout, PROP_ORIGIN_Y, 50, important);
+		}
+		return;
+	}
+	if (n >= 2) {
+		int x = vert[0] && !vert[1] ? 1 : 0;
+		int y = 1 - x;
+
+		decl_add(out, nout, PROP_ORIGIN_X_KIND, kind[x], important);
+		decl_add(out, nout, PROP_ORIGIN_X, val[x], important);
+		decl_add(out, nout, PROP_ORIGIN_Y_KIND, kind[y], important);
+		decl_add(out, nout, PROP_ORIGIN_Y, val[y], important);
+	}
+}
+
 static void add_bg_image_decl(struct br_decl *out, unsigned int *nout,
 			      const char *v, unsigned int vl, int important)
 {
@@ -4497,30 +4612,25 @@ static void parse_decls(struct br_doc *d, const char *s,
 				decl_add(out, nout, PROP_ZSET, 0, important);
 			}
 		} else if (str_eq(prop, "transform")) {
+			const char *v = s + vstart;
+			unsigned int vl = vend - vstart;
 			int tx = 0, ty = 0;
-			int is_x = contains_ci_len(s + vstart, vend - vstart,
-						   "translatex");
-			int is_y = contains_ci_len(s + vstart, vend - vstart,
-						   "translatey");
-			unsigned int off = 0;
+			int is_x = contains_ci_len(v, vl, "translatex");
+			int is_y = contains_ci_len(v, vl, "translatey");
+			unsigned int off = 0, arg;
 
-			if (contains_ci_len(s + vstart, vend - vstart,
-					    "translate")) {
-				while (off < vend - vstart &&
-				       s[vstart + off] != '(')
+			if (contains_ci_len(v, vl, "translate")) {
+				while (off < vl && v[off] != '(')
 					off++;
-				if (off < vend - vstart)
+				if (off < vl)
 					off++;
 				if (!is_y)
-					tx = parse_len(s + vstart,
-						       vend - vstart, &off);
+					tx = parse_len(v, vl, &off);
 				if (!is_x) {
-					while (off < vend - vstart &&
-					       (is_space(s[vstart + off]) ||
-						s[vstart + off] == ','))
+					while (off < vl &&
+					       (is_space(v[off]) || v[off] == ','))
 						off++;
-					ty = parse_len(s + vstart,
-						       vend - vstart, &off);
+					ty = parse_len(v, vl, &off);
 				}
 				decl_add(out, nout, PROP_TRANSFORM_X, tx,
 					 important);
@@ -4529,6 +4639,48 @@ static void parse_decls(struct br_doc *d, const char *s,
 				decl_add(out, nout, PROP_TRANSFORM_SET, 1,
 					 important);
 			}
+			if (find_fn(v, vl, "scale", &arg)) {
+				unsigned int q = arg;
+				signed short sx = 100, sy = 100;
+
+				if (parse_fixed_100(v, vl, &q, &sx)) {
+					unsigned int r = q;
+
+					while (r < vl &&
+					       (is_space(v[r]) || v[r] == ','))
+						r++;
+					if (!parse_fixed_100(v, vl, &r, &sy))
+						sy = sx;
+					decl_add(out, nout, PROP_SCALE_X, sx,
+						 important);
+					decl_add(out, nout, PROP_SCALE_Y, sy,
+						 important);
+					decl_add(out, nout,
+						 PROP_TRANSFORM_PAINT, 1,
+						 important);
+					decl_add(out, nout,
+						 PROP_TRANSFORM_SET, 1,
+						 important);
+				}
+			}
+			if (find_fn(v, vl, "rotate", &arg)) {
+				unsigned int q = arg;
+				signed short deg;
+
+				if (parse_fixed_100(v, vl, &q, &deg)) {
+					decl_add(out, nout, PROP_ROTATE, deg,
+						 important);
+					decl_add(out, nout,
+						 PROP_TRANSFORM_PAINT, 1,
+						 important);
+					decl_add(out, nout,
+						 PROP_TRANSFORM_SET, 1,
+						 important);
+				}
+			}
+		} else if (str_eq(prop, "transform-origin")) {
+			add_transform_origin(out, nout, s + vstart,
+					     vend - vstart, important);
 		} else if (str_eq(prop, "grid-template-columns") ||
 			   str_eq(prop, "grid-template")) {
 			const char *v = s + vstart;
@@ -6253,6 +6405,30 @@ static void apply_decl(struct br_style *st, const struct br_decl *dcl)
 	case PROP_TRANSFORM_SET:
 		st->transform_set = (unsigned char)(dcl->val != 0);
 		break;
+	case PROP_TRANSFORM_PAINT:
+		st->transform_scale = (unsigned char)(dcl->val != 0);
+		break;
+	case PROP_SCALE_X:
+		st->scale_x = (signed short)dcl->val;
+		break;
+	case PROP_SCALE_Y:
+		st->scale_y = (signed short)dcl->val;
+		break;
+	case PROP_ROTATE:
+		st->rotate_x100 = (signed short)dcl->val;
+		break;
+	case PROP_ORIGIN_X_KIND:
+		st->origin_x_kind = (unsigned char)dcl->val;
+		break;
+	case PROP_ORIGIN_X:
+		st->origin_x = (signed short)dcl->val;
+		break;
+	case PROP_ORIGIN_Y_KIND:
+		st->origin_y_kind = (unsigned char)dcl->val;
+		break;
+	case PROP_ORIGIN_Y:
+		st->origin_y = (signed short)dcl->val;
+		break;
 	default:
 		break;
 	}
@@ -6326,6 +6502,11 @@ void br_style_for(struct br_doc *d, unsigned int node,
 	out->z_set = 0;
 	out->tx = out->ty = 0;
 	out->transform_set = 0;
+	out->transform_scale = 0;
+	out->scale_x = out->scale_y = 100;
+	out->rotate_x100 = 0;
+	out->origin_x = out->origin_y = 50;
+	out->origin_x_kind = out->origin_y_kind = 1;
 	out->vis_hidden = out->opacity_hidden = 0;
 	out->overflow_hidden = 0;
 	tag = d->nodes[node].tag;

+ 6 - 1
browser_html.h

@@ -18,7 +18,7 @@
 #define BR_MAX_VARS      512
 #define BR_TAG_MAX       128
 #define BR_RULE_HASH     256
-#define BR_DECLS         16
+#define BR_DECLS         24
 #define BR_TITLE_MAX     96
 #define BR_MAX_SCRIPTS   32
 
@@ -125,6 +125,11 @@ struct br_style {
 	unsigned char z_set;
 	signed short tx, ty;
 	unsigned char transform_set;
+	unsigned char transform_scale; /* scale()/rotate() paint hint */
+	signed short scale_x, scale_y; /* hundredths, 100 = 1.0 */
+	signed short rotate_x100;      /* hundredths of a degree */
+	signed short origin_x, origin_y;
+	unsigned char origin_x_kind, origin_y_kind; /* 0 px, 1 percent */
 	unsigned char no_bullet;    /* list-style: none (inherited) */
 	unsigned char list_item;    /* li marker is drawn */
 	unsigned char nowrap;       /* white-space: nowrap (inherited) */

Diff do ficheiro suprimidas por serem muito extensas
+ 1 - 1
docs/userland.html


+ 53 - 0
testdata/browser/compat/039-transform-scale-rotate.html

@@ -0,0 +1,53 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>039 transform</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; }
+.stage { width: 320px; height: 230px; background: #f4f4f4;
+         border: 1px solid #999999; }
+.imgrow { height: 130px; padding: 10px 0 0 10px; }
+.cell { float: left; width: 150px; }
+.scaled { transform: scale(0.5); transform-origin: top left; }
+.rotated-img { transform: rotate(90deg); transform-origin: center; }
+.scaled-box { width: 80px; height: 40px; margin: 10px 0 0 10px;
+              background: #cc3333; transform: scale(1.5);
+              transform-origin: top left; }
+.ref-scaled-box { width: 120px; height: 60px; margin: 10px 0 0 10px;
+                  background: #cc3333; }
+.caption { clear: both; color: #555555; padding-top: 3px; }
+</style>
+</head>
+<body>
+<h1>039 &middot; transform scale and rotate</h1>
+<p>Each pair must look identical. Transforms paint the element box and inline images; text and descendants keep their layout.</p>
+<div class="pane">
+  <div class="label">A &middot; transform</div>
+  <div class="stage">
+    <div class="imgrow">
+      <div class="cell"><img class="scaled" src="PIC.BMP" width="194" height="122"></div>
+      <div class="cell"><img class="rotated-img" src="TILE.PNG" width="64" height="64"></div>
+    </div>
+    <div class="scaled-box"></div>
+  </div>
+  <div class="caption">scale(0.5), rotate(90deg), scaled box</div>
+</div>
+<div class="pane">
+  <div class="label">B &middot; reference</div>
+  <div class="stage">
+    <div class="imgrow">
+      <div class="cell"><img src="PIC.BMP" width="97"></div>
+      <div class="cell"><img src="TILE90.PNG" width="64" height="64"></div>
+    </div>
+    <div class="ref-scaled-box"></div>
+  </div>
+  <div class="caption">97px image, pre-rotated tile, 120&times;60 box</div>
+</div>
+</body>
+</html>

+ 4 - 3
testdata/browser/compat/README

@@ -17,13 +17,14 @@ 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-038 and 030a pass.  036a needs the POST echo server:
+Status: 010-039 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
 
-Still missing from the ladder: the rest of transform (scale/rotate),
-sticky bottom/container clamping, and calc() beyond widths.
+Still missing from the ladder: 3D/perspective transforms, transformed
+text/descendants, sticky bottom/container clamping, and calc() beyond
+widths.
 
 Rules for new pages:
   - one behaviour per page;

BIN
testdata/browser/compat/TILE90.PNG


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

@@ -61,6 +61,7 @@ a { color: #0645ad; }
 <tr><td>036a</td><td><a href="036a-post.html">POST form</a></td><td>POST submission to <code>/echo</code> (needs <code>post_server.py</code>)</td><td class="pass">PASS</td></tr>
 <tr><td>037</td><td><a href="037-font-face.html">@font-face</a></td><td>custom TTF family and missing-URL fallback</td><td class="pass">PASS</td></tr>
 <tr><td>038</td><td><a href="038-background-props.html">background props</a></td><td>repeat, position, contain/cover and the shorthand URL</td><td class="pass">PASS</td></tr>
+<tr><td>039</td><td><a href="039-transform-scale-rotate.html">transform</a></td><td>scale, rotate, transform-origin on images and boxes</td><td class="pass">PASS</td></tr>
 </table>
 </body>
 </html>

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff