[webkit-changes] [WebKit/WebKit] 90ad90: [UnifiedPDF] Cursor should update correctly over t...

Abrar Rahman Protyasha noreply at github.com
Wed Dec 6 17:19:21 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 90ad90145f1d8c2e14aa0553119e03caf9056339
      https://github.com/WebKit/WebKit/commit/90ad90145f1d8c2e14aa0553119e03caf9056339
  Author: Abrar Rahman Protyasha <a_protyasha at apple.com>
  Date:   2023-12-06 (Wed, 06 Dec 2023)

  Changed paths:
    M Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h
    A Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h
    R Source/WebKit/Platform/spi/ios/PDFKitSPI.h
    M Source/WebKit/Shared/Cocoa/PDFKitSoftLink.h
    M Source/WebKit/Shared/Cocoa/PDFKitSoftLink.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Tools/TestWebKitAPI/Configurations/Base.xcconfig

  Log Message:
  -----------
  [UnifiedPDF] Cursor should update correctly over text and annotations
https://bugs.webkit.org/show_bug.cgi?id=265866
rdar://118550951

Reviewed by Tim Horton.

UnifiedPDFPlugin has the plumbing in place to send cursor updates to the
UI process, but does not actually know what annotations/text (or other
PDF elements of interest) exist under a given point in a PDF page. This
patch builds up our hit-testing logic to imbibe UnifiedPDFPlugin with
this knowledge.

The logic to build up our set of PDF elements under a point is fairly
straightforward as we consult (and map) the type of the annotation at a
given point reported by PDFKit. As for text and images, which are not
annotations, we have to call into CoreGraphics' PDFPageLayout SPI that
returns a bitset indicating the presence of text and images under a
given page point. Note that we only do so for tagged PDFs, since the SPI
in question does not return any information for PDFs that are not
tagged.

* Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h:

Provide declarations required to call into `CGPDFDocumentIsTaggedPDF`
and `CGPDFPageLayoutGetAreaOfInterestAtPoint`.

* Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h: Renamed from Source/WebKit/Platform/spi/ios/PDFKitSPI.h.

Move to a Cocoa subdirectory since this SPI declaration header is now
required in UnifiedPDFPlugin.mm.

Also, provide a declaration to be able to obtain a PDFPage object's
corresponding CGPDFPageLayout instance.

* Source/WebKit/Shared/Cocoa/PDFKitSoftLink.h:
* Source/WebKit/Shared/Cocoa/PDFKitSoftLink.mm:

Soft-link more PDFAnnotation-adjacent classes used for type equality
checks in our hit-testing logic.

Also, drive-by fix that sorts the PDFKit symbols alphabetically.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

In addition to moving PDFKitSPI.h around, also added WebKit target
membership for the file.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::toWebCoreCursorType):

Some drive-by ergonomics nicety to avoid having to type out the
`UniversalPDFPlugin::` prefix.

(WebKit::UnifiedPDFPlugin::isTaggedPDF const):

Add a method to query whether the PDFDocument is tagged.

(WebKit::UnifiedPDFPlugin::pdfElementTypesForPluginPoint const):

The bulk of the logic described in the commit message is implemented
here.

* Tools/TestWebKitAPI/Configurations/Base.xcconfig:

Since PDFKitSPI.h was moved to a Cocoa subdirectory, include said path
in the cocoatouch header search path.

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




More information about the webkit-changes mailing list