10520 Commits

Author SHA1 Message Date
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