[webkit-changes] [WebKit/WebKit] e7a5da: [UnifiedPDF] Scale pages to fix the available width

Simon Fraser noreply at github.com
Sun Oct 1 18:30:20 PDT 2023


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

  Changed paths:
    M Source/WebCore/html/PluginDocument.cpp
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm
    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] Scale pages to fix the available width
https://bugs.webkit.org/show_bug.cgi?id=262453
rdar://116295967

Reviewed by Tim Horton and Richard Robinson.

PDFs are always scaled so that the widest page (or pair of pages) fits the available width.
So we set the width of the `embed` in `PluginDocumentParser::createStyleElement()` to always
be 100%, and stop setting the width in inline style in `UnifiedPDFPlugin::sizeToFitContents()`.

`PDFDocumentLayout::updateLayout()` now lays out pages to the available width, and we compute
the scale factor afterwards. This scale is applied when drawing.

This PR also moves `convertFromRootViewToPlugin()` to the base class, since this will be
shared by both PDFPlugin implementations, and a future PR will use it for point mapping.

* Source/WebCore/html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createStyleElement):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::geometryDidChange):
(WebKit::PDFPlugin::convertFromRootViewToPlugin const): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::geometryDidChange):
(WebKit::PDFPluginBase::convertFromRootViewToPlugin const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h:
(WebKit::PDFDocumentLayout::scale const):
(WebKit::PDFDocumentLayout::layoutSize const): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::setPDFDocument):
(WebKit::PDFDocumentLayout::updateLayout):
(WebKit::PDFDocumentLayout::layoutPages):
(WebKit::PDFDocumentLayout::layoutSingleColumn):
(WebKit::PDFDocumentLayout::scaledContentsSize const):
(WebKit::PDFDocumentLayout::updateGeometry): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::sizeToFitContents):
(WebKit::UnifiedPDFPlugin::paint):
(WebKit::UnifiedPDFPlugin::geometryDidChange):

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




More information about the webkit-changes mailing list