WebKit Bugzilla
Attachment 358396 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-20190104165229.patch (text/plain), 14.42 KB, created by
Daniel Bates
on 2019-01-04 16:52:30 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2019-01-04 16:52:30 PST
Size:
14.42 KB
patch
obsolete
>Subversion Revision: 239568 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 5c23432fe891564907ceb8a768a7d6eae8558ebc..594b9eec4c0d6154782da5ee18da1d3520a64110 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,34 @@ >+2019-01-04 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 modifierFlagsDidChangeFrom:to:]): 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: >+ > 2019-01-01 Jeff Miller <jeffm@apple.com> > > Update user-visible copyright strings to include 2019 >diff --git a/Source/WebKit/Platform/spi/ios/UIKitSPI.h b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >index 1f63a32a539dd69a01493f29f400e4936a168578..2e21e71665930671cca0e679e34a0ac5523d9f96 100644 >--- a/Source/WebKit/Platform/spi/ios/UIKitSPI.h >+++ b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >@@ -393,6 +393,9 @@ typedef enum { > - (void)insertDictationResult:(NSArray *)dictationResult withCorrectionIdentifier:(id)correctionIdentifier; > - (void)replaceRangeWithTextWithoutClosingTyping:(UITextRange *)range replacementText:(NSString *)text; > - (void)setBottomBufferHeight:(CGFloat)bottomBuffer; >+#if USE(UIKIT_KEYBOARD_ADDITIONS) >+- (void)modifierFlagsDidChangeFrom:(UIKeyModifierFlags)oldFlags to:(UIKeyModifierFlags)newFlags; >+#endif > @property (nonatomic) UITextGranularity selectionGranularity; > @required > - (BOOL)hasContent; >diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt >index 8459750da34a6274adca8949015698909de55eb6..adb1b7d5750e5aec576631b379230b534193c4ec 100644 >--- a/Source/WebKit/SourcesCocoa.txt >+++ b/Source/WebKit/SourcesCocoa.txt >@@ -400,6 +400,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 cdfe5dba2e3877a1183f69b8f4c100aeda7ff931..491e8882f0ca3b74b85bcfb6233acdad9a4a527c 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" >@@ -3920,6 +3921,25 @@ - (CGRect)rectContainingCaretSelection > return CGRectZero; > } > >+#if USE(UIKIT_KEYBOARD_ADDITIONS) >+- (void)modifierFlagsDidChangeFrom:(UIKeyModifierFlags)oldFlags to:(UIKeyModifierFlags)newFlags >+{ >+ auto dispatchSyntheticFlagsChangedEvents = [&] (UIKeyModifierFlags flags, bool keyDown) { >+ if (flags & UIKeyModifierShift) >+ [self handleKeyWebEvent:adoptNS([[WKSyntheticFlagsChangedWebEvent alloc] initWithShiftState:keyDown]).get()]; >+ if (flags & UIKeyModifierAlphaShift) >+ [self handleKeyWebEvent:adoptNS([[WKSyntheticFlagsChangedWebEvent alloc] initWithCapsLockState:keyDown]).get()]; >+ }; >+ >+ UIKeyModifierFlags removedFlags = oldFlags & ~newFlags; >+ UIKeyModifierFlags addedFlags = newFlags & ~oldFlags; >+ if (removedFlags) >+ dispatchSyntheticFlagsChangedEvents(removedFlags, false); >+ if (addedFlags) >+ dispatchSyntheticFlagsChangedEvents(addedFlags, true); >+} >+#endif >+ > // Web events. > - (BOOL)requiresKeyEvents > { >@@ -3964,6 +3984,11 @@ - (void)handleKeyWebEvent:(::WebEvent *)theEvent withCompletionHandler:(void (^) > > - (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled > { >+#if USE(UIKIT_KEYBOARD_ADDITIONS) >+ 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..05e450fb499d875eae395b3bfc39938641c361ed >--- /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 USE(UIKIT_KEYBOARD_ADDITIONS) && PLATFORM(IOS_FAMILY) >+ >+#import <WebCore/WebEvent.h> >+ >+@interface WKSyntheticFlagsChangedWebEvent : WebEvent >+ >+- (instancetype)initWithCapsLockState:(BOOL)keyDown; >+- (instancetype)initWithShiftState:(BOOL)keyDown; >+ >+@end >+ >+#endif // USE(UIKIT_KEYBOARD_ADDITIONS) && 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..8082ecd9eddfd863d58c88389c050e8f233fbe86 >--- /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 USE(UIKIT_KEYBOARD_ADDITIONS) && 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 // USE(UIKIT_KEYBOARD_ADDITIONS) && PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 223a7bf8fb6e034c6ab97fc5672bb1933f6cfb39..367fb5311b68ac2912dfc7a89c2bac2288728eee 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1565,6 +1565,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 */; }; >@@ -4405,6 +4406,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>"; }; >@@ -5866,6 +5869,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 */, >@@ -9837,6 +9842,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