10508 Commits

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