RESOLVED FIXED312280
WebKitLegacy: printing a WebView embedded in an enclosing NSPrintOperation drops all text
https://bugs.webkit.org/show_bug.cgi?id=312280
Summary WebKitLegacy: printing a WebView embedded in an enclosing NSPrintOperation dr...
Jonathan Hammer
Reported 2026-04-14 09:38:58 PDT
304253@main (5f8a1e5) routed WebHTMLView's _setPrinting: through LocalFrame::setPrinting unconditionally. The embedded-print path (-[WebHTMLView adjustPageHeightNew:...], used when the WebHTMLView is a subview of a larger view tree being printed) calls _setPrinting: with all page dimensions equal to zero. Before 304253@main, WK1's layout helper explicitly gated forceLayoutForPagination on a nonzero minPageLogicalWidth and fell back to forceLayout(). That gate was lost in the refactor. With zero pageSize, shouldUsePrintingLayout() still returns true for the top frame, so forceLayoutForPagination runs with a zero page, which asserts in resizePageRectsKeepingRatio in debug and produces a degenerate paginated layout in release — line boxes collapse and text runs are never emitted to the CG print context, while raster content (images, backgrounds) still paints. Users see print/export output with images but no text.
Attachments
Visual example of buggy behavior (560.19 KB, application/pdf)
2026-04-14 12:26 PDT, Jonathan Hammer
no flags
Visual example of fix (508.49 KB, application/pdf)
2026-04-14 12:26 PDT, Jonathan Hammer
no flags
Jonathan Hammer
Comment 1 2026-04-14 09:44:23 PDT
Radar WebKit Bug Importer
Comment 2 2026-04-14 10:48:49 PDT
Jonathan Hammer
Comment 3 2026-04-14 12:26:02 PDT
Created attachment 479070 [details] Visual example of buggy behavior Just to visualize what this bug is referring to. Attached is a PDF of a WebView exhibiting the buggy behavior (text is not rendered and layout is wrong).
Jonathan Hammer
Comment 4 2026-04-14 12:26:39 PDT
Created attachment 479071 [details] Visual example of fix This is the same web page, this time with the patch applied. Text and layout is now correct.
Jonathan Hammer
Comment 5 2026-05-04 12:45:07 PDT
Requesting that this pull request please be landed via the merge queue. The PR was code-reviewed and passes EWS for everything (except a spurious ios-wk2-wpt failure). This bug is impacting our shipping app and we’d love to see the fix land in WebKit. If the PR is deficient in any way, please let me know. Thank you!
Simon Fraser (smfr)
Comment 6 2026-05-04 13:58:59 PDT
It looks like the latest push got no EWS coverage (perhaps it was down at the time). Could you rebase and update the PR please?
Jonathan Hammer
Comment 7 2026-05-05 10:40:02 PDT
Yes, no problem. Thank you. I updated the PR last night and ran EWS. All green except for win-tests (two failures, both of which seem unrelated).
EWS
Comment 8 2026-05-05 12:32:54 PDT
Committed 312629@main (d70314bc51fa): <https://commits.webkit.org/312629@main> Reviewed commits have been landed. Closing PR #62742 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.