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

Changeset 248343 in webkit


Ignore:
Timestamp:
Aug 6, 2019, 11:52:11 PM (7 years ago)
Author:
Kocsen Chung
Message:

Cherry-pick r247679. rdar://problem/54017903

[iOS] [WebKit2] Add limited support for -isPosition:atBoundary:inDirection: in WKContentView
https://bugs.webkit.org/show_bug.cgi?id=199993
<rdar://problem/49523528>

Reviewed by Beth Dakin.

Source/WebKit:

Add support for -isPosition:atBoundary:inDirection:, only in the cases where the given position is the start or
and position and the given granularity is UITextGranularityParagraph.

Test: EditorStateTests.ParagraphBoundary

  • Shared/EditorState.cpp: (WebKit::EditorState::PostLayoutData::encode const): (WebKit::EditorState::PostLayoutData::decode):
  • Shared/EditorState.h:

Add a couple of bits to indicate whether the selection start or end positions are at paragraph boundaries.

  • UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView isPosition:atBoundary:inDirection:]):

Implement this to return selectionStartIsAtParagraphBoundary or selectionEndIsAtParagraphBoundary.

  • WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::platformEditorState const):

Tools:

Add a new API test to verify the behavior of -isPosition:atBoundary:inDirection:.

  • TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm: (TestWebKitAPI::TEST):
  • TestWebKitAPI/cocoa/TestWKWebView.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247679 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608.1-branch
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608.1-branch/Source/WebKit/ChangeLog

    r248342 r248343  
     12019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r247679. rdar://problem/54017903
     4
     5    [iOS] [WebKit2] Add limited support for -isPosition:atBoundary:inDirection: in WKContentView
     6    https://bugs.webkit.org/show_bug.cgi?id=199993
     7    <rdar://problem/49523528>
     8   
     9    Reviewed by Beth Dakin.
     10   
     11    Source/WebKit:
     12   
     13    Add support for -isPosition:atBoundary:inDirection:, only in the cases where the given position is the start or
     14    and position and the given granularity is UITextGranularityParagraph.
     15   
     16    Test: EditorStateTests.ParagraphBoundary
     17   
     18    * Shared/EditorState.cpp:
     19    (WebKit::EditorState::PostLayoutData::encode const):
     20    (WebKit::EditorState::PostLayoutData::decode):
     21    * Shared/EditorState.h:
     22   
     23    Add a couple of bits to indicate whether the selection start or end positions are at paragraph boundaries.
     24   
     25    * UIProcess/ios/WKContentViewInteraction.mm:
     26    (-[WKContentView isPosition:atBoundary:inDirection:]):
     27   
     28    Implement this to return selectionStartIsAtParagraphBoundary or selectionEndIsAtParagraphBoundary.
     29   
     30    * WebProcess/WebPage/ios/WebPageIOS.mm:
     31    (WebKit::WebPage::platformEditorState const):
     32   
     33    Tools:
     34   
     35    Add a new API test to verify the behavior of -isPosition:atBoundary:inDirection:.
     36   
     37    * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
     38    (TestWebKitAPI::TEST):
     39    * TestWebKitAPI/cocoa/TestWKWebView.h:
     40   
     41   
     42    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247679 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     43
     44    2019-07-21  Wenson Hsieh  <wenson_hsieh@apple.com>
     45
     46            [iOS] [WebKit2] Add limited support for -isPosition:atBoundary:inDirection: in WKContentView
     47            https://bugs.webkit.org/show_bug.cgi?id=199993
     48            <rdar://problem/49523528>
     49
     50            Reviewed by Beth Dakin.
     51
     52            Add support for -isPosition:atBoundary:inDirection:, only in the cases where the given position is the start or
     53            and position and the given granularity is UITextGranularityParagraph.
     54
     55            Test: EditorStateTests.ParagraphBoundary
     56
     57            * Shared/EditorState.cpp:
     58            (WebKit::EditorState::PostLayoutData::encode const):
     59            (WebKit::EditorState::PostLayoutData::decode):
     60            * Shared/EditorState.h:
     61
     62            Add a couple of bits to indicate whether the selection start or end positions are at paragraph boundaries.
     63
     64            * UIProcess/ios/WKContentViewInteraction.mm:
     65            (-[WKContentView isPosition:atBoundary:inDirection:]):
     66
     67            Implement this to return selectionStartIsAtParagraphBoundary or selectionEndIsAtParagraphBoundary.
     68
     69            * WebProcess/WebPage/ios/WebPageIOS.mm:
     70            (WebKit::WebPage::platformEditorState const):
     71
    1722019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
    273
  • branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.cpp

    r243102 r248343  
    135135    encoder << caretColor;
    136136    encoder << atStartOfSentence;
     137    encoder << selectionStartIsAtParagraphBoundary;
     138    encoder << selectionEndIsAtParagraphBoundary;
    137139#endif
    138140#if PLATFORM(MAC)
     
    197199        return false;
    198200    if (!decoder.decode(result.atStartOfSentence))
     201        return false;
     202    if (!decoder.decode(result.selectionStartIsAtParagraphBoundary))
     203        return false;
     204    if (!decoder.decode(result.selectionEndIsAtParagraphBoundary))
    199205        return false;
    200206#endif
  • branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.h

    r243102 r248343  
    113113        WebCore::Color caretColor;
    114114        bool atStartOfSentence { false };
     115        bool selectionStartIsAtParagraphBoundary { false };
     116        bool selectionEndIsAtParagraphBoundary { false };
    115117#endif
    116118#if PLATFORM(MAC)
  • branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r248341 r248343  
    50695069- (BOOL)isPosition:(UITextPosition *)position atBoundary:(UITextGranularity)granularity inDirection:(UITextDirection)direction
    50705070{
     5071    if (granularity == UITextGranularityParagraph) {
     5072        if (direction == UITextStorageDirectionBackward && [position isEqual:self.selectedTextRange.start])
     5073            return _page->editorState().postLayoutData().selectionStartIsAtParagraphBoundary;
     5074
     5075        if (direction == UITextStorageDirectionForward && [position isEqual:self.selectedTextRange.end])
     5076            return _page->editorState().postLayoutData().selectionEndIsAtParagraphBoundary;
     5077    }
     5078
    50715079    return NO;
    50725080}
  • branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r247798 r248343  
    274274        }
    275275        computeEditableRootHasContentAndPlainText(selection, postLayoutData);
     276        postLayoutData.selectionStartIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleStart(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionBackward);
     277        postLayoutData.selectionEndIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleEnd(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionForward);
    276278    }
    277279}
  • branches/safari-608.1-branch/Tools/ChangeLog

    r248127 r248343  
     12019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r247679. rdar://problem/54017903
     4
     5    [iOS] [WebKit2] Add limited support for -isPosition:atBoundary:inDirection: in WKContentView
     6    https://bugs.webkit.org/show_bug.cgi?id=199993
     7    <rdar://problem/49523528>
     8   
     9    Reviewed by Beth Dakin.
     10   
     11    Source/WebKit:
     12   
     13    Add support for -isPosition:atBoundary:inDirection:, only in the cases where the given position is the start or
     14    and position and the given granularity is UITextGranularityParagraph.
     15   
     16    Test: EditorStateTests.ParagraphBoundary
     17   
     18    * Shared/EditorState.cpp:
     19    (WebKit::EditorState::PostLayoutData::encode const):
     20    (WebKit::EditorState::PostLayoutData::decode):
     21    * Shared/EditorState.h:
     22   
     23    Add a couple of bits to indicate whether the selection start or end positions are at paragraph boundaries.
     24   
     25    * UIProcess/ios/WKContentViewInteraction.mm:
     26    (-[WKContentView isPosition:atBoundary:inDirection:]):
     27   
     28    Implement this to return selectionStartIsAtParagraphBoundary or selectionEndIsAtParagraphBoundary.
     29   
     30    * WebProcess/WebPage/ios/WebPageIOS.mm:
     31    (WebKit::WebPage::platformEditorState const):
     32   
     33    Tools:
     34   
     35    Add a new API test to verify the behavior of -isPosition:atBoundary:inDirection:.
     36   
     37    * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
     38    (TestWebKitAPI::TEST):
     39    * TestWebKitAPI/cocoa/TestWKWebView.h:
     40   
     41   
     42    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247679 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     43
     44    2019-07-21  Wenson Hsieh  <wenson_hsieh@apple.com>
     45
     46            [iOS] [WebKit2] Add limited support for -isPosition:atBoundary:inDirection: in WKContentView
     47            https://bugs.webkit.org/show_bug.cgi?id=199993
     48            <rdar://problem/49523528>
     49
     50            Reviewed by Beth Dakin.
     51
     52            Add a new API test to verify the behavior of -isPosition:atBoundary:inDirection:.
     53
     54            * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
     55            (TestWebKitAPI::TEST):
     56            * TestWebKitAPI/cocoa/TestWKWebView.h:
     57
    1582019-08-01  Ryan Haddad  <ryanhaddad@apple.com>
    259
  • branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm

    r244955 r248343  
    399399}
    400400
     401TEST(EditorStateTests, ParagraphBoundary)
     402{
     403    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     404    [webView synchronouslyLoadHTMLString:@"<body contenteditable><p>Hello world.</p></body>"];
     405    [webView stringByEvaluatingJavaScript:@"document.body.focus()"];
     406    [webView waitForNextPresentationUpdate];
     407
     408    auto textInput = [webView textInputContentView];
     409    auto editor = adoptNS([[EditingTestHarness alloc] initWithWebView:webView.get()]);
     410    [editor selectAll];
     411
     412    EXPECT_TRUE([textInput isPosition:textInput.selectedTextRange.start atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionBackward]);
     413    EXPECT_TRUE([textInput isPosition:textInput.selectedTextRange.end atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionForward]);
     414
     415    [editor moveForward];
     416    [editor moveBackward];
     417    [editor moveBackward];
     418
     419    EXPECT_FALSE([textInput isPosition:textInput.selectedTextRange.start atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionBackward]);
     420    EXPECT_FALSE([textInput isPosition:textInput.selectedTextRange.end atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionForward]);
     421}
     422
    401423#endif // PLATFORM(IOS_FAMILY)
    402424
  • branches/safari-608.1-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h

    r246924 r248343  
    8787
    8888@interface TestWKWebView (IOSOnly)
    89 @property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputInternal, UITextInputMultiDocument, UIWKInteractionViewProtocol> *textInputContentView;
     89@property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputInternal, UITextInputMultiDocument, UIWKInteractionViewProtocol, UITextInputTokenizer> *textInputContentView;
    9090@property (nonatomic, readonly) RetainPtr<NSArray> selectionRectsAfterPresentationUpdate;
    9191@property (nonatomic, readonly) CGRect caretViewRectInContentCoordinates;
Note: See TracChangeset for help on using the changeset viewer.