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

10465 Коммитов

Автор SHA1 Сообщение Дата
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