⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 292898 in webkit


Ignore:
Timestamp:
Apr 14, 2022, 6:45:58 PM (4 years ago)
Author:
Wenson Hsieh
Message:

Undo option after invoking "Markup Image" says "Undo Paste"
https://bugs.webkit.org/show_bug.cgi?id=239351
rdar://91647863

Reviewed by Darin Adler.

Source/WebCore:

Add plumbing to allow a caller of Editor::replaceNodeFromPasteboard to specify an EditAction for the editing
command that is not just EditAction::Paste, and use it to supply a more specific edit action type of
MarkupImage in the case where "Markup Image" is used to replace an image element with other image data. This
allows the undo/redo title to be more accurate than simply "Undo/Redo Paste".

Test: ImageAnalysisTests.PerformImageAnalysisMarkup

  • dom/TextEvent.cpp:

(WebCore::TextEvent::createForPlainTextPaste):
(WebCore::TextEvent::createForFragmentPaste):
(WebCore::TextEvent::TextEvent):

  • dom/TextEvent.h:
  • dom/TextEventInputType.h:

Introduce TextEventInputMarkup. This is used to preserve the fact that a TextEvent was triggered via
"Markup Image" as opposed to a regular "Paste" command, when plumbing this event object through DOM event
propagation code. Once it reenters editing code, we consult this type to re-map this event to
EditAction::MarkupImage if appropriate.

I opted for this (slightly more roundabout) approach to prevent a potential layering violation, due to TextEvent
otherwise knowing about EditAction.

  • editing/EditAction.cpp:

(WebCore::undoRedoLabel):

  • editing/EditAction.h:

Introduce EditAction::MarkupImage. Additionally, alphabetically sort these enum types.

  • editing/Editor.cpp:

(WebCore::Editor::handleTextEvent):
(WebCore::Editor::pasteAsFragment):
(WebCore::Editor::replaceSelectionWithFragment):

  • editing/Editor.h:
  • editing/cocoa/EditorCocoa.mm:

(WebCore::Editor::replaceNodeFromPasteboard):

Add an EditAction argument; by default, this is EditAction::Paste.

  • en.lproj/Localizable.strings:

Add a new localized string to represent the name of the "Markup Image" item, for the purposes of setting the
Redo/Undo action title.

Source/WebKit:

Rename replaceWithPasteboardData to the more specific replaceImageWithMarkupResults. This method was
introduced (and is currently only used) to drive image replacement using "Markup Image"; giving this method a
more specific name allows us to hard-code EditAction::MarkupImage when calling into Editor to carry out the
replacement editing action in WebPage::replaceImageWithMarkupResults.

See WebCore/ChangeLog for additional details.

  • UIProcess/Cocoa/WebPageProxyCocoa.mm:

(WebKit::WebPageProxy::replaceImageWithMarkupResults):
(WebKit::WebPageProxy::replaceWithPasteboardData): Deleted.

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView imageAnalysisMarkupMenu]):

  • UIProcess/mac/WebContextMenuProxyMac.mm:

(WebKit::WebContextMenuProxyMac::applyMarkupToControlledImage):

  • WebProcess/WebPage/Cocoa/WebPageCocoa.mm:

(WebKit::WebPage::replaceImageWithMarkupResults):
(WebKit::WebPage::replaceWithPasteboardData): Deleted.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:

Tools:

Augment an existing API test to verify that the resulting undo action title after invoking "Markup Image" is not
"Undo Paste".

  • TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r292895 r292898  
     12022-04-14  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Undo option after invoking "Markup Image" says "Undo Paste"
     4        https://bugs.webkit.org/show_bug.cgi?id=239351
     5        rdar://91647863
     6
     7        Reviewed by Darin Adler.
     8
     9        Add plumbing to allow a caller of `Editor::replaceNodeFromPasteboard` to specify an `EditAction` for the editing
     10        command that is not just `EditAction::Paste`, and use it to supply a more specific edit action type of
     11        `MarkupImage` in the case where "Markup Image" is used to replace an image element with other image data. This
     12        allows the undo/redo title to be more accurate than simply "Undo/Redo Paste".
     13
     14        Test: ImageAnalysisTests.PerformImageAnalysisMarkup
     15
     16        * dom/TextEvent.cpp:
     17        (WebCore::TextEvent::createForPlainTextPaste):
     18        (WebCore::TextEvent::createForFragmentPaste):
     19        (WebCore::TextEvent::TextEvent):
     20        * dom/TextEvent.h:
     21        * dom/TextEventInputType.h:
     22
     23        Introduce TextEventInputMarkup. This is used to preserve the fact that a `TextEvent` was triggered via
     24        "Markup Image" as opposed to a regular "Paste" command, when plumbing this event object through DOM event
     25        propagation code. Once it reenters editing code, we consult this type to re-map this event to
     26        `EditAction::MarkupImage` if appropriate.
     27
     28        I opted for this (slightly more roundabout) approach to prevent a potential layering violation, due to TextEvent
     29        otherwise knowing about `EditAction`.
     30
     31        * editing/EditAction.cpp:
     32        (WebCore::undoRedoLabel):
     33        * editing/EditAction.h:
     34
     35        Introduce EditAction::MarkupImage. Additionally, alphabetically sort these enum types.
     36
     37        * editing/Editor.cpp:
     38        (WebCore::Editor::handleTextEvent):
     39        (WebCore::Editor::pasteAsFragment):
     40        (WebCore::Editor::replaceSelectionWithFragment):
     41        * editing/Editor.h:
     42        * editing/cocoa/EditorCocoa.mm:
     43        (WebCore::Editor::replaceNodeFromPasteboard):
     44
     45        Add an `EditAction` argument; by default, this is `EditAction::Paste`.
     46
     47        * en.lproj/Localizable.strings:
     48
     49        Add a new localized string to represent the name of the "Markup Image" item, for the purposes of setting the
     50        Redo/Undo action title.
     51
    1522022-04-14  Caitlin Potter  <caitp@igalia.com>
    253
  • trunk/Source/WebCore/dom/TextEvent.cpp

    r283237 r292898  
    4949Ref<TextEvent> TextEvent::createForPlainTextPaste(RefPtr<WindowProxy>&& view, const String& data, bool shouldSmartReplace)
    5050{
    51     return adoptRef(*new TextEvent(WTFMove(view), data, nullptr, shouldSmartReplace, false, MailBlockquoteHandling::RespectBlockquote));
     51    return adoptRef(*new TextEvent(WTFMove(view), data, nullptr, TextEventInputPaste, shouldSmartReplace, false, MailBlockquoteHandling::RespectBlockquote));
    5252}
    5353
    54 Ref<TextEvent> TextEvent::createForFragmentPaste(RefPtr<WindowProxy>&& view, RefPtr<DocumentFragment>&& data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
     54Ref<TextEvent> TextEvent::createForFragmentPaste(RefPtr<WindowProxy>&& view, RefPtr<DocumentFragment>&& data, TextEventInputType inputType, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
    5555{
    56     return adoptRef(*new TextEvent(WTFMove(view), emptyString(), WTFMove(data), shouldSmartReplace, shouldMatchStyle, mailBlockquoteHandling));
     56    return adoptRef(*new TextEvent(WTFMove(view), emptyString(), WTFMove(data), inputType, shouldSmartReplace, shouldMatchStyle, mailBlockquoteHandling));
    5757}
    5858
     
    8585}
    8686
    87 TextEvent::TextEvent(RefPtr<WindowProxy>&& view, const String& data, RefPtr<DocumentFragment>&& pastingFragment, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
     87TextEvent::TextEvent(RefPtr<WindowProxy>&& view, const String& data, RefPtr<DocumentFragment>&& pastingFragment, TextEventInputType inputType, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
    8888    : UIEvent(eventNames().textInputEvent, CanBubble::Yes, IsCancelable::Yes, IsComposed::Yes, WTFMove(view), 0)
    89     , m_inputType(TextEventInputPaste)
     89    , m_inputType(inputType)
    9090    , m_data(data)
    9191    , m_pastingFragment(WTFMove(pastingFragment))
  • trunk/Source/WebCore/dom/TextEvent.h

    r250060 r292898  
    4343        static Ref<TextEvent> createForBindings();
    4444        static Ref<TextEvent> createForPlainTextPaste(RefPtr<WindowProxy>&&, const String& data, bool shouldSmartReplace);
    45         static Ref<TextEvent> createForFragmentPaste(RefPtr<WindowProxy>&&, RefPtr<DocumentFragment>&& data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
     45        static Ref<TextEvent> createForFragmentPaste(RefPtr<WindowProxy>&&, RefPtr<DocumentFragment>&& data, TextEventInputType, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
    4646        static Ref<TextEvent> createForDrop(RefPtr<WindowProxy>&&, const String& data);
    4747        static Ref<TextEvent> createForDictation(RefPtr<WindowProxy>&&, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
     
    6363        bool isAutocompletion() const { return m_inputType == TextEventInputAutocompletion; }
    6464        bool isKeyboard() const { return m_inputType == TextEventInputKeyboard; }
     65        bool isMarkup() const { return m_inputType == TextEventInputMarkup; }
    6566
    6667        bool shouldSmartReplace() const { return m_shouldSmartReplace; }
     
    7475
    7576        TextEvent(RefPtr<WindowProxy>&&, const String& data, TextEventInputType = TextEventInputKeyboard);
    76         TextEvent(RefPtr<WindowProxy>&&, const String& data, RefPtr<DocumentFragment>&&, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
     77        TextEvent(RefPtr<WindowProxy>&&, const String& data, RefPtr<DocumentFragment>&&, TextEventInputType, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
    7778        TextEvent(RefPtr<WindowProxy>&&, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
    7879
  • trunk/Source/WebCore/dom/TextEventInputType.h

    r208179 r292898  
    3737    TextEventInputDrop,
    3838    TextEventInputDictation,
     39    TextEventInputMarkup,
    3940    TextEventInputOther,
    4041};
  • trunk/Source/WebCore/editing/EditAction.cpp

    r266342 r292898  
    143143    case EditAction::ConvertToUnorderedList:
    144144        return WEB_UI_STRING_KEY("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name");
     145    case EditAction::MarkupImage:
     146        return WEB_UI_STRING_KEY("Markup Image", "Image analysis markup menu item (Undo action name)", "Undo action name");
    145147    }
    146148    return { };
  • trunk/Source/WebCore/editing/EditAction.h

    r266342 r292898  
    3333
    3434enum class EditAction : uint8_t {
    35     Unspecified,
    36     Insert,
    37     InsertReplacement,
    38     InsertFromDrop,
    39     SetColor,
    40     SetBackgroundColor,
    41     TurnOffKerning,
    42     TightenKerning,
    43     LoosenKerning,
    44     UseStandardKerning,
    45     TurnOffLigatures,
    46     UseStandardLigatures,
    47     UseAllLigatures,
    48     RaiseBaseline,
    49     LowerBaseline,
    50     SetTraditionalCharacterShape,
    51     SetFont,
    52     ChangeAttributes,
    5335    AlignLeft,
    5436    AlignRight,
     37    Bold,
    5538    Center,
     39    ChangeAttributes,
     40    ConvertToOrderedList,
     41    ConvertToUnorderedList,
     42    CreateLink,
     43    Cut,
     44    Delete,
     45    DeleteByDrag,
     46    Dictation,
     47    FormatBlock,
     48    Indent,
     49    Insert,
     50    InsertFromDrop,
     51    InsertOrderedList,
     52    InsertReplacement,
     53    InsertUnorderedList,
     54    Italics,
    5655    Justify,
    57     SetInlineWritingDirection,
    58     SetBlockWritingDirection,
    59     Subscript,
    60     Superscript,
    61     Underline,
    62     StrikeThrough,
     56    LoosenKerning,
     57    LowerBaseline,
     58    MarkupImage,
     59    Outdent,
    6360    Outline,
    64     Unscript,
    65     DeleteByDrag,
    66     Cut,
    67     Bold,
    68     Italics,
    69     Delete,
    70     Dictation,
    7161    Paste,
    7262    PasteFont,
    7363    PasteRuler,
    74     TypingDeleteSelection,
     64    RaiseBaseline,
     65    SetBackgroundColor,
     66    SetBlockWritingDirection,
     67    SetColor,
     68    SetFont,
     69    SetInlineWritingDirection,
     70    SetTraditionalCharacterShape,
     71    StrikeThrough,
     72    Subscript,
     73    Superscript,
     74    TightenKerning,
     75    TurnOffKerning,
     76    TurnOffLigatures,
    7577    TypingDeleteBackward,
     78    TypingDeleteFinalComposition,
    7679    TypingDeleteForward,
    77     TypingDeleteWordBackward,
    78     TypingDeleteWordForward,
    7980    TypingDeleteLineBackward,
    8081    TypingDeleteLineForward,
    8182    TypingDeletePendingComposition,
    82     TypingDeleteFinalComposition,
    83     TypingInsertText,
     83    TypingDeleteSelection,
     84    TypingDeleteWordBackward,
     85    TypingDeleteWordForward,
     86    TypingInsertFinalComposition,
    8487    TypingInsertLineBreak,
    8588    TypingInsertParagraph,
    8689    TypingInsertPendingComposition,
    87     TypingInsertFinalComposition,
    88     CreateLink,
     90    TypingInsertText,
     91    Underline,
    8992    Unlink,
    90     FormatBlock,
    91     InsertOrderedList,
    92     InsertUnorderedList,
    93     ConvertToOrderedList,
    94     ConvertToUnorderedList,
    95     Indent,
    96     Outdent
     93    Unscript,
     94    Unspecified,
     95    UseAllLigatures,
     96    UseStandardKerning,
     97    UseStandardLigatures,
    9798};
    9899
  • trunk/Source/WebCore/editing/Editor.cpp

    r292810 r292898  
    338338        return false;
    339339
    340     if (event.isPaste()) {
     340    if (event.isPaste() || event.isMarkup()) {
     341        auto action = event.isMarkup() ? EditAction::MarkupImage : EditAction::Paste;
    341342        if (event.pastingFragment()) {
    342343#if PLATFORM(IOS_FAMILY)
     
    344345                return true;
    345346#endif
    346             replaceSelectionWithFragment(*event.pastingFragment(), SelectReplacement::No, event.shouldSmartReplace() ? SmartReplace::Yes : SmartReplace::No, event.shouldMatchStyle() ? MatchStyle::Yes : MatchStyle::No, EditAction::Paste, event.mailBlockquoteHandling());
     347            replaceSelectionWithFragment(*event.pastingFragment(), SelectReplacement::No, event.shouldSmartReplace() ? SmartReplace::Yes : SmartReplace::No, event.shouldMatchStyle() ? MatchStyle::Yes : MatchStyle::No, action, event.mailBlockquoteHandling());
    347348        } else
    348             replaceSelectionWithText(event.data(), SelectReplacement::No, event.shouldSmartReplace() ? SmartReplace::Yes : SmartReplace::No, EditAction::Paste);
     349            replaceSelectionWithText(event.data(), SelectReplacement::No, event.shouldSmartReplace() ? SmartReplace::Yes : SmartReplace::No, action);
    349350        return true;
    350351    }
     
    627628}
    628629
    629 void Editor::pasteAsFragment(Ref<DocumentFragment>&& pastingFragment, bool smartReplace, bool matchStyle, MailBlockquoteHandling respectsMailBlockquote)
     630void Editor::pasteAsFragment(Ref<DocumentFragment>&& pastingFragment, bool smartReplace, bool matchStyle, MailBlockquoteHandling respectsMailBlockquote, EditAction action)
    630631{
    631632    auto target = findEventTargetFromSelection();
    632633    if (!target)
    633634        return;
    634     target->dispatchEvent(TextEvent::createForFragmentPaste(document().windowProxy(), WTFMove(pastingFragment), smartReplace, matchStyle, respectsMailBlockquote));
     635
     636    ASSERT(action == EditAction::MarkupImage || action == EditAction::Paste);
     637    auto type = action == EditAction::MarkupImage ? TextEventInputMarkup : TextEventInputPaste;
     638    target->dispatchEvent(TextEvent::createForFragmentPaste(document().windowProxy(), WTFMove(pastingFragment), type, smartReplace, matchStyle, respectsMailBlockquote));
    635639}
    636640
     
    687691
    688692    AccessibilityReplacedText replacedText;
    689     if (AXObjectCache::accessibilityEnabled() && (editingAction == EditAction::Paste || editingAction == EditAction::Insert))
     693    if (AXObjectCache::accessibilityEnabled() && (editingAction == EditAction::Paste || editingAction == EditAction::Insert || editingAction == EditAction::MarkupImage))
    690694        replacedText = AccessibilityReplacedText(selection);
    691695
  • trunk/Source/WebCore/editing/Editor.h

    r292032 r292898  
    445445    void dismissCorrectionPanelAsIgnored();
    446446
    447     WEBCORE_EXPORT void pasteAsFragment(Ref<DocumentFragment>&&, bool smartReplace, bool matchStyle, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
     447    WEBCORE_EXPORT void pasteAsFragment(Ref<DocumentFragment>&&, bool smartReplace, bool matchStyle, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote, EditAction = EditAction::Paste);
    448448    WEBCORE_EXPORT void pasteAsPlainText(const String&, bool smartReplace);
    449449
     
    538538    WEBCORE_EXPORT void replaceSelectionWithAttributedString(NSAttributedString *, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
    539539    WEBCORE_EXPORT void readSelectionFromPasteboard(const String& pasteboardName);
    540     WEBCORE_EXPORT void replaceNodeFromPasteboard(Node&, const String& pasteboardName);
     540    WEBCORE_EXPORT void replaceNodeFromPasteboard(Node&, const String& pasteboardName, EditAction = EditAction::Paste);
    541541#endif
    542542
  • trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm

    r290578 r292898  
    347347}
    348348
    349 void Editor::replaceNodeFromPasteboard(Node& node, const String& pasteboardName)
     349void Editor::replaceNodeFromPasteboard(Node& node, const String& pasteboardName, EditAction action)
    350350{
    351351    if (node.document() != m_document)
     
    378378        maybeCopyNodeAttributesToFragment(node, *fragment);
    379379        if (shouldInsertFragment(*fragment, *range, EditorInsertAction::Pasted))
    380             pasteAsFragment(fragment.releaseNonNull(), false, false, MailBlockquoteHandling::IgnoreBlockquote);
     380            pasteAsFragment(fragment.releaseNonNull(), false, false, MailBlockquoteHandling::IgnoreBlockquote, action);
    381381    }
    382382
  • trunk/Source/WebCore/en.lproj/Localizable.strings

    r291567 r292898  
    549549
    550550/* Undo action name */
     551"Image analysis markup menu item (Undo action name)" = "Markup Image";
     552
     553/* Undo action name */
    551554"Indent (Undo action name)" = "Indent";
    552555
  • trunk/Source/WebKit/ChangeLog

    r292896 r292898  
     12022-04-14  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Undo option after invoking "Markup Image" says "Undo Paste"
     4        https://bugs.webkit.org/show_bug.cgi?id=239351
     5        rdar://91647863
     6
     7        Reviewed by Darin Adler.
     8
     9        Rename `replaceWithPasteboardData` to the more specific `replaceImageWithMarkupResults`. This method was
     10        introduced (and is currently only used) to drive image replacement using "Markup Image"; giving this method a
     11        more specific name allows us to hard-code `EditAction::MarkupImage` when calling into Editor to carry out the
     12        replacement editing action in `WebPage::replaceImageWithMarkupResults`.
     13
     14        See WebCore/ChangeLog for additional details.
     15
     16        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
     17        (WebKit::WebPageProxy::replaceImageWithMarkupResults):
     18        (WebKit::WebPageProxy::replaceWithPasteboardData): Deleted.
     19        * UIProcess/WebPageProxy.h:
     20        * UIProcess/ios/WKContentViewInteraction.mm:
     21        (-[WKContentView imageAnalysisMarkupMenu]):
     22        * UIProcess/mac/WebContextMenuProxyMac.mm:
     23        (WebKit::WebContextMenuProxyMac::applyMarkupToControlledImage):
     24        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
     25        (WebKit::WebPage::replaceImageWithMarkupResults):
     26        (WebKit::WebPage::replaceWithPasteboardData): Deleted.
     27        * WebProcess/WebPage/WebPage.h:
     28        * WebProcess/WebPage/WebPage.messages.in:
     29
    1302022-04-14  Wenson Hsieh  <wenson_hsieh@apple.com>
    231
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r291810 r292898  
    916916}
    917917
    918 void WebPageProxy::replaceWithPasteboardData(const ElementContext& elementContext, const Vector<String>& types, const IPC::DataReference& data)
    919 {
    920     send(Messages::WebPage::ReplaceWithPasteboardData(elementContext, types, data));
     918void WebPageProxy::replaceImageWithMarkupResults(const ElementContext& elementContext, const Vector<String>& types, const IPC::DataReference& data)
     919{
     920    send(Messages::WebPage::ReplaceImageWithMarkupResults(elementContext, types, data));
    921921}
    922922
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r292812 r292898  
    268268enum class DOMPasteAccessCategory : uint8_t;
    269269enum class DOMPasteAccessResponse : uint8_t;
     270enum class EditAction : uint8_t;
    270271enum class EventMakesGamepadsVisible : bool;
    271272enum class LockBackForwardList : bool;
     
    11951196    // Called by the UI process when it is ready to send its tokens to the web process.
    11961197    void registerUIProcessAccessibilityTokens(const IPC::DataReference& elemenToken, const IPC::DataReference& windowToken);
    1197     void replaceWithPasteboardData(const WebCore::ElementContext&, const Vector<String>& types, const IPC::DataReference&);
     1198    void replaceImageWithMarkupResults(const WebCore::ElementContext&, const Vector<String>& types, const IPC::DataReference&);
    11981199    void replaceSelectionWithPasteboardData(const Vector<String>& types, const IPC::DataReference&);
    11991200    bool readSelectionFromPasteboard(const String& pasteboardName);
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r292896 r292898  
    47354735        auto [elementContext, image, preferredMIMEType] = *view->_imageAnalysisMarkupData;
    47364736        if (auto [data, type] = WebKit::transcodeWithPreferredMIMEType(image.get(), preferredMIMEType.createCFString().get(), (__bridge CFStringRef)UTTypeTIFF.identifier); data)
    4737             view->_page->replaceWithPasteboardData(elementContext, { String { type.get() } }, { static_cast<const uint8_t*>([data bytes]), [data length] });
     4737            view->_page->replaceImageWithMarkupResults(elementContext, { String { type.get() } }, { static_cast<const uint8_t*>([data bytes]), [data length] });
    47384738    }];
    47394739}
  • trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm

    r292800 r292898  
    350350            return;
    351351
    352         protectedPage->replaceWithPasteboardData(elementContext, { String(type.get()) }, IPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length]));
     352        protectedPage->replaceImageWithMarkupResults(elementContext, { String(type.get()) }, IPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length]));
    353353    });
    354354#endif // ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm

    r292587 r292898  
    567567};
    568568
    569 void WebPage::replaceWithPasteboardData(const ElementContext& elementContext, const Vector<String>& types, const IPC::DataReference& data)
     569void WebPage::replaceImageWithMarkupResults(const ElementContext& elementContext, const Vector<String>& types, const IPC::DataReference& data)
    570570{
    571571    Ref frame = CheckedRef(m_page->focusController())->focusedOrMainFrame();
     
    595595        OverridePasteboardForSelectionReplacement overridePasteboard { types, data };
    596596        IgnoreSelectionChangeForScope ignoreSelectionChanges { frame.get() };
    597         frame->editor().replaceNodeFromPasteboard(*element, replaceSelectionPasteboardName());
     597        frame->editor().replaceNodeFromPasteboard(*element, replaceSelectionPasteboardName(), EditAction::MarkupImage);
    598598    }
    599599
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r292800 r292898  
    978978
    979979#if PLATFORM(COCOA)
    980     void replaceWithPasteboardData(const WebCore::ElementContext&, const Vector<String>& types, const IPC::DataReference&);
     980    void replaceImageWithMarkupResults(const WebCore::ElementContext&, const Vector<String>& types, const IPC::DataReference&);
    981981    void replaceSelectionWithPasteboardData(const Vector<String>& types, const IPC::DataReference&);
    982982#endif
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r292800 r292898  
    471471    GetDataSelectionForPasteboard(String pasteboardType) -> (WebKit::SharedMemory::IPCHandle ipcHandle) Synchronous
    472472    ReadSelectionFromPasteboard(String pasteboardName) -> (bool result) Synchronous
    473     ReplaceWithPasteboardData(struct WebCore::ElementContext context, Vector<String> types, IPC::DataReference data)
     473    ReplaceImageWithMarkupResults(struct WebCore::ElementContext context, Vector<String> types, IPC::DataReference data)
    474474    ReplaceSelectionWithPasteboardData(Vector<String> types, IPC::DataReference data)
    475475
  • trunk/Tools/ChangeLog

    r292894 r292898  
     12022-04-14  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Undo option after invoking "Markup Image" says "Undo Paste"
     4        https://bugs.webkit.org/show_bug.cgi?id=239351
     5        rdar://91647863
     6
     7        Reviewed by Darin Adler.
     8
     9        Augment an existing API test to verify that the resulting undo action title after invoking "Markup Image" is not
     10        "Undo Paste".
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:
     13        (TestWebKitAPI::TEST):
     14
    1152022-04-14  Robert Jenner  <Jenner@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm

    r292259 r292898  
    342342        return [[webView objectByEvaluatingJavaScript:@"document.images[0].getBoundingClientRect().width"] intValue] == 215;
    343343    }, 3, @"Expected bounding client rect to become 215.");
     344
     345    NSString *undoTitle = [webView undoManager].undoMenuItemTitle;
     346    EXPECT_GT(undoTitle.length, 0U);
     347    EXPECT_FALSE([undoTitle containsString:@"Paste"]);
    344348}
    345349
Note: See TracChangeset for help on using the changeset viewer.