[webkit-changes] [WebKit/WebKit] 1d980c: [UnifiedPDF] Implement pinch-zooming (macOS)

Tim Horton noreply at github.com
Mon Dec 4 12:45:13 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1d980c4592b05f24494e5fd86640b4289f2e01e5
      https://github.com/WebKit/WebKit/commit/1d980c4592b05f24494e5fd86640b4289f2e01e5
  Author: Tim Horton <timothy_horton at apple.com>
  Date:   2023-12-04 (Mon, 04 Dec 2023)

  Changed paths:
    M Source/WebKit/UIProcess/ViewGestureController.cpp
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    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/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Source/WebKit/WebProcess/Plugins/PluginView.cpp
    M Source/WebKit/WebProcess/Plugins/PluginView.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

  Log Message:
  -----------
  [UnifiedPDF] Implement pinch-zooming (macOS)
https://bugs.webkit.org/show_bug.cgi?id=265760
<rdar://problem/114832109>

Reviewed by Simon Fraser.

Implement pinch zooming (not HUD zooming or etc.) for the UnifiedPDFPlugin for macOS.

* Source/WebKit/UIProcess/ViewGestureController.cpp:
(WebKit::ViewGestureController::didCollectGeometryForMagnificationGesture):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didBeginMagnificationGesture):
(WebKit::WebPageProxy::didEndMagnificationGesture):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
Let the WebContent process know when we start a gesture (we already send the matching "end").

* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::installPDFDocument):
(WebKit::PDFPlugin::deviceScaleFactorChanged):
(WebKit::PDFPlugin::geometryDidChange):
(WebKit::PDFPlugin::setPageScaleFactor):
(WebKit::PDFPlugin::notifyContentScaleFactorChanged):
(WebKit::PDFPlugin::contentsScaleFactorChanged): Deleted.
(WebKit::PDFPlugin::handlesPageScaleFactor const): Deleted.
Two small changes to the legacy PDFPlugin:
- rename contentsScaleFactorChanged to deviceScaleFactorChanged since that's what it's used for.
- Adopt the new `origin` parameter on setPageScaleFactor instead of using the "last mouse position".

This makes us match Preview and Web Content behavior when using the keyboard to zoom
(around the center of the view, not around the mouse!), and avoids the need to store
the last mouse position in UnifiedPDFPlugin (there remains one use in legacy PDFPlugin).

* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::deviceScaleFactorChanged):
(WebKit::PDFPluginBase::didBeginMagnificationGesture):
(WebKit::PDFPluginBase::didEndMagnificationGesture):
(WebKit::PDFPluginBase::contentsScaleFactorChanged): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::handlesPageScaleFactor const):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::topContentInsetDidChange):
(WebKit::PluginView::didBeginMagnificationGesture):
(WebKit::PluginView::didEndMagnificationGesture):
(WebKit::PluginView::setPageScaleFactor):
(WebKit::PluginView::setDeviceScaleFactor):
(WebKit::PluginView::pageScaleFactorDidChange): Deleted.
* Source/WebKit/WebProcess/Plugins/PluginView.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setTextZoomFactor):
(WebKit::WebPage::setPageZoomFactor):
(WebKit::WebPage::setPageAndTextZoomFactors):
(WebKit::WebPage::scalePage):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::didBeginMagnificationGesture):
(WebKit::WebPage::didEndMagnificationGesture):
Plumb beginning and end of magnification gestures, and the gesture origin, to the plugin.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updateLayerHierarchy):
Mark our root layer as "the one that applies the page scale" if we're the whole main frame.

(WebKit::UnifiedPDFPlugin::paintContents):
(WebKit::UnifiedPDFPlugin::pageScaleFactor const):
(WebKit::UnifiedPDFPlugin::didBeginMagnificationGesture):
(WebKit::UnifiedPDFPlugin::didEndMagnificationGesture):
Keep track of when we're inside a magnification gesture, and tickle the layers
when the gesture ends.

(WebKit::UnifiedPDFPlugin::setPageScaleFactor):
Scale the contents layer with page scale, and counter-scroll to keep the
gesture origin in the same position.

For now, until we have async painting, we avoid updating the tiles until
the gesture ends.

(WebKit::UnifiedPDFPlugin::documentSize const):
(WebKit::UnifiedPDFPlugin::contentsSize const):
Split these two; documentSize is unscaled (scale=1); contentsSize is the
ScrollableArea contents size (which must have the scale applied).

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




More information about the webkit-changes mailing list