Commit Graph

124 Commits

Author SHA1 Message Date
Masayuki Nakano
22aa786ab3 Bug 1753508 - Add logger of selection batch r=smaug
This was required for debugging the bug.

Differential Revision: https://phabricator.services.mozilla.com/D139350
2022-03-11 02:24:24 +00:00
Masayuki Nakano
a8c2bbc3f0 Bug 1191862 - part 1: Make nsIWidget::NativeKeyBindingsType independent from nsIWidget and defined in an independent header file r=smaug
I'd like to use it in `IMEData.h`.  However, adding new include into it may
cause bustage with MinGW, and it's included by `nsIWidget.h` because `nsIWidget`
requires some classes defined in `IMEData.h`.  Therefore, I'd like to make a
new header file for avoiding the include hell.

Differential Revision: https://phabricator.services.mozilla.com/D138007
2022-02-15 08:00:05 +00:00
Masayuki Nakano
1ebfc35bf2 Bug 1743346 - Make TextInputHandler::HandleEvent handle native key bindings first, then, our shortcut keys r=smaug
Oddly, `TextInputHandler` which is keyboard event handler for
`<input type="text">` and `<textarea>` handles our shortcut keys
first, then, refer native key bindings.  So if a key combination
matches in both definitions, our shortcut key wins.

On the other hand, if `HTMLEditor` has focus, `keypress` event
listener on the `Document` node hanldes native key bindings:
https://searchfox.org/mozilla-central/rev/70b32246fce5ca1f53af573a21c1939df58cb969/editor/libeditor/EditorEventListener.cpp#641-644

Then, global key listener will be run later:
https://searchfox.org/mozilla-central/rev/70b32246fce5ca1f53af573a21c1939df58cb969/dom/events/GlobalKeyListener.cpp#163-164

Perhaps, it's better to refer native key bindings first because
unusual shortcut key definition must be caused by customization
by the user in the system level.

Therefore, this patch makes the order switchable with the new
pref for making it easier to back it out.

Differential Revision: https://phabricator.services.mozilla.com/D132451
2021-12-03 11:57:29 +00:00
Masayuki Nakano
2ae66680b2 Bug 1735745 - Make SelectionChangeEventDispatcher dispatch select event and selectchange event only when there may be corresponding event listeners r=smaug
`select` event on text controls now dispatched immediately before
`selectionchange`.  However, it needs to create `AsyncEventDispatcher` for
each.  This cost may not be expensive, but they are called really a lot even
if there is no corresponding event listener.

Therefore, this patch makes `nsPIDOMWindow` and `EventListenerManager` have
`MayHave*EventListeners` flag separately for each, and makes
`SelectionChangeEventDispatcher` does not try to do create
`AsyncEventDispatcher` when there is no corresponding event listener.

Differential Revision: https://phabricator.services.mozilla.com/D131750
2021-11-25 07:09:23 +00:00
Edgar Chen
92a1fc095f Bug 1556351 - Part 3: Rename nsGenericHTMLFormElementWithState to nsGenericHTMLFormControlElementWithState; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D124786
2021-10-04 20:51:26 +00:00
Edgar Chen
cd1f327b86 Bug 1729358 - Part 1: Move FocusState to TextControlElement; r=smaug
And convert FocusTristate to enum class.

Differential Revision: https://phabricator.services.mozilla.com/D124693
2021-09-07 09:47:09 +00:00
Kagami Sascha Rosylight
bda51c1d58 Bug 1648944 - Part 2: Fire selectionchange at document from text controls r=masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D86701
2021-07-20 13:46:44 +00:00
Kagami Sascha Rosylight
c13d219483 Bug 1648944 - Part 1: Split select event flags into each event name r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D86700
2021-07-20 13:46:44 +00:00
Brindusan Cristian
0c4fbf4b49 Backed out 5 changesets (bug 1648944) for causing wpt failures in idlharness.window.html.
CLOSED TREE

Backed out changeset 598789cabb9f (bug 1648944)
Backed out changeset f464507bef57 (bug 1648944)
Backed out changeset fb2b9ceb7c69 (bug 1648944)
Backed out changeset a73cfada74cf (bug 1648944)
Backed out changeset 3f41877ffd14 (bug 1648944)
2021-07-20 13:29:49 +03:00
Kagami Sascha Rosylight
3dc848256c Bug 1648944 - Part 2: Fire selectionchange at document from text controls r=masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D86701
2021-07-20 08:59:47 +00:00
Kagami Sascha Rosylight
dff494f1a7 Bug 1648944 - Part 1: Split select event flags into each event name r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D86700
2021-07-20 08:59:47 +00:00
Masayuki Nakano
2eac55a01e Bug 1676702 - part 3: Make TextControlState store unmasked range while it does not have TextEditor r=m_kato
`TextControlState` is alive during reframing, but `TextEditor` is not so.
Therefore, `TextControlState` should take the `PasswordMaskData` before
`TextEditor` is destroyed.  And if `TextEditor` is recreated, and the value
hasn't been modified, unmasked range should be restored in the new editor.

Depends on D118757

Differential Revision: https://phabricator.services.mozilla.com/D118758
2021-06-28 04:37:54 +00:00
Masayuki Nakano
b224f9cb5b Bug 1676702 - part 2: Make TextControlState initialize TextEditor with PasswordMaskData r=m_kato
During a `TextControlState` alive, `PasswordMaskData` should be alive too.
Otherwise, we cannot keep unmasked range at reframing.

Depends on D118756

Differential Revision: https://phabricator.services.mozilla.com/D118757
2021-06-28 04:37:54 +00:00
Masayuki Nakano
569104c02d Bug 1717156 - part 6: Get rid of nsIEditor::eEditorDontEchoPassword r=m_kato
It's used only by password field, i.e., only by `TextEditor`, and used
temporarily.  Additionally, there is some space in `TextEditor`.  So, we
can get rid of it, and make `TextEditor` store it directly.

Note that this allows to skip expensive `nsIEditor::SetFlags()` calls by
`AutoRestoreEditorState`.  This may improve setting `<input>.value` performance.

Differential Revision: https://phabricator.services.mozilla.com/D118266
2021-06-22 00:18:08 +00:00
Masayuki Nakano
d6c4790121 Bug 1717156 - part 2: Get rid of nsIEditor::eEditorWidgetMask and its accessor r=m_kato
With the previous patch, we know `nsIEditor::eEditorWidgetMask` always
matches with `EditorBase::IsTextEditor()`.  And it's not referred from JS
(including comm-central and BlueGriffon).  So, we can get rid of it.

Differential Revision: https://phabricator.services.mozilla.com/D118262
2021-06-22 00:18:06 +00:00
Kagami Sascha Rosylight
7fe1ff4e91 Bug 1677253 - Part 1: Fire select event from SelectionChangeEventDispatcher r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D101245
2021-06-21 00:58:35 +00:00
Ryan VanderMeulen
4c53d4eb06 Backed out 3 changesets (bug 1677253) because it depends on bug 1713334 which was backed out.
Backed out changeset 3d30a54409a7 (bug 1677253)
Backed out changeset 1c385b21e0e5 (bug 1677253)
Backed out changeset eb6001404a57 (bug 1677253)
2021-06-17 11:38:53 -04:00
Kagami Sascha Rosylight
362dd7af5e Bug 1677253 - Part 1: Fire select event from SelectionChangeEventDispatcher r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D101245
2021-06-16 11:13:14 +00:00
Kartikaya Gupta
7c375a1189 Bug 1694847 - Remove the expired SCROLL_INPUT_METHODS telemetry probe. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D116320
2021-05-31 21:36:35 +00:00
Masayuki Nakano
9566ff5659 Bug 1540037 - part 18: Move ReplaceTextAsAction() and ReplaceSelectionAsSubAction() to EditorBase r=m_kato
They are used by setting text value of `TextEditor` or replacing a misspelled
word with a new word in both `TextEditor` and `HTMLEditor`.  Therefore,
they should be in the `EditorBase` rather than `TextEditor`.

Note that the path of the former case may be in a hot path.  Therefore, we need
to keep redirecting to `TextEditor` for keeping the performance only in the
case.

Depends on D115785

Differential Revision: https://phabricator.services.mozilla.com/D115786
2021-05-25 04:26:14 +00:00
Kagami Sascha Rosylight
55be2e6e45 Bug 1712255 - Defer SetMaxLength in SetValueFromSetRangeText r=masayuki
Capping selection range in SetValue early makes the subsequent SetSelectionRange call unable to detect actual selection range change. This patch defers it so that select events can be consistently fired.

Differential Revision: https://phabricator.services.mozilla.com/D115729
2021-05-24 03:11:27 +00:00
Emilio Cobos Álvarez
e1e13fa181 Bug 1698315 - Manage placeholder and autofill preview visibility using CSS rather than custom code. r=masayuki
Should be much simpler and doesn't need to deal with the different
stuff. We already have pseudo-classes for this, :autofill and
:placeholder-shown.

I initially wrote this because this is the only limitation that forces
us to have the placeholder text as a direct child of the text control
frame. In the end I kept that as-is, but this simplification is still
worth it.

We remove dom.placeholder.show_on_focus because it doesn't behave
correctly (it doesn't match the :placeholder-shown pseudo-class and it
should). It was introduced in bug 807613 and never turned to false by
default. I suspect nobody will miss this, but if somebody complains
about it we can reintroduce it properly (handling the pref in DOM
instead, changing the right state bits).

Differential Revision: https://phabricator.services.mozilla.com/D108304
2021-03-15 08:52:43 +00:00
Chris Peterson
5ac4034b03 Bug 1691889 - Replace MOZ_MUST_USE with [[nodiscard]] in dom/. r=peterv
The MOZ_MUST_USE macro is defined as clang's and gcc's nonstandard __attribute__((warn_unused_result)). Now that we compile as C++17 by default (bug 1560664), we can replace MOZ_MUST_USE with C++17's standard [[nodiscard]] attribute.

The [[nodiscard]] attribute must precede a function declaration's declaration specifiers (like static, extern, inline, or virtual). The __attribute__((warn_unused_result)) attribute does not have this order restriction.

Differential Revision: https://phabricator.services.mozilla.com/D107355
2021-03-10 08:19:25 +00:00
Kagami Sascha Rosylight
7057dbdc56 Bug 1671768 - Part 4: Use MOZ_CAN_RUN_SCRIPT for Selection::RemoveAllRanges r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D103780
2021-02-03 21:52:48 +00:00
Masayuki Nakano
71edddfad2 Bug 1685491 - part 5: Move the code remapping arrow keys in vertical content to NativeKeyBindings r=smaug,jfkthame
Currently, this feature is implemented only on Linux and macOS (see also
bug 1077515 and bug 1301497), and the code is really similar each other.
Additionally, it always tries to query selection to check whether the caret is
in vertical content or not if arrow keys are pressed.  For avoiding a lot of
query, this patch makes `TextEventDispatcher` cache writing mode at every
selection change notification.  However, unfortunately, it's not available when
non-editable content has focus, but it should be out of scope of this bug since
it requires a lot of changes.

Anyway, with this patch, we can write a mochitest only on Linux and macOS.
The following patch adds a test for this as a fix of bug 1103374.

Differential Revision: https://phabricator.services.mozilla.com/D102881
2021-02-02 03:29:31 +00:00
Mirko Brodesser
3cef08a463 Bug 1685303: part 10) Annotate nsFrameSelection::HandleClick with MOZ_CAN_RUN_SCRIPT. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D101598
2021-01-14 13:24:36 +00:00
Bogdan Tara
1bdc209f41 Backed out 4 changesets (bug 1685303) for bustage complaining about offsets CLOSED TREE
Backed out changeset a4640aac6619 (bug 1685303)
Backed out changeset bd2020c26531 (bug 1685303)
Backed out changeset 3f2e96b93f19 (bug 1685303)
Backed out changeset 8cf49a7677c9 (bug 1685303)
2021-01-14 12:58:25 +02:00
Mirko Brodesser
1454bdc35c Bug 1685303: part 10) Annotate nsFrameSelection::HandleClick with MOZ_CAN_RUN_SCRIPT. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D101598
2021-01-14 10:21:17 +00:00
Razvan Maries
84efa2f4e4 Backed out 3 changesets (bug 1677253) for multiple perma failures. CLOSED TREE
Backed out changeset 01b34d4be08c (bug 1677253)
Backed out changeset aabba45e0b43 (bug 1677253)
Backed out changeset 171689d8d386 (bug 1677253)
2021-01-12 17:18:04 +02:00
Kagami Sascha Rosylight
050205a165 Bug 1677253 - Part 1: Fire select event from SelectionChangeEventDispatcher r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D101245
2021-01-12 08:59:34 +00:00
Emilio Cobos Álvarez
94e15755b4 Bug 1685153 - Null check mBoundFrame before scrolling to it. r=masayuki
SetSelectionRange may kill the frame (in the test-case, AccessibleCaret
flushes layout).

No crashtest as there doesn't seem to be one available.

Differential Revision: https://phabricator.services.mozilla.com/D101253
2021-01-11 23:25:04 +00:00
Kagami Sascha Rosylight
5230936eed Bug 1682706 - Use SelectionBatcher in SetRangeText r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D100705
2021-01-04 23:29:36 +00:00
Kagami Sascha Rosylight
53c124fe30 Bug 1675894 - Fire selectionchange from disconnected text controls r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D98810
2020-12-05 12:50:04 +00:00
Kagami Sascha Rosylight
d8b52acc32 Bug 1682313 - Make sure mMaxLength exists in SetSelectionRange r=masayuki
Cloning a textarea element without a dirty value flag does not call SetValue() and thus gets no max length. This makes sure it always gets one before setting selection range.

Differential Revision: https://phabricator.services.mozilla.com/D99734
2020-12-15 02:06:38 +00:00
Kagami Sascha Rosylight
da8621865a Bug 1680951 - Do not scroll when calling select() r=masayuki
This is intended to be a hotfix for the URL bar regression. Ideally there should be a spec or this behavior should be removed completely.

Previously select() scrolled back to the start position before the regression, but this fix does not restore that behavior.

Differential Revision: https://phabricator.services.mozilla.com/D98972
2020-12-09 20:59:17 +00:00
Kagami Sascha Rosylight
816778fec7 Bug 1681615 - Detect selection changes through the setters r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D99291
2020-12-10 12:58:04 +00:00
Masayuki Nakano
fbba4fb0ed Bug 1681240 - Make TextControlState::SetValueFlags an enum class r=saschanaz
Using integer as a bit field may cause simple mistake and may not be easy
to read, and we have `EnumSet` class which can treat an `enum class` as
a bit flags so that we should make it an `enum class` and use it with the
`EnumSet` class.

Differential Revision: https://phabricator.services.mozilla.com/D99172
2020-12-09 23:34:28 +00:00
Butkovits Atila
45bf9cbd18 Backed out changeset 29bbd5887d66 (bug 1680951) for failure on browser_blockingCookies.js. CLOSED TREE 2020-12-08 14:46:48 +02:00
Kagami Sascha Rosylight
79eb1ce2c7 Bug 1680951 - Do not scroll when calling select() r=masayuki
This is intended to be a hotfix for the URL bar regression. Ideally there should be a spec or this behavior should be removed completely.

Previously select() scrolled back to the start position before the regression, but this fix does not restore that behavior.

Differential Revision: https://phabricator.services.mozilla.com/D98972
2020-12-08 07:52:07 +00:00
Bogdan Tara
1981b0d0f7 Backed out changeset 18c139fe8859 (bug 1675894) for selectionchange.tentative.html failures CLOSED TREE 2020-12-05 14:45:37 +02:00
Kagami Sascha Rosylight
f8cb249c67 Bug 1680548 - Cache the max length in TextControlState::SelectionProperties r=masayuki
GetValue() is not a cheap operation, and this allows to skip it in SetSelectionRange.

Differential Revision: https://phabricator.services.mozilla.com/D98659
2020-12-05 09:34:59 +00:00
Bogdan Tara
12c0cd7a20 Backed out changeset b9fa2c214287 (bug 1680548) for multiple mochitest failures 2020-12-05 10:52:56 +02:00
Kagami Sascha Rosylight
ff3887e067 Bug 1680798 - Assign forward selection in Select() before bug 1541454 r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D98823
2020-12-05 07:47:50 +00:00
Kagami Sascha Rosylight
24c18c473d Bug 1675894 - Fire selectionchange from disconnected text controls r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D98810
2020-12-05 07:50:41 +00:00
Kagami Sascha Rosylight
07a9844db6 Bug 1680548 - Cache the max length in TextControlState::SelectionProperties r=masayuki
GetValue() is not a cheap operation, and this allows to skip it in SetSelectionRange.

Differential Revision: https://phabricator.services.mozilla.com/D98659
2020-12-05 07:34:41 +00:00
Mihai Alexandru Michis
fcd894ffe5 Backed out changeset 651187869807 (bug 1680548) for causing valgrid bustages in nsTextControlFrame. 2020-12-05 03:15:59 +02:00
Kagami Sascha Rosylight
88e3ed35eb Bug 1680548 - Cache the max length in TextControlState::SelectionProperties r=masayuki
GetValue() is not a cheap operation, and this allows to skip it in SetSelectionRange.

Differential Revision: https://phabricator.services.mozilla.com/D98659
2020-12-04 22:19:33 +00:00
Kagami Sascha Rosylight
3816a65f30 Bug 1679460 - Call Get/SetSelectionRange even when cached r=masayuki
No need to special case here as both already use cached selection. This makes it consistent with SetSelectionStart etc.

Differential Revision: https://phabricator.services.mozilla.com/D98185
2020-12-02 19:26:49 +00:00
Bogdan Tara
9ef9c44401 Backed out 3 changesets (bug 1677263, bug 1679460, bug 1679461) for test_focus.xhtml failures CLOSED TREE
Backed out changeset 03db12dabc63 (bug 1677263)
Backed out changeset 75de13448090 (bug 1679460)
Backed out changeset 4f4fd8e7ce93 (bug 1679461)
2020-12-02 21:16:28 +02:00
Kagami Sascha Rosylight
b797dc2dbc Bug 1679460 - Call Get/SetSelectionRange even when cached r=masayuki
No need to special case here as both already use cached selection. This makes it consistent with SetSelectionStart etc.

Differential Revision: https://phabricator.services.mozilla.com/D98185
2020-12-02 02:21:13 +00:00