Bug 203944 - 'Strikethrough' editing command reported as 'formatUnderline'
Summary: 'Strikethrough' editing command reported as 'formatUnderline'
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 203992
  Show dependency treegraph
 
Reported: 2019-11-07 00:46 PST by Milan Crha
Modified: 2019-11-08 01:12 PST (History)
7 users (show)

See Also:


Attachments
Patch (5.82 KB, patch)
2019-11-07 02:57 PST, Carlos Garcia Campos
aperez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Crha 2019-11-07 00:46:36 PST
Calling:

webkit_web_view_execute_editing_command (web_view, "Strikethrough");

is reported as "formatUnderline" in document.oninput() callback.

Semi-steps:
a) open web inspector and switch to the Console
b) run there this:

   document.oninput = function(op) { console.log("oninput:'" + op.inputType + "'"); }

c) run:

   webkit_web_view_execute_editing_command (web_view, "Strikethrough");

   from the C code.

Actual result:

   The console prints:

      oninput:'formatUnderline'

   even the HTML does strikethrough.

Expected:

   The inputType should be "formatStrikethrough" or similar, definitely not "formatUnderline".

There are several other editing commands, which identify itself with empty string. Maybe most of them are custom WebKit commands, but it does so also for standard commands, like when I execute this on Console:

   document.execCommand("strikethrough", false, "")

the printed output on it is:

   oninput:''

Having properly identified events helps for correct undo/redo implementation, among other things.
Comment 1 Carlos Garcia Campos 2019-11-07 01:56:39 PST
This is not GTK specific.

static bool executeStrikethrough(Frame& frame, Event*, EditorCommandSource source, const String&)
{
    Ref<EditingStyle> style = EditingStyle::create();
    style->setStrikeThroughChange(textDecorationChangeForToggling(frame.editor(), CSSPropertyWebkitTextDecorationsInEffect, "line-through"_s));
    // FIXME: Needs a new EditAction!                                                                                                                                                         
    return applyCommandToFrame(frame, source, EditAction::Underline, WTFMove(style));
}

Regarding others identified as empty string is probably because they are not listed in:

https://w3c.github.io/input-events/#interface-InputEvent-Attributes
Comment 2 Milan Crha 2019-11-07 02:05:11 PST
(In reply to Carlos Garcia Campos from comment #1)
> Regarding others identified as empty string is probably because they are not
> listed in:
> 
> https://w3c.github.io/input-events/#interface-InputEvent-Attributes

Aha, nice. Should I try to identify those which are listed in the above URL and WebKitGTK+ reports empty string in the oninput() event?

By the way, I tried the above JavaScipt commands in Firefox (67.0) and calling document.execCommand() did not trigger the oninput event handler. For me, WebKit(GTK+) works better than Firefox in this regard (because I rely on these events heavily).
Comment 3 Carlos Garcia Campos 2019-11-07 02:57:20 PST
Created attachment 383032 [details]
Patch
Comment 4 Adrian Perez 2019-11-07 05:50:37 PST
Comment on attachment 383032 [details]
Patch

Patch looks good to me. While I don't expect any issue with the changes
because they build and complete upon existing code without essentially
changing how things work, let's anyway wait a day or two before landing
it in case somebody else may have feedback :-)
Comment 5 Milan Crha 2019-11-08 00:28:03 PST
(In reply to Milan Crha from comment #2)
> Should I try to identify those which are listed in the above URL
> and WebKitGTK+ reports empty string in the oninput() event?

I went ahead and opened bug #203992 for the other events.
Comment 6 Carlos Garcia Campos 2019-11-08 01:09:42 PST
Committed r252233: <https://trac.webkit.org/changeset/252233>
Comment 7 Radar WebKit Bug Importer 2019-11-08 01:12:29 PST
<rdar://problem/57014779>