Skip to content

Commit

Permalink
Rewrite TestWebKitAPI.AutocorrectionTests.FontAtCaretWhenUsingUICTFon…
Browse files Browse the repository at this point in the history
…tTextStyle to not use fontForCaretSelection.

https://bugs.webkit.org/show_bug.cgi?id=266055
rdar://119344370

Reviewed by Tim Horton.

After https://commits.webkit.org/271515@main TestWebKitAPI.AutocorrectionTests.FontAtCaretWhenUsingUICTFontTextStyle
was failing because it used a method that no longer existed. The test needed to be re-written to use the API that
now gives the font information.

I also removed a duplicate line from the previous patch, no need to set the default black color twice.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView textStylingAtPosition:inDirection:]):
* Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm:
(TEST):

Canonical link: https://commits.webkit.org/271724@main
  • Loading branch information
megangardner committed Dec 8, 2023
1 parent 008862a commit f75c480
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4264,8 +4264,6 @@ - (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:(
if (!_page->editorState().postLayoutData)
return result;

[result setObject:[UIColor blackColor] forKey:NSForegroundColorAttributeName];

auto typingAttributes = _page->editorState().postLayoutData->typingAttributes;

UIFont *font = _autocorrectionData.font.get();
Expand Down
8 changes: 6 additions & 2 deletions Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,18 @@ static void checkCGRectIsNotEmpty(CGRect rect)
checkCGRectIsNotEmpty([autocorrectionRects lastRect]);

auto contentView = [webView textInputContentView];
UIFont *fontBeforeScaling = [contentView fontForCaretSelection];
auto selectedTextRangeBeforeScaling = contentView.selectedTextRange;
auto stylingDictionaryBeforeScaling = [contentView textStylingAtPosition:selectedTextRangeBeforeScaling.start inDirection:UITextStorageDirectionForward];
UIFont *fontBeforeScaling = [stylingDictionaryBeforeScaling objectForKey:NSFontAttributeName];
UIFont *size16SystemFont = [UIFont systemFontOfSize:16];
EXPECT_WK_STREQ(size16SystemFont.fontName, fontBeforeScaling.fontName);
EXPECT_WK_STREQ(size16SystemFont.familyName, fontBeforeScaling.familyName);
EXPECT_EQ(16, fontBeforeScaling.pointSize);

[webView scrollView].zoomScale = 2;
UIFont *fontAfterScaling = [contentView fontForCaretSelection];
auto selectedTextRangeAfterScaling = contentView.selectedTextRange;
auto stylingDictionaryAfterScaling = [contentView textStylingAtPosition:selectedTextRangeAfterScaling.start inDirection:UITextStorageDirectionForward];
UIFont *fontAfterScaling = [stylingDictionaryAfterScaling objectForKey:NSFontAttributeName];
UIFont *size32SystemFont = [UIFont systemFontOfSize:32];
EXPECT_WK_STREQ(size32SystemFont.fontName, fontAfterScaling.fontName);
EXPECT_WK_STREQ(size32SystemFont.familyName, fontAfterScaling.familyName);
Expand Down

0 comments on commit f75c480

Please sign in to comment.