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

10835 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano dbc4e0135e Bug 1721317 - part 2: Make `_pasteToTargetElement()` sync r=m_kato
The function tests whether `input` event whose `inputType` is `insertFromPaste`
or not and it waits the event until timeout.  This sometimes fails in my
environment, and `input` event should be fired synchronously in this case.
Therefore, it should just fail if the event isn't fired.

Depends on D120424

Differential Revision: https://phabricator.services.mozilla.com/D120425
2021-07-21 23:22:04 +00:00
Masayuki Nakano e21daf33c3 Bug 1721317 - part 1: Make `test_pasting_table_rows.html` abort remaining tests if unexpected exception is thrown r=m_kato
Oddly, clipboard related test randomly (and frequently) fails in my environment.
And `test_pasting_table_rows.html` does not handle exception which is thrown
by `SimpleTest.promiseClipboardChange`.  Therefore, I'm always waiting 5 mins
when I run all tests under `editor/libeditor/tests`.

Therefore, I'd like to make it abort remaning tests if it fails due to
an unexpected exception.

Additionally, this fixes a bug in `_copyToClipboard#validatorFn`.  This method
modifies the variable of the parent function, `aExpectedPastedHTML`, with
itself.  Therefore, when the function is called multiple times, the expected
string will be re-wrapped with `kTextHtmlPrefixClipboardDataWindows` and
`kTextHtmlSuffixClipboardDataWindows` again and again...

Differential Revision: https://phabricator.services.mozilla.com/D120424
2021-07-21 23:22:03 +00:00
Masayuki Nakano 7448c66839 Bug 1721323 - Move some tests under `editor/libeditor/tests` which mainly test spellchecker behavior to `editor/spellchecker/tests` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D120421
2021-07-21 05:39:16 +00:00
Masayuki Nakano 45b115a2d0 Bug 1311934 - Replace `TextServicesDocument::IsBlockNode()` with `HTMLEditUtils::IsBlockElement()` r=m_kato
For consistency, between `TextServicesDocument` and `HTMLEditor`,
`TextServicesDocument::IsBlockNode()` should be replaced with
`HTMLEditUtils::IsBlockElement()` for making same consideration for each
element type.

Differential Revision: https://phabricator.services.mozilla.com/D119870
2021-07-19 23:11:25 +00:00
Masayuki Nakano b5ce8cc8c4 Bug 1720436 - Make `test_bug408231.html` specify default `font-familiy` explicitly r=m_kato
It checks default `font-family` with editing commands, but it depends on the
system locale. ("serif" vs. "sans-serif").  So, its `<body>` should be styled
as `font-family: serif` for consistent behavior in any environment.

Differential Revision: https://phabricator.services.mozilla.com/D119871
2021-07-15 10:46:55 +00:00
Masayuki Nakano 04b41051dd Bug 1665550 - part 4: Make `EventStateManager` update `mGestureDownFrameOwner` when anonymous nodes in `<input>` or `<textarea>` are replaced r=smaug
`EventStateManager` gives up to track gesture to start a drag if mouse down
content which is stored in `mGestureDownFrameOwner` gets lost its primary frame.

When user tries to start to drag selected text in `<input>` or `<textarea>`
element, mouse down content is an anonymous node in `TextControlElement`. So,
if a reflow occurs after `mousedown` event, the anonymous `<div>` element
is replaced with new one and `EventStateManager` gives up to track it.

Therefore, this patch makes `EventStateManager` do similar things as
`nsBaseDragService`.  When `nsTextControlFrame` notifies of remove/add
the anonymous nodes, `EventStateManager` tries to keep tracking gesture with
a new anonymous node.

Differential Revision: https://phabricator.services.mozilla.com/D119488
2021-07-14 01:20:20 +00:00
Masayuki Nakano a171e12db6 Bug 1665550 - part 3: Make `nsTextControlFrame` set the source node and selection of drag session to new ones when it's reframed r=smaug
When `nsTextControlFrame` is reframed, `TextEditor`, anonymous `<div>`, its
`Text` and the independent `Selection`s are deleted temporarily and recreated
them.

If users are dragging text in `<input>` or `<textarea>`, the drag session's
source node is set to the anonymous text node in the element and the selection
is set to the independent selection.  So, if the element is reframed during a
drag, the source node is disconnected from the document and `EndDragSession`
failed to dispatch `eDragEnd` event.

Therefore, this patch makes `nsTextControlFrame` replaces the source node and
selection when it's recreated and only when the drag session's original source
node was in the text control element.  For checking which text control had the
anonymous text node, this patch makes `nsTextControlFrame` replaces source
node with the `<input>` or `<textarea>` element when the frame is destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D119487
2021-07-14 01:20:19 +00:00
Masayuki Nakano e577d75b11 Bug 1665550 - part 2: Rewrite `test_dragdrop.html` with IIEF r=m_kato
With IIEF, we can guarantee each test block isolated.  So, without declaring
semi-global variables a lot for all tests, developers can comment out every
tests to debug only one thing.

Differential Revision: https://phabricator.services.mozilla.com/D119486
2021-07-14 01:20:19 +00:00
Masayuki Nakano 0324a4e4ef Bug 1665550 - part 1: Make `test_dragdrop.html` handle exception from synthesizePlainDragAndDrop r=m_kato
When the test is timed out, there is a JS error which is thrown by
`synthesizePlainDragAndDrop`.  So, first, make the test handle exception
with `try-catch` and assert the error.

Differential Revision: https://phabricator.services.mozilla.com/D119485
2021-07-14 01:20:18 +00:00
Masayuki Nakano 886c96059e Bug 1718924 - part 18: Move some blocks which work with `TextServicesDocument::mOffsetTable` into new separated methods r=m_kato
Depends on D119164

Differential Revision: https://phabricator.services.mozilla.com/D119165
2021-07-13 11:19:22 +00:00
Masayuki Nakano 1fbcf183f9 Bug 1718924 - part 17: Move `TextServicesDocument::mSelectionStartOffsetInTexInBlock` and `TextServicesDocument::mSelectionEndOffsetInTextInBlock` into `OffsetEntryTable` r=m_kato
Depends on D119163

Differential Revision: https://phabricator.services.mozilla.com/D119164
2021-07-13 11:09:57 +00:00
Masayuki Nakano abfa8fead9 Bug 1718924 - part 16: Move `TextServicesDocument::RemoveInvalidOffsetEntries()` to `OffsetEntry` r=m_kato
Depends on D119162

Differential Revision: https://phabricator.services.mozilla.com/D119163
2021-07-13 11:03:56 +00:00
Masayuki Nakano d3e59b2f42 Bug 1718924 - part 15: Move `TextServicesDocument::mSelStartIndex` and `TextServicesDocument::mSelEndIndex` into `OffsetEntryArray` r=m_kato
They are indices of `OffsetEntryArray`. Therefore, they should be managed in it.

Depends on D119161

Differential Revision: https://phabricator.services.mozilla.com/D119162
2021-07-13 10:57:48 +00:00
Masayuki Nakano 987147357a Bug 1718924 - part 14: Move `TextServicesDocument::SplitOffsetEntry` to `OffsetEntryArray` r=m_kato
Depends on D119160

Differential Revision: https://phabricator.services.mozilla.com/D119161
2021-07-13 10:51:46 +00:00
Masayuki Nakano f4d6fde8cd Bug 1718924 - part 13: Move `TextServicesDocument::NodeHasOffsetEntry()` into `OffsetEntryArray` r=m_kato
Depends on D119159

Differential Revision: https://phabricator.services.mozilla.com/D119160
2021-07-13 10:46:40 +00:00
Masayuki Nakano 5f44d6166c Bug 1718924 - part 12: Move `TextServicesDocument::FindWordBounds()` to `OffsetEntryArray` r=m_kato
Depends on D119158

Differential Revision: https://phabricator.services.mozilla.com/D119159
2021-07-13 10:19:40 +00:00
Masayuki Nakano e2aec22fef Bug 1718924 - part 11: Create custom class of `nsTArray<UniquePtr<OffsetEntry>>` r=m_kato
There are some methods in `TextServicesDocument` which work only with
`TextServicesDocument::mOffsetTable`.  Once we move such methods to custom
class of `nsTArray<UniquePtr<OffsetEntry>>`, we can make `TextServicesDocument`
simpler.

Depends on D119157

Differential Revision: https://phabricator.services.mozilla.com/D119158
2021-07-13 10:11:06 +00:00
Masayuki Nakano 3169bc5de5 Bug 1720252 - Get rid of "dom.input_events.beforeinput.enabled" from tests r=smaug
`beforeinput` event was shipped and it won't be disabled for avoiding confusion
of web developers. So, we can drop the pref setting of
"dom.input_events.beforeinput.enabled" in our tests.

Depends on D119716

Differential Revision: https://phabricator.services.mozilla.com/D119729
2021-07-13 10:02:12 +00:00
Masayuki Nakano afce03d9c7 Bug 1718924 - part 10: Make all `OffsetEntry` instances unique pointers r=m_kato
Now, it stores `dom::Text` with `OwningNonNull`.  So, once it's leaked, it
wastes a lot of memory spaces.  Therefore, we should make `mOffsetTable`
store `UniquePtr<OffsetEntry>` instead of `OffsetEntry*`.

Depends on D119156

Differential Revision: https://phabricator.services.mozilla.com/D119157
2021-07-13 09:55:59 +00:00
Masayuki Nakano b8ea33dddf Bug 1718924 - part 9: Rename `TextServicesDocument::mSel(Start|End)Offset` r=m_kato
Now, the meaning of `OffsetEntry` is clear.  Therefore, this patch adds comment
explaining the class and its members.

Then, the meaning of `TextServicesDocument::mSelStartOffset` and
`TextServicesDocument::mSelEndOffset` becomes clearer since they are used to
create `OffsetEntry` instances.  Therefore, this patch renames them.

Depends on D119155

Differential Revision: https://phabricator.services.mozilla.com/D119156
2021-07-13 09:42:34 +00:00
Masayuki Nakano 9ccb5fd526 Bug 1718924 - part 8: Add `OffsetEntry::OffsetInTextInBlockIsInRangeOrEndOffset()` r=m_kato
Depends on D119154

Differential Revision: https://phabricator.services.mozilla.com/D119155
2021-07-13 09:06:04 +00:00
Masayuki Nakano 36c6e61f3c Bug 1718924 - part 7: Add `OffsetEntry::EndOffsetInTextInBlock()` r=m_kato
Depends on D119153

Differential Revision: https://phabricator.services.mozilla.com/D119154
2021-07-13 08:49:47 +00:00
Masayuki Nakano 91272b59bb Bug 1718924 - part 6: Rename `OffsetEntry::mStrOffset` to `mOffsetInTextInBlock` r=m_kato
Depends on D119152

Differential Revision: https://phabricator.services.mozilla.com/D119153
2021-07-13 08:42:01 +00:00
Masayuki Nakano d1c80af6c8 Bug 1718924 - part 5: Add `OffsetEntry::OffsetInTextNodeIsInRangeOrEndOffset()` r=m_kato
Depends on D119151

Differential Revision: https://phabricator.services.mozilla.com/D119152
2021-07-13 08:42:00 +00:00
Masayuki Nakano 84f8568e67 Bug 1718924 - part 4: Add `OffsetEntry::EndOffsetInTextNode()` r=m_kato
Depends on D119150

Differential Revision: https://phabricator.services.mozilla.com/D119151
2021-07-13 08:35:32 +00:00
Masayuki Nakano 59ed2fb43b Bug 1718924 - part 3: Rename `OffsetEntry::mNodeOffset` to `mOffsetInTextNode` r=m_kato
Depends on D119149

Differential Revision: https://phabricator.services.mozilla.com/D119150
2021-07-13 08:20:13 +00:00
Masayuki Nakano f7a5d2ebbe Bug 1718924 - part 2: Change `OffsetEntry::mNode` to `OwningNonNull<Text>` r=m_kato
Now, `mNode` is always a text node, and it may store across "can run script"
boundaries.  So, it should be `OwningNonNull<Text>`.

Depends on D119148

Differential Revision: https://phabricator.services.mozilla.com/D119149
2021-07-13 08:20:13 +00:00
Masayuki Nakano bbfaac5e36 Bug 1718924 - part 1: Get rid of `TextServicesDocument::IsTextNode()` and use `AsText()` if it's safe r=m_kato
It seems that it treats mainly a text node in various places, but it's not
guaranteed by any variable declarations.  So, first of all, I'd like to make
it clearer.

`TextServicesDocument::IsTextNode()` isn't necessary because `nsINode::IsText()`
is enough useful.  And `AsText()` should be zero cost at runtime.  So, in blocks
which guarantee specific content node is a text node, this patch appends
`AsText()` for making the code clearer.

Differential Revision: https://phabricator.services.mozilla.com/D119148
2021-07-13 08:13:11 +00:00
Masayuki Nakano b94d2d1076 Bug 1719669 - Fix the reverse loop in `SelectionState::SaveSelection()` r=m_kato
The crash is caused by the infinite loop to delete unnecessary ranges.
The `i` is always equals or larger than `0` due to unsigned.  So, if
`Selection::RangeCount()` is `0`, `i` can be `UINT32_MAX`.

Instead, we can use `nsTArray<RefPtr<RangeItem>>::TruncateLength()`.

Differential Revision: https://phabricator.services.mozilla.com/D119564
2021-07-12 07:52:32 +00:00
Masayuki Nakano a81636618b Bug 1719387 - Make `test_bug795418-2.html` request `text/unicode` flavor in the headless mode r=smaug
Until fixing bug 1686012, clipboard in the headless mode does not support
"text/html" flavor.  Therefore, the `waitForClipboard` in the test does not
get expected value as `aData` in the first callback.

So, it should request `text/unicode` in the headless mode.

Depends on D119483

Differential Revision: https://phabricator.services.mozilla.com/D119484
2021-07-12 03:55:21 +00:00
Masayuki Nakano f9bedeed22 Bug 1719387 - Make `HTMLEditor::HandleInsertText()` allow to insert text outside `<body>` in XHTML document r=m_kato
With the change of bug 1716863, it retrieves editing host, but it's `nullptr`
if there is no `<body>` element in XHTML document.  The root cause should be
fixed in bug 1697989, but for now, we should allow it only in XHTML document
for safer regression fix.

Differential Revision: https://phabricator.services.mozilla.com/D119483
2021-07-12 03:55:21 +00:00
Masayuki Nakano 5dd777bdc1 Bug 1716863 - Make `HTMLEditor::HandleInsertText()` climb up the tree when `Selection` is in elements which cannot have text nodes r=m_kato
In most cases, it's called with selection range which is collapsed in a text
node, but otherwise, the selection may be in an element which cannot have
text nodes.  Therefore, before handling the insertion, it should look for
ancestor element which can have text nodes.

Note that this patch makes inserting text immediately before an inclusive
ancestor element whose parent can have a text node.  However, both Blink and
WebKit ignores if there are invisible/empty inline nodes.  So, even with
this patch, Gecko keeps failing in some tests of the WPT.  It should be handled
in a follow up bug because doing it requires complicated code.

Differential Revision: https://phabricator.services.mozilla.com/D119065
2021-07-06 04:55:28 +00:00
Masayuki Nakano 637a88b524 Bug 1718815 - part 4: Move `EditorBase::AppendNodeToSelectionAsRange()` and `EditorBase::ClearSelection()` to `HTMLEditor` r=m_kato
Depends on D119003

Differential Revision: https://phabricator.services.mozilla.com/D119004
2021-07-02 08:23:46 +00:00
Masayuki Nakano 46d18deed5 Bug 1718815 - part 3: Move `EditorBase::AutoTransactionBatch` to `HTMLEditor` r=m_kato
I guess that this class is replaced with `AutoPlaceholderBatch`, and both of
them are followed by its instances.  However, I don't want to change the
behavior in this bug.  Therefore, this patch just moves it into `HTMLEditor`.

Depends on D119002

Differential Revision: https://phabricator.services.mozilla.com/D119003
2021-07-02 08:23:45 +00:00
Masayuki Nakano a68528b057 Bug 1718815 - part 2: Move `EditorBase::AutoSelectionRestorer` and `EditorBase` methods called only by it to `HTMLEditor` r=m_kato
Unfortunately, marking its constructor and destructor as `MOZ_CAN_RUN_SCRIPT`,
`Maybe<AutoSelectionRestorer>::reset()` and
`Maybe<AutoSelectionRestorer>::emplace()` cause bustage.  Therefore, this patch
just mark them as `MOZ_CAN_RUN_SCRIPT_BOUNDARY`.

Note that `EditorBase::SavedSelectionRef()` cannot be moved to `HTMLEditor`
because `mEditActionData` is a private member of `EditorBase`.

Depends on D119001

Differential Revision: https://phabricator.services.mozilla.com/D119002
2021-07-02 08:23:45 +00:00
Masayuki Nakano 7ac37b46ec Bug 1718815 - part 1: Move `EditorBase::AddTransactionListener()` and `EditorBase::RemoveTransactionListener()` to `HTMLEditor` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D119001
2021-07-02 08:23:44 +00:00
Masayuki Nakano 1fc0882ecc Bug 1718607 - Make `TextServicesDocument` use `uint32_t` for offset in DOM node r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D118955
2021-06-30 09:07:35 +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 f8426533d4 Bug 1717178 - part 8: Get rid of `nsIEditor.doTransaction()` because of unused r=m_kato
Depends on D118803

Differential Revision: https://phabricator.services.mozilla.com/D118805
2021-06-28 12:08:51 +00:00
Masayuki Nakano 917dc274f8 Bug 1717178 - part 7: Get rid of `nsIEditor::AddEditorObserver()` and `nsIEditorObserver` interface because of unused r=m_kato
Depends on D118802

Differential Revision: https://phabricator.services.mozilla.com/D118803
2021-06-28 12:08:51 +00:00
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
Masayuki Nakano 6b9d03cab3 Bug 1627175 - part 66: Move `HTMLEditor::IsTextPropertySetByContent()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115178
2021-05-18 06:55:03 +00:00
Masayuki Nakano e9d6280e92 Bug 1520983 - part 1: Add new content command event for inserting text r=smaug
For inserting text from OS in special cases, e.g., when inserting 2 or more characters
per keydown or inserting text without key press, we use a set of composition events on
macOS, but the other browsers don't use composition events.  Instead, they expose only
`beforeinput` event and `input` event.  We should follow their behavior for web-compat
because `beforeinput` events for IME composition are never cancelable, but the
`beforeinput` events for the cases are cancelable of the other browsers.

Differential Revision: https://phabricator.services.mozilla.com/D114826
2021-05-18 06:30:35 +00:00
Masayuki Nakano 1a6a786787 Bug 1627175 - part 65: Move `HTMLEditor::GetDeepestEditableOnlyChildDivBlockquoteOrListElement()` to `HTMLEditUtils` r=m_kato
And also `HTMLEditor::CountEditableChildren()` is moved since it's used only by
it.

Despite the long method name, it's really unclear what it does.  I try to
explain it with new name, but the things which the method does are not make
sense.  So, if you have better name idea, I'll take it...

Differential Revision: https://phabricator.services.mozilla.com/D115177
2021-05-18 05:52:25 +00:00
Masayuki Nakano 14455fdb7b Bug 1627175 - part 64: Get rid of `HTMLEditor::GetWhiteSpaceEndPoint()` r=m_kato
Now, it does easy things and called only by
`HTMLEditor::CreateRangeIncludingAdjuscentWhiteSpaces()`.  Therefore, we can
move the code into the caller.

Differential Revision: https://phabricator.services.mozilla.com/D115173
2021-05-18 05:06:54 +00:00
Butkovits Atila f3f08e64ba Backed out 2 changesets (bug 1520983) for causing build bustages. CLOSED TREE
Backed out changeset c09060ee8358 (bug 1520983)
Backed out changeset b4c25d047cee (bug 1520983)
2021-05-18 07:47:57 +03:00
Masayuki Nakano 01872d6254 Bug 1627175 - part 63: Get rid of `HTMLEditor::IsNextCharInNodeWhiteSpace()` r=m_kato
Similarly, it's called only by `HTMLEditor::GetWhiteSpaceEndPoint()` and
it returns after point of last white-space if and only if the given point
container is a text node and the offset is not end of the text node.
Therefore, we can reimplement it in the caller simply.

Differential Revision: https://phabricator.services.mozilla.com/D115172
2021-05-18 02:05:34 +00:00
Masayuki Nakano 1bb2df9ea3 Bug 1520983 - part 1: Add new content command event for inserting text r=smaug
For inserting text from OS in special cases, e.g., when inserting 2 or more characters
per keydown or inserting text without key press, we use a set of composition events on
macOS, but the other browsers don't use composition events.  Instead, they expose only
`beforeinput` event and `input` event.  We should follow their behavior for web-compat
because `beforeinput` events for IME composition are never cancelable, but the
`beforeinput` events for the cases are cancelable of the other browsers.

Differential Revision: https://phabricator.services.mozilla.com/D114826
2021-05-17 23:52:43 +00:00
Masayuki Nakano f1b447b280 Bug 1627175 - part 62: Get rid of `HTMLEditor::IsPrevCharInNodeWhiteSpace()` r=m_kato
It's used only by `HTMLEditor::GetWhiteSpaceEndPoint()` and it just skips
white-spaces and returns first white-space position if and only if the
given point container is a text node and its previous character is a
white-space.  Therefore, it can be rewritten with `EditorDOMPoint` simply in
the caller.

Differential Revision: https://phabricator.services.mozilla.com/D115171
2021-05-17 22:25:30 +00:00
Masayuki Nakano bc318df1a4 Bug 1627175 - part 61: Get rid of `HTMLEditor::NodesInDifferentTableElements()` r=m_kato
Despite its name, it checks whether both given nodes are in same/no table
structure element or not.  For avoiding this confusion, let's add
`GetInclusiveAncestorAnyTableElement()` to `HTMLEditUtils` and compare
the result of its calls with 2 content nodes.

Differential Revision: https://phabricator.services.mozilla.com/D115170
2021-05-17 22:19:05 +00:00
Masayuki Nakano 57b8116405 Bug 1627175 - part 60: Move `HTMLEditor::GetNearestAncestorListItemElement()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115169
2021-05-17 22:12:13 +00:00
Masayuki Nakano 796828cb75 Bug 1627175 - part 59: Move `HTMLEditor::GetMostAncestorInlineElement()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115168
2021-05-17 21:58:10 +00:00
Masayuki Nakano e0baad182c Bug 1627175 - part 58: Move `HTMLEditor::IsEmptyBlockElement()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115167
2021-05-17 21:50:39 +00:00
Masayuki Nakano 0c4f51fb31 Bug 1627175 - part 57: Move `HTMLEditor::GetBetterInsertionPointFor()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115166
2021-05-17 08:56:26 +00:00
Masayuki Nakano 30a75921ad Bug 1627175 - part 56: Move `HTMLEditor::GetGoodCaretPointFor()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115165
2021-05-17 08:44:24 +00:00
Masayuki Nakano b6ea40871b Bug 1627175 - part 55: Move `HTMLEditor::IsEmptyInlineNode()` and `HTMLEditor::IsEmptyOneHardLine()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115164
2021-05-17 08:38:55 +00:00
Masayuki Nakano 249be2b40e Bug 1627175 - part 54: Merge `HTMLEditor::Get(First|Last)EditableLeaf()` into `HTMLEditUtils::Get(First|Last)LeafContent()` r=m_kato
The different points are, whether it checks in a given element or not, and
whether it ignores non-editable content.  Therefore, this patch adds new
`LeafNodeType` and new ancestor limiter argument.

The new flag is not handled in the other methods which take `LeafNodeType`
because there is no test.

Differential Revision: https://phabricator.services.mozilla.com/D115123
2021-05-17 08:01:38 +00:00
Masayuki Nakano d6eec3ae11 Bug 1627175 - part 53: Rename `HTMLEditUtils::GetFirstLeafChild()` and `HTMLEditUtils::GetLastLeafChild()` r=m_kato
They may return a descendant, and now `HTMLEditUtils` has some methods whose
name ends with `Child` and they scan only direct children of given node.
So, we should rename these methods for avoiding misunderstanding.

Differential Revision: https://phabricator.services.mozilla.com/D115122
2021-05-17 08:01:37 +00:00
Masayuki Nakano 83505534d9 Bug 1627175 - part 52: Move `HTMLEditor::IsLastEditableChild()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115121
2021-05-17 07:42:40 +00:00
Masayuki Nakano f852818779 Bug 1627175 - part 51: Move `HTMLEditor::IsFirstEditableChild()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115120
2021-05-17 07:28:43 +00:00
Masayuki Nakano cecdac0aa5 Bug 1627175 - part 50: Move `HTMLEditor::GetFirstEditableChild()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115119
2021-05-17 07:08:39 +00:00
Masayuki Nakano 228c4e9b85 Bug 1627175 - part 49: Move `HTMLEditor::GetLastEditableChild()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115118
2021-05-17 05:44:34 +00:00
Masayuki Nakano 91727d78a7 Bug 1627175 - part 48: Get rid of `HTMLEditUtils::GetFirstEditableLeafContent()` due to unused r=m_kato
I realized that it's used only by the dead path because the only caller,
`EditorBase::BeginningOfDocument()` is overridden by `HTMLEditor` and
is never called.

Differential Revision: https://phabricator.services.mozilla.com/D115117
2021-05-17 05:37:24 +00:00
Masayuki Nakano c2b6acf141 Bug 1627175 - part 47: Move `HTMLEditor::GetNextHTMLSibling()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115116
2021-05-17 05:25:04 +00:00
Masayuki Nakano 1d94e91f3f Bug 1627175 - part 46: Move `HTMLEditor::GetPriorHTMLSibling()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D115115
2021-05-17 03:05:13 +00:00
Masayuki Nakano e2a6a7ae0b Bug 1627175 - part 45: Add helper methods which test found `<br>` element visibility to `WSRunScanner` and `WSScanResult` r=m_kato
This must make the callers of `HTMLEditUtils::IsVisibleBRElement()` and
`HTMLEditUtils::IsInvisibleBRElement()` easier to read.

Depends on D114933

Differential Revision: https://phabricator.services.mozilla.com/D114934
2021-05-13 13:44:04 +00:00
Masayuki Nakano b9607b64d3 Bug 1627175 - part 44: Add `HTMLEditUtils::IsInvisibleBRElement()` for avoiding a mistake r=m_kato
When I review patches, sometimes I saw wrong usage of `!IsVisibleBRElement()`.
It means that it's an invisible <br> element **or** non-<br> element node,
but developers may think it checks whether it's an invisible `<br>` element
or not without checking the specifying content is a <br> element.

For avoiding this, there should be `IsInvisibleBRElement()` too.

Depends on D114932

Differential Revision: https://phabricator.services.mozilla.com/D114933
2021-05-13 06:46:24 +00:00
Masayuki Nakano 6c9c8af840 Bug 1627175 - part 43: Move `HTMLEditor::IsVisibleBRElement()` to `HTMLEditUtils::IsVisibleBRElement()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D114932
2021-05-13 06:02:34 +00:00
Makoto Kato 6c788dbaf0 Bug 1708670 - nsIEditor.pasteTransferable won't insert image/png if nsITransaferable uses nsIInputStream. r=masayuki
editor.pastedTransferable cannot insert image/png when using nsITransaferable.

Although pastedTransferable stores DataTransfer in stack, when mime type is
image/png, DataTransfer fetches all data in
DataTransferItem::FillInExternalData then stores it as `KIND_FILE`.
It means that nsIInputStream in nsITransferable is already EOF.

So we should use InsertFromDataTransfer when internal data moves to
DataTransfer.

Differential Revision: https://phabricator.services.mozilla.com/D114702
2021-05-11 09:47:09 +00:00
Matt Woodrow a6d0dff2b5 Bug 1707513 - Add 'drawSnapshot' mode to reftest harness, and annotate all current failures. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D114188
2021-05-10 00:28:01 +00:00
Alexandru Michis 4b2cad43d1 Backed out 2 changesets (bug 1707513) for causing reftest failures in partial-prerender-expansion-with-resolution-1.html
Backed out changeset f9bdd1b929f2 (bug 1707513)
Backed out changeset b76d28f3a159 (bug 1707513)
2021-05-08 22:13:23 +03:00
Matt Woodrow a77dc2167d Bug 1707513 - Add 'drawSnapshot' mode to reftest harness, and annotate all current failures. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D114188
2021-05-08 05:52:19 +00:00
Masayuki Nakano 812ed2fc52 Bug 1707630 - part 3: Make `EditorBase::CreateNodeWithTransaction()` return error if failed r=m_kato
Depends on D113473

Differential Revision: https://phabricator.services.mozilla.com/D113474
2021-04-28 03:33:26 +00:00
Masayuki Nakano 39b71b059e Bug 1707630 - part 2: Make `HTMLEditor::PrepareToInsertBRElement()` return error if failed r=m_kato
Depends on D113472

Differential Revision: https://phabricator.services.mozilla.com/D113473
2021-04-28 03:33:26 +00:00
Masayuki Nakano 867fd9ab9a Bug 1707630 - part 1: Make `HTMLEditor::InsertBREelementWithTransaction()` return error when it fails r=m_kato
The testcase hits the assertion because `CreateNodeTransaction::DoTransaction()`
returns error, but it's not handled by `HandledInsertParagraphInParagraph()`
so that we should make `InsertBRElementWithTransaction()` and its callees
should return error if they meet unexpected cases.

Depends on D113471

Differential Revision: https://phabricator.services.mozilla.com/D113472
2021-04-28 03:33:25 +00:00
Masayuki Nakano a6ae919f0e Bug 1707630 - Fix the crash with a one line fix r=m_kato
For making it's upliftable, this patch just fixes the crash with a one line fix.

Depends on D113282

Differential Revision: https://phabricator.services.mozilla.com/D113471
2021-04-28 03:33:25 +00:00
Masayuki Nakano ebf2dd010f Bug 1627175 - part 42: Get rid of `HTMLEditor::GetNextEditableHTMLNode()` and `HTMLEditor::GetPreviousEditableHTMLNode()` r=m_kato
This changes the logic of `HTMLEditor::GetFirstEditableLeaf()` and
`HTMLEditor::GetLastEditableLeaf()`, but it shouldn't change actual behavior
because the case is that the first/last child of `aNode` is not in editing
host but editable.

Differential Revision: https://phabricator.services.mozilla.com/D113282
2021-04-27 23:45:49 +00:00
Masayuki Nakano 655c27c32b Bug 1627175 - part 41: Get rid of `HTMLEditor::GetNextEditableHTMLNodeInBlock()` and `HTMLEditor::GetPreviousEditableHTMLNodeInBlock()` r=m_kato
Depends on D113280

Differential Revision: https://phabricator.services.mozilla.com/D113281
2021-04-27 21:13:43 +00:00
Masayuki Nakano 5f2961c2f7 Bug 1627175 - part 40: Get rid of `HTMLEditor::GetNextHTMLElementOrText()` and `HTMLEditor::GetPreviousHTMLElementOrText()` and their internal methods r=m_kato
Depends on D113279

Differential Revision: https://phabricator.services.mozilla.com/D113280
2021-04-27 14:03:17 +00:00
Masayuki Nakano 0187400c5b Bug 1627175 - part 39: Get rid of `HTMLEditor::GetNextHTMLElementOrTextInBlock()` and `HTMLEditor::GetPreviousHTMLElementOrTextInBlock()` r=m_kato
Depends on D113242

Differential Revision: https://phabricator.services.mozilla.com/D113279
2021-04-27 11:56:34 +00:00
Masayuki Nakano 3aef835f6c Bug 1627175 - part 38: Move `EditorBase::GetNextContent()` and `EditorBase::GetPreviousContent()` to `HTMLEditUtils` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D113242
2021-04-27 11:17:44 +00:00
Masayuki Nakano 7da0836039 Bug 1627175 - part 37: Get rid of editor type argument from `EditorBase::GetNextContent()` and `EditorBase::GetPreviousContent()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D113241
2021-04-27 11:17:43 +00:00
Masayuki Nakano 267025f6e5 Bug 1627175 - part 36: Make `EditorBase::CreateTransactionForCollapsedRange()` use `EditorBase::GetNextContent()` and `EditorBase::GetPreviousContent()` only when it's an `HTMLEditor` r=m_kato
If the editor instance is a `TextEditor`, the root element has to be
anonymous `<div>` element and it has only one text node when it has non-empty
value.  Therefore, if it's in `TextEditor`, the method does not need to use
the complicated APIs for finding a text node from the anonymous `<div>` element
or padding `<br>` element since it can adjust the given point into the text
node without such API.

Differential Revision: https://phabricator.services.mozilla.com/D113240
2021-04-27 11:17:43 +00:00
Masayuki Nakano 4e78552ddb Bug 1627175 - part 35: Move `EditorBase::GetFirstEditableNode()` into `HTMLEditUtils` r=m_kato
Only the user is `EditorBase::BeginningOfDocument()` which is used by both
`TextEditor` and `HTMLEditor`.  However, if it's a `TextEditor`, expected
result is only the first text node only when there is one.  Therefore, we can
move it into `HTMLEditUtils` and make `EditorBase::BeginningOfDocument()`
find the text node by it self.  Then, we can get rid of using
`EditorBase::GetEditorType()` in this case.

Differential Revision: https://phabricator.services.mozilla.com/D113239
2021-04-27 11:17:43 +00:00
Masayuki Nakano 1b0d3e96c4 Bug 1627175 - part 34: Make `EditorBase::GetNextContent()` and `EditorBase::GetPreviousContent()` static r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D113238
2021-04-27 11:17:42 +00:00
Masayuki Nakano 4debffd39d Bug 1627175 - part 33: Make `EditorBase::FindNode()` and `EditorBase::FindNextLeafNode()` static r=m_kato
They are instance members of `EditorBase` only for referring editor type and
editing host.  Therefore, we can make them static with making them take
editor type and ancestor limiter as arguments.

Depends on D113236

Differential Revision: https://phabricator.services.mozilla.com/D113237
2021-04-27 11:17:42 +00:00
Masayuki Nakano 3cfc86a155 Bug 1627175 - part 32: Get rid of `EditorBase::GetNextNodeInBlock()` and `EditorBase::GetPreviousNodeInBlock()` r=m_kato
Depends on D113235

Differential Revision: https://phabricator.services.mozilla.com/D113236
2021-04-27 11:17:41 +00:00
Masayuki Nakano 1cc0a524f6 Bug 1627175 - part 31: Get rid of `EditorBase::GetNextEditableNode()` and `EditorBase::GetPreviousEditableNode()` r=m_kato
Depends on D113234

Differential Revision: https://phabricator.services.mozilla.com/D113235
2021-04-27 11:17:41 +00:00
Masayuki Nakano eb26e869e5 Bug 1627175 - part 30: Get rid of `EditorBase::GetNextEditableNodeInBlock()` and `EditorBase::GetPreviousEditableNodeInBlock()` r=m_kato
Depends on D113233

Differential Revision: https://phabricator.services.mozilla.com/D113234
2021-04-27 11:17:41 +00:00
Masayuki Nakano 3f701eb0f4 Bug 1627175 - part 29: Get rid of `EditorBase::GetNextElementOrTextInBlock()` and `EditorBase::GetPreviousElementOrTextInBlock()` r=m_kato
Depends on D113232

Differential Revision: https://phabricator.services.mozilla.com/D113233
2021-04-27 11:17:40 +00:00
Masayuki Nakano 4a928f25f7 Bug 1627175 - part 28: Get rid of `EditorBase::GetNextElementOrText()` and `EditorBase::GetPreviousElementOrText()` r=m_kato
Depends on D113231

Differential Revision: https://phabricator.services.mozilla.com/D113232
2021-04-27 11:17:40 +00:00
Masayuki Nakano 7a2d02c10f Bug 1627175 - part 27: Get rid of `EditorBase::GetNextNode()` and `EditorBase::GetPreviousNode()` r=m_kato
Depends on D113230

Differential Revision: https://phabricator.services.mozilla.com/D113231
2021-04-27 11:17:39 +00:00
Masayuki Nakano 82aa5b8992 Bug 1627175 - part 26: Rename `EditorBase::Get*NodeInternal()` to `Get*Content()` r=m_kato
The following patches will get rid of inline wrapper methods of them.
Therefore, they shouldn't be called as "internal".  And they return
`nsIContent*` instead of `nsINode*` so, `Get*Content()` is better name for
them.

Depends on D113229

Differential Revision: https://phabricator.services.mozilla.com/D113230
2021-04-27 11:17:39 +00:00
Masayuki Nakano a525512d98 Bug 1627175 - part 25: Rename `WalkTreeOption::FindAnyDataNode` to `WalkTreeOption::IgnoreDataNodeExceptText` r=m_kato
So, the meaning is reverted of this action.  But with this change, the scanner
methods scans any nodes by default.  This is simpler to understand from the
callers.

Depends on D113228

Differential Revision: https://phabricator.services.mozilla.com/D113229
2021-04-27 11:17:39 +00:00
Masayuki Nakano 8eb9f61b5e Bug 1627175 - part 24: Make `EditorBase::FindNode` and `EditorBase::Get*NodeInternal()` take an `EnumSet` instead of multiple `bool` arguments r=m_kato
Before moving them from `EditorBase`, they should take only one option argument
whose type is an `EnumSet` class.

Note that I wanted to name each option for optional behavior, but
`FindAnyDataNode` requires to revert the its meaning  (I.e., only with this
patch, `true` should be set an option).  Therefore, the following patch renames
it.

Differential Revision: https://phabricator.services.mozilla.com/D113228
2021-04-27 11:17:38 +00:00
Masayuki Nakano dc502df61b Bug 1703561 - Make `HTMLEditor` not allow to modify content nodes in `<select>` element r=m_kato
Like the other browsers, we shouldn't allow to user modify content in
`<select>` element.  Note that this case won't occur with moving caret
with input devices.  This occurs only with Selection API.

FYI: Chrome deletes `<select>` element if children of it are selected,
but it's odd behavior since user don't see where is selected visually
and may cause unexpected data loss (i.e., deleting `<select>` element).

Perhaps, we should investigate the behavior in other replaced elements
like `<textarea>` etc in follow up bugs.

Depends on D112513

Differential Revision: https://phabricator.services.mozilla.com/D112517
2021-04-20 12:07:15 +00:00
Masayuki Nakano d39859eba7 Bug 1627175 - part 23: Move `HTMLEditor::IsEmptyNode()` into `HTMLEditUtils` with making it take `EnumSet` instead of `bool` arguments r=m_kato
It's hard to understand each caller of `HTMLEditor::IsEmptyNode()` tries to
check with multiple `bool` arguments.  Therefore, they should be replaced
with an `EnumSet`.

Note that only the first argument is reverted the meaning.  Therefore, if
it's omitted or `false`, `EmptyCheckOption::TreatSingleBRElementAsVisible`
is specified explicitly.  Otherwise, i.e., `true`, nothing should be
specified.

Differential Revision: https://phabricator.services.mozilla.com/D112513
2021-04-20 12:02:17 +00:00
Masayuki Nakano 1ce7f565ac Bug 1627175 - part 22: Get rid of `HTMLEditor::IsEmptyTextNode()` r=m_kato
It returns true only when it's a text node, but the text is empty.
However, `HTMLEditUtils::IsVisibleTextNode()` is used in
`HTMLEditor::IsEmptyNodeImpl()`.  So, we replace it with directly using
`HTMLEditUtils::IsVisibleTextNode()`.

Depends on D112511

Differential Revision: https://phabricator.services.mozilla.com/D112512
2021-04-20 02:00:15 +00:00
Masayuki Nakano 96ee002082 Bug 1627175 - part 21: Move `HTMLEditor::IsInVisibleTextFrames()` to `HTMLEditUtils` r=m_kato
Depends on D112510

Differential Revision: https://phabricator.services.mozilla.com/D112511
2021-04-20 00:41:25 +00:00
Masayuki Nakano fd48bf5244 Bug 1627175 - part 20: Move `HTMLEditor::IsEmptyTextNode()` to `HTMLEditUtils` r=m_kato
Now, it does not depend on `HTMLEditor`.  So, we can move it into the
`HTMLEditUtils`.

Depends on D112509

Differential Revision: https://phabricator.services.mozilla.com/D112510
2021-04-20 00:41:24 +00:00
Masayuki Nakano 91572af027 Bug 1705598 - part 8: Make `WSRunScanner::AutoInclusiveAncestorBlockElementsJoiner()` take editing host instead of `HTMLEditor` r=m_kato
Depends on D112508

Differential Revision: https://phabricator.services.mozilla.com/D112509
2021-04-19 23:25:47 +00:00
Masayuki Nakano 16c03a3b47 Bug 1705598 - part 7: Make `WSRunScanner::GetRangeContainingInvisibleWhiteSpacesAtRangeBoundaries()` take editing host instead of `HTMLEditor` r=m_kato
Depends on D112507

Differential Revision: https://phabricator.services.mozilla.com/D112508
2021-04-19 23:25:47 +00:00
Masayuki Nakano 7c39f920b9 Bug 1705598 - part 6: Make `WSRunScanner::GetRangesForDeletingAtomicContent()` take editing host instead of `HTMLEditor` r=m_kato
Depends on D112506

Differential Revision: https://phabricator.services.mozilla.com/D112507
2021-04-19 23:25:46 +00:00
Masayuki Nakano 73372428c9 Bug 1705598 - part 5: Make `WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom()` and `WSRunScanner::GetRangeInTextNodesToBackspaceFrom()` take editing host instead of `HTMLEditor` r=m_kato
Depends on D112505

Differential Revision: https://phabricator.services.mozilla.com/D112506
2021-04-19 23:25:46 +00:00
Masayuki Nakano dd0159dcf3 Bug 1705598 - part 4: Make `WSRunScanner::ScanNextVisibleNodeOrBlockBoundary()` and `WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary()` take editing host instead of `HTMLEditor` r=m_kato
Depends on D112504

Differential Revision: https://phabricator.services.mozilla.com/D112505
2021-04-19 23:25:46 +00:00
Masayuki Nakano 265f751419 Bug 1705598 - part 3: Make `WSRunScanner::GetPreviousEditableCharPoint()` and `WSRunScanner::GetInclusiveNextEditableCharPoint()` take editing host instead of `HTMLEditor` r=m_kato
Depends on D112503

Differential Revision: https://phabricator.services.mozilla.com/D112504
2021-04-19 23:25:45 +00:00
Masayuki Nakano a7b87b61b1 Bug 1705598 - part 2: Make the constructor of `WSRunScanner` take editing host instead of `HTMLEditor` r=m_kato
I think that it's no matter to make `WSRunScanner` work without editing host.
Therefore, this patch make it take pointer of `Element` rather than reference.

Depends on D112502

Differential Revision: https://phabricator.services.mozilla.com/D112503
2021-04-19 23:25:45 +00:00
Masayuki Nakano 9227d30f9b Bug 1705598 - part 1: Get rid of `WSRunScanner::mHTMLEditor` r=m_kato
It's not referred by anybody.

Differential Revision: https://phabricator.services.mozilla.com/D112502
2021-04-19 23:25:45 +00:00
Masayuki Nakano d8194cbbea Bug 1704381 - part 3: Add automated test r=m_kato
Depends on D111580

Differential Revision: https://phabricator.services.mozilla.com/D111581
2021-04-13 05:54:49 +00:00
Masayuki Nakano 1d08839089 Bug 1704381 - part 2: Make `AutoEditActionDataSetter` not store whether editor is destroyed after handling its edit action r=m_kato
Currently, its `mEditorWasDestroyed` is set to true even while `input` event
is being dispatched, i.e., even when it finished everything for the edit action.
However, the flag should be only for blocking unexpected cause which is caused
by mutation event listeners or something other unexpected event listeners
which shouldn't be run while editor is handling an edit action.

Therefore, this patch makes it store "handled" state which is marked before
notifying editor observers and dispatching `input` event and the flag won't
be set to true after it's marked as "handled".

Depends on D111579

Differential Revision: https://phabricator.services.mozilla.com/D111580
2021-04-13 05:54:49 +00:00
Masayuki Nakano 518cbe163b Bug 1704381 - part 1: Make `EditorBase::Init` set edit action to `EditAction::eInitializing` r=m_kato
I forgot to do this in `EditorBase::Init`. Therefore, it fails at synchronous
reinitializing during an edit action.

Differential Revision: https://phabricator.services.mozilla.com/D111579
2021-04-13 05:54:49 +00:00
Masayuki Nakano 762db8b745 Bug 1691051 - Make edit action data which is being handled manage whether the editor was temporarily destroyed or not r=m_kato
The editing session is temporarily disabled when opening a document.  Then,
when the document is closed, the editing session is restored with same
`HTMLEditor` instance.  Therefore, initializing editor may occur during
an edit action is being handled.

Probably, this must not be used in normal webapps since mutation events are
used rarely.  So, I think that for avoiding further complicated things, we
should make editor won't accept new edit action handling after original
editing session ended.

This patch renames `AutoEditActionDataSetter::CanHandle()` to
`IsDataAvailable()` since it just checks whether the important resource is
available or not.  And makes new `CanHandle()` return `false` for
non-initializing edit actions if editing session has ended.

Differential Revision: https://phabricator.services.mozilla.com/D111241
2021-04-09 06:59:54 +00:00
Masayuki Nakano 46da3502b3 Bug 1699866 - Make `HTMLEditor::SplitAncestorStyledInlineElementsAt` return "not handled" if there is no splitable element at given point r=m_kato
When given point is **in** a void element, e.g., this can be when JS inserts
nodes into a void element like `<meta>`,
`HTMLEditor::SplitNodeDeepWithTransaction` may return "not handled" state.
So, it's possible case, we shouldn't assert the case.

This patch adds both WPT and crashtests because I couldn't reproduce it
with WPT's simpler API use.

Differential Revision: https://phabricator.services.mozilla.com/D111231
2021-04-09 02:34:23 +00:00
Masayuki Nakano 74d01e2a81 Bug 1701348 - Make `TextEditor::Init()` and `HTMLEditor::Init()` stop using `EditAction::eNotEditing` r=m_kato
Currently, they set `EditAction::eNotEditing` even though they may create a
paddning `<br>` element.  If there is already handling edit action, setting
`eNotEditing` makes inherit the parent edit action.
https://searchfox.org/mozilla-central/rev/be413c29deeb86be6cdac22445e0d0b035cb9e04/editor/libeditor/EditorBase.cpp#5150-5159

However, in the reported case, `FlushPendingNotificationsIfToHandleDeletionWithFrameSelection()`
is called for computing target ranges at `forwarddelete` command handling.
In this case, `EditAction::eDeleteSelection` or something is set as parent
edit action.
https://searchfox.org/mozilla-central/rev/be413c29deeb86be6cdac22445e0d0b035cb9e04/editor/libeditor/EditorBase.cpp#3638-3660
But at this moment, `beforeinput` event hasn't been dispatched.  Then,
initializing code inherits this state and trying to insert a padding `<br>`
element without `beforeinput` event.  Then, we hit the assertion.

For solving this issue, `Init` methods should set edit action to "initializing"
and it should be marked as not requiring `beforeinput` event.

Differential Revision: https://phabricator.services.mozilla.com/D111191
2021-04-08 08:51:41 +00:00
Masayuki Nakano 0175ca9bc4 Bug 1649639 - Add WPT and remove unnecessary `MOZ_ASSERT` of `HTMLEditor::ClearStyleAt` r=m_kato
When the method detects the style coming from a parent block, the `MOZ_ASSERT`
checks whether the current mode is "style with CSS" or not because currently,
`HTMLEditor` does not use `<span>` with CSS when the mode is not "style with
CSS".  However, fixing it requires bigger patch, and the change does not match
with the bug's summary.  So, I just remove the `MOZ_ASSERT`, add WPT and filed
bug 1649639 for the root issue.

Differential Revision: https://phabricator.services.mozilla.com/D111067
2021-04-08 07:49:53 +00:00
Masayuki Nakano 4bd57eadd1 Bug 1703144 - Get rid of `MOZ_KnownLive` for `EditorBase::SelectionRefPtr()` r=m_kato
The lifetime of it is guaranteed by `AutoEditActionDataSetter` which grabs
`Selection` until it's destroyed, and it's a stack only class and created
at first step of all public method calls.  Therefore, we can mark it as
`MOZ_KNOWN_LIVE` and we can change it returning reference of `Selection`
instead of reference of `RefPtr<Selection>`.

Differential Revision: https://phabricator.services.mozilla.com/D110896
2021-04-08 01:31:54 +00:00
Masayuki Nakano e1298d770d Bug 1697876 - part 2: Make `EditorBase::EndPlaceholderTransaction()` release placeholder transaction and related stuff before dispatching `input` event r=m_kato
Currently, it dispatches `input` event with holding `mPlaceholderTransaction`
and `mPlaceholerBatch` as 1.  If `input` event listener sets value in XUL
document, the setting value transaction will break the existing placeholder
transaction.  Then, only the last one will be undone, and it causes inserting
new padding `br` element with transaction and clears redo history.

This patch makes it forget them before dispatching `input` event.

Note that I tried to create automated test for this, but I cannot reproduce
this with simple testcase.  I guess something other things also required to
reproduce this bug.

Differential Revision: https://phabricator.services.mozilla.com/D110715
2021-04-05 11:35:49 +00:00
Masayuki Nakano 119be8e287 Bug 1697876 - part 1: Add logging code to transaction classes for making easier to debug r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D110714
2021-04-05 11:35:48 +00:00
Masayuki Nakano cbb83f40f6 Bug 1655988 - Fix assertion in `WhiteSpaceVisibilityKeeper::MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()` r=m_kato
This is a bug of the assertion.

When there is 2 text nodes are adjacent, one ends with a visible character and
the other starts with a white-space, and the deleting range ends at end of the
first one, `GetReplaceRangeDataAtEndOfDeletionRange()` returns a range starting
with the start of the second one since it does not need to touch the first one.
Therefore, the white-space range start may be after the deleting range end.

This patch adds new condition to the `MOZ_ASSERT_IF`, and test this specific
case with new `MOZ_ASSERT_IF`.

Differential Revision: https://phabricator.services.mozilla.com/D110068
2021-03-30 06:09:23 +00:00
Masayuki Nakano d68f6fc838 Bug 1220696 - part 6: Support `insertLineBreak` and `insertParagraphSeparator` commands in `<textarea>` r=smaug
Those command handlers just check whether the given editor is an `HTMLEditor`
or not.  Therefore, we should make them check whether the given editor is
a single line editor or not instead.

Differential Revision: https://phabricator.services.mozilla.com/D108572
2021-03-24 01:55:09 +00:00
Masayuki Nakano fad3ed3447 Bug 1220696 - part 5: Support "contentReadOnly" and "getHTML" commands in `<input>` and `<textarea>` r=smaug
Although these commands supported supported only by Gecko, we shouldn't stop
supporting them unless we know the usage in the wild.  Therefore, this patch
adds the handling code for `TextEditor` too.

Differential Revision: https://phabricator.services.mozilla.com/D108571
2021-03-24 01:55:09 +00:00
Masayuki Nakano f956ee81ea Bug 1220696 - part 3: Make `AutoEditorCommandTarget` consider command handling editor with command and focused `TextEditor` or `HTMLEditor` r=smaug
For making `execCommand` and related methods with `<input>` and `<textarea>`
even if they are in `contenteditable` and focused, command should be handled
in active editor (focused editor if in foreground window and tab).

However, some commands should be handled by `HTMLEditor` even if an `TextEditor`
has focus.  Therefore, this patch adds new enum class which have 3 state into
`InternalCommandData` and makes `AutoEditorCommandTarget` consider it with the
enum class.

Note that the new failures about `contentReadOnly` command will be fixed by
a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D108569
2021-03-24 01:55:08 +00:00
Butkovits Atila 3361c11f7d Backed out 7 changesets (bug 1220696) for causing build bustages. CLOSED TREE
Backed out changeset 1ad2d5c0f253 (bug 1220696)
Backed out changeset 5e2f62a11d95 (bug 1220696)
Backed out changeset 07012ed7a30e (bug 1220696)
Backed out changeset a4e90de9355d (bug 1220696)
Backed out changeset 63ec6c3d05fd (bug 1220696)
Backed out changeset f165f45f8e1a (bug 1220696)
Backed out changeset ade95bf58db4 (bug 1220696)
2021-03-24 01:34:56 +02:00
Masayuki Nakano 9892a73421 Bug 1220696 - part 6: Support `insertLineBreak` and `insertParagraphSeparator` commands in `<textarea>` r=smaug
Those command handlers just check whether the given editor is an `HTMLEditor`
or not.  Therefore, we should make them check whether the given editor is
a single line editor or not instead.

Differential Revision: https://phabricator.services.mozilla.com/D108572
2021-03-23 19:29:23 +00:00
Masayuki Nakano 843cdb6b35 Bug 1220696 - part 5: Support "contentReadOnly" and "getHTML" commands in `<input>` and `<textarea>` r=smaug
Although these commands supported supported only by Gecko, we shouldn't stop
supporting them unless we know the usage in the wild.  Therefore, this patch
adds the handling code for `TextEditor` too.

Differential Revision: https://phabricator.services.mozilla.com/D108571
2021-03-23 19:29:23 +00:00
Masayuki Nakano fc94975380 Bug 1220696 - part 3: Make `AutoEditorCommandTarget` consider command handling editor with command and focused `TextEditor` or `HTMLEditor` r=smaug
For making `execCommand` and related methods with `<input>` and `<textarea>`
even if they are in `contenteditable` and focused, command should be handled
in active editor (focused editor if in foreground window and tab).

However, some commands should be handled by `HTMLEditor` even if an `TextEditor`
has focus.  Therefore, this patch adds new enum class which have 3 state into
`InternalCommandData` and makes `AutoEditorCommandTarget` consider it with the
enum class.

Note that the new failures about `contentReadOnly` command will be fixed by
a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D108569
2021-03-23 19:29:22 +00:00
Mirko Brodesser 814b998fc2 Bug 1698786: part 4) Add some logging to `EditorSpellChecker`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D108624
2021-03-18 09:33:22 +00:00
Jonathan Kew 0bf4eb7c5d Bug 1698734 - Don't create an EventListenerManager just to check for existing listeners. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D108612
2021-03-16 12:49:44 +00:00
Makoto Kato 605d5484aa Bug 1692052 - Don't notify IMEContext of widget when IMEStateManger doesn't manage this content. r=masayuki
This test case doesn't generate body element and isn't general case. Actually
since we don't manage current IME focus on IMEStateManager, we shouldn't notify
IMEContext of widget.

Differential Revision: https://phabricator.services.mozilla.com/D108366
2021-03-15 09:31:58 +00:00
Jonathan Kew a9143c6051 Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-12 16:34:42 +00:00
Jonathan Kew 4fec409fa9 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-12 16:34:42 +00:00
Brindusan Cristian b073741c99 Backed out 3 changesets (bug 1692673) for bc failures in browser_contextmenu_input.js. CLOSED TREE
Backed out changeset 6060fa16bc3e (bug 1692673)
Backed out changeset 0f6717c26ae3 (bug 1692673)
Backed out changeset 8148b9e5dfba (bug 1692673)
2021-03-12 16:07:49 +02:00
Jonathan Kew 5eda87fe7b Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-12 12:04:08 +00:00
Jonathan Kew 91adcd2694 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-12 12:04:07 +00:00
Csoregi Natalia 46c0e3eebc Backed out 2 changesets (bug 1692673) for failures on browser_contextmenu.js. CLOSED TREE
Backed out changeset dd24e610d956 (bug 1692673)
Backed out changeset b88ab8c6dd39 (bug 1692673)
2021-03-11 23:27:31 +02:00
Jonathan Kew ba5722b476 Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-11 16:16:34 +00:00
Jonathan Kew e3ad8e8158 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-11 16:16:33 +00:00
Butkovits Atila 479d6f893c Backed out 2 changesets (bug 1692673) for causing build bustages on EditorBase.cpp. CLOSED TREE
Backed out changeset 988b919adc5c (bug 1692673)
Backed out changeset 5b1ba8dbfc8a (bug 1692673)
2021-03-11 12:43:24 +02:00
Jonathan Kew ba23557a7e Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-11 10:27:04 +00:00
Jonathan Kew 24a5b45445 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-11 10:27:04 +00:00
Masayuki Nakano 18e444a223 Bug 1697249 - Stop creating `<span>` element for keeping same style as the link when the link will be unlinked r=m_kato
When typing at edge of a link, editor splits the link element at the edge (i.e.,
creating an empty link element).  Then, unlink the new link element (i.e.,
clearing the "link style").  At this time, `class` attribute and `style`
attribute are cloned to new `<span>` element for keeping the original style.
However, in this case, other browsers discard the specified style of the link.

On the other hand, when unlinking a link with `execCommand("unlink")`, the
other browsers keep specified style coming from `style` attribute.

Therefore, this patch adds new state to `PropItem`, which indicates whether
the `class` and `style` attribute should be cloned or discarded.  And then,
when preparing for inserting text, this patch makes it pass to the utility
method.

For better compatibility, we should stop cloning `class` attribute, but not
in this bug because this patch should be minimized for requesting uplift to
beta channel.

Differential Revision: https://phabricator.services.mozilla.com/D107801
2021-03-11 07:19:33 +00:00
Jonathan Kew ceb44d34d6 Bug 1664730 - Disable async font fallback when running mochitests, to avoid unpredictable extra reflows that can disrupt event-/timing-sensitive tests. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D107284
2021-03-10 12:26:52 +00:00
Masayuki Nakano 468bffc558 Bug 1429523 - Make IMEContentObserver ignore character data change notifications of invisible data nodes r=smaug
E.g., comment node is an invisible data node, and it's not handled by
`HTMLEditor` nor `ContentEventHandler`.  Therefore, `IMEContentObserver`
should ignore invisible data nodes, which are not derived from `dom::Text`.

Differential Revision: https://phabricator.services.mozilla.com/D107590
2021-03-09 23:57:56 +00:00
Masayuki Nakano eec5dff65e Bug 1655539 - Add crash test (the bug itself is fixed by the patch for bug 1677566) r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D107589
2021-03-09 23:57:55 +00:00
Masayuki Nakano 7af10cee55 Bug 1677566 - part 3: Ignore non-deletable ranges in `HTMLEditor::HandleDeleteSelection()` r=m_kato
For making delete handlers simpler, and set better target ranges to the
corresponding `beforeinput` event, we should ignore non-editable ranges
before handling deletion.

This patch makes editor stop handling deleteion when a range crosses editing
host boundaries.  In this case, Gecko has done nothing, but fired
`beforeinput` event.  Note that Blink deletes editable contents in the range
**until** it meets first non-editable content, but I don't think this is
a good behavior because it makes things complicated.  Therefore, I filed
a spec issue: https://github.com/w3c/editing/issues/283

On the other hand, this behavior change causes different behavior in
https://searchfox.org/mozilla-central/source/editor/libeditor/crashtests/1345015.html

It tries to insert paragraph into `<html>` element, but our editor currently
does not support it.  Therefore, it hits `MOZ_ASSERT`.  Therefore, this patch
added a new check into `HTMLEditor::InsertParagraphSeparatorAsSubAction()`.

Differential Revision: https://phabricator.services.mozilla.com/D107588
2021-03-09 23:57:54 +00:00
Masayuki Nakano 1229430221 Bug 1677566 - part 2: Make `HTMLEditUtils` treat a found non-editable element as a leaf node even if it has children r=m_kato
Blink treats each non-editable node as an atomic object.  E.g., deleting or
forward-deleting from next to a non-editable element, it deletes only one
non-editable element.

Unfortunately, our layout treat adjacent non-editable nodes as a node.
Therefore, the adding WPTs do not work, but they are not new regression of
this patch.

Differential Revision: https://phabricator.services.mozilla.com/D107587
2021-03-09 23:57:54 +00:00
Masayuki Nakano e659ab60ed Bug 1677566 - part 1: `WSRunScanner::TextFragmentData` stop handling non-editable content r=m_kato
It does not make sense `WSRunScanner` handles invisible white-spaces in
non-editable elements.  Therefore, this patch makes it stop handling in the
cases.

Note that this change causes new fail of some WPTs.  That will be fixed by
the following patch.

Differential Revision: https://phabricator.services.mozilla.com/D107586
2021-03-09 23:57:54 +00:00
Emilio Cobos Álvarez 0a34cbc059 Bug 1695650 - Consider selection editable even if the anchor is the empty <br> element. r=masayuki
Otherwise we disable the context menu commands which seems bad. This also
matches the HTML editor.

Differential Revision: https://phabricator.services.mozilla.com/D107513
2021-03-09 01:32:47 +00:00
Emilio Cobos Álvarez 942ec256fe Bug 1695650 - Clean up some checks in EditorUtils. r=masayuki
No behavior change. We were already returning false for HTML editor +
non-editable so we can simplify it a bit.

Depends on D107511

Differential Revision: https://phabricator.services.mozilla.com/D107512
2021-03-09 00:24:27 +00:00
Emilio Cobos Álvarez 60aae1e6b6 Bug 1695650 - Avoid to warn always. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107511
2021-03-09 00:24:27 +00:00
Emilio Cobos Álvarez 4f347077a1 Bug 1696378 - Fuzz other test annotation.
MANUAL PUSH: Sheriffs mentioned this failure afterwards.
2021-03-05 02:41:03 +01:00