Changeset 256000 in webkit


Ignore:
Timestamp:
Feb 6, 2020 6:54:43 PM (4 years ago)
Author:
Wenson Hsieh
Message:

WebPage::rangeForGranularityAtPoint always returns null in the case of CharacterGranularity
https://bugs.webkit.org/show_bug.cgi?id=207350
<rdar://problem/59239914>

Reviewed by Tim Horton.

Source/WebKit:

Handle the character granularity case in WebPage::rangeForGranularityAtPoint by just returning a collapsed
Range. Certain internal clients will have a need to place and update the text selection using character
granularity; see radar for more details.

Test: UIWKInteractionViewProtocol.SelectTextWithCharacterGranularity

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView supportsTextSelectionWithCharacterGranularity]):

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::rangeForGranularityAtPoint):

Tools:

Add a test to exercise the corner case in the SPI.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm: Added.
Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r255999 r256000  
     12020-02-06  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        WebPage::rangeForGranularityAtPoint always returns null in the case of CharacterGranularity
     4        https://bugs.webkit.org/show_bug.cgi?id=207350
     5        <rdar://problem/59239914>
     6
     7        Reviewed by Tim Horton.
     8
     9        Handle the character granularity case in `WebPage::rangeForGranularityAtPoint` by just returning a collapsed
     10        Range. Certain internal clients will have a need to place and update the text selection using character
     11        granularity; see radar for more details.
     12
     13        Test: UIWKInteractionViewProtocol.SelectTextWithCharacterGranularity
     14
     15        * UIProcess/ios/WKContentViewInteraction.mm:
     16        (-[WKContentView supportsTextSelectionWithCharacterGranularity]):
     17        * WebProcess/WebPage/ios/WebPageIOS.mm:
     18        (WebKit::WebPage::rangeForGranularityAtPoint):
     19
    1202020-02-06  Jiewen Tan  <jiewen_tan@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r255664 r256000  
    63836383}
    63846384
     6385- (BOOL)supportsTextSelectionWithCharacterGranularity
     6386{
     6387    return YES;
     6388}
     6389
    63856390- (BOOL)hasHiddenContentEditable
    63866391{
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r255879 r256000  
    20532053    RefPtr<Range> range;
    20542054    switch (static_cast<WebCore::TextGranularity>(granularity)) {
     2055    case CharacterGranularity:
     2056        range = makeRange(position, position);
     2057        break;
    20552058    case WordGranularity:
    20562059        range = wordRangeFromPosition(position);
     
    20632066        break;
    20642067    case DocumentGranularity:
     2068        // FIXME: It's not clear why this mutates the current selection and returns null.
    20652069        frame.selection().selectAll();
    20662070        break;
  • trunk/Tools/ChangeLog

    r255999 r256000  
     12020-02-06  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        WebPage::rangeForGranularityAtPoint always returns null in the case of CharacterGranularity
     4        https://bugs.webkit.org/show_bug.cgi?id=207350
     5        <rdar://problem/59239914>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a test to exercise the corner case in the SPI.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm: Added.
     13
    1142020-02-06  Jiewen Tan  <jiewen_tan@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r255595 r256000  
    996996                E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E5036F77211BC22800BFDBE2 /* color-drop.html */; };
    997997                ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; };
     998                F402F56C23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = F402F56B23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm */; };
    998999                F407FE391F1D0DFC0017CF25 /* enormous.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = F407FE381F1D0DE60017CF25 /* enormous.svg */; };
    9991000                F4106C6921ACBF84004B89A1 /* WKWebViewFirstResponderTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4106C6821ACBF84004B89A1 /* WKWebViewFirstResponderTests.mm */; };
     
    25612562                ECA680CD1E68CC0900731D20 /* StringUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringUtilities.mm; sourceTree = "<group>"; };
    25622563                F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
     2564                F402F56B23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UIWKInteractionViewProtocol.mm; sourceTree = "<group>"; };
    25632565                F407FE381F1D0DE60017CF25 /* enormous.svg */ = {isa = PBXFileReference; lastKnownFileType = text; path = enormous.svg; sourceTree = "<group>"; };
    25642566                F4106C6821ACBF84004B89A1 /* WKWebViewFirstResponderTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewFirstResponderTests.mm; sourceTree = "<group>"; };
     
    32643266                                F45033F4206BEC95009351CE /* TextAutosizingBoost.mm */,
    32653267                                F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */,
     3268                                F402F56B23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm */,
    32663269                                F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */,
    32673270                                514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */,
     
    49934996                                5CB40B4E1F4B98D3007DC7B9 /* UIDelegate.mm in Sources */,
    49944997                                F46849BE1EEF58E400B937FE /* UIPasteboardTests.mm in Sources */,
     4998                                F402F56C23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm in Sources */,
    49954999                                5C9D922E22D7DE1C008E9266 /* UnifiedSource1.cpp in Sources */,
    49965000                                5C9D922C22D7DE12008E9266 /* UnifiedSource1-mm.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r255907 r256000  
    175175- (void)requestAutocorrectionContextWithCompletionHandler:(void (^)(UIWKAutocorrectionContext *autocorrectionContext))completionHandler;
    176176- (void)selectWordBackward;
     177- (void)selectTextWithGranularity:(UITextGranularity)granularity atPoint:(CGPoint)point completionHandler:(void (^)(void))completionHandler;
     178- (void)updateSelectionWithExtentPoint:(CGPoint)point withBoundary:(UITextGranularity)granularity completionHandler:(void (^)(BOOL selectionEndIsMoving))completionHandler;
    177179@property (nonatomic, readonly) NSString *selectedText;
    178180@end
Note: See TracChangeset for help on using the changeset viewer.