RESOLVED FIXED 191937
Make it possible to insert editable images with a gesture
https://bugs.webkit.org/show_bug.cgi?id=191937
Summary Make it possible to insert editable images with a gesture
Tim Horton
Reported 2018-11-24 01:30:07 PST
Make it possible to insert editable images with a gesture
Attachments
Patch (34.93 KB, patch)
2018-11-24 01:32 PST, Tim Horton
no flags
Patch (41.63 KB, patch)
2018-11-25 02:50 PST, Tim Horton
no flags
Patch (41.60 KB, patch)
2018-11-25 02:55 PST, Tim Horton
no flags
Tim Horton
Comment 1 2018-11-24 01:32:41 PST
Tim Horton
Comment 2 2018-11-24 01:51:48 PST
Comment on attachment 355557 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355557&action=review > Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm:657 > + case EditAction::ConvertToUnorderedList: return UI_STRING_KEY_INTERNAL("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name"); I didn't mean to change this one in this patch (if I did, I would have done them both)
Tim Horton
Comment 3 2018-11-24 01:56:32 PST
View in context: https://bugs.webkit.org/attachment.cgi?id=355557&action=review > Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm:657 > + case EditAction::ConvertToUnorderedList: return UI_STRING_KEY_INTERNAL("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name"); I didn't mean to change this one in this patch (if I did, I would have done them both)
Wenson Hsieh
Comment 4 2018-11-24 10:20:53 PST
Comment on attachment 355557 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355557&action=review > Source/WebCore/editing/VisibleSelection.cpp:34 > +#include "ShadowRoot.h" Nit - is this needed? > Source/WebKit/UIProcess/WebEditCommandProxy.cpp:-79 > - return String(); Was this change intended? >> Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm:657 >> + case EditAction::ConvertToUnorderedList: return UI_STRING_KEY_INTERNAL("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name"); > > I didn't mean to change this one in this patch (if I did, I would have done them both) Oops. I think I'll clean these four up in a separate patch (it looks like WebEditCommandProxy.cpp is also affected). > LayoutTests/editing/images/basic-editable-image-from-execCommand.html:11 > + window.getSelection().setBaseAndExtent(document.body, 0, document.body, 0); Nit - setPosition(document.body, 0) would be cleaner here.
Tim Horton
Comment 5 2018-11-24 18:45:34 PST
(In reply to Wenson Hsieh from comment #4) > Comment on attachment 355557 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=355557&action=review > > > Source/WebCore/editing/VisibleSelection.cpp:34 > > +#include "ShadowRoot.h" > > Nit - is this needed? I think whenever you see something like this in a patch that touches Sources*.txt, assume it's a unified sources build fix :P > > Source/WebKit/UIProcess/WebEditCommandProxy.cpp:-79 > > - return String(); > > Was this change intended? Definitely not. > >> Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm:657 > >> + case EditAction::ConvertToUnorderedList: return UI_STRING_KEY_INTERNAL("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name"); > > > > I didn't mean to change this one in this patch (if I did, I would have done them both) > > Oops. I think I'll clean these four up in a separate patch (it looks like > WebEditCommandProxy.cpp is also affected). Thank you! > > LayoutTests/editing/images/basic-editable-image-from-execCommand.html:11 > > + window.getSelection().setBaseAndExtent(document.body, 0, document.body, 0); > > Nit - setPosition(document.body, 0) would be cleaner here. Ooh, somehow I didn't know that was a thing (really the whole DOM selection API feels very oddly named/designed to me).
Wenson Hsieh
Comment 6 2018-11-24 19:41:14 PST
Comment on attachment 355557 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355557&action=review > Source/WebCore/editing/InsertEditableImageCommand.cpp:34 > +InsertEditableImageCommand::InsertEditableImageCommand(Document& document) One could imagine moving the selection to the pencil position and using ReplaceSelectionCommand with EditAction::InsertEditableImage as an alternative to introducing a new edit command. However, it seems like this may be followed up with more complex logic for inserting editable images, such as paragraph splitting, in which case we would eventually want to add a new edit command > Source/WebCore/editing/InsertEditableImageCommand.cpp:50 > + insertNodeAt(imgElement.copyRef(), endingSelection().start()); Nit - We can WTFMove(imgElement) here instead of creating a new Ref. > Source/WebCore/editing/InsertEditableImageCommand.cpp:51 > +} I think you also probably want to set the ending selection to either encompass the new image, or place it right after the new image? > Source/WebCore/editing/InsertEditableImageCommand.h:43 > + EditAction editingAction() const override { return EditAction::InsertEditableImage; } Nit - override => final? > LayoutTests/editing/images/basic-editable-image-from-execCommand.html:10 > +addEventListener("load", async () => { It might also be good to also test undo-redoing, and then check to see where the selection ends up.
Tim Horton
Comment 7 2018-11-24 20:40:07 PST
(In reply to Wenson Hsieh from comment #6) > Comment on attachment 355557 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=355557&action=review > > > Source/WebCore/editing/InsertEditableImageCommand.cpp:34 > > +InsertEditableImageCommand::InsertEditableImageCommand(Document& document) > > One could imagine moving the selection to the pencil position and using > ReplaceSelectionCommand with EditAction::InsertEditableImage as an > alternative to introducing a new edit command. > > However, it seems like this may be followed up with more complex logic for > inserting editable images, such as paragraph splitting, in which case we > would eventually want to add a new edit command Right, that's what I'm envisioning. We'll need to break out of blockquotes, containers, indentation, etc. But in a future patch - this is just setting us up for that. > > > Source/WebCore/editing/InsertEditableImageCommand.cpp:50 > > + insertNodeAt(imgElement.copyRef(), endingSelection().start()); > > Nit - We can WTFMove(imgElement) here instead of creating a new Ref. > > > Source/WebCore/editing/InsertEditableImageCommand.cpp:51 > > +} > > I think you also probably want to set the ending selection to either > encompass the new image, or place it right after the new image? Yeah, that's in the WebPageIOS code but I should move it here instead. > > Source/WebCore/editing/InsertEditableImageCommand.h:43 > > + EditAction editingAction() const override { return EditAction::InsertEditableImage; } > > Nit - override => final? > > > LayoutTests/editing/images/basic-editable-image-from-execCommand.html:10 > > +addEventListener("load", async () => { > > It might also be good to also test undo-redoing, and then check to see where > the selection ends up. Sure!
Tim Horton
Comment 8 2018-11-25 02:50:42 PST
Tim Horton
Comment 9 2018-11-25 02:55:11 PST
WebKit Commit Bot
Comment 10 2018-11-25 04:11:25 PST
Comment on attachment 355588 [details] Patch Clearing flags on attachment: 355588 Committed r238475: <https://trac.webkit.org/changeset/238475>
WebKit Commit Bot
Comment 11 2018-11-25 04:11:27 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 12 2018-11-25 04:12:33 PST
Note You need to log in before you can comment on or make changes to this bug.