Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add WKHoverPlatter and some knobs to tweak its appearance
https://bugs.webkit.org/show_bug.cgi?id=227735
<rdar://problem/79198262>

Reviewed by Sam Weinig.

Source/WebCore/PAL:

* pal/spi/cocoa/QuartzCoreSPI.h:

Source/WebKit:

* Configurations/WebKit.xcconfig:
* Platform/spi/ios/PrototypeToolsSPI.h: Added.
* SourcesCocoa.txt:
* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView rootContentView]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setUpInteraction]):
(-[WKContentView cleanUpInteraction]):
Install and uninstall the platter alongside the gestures that drive it.

(-[WKContentView mouseGestureRecognizerChanged:]):
(-[WKContentView hoverGestureRecognizerChanged:]):
When the gesture recognizers fire, also update the hover point.

(-[WKContentView positionInformationForHoverPlatter:withRequest:completionHandler:]):
* UIProcess/ios/WKHoverPlatter.h: Added.
* UIProcess/ios/WKHoverPlatter.mm: Added.
(createBaseAnimation):
(addAnimation):
(setAdditionalPlatterLayerProperties):
(addAdditionalIncomingAnimations):
(addAdditionalDismissalAnimations):
(-[WKHoverPlatter initWithView:delegate:]):
(-[WKHoverPlatter invalidate]):
(-[WKHoverPlatter hoverPoint]):
(-[WKHoverPlatter setHoverPoint:]):
(-[WKHoverPlatter requestPositionInformationForCurrentHoverPoint]):
(-[WKHoverPlatter didReceivePositionInformation:]):
(-[WKHoverPlatter dismissPlatterWithAnimation:]):
(-[WKHoverPlatter didFinishAnimationForShadow:]):
(-[WKHoverPlatter clearLayers]):
Animate the platter in and out, and optionally between states, as the hover point moves.
Use the TextIndicator's geometry information, but not its snapshot; we use a
CAPortalLayer for the platter instead. A future patch will avoid taking the snapshot
entirely, since we call setHoverPoint (and thus generate a TextIndicator) a *lot*
when moving the mouse around, and all those snapshots add up.

* UIProcess/ios/WKHoverPlatterParameters.h: Added.
* UIProcess/ios/WKHoverPlatterParameters.mm: Added.
(-[PTSliderRow integerMinValue:maxValue:]):
(-[WKHoverPlatterParameters setDefaultValues]):
(+[WKHoverPlatterParameters settingsControllerModule]):
(+[WKHoverPlatterDomain rootSettings]):
(+[WKHoverPlatterDomain domainGroupName]):
(+[WKHoverPlatterDomain domainName]):
(+[WKHoverPlatterDomain rootSettingsClass]):
Add some knobs, with reasonable defaults, for experimentation.

* WebKit.xcodeproj/project.pbxproj:

WebKitLibraries:

* WebKitPrivateFrameworkStubs/appletvos/14/PrototypeTools.framework/PrototypeTools.tbd: Added.
* WebKitPrivateFrameworkStubs/appletvos/15/PrototypeTools.framework/PrototypeTools.tbd: Added.
* WebKitPrivateFrameworkStubs/iOS/14/PrototypeTools.framework/PrototypeTools.tbd: Added.
* WebKitPrivateFrameworkStubs/iOS/15/PrototypeTools.framework/PrototypeTools.tbd: Added.
* WebKitPrivateFrameworkStubs/watchos/7/PrototypeTools.framework/PrototypeTools.tbd: Added.
* WebKitPrivateFrameworkStubs/watchos/8/PrototypeTools.framework/PrototypeTools.tbd: Added.


Canonical link: https://commits.webkit.org/239503@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Jul 8, 2021
1 parent 1b304f9 commit 5ce1ea4
Show file tree
Hide file tree
Showing 22 changed files with 881 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Source/WebCore/PAL/ChangeLog
@@ -1,3 +1,13 @@
2021-07-07 Tim Horton <timothy_horton@apple.com>

Add WKHoverPlatter and some knobs to tweak its appearance
https://bugs.webkit.org/show_bug.cgi?id=227735
<rdar://problem/79198262>

Reviewed by Sam Weinig.

* pal/spi/cocoa/QuartzCoreSPI.h:

2021-07-06 Youenn Fablet <youenn@apple.com>

Set kVTCompressionPropertyKey_MaxKeyFrameInterval in VideoSampleBufferCompressor
Expand Down
6 changes: 6 additions & 0 deletions Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h
Expand Up @@ -163,6 +163,12 @@ typedef enum {
- (float)_solveForInput:(float)t;
@end

@interface CAPortalLayer : CALayer
@property (weak) CALayer *sourceLayer;
@property BOOL matchesPosition;
@property BOOL matchesTransform;
@end

#endif // __OBJC__

#endif
Expand Down
60 changes: 60 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,63 @@
2021-07-07 Tim Horton <timothy_horton@apple.com>

Add WKHoverPlatter and some knobs to tweak its appearance
https://bugs.webkit.org/show_bug.cgi?id=227735
<rdar://problem/79198262>

Reviewed by Sam Weinig.

* Configurations/WebKit.xcconfig:
* Platform/spi/ios/PrototypeToolsSPI.h: Added.
* SourcesCocoa.txt:
* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView rootContentView]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setUpInteraction]):
(-[WKContentView cleanUpInteraction]):
Install and uninstall the platter alongside the gestures that drive it.

(-[WKContentView mouseGestureRecognizerChanged:]):
(-[WKContentView hoverGestureRecognizerChanged:]):
When the gesture recognizers fire, also update the hover point.

(-[WKContentView positionInformationForHoverPlatter:withRequest:completionHandler:]):
* UIProcess/ios/WKHoverPlatter.h: Added.
* UIProcess/ios/WKHoverPlatter.mm: Added.
(createBaseAnimation):
(addAnimation):
(setAdditionalPlatterLayerProperties):
(addAdditionalIncomingAnimations):
(addAdditionalDismissalAnimations):
(-[WKHoverPlatter initWithView:delegate:]):
(-[WKHoverPlatter invalidate]):
(-[WKHoverPlatter hoverPoint]):
(-[WKHoverPlatter setHoverPoint:]):
(-[WKHoverPlatter requestPositionInformationForCurrentHoverPoint]):
(-[WKHoverPlatter didReceivePositionInformation:]):
(-[WKHoverPlatter dismissPlatterWithAnimation:]):
(-[WKHoverPlatter didFinishAnimationForShadow:]):
(-[WKHoverPlatter clearLayers]):
Animate the platter in and out, and optionally between states, as the hover point moves.
Use the TextIndicator's geometry information, but not its snapshot; we use a
CAPortalLayer for the platter instead. A future patch will avoid taking the snapshot
entirely, since we call setHoverPoint (and thus generate a TextIndicator) a *lot*
when moving the mouse around, and all those snapshots add up.

* UIProcess/ios/WKHoverPlatterParameters.h: Added.
* UIProcess/ios/WKHoverPlatterParameters.mm: Added.
(-[PTSliderRow integerMinValue:maxValue:]):
(-[WKHoverPlatterParameters setDefaultValues]):
(+[WKHoverPlatterParameters settingsControllerModule]):
(+[WKHoverPlatterDomain rootSettings]):
(+[WKHoverPlatterDomain domainGroupName]):
(+[WKHoverPlatterDomain domainName]):
(+[WKHoverPlatterDomain rootSettingsClass]):
Add some knobs, with reasonable defaults, for experimentation.

* WebKit.xcodeproj/project.pbxproj:

2021-07-07 John Wilander <wilander@apple.com>

PCM: Add error logging for CryptoKit operations
Expand Down
5 changes: 4 additions & 1 deletion Source/WebKit/Configurations/WebKit.xcconfig
Expand Up @@ -93,6 +93,9 @@ WK_PDFKIT_LDFLAGS_iphonesimulator[sdk=iphone*11.*] = ;
WK_PDFKIT_LDFLAGS_maccatalyst = $(WK_PDFKIT_LDFLAGS_maccatalyst$(WK_MACOS_1100));
WK_PDFKIT_LDFLAGS_maccatalyst_MACOS_SINCE_1100 = $(WK_PDFKIT_LDFLAGS_iphoneos);

WK_PROTOTYPE_TOOLS_LDFLAGS = $(WK_PROTOTYPE_TOOLS_LDFLAGS_$(WK_COCOA_TOUCH));
WK_PROTOTYPE_TOOLS_LDFLAGS_cocoatouch = -framework PrototypeTools;

WK_SAFE_BROWSING_LDFLAGS = $(WK_SAFE_BROWSING_LDFLAGS_$(WK_PLATFORM_NAME));
WK_SAFE_BROWSING_LDFLAGS_iphoneos = -framework SafariSafeBrowsing;
WK_SAFE_BROWSING_LDFLAGS_iphoneos[sdk=iphone*10.*] = ;
Expand Down Expand Up @@ -143,7 +146,7 @@ WK_LIBNETWORKEXTENSION_LDFLAGS_maccatalyst = -lnetworkextension;
WK_LIBNETWORKEXTENSION_LDFLAGS_macosx = -weak_library /usr/lib/libnetworkextension.dylib;
WK_LIBNETWORKEXTENSION_LDFLAGS_tvos = ;

FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork -framework Metal $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_BACKBOARD_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CONTACTS_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBNETWORKEXTENSION_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS) $(WK_COORDINATOR_LDFLAGS);
FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork -framework Metal $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_BACKBOARD_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CONTACTS_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBNETWORKEXTENSION_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_PROTOTYPE_TOOLS_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS) $(WK_COORDINATOR_LDFLAGS);

// Prevent C++ standard library basic_stringstream, operator new, delete and their related exception types from being exported as weak symbols.
UNEXPORTED_SYMBOL_LDFLAGS = -Wl,-unexported_symbol -Wl,__ZTISt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTISt9exception -Wl,-unexported_symbol -Wl,__ZTSSt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTSSt9exception -Wl,-unexported_symbol -Wl,__ZdlPvS_ -Wl,-unexported_symbol -Wl,__ZnwmPv -Wl,-unexported_symbol -Wl,__Znwm -Wl,-unexported_symbol -Wl,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_istreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_14basic_iostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE16_NS_13basic_ostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTTNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE8_NS_13basic_ostreamIcS2_EE;
Expand Down
79 changes: 79 additions & 0 deletions Source/WebKit/Platform/spi/ios/PrototypeToolsSPI.h
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#if USE(APPLE_INTERNAL_SDK)

#import <PrototypeTools/PrototypeTools.h>

#else

@interface PTSettings : NSObject <NSCopying>
- (void)setDefaultValues;
@end

@interface PTDomain : NSObject
+ (__kindof PTSettings *)rootSettings;
@end

@interface PTSection : NSObject
@end

@interface PTModule : NSObject
+ (instancetype)moduleWithTitle:(NSString *)title contents:(NSArray *)contents;
+ (PTSection *)sectionWithRows:(NSArray *)rows title:(NSString *)title;
+ (PTSection *)sectionWithRows:(NSArray *)rows;
@end

@interface PTRow : NSObject <NSCopying, NSSecureCoding>
+ (instancetype)rowWithTitle:(NSString *)staticTitle valueKeyPath:(NSString *)keyPath;
- (id)valueValidator:(id(^)(id proposedValue, id settings))validator;
- (id)condition:(NSPredicate *)condition;
@end

@interface PTSRow : PTRow
@end

@interface PTSwitchRow : PTSRow
@end

@interface PTSliderRow : PTSRow
- (id)minValue:(CGFloat)minValue maxValue:(CGFloat)maxValue;
@end

@interface PTEditFloatRow : PTSRow
@end

@interface PTRowAction : NSObject
@end

@interface PTRestoreDefaultSettingsRowAction : PTRowAction
+ (instancetype)action;
@end

@interface PTButtonRow : PTSRow
+ (instancetype)rowWithTitle:(NSString *)staticTitle action:(PTRowAction *)action;
@end

#endif
2 changes: 2 additions & 0 deletions Source/WebKit/SourcesCocoa.txt
Expand Up @@ -489,6 +489,8 @@ UIProcess/ios/WKDeferringGestureRecognizer.mm
UIProcess/ios/WKGeolocationProviderIOS.mm
UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm
UIProcess/ios/WKHighlightLongPressGestureRecognizer.mm
UIProcess/ios/WKHoverPlatter.mm
UIProcess/ios/WKHoverPlatterParameters.mm
UIProcess/ios/WKImageAnalysisGestureRecognizer.mm
UIProcess/ios/WKKeyboardScrollingAnimator.mm
UIProcess/ios/WKModelInteractionGestureRecognizer.mm
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/ios/WKContentView.h
Expand Up @@ -94,6 +94,7 @@ enum class ViewStabilityFlag : uint8_t;
- (void)_webViewDestroyed;

- (WKWebView *)webView;
- (UIView *)rootContentView;

- (std::unique_ptr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy:(WebKit::WebProcessProxy&)process;
- (void)_processDidExit;
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/UIProcess/ios/WKContentView.mm
Expand Up @@ -326,6 +326,11 @@ - (WKWebView *)webView
return _webView.getAutoreleased();
}

- (UIView *)rootContentView
{
return _rootContentView.get();
}

- (void)willMoveToWindow:(UIWindow *)newWindow
{
[super willMoveToWindow:newWindow];
Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Expand Up @@ -39,6 +39,7 @@
#import "TextCheckingController.h"
#import "TransactionID.h"
#import "UIKitSPI.h"
#import "WKHoverPlatter.h"
#import <WebKit/WKActionSheetAssistant.h>
#import <WebKit/WKAirPlayRoutePicker.h>
#import <WebKit/WKContactPicker.h>
Expand Down Expand Up @@ -295,6 +296,10 @@ using ImageAnalysisRequestIdentifier = ObjectIdentifier<ImageAnalysisRequestIden
RetainPtr<WKHoverGestureRecognizer> _hoverGestureRecognizer;
#endif

#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)
RetainPtr<WKHoverPlatter> _hoverPlatter;
#endif

#if HAVE(PENCILKIT_TEXT_INPUT)
RetainPtr<UIIndirectScribbleInteraction> _scribbleInteraction;
#endif
Expand Down Expand Up @@ -526,6 +531,9 @@ using ImageAnalysisRequestIdentifier = ObjectIdentifier<ImageAnalysisRequestIden
, UIDragInteractionDelegate, UIDropInteractionDelegate
#endif
, WKTouchActionGestureRecognizerDelegate
#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)
, WKHoverPlatterDelegate
#endif
>

@property (nonatomic, readonly) CGPoint lastInteractionLocation;
Expand Down
30 changes: 30 additions & 0 deletions Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Expand Up @@ -56,6 +56,8 @@
#import "WKFormSelectControl.h"
#import "WKFrameInfoInternal.h"
#import "WKHighlightLongPressGestureRecognizer.h"
#import "WKHoverPlatter.h"
#import "WKHoverPlatterParameters.h"
#import "WKImageAnalysisGestureRecognizer.h"
#import "WKImagePreviewViewController.h"
#import "WKInspectorNodeSearchGestureRecognizer.h"
Expand Down Expand Up @@ -128,6 +130,7 @@
#import <WebCore/UTIUtilities.h>
#import <WebCore/VersionChecks.h>
#import <WebCore/VisibleSelection.h>
#import <WebCore/WebCoreCALayerExtras.h>
#import <WebCore/WebEvent.h>
#import <WebCore/WebTextIndicatorLayer.h>
#import <WebCore/WritingDirection.h>
Expand All @@ -136,6 +139,7 @@
#import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
#import <pal/spi/cocoa/LaunchServicesSPI.h>
#import <pal/spi/cocoa/NSAttributedStringSPI.h>
#import <pal/spi/cocoa/QuartzCoreSPI.h>
#import <pal/spi/ios/DataDetectorsUISPI.h>
#import <pal/spi/ios/GraphicsServicesSPI.h>
#import <pal/spi/ios/ManagedConfigurationSPI.h>
Expand Down Expand Up @@ -894,6 +898,10 @@ - (void)setUpInteraction
[self setUpHoverGestureRecognizer];
#endif

#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)
_hoverPlatter = adoptNS([[WKHoverPlatter alloc] initWithView:self.rootContentView delegate:self]);
#endif

#if HAVE(LOOKUP_GESTURE_RECOGNIZER)
_lookupGestureRecognizer = adoptNS([[_UILookupGestureRecognizer alloc] initWithTarget:self action:@selector(_lookupGestureRecognized:)]);
[_lookupGestureRecognizer setDelegate:self];
Expand Down Expand Up @@ -1081,6 +1089,11 @@ - (void)cleanUpInteraction
[self removeGestureRecognizer:_hoverGestureRecognizer.get()];
#endif

#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)
[_hoverPlatter invalidate];
_hoverPlatter = nil;
#endif

#if HAVE(LOOKUP_GESTURE_RECOGNIZER)
[_lookupGestureRecognizer setDelegate:nil];
[self removeGestureRecognizer:_lookupGestureRecognizer.get()];
Expand Down Expand Up @@ -4740,6 +4753,10 @@ - (void)_didCommitLoadForMainFrame
_activeTextInteractionCount = 0;
_treatAsContentEditableUntilNextEditorStateUpdate = NO;
[self _invalidateCurrentPositionInformation];

#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)
[_hoverPlatter dismissPlatterWithAnimation:NO];
#endif
}

#if !USE(UIKIT_KEYBOARD_ADDITIONS)
Expand Down Expand Up @@ -9502,6 +9519,8 @@ - (void)mouseGestureRecognizerChanged:(WKMouseGestureRecognizer *)gestureRecogni
[self.window makeKeyWindow];

_page->handleMouseEvent(*event);
if (WKHoverPlatterDomain.rootSettings.platterEnabledForMouse)
[_hoverPlatter setHoverPoint:event->position()];
}

- (void)_configureMouseGestureRecognizer
Expand Down Expand Up @@ -9536,10 +9555,21 @@ - (void)hoverGestureRecognizerChanged:(WKHoverGestureRecognizer *)gestureRecogni
return;

_page->handleMouseEvent(*event);
if (WKHoverPlatterDomain.rootSettings.platterEnabledForHover)
[_hoverPlatter setHoverPoint:event->position()];
}

#endif // ENABLE(HOVER_GESTURE_RECOGNIZER)

#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)

- (void)positionInformationForHoverPlatter:(WKHoverPlatter *)hoverPlatter withRequest:(WebKit::InteractionInformationRequest&)request completionHandler:(void (^)(WebKit::InteractionInformationAtPosition))completionHandler
{
[self doAfterPositionInformationUpdate:completionHandler forRequest:request];
}

#endif

#if ENABLE(MEDIA_CONTROLS_CONTEXT_MENUS) && USE(UICONTEXTMENU)

- (void)_showMediaControlsContextMenu:(WebCore::FloatRect&&)targetFrame items:(Vector<WebCore::MediaControlsContextMenuItem>&&)items completionHandler:(CompletionHandler<void(WebCore::MediaControlsContextMenuItem::ID)>&&)completionHandler
Expand Down
49 changes: 49 additions & 0 deletions Source/WebKit/UIProcess/ios/WKHoverPlatter.h
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)

@class WKHoverPlatter;

@protocol WKHoverPlatterDelegate

@required
- (void)positionInformationForHoverPlatter:(WKHoverPlatter *)hoverPlatter withRequest:(WebKit::InteractionInformationRequest&)request completionHandler:(void (^)(WebKit::InteractionInformationAtPosition))completionHandler;

@end

@interface WKHoverPlatter : NSObject

- (instancetype)initWithView:(UIView *)view delegate:(id <WKHoverPlatterDelegate>)delegate;

- (void)dismissPlatterWithAnimation:(BOOL)withAnimation;

- (void)invalidate;

@property (nonatomic, assign) WebCore::FloatPoint hoverPoint;

@end

#endif // HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)

0 comments on commit 5ce1ea4

Please sign in to comment.