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

341 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Kew fff2fa76a6 Bug 1734590 - Both the static InternetCiter methods are now infallible, so no need to return/check an nsresult. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D127865
2021-10-11 12:20:42 +00:00
Csoregi Natalia e92f158606 Backed out 4 changesets (bug 1734590) for failures on test_xmlserializer.js. CLOSED TREE
Backed out changeset e492f8fd3d53 (bug 1734590)
Backed out changeset 0af985bb7569 (bug 1734590)
Backed out changeset 3751b93ae994 (bug 1734590)
Backed out changeset 45059121c015 (bug 1734590)
2021-10-08 14:41:06 +03:00
Jonathan Kew 7daf89e7fe Bug 1734590 - Both the static InternetCiter methods are now infallible, so no need to return/check an nsresult. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D127865
2021-10-08 10:05:52 +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
Andi-Bogdan Postelnicu 75ed803f7c Bug 1725145 - fixes for linking in the hybrid build env. r=valentin
Differential Revision: https://phabricator.services.mozilla.com/D122344
2021-08-22 10:21:56 +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 dcc8404a03 Bug 1717156 - part 7: Revert the change of the debug `printf` in `TextEditor.cpp` r=m_kato
I forgot to revert this before landing.

Differential Revision: https://phabricator.services.mozilla.com/D118447
2021-06-22 10:33:44 +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 e40714855d Bug 1716728 - Part 7: Move mPaddingBRElementForEmptyEditor to HTMLEditor r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118074
2021-06-21 01:49:01 +00:00
Kagami Sascha Rosylight 072dc887f9 Bug 1716728 - Part 4: Remove EnsureNoPaddingBRElementForEmptyEditor call for TextEditor r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118066
2021-06-21 01:49:00 +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
Masayuki Nakano 698fd90470 Bug 1716746 - Rename `EditorBase::IsPlaintextEditor()` to `IsInPlaintextMode()` r=m_kato
Developers may be confused at `IsTextEditor()` and `IsPlaintextEditor()`. When
the latter is `true`, the former is always `true`, but it may be `true` when the
editor is `HTMLEditor` too. So, it's a mode of  `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D118246
2021-06-18 20:35:48 +00:00
Kagami Sascha Rosylight 673eb02a8f Bug 1713334 - Part 4: Always select the text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117474
2021-06-18 00:36:55 +00:00
Kagami Sascha Rosylight 688fa49f4c Bug 1713334 - Part 3: Assume TextEditor always have a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117023
2021-06-18 00:36:54 +00:00
Kagami Sascha Rosylight 8bbe7f3f11 Bug 1713334 - Part 1: Keep a text node inside text controls even if empty r=masayuki,Jamie
Doing so prevents confusion when detecting selection change.

Differential Revision: https://phabricator.services.mozilla.com/D116303
2021-06-18 00:36:53 +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 92d3464a2e Bug 1716350 - Remove redundant editor type checks r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117662
2021-06-15 10:45:20 +00:00
Kagami Sascha Rosylight 7916262845 Bug 1713334 - Part 4: Always select the text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117474
2021-06-14 19:56:23 +00:00
Kagami Sascha Rosylight d6d3699b31 Bug 1713334 - Part 3: Assume TextEditor always have a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117023
2021-06-14 19:56:23 +00:00
Kagami Sascha Rosylight 52d022e717 Bug 1713334 - Part 1: Keep a text node inside text controls even if empty r=masayuki,Jamie
Doing so prevents confusion when detecting selection change.

Differential Revision: https://phabricator.services.mozilla.com/D116303
2021-06-14 19:56:22 +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 ca55613fb3 Bug 1713334 - Part 4: Always select the text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117474
2021-06-14 13:08:33 +00:00
Kagami Sascha Rosylight 237a6dbabc Bug 1713334 - Part 3: Assume TextEditor always have a text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117023
2021-06-14 13:08:33 +00:00
Kagami Sascha Rosylight b327288d9d Bug 1713334 - Part 1: Keep a text node inside text controls even if empty r=masayuki,Jamie
Doing so prevents confusion when detecting selection change.

Differential Revision: https://phabricator.services.mozilla.com/D116303
2021-06-14 13:08:32 +00:00
Kagami Sascha Rosylight 6338ce9f05 Bug 1715819 - Select the text node if exists in TextEditor::SelectEntireDocument r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117444
2021-06-12 11:04:51 +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 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 11211e435b Bug 1540037 - part 36: Make `EditorBase` handle `Delete`, `Backspace` and `Tab` of plaintext editor mode r=m_kato
`Delete` and `Backspace` keys are handled by same code.  So, the code should
be in `EditorBase` instead of `TextEditor`.

If `HTMLEditor` is in the plaintext editing mode of mail composer, `Tab` key
is also handled by the same code as `TextEditor`.  So, the code in `TextEditor`
should be moved to `EditorBase` too and `HTMLEditor` should call `EditorBase`'s
method only when it's in the plaintext mode.

Depends on D116352

Differential Revision: https://phabricator.services.mozilla.com/D116353
2021-06-01 08:51:25 +00:00
Masayuki Nakano 4814221877 Bug 1540037 - part 35: Make `TextEditor` and `HTMLEditor` handle modifier keys' `eKeyPress` event directly r=m_kato
Such events shouldn't be fired, but for now, we should make them handled in
the overrides.  Then, we can avoid the skipping `TextEditor` case from
`HTMLEditor`.

Depends on D116351

Differential Revision: https://phabricator.services.mozilla.com/D116352
2021-06-01 08:29:17 +00:00
Masayuki Nakano c9d764ea8a Bug 1540037 - part 34: Create `HandleKeyPressEventInReadOnlyMode()` r=m_kato
In any types of editor, `EditorBase` handles if it's in the read-only mode.
For making `HandleKeyPressEvent` relation between classes simpler, let's
handle it in an independent method.

Depends on D116350

Differential Revision: https://phabricator.services.mozilla.com/D116351
2021-06-01 07:51:48 +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 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
Masayuki Nakano f5499c4636 Bug 1540037 - part 24: Move `TextEditor::FireClipboardEvent()` to `EditorBase` r=m_kato
It's used by `HTMLEditor` too.  So, we should move it into `EditorBase`.

Depends on D115791

Differential Revision: https://phabricator.services.mozilla.com/D115792
2021-05-25 11:47:14 +00:00
Masayuki Nakano 8b5b4c1e04 Bug 1540037 - part 23: Move `TextEditor::AreClipboardCommandsUnconditionallyEnabled()` into `EditorBase` r=m_kato
This is used by `HTMLEditor` too.  So, this should be a method of `EditorBase`.

Depends on D115790

Differential Revision: https://phabricator.services.mozilla.com/D115791
2021-05-25 11:47:14 +00:00
Masayuki Nakano 585be1beb9 Bug 1540037 - part 22: Move `IsCopyCommandEnabled()` and `IsCutCommandEnabled()` from `TextEditor` to `HTMLEditor` r=m_kato
Of course, they are used for `HTMLEditor` instances too.  Therefore, they
should be in `EditorBase` rather than `TextEditor`.

Depends on D115789

Differential Revision: https://phabricator.services.mozilla.com/D115790
2021-05-25 08:32:57 +00:00
Masayuki Nakano c030d257c2 Bug 1540037 - part 21: Move `TextEditor::IsCopyToClipboardAllowed()` to `EditorBase` r=m_kato
It calls only its helper method, and the helper method,
`IsCopyToClipboardAllowedInternal()`, needs to check complicated things only
when it's a password editor.

This patch makes `IsCopyToCLipboardAllowedInternal()` a virtual method.  But
this shouldn't cause performance regression because this should be called
only when updating menu items or handling "copy" commands.  So, this shouldn't
be in any hot paths.

Depends on D115788

Differential Revision: https://phabricator.services.mozilla.com/D115789
2021-05-25 08:03:25 +00:00
Masayuki Nakano c0aa5a2f3f Bug 1540037 - part 20: Move `UndoAsAction()` and `RedoAsAction()` from `TextEditor` to `EditorBase` r=m_kato
They just work with a transaction manager and transactions, and they are used
by both `TextEditor` and `HTMLEditor`.  Therefore, they should be in
`EditorBase` for making `HTMLEditor` stop inheriting `TextEditor` in the
future.

Depends on D115787

Differential Revision: https://phabricator.services.mozilla.com/D115788
2021-05-25 06:46:18 +00:00
Masayuki Nakano 95c41d54c3 Bug 1540037 - part 19: Make `IsEmpty()` be a virtual method of `EditorBase` and implement `nsIEditor::GetDocumentIsEmpty()` in `EditorBase` r=m_kato
Currently, `EditorBase::GetDocumentIsEmpty()` is implemented by `TextEditor`,
and it refers only `IsEmpty()` which is implemented both by `TextEditor` and
`HTMLEditor`.  So, `IsEmpty()` should be a virtual method of `EditorBase`,
then, `EditorBase` can implement `GetDocumentIsEmpty()`.

Depends on D115786

Differential Revision: https://phabricator.services.mozilla.com/D115787
2021-05-25 04:53:01 +00:00
Masayuki Nakano ae69b73075 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