Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 099965ad5853b105e0140df560a99906d5a2b8f1
      
https://github.com/WebKit/WebKit/commit/099965ad5853b105e0140df560a99906d5a2b8f1
  Author: Tim Horton <[email protected]>
  Date:   2025-12-03 (Wed, 03 Dec 2025)

  Changed paths:
    M Source/WebCore/page/ContextMenuController.cpp
    M Source/WebCore/platform/mac/PasteboardMac.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/CopyURL.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteboardUtilities.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteboardUtilities.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKFragmentDirectiveGeneration.mm
    M Tools/TestWebKitAPI/Tests/mac/ContextMenuTests.mm
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.h
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

  Log Message:
  -----------
  Copy Link With Highlight copies the URL with a useless ('/') title
https://bugs.webkit.org/show_bug.cgi?id=303497
rdar://144782871

Reviewed by Aditya Keerthi.

Text fragment URLs are currently generated with a null title, which then
results in pasteboard code inferring the title from the URL. However,
for URLs with an empty path, we infer the title "/".

Fix this two ways: pass the selection as the title for text fragment URLs,
and also avoid ever inferring a single-character title from the URL when a 
title is not provided.

Tests: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKFragmentDirectiveGeneration.mm
       Tools/TestWebKitAPI/Tests/mac/ContextMenuTests.mm

* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
Try to include the selection as the title of the generated text fragment URL.

* Source/WebCore/platform/mac/PasteboardMac.mm:
(WebCore::writeURLForTypes):
Avoid inferring single-character titles from URL paths, they are common
(because of single-slash last path components), but out of context (when pasted
into TextEdit or Notes or wherever) are very mysterious.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/CopyURL.mm:
(readURLFromPasteboard): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteboardUtilities.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteboardUtilities.mm:
(readURLFromPasteboard):
(readTitleFromPasteboard):
(clearPasteboard):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKFragmentDirectiveGeneration.mm:
(TestWebKitAPI::createWebViewForFragmentDirectiveGenerationWithHTML):
(TestWebKitAPI::TEST(FragmentDirectiveGeneration, GenerateFragment)):
(TestWebKitAPI::TEST(FragmentDirectiveGeneration, VerifyFragmentRanges)):
(TestWebKitAPI::TEST(FragmentDirectiveGeneration, IncludesSelectionAsURLTitle)):
Add a test ensuring that "Copy Link With Highlight" includes the selection as 
the URL's title.

* Tools/TestWebKitAPI/Tests/mac/ContextMenuTests.mm:
(TestWebKitAPI::TEST(ContextMenuTests, CopyLinkIncludesTitle)):
(TestWebKitAPI::TEST(ContextMenuTests, 
CopyLinkUsesFullURLAsTitleForLinkWithShortPath)):
(TestWebKitAPI::TEST(ContextMenuTests, 
CopyLinkUsesPathComponentAsTitleForLinkWithPath)):
Add a test ensuring that "Copy Link" includes the full URL as the title for a 
link with a single-character
path, and includes the last path component in other cases.

(itemMatchingFilter): Deleted.
(-[TestWKWebView rightClick:andSelectItemMatching:]): Deleted.
(-[TestWKWebView rightClickAtPointAndWaitForContextMenu:]): Deleted.
Hoist these useful utilities into shared places.

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



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

Reply via email to