-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Adopt UIAsyncTextInput, UIKeyEvent and related APIs
https://bugs.webkit.org/show_bug.cgi?id=262017 rdar://116319413 Reviewed by Tim Horton. First pass at adopting new UIKit interfaces for dispatching key events asynchronously and deferring key events to UIKit in the case where the default action was not prevented by the page. This work aims to clean up existing architecture for propagating key events from UIKit to WebKit, which currently requires UIKit to instantiate a `WebEvent` (from the WebCore framework) and hand it to WebKit. In this new architecture, UIKit instead sends `UIKeyEvent`s to WebKit, which (for the time being) are wrapped by `WebEvent`s within WebKit code. This will eventually allow us to break UIKit out of the WebKit "framework layering sandwich", wherein WebKit links UIKit and UIKit currently links WebKitLegacy in order to call directly into the WebCore framework. See below for more details. * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/ios/WebEvent.mm: (webEventType): (webEventModifierFlags): (-[WebEvent initWithUIKeyEvent:]): (-[WebEvent originalUIKeyEvent]): Add an initializer to wrap a `UIKeyEvent` in a `WebEvent`, while keeping a pointer to the original `UIKeyEvent` (accessible via a new property, `-originalUIKeyEvent`). * Source/WebCore/platform/ios/WebEventPrivate.h: Added. Put these new WebCore helpers in a new category on `WebEvent` in a separate private header, `WebEventPrivate.h`. This separation from `WebEvent.h` allows us to use `HAVE(UI_ASYNC_TEXT_INPUT)` consistently throughout WebKit, and avoid expanding the API surface exported through `WebEvent` to system clients, such as UIKit or accessibility. * Source/WebKit/UIProcess/ios/WKContentViewInteraction.h: * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _interpretKeyEvent:isCharEvent:]): Call back into UIKit via `-deferHandlingToSystemForKeyEvent:` when interpreting key events. (-[WKContentView asyncSystemInputDelegate]): (-[WKContentView setAsyncSystemInputDelegate:]): (-[WKContentView handleAsyncKeyEvent:withCompletionHandler:]): Wrap the given `UIKeyEvent` in a `WebEvent`, and just call into the existing `-handleKeyWebEvent:` method. (-[WKContentView textInputView]): Canonical link: https://commits.webkit.org/269010@main
- Loading branch information
Showing
5 changed files
with
161 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2023 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#import <WebCore/WebEvent.h> | ||
|
||
#if HAVE(UI_ASYNC_TEXT_INPUT) | ||
|
||
@class UIKeyEvent; | ||
|
||
@interface WebEvent (UIAsyncTextInputSupport) | ||
|
||
- (instancetype)initWithUIKeyEvent:(UIKeyEvent *)event; | ||
@property (nonatomic, readonly) UIKeyEvent *originalUIKeyEvent; | ||
|
||
@end | ||
|
||
#endif // HAVE(UI_ASYNC_TEXT_INPUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters