Changeset 247679 in webkit
- Timestamp:
- Jul 21, 2019 8:35:38 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r247673 r247679 1 2019-07-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] [WebKit2] Add limited support for -isPosition:atBoundary:inDirection: in WKContentView 4 https://bugs.webkit.org/show_bug.cgi?id=199993 5 <rdar://problem/49523528> 6 7 Reviewed by Beth Dakin. 8 9 Add support for -isPosition:atBoundary:inDirection:, only in the cases where the given position is the start or 10 and position and the given granularity is UITextGranularityParagraph. 11 12 Test: EditorStateTests.ParagraphBoundary 13 14 * Shared/EditorState.cpp: 15 (WebKit::EditorState::PostLayoutData::encode const): 16 (WebKit::EditorState::PostLayoutData::decode): 17 * Shared/EditorState.h: 18 19 Add a couple of bits to indicate whether the selection start or end positions are at paragraph boundaries. 20 21 * UIProcess/ios/WKContentViewInteraction.mm: 22 (-[WKContentView isPosition:atBoundary:inDirection:]): 23 24 Implement this to return selectionStartIsAtParagraphBoundary or selectionEndIsAtParagraphBoundary. 25 26 * WebProcess/WebPage/ios/WebPageIOS.mm: 27 (WebKit::WebPage::platformEditorState const): 28 1 29 2019-07-20 Chris Dumez <cdumez@apple.com> 2 30 -
trunk/Source/WebKit/Shared/EditorState.cpp
r243102 r247679 135 135 encoder << caretColor; 136 136 encoder << atStartOfSentence; 137 encoder << selectionStartIsAtParagraphBoundary; 138 encoder << selectionEndIsAtParagraphBoundary; 137 139 #endif 138 140 #if PLATFORM(MAC) … … 197 199 return false; 198 200 if (!decoder.decode(result.atStartOfSentence)) 201 return false; 202 if (!decoder.decode(result.selectionStartIsAtParagraphBoundary)) 203 return false; 204 if (!decoder.decode(result.selectionEndIsAtParagraphBoundary)) 199 205 return false; 200 206 #endif -
trunk/Source/WebKit/Shared/EditorState.h
r243102 r247679 113 113 WebCore::Color caretColor; 114 114 bool atStartOfSentence { false }; 115 bool selectionStartIsAtParagraphBoundary { false }; 116 bool selectionEndIsAtParagraphBoundary { false }; 115 117 #endif 116 118 #if PLATFORM(MAC) -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r247653 r247679 5070 5070 - (BOOL)isPosition:(UITextPosition *)position atBoundary:(UITextGranularity)granularity inDirection:(UITextDirection)direction 5071 5071 { 5072 if (granularity == UITextGranularityParagraph) { 5073 if (direction == UITextStorageDirectionBackward && [position isEqual:self.selectedTextRange.start]) 5074 return _page->editorState().postLayoutData().selectionStartIsAtParagraphBoundary; 5075 5076 if (direction == UITextStorageDirectionForward && [position isEqual:self.selectedTextRange.end]) 5077 return _page->editorState().postLayoutData().selectionEndIsAtParagraphBoundary; 5078 } 5079 5072 5080 return NO; 5073 5081 } -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r247667 r247679 274 274 } 275 275 computeEditableRootHasContentAndPlainText(selection, postLayoutData); 276 postLayoutData.selectionStartIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleStart(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionBackward); 277 postLayoutData.selectionEndIsAtParagraphBoundary = atBoundaryOfGranularity(selection.visibleEnd(), TextGranularity::ParagraphGranularity, SelectionDirection::DirectionForward); 276 278 } 277 279 } -
trunk/Tools/ChangeLog
r247677 r247679 1 2019-07-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] [WebKit2] Add limited support for -isPosition:atBoundary:inDirection: in WKContentView 4 https://bugs.webkit.org/show_bug.cgi?id=199993 5 <rdar://problem/49523528> 6 7 Reviewed by Beth Dakin. 8 9 Add a new API test to verify the behavior of -isPosition:atBoundary:inDirection:. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm: 12 (TestWebKitAPI::TEST): 13 * TestWebKitAPI/cocoa/TestWKWebView.h: 14 1 15 2019-07-21 Andres Gonzalez <andresg_22@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm
r244955 r247679 399 399 } 400 400 401 TEST(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 401 423 #endif // PLATFORM(IOS_FAMILY) 402 424 -
trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h
r247567 r247679 88 88 89 89 @interface TestWKWebView (IOSOnly) 90 @property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputInternal, UITextInputMultiDocument, UIWKInteractionViewProtocol > *textInputContentView;90 @property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputInternal, UITextInputMultiDocument, UIWKInteractionViewProtocol, UITextInputTokenizer> *textInputContentView; 91 91 @property (nonatomic, readonly) RetainPtr<NSArray> selectionRectsAfterPresentationUpdate; 92 92 @property (nonatomic, readonly) CGRect caretViewRectInContentCoordinates;
Note: See TracChangeset
for help on using the changeset viewer.