Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
#endif // PLATFORM(IOS_FAMILY)

#import <PDFKit/PDFDocumentPriv.h>
#import <PDFKit/PDFPagePriv.h>
#import <PDFKit/PDFSelectionPriv.h>

#if __has_include(<PDFKit/PDFActionPriv.h>)
#import <PDFKit/PDFActionPriv.h>
#else
Expand Down Expand Up @@ -122,6 +124,23 @@
@end
#endif

#if HAVE(PDFPAGE_AREA_OF_INTEREST_AT_POINT)
#define PDFAreaOfInterest NSInteger

#define kPDFTextArea (1UL << 1)
#define kPDFAnnotationArea (1UL << 2)
#define kPDFLinkArea (1UL << 3)
#define kPDFControlArea (1UL << 4)
#define kPDFTextFieldArea (1UL << 5)
#define kPDFIconArea (1UL << 6)
#define kPDFPopupArea (1UL << 7)
#define kPDFImageArea (1UL << 8)

@interface PDFPage (Staging_119217538)
- (PDFAreaOfInterest)areaOfInterestAtPoint:(PDFPoint)point;
@end
#endif

#if HAVE(PDFDOCUMENT_SELECTION_WITH_GRANULARITY)
typedef NS_ENUM(NSUInteger, PDFSelectionGranularity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,38 @@ static BOOL annotationIsLinkWithDestination(PDFAnnotation *annotation)

PDFElementTypes pdfElementTypes { PDFElementType::Page };

#if HAVE(PDFPAGE_AREA_OF_INTEREST_AT_POINT)
if ([page respondsToSelector:@selector(areaOfInterestAtPoint:)]) {
PDFAreaOfInterest areaOfInterest = [page areaOfInterestAtPoint:pointInPDFPageSpace];

if (areaOfInterest & kPDFTextArea)
pdfElementTypes.add(PDFElementType::Text);

if (areaOfInterest & kPDFAnnotationArea)
pdfElementTypes.add(PDFElementType::Annotation);

if ((areaOfInterest & kPDFLinkArea) && annotationIsLinkWithDestination([page annotationAtPoint:pointInPDFPageSpace]))
pdfElementTypes.add(PDFElementType::Link);

if (areaOfInterest & kPDFControlArea)
pdfElementTypes.add(PDFElementType::Control);

if (areaOfInterest & kPDFTextFieldArea)
pdfElementTypes.add(PDFElementType::TextField);

if (areaOfInterest & kPDFIconArea)
pdfElementTypes.add(PDFElementType::Icon);

if (areaOfInterest & kPDFPopupArea)
pdfElementTypes.add(PDFElementType::Popup);

if (areaOfInterest & kPDFImageArea)
pdfElementTypes.add(PDFElementType::Image);

return pdfElementTypes;
}
#endif

if (auto annotation = [page annotationAtPoint:pointInPDFPageSpace]) {
pdfElementTypes.add(PDFElementType::Annotation);

Expand Down Expand Up @@ -1658,8 +1690,6 @@ static BOOL annotationIsLinkWithDestination(PDFAnnotation *annotation)
}
#endif

// FIXME: <https://webkit.org/b/265908> Cursor updates are incorrect over text/image elements for untagged PDFs.

return pdfElementTypes;
}

Expand Down