WebKit Bugzilla
Attachment 357627 Details for
Bug 191475
: [iOS] WebKit should handle shift state changes when using the software keyboard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-191475-20181218160408.patch (text/plain), 14.98 KB, created by
Daniel Bates
on 2018-12-18 16:04:09 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-12-18 16:04:09 PST
Size:
14.98 KB
patch
obsolete
>Subversion Revision: 239338 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 6c8822de09151b025fc2382e5a810e45b84c0904..2e2d289bc647458faa826c50e19ae0cb699ea8a6 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,34 @@ >+2018-12-18 Daniel Bates <dabates@apple.com> >+ >+ [iOS] WebKit should handle shift state changes when using the software keyboard >+ https://bugs.webkit.org/show_bug.cgi?id=191475 >+ <rdar://problem/45949246> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement UIKit SPI to be notified of shift state changes to the software keyboard >+ and dispatch a synthetic keydown or keyup event for either the Shift key or Caps Lock >+ key. >+ >+ A side benefit of this change is that we now show and hide the caps lock indicator >+ in a focused password field when caps lock is enabled or disabled using the software >+ keyboard, respectively. >+ >+ * Platform/spi/ios/UIKitSPI.h: Expose more SPI. >+ * SourcesCocoa.txt: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView shiftStateDidChange:newState:]): Create a synthetic flags changed >+ web event based on the state change and dispatch it. >+ (-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Early return if the event >+ was a synethic flags change event so that we do not notify UIKit about this event >+ as it does not know anything about such synthetic events. >+ * UIProcess/ios/WKSyntheticFlagsChangedWebEvent.h: Added. >+ * UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm: Added. >+ (-[WKSyntheticFlagsChangedWebEvent initWithKeyCode:modifiers:keyDown:]): >+ (-[WKSyntheticFlagsChangedWebEvent initWithCapsLockState:]): >+ (-[WKSyntheticFlagsChangedWebEvent initWithShiftState:]): >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2018-12-18 Chris Dumez <cdumez@apple.com> > > Regression(r239182) SuspendedPage's process reuse for link navigation optimization sometimes broken >diff --git a/Source/WebKit/Platform/spi/ios/UIKitSPI.h b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >index 1f63a32a539dd69a01493f29f400e4936a168578..1e0cc53b683cc797f53e7b3cf7c20235061717b2 100644 >--- a/Source/WebKit/Platform/spi/ios/UIKitSPI.h >+++ b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >@@ -382,6 +382,15 @@ typedef enum { > > @class UITextInputArrowKeyHistory; > >+#if HAVE(KEYBOARD_SHIFT_STATE_DID_CHANGE) >+typedef NS_ENUM(NSInteger, _UITextInputShiftState) { >+ _UITextInputShiftStateNone = 0, >+ _UITextInputShiftStateManual, >+ _UITextInputShiftStateAuto, >+ _UITextInputShiftStateLocked, >+}; >+#endif >+ > @protocol UITextInputPrivate <UITextInput, UITextInputTokenizer, UITextInputTraits_Private> > @optional > - (BOOL)requiresKeyEvents; >@@ -393,6 +402,9 @@ typedef enum { > - (void)insertDictationResult:(NSArray *)dictationResult withCorrectionIdentifier:(id)correctionIdentifier; > - (void)replaceRangeWithTextWithoutClosingTyping:(UITextRange *)range replacementText:(NSString *)text; > - (void)setBottomBufferHeight:(CGFloat)bottomBuffer; >+#if HAVE(KEYBOARD_SHIFT_STATE_DID_CHANGE) >+- (void)shiftStateDidChange:(_UITextInputShiftState)oldState newState:(_UITextInputShiftState)newState; >+#endif > @property (nonatomic) UITextGranularity selectionGranularity; > @required > - (BOOL)hasContent; >diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt >index f1a057a45db0fa35ce10dcf419693efe818a6da3..216c7532202cd3e0033478b84fc9d15d9e12291a 100644 >--- a/Source/WebKit/SourcesCocoa.txt >+++ b/Source/WebKit/SourcesCocoa.txt >@@ -399,6 +399,7 @@ UIProcess/ios/WKPDFPageNumberIndicator.mm > UIProcess/ios/WKPDFView.mm > UIProcess/ios/WKScrollView.mm > UIProcess/ios/WKSyntheticClickTapGestureRecognizer.m >+UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm > UIProcess/ios/WKSystemPreviewView.mm > UIProcess/ios/WKWebEvent.mm > >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 16824559a6dd0aec82c4dba72238cb4a99d8efd6..19fa8919f35dad8471a7438525f59ffe83d682eb 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -55,6 +55,7 @@ > #import "WKPreviewElementInfoInternal.h" > #import "WKQuickboardListViewController.h" > #import "WKSelectMenuListViewController.h" >+#import "WKSyntheticFlagsChangedWebEvent.h" > #import "WKTextInputListViewController.h" > #import "WKTimePickerViewController.h" > #import "WKUIDelegatePrivate.h" >@@ -3930,6 +3931,24 @@ - (CGRect)rectContainingCaretSelection > return CGRectZero; > } > >+#if HAVE(KEYBOARD_SHIFT_STATE_DID_CHANGE) >+- (void)shiftStateDidChange:(_UITextInputShiftState)oldState newState:(_UITextInputShiftState)newState >+{ >+ bool isShiftEnabled = newState == _UITextInputShiftStateManual; >+ bool wasShiftEnabled = oldState == _UITextInputShiftStateManual; >+ bool isCapsLockEnabled = newState == _UITextInputShiftStateLocked; >+ bool wasCapsLockEnabled = oldState == _UITextInputShiftStateLocked; >+ >+ RetainPtr<WKSyntheticFlagsChangedWebEvent> fakeEvent; >+ if (isCapsLockEnabled || wasCapsLockEnabled) >+ fakeEvent = adoptNS([[WKSyntheticFlagsChangedWebEvent alloc] initWithCapsLockState:isCapsLockEnabled]); >+ else if (isShiftEnabled || wasShiftEnabled) >+ fakeEvent = adoptNS([[WKSyntheticFlagsChangedWebEvent alloc] initWithShiftState:isShiftEnabled]); >+ if (fakeEvent) >+ [self handleKeyWebEvent:fakeEvent.get()]; >+} >+#endif >+ > // Web events. > - (BOOL)requiresKeyEvents > { >@@ -3974,6 +3993,11 @@ - (void)handleKeyWebEvent:(::WebEvent *)theEvent withCompletionHandler:(void (^) > > - (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled > { >+#if HAVE(KEYBOARD_SHIFT_STATE_DID_CHANGE) >+ if ([event isKindOfClass:[WKSyntheticFlagsChangedWebEvent class]]) >+ return; >+#endif >+ > if (!(event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)) > [_keyboardScrollingAnimator handleKeyEvent:event]; > >diff --git a/Source/WebKit/UIProcess/ios/WKSyntheticFlagsChangedWebEvent.h b/Source/WebKit/UIProcess/ios/WKSyntheticFlagsChangedWebEvent.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ca4c5a6b5e6c96a828136432308b92f6ddd5ec44 >--- /dev/null >+++ b/Source/WebKit/UIProcess/ios/WKSyntheticFlagsChangedWebEvent.h >@@ -0,0 +1,37 @@ >+/* >+ * Copyright (C) 2018 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(KEYBOARD_SHIFT_STATE_DID_CHANGE) && PLATFORM(IOS_FAMILY) >+ >+#import <WebCore/WebEvent.h> >+ >+@interface WKSyntheticFlagsChangedWebEvent : WebEvent >+ >+- (instancetype)initWithCapsLockState:(BOOL)keyDown; >+- (instancetype)initWithShiftState:(BOOL)keyDown; >+ >+@end >+ >+#endif // HAVE(KEYBOARD_SHIFT_STATE_DID_CHANGE) && PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm b/Source/WebKit/UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..ae7aeabbabf60d54ad0b4c2cef361524267a5b82 >--- /dev/null >+++ b/Source/WebKit/UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2018 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. >+ */ >+ >+#import "config.h" >+#import "WKSyntheticFlagsChangedWebEvent.h" >+ >+#if HAVE(KEYBOARD_SHIFT_STATE_DID_CHANGE) && PLATFORM(IOS_FAMILY) >+ >+#import <pal/spi/cocoa/IOKitSPI.h> >+#import <pal/spi/ios/GraphicsServicesSPI.h> >+ >+@implementation WKSyntheticFlagsChangedWebEvent >+ >+- (instancetype)initWithKeyCode:(uint16_t)keyCode modifiers:(WebEventFlags)modifiers keyDown:(BOOL)keyDown >+{ >+ self = [super initWithKeyEventType:(keyDown ? WebEventKeyDown : WebEventKeyUp) timeStamp:GSCurrentEventTimestamp() characters:@"" charactersIgnoringModifiers:@"" modifiers:modifiers isRepeating:NO withFlags:WebEventKeyboardInputModifierFlagsChanged withInputManagerHint:nil keyCode:keyCode isTabKey:(keyCode == kHIDUsage_KeyboardTab)]; >+ return self; >+} >+ >+- (instancetype)initWithCapsLockState:(BOOL)keyDown >+{ >+ return [self initWithKeyCode:kHIDUsage_KeyboardCapsLock modifiers:(keyDown ? WebEventFlagMaskLeftCapsLockKey : 0) keyDown:keyDown]; >+} >+ >+- (instancetype)initWithShiftState:(BOOL)keyDown >+{ >+ return [self initWithKeyCode:kHIDUsage_KeyboardLeftShift modifiers:(keyDown ? WebEventFlagMaskLeftShiftKey : 0) keyDown:keyDown]; >+} >+ >+@end >+ >+#endif // HAVE(KEYBOARD_SHIFT_STATE_DID_CHANGE) && PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 2832bb7c4b81ae89965666ee4b517fe0d307b1f7..1fe49be529d67bb5d7838f5d6f3619a39823316e 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1561,6 +1561,7 @@ > CE1A0BD51A48E6C60054EF74 /* ManagedConfigurationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BCF1A48E6C60054EF74 /* ManagedConfigurationSPI.h */; }; > CE1A0BD61A48E6C60054EF74 /* TCCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */; }; > CE1A0BD71A48E6C60054EF74 /* TextInputSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */; }; >+ CE5B4C8821B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = CE5B4C8621B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h */; }; > CEC8F9CB1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CEC8F9CA1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; > CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */; }; > CEE4AE2B1A5DCF430002F49B /* UIKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CEE4AE2A1A5DCF430002F49B /* UIKitSPI.h */; }; >@@ -4394,6 +4395,8 @@ > CE1A0BCF1A48E6C60054EF74 /* ManagedConfigurationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManagedConfigurationSPI.h; sourceTree = "<group>"; }; > CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCCSPI.h; sourceTree = "<group>"; }; > CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputSPI.h; sourceTree = "<group>"; }; >+ CE5B4C8621B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKSyntheticFlagsChangedWebEvent.h; path = ios/WKSyntheticFlagsChangedWebEvent.h; sourceTree = "<group>"; }; >+ CE5B4C8721B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKSyntheticFlagsChangedWebEvent.mm; path = ios/WKSyntheticFlagsChangedWebEvent.mm; sourceTree = "<group>"; }; > CEC8F9CA1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInNodeHandlePrivate.h; sourceTree = "<group>"; }; > CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAlternativeTextClient.h; sourceTree = "<group>"; }; > CEDA12DF152CCAE800D9E08D /* WebAlternativeTextClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAlternativeTextClient.cpp; sourceTree = "<group>"; }; >@@ -5853,6 +5856,8 @@ > 0FCB4E4518BBE044000FCFC9 /* WKScrollView.mm */, > 26F10BE619187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h */, > 26F10BE719187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m */, >+ CE5B4C8621B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h */, >+ CE5B4C8721B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.mm */, > 316B8B622054B55800BD4A62 /* WKSystemPreviewView.h */, > 316B8B612054B55800BD4A62 /* WKSystemPreviewView.mm */, > 2D1E8221216FFF5000A15265 /* WKWebEvent.h */, >@@ -9816,6 +9821,7 @@ > BC40761A124FF0370068F20A /* WKStringCF.h in Headers */, > BC9099801256A98200083756 /* WKStringPrivate.h in Headers */, > 26F10BE819187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h in Headers */, >+ CE5B4C8821B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h in Headers */, > 316B8B642054B55800BD4A62 /* WKSystemPreviewView.h in Headers */, > 51F886A61F2C228100C193EF /* WKTestingSupport.h in Headers */, > 31D755C11D91B81500843BD1 /* WKTextChecker.h in Headers */,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 191475
:
357627
|
357644
|
358396
|
358418