⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 247524 in webkit


Ignore:
Timestamp:
Jul 17, 2019, 11:23:38 AM (7 years ago)
Author:
rniwa@webkit.org
Message:

[iOS] Option + Up or Down Arrow key doesn’t move cursor past paragraph boundaries in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=199851

Reviewed by Wenson Hsieh.

Source/WebKit:

The bug was caused by the difference in the way AppKit and UIKit responds to Option + Up / Down.

On macOS, AppKit sends moveForward before sending moveToStartOfParagraph and moveBackward
before sending moveToEndOfParagraph. As a result, when Option + Down is pressed when we are at
the end of a line, we would first move to the beginning of the next line (i.e. after the line break)
before moving or extending selection with the paragraph boundary granurality.

On iOS, UIKit only calls _moveToStartOfParagraph without moving forward by a character. As a result,
moving forward by the paragraph boundary granurality immediately stops when we're starting at the
end of a line when Option + Down is pressed. Option + Up case is similar.

Fix the bug on iOS by emulating what happens on macOS. Namely, move the selection forward or backward
by the character granurality before moving by the paragraph boundary granurality.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _moveToStartOfParagraph:withHistory:]):
(-[WKContentView _moveToEndOfParagraph:withHistory:]):

Tools:

Added a regression test for iOS. Unfortunately, event sender, etc... doesn't work because
this code is getting directly triggered from UIKeyboard's code.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/ios/SelectionModifyByParagraphBoundary.h: Added.
  • TestWebKitAPI/Tests/ios/SelectionModifyByParagraphBoundary.mm: Added.
  • TestWebKitAPI/ios/UIKitSPI.h:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247510 r247524  
     12019-07-17  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        [iOS] Option + Up or Down Arrow key doesn’t move cursor past paragraph boundaries in WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=199851
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        The bug was caused by the difference in the way AppKit and UIKit responds to Option + Up / Down.
     9
     10        On macOS, AppKit sends moveForward before sending moveToStartOfParagraph and moveBackward
     11        before sending moveToEndOfParagraph. As a result, when Option + Down is pressed when we are at
     12        the end of a line, we would first move to the beginning of the next line (i.e. after the line break)
     13        before moving or extending selection with the paragraph boundary granurality.
     14
     15        On iOS, UIKit only calls _moveToStartOfParagraph without moving forward by a character. As a result,
     16        moving forward by the paragraph boundary granurality immediately stops when we're starting at the
     17        end of a line when Option + Down is pressed. Option + Up case is similar.
     18
     19        Fix the bug on iOS by emulating what happens on macOS. Namely, move the selection forward or backward
     20        by the character granurality before moving by the paragraph boundary granurality.
     21
     22        * UIProcess/ios/WKContentViewInteraction.mm:
     23        (-[WKContentView _moveToStartOfParagraph:withHistory:]):
     24        (-[WKContentView _moveToEndOfParagraph:withHistory:]):
     25
    1262019-07-17  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r247411 r247524  
    49364936- (UITextInputArrowKeyHistory *)_moveToStartOfParagraph:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
    49374937{
     4938    [self executeEditCommandWithCallback:extending ? @"moveBackwardAndModifySelection" : @"moveBackward"];
    49384939    [self executeEditCommandWithCallback:extending ? @"moveToBeginningOfParagraphAndModifySelection" : @"moveToBeginningOfParagraph"];
    49394940    return nil;
     
    49604961- (UITextInputArrowKeyHistory *)_moveToEndOfParagraph:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
    49614962{
     4963    [self executeEditCommandWithCallback:extending ? @"moveForwardAndModifySelection" : @"moveForward"];
    49624964    [self executeEditCommandWithCallback:extending ? @"moveToEndOfParagraphAndModifySelection" : @"moveToEndOfParagraph"];
    49634965    return nil;
  • trunk/Tools/ChangeLog

    r247523 r247524  
     12019-07-17  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        [iOS] Option + Up or Down Arrow key doesn’t move cursor past paragraph boundaries in WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=199851
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Added a regression test for iOS. Unfortunately, event sender, etc... doesn't work because
     9        this code is getting directly triggered from UIKeyboard's code.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/ios/SelectionModifyByParagraphBoundary.h: Added.
     13        * TestWebKitAPI/Tests/ios/SelectionModifyByParagraphBoundary.mm: Added.
     14        * TestWebKitAPI/ios/UIKitSPI.h:
     15
    1162019-07-17  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r247402 r247524  
    698698                9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
    699699                9B270FEE1DDC2C0B002D53F3 /* closed-shadow-tree-test.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */; };
     700                9B4B5EA522DEBE19001E3D5A /* SelectionModifyByParagraphBoundary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B4B5EA422DEBE19001E3D5A /* SelectionModifyByParagraphBoundary.mm */; };
    700701                9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
    701702                9B59F12A2034086F009E63D5 /* mso-list-compat-mode.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B59F12920340854009E63D5 /* mso-list-compat-mode.html */; };
     
    20202021                9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLFormCollectionNamedItem.html; sourceTree = "<group>"; };
    20212022                9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "closed-shadow-tree-test.html"; sourceTree = "<group>"; };
     2023                9B4B5EA422DEBE19001E3D5A /* SelectionModifyByParagraphBoundary.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SelectionModifyByParagraphBoundary.mm; sourceTree = "<group>"; };
    20222024                9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; };
    20232025                9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; };
     
    29862988                                F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */,
    29872989                                0FF1134D22D68679009A81DA /* ScrollViewScrollabilityTests.mm */,
     2990                                9B4B5EA422DEBE19001E3D5A /* SelectionModifyByParagraphBoundary.mm */,
    29882991                                CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */,
    29892992                                4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */,
     
    45454548                                0FF1134E22D68679009A81DA /* ScrollViewScrollabilityTests.mm in Sources */,
    45464549                                CE06DF9B1E1851F200E570C9 /* SecurityOrigin.cpp in Sources */,
     4550                                9B4B5EA522DEBE19001E3D5A /* SelectionModifyByParagraphBoundary.mm in Sources */,
    45474551                                5769C50B1D9B0002000847FB /* SerializedCryptoKeyWrap.mm in Sources */,
    45484552                                51EB12941FDF052500A5A1BD /* ServiceWorkerBasic.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r246924 r247524  
    3333#import <UIKit/UIBarButtonItemGroup_Private.h>
    3434#import <UIKit/UICalloutBar.h>
     35#import <UIKit/UIKeyboardImpl.h>
    3536#import <UIKit/UIKeyboard_Private.h>
    3637#import <UIKit/UIResponder_Private.h>
     
    7879@class WebEvent;
    7980
     81@class UITextInputArrowKeyHistory;
     82
    8083@protocol UITextInputPrivate <UITextInput, UITextInputTraits_Private>
    8184- (UITextInputTraits *)textInputTraits;
Note: See TracChangeset for help on using the changeset viewer.