[webkit-changes] [WebKit/WebKit] 7e3907: [UnifiedPDF] Handle page rotation

Simon Fraser noreply at github.com
Sun Oct 1 11:04:12 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7e3907d4cb77cae87cc983af5f2ec852508cc99e
      https://github.com/WebKit/WebKit/commit/7e3907d4cb77cae87cc983af5f2ec852508cc99e
  Author: Simon Fraser <simon.fraser at apple.com>
  Date:   2023-10-01 (Sun, 01 Oct 2023)

  Changed paths:
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm

  Log Message:
  -----------
  [UnifiedPDF] Handle page rotation
https://bugs.webkit.org/show_bug.cgi?id=262449
rdar://116292055

Reviewed by Tim Horton and Richard Robinson.

PDFs have per-page metadata about page rotation, and we have to respect this when drawing.

Rename the bounds vector in PDFDocumentLayout to m_pageGeometry and have it store both
rotation and normalized page bounds. Normalize page rotation to multiples of 90deg,
and store normalized bounds for rotated pages.

When drawing, we can use `CGPDFPageGetDrawingTransform()` to compute the transform
from the page crop box to the destination rect, but we have to first transform the
context to the page destination origin and flip.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::updateGeometry):
(WebKit::PDFDocumentLayout::layoutSingleColumn):
(WebKit::PDFDocumentLayout::boundsForPageAtIndex const):
(WebKit::PDFDocumentLayout::rotationForPageAtIndex const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::paint):

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




More information about the webkit-changes mailing list