首页›Eric Meyer›文章

Canvas-ing the Web

Eric Meyer · 2026年4月27日

AI 摘要 AI 生成,可能有误

作者描述了如何使用 Chrome 新推出的需通过标志(flag)启用的 HTML-in-canvas API,为 Igalia 开发的一款用于生成社交媒体横幅图和缩略图的浏览器端工具添加一键式“下载横幅图片”按钮。他们讲述了克服技术难题的过程,包括在向画布中插入自定义元素时避免无限递归(通过 Element.moveBefore() 和 connectedMoveCallback() 解决),以及动态调整画布大小以适应其内容。他们总结道,尽管 HTML-in-canvas 非常适合像他们这样的静态截图式用例,但流式 DOM 布局与固定画布尺寸之间的固有不匹配可能会限制其在网络上的更广泛采用。

Over the years, I’ve created an experiment or two that drew stuff to a <canvas> element: a wave function collapse experiment here, a crystallizing palette there.  After a while, I found a way to wire up a button so that clicking it would save the canvas’s contents to my computer as a PNG file.  Pretty cool, I thought.  Can I do the same thing with HTML+CSS structures?

First I generated it on a canvas, then I clicked a button to save it.

Turns out, no.  I could use, and often have used, Firefox’s “Screenshot node” menu entry in the web inspector, or the :screenshot command in Firefox’s console, but not do it with an in-page button.  Because HTML nodes don’t go in <canvas>, you see, let alone styled and scripted ones.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Eric Meyer

My Interop 2027 Rankings

AI 摘要The author shares their personal rankings for Interop 2027 proposals using Jake Archibald's community ranking tool, placing JavaScript Temporal first, followed by improving CSS sibling-count()/sibling-index() interop, unprefixed CSS box-decoration-break, HTML headingoffset/headingreset attributes, and CSS line-clamp plus margin-trim. In total they ranked twenty proposals and explain their reasoning for each, while emphasizing these personal rankings do not predict how they will vote as Igalia's representative to Interop. They encourage readers to rank and share their own favorite proposals.

In situ Syntax Highlighting in macOS Applications Like Keynote

AI 摘要The author shares a macOS workflow for syntax-highlighting code blocks in place within Keynote (and other apps), built from the highlight command-line tool, a custom shell script, and an Automator Quick Action that adds an entry to the Services submenu of the right-click menu. The setup preserves the original font face and size, though line spacing is reset to 1.0 due to a limitation in highlight, and support for other languages can be added by duplicating the workflow and changing the syntax variable. Tested on macOS Sequoia, the approach has caveats such as failing on text with mixed fonts or sizes and performing no validation that the selected text matches the configured language.

Eighteen

AI 摘要The author reflects on what would have been his daughter Rebecca's eighteenth birthday, twelve years after her death, recalling her funeral and imagining the adulthood she never reached, including a high school graduation she likely would have had. He considers this transition from her 'phantom childhood' to 'phantom adulthood' as a possible turning point for the family, who have traditionally visited her grave together each year and are beginning to discuss loosening that ritual. This year, the family visited on the day itself, where a cellophane spinner cast glowing purple shapes—including a butterfly—across her name, a sight the Rebecca they knew would have loved.

Accessible (I Think) Split-Cell Table Headers

AI 摘要The author describes an attempt to build an accessible split-diagonal table header cell, inspired by Apollo 16 documentation, using rowspan on header cells (to satisfy WCAG 1.3.3), CSS positioning, and a gradient to draw the diagonal. He shares layout caveats, including a Safari bug with relative positioning on thead that required a workaround, and notes basic testing with accessibility experts found no major issues. He ultimately asks assistive technology users to confirm whether the solution actually works well for them.

Targeting by Reference in the Shadow DOM

AI 摘要The article discusses the Reference Target proposal, which addresses how the Shadow DOM breaks references such as label 'for' attributes, popoverTarget, commandFor, and ARIA attributes by creating a separate node tree. The proposed shadowRootReferenceTarget attribute lets a component redirect external references to a specific element inside its shadow tree, with prototype implementations available in Chrome and Safari (and a Gecko version under review). The author encourages developers to test the feature in these browsers and provide feedback on the proposal's issue tracker.