[Input Events] Implement InputEvent.data and InputEvent.dataTransfer
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox67 | --- | fixed |
People
(Reporter: crimsteam, Assigned: masayuki)
References
()
Details
(Keywords: dev-doc-complete)
Attachments
(12 files)
59 bytes,
text/x-review-board-request
|
Details | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
Bug 998941 - part 1-5: Make HTMLEditor set InputEvent.data when InputEvent.inputType is "insertLink"
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
Assignee | ||
Comment 2•11 years ago
|
||
Updated•11 years ago
|
Updated•10 years ago
|
Comment 3•10 years ago
|
||
Comment 4•10 years ago
|
||
Comment 5•8 years ago
|
||
Assignee | ||
Comment 6•8 years ago
|
||
Comment hidden (mozreview-request) |
Assignee | ||
Comment 8•8 years ago
|
||
mozreview-review |
Assignee | ||
Comment 9•8 years ago
|
||
Updated•8 years ago
|
Comment 10•8 years ago
|
||
mozreview-review |
Comment 11•8 years ago
|
||
Comment hidden (mozreview-request) |
Comment 13•8 years ago
|
||
mozreview-review |
Comment 14•8 years ago
|
||
Comment 15•8 years ago
|
||
Assignee | ||
Comment 16•8 years ago
|
||
mozreview-review-reply |
Updated•8 years ago
|
Assignee | ||
Updated•8 years ago
|
Assignee | ||
Updated•7 years ago
|
Assignee | ||
Updated•7 years ago
|
Updated•7 years ago
|
Comment 17•7 years ago
|
||
Assignee | ||
Comment 18•7 years ago
|
||
Comment 19•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Assignee | ||
Comment 20•7 years ago
|
||
Assignee | ||
Comment 21•7 years ago
|
||
Oh, neither Chrome nor Safari sets InputEvent.data when InputEvent.inputType is "formatBackColor", "formatFontColor" or "formatFontName". I think that we don't need to support them here because they are available only with execCommand
and their data
value is really complicated.
Assignee | ||
Comment 22•7 years ago
|
||
Assignee | ||
Comment 23•7 years ago
|
||
Assignee | ||
Comment 24•7 years ago
|
||
smaug:
I have a question. I want to add a member to RefPtr<DataTransfer>
to InternalEditorInputEvent
for InputEvent.dataTransfer
. However, with the new member, (new AsyncEventDispatcher(aEventTargetElement, inputEvent))->RunDOMEventWhenSafe()
in nsContentUtils::DispatchInputEvent()
claims that Hit MOZ_CRASH(DataTransfer not thread-safe) at m:/src/xpcom/base/nsISupportsImpl.cpp:40
. However, in my understanding, AsyncEventDispatcher
runs in created thread, i.e., won't run in another thread. So, I guess that the MOZ_ASSERT is caused by using Runnable
. Is this intentional? If so, do you have ideas to avoid this issue?
Assignee | ||
Comment 25•7 years ago
|
||
(Well, if we cannot resolve this issue simply, I think that it's enough to set InputEvent.dataTransfer only when nsContentUtils::IsSafeToRunScript() returns true and dispatch it synchronously without AsyncEventDispatcher. Perhaps, InputEvent.dataTransfer won't be used by any web apps when "input" event is caused by script, e.g., document.execCommand("paste") is called by an event listener.)
Comment 26•7 years ago
|
||
I think I don't have enough information. Sure AsyncEventDispatcher is single thread only, since it deals with events and eventtargets which are single thread objects.
The issue is somewhere else.
What is the stack trace when you get the assert and what kind of patch you have?
Assignee | ||
Comment 27•7 years ago
|
||
Okay, I'll post it tomorrow morning because I need to build debug build without any optimization because optimization hides actual crash point.
Assignee | ||
Comment 28•7 years ago
|
||
Ah, really sorry. This must be my patch's bug. Probably, I set uninitialized raw pointer to the new member. I'll check it tomorrow.
Assignee | ||
Comment 29•7 years ago
|
||
Assignee | ||
Comment 30•7 years ago
|
||
Assignee | ||
Comment 31•7 years ago
|
||
Assignee | ||
Comment 32•7 years ago
|
||
Assignee | ||
Comment 33•7 years ago
|
||
According to a Safari developer, Safari on macOS may set data
value to color when inputType is formatBackColor
or formatFontColor
. However, they don't set it when execCommand()
causes an input
event. So, that we're still not sure that whether we should compute rgb()
or rgba()
style value with parsing given value or not. If we need to do it, looks like that the parser is written only by Rust. I'm not sure it's available from C++ code though. Anyway, I don't want to do complicated things... So, we should keep setting data
to null in these cases.
On the other hand, in the cause of formatFontName
, perhaps, it's okay to set given value as-is because web apps can set it directly to Element.style.fontFamily. So, just setting raw value must be enough.
Assignee | ||
Comment 34•7 years ago
|
||
Comment 35•7 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (JST, +0900) from comment #33)
According to a Safari developer, Safari on macOS may set
data
value to color when inputType isformatBackColor
orformatFontColor
. However, they don't set it whenexecCommand()
causes aninput
event. So, that we're still not sure that whether we should computergb()
orrgba()
style value with parsing given value or not. If we need to do it, looks like that the parser is written only by Rust. I'm not sure it's available from C++ code though. Anyway, I don't want to do complicated things... So, we should keep settingdata
to null in these cases.
I'm sure Emilio or someone else on layout team would be very happy to write a patch to call the rust code to parse a color if you decide you need to.
Assignee | ||
Comment 36•7 years ago
|
||
Comment 37•7 years ago
|
||
(In reply to Brian Birtles (:birtles, away Feb 8, 11, 18) from comment #35)
I'm sure Emilio or someone else on layout team would be very happy to write a patch to call the rust code to parse a color if you decide you need to.
Is the existing ServoCSSParser::ComputeColor enough?
Assignee | ||
Comment 38•7 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #37)
(In reply to Brian Birtles (:birtles, away Feb 8, 11, 18) from comment #35)
I'm sure Emilio or someone else on layout team would be very happy to write a patch to call the rust code to parse a color if you decide you need to.
Is the existing ServoCSSParser::ComputeColor enough?
Oh, looks like it's enough (according to the comment in the header).
Is there a method to create serialized computed value from nscolor value? If so, I'm really happy!
Comment 39•7 years ago
|
||
Should be able to move the string-creation part of:
To nsStyleUtil
or something, and use that.
Assignee | ||
Comment 40•7 years ago
|
||
Thank you very much!!
Assignee | ||
Comment 41•7 years ago
|
||
Assignee | ||
Comment 42•7 years ago
|
||
Assignee | ||
Comment 43•7 years ago
|
||
Assignee | ||
Comment 44•7 years ago
|
||
InputEvent.data notifies web apps of inserting/inserted text with "beforeinput"
and "input" events. So, this is important especially for "beforeinput" event
listeners. That's the reason why we need to support this before implementing
"beforeinput" event.
This patch adds it into InputEvent and make it enabled by default.
Assignee | ||
Comment 45•7 years ago
|
||
This patch makes nsContentUtils::DispatchInputEvent() support to set
InputEvent.data. Whether the its value should be null or DOMString depends
on InputEvent.inputType value.
- https://rawgit.com/w3c/input-events/v1/index.html#overview
- https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
- https://w3c.github.io/input-events/#overview
- https://w3c.github.io/input-events/#dfn-data
According to the draft specs, InputEvent.data should be always inserting text
when inputType is "insertText" or "insertCompositionText" (or
"insertFromCompoition" if Level 2 support is enabled).
Assignee | ||
Comment 46•7 years ago
|
||
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data
Both Input Events Level 1 and Level 2 declare that InputEvent.data should be
set to inserting string only on TextEditor when InputEvent.inputType is
"insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop",
"insertTranspose", "insertReplacementText" or "insertFromYank".
Currently, we support only "insertFromPaste", "insertFromDrop",
"insertReplacementText". Therefore, this patch makes TextEditor set
EditorBase::mEditActionData::mData only for them (and the instance is not
HTMLEditor's).
Assignee | ||
Comment 47•7 years ago
|
||
When InputEvent.inputType is "formatSetBlockTextDirection" or
"formatSetInlineTextDirection", InputEvent.data value should be one of
"ltr", "rtl", "auto" or "null".
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data
We only supports "ltr" and "rtl" when user switches the direction with
Accel + Shift + X. Therefore this patch makes EditorBase set the data
to "ltr" or "rtl".
Oddly, with synthesizing the shortcut keys, the command is not executed
properly in the automated test. Therefore, this patch dispatches the
command directly.
Assignee | ||
Comment 48•7 years ago
|
||
Although neither Chrome nor Safari does not set InputEvent.data value when
InputEvent.inputType is "insertLink", but it's easy to implement. Therefore,
this patch implements it as declaration of Input Events.
This patch sets the value to raw href attribute value because we create
<a> element without absolute URI when web apps call execCommand("createLink")
with relative URI.
Assignee | ||
Comment 49•7 years ago
|
||
Although neither Chrome nor Safari does not set InputEvent.data value when
InputEvent.inputType is "fontName", but it's easy to implement. Therefore, this
patch implements it as declaration of Input Events.
This patch uses given value as-is. Perhaps, this shouldn't cause any problems
because such value can be set to Element.style.fontFamily without any changes.
Note that automated test will be added into WPT later.
Assignee | ||
Comment 50•7 years ago
|
||
Although neither Chrome nor Safari does not set InputEvent.data when the event
is caused by document.execCommand()
with backColor
, foreColor
nor
hiliteColor
, Safari supports styling color with touchbar and in that case,
Safari sets it (*1).
Additionally, currently Safari uses rgb()
to represents a color value and
using same rule to serializing color value for CSS OM matches Safari's behavior
and can represent any valid color values.
This patch makes given color value parsed and then serialized with same code
in style system. If the value is currentColor
or invalid value, sets given
value as-is for forward compatibility.
Note that automated tests will be added into input-events-exec-command.html
by the last patch.
Assignee | ||
Comment 51•7 years ago
|
||
InputEvent.dataTransfer is declared by Input Events Level 1 and Level 2 (i.e.,
not UI Events). It's necessary for "beforeinput" event on contenteditable
elements because of with some InputEvent.inputType values on contenteditable,
InputEvent.dataTransfer is used instead of InputEvent.data.
According to the Chrome's behavior, if InputEvent.dataTransfer is created by
web apps, the DataTransfer object is mutable. Otherwise, i.e., the event
represents user input, the DataTransfer object is read only. We should follow
this behavior.
This is enabled by default.
Assignee | ||
Comment 52•7 years ago
|
||
InputEvent.dataTransfer should be set to non-null when InputEvent.inputType
is "insertFromPaste", "insertFromDrop" or "insertReplacementText" and
editor is an HTMLEditor instance:
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data
("insertTranspose" and "insertFromYank" are not currently supported on Gecko.)
This patch makes nsContentUtils::DispatchInputEvent() take dataTransfer value
and EditorBase set it via AutoEditActionDataSetter like data value.
However, we need to create other constructors of DataTransfer to create its
read-only instances initialized with nsITransferable or nsAString. This will
be implemented by the following patch.
Assignee | ||
Comment 53•7 years ago
|
||
DataTransfer should have more 2 constructors. One takes |const nsAString&| and
sets its data to the string. The other takes |nsITransferable*| and stores it
in its member for filling each data of DataTransferItem when it's retrieved.
Assignee | ||
Comment 54•7 years ago
|
||
Comment 55•6 years ago
|
||
Ah, I found https://github.com/w3c/uievents/issues/139, that clarifies "" vs null.
Assignee | ||
Comment 56•6 years ago
|
||
(In reply to Olli Pettay [:smaug] (massive needinfo queue, ping on IRC on anything urgent) from comment #55)
Ah, I found https://github.com/w3c/uievents/issues/139, that clarifies "" vs null.
Yeah, sorry, I forgot to mention it with comment.
Comment 58•6 years ago
|
||
Updated•6 years ago
|
Comment 61•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/7773539f3fdc
https://hg.mozilla.org/mozilla-central/rev/7eae0724c0aa
https://hg.mozilla.org/mozilla-central/rev/ebd32851bb24
https://hg.mozilla.org/mozilla-central/rev/cfd766ac9963
https://hg.mozilla.org/mozilla-central/rev/d392cc639292
https://hg.mozilla.org/mozilla-central/rev/f4039b1e1fb6
https://hg.mozilla.org/mozilla-central/rev/ef76c4985c1a
https://hg.mozilla.org/mozilla-central/rev/5b4aa09a20df
https://hg.mozilla.org/mozilla-central/rev/b259d7a34058
https://hg.mozilla.org/mozilla-central/rev/14aa08270157
https://hg.mozilla.org/mozilla-central/rev/e726a088a06c
Comment 62•6 years ago
|
||
I see in the commits that this is enabled by default:
+// Whether InputEvent.data is enabled.
+pref("dom.inputevent.data.enabled", true);
Yet comment #15 was saying that it should be behind a nightly flag and not ride the trains so as that we can evaluate the webcompat impact:
(In reply to Olli Pettay [:smaug] (PTO-ish Feb 16-23) from comment #15)
Masayuki requested to have it under a pref for a cycle, so enable in Nightly
only initially.
And pref has also the advantage that if the feature is breaking web sites,
it is easy switch it off with a hot fix.
Masayuki, can you clarify if this is meant to ship in 67? Thanks
Assignee | ||
Comment 64•6 years ago
|
||
(In reply to Pascal Chevrel:pascalc from comment #62)
I see in the commits that this is enabled by default:
+// Whether InputEvent.data is enabled. +pref("dom.inputevent.data.enabled", true);
Yet comment #15 was saying that it should be behind a nightly flag and not ride the trains so as that we can evaluate the webcompat impact:
(In reply to Olli Pettay [:smaug] (PTO-ish Feb 16-23) from comment #15)Masayuki requested to have it under a pref for a cycle, so enable in Nightly
only initially.
And pref has also the advantage that if the feature is breaking web sites,
it is easy switch it off with a hot fix.Masayuki, can you clarify if this is meant to ship in 67? Thanks
Yes, I currently plan to ship it at 67 because we're following the other browsers right now. Those new attributes are really important when we ship beforeinput
and we need to ship the new event as soon as possible. On the other hand, if some major web apps used these new attributes for feature detection, we'd stop shipping the release at least at 67.
Comment 65•6 years ago
|
||
For documentation purposes:
We need to remove the note from the first example on KeyboardEvent.key
that explains the errors in Firefox because we don't have the data
property, as well as update BCD.
Updated•6 years ago
|
Comment 66•6 years ago
|
||
Further notes for MDN writers:
I've added a note about these additions to https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/67#APIs.
The BCD needs updating, and we also need to clean up the property pages a bit; add examples, etc.
Comment 67•6 years ago
|
||
OK, documentation done.
I've removed the bit about Firefox not supporting InputEvent.data from the KeyboardEvent.key page as sheppy details above.
I've added compat data to BCD:
https://github.com/mdn/browser-compat-data/pull/4065
I've also added a demo to the data and dataTransfer pages:
https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/dataTransfer
https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/data
Let me know if you think this needs anything else. Thanks!
Description
•