[webkit-changes] [WebKit/WebKit] 166aef: Content with -webkit-user-select: none should be s...

Ryosuke Niwa noreply at github.com
Mon Dec 12 11:41:04 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 166aef8967703338451b376ce492edc0fa79d86a
      https://github.com/WebKit/WebKit/commit/166aef8967703338451b376ce492edc0fa79d86a
  Author: Ryosuke Niwa <rniwa at webkit.org>
  Date:   2022-12-12 (Mon, 12 Dec 2022)

  Changed paths:
    A LayoutTests/editing/pasteboard/copy-content-with-user-select-none-expected.txt
    A LayoutTests/editing/pasteboard/copy-content-with-user-select-none.html
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/editing/TextIterator.cpp
    M Source/WebCore/editing/TextIteratorBehavior.h
    M Source/WebCore/editing/cocoa/EditorCocoa.mm
    M Source/WebCore/editing/cocoa/HTMLConverter.mm
    M Source/WebCore/editing/gtk/EditorGtk.cpp
    M Source/WebCore/editing/libwpe/EditorLibWPE.cpp
    M Source/WebCore/editing/mac/EditorMac.mm
    M Source/WebCore/editing/markup.cpp
    M Source/WebCore/editing/markup.h
    M Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
    M Source/WebCore/page/DOMSelection.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/CopyRTF.mm

  Log Message:
  -----------
  Content with -webkit-user-select: none should be skipped during copy
https://bugs.webkit.org/show_bug.cgi?id=80159

Reviewed by Darin Adler.

Exclude content with -webkit-user-select: none when copying. This patch introduces
TextIteratorBehavior::IgnoresUserSelectNone to exclude such content from plain text,
and adds IgnoreUserSelectNone as an argument to serializePreservingVisualAppearance
to exclude such content from HTML. It also updates HTMLConverter::_enterElement to
exclude such content from RTFD.

Finally, this patch also updates DOMSelection::toString to have the same treatment.

* LayoutTests/editing/pasteboard/copy-content-with-user-select-none-expected.txt: Added.
* LayoutTests/editing/pasteboard/copy-content-with-user-select-none.html: Added.

* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::selectedText const):
(WebCore::Editor::selectedTextForDataTransfer const):

* Source/WebCore/editing/TextIterator.cpp:
(WebCore::isRendererVisible): Added.
(WebCore::TextIterator::advance):
(WebCore::hasVisibleTextNode):
(WebCore::TextIterator::handleTextNodeFirstLetter):

* Source/WebCore/editing/TextIteratorBehavior.h:

* Source/WebCore/editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::selectionInHTMLFormat):

* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_enterElement):

* Source/WebCore/editing/gtk/EditorGtk.cpp:
(WebCore::Editor::writeSelectionToPasteboard):

* Source/WebCore/editing/libwpe/EditorLibWPE.cpp:
(WebCore::Editor::writeSelectionToPasteboard):

* Source/WebCore/editing/mac/EditorMac.mm:
(WebCore::Editor::writeImageToPasteboard):

* Source/WebCore/editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
(WebCore::StyledMarkupAccumulator::renderedTextRespectingRange):
(WebCore::StyledMarkupAccumulator::traverseNodesForSerialization):
(WebCore::serializePreservingVisualAppearanceInternal):
(WebCore::serializePreservingVisualAppearance):
(WebCore::sanitizedMarkupForFragmentInDocument):

* Source/WebCore/editing/markup.h:

* Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::createFromSelection):

* Source/WebCore/page/DOMSelection.cpp:
(WebCore::DOMSelection::toString const):

* Tools/TestWebKitAPI/Tests/WebKitCocoa/CopyRTF.mm:
(CopyRTF.StripsUserSelectNone):

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




More information about the webkit-changes mailing list