Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d05070c1f5a99cbb7b38243b5924899c1c7280bc
https://github.com/WebKit/WebKit/commit/d05070c1f5a99cbb7b38243b5924899c1c7280bc
Author: Tyler Wilcock <[email protected]>
Date: 2025-06-26 (Thu, 26 Jun 2025)
Changed paths:
M Source/WebCore/accessibility/AXLogger.cpp
M Source/WebCore/accessibility/AXTextMarker.cpp
M Source/WebCore/accessibility/AXTextRun.cpp
M Source/WebCore/accessibility/AXTextRun.h
M Source/WebCore/accessibility/AccessibilityRenderObject.cpp
M Source/WebCore/accessibility/cocoa/AXTextMarkerCocoa.mm
Log Message:
-----------
AX: AXTextMarker::findMarker, a frequently called function, can copy all the
text-runs strings, causing performance issues on pages with lots of text
https://bugs.webkit.org/show_bug.cgi?id=294996
rdar://154332688
Reviewed by Joshua Hoffman.
For groups of text runs that contain non-ASCII characters,
AXTextMarker::findMarker needs to use CachedTextBreakIterator
to determine how many offsets to move forward or backward. This is relevant for
things like multi-byte emojis. CachedTextBreakIterator
takes a StringView, but we were always doing the far less efficient thing of
combining the text from all AXTextRun structs
into a single String, requiring multiple allocations along the way. This is a
major performance problem on webpages that
have lots of text (e.g. 40 seconds of a 60 second sample was spent building and
allocating strings underneath findMarker).
We had to do it this way because CachedTextBreakIterator needs the full string
from all runs, but because each AXTextRun
owned its own string, we couldn't just naively use StringView here, because you
can't combine disparate StringViews (one
for each AXTextRun) into one larger StringView (that's not how StringViews
work).
Solve the issue by making AXTextRuns own a singular string for all runs, and
add start and end index fields to AXTextRun
that point into this string. This allows us to use StringViews in many more
places, which this commit does.
* Source/WebCore/accessibility/AXLogger.cpp:
(WebCore::streamTextRuns):
* Source/WebCore/accessibility/AXTextMarker.cpp:
(WebCore::AXTextMarkerRange::toString const):
(WebCore::AXTextMarker::findMarker const):
(WebCore::AXTextMarker::findParagraph const):
(WebCore::AXTextMarker::findWordOrSentence const):
* Source/WebCore/accessibility/AXTextRun.cpp:
(WebCore::AXTextRuns::debugDescription const):
(WebCore::AXTextRuns::localRect const):
(WebCore::AXTextRuns::substring const): Deleted.
* Source/WebCore/accessibility/AXTextRun.h:
(WebCore::AXTextRun::AXTextRun):
(WebCore::AXTextRun::length const):
(WebCore::AXTextRuns::AXTextRuns):
(WebCore::AXTextRuns::at const):
(WebCore::AXTextRuns::operator[] const):
(WebCore::AXTextRuns::runLength const):
(WebCore::AXTextRuns::lastRunLength const):
(WebCore::AXTextRuns::lineID const):
(WebCore::AXTextRuns::toString const):
(WebCore::AXTextRuns::toStringView const):
(WebCore::AXTextRuns::substring const):
(WebCore::AXTextRuns::runString const):
(WebCore::AXTextRuns::runStringView const):
(WebCore::AXTextRuns::runStartsWithLineBreak const):
(WebCore::AXTextRuns::runEndsWithLineBreak const):
(WebCore::AXTextRun::debugDescription const): Deleted.
(WebCore::AXTextRun::startsWithLineBreak const): Deleted.
(WebCore::AXTextRun::endsWithLineBreak const): Deleted.
(WebCore::AXTextRun::characterAt const): Deleted.
(WebCore::AXTextRun::textLength const): Deleted.
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::textRuns):
* Source/WebCore/accessibility/cocoa/AXTextMarkerCocoa.mm:
(WebCore::AXTextMarkerRange::toAttributedString const):
Canonical link: https://commits.webkit.org/296681@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes