Skip to content

Commit ce5a85a

Browse files
committed
[UnifiedPDF] PDFPluginBase should send cursor updates to the web page
https://bugs.webkit.org/show_bug.cgi?id=264913 rdar://118483364 Reviewed by Tim Horton. In preparation to get cursor updates working for `UnifiedPDFPlugin`, we should move `PDFPlugin::notifyCursorChanged` up into the `PDFPluginBase` structure. We should be doing the same (trivial) amount of work for both PDF plugin types to send cursor updates to the web page. * Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h: * Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm: (toWebCoreCursorType): (-[WKPDFLayerControllerDelegate setMouseCursor:]): (WebKit::PDFPlugin::notifySelectionChanged): (WebKit::coreCursor): Deleted. (WebKit::PDFPlugin::notifyCursorChanged): Deleted. * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h: * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm: (WebKit::PDFPluginBase::notifyCursorChanged): Canonical link: https://commits.webkit.org/270863@main
1 parent 7bce33d commit ce5a85a

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ class PDFPlugin final : public PDFPluginBase {
9898
void notifyDisplayModeChanged(int);
9999

100100
void notifySelectionChanged(PDFSelection *);
101-
void notifyCursorChanged(uint64_t /* PDFLayerControllerCursorType */);
102101

103102
// HUD Actions.
104103
#if ENABLE(PDF_HUD)

Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,18 @@ - (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin;
428428

429429
@end
430430

431+
static WebCore::Cursor::Type toWebCoreCursorType(PDFLayerControllerCursorType cursorType)
432+
{
433+
switch (cursorType) {
434+
case kPDFLayerControllerCursorTypePointer: return WebCore::Cursor::Type::Pointer;
435+
case kPDFLayerControllerCursorTypeHand: return WebCore::Cursor::Type::Hand;
436+
case kPDFLayerControllerCursorTypeIBeam: return WebCore::Cursor::Type::IBeam;
437+
}
438+
439+
RELEASE_ASSERT_NOT_REACHED();
440+
return WebCore::Cursor::Type::Pointer;
441+
}
442+
431443
@implementation WKPDFLayerControllerDelegate
432444

433445
@synthesize pdfPlugin = _pdfPlugin;
@@ -519,7 +531,7 @@ - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didUpdateLay
519531

520532
- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType
521533
{
522-
_pdfPlugin->notifyCursorChanged(cursorType);
534+
_pdfPlugin->notifyCursorChanged(toWebCoreCursorType(cursorType));
523535
}
524536

525537
- (void)didChangeAnnotationState
@@ -2292,27 +2304,6 @@ static bool getEventTypeFromWebEvent(const WebEvent& event, NSEventType& eventTy
22922304
m_frame->page()->didChangeSelection(*m_frame->coreLocalFrame());
22932305
}
22942306

2295-
static const WebCore::Cursor& coreCursor(PDFLayerControllerCursorType type)
2296-
{
2297-
switch (type) {
2298-
case kPDFLayerControllerCursorTypeHand:
2299-
return WebCore::handCursor();
2300-
case kPDFLayerControllerCursorTypeIBeam:
2301-
return WebCore::iBeamCursor();
2302-
case kPDFLayerControllerCursorTypePointer:
2303-
default:
2304-
return WebCore::pointerCursor();
2305-
}
2306-
}
2307-
2308-
void PDFPlugin::notifyCursorChanged(uint64_t type)
2309-
{
2310-
if (!m_frame || !m_frame->page())
2311-
return;
2312-
2313-
m_frame->page()->send(Messages::WebPageProxy::SetCursor(coreCursor(static_cast<PDFLayerControllerCursorType>(type))));
2314-
}
2315-
23162307
String PDFPlugin::getSelectionString() const
23172308
{
23182309
return [[m_pdfLayerController currentSelection] string];

Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class HTMLPlugInElement;
5454
class ResourceResponse;
5555
class Scrollbar;
5656
class SharedBuffer;
57+
enum class PlatformCursorType : uint8_t;
5758
}
5859

5960
namespace WebKit {
@@ -167,6 +168,8 @@ class PDFPluginBase : public ThreadSafeRefCounted<PDFPluginBase>, public WebCore
167168
virtual void openWithPreview(CompletionHandler<void(const String&, FrameInfoData&&, const IPC::DataReference&, const String&)>&&) = 0;
168169
#endif
169170

171+
void notifyCursorChanged(WebCore::PlatformCursorType);
172+
170173
protected:
171174
explicit PDFPluginBase(WebCore::HTMLPlugInElement&);
172175

Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@
2828

2929
#if ENABLE(PDF_PLUGIN)
3030

31+
#import "MessageSenderInlines.h"
3132
#import "PluginView.h"
3233
#import "WebEventConversion.h"
3334
#import "WebFrame.h"
3435
#import "WebPage.h"
36+
#import "WebPageProxyMessages.h"
3537
#import <CoreFoundation/CoreFoundation.h>
3638
#import <WebCore/AXObjectCache.h>
3739
#import <WebCore/ArchiveResource.h>
3840
#import <WebCore/Chrome.h>
41+
#import <WebCore/Cursor.h>
3942
#import <WebCore/Document.h>
4043
#import <WebCore/FocusController.h>
4144
#import <WebCore/Frame.h>
@@ -558,6 +561,14 @@
558561

559562
#endif // ENABLE(PDF_HUD)
560563

564+
void PDFPluginBase::notifyCursorChanged(WebCore::PlatformCursorType cursorType)
565+
{
566+
if (!m_frame || !m_frame->page())
567+
return;
568+
569+
m_frame->protectedPage()->send(Messages::WebPageProxy::SetCursor(WebCore::Cursor::fromType(cursorType)));
570+
}
571+
561572
} // namespace WebKit
562573

563574
#endif // ENABLE(PDF_PLUGIN)

0 commit comments

Comments
 (0)