JavaScript Find in Page: DOM Text Above the Codename One Canvas
Browser search cannot find pixels. That was the JavaScript port's text model: Codename One drew each glyph onto a canvas, so a visible label was invisible to find-in-page, text selection, and ordinary browser text machinery. What is Codename One? Codename One is an open-source framework for building native iOS, Android, desktop, and web apps from a single Java or Kotlin codebase. Learn more at…
Codename One is an open-source framework for creating apps across multiple platforms from a single codebase. The JavaScript port of the framework faced limitations in finding text within its canvas-based rendering, as the browser's text search and selection capabilities could not access pixels drawn by Codename One. To address this, PR #5552 was implemented, promoting eligible visible text into a DOM layer while retaining the canvas for layout, rendering, and accessibility.
The browser handles text rasterization, selection, search, and device-pixel resolution, while Codename One remains responsible for measuring and placing every text run. This approach avoids duplicating UI implementations and maintains the browser's ability to handle encryption, selection, and accessibility. The new DOM structure includes a hidden presentation canvas, a text layer with absolute positioning, and an accessibility tree for screen readers.
The promotion of text to the DOM layer preserves focus and selection, and the browser can now better interpret input metadata, autocomplete, and spellcheck. The port also incorporates high-DPI display support and preserves the application's JavaScript properties for real-browser verification.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.