Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0d05b141742c9d80af6d6668505becd6a23f20fa
      
https://github.com/WebKit/WebKit/commit/0d05b141742c9d80af6d6668505becd6a23f20fa
  Author: Chris Dumez <[email protected]>
  Date:   2026-06-22 (Mon, 22 Jun 2026)

  Changed paths:
    M Source/WebCore/dom/FragmentDirectiveParser.cpp
    M Source/WebCore/dom/FragmentDirectiveParser.h
    M Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp
    M Source/WebCore/page/LocalFrameView.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp

  Log Message:
  -----------
  Clean up dead code in FragmentDirective parsing and range finding
https://bugs.webkit.org/show_bug.cgi?id=317565

Reviewed by Anne van Kesteren.

Address several dead/misleading code issues in the scroll-to-text-fragment
implementation found during code review:

- FragmentDirectiveParser::isValid() was meaningless: m_isValid was hardcoded
  to true on every construction, so the two caller guards (in LocalFrameView
  and WebPage) never fired. Rather than make it do something, remove isValid()
  and m_isValid entirely along with both caller guards. The empty-directives
  case those guards were nominally protecting against is already handled
  downstream: parsedTextDirectives() returns an empty vector, so
  findRangesFromTextDirectives() produces no ranges and the existing
  highlightRanges.isEmpty() checks take the early-return path.

- Removed FragmentDirectiveParser::remainingURLFragment() and its backing
  m_remainingURLFragment member. The member was never assigned and the getter
  had no callers, so it could only ever return an empty StringView.

- Removed the literal "&nbsp;" / "&nbsp" comparisons in
  advanceRangeStartToNextNonWhitespace(). A Text node's textContent holds
  decoded character data (an &nbsp; entity is already U+00A0), so these
  branches never matched. The U+00A0 case is already handled by the following
  isUnicodeWhitespace() check. Dropping them also keeps the subsequent index
  in bounds (it could previously be advanced up to 11 past the intended spot).

No change in behavior.

* Source/WebCore/dom/FragmentDirectiveParser.cpp:
(WebCore::FragmentDirectiveParser::FragmentDirectiveParser):
* Source/WebCore/dom/FragmentDirectiveParser.h:
(WebCore::FragmentDirectiveParser::fragmentDirective const):
(WebCore::FragmentDirectiveParser::isValid const): Deleted.
(WebCore::FragmentDirectiveParser::remainingURLFragment const): Deleted.
* Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp:
(WebCore::FragmentDirectiveRangeFinder::advanceRangeStartToNextNonWhitespace):
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::scrollToTextFragment):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::getTextFragmentMatch):

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



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

Reply via email to