[webkit-changes] [WebKit/WebKit] a20433: Add Context menu option to copy link to currently ...

megangardner noreply at github.com
Sat Feb 17 09:10:38 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a204337cb0ff2df80b628fb8415ee6a39ceb4b2f
      https://github.com/WebKit/WebKit/commit/a204337cb0ff2df80b628fb8415ee6a39ceb4b2f
  Author: Megan Gardner <megan_gardner at apple.com>
  Date:   2024-02-17 (Sat, 17 Feb 2024)

  Changed paths:
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WTF/wtf/URL.cpp
    M Source/WTF/wtf/URL.h
    M Source/WTF/wtf/URLParser.cpp
    M Source/WTF/wtf/URLParser.h
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/dom/FragmentDirectiveGenerator.cpp
    A Source/WebCore/dom/FragmentDirectiveGenerator.h
    M Source/WebCore/en.lproj/Localizable.strings
    M Source/WebCore/page/ContextMenuController.cpp
    M Source/WebCore/page/ContextMenuController.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/platform/ContextMenuItem.cpp
    M Source/WebCore/platform/ContextMenuItem.h
    M Source/WebCore/platform/LocalizedStrings.cpp
    M Source/WebCore/platform/LocalizedStrings.h
    M Source/WebKit/Shared/API/c/WKContextMenuItemTypes.h
    M Source/WebKit/Shared/API/c/WKSharedAPICast.h
    M Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  Add Context menu option to copy link to currently selected text.
https://bugs.webkit.org/show_bug.cgi?id=269400
rdar://113158483

Reviewed by Ryosuke Niwa.

As discussed in  https://wicg.github.io/scroll-to-text-fragment/#generating-text-fragment-directives
Which is non-normative, currently, we can generated fragment directives by
looking at the text that is highlighted and the surrounding text.
This is a first pass implementation and there are several edge cases that still need to be
worked out, but this is a place to start.

Currently, for short pieces of text, we look back up to 3 words, in the same node, in each direction for
context. And if we have a large piece of text, we take the first three words at the beginning and end of
the content. Medium sized pieces of text are just denoted completely.

This does not give enough for situations where there is lots of repeated text, or text that is
repeated several times across a page, but it covers most cases.

This will be expanded with tests and additional work on know edge cases.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WTF/wtf/URL.cpp:
(WTF::percentEncodeFragmentDirectiveSpecialCharacters):
* Source/WTF/wtf/URL.h:
* Source/WTF/wtf/URLParser.cpp:
(WTF::isSpecialCharacterForFragmentDirective):
(WTF::URLParser::isSpecialCharacterForFragmentDirective):
* Source/WTF/wtf/URLParser.h:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/FragmentDirectiveGenerator.cpp: Added.
(WebCore::FragmentDirectiveGenerator::FragmentDirectiveGenerator):
(WebCore::previousWordsFromPosition):
* Source/WebCore/dom/FragmentDirectiveGenerator.h: Added.
(WebCore::FragmentDirectiveGenerator::urlWithFragment const):
* Source/WebCore/en.lproj/Localizable.strings:
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::populate):
(WebCore::ContextMenuController::shouldEnableCopyLinkToHighlight const):
(WebCore::ContextMenuController::checkOrEnableIfNeeded const):
* Source/WebCore/page/ContextMenuController.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::urlForSelectedText):
* Source/WebCore/page/Page.h:
* Source/WebCore/platform/ContextMenuItem.cpp:
(WebCore::isValidContextMenuAction):
* Source/WebCore/platform/ContextMenuItem.h:
* Source/WebCore/platform/LocalizedStrings.h:
* Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm:
(WebCore::contextMenuItemTagCopyLinkToHighlight):
* Source/WebKit/Shared/API/c/WKContextMenuItemTypes.h:
* Source/WebKit/Shared/API/c/WKSharedAPICast.h:
(WebKit::toAPI):
(WebKit::toImpl):
* Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm:
* Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::copyLinkToHighlight):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldAllowHighlightLinkCreation]):
(-[WKContentView buildMenuForWebViewWithBuilder:]):
(-[WKContentView appHighlightMenu]):
(-[WKContentView scrollToTextFragmentGenerationMenu]):
(-[WKContentView shouldAllowAppHighlightCreation]): Deleted.
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::menuItemIdentifier):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::copyLinkToHighlight):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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