Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f1e6113a523e164159030fd1eb8dd96f33850729
      
https://github.com/WebKit/WebKit/commit/f1e6113a523e164159030fd1eb8dd96f33850729
  Author: Abrar Rahman Protyasha <[email protected]>
  Date:   2025-02-26 (Wed, 26 Feb 2025)

  Changed paths:
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WTF/wtf/PlatformEnableCocoa.h
    M Source/WebCore/en.lproj/Localizable.strings
    M Source/WebCore/page/ChromeClient.h
    M Source/WebCore/page/LocalFrameView.cpp
    M Source/WebKit/PlatformMac.cmake
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    A Source/WebKit/UIProcess/PDF/WKPDFPageNumberIndicator.h
    A Source/WebKit/UIProcess/PDF/WKPDFPageNumberIndicator.mm
    M Source/WebKit/UIProcess/PageClient.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.h
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
    M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    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/WebCoreSupport/WebChromeClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

  Log Message:
  -----------
  [UnifiedPDF] [iOS] Implement page number indicator
https://bugs.webkit.org/show_bug.cgi?id=288487
rdar://118154868

Reviewed by Wenson Hsieh and Tim Horton.

This patch implements the page number indicator for main frame PDF
plugins on iOS. More details in-line.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:

The web preference may be helpful to set (or unset) when authoring tests.
Currently, we enable it by default on iOS and gate creation of the
indicator behind it.

* Source/WTF/wtf/PlatformEnableCocoa.h:

Introduce a new compile-time guard for the page number indicator,
limiting behavior changes to the iOS family.

* Source/WebCore/en.lproj/Localizable.strings:

Localize the label text for the indicator.

* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::frameViewLayoutOrVisualViewportChanged):
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::layoutOrVisualViewportChanged):

Set up plumbing to forward (updated) unobscured content rect to any
relevant main frame plugin, downstream of visible content rect updates.

* Source/WebKit/PlatformMac.cmake:

* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _createPDFPageNumberIndicator:withFrame:pageCount:]):
(-[WKWebView _removePDFPageNumberIndicator:]):
(-[WKWebView _updatePDFPageNumberIndicator:withFrame:]):
(-[WKWebView _updatePDFPageNumberIndicator:currentPage:]):
(-[WKWebView _removeAnyPDFPageNumberIndicator]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:

Maintain a page number indicator (associated to a certain plugin) and
modify said indicator as necessary.

* Source/WebKit/UIProcess/PDF/WKPDFPageNumberIndicator.h: Added.
* Source/WebKit/UIProcess/PDF/WKPDFPageNumberIndicator.mm: Added.
(-[WKPDFPageNumberIndicator initWithFrame:view:pageCount:]):
(-[WKPDFPageNumberIndicator dealloc]):
(-[WKPDFPageNumberIndicator updatePosition:]):
(-[WKPDFPageNumberIndicator setCurrentPageNumber:]):
(-[WKPDFPageNumberIndicator setPageCount:]):
(-[WKPDFPageNumberIndicator show]):
(-[WKPDFPageNumberIndicator hide:]):
(-[WKPDFPageNumberIndicator _moveToPoint:animated:completionHandler:]):
(-[WKPDFPageNumberIndicator sizeThatFits:]):
(-[WKPDFPageNumberIndicator _updateLabel:]):

The implementation for the page number indicator. Things of note
include:

- We use a UIVisualEffectView to apply a blur style on the indicator.
- We maintain a timer that we use to present/dismiss the indicator
  predictably.

* Source/WebKit/UIProcess/PageClient.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCommitLoadForFrame):
(WebKit::WebPageProxy::resetStateAfterProcessTermination):

Destroy any lingering page number indicator instances as necessary.

* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::createPDFPageNumberIndicator):
(WebKit::PageClientImpl::removePDFPageNumberIndicator):
(WebKit::PageClientImpl::updatePDFPageNumberIndicatorLocation):
(WebKit::PageClientImpl::updatePDFPageNumberIndicatorCurrentPage):
(WebKit::PageClientImpl::removeAnyPDFPageNumberIndicator):
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::createPDFPageNumberIndicator):
(WebKit::WebPageProxy::removePDFPageNumberIndicator):
(WebKit::WebPageProxy::updatePDFPageNumberIndicatorLocation):
(WebKit::WebPageProxy::updatePDFPageNumberIndicatorCurrentPage):

Plumbing information flow from the plugin to the UI process to
(eventually) WKPDFPageNumberIndicator.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::frameViewLayoutOrVisualViewportChanged):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::teardown):
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::attemptToUnlockPDF):
(WebKit::UnifiedPDFPlugin::geometryDidChange):
(WebKit::UnifiedPDFPlugin::visibilityDidChange):
(WebKit::UnifiedPDFPlugin::frameForPageNumberIndicatorInRootViewCoordinates 
const):
(WebKit::UnifiedPDFPlugin::pageNumberIndicatorEnabled const):
(WebKit::UnifiedPDFPlugin::shouldShowPageNumberIndicator const):

There is a laundry list of conditions under which we do not want to show
the page number indicator, which includes:

- If the page number indicator preference is disabled.
- When the document is locked.
- For non-full-main-frame plugins.
- If the PluginView is not visible.
- If the PDF document is not installed yet.

(WebKit::UnifiedPDFPlugin::updatePageNumberIndicatorVisibility):
(WebKit::UnifiedPDFPlugin::updatePageNumberIndicatorLocation):
(WebKit::UnifiedPDFPlugin::updatePageNumberIndicatorCurrentPage):

The current page number can be deduced if we have the unobscured content
rect. We either get this plumbed to us from local frame view viewport
change updates, or we read this actively off of the local frame view as
neessary.

(WebKit::UnifiedPDFPlugin::updatePageNumberIndicator):
(WebKit::UnifiedPDFPlugin::frameViewLayoutOrVisualViewportChanged):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::frameViewLayoutOrVisualViewportChanged):
* Source/WebKit/WebProcess/Plugins/PluginView.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::frameViewLayoutOrVisualViewportChanged):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::frameViewLayoutOrVisualViewportChanged):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::createPDFPageNumberIndicator):
(WebKit::WebPage::updatePDFPageNumberIndicatorLocation):
(WebKit::WebPage::updatePDFPageNumberIndicatorCurrentPage):
(WebKit::WebPage::removePDFPageNumberIndicator):

More plumbing.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to