[webkit-changes] [WebKit/WebKit] 42ee0a: Copying link to a common term in an article result...

Tim Horton noreply at github.com
Sat Sep 7 02:05:47 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 42ee0a01c846807e6b64f348ffa141e05e8188d4
      https://github.com/WebKit/WebKit/commit/42ee0a01c846807e6b64f348ffa141e05e8188d4
  Author: Tim Horton <thorton at apple.com>
  Date:   2024-09-07 (Sat, 07 Sep 2024)

  Changed paths:
    A LayoutTests/http/tests/scroll-to-text-fragment/generation-can-pass-inline-boundaries-expected.txt
    A LayoutTests/http/tests/scroll-to-text-fragment/generation-can-pass-inline-boundaries.html
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/dom/FragmentDirectiveGenerator.cpp
    M Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp
    A Source/WebCore/dom/FragmentDirectiveUtilities.cpp
    A Source/WebCore/dom/FragmentDirectiveUtilities.h

  Log Message:
  -----------
  Copying link to a common term in an article results in the incorrect part of the page being highlighted
https://bugs.webkit.org/show_bug.cgi?id=279248
rdar://134882107

Reviewed by Richard Robinson and Megan Gardner.

The fragment directive generation code was terminating its context walk when it hit
*any* node boundary, meaning that (for example) if you selected a word in its own <b>,
we wouldn't be able to generate any context, and the link would match the first
instance of that word on the page, not the correct one.

The intent was to match the fragment directive *search* code, which breaks across
block boundaries, not any element's boundary. Factor out this code (and add a
place where we can share code between generation and search, since we will likely
need more of that in the future).

* LayoutTests/http/tests/scroll-to-text-fragment/generation-can-pass-inline-boundaries-expected.txt: Added.
* LayoutTests/http/tests/scroll-to-text-fragment/generation-can-pass-inline-boundaries.html: Added.
Add a test.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/FragmentDirectiveGenerator.cpp:
(WebCore::positionsHaveSameBlockAncestor):
(WebCore::previousWordsFromPositionInSameBlock):
(WebCore::nextWordsFromPositionInSameBlock):
Make the aforementioned change, only terminating the context search when we exit the block.

(WebCore::FragmentDirectiveGenerator::generateFragmentDirective):
Make sure layout is up to date before we go reading from the render tree.
Move the fragment directive prefix string closer to its use.

(WebCore::previousWordsFromPosition): Deleted.
(WebCore::nextWordsFromPosition): Deleted.

* Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp:
(WebCore::FragmentDirectiveRangeFinder::nearestBlockAncestor): Deleted.
* Source/WebCore/dom/FragmentDirectiveUtilities.cpp: Added.
(WebCore::FragmentDirectiveUtilities::nearestBlockAncestor):
* Source/WebCore/dom/FragmentDirectiveUtilities.h: Added.
Factor out nearestBlockAncestor. I couldn't find anything similar in the rest
of the project, so for now kept it local to this code.

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