Skip to content

Commit

Permalink
Add <input type=checkbox switch> iOS haptic feedback
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=266066

Reviewed by Aditya Keerthi.

Perform haptic feedback on iOS, iPadOS, and Mac Catalyst using the same
general infrastructure as macOS.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::performSwitchHapticFeedback):

Canonical link: https://commits.webkit.org/271733@main
  • Loading branch information
annevk committed Dec 8, 2023
1 parent 8425593 commit de5133f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/WTF/wtf/PlatformHave.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@
#define HAVE_ARKIT_QUICK_LOOK_PREVIEW_ITEM 1
#endif

#if PLATFORM(IOS) || PLATFORM(MACCATALYST)
#define HAVE_UI_IMPACT_FEEDBACK_GENERATOR 1
#endif

#if PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(VISION)
#define HAVE_UI_WK_DOCUMENT_CONTEXT 1
#define HAVE_UIDATEPICKER_STYLE 1
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/ios/PageClientImplIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ class PageClientImpl final : public PageClientImplCocoa
void didChangeDragCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) override;
#endif

void performSwitchHapticFeedback() final;

void handleAutocorrectionContext(const WebAutocorrectionContext&) final;

void setMouseEventPolicy(WebCore::MouseEventPolicy) final;
Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,14 @@ static UIInterfaceOrientationMask toUIInterfaceOrientationMask(WebCore::ScreenOr
}
#endif

void PageClientImpl::performSwitchHapticFeedback()
{
#if HAVE(UI_IMPACT_FEEDBACK_GENERATOR)
auto feedbackGenerator = adoptNS([[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight]);
[feedbackGenerator impactOccurred];
#endif
}

#if USE(QUICK_LOOK)
void PageClientImpl::requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&& completionHandler)
{
Expand Down

0 comments on commit de5133f

Please sign in to comment.