Repository navigation
Paint button widget appearances in the web annotation layer - #672
Merged
Merged
Conversation
Checkbox, radio and push-button widgets now draw their /AP appearance streams on the page canvas instead of showing native browser controls. The HTML controls stay on top as transparent hit and input targets. - Core keeps the resolved /AP /N and /D entries and reports, per page, the appearance each displayed button widget paints under live field state (on-state or Off, /AS for push buttons, /D while pressed). - PdfRenderer::render_annotation_appearances maps each form's transformed /BBox onto /Rect and draws it after the page content, without recording selectable text. - The web layer marks painted controls, hides their native look, lays PDFium's light-blue form highlight over non-button fields, and repaints the page after edits and while a widget is held down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the web stack (
pdfium-web), checkbox, radio and push-button widgets used to show as native browser controls (blue checkboxes, push buttons showing only their field label). PDFium draws each widget's/APappearance stream instead. This PR paints those appearances on the page canvas, matching PDFium.pdf-annotation-core):AppearanceDictionarykeeps the resolved/AP /Nand/Dentries. They are unparsed and not serialized.WidgetControl.paintedmarks button widgets that have an appearance.AnnotationOverlay::painted_appearances(page, pressed)returns each displayed widget's appearance under its live state: the on-state orOff,/ASfor push buttons, and/Dwhile pressed.PdfRenderer::render_annotation_appearancesmaps each form's transformed/BBoxonto/Rect(ISO 32000 §12.5.5). It draws through the existing content-stream path after the page content, without recording selectable text. An appearance stream that can't be read is skipped.WebPageRenderer::renderpaints the appearances. The conformance--renderer webharness goes through this path too.native-painted), so they still take clicks and keyboard focus.--native-form-highlight.onPresscallback reports a painted widget being held down, so the host can draw its down appearance.WebDocument::repaintandWebDocument::pressre-render a page with its stored viewport, after edits and while a widget is held down.Testing
cargo clippywith-D warningson the changed crates, natively and forwasm32-unknown-unknown.cargo fmt --check,cargo teston the changed crates, andcargo xtask annotation-types --check.action_hide_show_form.pdf(from the PDFium corpus) through the new appearance pass on Skia. The checkbox and radio glyphs, the button logos and the captions match PDFium.cargo xtask web-canvas). The glyph and highlight colours match PDFium's render: glyphs(87,89,99), field background(242,244,254)./D) appearance has only been built, not seen in a browser or rendered through Skia.Not run locally: clippy with
--all-features, which needs a Skia build with GL/PDF features that isn't cached here, and thetsctype check, which isn't installed. CI runs both.🤖 Generated with Claude Code