Title: [248343] branches/safari-608.1-branch
Revision
248343
Author
[email protected]
Date
2019-08-06 23:52:11 -0700 (Tue, 06 Aug 2019)

Log 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

Modified Paths

Diff

Modified: branches/safari-608.1-branch/Source/WebKit/ChangeLog (248342 => 248343)


--- branches/safari-608.1-branch/Source/WebKit/ChangeLog	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Source/WebKit/ChangeLog	2019-08-07 06:52:11 UTC (rev 248343)
@@ -1,5 +1,76 @@
 2019-08-06  Kocsen Chung  <[email protected]>
 
+        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
+
+    2019-07-21  Wenson Hsieh  <[email protected]>
+
+            [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.
+
+            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):
+
+2019-08-06  Kocsen Chung  <[email protected]>
+
         Cherry-pick r247657. rdar://problem/54017957
 
     Provide correct names for UIContextMenuInteraction API replacements

Modified: branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.cpp (248342 => 248343)


--- branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.cpp	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.cpp	2019-08-07 06:52:11 UTC (rev 248343)
@@ -134,6 +134,8 @@
     encoder << editableRootIsTransparentOrFullyClipped;
     encoder << caretColor;
     encoder << atStartOfSentence;
+    encoder << selectionStartIsAtParagraphBoundary;
+    encoder << selectionEndIsAtParagraphBoundary;
 #endif
 #if PLATFORM(MAC)
     encoder << candidateRequestStartPosition;
@@ -197,6 +199,10 @@
         return false;
     if (!decoder.decode(result.atStartOfSentence))
         return false;
+    if (!decoder.decode(result.selectionStartIsAtParagraphBoundary))
+        return false;
+    if (!decoder.decode(result.selectionEndIsAtParagraphBoundary))
+        return false;
 #endif
 #if PLATFORM(MAC)
     if (!decoder.decode(result.candidateRequestStartPosition))

Modified: branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.h (248342 => 248343)


--- branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.h	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Source/WebKit/Shared/EditorState.h	2019-08-07 06:52:11 UTC (rev 248343)
@@ -112,6 +112,8 @@
         bool editableRootIsTransparentOrFullyClipped { false };
         WebCore::Color caretColor;
         bool atStartOfSentence { false };
+        bool selectionStartIsAtParagraphBoundary { false };
+        bool selectionEndIsAtParagraphBoundary { false };
 #endif
 #if PLATFORM(MAC)
         uint64_t candidateRequestStartPosition { 0 };

Modified: branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248342 => 248343)


--- branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-07 06:52:11 UTC (rev 248343)
@@ -5068,6 +5068,14 @@
 
 - (BOOL)isPosition:(UITextPosition *)position atBoundary:(UITextGranularity)granularity inDirection:(UITextDirection)direction
 {
+    if (granularity == UITextGranularityParagraph) {
+        if (direction == UITextStorageDirectionBackward && [position isEqual:self.selectedTextRange.start])
+            return _page->editorState().postLayoutData().selectionStartIsAtParagraphBoundary;
+
+        if (direction == UITextStorageDirectionForward && [position isEqual:self.selectedTextRange.end])
+            return _page->editorState().postLayoutData().selectionEndIsAtParagraphBoundary;
+    }
+
     return NO;
 }
 

Modified: branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (248342 => 248343)


--- branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-08-07 06:52:11 UTC (rev 248343)
@@ -273,6 +273,8 @@
                 postLayoutData.editableRootIsTransparentOrFullyClipped = isTransparentOrFullyClipped(*container);
         }
         computeEditableRootHasContentAndPlainText(selection, postLayoutData);
+        postLayoutData.selectionStartIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleStart(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionBackward);
+        postLayoutData.selectionEndIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleEnd(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionForward);
     }
 }
 

Modified: branches/safari-608.1-branch/Tools/ChangeLog (248342 => 248343)


--- branches/safari-608.1-branch/Tools/ChangeLog	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Tools/ChangeLog	2019-08-07 06:52:11 UTC (rev 248343)
@@ -1,3 +1,60 @@
+2019-08-06  Kocsen Chung  <[email protected]>
+
+        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
+
+    2019-07-21  Wenson Hsieh  <[email protected]>
+
+            [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.
+
+            Add a new API test to verify the behavior of -isPosition:atBoundary:inDirection:.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
+            (TestWebKitAPI::TEST):
+            * TestWebKitAPI/cocoa/TestWKWebView.h:
+
 2019-08-01  Ryan Haddad  <[email protected]>
 
         Cherry-pick r248072. rdar://problem/52355829

Modified: branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm (248342 => 248343)


--- branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm	2019-08-07 06:52:11 UTC (rev 248343)
@@ -398,6 +398,28 @@
     EXPECT_EQ(_WKSelectionAttributeNoSelection, [observer currentSelectionAttributes]);
 }
 
+TEST(EditorStateTests, ParagraphBoundary)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadHTMLString:@"<body contenteditable><p>Hello world.</p></body>"];
+    [webView stringByEvaluatingJavaScript:@"document.body.focus()"];
+    [webView waitForNextPresentationUpdate];
+
+    auto textInput = [webView textInputContentView];
+    auto editor = adoptNS([[EditingTestHarness alloc] initWithWebView:webView.get()]);
+    [editor selectAll];
+
+    EXPECT_TRUE([textInput isPosition:textInput.selectedTextRange.start atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionBackward]);
+    EXPECT_TRUE([textInput isPosition:textInput.selectedTextRange.end atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionForward]);
+
+    [editor moveForward];
+    [editor moveBackward];
+    [editor moveBackward];
+
+    EXPECT_FALSE([textInput isPosition:textInput.selectedTextRange.start atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionBackward]);
+    EXPECT_FALSE([textInput isPosition:textInput.selectedTextRange.end atBoundary:UITextGranularityParagraph inDirection:UITextStorageDirectionForward]);
+}
+
 #endif // PLATFORM(IOS_FAMILY)
 
 } // namespace TestWebKitAPI

Modified: branches/safari-608.1-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (248342 => 248343)


--- branches/safari-608.1-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2019-08-07 06:52:08 UTC (rev 248342)
+++ branches/safari-608.1-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2019-08-07 06:52:11 UTC (rev 248343)
@@ -86,7 +86,7 @@
 @end
 
 @interface TestWKWebView (IOSOnly)
-@property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputInternal, UITextInputMultiDocument, UIWKInteractionViewProtocol> *textInputContentView;
+@property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputInternal, UITextInputMultiDocument, UIWKInteractionViewProtocol, UITextInputTokenizer> *textInputContentView;
 @property (nonatomic, readonly) RetainPtr<NSArray> selectionRectsAfterPresentationUpdate;
 @property (nonatomic, readonly) CGRect caretViewRectInContentCoordinates;
 @property (nonatomic, readonly) NSArray<NSValue *> *selectionViewRectsInContentCoordinates;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to