[webkit-changes] [WebKit/WebKit] 0b92e6: FragmentDirectiveGenerator: Selecting the first tw...

Tim Horton noreply at github.com
Fri Aug 16 17:29:58 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0b92e6db304e4326e077b979552ef80ba56d5a1a
      https://github.com/WebKit/WebKit/commit/0b92e6db304e4326e077b979552ef80ba56d5a1a
  Author: Tim Horton <thorton at apple.com>
  Date:   2024-08-16 (Fri, 16 Aug 2024)

  Changed paths:
    A LayoutTests/http/tests/scroll-to-text-fragment/generation-does-not-emit-empty-prefix-expected.txt
    A LayoutTests/http/tests/scroll-to-text-fragment/generation-does-not-emit-empty-prefix.html
    M Source/WebCore/dom/FragmentDirectiveGenerator.cpp
    M Source/WebCore/dom/FragmentDirectiveGenerator.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl

  Log Message:
  -----------
  FragmentDirectiveGenerator: Selecting the first two or three words of the first sentence in a paragraph results in the whole page highlighting
https://bugs.webkit.org/show_bug.cgi?id=278257
rdar://133772459

Reviewed by Wenson Hsieh and Megan Gardner.

The bug in the title results from our unconditional generation of a prefix (or suffix)
fragment component in the case where there is no possible prefix or suffix.

Avoid generating empty components, and to do so, reorganize the generation code a bit.

Add a test for this case (and make FragmentDirectiveGenerator trivially testable).

* LayoutTests/http/tests/scroll-to-text-fragment/generation-does-not-emit-empty-prefix-expected.txt: Added.
* LayoutTests/http/tests/scroll-to-text-fragment/generation-does-not-emit-empty-prefix.html: Added.
* Source/WebCore/dom/FragmentDirectiveGenerator.cpp:
(WebCore::FragmentDirectiveGenerator::generateFragmentDirective):
* Source/WebCore/dom/FragmentDirectiveGenerator.h:
(WebCore::FragmentDirectiveGenerator::urlWithFragment const):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::textFragmentDirectiveForRange):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:

Canonical link: https://commits.webkit.org/282375@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