Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d70314bc51faaa3e661228bb8bd932fbe5bd723b
      
https://github.com/WebKit/WebKit/commit/d70314bc51faaa3e661228bb8bd932fbe5bd723b
  Author: Jonathan Hammer <[email protected]>
  Date:   2026-05-05 (Tue, 05 May 2026)

  Changed paths:
    M Source/WebCore/page/LocalFrame.cpp
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/EmbeddedPrintPagination.mm

  Log Message:
  -----------
  WebKitLegacy: printing a WebView embedded in an enclosing NSPrintOperation 
drops all text
https://bugs.webkit.org/show_bug.cgi?id=312280

Reviewed by Simon Fraser and Matt Woodrow.

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.

Restore the pre-304253@main behavior by gating on pageSize.width() > 0,
falling through to forceLayout() as before. Note that height may
legitimately be zero here — RenderTreeAsText's printing-mode dump calls
PrintContext::begin(renderer->width()) with the default height=0, and
WK1's -setPageWidthForPrinting: does the same — so FloatSize::isEmpty()
(which is true when either dimension is <= 0) is too broad.

Tests: Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
       Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/EmbeddedPrintPagination.mm

* Source/WebCore/page/LocalFrame.cpp:
(WebCore::LocalFrame::setPrinting):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitLegacy/mac/EmbeddedPrintPagination.mm: Added.
(-[EmbeddedPrintPaginationLoadDelegate webView:didFinishLoadForFrame:]):
(TestWebKitAPI::TEST(WebKitLegacy, EmbeddedPrintPaginationWithZeroPageSize)):

Canonical link: https://commits.webkit.org/312629@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to