[webkit-changes] [WebKit/WebKit] 536ff7: [UnifiedPDF] Discrete presentation mode rewrite

Abrar Rahman Protyasha noreply at github.com
Wed Jul 24 03:13:32 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 536ff7116f47121c9677e9f9daf0b5922f8424df
      https://github.com/WebKit/WebKit/commit/536ff7116f47121c9677e9f9daf0b5922f8424df
  Author: Abrar Rahman Protyasha <a_protyasha at apple.com>
  Date:   2024-07-24 (Wed, 24 Jul 2024)

  Changed paths:
    M LayoutTests/http/tests/pdf/linearized-pdf-in-iframe.html
    M LayoutTests/pdf/unifiedpdf/annotations/dropdown-select-second-option.html
    M LayoutTests/platform/mac-ventura/TestExpectations
    M Source/WebCore/dom/Document.h
    M Source/WebCore/platform/ScrollableArea.h
    M Source/WebCore/platform/animation/TimingFunction.cpp
    M Source/WebCore/platform/animation/TimingFunction.h
    M Source/WebCore/platform/graphics/transforms/TransformOperations.h
    M Source/WebKit/SourcesCocoa.txt
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.h
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.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/PDFPageCoverage.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPageCoverage.mm
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.h
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.mm
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.h
    A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm

  Log Message:
  -----------
  [UnifiedPDF] Discrete presentation mode rewrite
https://bugs.webkit.org/show_bug.cgi?id=276622
rdar://125383130

Reviewed by Tim Horton and Simon Fraser.

This patch rewrites document presentation in Unified PDF. We introduce
the notion of a `PDFPresentationController`, which handles how a PDF
document is presented. The PDF plugins also delegate event handling to
these presentation controllers.

We specialize the behavior of the presentation controller class
class to distinguish between continuous (scrolling) and discrete mode.

These changes are based primarily on a patch originally from Simon Fraser.

* LayoutTests/platform/mac-ventura/TestExpectations

Skip tests that enable UnifiedPDFPlugin on macOS 13. These tests crash
on that platform, and the UnifiedPDF plugin is meaningless before macOS
14 anyway.

* Source/WebCore/dom/Document.h:
* Source/WebCore/platform/ScrollableArea.h:
* Source/WebCore/platform/animation/TimingFunction.cpp:
(WebCore::CubicBezierTimingFunction::create):
* Source/WebCore/platform/animation/TimingFunction.h:
* Source/WebCore/platform/graphics/transforms/TransformOperations.h:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::overhangAmount const):
(WebKit::PDFPluginBase::wantsWheelEventsChanged):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/AsyncPDFRenderer.mm:
(WebKit::AsyncPDFRenderer::teardown):
(WebKit::AsyncPDFRenderer::releaseMemory):
(WebKit::AsyncPDFRenderer::startTrackingLayer):
(WebKit::AsyncPDFRenderer::stopTrackingLayer):
(WebKit::AsyncPDFRenderer::layerForTileGrid const):
(WebKit::AsyncPDFRenderer::renderInfoIsValidForTile const):
(WebKit::AsyncPDFRenderer::willRepaintTile):
(WebKit::AsyncPDFRenderer::coverageRectDidChange):
(WebKit::AsyncPDFRenderer::removePagePreviewsOutsideCoverageRect):
(WebKit::AsyncPDFRenderer::didAddGrid):
(WebKit::AsyncPDFRenderer::willRemoveGrid):
(WebKit::AsyncPDFRenderer::enqueueTilePaintIfNecessary):
(WebKit::AsyncPDFRenderer::renderInfoForTile const):
(WebKit::AsyncPDFRenderer::paintPDFIntoBuffer):
(WebKit::AsyncPDFRenderer::paintPDFPageIntoBuffer):
(WebKit::AsyncPDFRenderer::transferBufferToMainThread):
(WebKit::AsyncPDFRenderer::didCompleteTileRender):
(WebKit::AsyncPDFRenderer::paintTilesForPage):
(WebKit::AsyncPDFRenderer::pdfContentChangedInRect):
(WebKit::AsyncPDFRenderer::setupWithLayer): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.h: Added.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.mm: Added.
(WebKit::elasticDeltaForTimeDelta):
(WebKit::operator<<):
(WebKit::PDFDiscretePresentationController::PDFDiscretePresentationController):
(WebKit::PDFDiscretePresentationController::teardown):
(WebKit::PDFDiscretePresentationController::supportsDisplayMode const):
(WebKit::PDFDiscretePresentationController::willChangeDisplayMode):
(WebKit::PDFDiscretePresentationController::handleKeyboardEvent):
(WebKit::PDFDiscretePresentationController::handleKeyboardCommand):
(WebKit::PDFDiscretePresentationController::handleKeyboardEventForPageNavigation):
(WebKit::PDFDiscretePresentationController::canTransitionOnSide const):
(WebKit::PDFDiscretePresentationController::canTransitionInDirection const):
(WebKit::PDFDiscretePresentationController::handleWheelEvent):
(WebKit::PDFDiscretePresentationController::eventCanStartPageTransition const):
(WebKit::PDFDiscretePresentationController::handleBeginEvent):
(WebKit::PDFDiscretePresentationController::handleChangedEvent):
(WebKit::PDFDiscretePresentationController::handleEndedEvent):
(WebKit::PDFDiscretePresentationController::handleCancelledEvent):
(WebKit::PDFDiscretePresentationController::handleDiscreteWheelEvent):
(WebKit::PDFDiscretePresentationController::maybeEndGesture):
(WebKit::PDFDiscretePresentationController::gestureEndTimerFired):
(WebKit::PDFDiscretePresentationController::startPageTransitionOrSettle):
(WebKit::PDFDiscretePresentationController::updateState):
(WebKit::PDFDiscretePresentationController::startOrStopAnimationTimerIfNecessary):
(WebKit::PDFDiscretePresentationController::animationTimerFired):
(WebKit::PDFDiscretePresentationController::animateRubberBand):
(WebKit::PDFDiscretePresentationController::startTransitionAnimation):
(WebKit::PDFDiscretePresentationController::transitionEndTimerFired):
(WebKit::PDFDiscretePresentationController::additionalVisibleRowIndexForDirection const):
(WebKit::PDFDiscretePresentationController::updateLayerVisibilityForTransitionState):
(WebKit::PDFDiscretePresentationController::applyWheelEventDelta):
(WebKit::PDFDiscretePresentationController::relevantAxisForDirection):
(WebKit::PDFDiscretePresentationController::setRelevantAxisForDirection):
(WebKit::PDFDiscretePresentationController::layerOpacitiesForStretchOffset const):
(WebKit::PDFDiscretePresentationController::layerOffsetForStretch const):
(WebKit::PDFDiscretePresentationController::updateLayersForTransitionState):
(WebKit::PDFDiscretePresentationController::canGoToNextRow const):
(WebKit::PDFDiscretePresentationController::canGoToPreviousRow const):
(WebKit::PDFDiscretePresentationController::goToNextRow):
(WebKit::PDFDiscretePresentationController::goToPreviousRow):
(WebKit::PDFDiscretePresentationController::goToRowIndex):
(WebKit::PDFDiscretePresentationController::setVisibleRow):
(WebKit::PDFDiscretePresentationController::pageCoverageForContentsRect const):
(WebKit::PDFDiscretePresentationController::pageCoverageAndScalesForContentsRect const):
(WebKit::PDFDiscretePresentationController::contentsOffsetForPage const):
(WebKit::PDFDiscretePresentationController::convertFromContentsToPainting const):
(WebKit::PDFDiscretePresentationController::convertFromPaintingToContents const):
(WebKit::PDFDiscretePresentationController::deviceOrPageScaleFactorChanged):
(WebKit::PDFDiscretePresentationController::setupLayers):
(WebKit::PDFDiscretePresentationController::buildRows):
(WebKit::PDFDiscretePresentationController::positionForRowContainerLayer const):
(WebKit::PDFDiscretePresentationController::rowContainerSize const):
(WebKit::PDFDiscretePresentationController::updateLayersOnLayoutChange):
(WebKit::PDFDiscretePresentationController::updateLayersAfterChangeInVisibleRow):
(WebKit::PDFDiscretePresentationController::updateIsInWindow):
(WebKit::PDFDiscretePresentationController::updateDebugBorders):
(WebKit::PDFDiscretePresentationController::updateForCurrentScrollability):
(WebKit::PDFDiscretePresentationController::repaintForIncrementalLoad):
(WebKit::PDFDiscretePresentationController::setNeedsRepaintInDocumentRect):
(WebKit::PDFDiscretePresentationController::didGeneratePreviewForPage):
(WebKit::PDFDiscretePresentationController::pdfPositionForCurrentView const):
(WebKit::PDFDiscretePresentationController::restorePDFPosition):
(WebKit::PDFDiscretePresentationController::ensurePageIsVisible):
(WebKit::PDFDiscretePresentationController::notifyFlushRequired):
(WebKit::PDFDiscretePresentationController::pageScaleFactor const):
(WebKit::PDFDiscretePresentationController::deviceScaleFactor const):
(WebKit::PDFDiscretePresentationController::customContentsScale const):
(WebKit::PDFDiscretePresentationController::layerNeedsPlatformContext const):
(WebKit::PDFDiscretePresentationController::tiledBackingUsageChanged):
(WebKit::PDFDiscretePresentationController::paintBackgroundLayerForRow):
(WebKit::PDFDiscretePresentationController::rowDataForLayerID const const):
(WebKit::PDFDiscretePresentationController::visibleRow const):
(WebKit::PDFDiscretePresentationController::rowForLayerID const):
(WebKit::PDFDiscretePresentationController::paintContents):
(WebKit::PDFDiscretePresentationController::paintPDFSelection):
(WebKit::PDFDiscretePresentationController::RowData::isPageBackgroundLayer const):
(WebKit::PDFDiscretePresentationController::RowData::leftPageBackgroundLayer const):
(WebKit::PDFDiscretePresentationController::RowData::rightPageBackgroundLayer const):
(WebKit::PDFDiscretePresentationController::RowData::backgroundLayerForPageIndex const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::nearestPageIndexForDocumentPoint const):
(WebKit::PDFDocumentLayout::updateLayout):
(WebKit::PDFDocumentLayout::layoutPages):
(WebKit::PDFDocumentLayout::layoutContinuousRows):
(WebKit::PDFDocumentLayout::layoutDiscreteRows):
(WebKit::PDFDocumentLayout::layoutRow):
(WebKit::PDFDocumentLayout::layoutSingleColumn): Deleted.
(WebKit::PDFDocumentLayout::layoutTwoUpColumn): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPageCoverage.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPageCoverage.mm:
(WebKit::operator<<):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.h: Added.
(WebKit::PDFPresentationController::convertFromContentsToPainting):
(WebKit::PDFPresentationController::convertFromPaintingToContents):
(WebKit::PDFPresentationController::visibleRow const):
(WebKit::PDFPresentationController::rowForLayerID const):
(WebKit::PDFPresentationController::wantsWheelEvents const):
(WebKit::PDFPresentationController::handleWheelEvent):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.mm: Added.
(WebKit::PDFPresentationController::createForMode):
(WebKit::PDFPresentationController::PDFPresentationController):
(WebKit::PDFPresentationController::teardown):
(WebKit::PDFPresentationController::asyncRenderer):
(WebKit::PDFPresentationController::asyncRendererIfExists const):
(WebKit::PDFPresentationController::clearAsyncRenderer):
(WebKit::PDFPresentationController::createGraphicsLayer):
(WebKit::PDFPresentationController::makePageContainerLayer):
(WebKit::PDFPresentationController::pageBackgroundLayerForPageContainerLayer):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.h: Added.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.mm: Added.
(WebKit::PDFScrollingPresentationController::PDFScrollingPresentationController):
(WebKit::PDFScrollingPresentationController::teardown):
(WebKit::PDFScrollingPresentationController::supportsDisplayMode const):
(WebKit::PDFScrollingPresentationController::handleKeyboardEvent):
(WebKit::PDFScrollingPresentationController::checkedKeyboardScrollingAnimator const):
(WebKit::PDFScrollingPresentationController::handleKeyboardCommand):
(WebKit::PDFScrollingPresentationController::pageCoverageForContentsRect const):
(WebKit::PDFScrollingPresentationController::pageCoverageAndScalesForContentsRect const):
(WebKit::PDFScrollingPresentationController::setupLayers):
(WebKit::PDFScrollingPresentationController::updateLayersOnLayoutChange):
(WebKit::PDFScrollingPresentationController::updatePageBackgroundLayers):
(WebKit::PDFScrollingPresentationController::backgroundLayerForPage const):
(WebKit::PDFScrollingPresentationController::didGeneratePreviewForPage):
(WebKit::PDFScrollingPresentationController::repaintForIncrementalLoad):
(WebKit::PDFScrollingPresentationController::updateIsInWindow):
(WebKit::PDFScrollingPresentationController::updateDebugBorders):
(WebKit::PDFScrollingPresentationController::updateForCurrentScrollability):
(WebKit::PDFScrollingPresentationController::setNeedsRepaintInDocumentRect):
(WebKit::PDFScrollingPresentationController::paintBackgroundLayerForPage):
(WebKit::PDFScrollingPresentationController::pageIndexForPageBackgroundLayer const):
(WebKit::PDFScrollingPresentationController::pdfPositionForCurrentView const):
(WebKit::PDFScrollingPresentationController::restorePDFPosition):
(WebKit::PDFScrollingPresentationController::notifyFlushRequired):
(WebKit::PDFScrollingPresentationController::pageScaleFactor const):
(WebKit::PDFScrollingPresentationController::deviceScaleFactor const):
(WebKit::PDFScrollingPresentationController::customContentsScale const):
(WebKit::PDFScrollingPresentationController::layerNeedsPlatformContext const):
(WebKit::PDFScrollingPresentationController::tiledBackingUsageChanged):
(WebKit::PDFScrollingPresentationController::paintContents):
(WebKit::PDFScrollingPresentationController::paintPDFSelection):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
(WebKit::UnifiedPDFPlugin::convertDown const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::teardown):
(WebKit::UnifiedPDFPlugin::setPresentationController):
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::graphicsLayerFactory const):
(WebKit::UnifiedPDFPlugin::setNeedsRepaintForAnnotation):
(WebKit::UnifiedPDFPlugin::setNeedsRepaintInDocumentRect):
(WebKit::UnifiedPDFPlugin::setNeedsRepaintInDocumentRects):
(WebKit::UnifiedPDFPlugin::ensureLayers):
(WebKit::UnifiedPDFPlugin::repaintForIncrementalLoad):
(WebKit::UnifiedPDFPlugin::didGeneratePreviewForPage):
(WebKit::UnifiedPDFPlugin::didSameDocumentNavigationForFrame):
(WebKit::UnifiedPDFPlugin::updateLayerHierarchy):
(WebKit::UnifiedPDFPlugin::didChangeSettings):
(WebKit::UnifiedPDFPlugin::isInWindow const):
(WebKit::UnifiedPDFPlugin::didChangeIsInWindow):
(WebKit::UnifiedPDFPlugin::paint):
(WebKit::UnifiedPDFPlugin::paintContents):
(WebKit::UnifiedPDFPlugin::pageCoverageForContentsRect const):
(WebKit::UnifiedPDFPlugin::pageCoverageAndScalesForContentsRect const):
(WebKit::UnifiedPDFPlugin::paintPDFContent):
(WebKit::UnifiedPDFPlugin::paintPDFSelection):
(WebKit::UnifiedPDFPlugin::rowForLayerID const):
(WebKit::UnifiedPDFPlugin::pageScaleFactor const):
(WebKit::UnifiedPDFPlugin::didEndMagnificationGesture):
(WebKit::UnifiedPDFPlugin::setScaleFactor):
(WebKit::UnifiedPDFPlugin::setPageScaleFactor):
(WebKit::UnifiedPDFPlugin::deviceOrPageScaleFactorChanged):
(WebKit::UnifiedPDFPlugin::updateLayout):
(WebKit::UnifiedPDFPlugin::releaseMemory):
(WebKit::UnifiedPDFPlugin::didChangeScrollOffset):
(WebKit::UnifiedPDFPlugin::willChangeVisibleRow):
(WebKit::UnifiedPDFPlugin::didChangeVisibleRow):
(WebKit::UnifiedPDFPlugin::updateScrollingExtents):
(WebKit::UnifiedPDFPlugin::nearestPageIndexForDocumentPoint const):
(WebKit::UnifiedPDFPlugin::pageIndexForDocumentPoint const):
(WebKit::UnifiedPDFPlugin::indexForCurrentPageInView const):
(WebKit::UnifiedPDFPlugin::convertFromContentsToPainting const):
(WebKit::UnifiedPDFPlugin::convertFromPaintingToContents const):
(WebKit::UnifiedPDFPlugin::pdfElementTypesForPluginPoint const):
(WebKit::UnifiedPDFPlugin::handleMouseEvent):
(WebKit::UnifiedPDFPlugin::wantsWheelEvents const):
(WebKit::UnifiedPDFPlugin::handleWheelEvent):
(WebKit::UnifiedPDFPlugin::wheelEventCopyWithVelocity const):
(WebKit::UnifiedPDFPlugin::handleKeyboardEvent):
(WebKit::UnifiedPDFPlugin::revealRectInPage):
(WebKit::UnifiedPDFPlugin::revealPointInPage):
(WebKit::UnifiedPDFPlugin::revealPage):
(WebKit::UnifiedPDFPlugin::scrollToPointInContentsSpace):
(WebKit::UnifiedPDFPlugin::createContextMenu const):
(WebKit::UnifiedPDFPlugin::pageCoverageForSelection const):
(WebKit::UnifiedPDFPlugin::repaintOnSelectionChange):
(WebKit::UnifiedPDFPlugin::continueAutoscroll):
(WebKit::UnifiedPDFPlugin::rectsForTextMatchesInRect const):
(WebKit::UnifiedPDFPlugin::textIndicatorForSelection):
(WebKit::UnifiedPDFPlugin::setDisplayMode):
(WebKit::UnifiedPDFPlugin::setDisplayModeAndUpdateLayout):
(WebKit::UnifiedPDFPlugin::asyncRenderer): Deleted.
(WebKit::UnifiedPDFPlugin::asyncRendererIfExists const): Deleted.
(WebKit::UnifiedPDFPlugin::updatePageBackgroundLayers): Deleted.
(WebKit::UnifiedPDFPlugin::paintBackgroundLayerForPage): Deleted.
(WebKit::UnifiedPDFPlugin::backgroundLayerForPage const): Deleted.
(WebKit::UnifiedPDFPlugin::pageIndexForPageBackgroundLayer const): Deleted.
(WebKit::UnifiedPDFPlugin::updateLayerPositions): Deleted.
(WebKit::UnifiedPDFPlugin::customContentsScale const): Deleted.
(WebKit::UnifiedPDFPlugin::layerNeedsPlatformContext const): Deleted.
(WebKit::UnifiedPDFPlugin::tiledBackingUsageChanged): Deleted.
(WebKit::UnifiedPDFPlugin::pageCoverageForRect const): Deleted.
(WebKit::UnifiedPDFPlugin::pageCoverageAndScalesForRect const): Deleted.
(WebKit::UnifiedPDFPlugin::scrollAnchoringForCurrentScrollPosition const): Deleted.
(WebKit::UnifiedPDFPlugin::restoreScrollPositionWithInfo): Deleted.
(WebKit::UnifiedPDFPlugin::populateScrollSnapIdentifiers): Deleted.
(WebKit::UnifiedPDFPlugin::pageForScrollSnapIdentifier const): Deleted.
(WebKit::UnifiedPDFPlugin::updateSnapOffsets): Deleted.
(WebKit::UnifiedPDFPlugin::determineCurrentlySnappedPage): Deleted.
(WebKit::UnifiedPDFPlugin::visibleRow const): Deleted.
(WebKit::UnifiedPDFPlugin::shouldDisplayPage): Deleted.
(WebKit::UnifiedPDFPlugin::convertDown const): Deleted.
(WebKit::UnifiedPDFPlugin::handleKeyboardCommand): Deleted.
(WebKit::UnifiedPDFPlugin::handleKeyboardEventForDiscreteDisplayMode): Deleted.
(WebKit::UnifiedPDFPlugin::snapToNearbyPageExtentForKeyboardScrolling): Deleted.
(WebKit::UnifiedPDFPlugin::showOrHideSelectionLayerAsNecessary): Deleted.

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list