[webkit-changes] [WebKit/WebKit] 63dde7: UnifiedPDF: Support for loading PDFs with #page= f...

Tim Horton noreply at github.com
Mon Feb 12 15:39:04 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 63dde78713856ee9925a6802d16d971d1547babf
      https://github.com/WebKit/WebKit/commit/63dde78713856ee9925a6802d16d971d1547babf
  Author: Tim Horton <thorton at apple.com>
  Date:   2024-02-12 (Mon, 12 Feb 2024)

  Changed paths:
    M Source/WebCore/plugins/PluginViewBase.h
    M Source/WebCore/rendering/RenderEmbeddedObject.cpp
    M Source/WebCore/rendering/RenderEmbeddedObject.h
    M Source/WebCore/rendering/RenderLayerCompositor.cpp
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
    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

  Log Message:
  -----------
  UnifiedPDF: Support for loading PDFs with #page= fragments
https://bugs.webkit.org/show_bug.cgi?id=269180
rdar://122765668

Reviewed by Simon Fraser.

* Source/WebCore/plugins/PluginViewBase.h:
(WebCore::PluginViewBase::didAttachScrollingNode):
* Source/WebCore/rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::didAttachScrollingNode):
* Source/WebCore/rendering/RenderEmbeddedObject.h:
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::attachWidgetContentLayers):
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::didAttachScrollingNode):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::didAttachScrollingNode):
* Source/WebKit/WebProcess/Plugins/PluginView.h:
Let the plugin know when it's in the scrolling tree and it's safe to start scrolling.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::didAttachScrollingNode):
Scroll to the fragment in the URL whenever *both* the PDF document is installed and we're in the scrolling tree.

(WebKit::UnifiedPDFPlugin::pageHeight const):
(WebKit::UnifiedPDFPlugin::firstPageHeight const):
Factor out pageHeight() from firstPageHeight().

(WebKit::UnifiedPDFPlugin::scrollToPDFDestination):
Fix a mistake in here: indexForPage is zero-based like PageIndex, but the origin
is flipped, so the y origin of the page is at its height instead of 0 (which is
how I was misled into subtracting 1 from the page index...).

(WebKit::UnifiedPDFPlugin::scrollToPointInPage):
Fix the local name here to say `contents` instead of `document`.
Rename this to "point in page", to go along with...

(WebKit::UnifiedPDFPlugin::scrollToPage):
... this new function, which just scrolls to the origin of a page.

(WebKit::UnifiedPDFPlugin::scrollToFragmentIfNeeded):
Parse the fragment out. For now, only support page=; for parity with
PDFPlugin we also need to support nameddest=.

* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::didSameDocumentNavigationForFrame):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::didSameDocumentNavigationForFrame):
* Source/WebKit/WebProcess/Plugins/PluginView.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didSameDocumentNavigationForFrame):
Plumb fragment changes through to the plugin, so that dynamically editing
the URL navigates to the new fragment (instead of having to force a reload).

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




More information about the webkit-changes mailing list