Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ce9170834f27d66522b20ec1f423db0ee11f0ca2
      
https://github.com/WebKit/WebKit/commit/ce9170834f27d66522b20ec1f423db0ee11f0ca2
  Author: Tyler Wilcock <tyle...@apple.com>
  Date:   2025-03-01 (Sat, 01 Mar 2025)

  Changed paths:
    M Source/WebCore/accessibility/AXCoreObject.h
    M Source/WebCore/accessibility/AXLogger.cpp
    M Source/WebCore/accessibility/AXTextMarker.cpp
    M Source/WebCore/accessibility/AccessibilityNodeObject.cpp
    M Source/WebCore/accessibility/AccessibilityNodeObject.h
    M Source/WebCore/accessibility/AccessibilityObject.h
    M Source/WebCore/accessibility/cocoa/AXTextMarkerCocoa.mm
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h

  Log Message:
  -----------
  AX: AXTextMarker::offsetFromRoot repeatedly calls lineID() on a non-text-run 
marker, which is very expensive
https://bugs.webkit.org/show_bug.cgi?id=288887
rdar://145889534

Reviewed by Chris Fleizach.

This commit fixes quadratic behavior in AXTextMarker::offsetFromRoot caused by 
repeatedly calling lineID() on
a non-text-runs marker, which traverses to the first text-runs marker. This 
commit reimplements offsetFromRoot in a way
that is much more efficient, leaning on our existing knowledge of whether 
objects emit newlines rather than comparing
lineID()s.

This commit also includes a few other minor performance optimizations based on 
the learning from this problem — namely,
we should always convert marker to text-runs-markers ASAP to avoid repeatedly 
doing so in functions that require
text-runs-markers to operate correctly.

* Source/WebCore/accessibility/AXCoreObject.h:
(WebCore::AXCoreObject::emitsNewline const):
(WebCore::AXCoreObject::emitsNewlineAfter const): Deleted.
* Source/WebCore/accessibility/AXLogger.cpp:
(WebCore::operator<<):
* Source/WebCore/accessibility/AXTextMarker.cpp:
(WebCore::AXTextMarker::lineIndex const):
(WebCore::AXTextMarker::offsetFromRoot const):
(WebCore::AXTextMarkerRange::toString const):
(WebCore::AXTextMarker::lineRange const):
(WebCore::AXTextMarker::wordRange const):
(WebCore::AXTextMarker::sentenceRange const):
(WebCore::AXTextMarker::paragraphRange const):
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::textEmissionBehavior const):
(WebCore::AccessibilityNodeObject::emitTextAfterBehavior const): Deleted.
* Source/WebCore/accessibility/AccessibilityNodeObject.h:
* Source/WebCore/accessibility/AccessibilityObject.h:
* Source/WebCore/accessibility/cocoa/AXTextMarkerCocoa.mm:
(WebCore::AXTextMarkerRange::toAttributedString const):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeProperties):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:

Canonical link: https://commits.webkit.org/291455@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to