[webkit-changes] [WebKit/WebKit] 37723d: [UnifiedPDF] Data detection overlays should show o...
Abrar Rahman Protyasha
noreply at github.com
Thu Mar 14 20:02:37 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 37723d9e6498a980cb60caec159f92c546f4726b
https://github.com/WebKit/WebKit/commit/37723d9e6498a980cb60caec159f92c546f4726b
Author: Abrar Rahman Protyasha <a_protyasha at apple.com>
Date: 2024-03-14 (Thu, 14 Mar 2024)
Changed paths:
M Source/WTF/wtf/PlatformEnableCocoa.h
M Source/WebCore/PAL/pal/cocoa/DataDetectorsCoreSoftLink.h
M Source/WebCore/PAL/pal/cocoa/DataDetectorsCoreSoftLink.mm
M Source/WebCore/PAL/pal/spi/cocoa/DataDetectorsCoreSPI.h
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/platform/mac/DataDetectorHighlight.h
M Source/WebCore/platform/mac/DataDetectorHighlight.mm
M Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h
M Source/WebKit/Shared/Cocoa/PDFKitSoftLink.h
M Source/WebKit/Shared/Cocoa/PDFKitSoftLink.mm
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
A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorItem.h
A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorItem.mm
A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorOverlayController.h
A Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorOverlayController.mm
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
Log Message:
-----------
[UnifiedPDF] Data detection overlays should show on PDFs
https://bugs.webkit.org/show_bug.cgi?id=270998
rdar://123761050
Reviewed by Simon Fraser.
Currently, we do not surface any data detection results on
UnifiedPDFPlugin. This patch introduces the plumbing required to
fetch data detection results from PDFKit, the infrastructure to display
data detector overlays, and the requisite event handling/state
management to only display (or act on) a data detection result when the
mouse hovers/clicks over it.
To facilitate this end:
- Introduce two classes WebKit::PDFDataDetectorItem and
WebKit::PDFDataDetectorOverlayController. The former encapsulates all
the data we need to represent a data detection scanning result
obtained from PDFKit, while the latter manages all the state for us to
be able to indicate data detector results as page overlays.
- Introduce new public helpers on UnifiedPDFPlugin that
PDFDataDetectorOverlayController can use to delegate work. Notably,
this is required for us to implement the updated
DataDetectorHighlightClient interface from 276060 at main.
- Modify WebCore::DataDetectorHighlight to understand a new type of
highlight corresponding to PDF selections.
* Source/WTF/wtf/PlatformEnableCocoa.h:
Add a new PlatformEnable flag so we don't have to litter the codebase
with #if ENABLE(UNIFIED_PDF) && ENABLE(DATA_DETECTION) && PLATFORM(MAC)
* Source/WebCore/PAL/pal/cocoa/DataDetectorsCoreSoftLink.h:
* Source/WebCore/PAL/pal/cocoa/DataDetectorsCoreSoftLink.mm:
DDResultIsPastDate is available (and used) on non-IOS_FAMILY platforms,
so let's move its declaration out from the platform-specific section.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/mac/DataDetectorHighlight.h:
* Source/WebCore/platform/mac/DataDetectorHighlight.mm:
(WebCore::DataDetectorHighlight::createForPDFSelection):
(WebCore::DataDetectorHighlight::isRangeSupportingType const):
* Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h:
* Source/WebKit/Shared/Cocoa/PDFKitSoftLink.h:
* Source/WebKit/Shared/Cocoa/PDFKitSoftLink.mm:
* 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::lastKnownMousePositionInView const):
(WebKit::PDFPluginBase::mousePositionInView const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorItem.h: Added.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorItem.mm: Added.
(WebKit::hasActionsForResult):
(WebKit::resultIsPastDate):
(WebKit::PDFDataDetectorItem::create):
(WebKit::PDFDataDetectorItem::PDFDataDetectorItem):
(WebKit::PDFDataDetectorItem::scannerResult const):
(WebKit::PDFDataDetectorItem::hasActions const):
(WebKit::PDFDataDetectorItem::isPastDate const):
(WebKit::PDFDataDetectorItem::selection const):
(WebKit::PDFDataDetectorItem::pageBounds const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorOverlayController.h: Added.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDataDetectorOverlayController.mm: Added.
(WebKit::PDFDataDetectorOverlayController::PDFDataDetectorOverlayController):
(WebKit::PDFDataDetectorOverlayController::protectedPlugin const):
(WebKit::PDFDataDetectorOverlayController::installOverlayIfNeeded):
(WebKit::PDFDataDetectorOverlayController::uninstallOverlay):
(WebKit::PDFDataDetectorOverlayController::teardown):
(WebKit::createPlatformDataDetectorHighlight):
(WebKit::PDFDataDetectorOverlayController::createPlatformDataDetectorHighlight const):
(WebKit::PDFDataDetectorOverlayController::handleMouseEvent):
(WebKit::PDFDataDetectorOverlayController::handleDataDetectorAction):
(WebKit::PDFDataDetectorOverlayController::updateDataDetectorHighlightsIfNeeded):
(WebKit::PDFDataDetectorOverlayController::updatePlatformHighlightData):
(WebKit::PDFDataDetectorOverlayController::didInvalidateHighlightOverlayRects):
(WebKit::PDFDataDetectorOverlayController::willMoveToPage):
(WebKit::PDFDataDetectorOverlayController::scheduleRenderingUpdate):
(WebKit::PDFDataDetectorOverlayController::deviceScaleFactor const):
(WebKit::PDFDataDetectorOverlayController::createGraphicsLayer):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::UnifiedPDFPlugin):
(WebKit::UnifiedPDFPlugin::teardown):
(WebKit::UnifiedPDFPlugin::installPDFDocument):
(WebKit::UnifiedPDFPlugin::enableDataDetection):
(WebKit::UnifiedPDFPlugin::handleClickForDataDetectionResult):
(WebKit::UnifiedPDFPlugin::createGraphicsLayer):
Refactor createGraphicsLayer into three overloads so it isn't
inconvenient to use internally or from the overlay controller.
(WebKit::UnifiedPDFPlugin::scheduleRenderingUpdate):
(WebKit::UnifiedPDFPlugin::pageAtIndex const):
Expose this helper to avoid having to pass the entire PDFDocumentLayout
object to the overlay controller.
(WebKit::UnifiedPDFPlugin::didChangeScrollOffset):
Repaint the data detector overlays to our hearts content on a scroll. To
be optimized!
(WebKit::UnifiedPDFPlugin::handleMouseEvent):
(WebKit::UnifiedPDFPlugin::rectForSelectionInPluginSpace const):
(WebKit::UnifiedPDFPlugin::installDataDetectorOverlay):
(WebKit::UnifiedPDFPlugin::uninstallDataDetectorOverlay):
Canonical link: https://commits.webkit.org/276131@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