Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d890a1f38c566bb9d17041ba1f93aaa7c1d2d6ed
https://github.com/WebKit/WebKit/commit/d890a1f38c566bb9d17041ba1f93aaa7c1d2d6ed
Author: Megan Gardner <[email protected]>
Date: 2026-09-29 (Tue, 29 Sep 2026)
Changed paths:
M Source/WebCore/editing/cocoa/AttributedString.h
M Source/WebCore/editing/cocoa/AttributedString.mm
M Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
M Tools/TestWebKitAPI/Tests/WebCore/cocoa/AttributedStringFontCache.mm
Log Message:
-----------
WebContent spends seconds converting attributed text when returning a large
range from attributedSubstringForProposedRange.
https://bugs.webkit.org/show_bug.cgi?id=325562
rdar://188645692
Reviewed by Abrar Rahman Protyasha.
WebPage::attributedSubstringForCharacterRangeAsync() converted the
WebCore::AttributedString from
editingAttributedString() to an NSAttributedString and back, only to trim the
trailing whitespace
that breaks ATOK. Each direction converts every attribute run, creating a
CTFont and converting
colors on the way out and back, so on a large range the round trip dominates
the time spent.
Stay in WebCore::AttributedString and trim with a new
AttributedString::truncate(), which clips
the run that straddles the new end and drops the runs after it.
Test: Tools/TestWebKitAPI/Tests/WebCore/cocoa/AttributedStringFontCache.mm
* Source/WebCore/editing/cocoa/AttributedString.h:
* Source/WebCore/editing/cocoa/AttributedString.mm:
(WebCore::AttributedString::truncate):
* Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::attributedSubstringForCharacterRangeAsync):
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/AttributedStringFontCache.mm:
(TestWebKitAPI::testAttributeValue):
(TestWebKitAPI::TEST(AttributedStringTruncate,
ClipsStraddlingRunsAndDropsLaterOnes)):
(TestWebKitAPI::TEST(AttributedStringTruncate, LeavesShorterStringUntouched)):
(TestWebKitAPI::TEST(AttributedStringTruncate,
DropsEveryRunWhenTruncatedToNothing)):
Canonical link: https://commits.webkit.org/322213@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications