Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7980c0dc3a35b7bb1f573647bcd0951c87d21869
      
https://github.com/WebKit/WebKit/commit/7980c0dc3a35b7bb1f573647bcd0951c87d21869
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-05 (Sun, 05 Apr 2026)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp

  Log Message:
  -----------
  TextUtil::width: Fix single space width fast path to only apply to space 
characters
https://bugs.webkit.org/show_bug.cgi?id=311516

Reviewed by Alan Baradlay.

The single-whitespace fast path in TextUtil::width had three issues:

1. `from - to == 1` underflows because both operands are unsigned and
   from < to in normal usage, making the comparison always false.

2. Even after fixing the underflow to `to - from == 1`, the fast path
   incorrectly returned singleSpaceWidth for tab characters. Tabs need
   full measurement to account for CSS tab-size, so the fast path must
   be restricted to actual space characters when whitespace is preserved.

3. When whitespace collapses (!shouldPreserveSpacesAndTabs), the
   underlying string may still contain newlines or tabs even though
   they visually collapse to a space. The space character check must
   not apply in this case, as all collapsed whitespace should use the
   singleSpaceWidth fast path regardless of the original character.

* Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::width):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to