Changeset 249508 in webkit
- Timestamp:
- Sep 4, 2019 6:17:13 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r249504 r249508 1 2019-09-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 -[WKContentView selectedText] returns an empty string when selecting more than 200 characters 4 https://bugs.webkit.org/show_bug.cgi?id=201471 5 <rdar://problem/55039227> 6 7 Reviewed by Tim Horton. 8 9 The fix for <rdar://problem/54308019> is contingent on -[WKContentView selectedText] returning a non-empty 10 result in the case where text is selected. However, in WebKit, if more than 200 characters are selected, 11 -selectedText ends up returning nothing. 12 13 This is due to logic added in trac.webkit.org/r167624 that was intended to return the selected text in 14 PostLayoutData's wordAtSelection, up to a maximum of 200 characters, likely for performance and/or security 15 reasons. However, instead of truncating at 200 characters, the change simply drops wordAtSelection altogether. 16 This patch fixes this issue by taking the first 200 characters of the selected text. 17 18 Test: EditorStateTests.SelectedText 19 20 * WebProcess/WebPage/ios/WebPageIOS.mm: 21 (WebKit::WebPage::platformEditorState const): 22 1 23 2019-09-04 Joseph Pecoraro <pecoraro@apple.com> 2 24 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r249435 r249508 262 262 postLayoutData.selectedTextLength = selectedText.length(); 263 263 const int maxSelectedTextLength = 200; 264 if (selectedText.length() <= maxSelectedTextLength) 265 postLayoutData.wordAtSelection = selectedText; 264 postLayoutData.wordAtSelection = selectedText.left(maxSelectedTextLength); 266 265 } 267 266 // FIXME: We should disallow replace when the string contains only CJ characters. -
trunk/Tools/ChangeLog
r249506 r249508 1 2019-09-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 -[WKContentView selectedText] returns an empty string when selecting more than 200 characters 4 https://bugs.webkit.org/show_bug.cgi?id=201471 5 <rdar://problem/55039227> 6 7 Reviewed by Tim Horton. 8 9 Add an API test to ensure that -selectedText is non-empty in the case where more than 200 characters are 10 selected. 11 12 * TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm: 13 (TestWebKitAPI::TEST): 14 * TestWebKitAPI/ios/UIKitSPI.h: 15 1 16 2019-09-04 Jonathan Bedard <jbedard@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm
r247679 r249508 421 421 } 422 422 423 TEST(EditorStateTests, SelectedText) 424 { 425 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 426 [webView synchronouslyLoadTestPageNamed:@"lots-of-text"]; 427 [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; 428 [webView waitForNextPresentationUpdate]; 429 EXPECT_GT([[webView textInputContentView] selectedText].length, 0U); 430 } 431 423 432 #endif // PLATFORM(IOS_FAMILY) 424 433 -
trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h
r248487 r249508 164 164 - (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHandler:(void (^)(UIWKAutocorrectionRects *rectsForInput))completionHandler; 165 165 - (void)requestAutocorrectionContextWithCompletionHandler:(void (^)(UIWKAutocorrectionContext *autocorrectionContext))completionHandler; 166 @property (nonatomic, readonly) NSString *selectedText; 166 167 @end 167 168
Note: See TracChangeset
for help on using the changeset viewer.