Граф коммитов

206 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 994759243f Bug 1793694 - part 5: Move `EditorUtils::MaskString` to `TextEditor` r=m_kato
It's the only method which is used outside of the editor module.  Therefore,
we can stop exposing `EditorUtils.h` later.

Depends on D158634

Differential Revision: https://phabricator.services.mozilla.com/D158635
2022-10-12 02:44:19 +00:00
Masayuki Nakano bd1059c951 Bug 1791501 - Use `EditActionResult` as ok type of `mozilla::Result` r=m_kato
Any callers do not refer "ignored", "handled" and "cancel" state without
checking whether the method returns error or not.  Therefore, error state
can be (and should be) managed by `mozilla::Result`'s error state.

Perhaps, it should store a caret position later because deletion handlers
of `HTMLEditor` use it, but update `Selection` immediately.

Differential Revision: https://phabricator.services.mozilla.com/D158080
2022-09-28 07:21:37 +00:00
Masayuki Nakano 2f0ed118ae Bug 1789967 - part 2: Make `TextEditor` and `HTMLEditor` implement `EditorBase::CollapseSelectionToEndOfLastLeafNode` by themselves r=m_kato
It does different thing for `TextEditor` and `HTMLEditor`, and used almost
internally.  Therefore, it should be implemented in the sub classes and
we should name them better.

Differential Revision: https://phabricator.services.mozilla.com/D157407
2022-09-22 06:17:36 +00:00
Masayuki Nakano f1dd8bf3b5 Bug 1789967 - part 1: Make `TextEditor` and `HTMLEditor` implement `EditorBase::InitEditorContentAndSelection` by themselves r=m_kato
The method is enough simple, and uses bad cast from point of view of OOP.
Therefore, this patch make the sub classes implement the method only for each.

Differential Revision: https://phabricator.services.mozilla.com/D157406
2022-09-22 06:06:54 +00:00
Iulian Moraru 6af4d42518 Backed out changeset 555d2ca16477 (bug 1789967) as per dev request. CLOSED TREE 2022-09-21 06:48:30 +03:00
Masayuki Nakano f3ce7840c7 Bug 1789967 - part 1: Make `TextEditor` and `HTMLEditor` implement `EditorBase::InitEditorContentAndSelection` by themselves r=m_kato CLOSED TREE
The method is enough simple, and uses bad cast from point of view of OOP.
Therefore, this patch make the sub classes implement the method only for each.

Differential Revision: https://phabricator.services.mozilla.com/D157406
2022-09-21 00:20:26 +00:00
Iulian Moraru 52da19beca Backed out 2 changesets (bug 1789967) for causing wd failures on content_editable.py. CLOSED TREE
Backed out changeset f2f431ee78a3 (bug 1789967)
Backed out changeset edac234f1eba (bug 1789967)
2022-09-21 04:40:46 +03:00
Masayuki Nakano 7f5b2e7242 Bug 1789967 - part 2: Make `TextEditor` and `HTMLEditor` implement `EditorBase::CollapseSelectionToEndOfLastLeafNode` by themselves r=m_kato
It does different thing for `TextEditor` and `HTMLEditor`, and used almost
internally.  Therefore, it should be implemented in the sub classes and
we should name them better.

Differential Revision: https://phabricator.services.mozilla.com/D157407
2022-09-21 00:38:23 +00:00
Masayuki Nakano 7f5a748878 Bug 1789967 - part 1: Make `TextEditor` and `HTMLEditor` implement `EditorBase::InitEditorContentAndSelection` by themselves r=m_kato
The method is enough simple, and uses bad cast from point of view of OOP.
Therefore, this patch make the sub classes implement the method only for each.

Differential Revision: https://phabricator.services.mozilla.com/D157406
2022-09-21 00:20:26 +00:00
Masayuki Nakano dd554016e6 Bug 1770874 - part 8: Make `EditorBase::OnBlur` temporarily a virtual method r=m_kato
Similar to the previous patch, we should split the method into `TextEditor`
and `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D147144
2022-05-27 04:09:19 +00:00
Masayuki Nakano 353a53ded7 Bug 1770874 - part 7: Make `EditorBase::OnFocus` temporarily a virtual method r=m_kato
I'd like to split it for `TextEditor` and `HTMLEditor`.  `HTMLEditor` does not
require flushing the layout because it's required by `TextEditor` if and only if
a preceding `focus` event listener or the `Element.focus` caller reframes
`<input>` or `<textarea>` element (bug 1755104).  So this would fix bug 1760045.

Differential Revision: https://phabricator.services.mozilla.com/D147143
2022-05-27 04:09:19 +00:00
Masayuki Nakano f6c2fb109c Bug 1770874 - part 5: Move `EditorBase::ReinitializeSelection` into `TextEditor` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147141
2022-05-27 04:02:30 +00:00
Masayuki Nakano 1abcb1c46b Bug 1764866 - Add "mozilla/EditorForwards.h" r=m_kato
Headers in editor module has a lot of forward declarations for avoiding the
include hell and has a lot of helper template classes.

Forward declarations of template classes is really messy and I'd want to
avoid the duplication because it blocks changing template class.  Therefore,
centralizing forward declarations makes the headers cleaner and maintaining
template classes easier.  Therefore, this patch adds a new header file which
has only forward declarations and some aliases.

It'd be better to define `enum class`es in it like `EventForwards.h` for
reducing the dependencies between headers, but currently this does not do it
for making the new file simpler as far as possible.

Removing `EditActionListener.h` is because it's unused.

Removing `AutoTopLevelEditSubActionNotifier` is because it's renamed to
`AutoEditSubActionNotifier`.
https://hg.mozilla.org/mozilla-central/rev/6de55c5b5f8d5f92389d0d244d2bced1f979ade9

Differential Revision: https://phabricator.services.mozilla.com/D143817
2022-04-20 14:46:16 +00:00
Masayuki Nakano 78430c342b Bug 1734507 - Make `TextEditor` guarantee that ranges to delete are in the text node r=saschanaz
Our internal code can touch internal `Selection` object of `<input>` and
`<textarea>`, thus, selection ranges in them may be not in the text node.
Therefore, we should make `TextEditor` instance try to shrink the deleting
ranges into the text node first.

In a followup bug (perhaps, bug 1734846), we should split the deletion code into
`TextEditor` and `HTMLEditor` for making the code simpler and never regressed.

Differential Revision: https://phabricator.services.mozilla.com/D133181
2021-12-08 21:37:22 +00:00
Masayuki Nakano 153b43e7e2 Bug 1720809 - part 2: Make `insertLineBreak` command handler in `HTMLEditor` insert a linefeed character instead of `<br>` element in same condition as Blink/WebKit r=m_kato
Similar to the previous patch, this patch makes `insertLineBreak` command
handler of `HTMLEditor` may insert a linefeed character instead of `<br>`
element for compatibility with Blink/WebKit.

Note that for making same name rules as `insertParagraphSeparator` command
handlers, this patch renames
`HTMLEditor::InsertBRElementAtSelectionWithTransaction()` to
`InsertLineBreakAsSubAction()` and moves
`EditorBase::InsertLineBreakAsSubAction()` to `TextEditor` since it's
used only by `TextEditor` instance.

Depends on D124731

Differential Revision: https://phabricator.services.mozilla.com/D124732
2021-09-10 21:45:47 +00:00
Neil Deakin 4d1d84fe2f Bug 1727176, use the principal to determine the source of the drag, r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D123522
2021-08-31 00:58:35 +00:00
Masayuki Nakano 6122a660a0 Bug 1723125 - Ignore normal selection when updating composition string r=m_kato
Web apps can modify normal selection even during IME composition and no
browsers stop composition by it.  However, our editor tries to delete
non-collapsed selected range before updating composition.  Therefore,
we need additional state at handling inserting text whether selection
should be deleted or ignored.

Depends on D121371

Differential Revision: https://phabricator.services.mozilla.com/D121372
2021-08-02 08:23:50 +00:00
Masayuki Nakano 347bc5719a Bug 1714914 - Make editor classes treat offset in parent node as uint32_t r=m_kato
It should be treated as `uint32_t` since DOM API does so.  However, there are
some exceptions:

* Result of `nsINode::ComputeIndexOf()`
* Result of `nsAString` methods

They return `-1` as not found, and anyway, they cannot treat large integer
than `INT32_MAX`.  Therefore, this patch does not touch around them.

Differential Revision: https://phabricator.services.mozilla.com/D118933
2021-06-30 07:07:28 +00:00
Masayuki Nakano 0b53199bb0 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 63d372da2f 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 30130a49c1 Bug 1676702 - part 1: Make `TextEditor` store password masking data in a struct r=m_kato
The intermittent failure is caused by unexpected global reflow during the test.
If `<input type="password">` is reframed, `TextEditor` instance is recreated.
Then, the unmasked range of the editor stored by `TextEditor` is also lost.
Therefore, unmasked range is randomly lost by unexpected reflow.

If the global reflow is occurred by font list update etc which are not expected
by users, unmasked password field is unexpectedly masked.  So, this is a real
bug of `TextEditor`.

So, unmasked range needs to be stored outside `TextEditor` for making its
lifetime longer than `TextEditor`.  For doing it, first, `TextEditor` should
access password mask data via a pointer to a struct.  Then, fortunately,
we need to allocate it only when the `TextEditor` is a password editor.

Depends on D118755

Differential Revision: https://phabricator.services.mozilla.com/D118756
2021-06-28 04:37:53 +00:00
Masayuki Nakano 3485a15088 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
Kagami Sascha Rosylight 5dc38e6e2f Bug 1716728 - Part 2: Remove TextEditor::EnsurePaddingBRElementForEmptyEditor() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118064
2021-06-21 01:48:59 +00:00
Kagami Sascha Rosylight 9b640ade5b Bug 1713334 - Part 2: Initialize TextEditor always with a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117022
2021-06-18 00:36:54 +00:00
Masayuki Nakano 4fe63da099 Bug 1716720 - Clean up `TextEditor.h` and `HTMLEditor.h` r=m_kato
`TextEditor` is now a final class, so, it should be marked as so.  And this
patch modernize `virtual`, `override` and `final` keywords in them.

Differential Revision: https://phabricator.services.mozilla.com/D117998
2021-06-17 23:25:55 +00:00
Ryan VanderMeulen a337a14382 Backed out 5 changesets (bug 1713334) for causing bug 1716714.
Backed out changeset bd1c37ce2c61 (bug 1713334)
Backed out changeset 876ed18c5126 (bug 1713334)
Backed out changeset 5a4f4514d99a (bug 1713334)
Backed out changeset 7d7feef654c7 (bug 1713334)
Backed out changeset 61e15374e617 (bug 1713334)
2021-06-17 10:57:32 -04:00
Kagami Sascha Rosylight 4a9087283b Bug 1713334 - Part 2: Initialize TextEditor always with a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117022
2021-06-14 19:56:23 +00:00
Csoregi Natalia 85bb87115a Backed out 5 changesets (bug 1713334) for failures on test_texteditor_keyevent_handling.html. CLOSED TREE
Backed out changeset ab7b2061f5e8 (bug 1713334)
Backed out changeset f4032094748d (bug 1713334)
Backed out changeset 858410646bf7 (bug 1713334)
Backed out changeset 875b520387b8 (bug 1713334)
Backed out changeset 78b0cdebc890 (bug 1713334)
2021-06-14 20:58:37 +03:00
Kagami Sascha Rosylight 760acf8789 Bug 1713334 - Part 2: Initialize TextEditor always with a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117022
2021-06-14 13:08:32 +00:00
Masayuki Nakano db1228b24c Bug 1714918 - Sort out editor class accessors of `nsIEditor` r=m_kato
For consistency with the similar internal DOM API, `As*()` should just cast
the type without checking editor type.  Instead, `GetAs*()` should do it.

Differential Revision: https://phabricator.services.mozilla.com/D117381
2021-06-11 03:01:08 +00:00
Masayuki Nakano 96627061a2 Bug 1540037 - part 47: Move `TextEditor::InitEditorContentAndSelection()` to `EditorBase` r=m_kato
Depends on D117114

Differential Revision: https://phabricator.services.mozilla.com/D117115
2021-06-09 03:47:38 +00:00
Masayuki Nakano f41bc0674d Bug 1540037 - part 46: Move `TextEditor::EnsurePaddingBRElementInMultilineEditor()` into `EditorBase` r=m_kato
It's used by `TextEditor` and `HTMLEditor` in the plaintext mode.  Therefore,
it should be moved into `EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D117114
2021-06-09 03:47:38 +00:00
Masayuki Nakano 25db446d2f Bug 1540037 - part 45: Move `TextEditor::OnDrop()` into `EditorBase` r=m_kato
Depends on D116802

Differential Revision: https://phabricator.services.mozilla.com/D116803
2021-06-07 11:38:18 +00:00
Masayuki Nakano 740f16dc58 Bug 1540037 - part 44: Move the inserting dropped items part of `TextEditor::OnDrop()` to the new virtual method r=m_kato
This patch makes the previously created handler method to virtual (derived from
`EditorBase`), and makes `TextEditor` override it.

Depends on D116801

Differential Revision: https://phabricator.services.mozilla.com/D116802
2021-06-07 06:20:25 +00:00
Masayuki Nakano 78c3880b23 Bug 1540037 - part 42: Move `TextEditor::DeleteSelectionByDragAsAction()` into `EditorBase` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D116569
2021-06-04 05:23:05 +00:00
Masayuki Nakano 875fdeac2f Bug 1540037 - part 41: Split `TextEditor::PasteAsAction()` r=m_kato
It should be a virtual method derived from `EditorBase`, and `TextEditor`
and `HTMLEditor` should override it.  Then, `nsIEditor::Paste()` requires
referring vtable again if we keep implementing it only in `EditorBase`.
Therefore, this patch avoid it with implementing it in both `TextEditor`
and `HTMLEditor`.

Depends on D116567

Differential Revision: https://phabricator.services.mozilla.com/D116568
2021-06-04 05:01:39 +00:00
Masayuki Nakano 0ffb058047 Bug 1540037 - part 40: Move `TextEditor::PrepareTransferable()` into `EditorUtils` r=m_kato
It just creates an `nsITransferable` instance and add 2 flavors for storing
plain text.  Therefore, it can be in `EditorUtils` instead.

Depends on D116566

Differential Revision: https://phabricator.services.mozilla.com/D116567
2021-06-04 04:32:28 +00:00
Masayuki Nakano 9bb09489ad Bug 1540037 - part 39: Move `TextEditor::IsSafeToInsertData()` into `EditorBase` r=m_kato
Depends on D116565

Differential Revision: https://phabricator.services.mozilla.com/D116566
2021-06-04 03:28:24 +00:00
Masayuki Nakano 957175245e Bug 1540037 - part 38: Move `TextEditor::InsertTextAt()` into `EditorBase` r=m_kato
Depends on D116564

Differential Revision: https://phabricator.services.mozilla.com/D116565
2021-06-03 21:00:07 +00:00
Masayuki Nakano b5894800b8 Bug 1540037 - part 37: Move `TextEditor::PrepareToInsertContent()` into `EditorBase` r=m_kato
Depends on D116541

Differential Revision: https://phabricator.services.mozilla.com/D116564
2021-06-03 19:48:47 +00:00
Masayuki Nakano d064dce6e2 Bug 1713867 - Make `EditorBase::ComputeValueInternal` handle the case when there is only a padding <br> element for empty editor r=m_kato
It stopped using `ComputeValueFromTextNodeAndBRElement` for `HTMLEditor` case.
However, `ComputeValueFromTextNodeAndBRElement` handles the case that there is
only padding `<br>` element for empty editor even if the instance is
`HTMLEditor`.

So, this patch makes it handle this special case by itself before checking
whether the instance is `TextEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D116541
2021-06-03 08:03:41 +00:00
Masayuki Nakano e3e525a13b Bug 1540037 - part 33: Implement `nsIEditor::OutputToString()` in `EditorBase` rather than `TextEditor` r=m_kato
It's used both with `TextEditor` instance and `HTMLEditor` instance.  So, it
should be implemented in `EditorBase`.

Depends on D116349

Differential Revision: https://phabricator.services.mozilla.com/D116350
2021-06-01 07:51:47 +00:00
Masayuki Nakano 236d1d1228 Bug 1540037 - part 32: Move `TextEditor::ComputeValueInternal()` into `EditorBase` r=m_kato
Depends on D116348

Differential Revision: https://phabricator.services.mozilla.com/D116349
2021-06-01 02:17:50 +00:00
Masayuki Nakano 11f319ab64 Bug 1540037 - part 31: Move `TextEditor::GetAndIniitDocEncoder()` into `EditorBase` r=m_kato
It's a helper method of `TextEditor::ComputeValueInternal()` which is used by
`TextEditor` and `HTMLEditor::Rewrap()`.  So, before we move
`ComputeValueInternal()`, we need to move this first.

Depends on D116347

Differential Revision: https://phabricator.services.mozilla.com/D116348
2021-05-31 23:41:00 +00:00
Masayuki Nakano ac6b41fb7a Bug 1540037 - part 30: Get rid of `TextEditor::SharedOutputString()` r=m_kato
It's now used only by `HTMLEditor::Rewrap()` and it does simple thing with
`TextEditor::ComputeValueInternal()`.  So, we can make `Rewrap()` directly
do it instead.

Differential Revision: https://phabricator.services.mozilla.com/D116347
2021-05-31 22:34:00 +00:00
Masayuki Nakano abb1aff2ff Bug 1540037 - part 29: Move `nsIEditor.documentCharacterSet` definitions into `HTMLEditor` r=m_kato
The attribute is used only with `HTMLEditor`, and it does not make sense to
access document's character-set via `TextEditor`.  Therefore, this patch
makes it implement in `HTMLEditor` (`EditorBase` will return
`NS_ERROR_NOT_AVAILABLE` both getter and setter).

Note that `EditorBase::GetDocumentCharsetInternal()` is required by
`TextEditor::ComputeValueInternal()`.  Therefore, it needs to stay in
`EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D115948
2021-05-26 07:45:02 +00:00
Masayuki Nakano 3104bf1689 Bug 1540037 - part 28: Add pure virtual methods to `EditorBase`, which are originated from `TextEditor` r=m_kato
`TextEditor` declares some virtual methods newly.  However, for moving some
methods from `TextEditor` to `EditorBase`, they should be accessible from
`EditorBase`.  Therefore, this patch adds declarations of pure virtual
methods of them to `EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D115796
2021-05-26 02:00:45 +00:00
Masayuki Nakano 254db9612f Bug 1540037 - part 27: Move `TextEditor::CanDeleteSelection()` to `EditorBase` r=m_kato
It's used with both `TextEditor` and `HTMLEditor` instances.  So, it should be
implemented in `EditorBase` instead.

Differential Revision: https://phabricator.services.mozilla.com/D115795
2021-05-26 01:19:43 +00:00
Masayuki Nakano 85cc2d756b Bug 1540037 - part 26: Get rid of `TextEditor::Copy()` r=m_kato
It's common method of `TextEditor` and `HTMLEditor`, but implemented by
`TextEditor` even though it's an override of `nsIEditor`'s method.

Therefore, it should be implemented in `EditorBase` instead.

Differential Revision: https://phabricator.services.mozilla.com/D115794
2021-05-26 01:13:23 +00:00
Masayuki Nakano 98b26adadd Bug 1540037 - part 25: Move `TextEditor::CutAsAction()` to `EditorBase` r=m_kato
It's a common method to cut selection.  Therefore, it should be in `EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D115793
2021-05-26 00:25:30 +00:00