[webkit-changes] [WebKit/WebKit] 3c7e1d: AX: Various attributedStringSetProperty methods un...

Tyler Wilcock noreply at github.com
Thu May 25 19:21:11 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3c7e1dfb09fafbbf4e7636ccd29c439eba2ed015
      https://github.com/WebKit/WebKit/commit/3c7e1dfb09fafbbf4e7636ccd29c439eba2ed015
  Author: Tyler Wilcock <tyler_w at apple.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M Source/WebCore/accessibility/cocoa/AccessibilityObjectCocoa.mm
    M Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm

  Log Message:
  -----------
  AX: Various attributedStringSetProperty methods unnecessarily call -[NSMutableAttributedString removeAttribute:range:]
https://bugs.webkit.org/show_bug.cgi?id=257287
rdar://problem/109798594

Reviewed by Chris Fleizach.

When we call attributedStringCreate, we always start with a fresh
attributed string. Then as we build the attributed string with the
various attributedStringSetFoo methods, we add the attribute to a given
range if necessary, and remove the attribute otherwise. But this removal
is completely unnecessary since we know we never added it in the first
place because the attributed string is brand new.

This saves 4.6k of 38k total samples on an academic journal webpage with
a lot of text (and therefore a lot of attributed strings that need creating).

* Source/WebCore/accessibility/cocoa/AccessibilityObjectCocoa.mm:
(WebCore::attributedStringSetNumber):
(WebCore::attributedStringSetFont):
* Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm:
(WebCore::attributedStringSetColor):
(WebCore::attributedStringSetStyle):
(WebCore::attributedStringSetHeadingLevel):
(WebCore::attributedStringSetBlockquoteLevel):
(WebCore::attributedStringSetExpandedText):
(WebCore::attributedStringSetElement):

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




More information about the webkit-changes mailing list