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

10645 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 5017e990c8 Bug 1717178 - part 6: Get rid of `nsIHTMLEditor.setCaretAfterElement()` because of unused r=m_kato
Depends on D118801

Differential Revision: https://phabricator.services.mozilla.com/D118802
2021-06-28 12:08:51 +00:00
Masayuki Nakano 3e099ba376 Bug 1717178 - part 5: Get rid of `nsIHTMLEditor.pasteNoFormatting()` because of unused r=m_kato
Depends on D118800

Differential Revision: https://phabricator.services.mozilla.com/D118801
2021-06-28 12:08:50 +00:00
Masayuki Nakano bc454f8841 Bug 1717178 - part 4: Get rid of `nsIHTMLEditor.getInlineProperty()` because of unused r=m_kato
Only `test_bug1140105.html` is its user, but it can be replaced with
`getInlinePropertyWithAttrValue()` since they do exactly same things:
https://searchfox.org/mozilla-central/rev/fc95c6ad297d9d257f05599d01741503f3f57326/editor/libeditor/HTMLStyleEditor.cpp#1685-1687,1719-1721

Depends on D118799

Differential Revision: https://phabricator.services.mozilla.com/D118800
2021-06-28 12:08:50 +00:00
Masayuki Nakano 4ac1a649ab Bug 1717178 - part 3: Get rid of `nsIHTMLObjectResizer.refreshResizers()` because of unused r=m_kato
Depends on D118798

Differential Revision: https://phabricator.services.mozilla.com/D118799
2021-06-28 12:08:49 +00:00
Masayuki Nakano ab7d00e972 Bug 1717178 - part 2: Get rid of `nsIHTMLAbsPosEditor.refreshGrabber()` because of unused r=m_kato
Depends on D118797

Differential Revision: https://phabricator.services.mozilla.com/D118798
2021-06-28 12:08:49 +00:00
Masayuki Nakano 807bae35f4 Bug 1717178 - part 1: Get rid of `nsIHTMLInlineTableEditor.refreshInlineTableEditingUI()` because of unused r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D118797
2021-06-28 12:08:49 +00:00
Masayuki Nakano ca0a51ea08 Bug 1716408 - Make enable `test_cut_copy_password.html` in all cases r=m_kato
The fix of bug 1676702 made the test stable.  So, let's try to enable it in
any environment.

Depends on D118758

Differential Revision: https://phabricator.services.mozilla.com/D118759
2021-06-28 06:31:08 +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 8927b994ea Bug 1676702 - part 0: Add automated tests for keeping unmasked range during reflows r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D118755
2021-06-28 04:37:53 +00:00
Masayuki Nakano 88b5b85325 Bug 1717749: Drop `MOZ_ASSERT` check for `nsIEditor.eEditorMailMask` r=m_kato
In my understanding at fixing bug 1717156, `nsIEditor.eEditorMailMask` won't be
set to `TextEditor` instance.  However for making consistent **spellchecker**
behavior on email composer, subject editor is also set this flag.  So, we need
to drop the check in `SetFlags` and IsMailEditor.

Differential Revision: https://phabricator.services.mozilla.com/D118561
2021-06-23 23:01:48 +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
Masayuki Nakano e178e6da17 Bug 1717156 - part 5: Get rid of `nsIEditor::eEditorNoCSSMask` r=m_kato
Now, `nsIEditor::eEditorNoCSSMask` is used only in the editor internally.
And it's available and meaningful only with `HTMLEditor` instance.  So,
we can get rid of it from `EditorBase`.  Fortunately, `HTMLEditor` always
creates `CSSEditUtils` and it stores the raw value indicating whether the
editor manager enabled or disabled CSS.  Therefore, we don't need new
member variable in `HTMLEditor` for storing the flag.  And this allows us
to remove `nsIEditor::SetFlags()` override of `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D118265
2021-06-22 00:18:07 +00:00
Masayuki Nakano 148a74cbc3 Bug 1717156 - part 4: Drop `Tab` key handling in `EditorBase` r=m_kato
Now, `EditorBase::IsTabable()` returns true only when it's an `HTMLEditor`
instance and `nsIEditor::eEditorAllowInteraction` is not set.  Additionally,
nobody controls the flag of `TextEditor`.  So, we can make the flag available
only with `HTMLEditor` instance, and `Tab` key handling in `EditorBase`
can be moved to `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D118264
2021-06-22 00:18:07 +00:00
Masayuki Nakano 88d2a84a0f Bug 1717156 - part 3: Get rid of `nsIEditor::eEditorFilterInputMask` and its accessor r=m_kato
Nobody (including comm-central and BlueGriffon) uses
`nsIEditor::eEditorFilterInputMask`.  Therefore, we can get rid of this and its
accessor, `EditorBase::IsInputFiltered()`.

Differential Revision: https://phabricator.services.mozilla.com/D118263
2021-06-22 00:18:06 +00:00
Masayuki Nakano 666946b157 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
Masayuki Nakano 0e68fa3f7e Bug 1717156 - part 1: Make editor type specific flags clearer with `MOZ_ASSERT` r=m_kato
Some `nsIEditor::eEditor*Mask` flags are now only for `TextEditor` or
`HTMLEditor`.  For making it clearer, add `MOZ_ASSERT` to the `SetFlags` and
each flag accessor.

Differential Revision: https://phabricator.services.mozilla.com/D118261
2021-06-22 00:18:05 +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 89ab198242 Bug 1716728 - Part 6: Add HTMLEditor::ReflectPaddingBRElementForEmptyEditor() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118071
2021-06-21 01:49:00 +00:00
Kagami Sascha Rosylight 17fdc5f56b Bug 1716728 - Part 5: Move EnsureNoPaddingBRElementForEmptyEditor to HTMLEditor r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118068
2021-06-21 01:49:00 +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 24eb2dca60 Bug 1716728 - Part 3: Move MaybeCreatePaddingBRElementForEmptyEditor to HTMLEditor r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118065
2021-06-21 01:48:59 +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 7851edce6e Bug 1716728 - Part 1: Use IsEmpty() instead of mPaddingBRElementForEmptyEditor existence check r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118063
2021-06-21 01:48:58 +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 3f6f05b7eb Bug 1713334 - Part 6: Actively prevent text deletion in DeleteRangeTransaction r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118239
2021-06-18 00:36:56 +00:00
Kagami Sascha Rosylight 2de7595469 Bug 1713334 - Part 5: Allow caret to be at the end of text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117024
2021-06-18 00:36:55 +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 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
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
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
Ryan VanderMeulen 52692e2ba0 Backed out changeset 2f69dc403886 (bug 1716714) for causing bug 1717007. 2021-06-17 10:56:58 -04:00
Kagami Sascha Rosylight 81c32a2ea5 Bug 1716714 - Temporarily convert text node assertion as diagnostic r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D118034
2021-06-17 05:30:28 +00:00
Masayuki Nakano bccd582eaf Bug 1716068 - Don't start autoscroll on editable content or document whose designMode is on r=smaug
When middle mouse paste is enabled and middle click occurs in an editable
content or it's in a document whose `designMode` is `on`, we shouldn't start
the autoscrolling because the click must be intended for pasting clipboard
content or primary selection to the position.

Differential Revision: https://phabricator.services.mozilla.com/D117987
2021-06-16 12:20:17 +00:00
Masayuki Nakano 5a85202b76 Bug 1716299 - Fix the flag name r=m_kato
`nsIDocumentEncoder.OutputRaw` was misspelled as `nsIDocumentEncoder.OutRaw`.

Then, I investigate the expected result more.  Then, I see that when only this
flag is set, any markups should be ignored except `<br>`.  Therefore, I modified
the 2 test results which check `<p>`, `<div>` and `<br>` elements.

Differential Revision: https://phabricator.services.mozilla.com/D117966
2021-06-16 10:47:27 +00:00
Andrew Halberstadt 7a16af4434 Bug 1700781 - Skip failing mochitest-plain tests with fission + xorigin, r=jmaher
Differential Revision: https://phabricator.services.mozilla.com/D117704
2021-06-15 18:24:18 +00: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
Kris Maglione ae436f55ec Bug 1646560: Part 2 - Move allowJavascript and friends from DocShell to BrowsingContext and WindowContext. r=jdescottes,nika,geckoview-reviewers,devtools-backward-compat-reviewers,agi
This is slightly complicated by the fact that the editor code wants to be able
to set this from the content process, so we really need separate
BrowsingContext and WindowContext flags, the latter of which can be set by the
owning process.

Differential Revision: https://phabricator.services.mozilla.com/D114899
2021-06-15 04:40:11 +00:00
Kagami Sascha Rosylight d371e763e5 Bug 1713334 - Part 5: Allow caret to be at the end of text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117024
2021-06-14 19:56:24 +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 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
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 2acf39c5b0 Bug 1713334 - Part 5: Allow caret to be at the end of text node r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117024
2021-06-14 13:08:34 +00: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 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
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 5423cae57c Bug 1560396 - Replace `EditorBase::GetNodeAtRangeOffsetPoint()` with new API in `EditorDOMPointBase` r=m_kato
It's a static method and called only with `EditorDOMPointBase` instances.
So, we can add new API to `EditorDOMPointBase` instead.

Note that it's changed to return container when the container is a data node
rather than a text node.  This should be better because no data node can
have children.

Depends on D117382

Differential Revision: https://phabricator.services.mozilla.com/D117490
2021-06-11 08:57:18 +00:00
Masayuki Nakano e57b20394e Bug 1713760 - Make `HTMLEditor` inherit `EditorBase` directly r=m_kato
For making it clearer that `TextEditor` has only its specific members.  For
guaranteeing that, we should split `TextEditor` and `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D117382
2021-06-11 03:01:09 +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 e4b33674ec Bug 1713821 - Make `EditorEventListener::Blur()` ignore coming events whose target is an element, but the editor is in the design mode r=smaug
While initializing `HTMLEditor` for `designMode`, `blur` event for the
previously focused element will be fired after `HTMLEditor` initialization
because of the script blocker in `Document::EditingStateChanged()`:
https://searchfox.org/mozilla-central/rev/c0f286b1f541c675bbe052b21bdefa80d150ec35/dom/base/Document.cpp#5878,5891,5923

This causes `EditorEventListener::Blur()` calling
`EditorBase::FinalizeSelection()` to make the editor stop handling selection.
Therefore, if the design mode is turned on from an event listener run by a
user operation cannot make the caret visible.

This patch makes the `Blur()` ignore `blur` events whose target is element
in the design mode since the target of `blur` events should be handled in the
design mode is always the DOM window or the document node.

Differential Revision: https://phabricator.services.mozilla.com/D117268
2021-06-09 22:26:16 +00:00
Masayuki Nakano c0624f4771 Bug 1713757 - Make `mozInlineSpellChecker`, `mozInlineSpellWordUtil` and `TextServicesDocument` use `EditorBase` instead of `TextEditor` r=m_kato
Depends on D117117

Differential Revision: https://phabricator.services.mozilla.com/D117118
2021-06-09 09:02:31 +00:00
Masayuki Nakano 95c6e30135 Bug 1713756 - Make editor command classes treat `EditorBase` instead of `TextEditor` r=m_kato
`TextEditor` will be not a parent class of `HTMLEditor`.  Therefore, editor
command classes should use `EditorBase` class instead.

Depends on D117116

Differential Revision: https://phabricator.services.mozilla.com/D117117
2021-06-09 07:17:52 +00:00
Masayuki Nakano b52cf6bbe2 Bug 1714916 - Make `HTMLEditor::InsertFromDataTransfer()` and `GetStringFromDataTransfer()` take `uint32_t` as index of `DataTransfer` items r=m_kato
`DataTransfer` manages its items with `uint32_t` now, but editor methods still
access with `int32_t`.  Therefore, editor module should use `uint32_t`.

Depends on D117115

Differential Revision: https://phabricator.services.mozilla.com/D117116
2021-06-09 03:47:39 +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
Emilio Cobos Álvarez 2b0eae6061 Bug 1715134 - Make form control type an enum class. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D117087
2021-06-08 09:43:59 +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 fdcc651230 Bug 1540037 - part 43: Move inserting dropped items part on `HTMLEditor` to `HTMLEditor` r=m_kato
`TextEditor::OnDrop()` handles both cases, in `TextEditor` and in `HTMLEditor`
because the common part is too complicated to duplicate.  However, most
different part is inserting the dropped items part.  So, let's make them
into a virtual method.

In this patch, creating a method only in `HTMLEditor` and moves the part
into it.

Depends on D116569

Differential Revision: https://phabricator.services.mozilla.com/D116801
2021-06-07 04:18:08 +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 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 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
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
Masayuki Nakano de91059947 Bug 1540037 - part 17: Move `TextEditor::OnInputText()` into `EditorBase` r=m_kato
This method is semi-public method, meaning that this is commonly used by
public methods which handle various user input and that causes inputting
text, both in `TextEditor` and `HTMLEditor`.

Therefore, for making `HTMLEditor` stop inheriting `TextEditor` class in the
future, we should move it into `EditorBase`.

Depends on D115784

Differential Revision: https://phabricator.services.mozilla.com/D115785
2021-05-25 04:12:14 +00:00
Masayuki Nakano 1a7abaeafa Bug 1540037 - part 16: Move composition event handlers from `TextEditor` to `EditorBase` r=m_kato
IME is available in both `TextEditor` and `HTMLEditor`, and the handling
code is almost same (they partially do different things with checking
`IsHTMLEditor()`).  Therefore, we should move them to `EditorBase` for
making `HTMLEditor` possible to inherit only `EditorBase` in the future.

Differential Revision: https://phabricator.services.mozilla.com/D115784
2021-05-25 02:06:32 +00:00
Makoto Kato b9d27ed316 Bug 1694255 - Allow delete previous block element. r=masayuki
This fix allows that we can remove previous div block that isn't editable.

```
<div contenteditable>foo<div contenteditable=false>bar</div><[]baz</div>
```

Our text scanner can reach previous text node in other block when deleting
text even if text node is read-only. In this situation, we try joining each
block. But since target element/node isn't editable, this operation is
failure.

So we should use atomic deletion instead for this case.

Differential Revision: https://phabricator.services.mozilla.com/D115341
2021-05-21 01:48:58 +00:00
Butkovits Atila 65837795f4 Backed out changeset 8707a9007c17 (bug 1694255) for causing failure at crashtests/1677566.html. 2021-05-20 16:22:32 +03:00
Makoto Kato b87fac8911 Bug 1694255 - Allow delete previous block element. r=masayuki
This fix allows that we can remove previous div block that isn't editable.

```
<div contenteditable>foo<div contenteditable=false>bar</div><[]baz</div>
```

Our text scanner can reach previous text node in other block when deleting
text even if text node is read-only. In this situation, we try joining each
block. But since target element/node isn't editable, this operation is
failure.

So we should use atomic deletion instead for this case.

Differential Revision: https://phabricator.services.mozilla.com/D115341
2021-05-20 08:52:00 +00:00
Masayuki Nakano 7c0197d85c Bug 1627175 - part 68: Move `HTMLEditor::StartOrEndOfSelectionRangesIsIn()` to `AutoRangeArray` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115180
2021-05-18 09:06:13 +00:00
Masayuki Nakano af77fca66e Bug 1627175 - part 67: Move `HTMLEditor::FindNearEditableContent()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115179
2021-05-18 08:28:32 +00:00