Changeset 240288 in webkit


Ignore:
Timestamp:
Jan 22, 2019 1:15:35 PM (5 years ago)
Author:
dbates@webkit.org
Message:

[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 Brent Fulgham.

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:
Location:
trunk/Source/WebKit
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r240285 r240288  
     12019-01-22  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] WebKit should handle shift state changes when using the software keyboard
     4        https://bugs.webkit.org/show_bug.cgi?id=191475
     5        <rdar://problem/45949246>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Implement UIKit SPI to be notified of shift state changes to the software keyboard
     10        and dispatch a synthetic keydown or keyup event for either the Shift key or Caps Lock
     11        key.
     12
     13        A side benefit of this change is that we now show and hide the caps lock indicator
     14        in a focused password field when caps lock is enabled or disabled using the software
     15        keyboard, respectively.
     16
     17        * Platform/spi/ios/UIKitSPI.h: Expose more SPI.
     18        * SourcesCocoa.txt:
     19        * UIProcess/ios/WKContentViewInteraction.mm:
     20        (-[WKContentView modifierFlagsDidChangeFrom:to:]): Create a synthetic flags changed
     21        web event based on the state change and dispatch it.
     22        (-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Early return if the event
     23        was a synethic flags change event so that we do not notify UIKit about this event
     24        as it does not know anything about such synthetic events.
     25        * UIProcess/ios/WKSyntheticFlagsChangedWebEvent.h: Added.
     26        * UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm: Added.
     27        (-[WKSyntheticFlagsChangedWebEvent initWithKeyCode:modifiers:keyDown:]):
     28        (-[WKSyntheticFlagsChangedWebEvent initWithCapsLockState:]):
     29        (-[WKSyntheticFlagsChangedWebEvent initWithShiftState:]):
     30        * WebKit.xcodeproj/project.pbxproj:
     31
    1322019-01-22  Daniel Bates  <dabates@apple.com>
    233
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r240285 r240288  
    394394- (void)replaceRangeWithTextWithoutClosingTyping:(UITextRange *)range replacementText:(NSString *)text;
    395395- (void)setBottomBufferHeight:(CGFloat)bottomBuffer;
     396#if USE(UIKIT_KEYBOARD_ADDITIONS)
     397- (void)modifierFlagsDidChangeFrom:(UIKeyModifierFlags)oldFlags to:(UIKeyModifierFlags)newFlags;
     398#endif
    396399@property (nonatomic) UITextGranularity selectionGranularity;
    397400@required
  • trunk/Source/WebKit/SourcesCocoa.txt

    r240275 r240288  
    406406UIProcess/ios/WKScrollView.mm
    407407UIProcess/ios/WKSyntheticClickTapGestureRecognizer.m
     408UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm
    408409UIProcess/ios/WKSystemPreviewView.mm
    409410UIProcess/ios/WKWebEvent.mm
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r240285 r240288  
    5757#import "WKQuickboardListViewController.h"
    5858#import "WKSelectMenuListViewController.h"
     59#import "WKSyntheticFlagsChangedWebEvent.h"
    5960#import "WKTextInputListViewController.h"
    6061#import "WKTimePickerViewController.h"
     
    39223923}
    39233924
     3925#if USE(UIKIT_KEYBOARD_ADDITIONS)
     3926- (void)modifierFlagsDidChangeFrom:(UIKeyModifierFlags)oldFlags to:(UIKeyModifierFlags)newFlags
     3927{
     3928    auto dispatchSyntheticFlagsChangedEvents = [&] (UIKeyModifierFlags flags, bool keyDown) {
     3929        if (flags & UIKeyModifierShift)
     3930            [self handleKeyWebEvent:adoptNS([[WKSyntheticFlagsChangedWebEvent alloc] initWithShiftState:keyDown]).get()];
     3931        if (flags & UIKeyModifierAlphaShift)
     3932            [self handleKeyWebEvent:adoptNS([[WKSyntheticFlagsChangedWebEvent alloc] initWithCapsLockState:keyDown]).get()];
     3933    };
     3934
     3935    UIKeyModifierFlags removedFlags = oldFlags & ~newFlags;
     3936    UIKeyModifierFlags addedFlags = newFlags & ~oldFlags;
     3937    if (removedFlags)
     3938        dispatchSyntheticFlagsChangedEvents(removedFlags, false);
     3939    if (addedFlags)
     3940        dispatchSyntheticFlagsChangedEvents(addedFlags, true);
     3941}
     3942#endif
     3943
    39243944// Web events.
    39253945- (BOOL)requiresKeyEvents
     
    39663986- (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled
    39673987{
     3988#if USE(UIKIT_KEYBOARD_ADDITIONS)
     3989    if ([event isKindOfClass:[WKSyntheticFlagsChangedWebEvent class]])
     3990        return;
     3991#endif
     3992
    39683993    if (!(event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged))
    39693994        [_keyboardScrollingAnimator handleKeyEvent:event];
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r240275 r240288  
    15591559                CE1A0BD61A48E6C60054EF74 /* TCCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */; };
    15601560                CE1A0BD71A48E6C60054EF74 /* TextInputSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */; };
     1561                CE5B4C8821B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = CE5B4C8621B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h */; };
    15611562                CEC8F9CB1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CEC8F9CA1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    15621563                CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */; };
     
    43864387                CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCCSPI.h; sourceTree = "<group>"; };
    43874388                CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputSPI.h; sourceTree = "<group>"; };
     4389                CE5B4C8621B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKSyntheticFlagsChangedWebEvent.h; path = ios/WKSyntheticFlagsChangedWebEvent.h; sourceTree = "<group>"; };
     4390                CE5B4C8721B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKSyntheticFlagsChangedWebEvent.mm; path = ios/WKSyntheticFlagsChangedWebEvent.mm; sourceTree = "<group>"; };
    43884391                CEC8F9CA1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInNodeHandlePrivate.h; sourceTree = "<group>"; };
    43894392                CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAlternativeTextClient.h; sourceTree = "<group>"; };
     
    58545857                                26F10BE619187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h */,
    58555858                                26F10BE719187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m */,
     5859                                CE5B4C8621B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h */,
     5860                                CE5B4C8721B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.mm */,
    58565861                                316B8B622054B55800BD4A62 /* WKSystemPreviewView.h */,
    58575862                                316B8B612054B55800BD4A62 /* WKSystemPreviewView.mm */,
     
    98509855                                BC9099801256A98200083756 /* WKStringPrivate.h in Headers */,
    98519856                                26F10BE819187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h in Headers */,
     9857                                CE5B4C8821B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h in Headers */,
    98529858                                316B8B642054B55800BD4A62 /* WKSystemPreviewView.h in Headers */,
    98539859                                51F886A61F2C228100C193EF /* WKTestingSupport.h in Headers */,
Note: See TracChangeset for help on using the changeset viewer.