[webkit-changes] [WebKit/WebKit] fecae5: Generating scroll to text fragments around text th...

megangardner noreply at github.com
Thu Feb 20 16:56:54 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fecae51ab97156332c1faf6c5e42c7a6e41841d9
      https://github.com/WebKit/WebKit/commit/fecae51ab97156332c1faf6c5e42c7a6e41841d9
  Author: Megan Gardner <megan_gardner at apple.com>
  Date:   2025-02-20 (Thu, 20 Feb 2025)

  Changed paths:
    A LayoutTests/http/tests/scroll-to-text-fragment/generation-deal-with-newlines-in-directive-expected.txt
    A LayoutTests/http/tests/scroll-to-text-fragment/generation-deal-with-newlines-in-directive.html
    M Source/WebCore/dom/FragmentDirectiveGenerator.cpp

  Log Message:
  -----------
  Generating scroll to text fragments around text that contains newlines fails.
https://bugs.webkit.org/show_bug.cgi?id=288156
rdar://137109344

Reviewed by Wenson Hsieh.

When generating text fragments from text that includes a new line character
we would send that text that included the newline to the URL parser when we added
the fragment to the URL that we would then paste to the clipboard. The URL spec
says to remove all newlines and tabs so the two words that were separated by a
newline are now squished together and the fragment is incorrect. We need to
simplify the white space that is extracted from the range and then the words
will not be squished together and the permissive white space matching in the
fragment find code will find the correct text.

We encode newlines as spaces when generating text fragments, so that they are
ingested correctly in both Chrome and Safari.

* LayoutTests/http/tests/scroll-to-text-fragment/generation-deal-with-newlines-in-directive-expected.txt: Added.
* LayoutTests/http/tests/scroll-to-text-fragment/generation-deal-with-newlines-in-directive.html: Added.
* Source/WebCore/dom/FragmentDirectiveGenerator.cpp:
(WebCore::previousWordsFromPositionInSameBlock):
(WebCore::nextWordsFromPositionInSameBlock):
(WebCore::FragmentDirectiveGenerator::generateFragmentDirective):

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



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


More information about the webkit-changes mailing list