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

11233 Коммитов

Автор SHA1 Сообщение Дата
Daniel Holbert 4209467c50 Bug 1786210: Remove mentions of unused pref gfx.font_loader.interval. r=emilio
This patch doesn't impact behavior.

The pref "gfx.font_loader.interval" used to control certain aspects of
font-loading behavior, but that code has evolved and we no longer read the
value of this pref anywhere.

Differential Revision: https://phabricator.services.mozilla.com/D155183
2022-08-21 23:45:56 +00:00
Masayuki Nakano ff67736d1c Bug 1781994 - part 12: Make `HTMLEditor::SetCSSBackgroundColorWithTransaction` use similar approach as `SetInlinePropertiesAsSubAction` etc r=m_kato
It's a Gecko specific feature, and it sets background color of parent block
elements of selection ranges.  This does similar things to
`SetInlinePropertiesAsSubAction`, but still refers `Selection` directly and
uses `AutoSelectionRestorer`.  For consistency between similar methods, this
patch makes it use `AutoRangeArray`.

Depends on D154353

Differential Revision: https://phabricator.services.mozilla.com/D154354
2022-08-16 01:17:46 +00:00
Masayuki Nakano 0f6bbf324c Bug 1781994 - part 11: Clean up `HTMLEditor::RelativeFontChange` r=m_kato
It should use `AutoRangeArray` to stop using `AutoSelectionRestorer`.

Depends on D154352

Differential Revision: https://phabricator.services.mozilla.com/D154353
2022-08-16 01:17:45 +00:00
Masayuki Nakano d1c4c5d8e2 Bug 1781994 - part 10: Make `HTMLEditor::RelativeFontChangeOnNode` and `HTMLEditor::RelativeFontChangeHelper` stop touching `Selection` directly r=m_kato
They are renamed to `SetFontSizeWithBigOrSmallElement` and
`SetFontSizeOfFontElementChildren`.

Depends on D154351

Differential Revision: https://phabricator.services.mozilla.com/D154352
2022-08-16 01:09:31 +00:00
Masayuki Nakano 3327432a6a Bug 1781994 - part 9: Make `HTMLEditor::RelativeFontChangeOnNode` and `HTMLEditor::RelativeFontChangeHelper` use `FontSize` r=m_kato
`HTMLEditor::RelativeFontChange()` and its helpers are based on
`SetInlinePropertiesAsSubAction()` and its helpers.  Therefore, they may have
similar problem to switch join/split direction.  Therefore, this and the
following patches clean them up too.

Depends on D154350

Differential Revision: https://phabricator.services.mozilla.com/D154351
2022-08-16 01:01:06 +00:00
Masayuki Nakano 648f892bde Bug 1781994 - part 8: Make `HTMLEditor::SetInlinePropertyAsSubAction` handle multiple styles once r=m_kato
Depends on D154349

Differential Revision: https://phabricator.services.mozilla.com/D154350
2022-08-16 01:01:05 +00:00
Masayuki Nakano d6991deecb Bug 1781994 - part 7: Make `HTMLEditor::RemoveInlinePropertyAsSubAction` handle multiple styles once r=m_kato
I think that `HTMLEditor::SetInlinePropertyAsSubAction` and
`HTMLEditor::RemoveInlinePropertyAsSubAction` should not be called multiple
times in one edit action.  Therefore, I'd like to make them take multiple
styles once.  Then, we could collect all targets before touching the DOM tree
in the future.

Depends on D154348

Differential Revision: https://phabricator.services.mozilla.com/D154349
2022-08-16 00:55:06 +00:00
Masayuki Nakano da11385641 Bug 1781994 - part 6: Make `HTMLEditor::SetInlinePropertyInternal` use `AutoRangeArray` r=m_kato
Depends on D154347

Differential Revision: https://phabricator.services.mozilla.com/D154348
2022-08-16 00:38:30 +00:00
Masayuki Nakano 9d26dd1005 Bug 1781994 - part 5: Make `HTMLEditor::RemoveInlinePropertyAsSubAction` handle correct text node after splitting a text to any direction r=m_kato
This is a pre-fix for bug 1735608.  Currently, the loop assumes that collected
nodes are always right node, but it'll be changed, therefore, it creates
new array for the follow up loops handle expected nodes.

Depends on D154346

Differential Revision: https://phabricator.services.mozilla.com/D154347
2022-08-16 00:31:45 +00:00
Masayuki Nakano 181da530ee Bug 1781994 - part 4: Make `HTMLEditor::RemoveInlinePropertyInternal` use `AutoRangeArray` r=m_kato
I'd like to get rid of `AutoSelectionRangeArray` and `AutoRestoreSelection`,
and I'd like to make it stop touching `Selection` while it is removing style
of each content nodes in the range.  Therefore, this patch rewrites it with
`AutoRangeArray`.  Then, we can reduce the indent level of the nested `for`
loops.

Note that it creates `AutoEditSubActionNotifier`, so it's a sub-edit action
handler.  Therefore, this patch renames it.

Depends on D154345

Differential Revision: https://phabricator.services.mozilla.com/D154346
2022-08-16 00:26:05 +00:00
Masayuki Nakano 55250ca5e0 Bug 1781994 - part 3: Make `HTMLEditor::SetInlinePropertyOnTextNode` stop touching `Selection` directly r=m_kato
Depends on D154344

Differential Revision: https://phabricator.services.mozilla.com/D154345
2022-08-16 00:13:40 +00:00
Masayuki Nakano fcecac970b Bug 1781994 - part 2: Make `HTMLEditor::SplitAncestorStyledInlineElementsAtRangeEdges` stop touching `Selection` directly r=m_kato
Depends on D154343

Differential Revision: https://phabricator.services.mozilla.com/D154344
2022-08-16 00:08:07 +00:00
Masayuki Nakano 9f9cd9e318 Bug 1781994 - part 1: Make `HTMLEditor::SplitAncestorStyledInlineElementsAt` and `HTMLEditor::ClearStyleAt` stop touching `Selection` directly r=m_kato
I've already made a caller of `HTMLEditor::ClearStyleAt`,
`HTMLEditor::CreateStyleForInsertText`, in bug 1770877, so this fixes a bug of
the patch.

`HTMLEditor::ClearStyleAt` is still updates `Selection` only in some cases.
And one of the caller has not handle the `Selection` update.  Therefore, once
it completely stop touching `Selection`, `ComputeEditingHost` will fail and
the other paths update `Selection`, so it should do it too.  (Without the
change, `test_dragdrop.html` fails.)

Finally, we don't need `EditResult` anymore because we have
`Result<EditorDOMPoint, nsresult>`.

Differential Revision: https://phabricator.services.mozilla.com/D154343
2022-08-16 00:02:25 +00:00
André Bargull 8c56e722b1 Bug 1784426: Call Locale::Canonicalize() on the newly parsed locale. r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D154489
2022-08-15 15:34:29 +00:00
Masayuki Nakano 64e700332c Bug 1783402 - part 3: Make result of unsafe getter methods of `EditorDOMPointBase` templated r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D153842
2022-08-09 01:43:24 +00:00
Masayuki Nakano fe4e77e324 Bug 1783402 - part 2: Make result of safe getter methods of `EditorDOMPointBase` templated r=m_kato
Similar to the previous patch, and for consistency between editor helper
classes, we should make result of getter methods of `EditorDOMPointBase` too.

Differential Revision: https://phabricator.services.mozilla.com/D153841
2022-08-09 01:43:24 +00:00
Masayuki Nakano 2c1d4805a6 Bug 1783402 - part 1: Make result of the getter methods of `SplitRangeOffFromNodeResult` templated r=m_kato
We'll need the version to return `dom::Text*` in coming patches for bug 1735608.
For avoiding the class to have a lot of getters, we should make result of the
getters templated.

Differential Revision: https://phabricator.services.mozilla.com/D153840
2022-08-09 01:43:23 +00:00
Masayuki Nakano d636f57443 Bug 1783393 - Get rid of the constructor of `SplitRangeOffFromNodeResult` which takes 2 `SplitNodeResult`s r=m_kato
`GetLeftContent()` etc is explained as:
> This may return nullptr if the method didn't split at start edge of the node.

On the other hand, `SplitNodeResult::GetPreviousContent()` and
`SplitNodeResult::GetNextContent()` returns previous or next content node
of split point when the split is not performed, but not in error.

Therefore, it should check `SplitNodeResult::DidSplit()` instead of
`SplitNodeResult::isOk()`.

However, there is another problem.  The constructor cannot specify the order
of the 2 splits.  Therefore, it's hard to maintain the constructor.
Fortunately, there is only one user, so we can make the user create the
result with another constructor.

Differential Revision: https://phabricator.services.mozilla.com/D153838
2022-08-08 09:06:24 +00:00
Masayuki Nakano 982149f4f1 Bug 1782874 - part 2: Make `HTMLEditor::RemoveEmptyNodesIn` remove end container of the range if empty r=m_kato
If splitting node creates new right node instead of new left node,
`TopLevelEditSubActionData::mChangedRange` ends by start of the right node.
However, `RemoveEmptyNodesIn` uses `PostContentIterator` which collects DOM
nodes whose "end tag" appear in the range.  Therefore, for cleaning up new
empty right nodes correctly, we need to extend the range to contain the node.

Additionally, it removes unexpected element which is editable but shouldn't be
removed from the DOM tree.  Therefore, this patch adds new check such as
`HTMLEditUtils::IsRemovalNode()`.

Finally, this patch adds a check whether the editor is a mail editor or not
at considering whether a node is a "mail-cite" because `contenteditable` in
web apps do not need special handling for such Gecko-specific element.

Differential Revision: https://phabricator.services.mozilla.com/D153834
2022-08-08 08:22:44 +00:00
Masayuki Nakano 8b7fb928d3 Bug 1782628 - Make `HTMLEditor::HandleInsertBRElement` create caret position before moving its container r=m_kato
The test oddly passes without the fix in `HandleInsertBRElement`.  I guess that
post-processing in `HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal()`
handles `Selection`, and anyway the insertion point of the following
`insertText` is wrong.  It seems that we don't need to uplift this.

Differential Revision: https://phabricator.services.mozilla.com/D153832
2022-08-08 01:54:47 +00:00
Masayuki Nakano bea9bf4233 Bug 1782852 - part 1: Get rid of unused editor commands in the wild r=smaug
`increaseFontSize`, `decreaseFontSize`, `gethtml`, `heading` and `readonly`
commands were disabled for a year in all channels, but no regression reports
have been filed.  Therefore, we can delete the commands and the telemetry
probes.

Note that `cmd_getContents` command which is the internal command of `gethtml`
is not used in comm-central too.  Therefore, this patch deletes the command
handler, `nsClipboardGetContentsCommand`, and `Command::GetHTML` too.

Differential Revision: https://phabricator.services.mozilla.com/D153720
2022-08-05 02:55:22 +00:00
Masayuki Nakano eddeebefce Bug 1775381 - Move `AutoRangeArray` from `EditorUtils.h` to its own header and cpp file r=m_kato
Depends on D152982

Differential Revision: https://phabricator.services.mozilla.com/D153063
2022-08-04 05:39:16 +00:00
Masayuki Nakano b938b9b105 Bug 1774704 - part 9: Get rid of `EditorBase::TopLevelEditSubActionData::mNewBlockElement` due to unused r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152982
2022-08-04 05:39:15 +00:00
Masayuki Nakano aaa97aa9d5 Bug 1774704 - part 8: Make `HTMLEditor::SetSelectionToAbsoluteAsSubAction` stop setting `TopLevelEditSubActionData::mNewBlockElement` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152981
2022-08-04 05:31:12 +00:00
Masayuki Nakano 0196645809 Bug 1774704 - part 7-7: Make `HTMLEditor::AlignNodesAndDescendants` stop touching `Selection` directly and setting `mNewBlockElement` r=m_kato
For doing that, this patch also making `HTMLEditor::AlignContentsAtSelection`
which the only caller of `HTMLEditor::AlignNodesAndDescendants` handle
`Selection` with `AutoRangeArray` because it uses `AutoSelectionRestorer` and
we need to adjust `Selection` after restored.

Differential Revision: https://phabricator.services.mozilla.com/D152980
2022-08-04 05:07:32 +00:00
Masayuki Nakano 3a9a1e4035 Bug 1774704 - part 7-6: Make `HTMLEditor::AlignContentsInAllTableCellsAndListItems` and `HTMLEditor::AlignBlockContentsWithDivElement` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152979
2022-08-04 05:00:38 +00:00
Masayuki Nakano 1da47692c5 Bug 1774704 - part 7-5: Make `HTMLEditor::AlignContentsAtSelectionWithEmptyDivElement` stop touching `Selection` directly and setting `mNewBlockElement` r=m_kato
It's only caller is `HTMLEditor::AlignContentsAtSelection` which is called only
by `HTMLEditor::AlignAsSubAction` at almost last of it.  Therefore, it's safe
to handle `mNewBlockElement` at the caller of
`AlignContentsAtSelectionWithEmptyDivElement` is safe.

Differential Revision: https://phabricator.services.mozilla.com/D152978
2022-08-04 04:53:54 +00:00
Masayuki Nakano 3f4655f24a Bug 1774704 - part 7-4: Make `HTMLEditor::SetBlockElementAlign` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152977
2022-08-04 04:40:14 +00:00
Masayuki Nakano fd641593ca Bug 1774704 - part 7-3: Make `HTMLEditor::RemoveAlignFromDescendants` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152976
2022-08-04 04:33:56 +00:00
Masayuki Nakano efd0248a4c Bug 1774704 - part 7-2: Make `CSSEditUtils::RemoveCSSInlineStyleWithTransaction` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152975
2022-08-04 04:28:13 +00:00
Masayuki Nakano 68caf865dc Bug 1774704 - part 7-1: Make `HTMLEditor::EnsureHardLineBeginsWithFirstChildOf` and `HTMLEditor::EnsureHardLineEndsWithLastChildOf` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152974
2022-08-04 04:19:46 +00:00
Masayuki Nakano b653b11028 Bug 1774704 - part 6: Make `HTMLEditor::HandleHTMLIndentAtSelectionInternal` stop touching `Selection` directly and stop setting `mNewBlockElement` r=m_kato
The change of expected assertion count in the crash test is caused by that the
test calls `execCommand` recursively from the legacy mutation event listeners.
Therefore, stopping updating `Selection` for each DOM tree change causes that
the target range in the nested edit action is changed.  However, the nested
handling has already been disabled by default, so this should not be a problem
for the users.

Differential Revision: https://phabricator.services.mozilla.com/D152973
2022-08-04 04:07:46 +00:00
Masayuki Nakano c18ae2e047 Bug 1774704 - part 5-3: Make `HTMLEditor::HandleCSSIndentAtSelectionInternal` stop touching `Selection` directly and setting `mNewBlockElement` r=m_kato
It's called only by `HTMLEditor::HandleCSSIndentAtSelection` which is called
only by `HTMLEditor::HandleIndentAtSelection`.  They don't touch `Selection`
after calling it.  Therefore, we can make it adjust collapsing selection point
by itself.

Differential Revision: https://phabricator.services.mozilla.com/D152972
2022-08-04 03:16:28 +00:00
Masayuki Nakano 2296d580e7 Bug 1774704 - part 5-2: Make `HTMLEditor::IndentListChild` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152971
2022-08-04 03:00:31 +00:00
Masayuki Nakano 49869c2825 Bug 1774704 - part 5-1: Make `HTMLEditor::ChangeMarginStart` stop touching `Selection` directly r=m_kato
And also this patch makes it and an its caller stop computing editing host
with the latest `Selection`.

Differential Revision: https://phabricator.services.mozilla.com/D152970
2022-08-04 02:40:57 +00:00
Masayuki Nakano 6a5e4e03e3 Bug 1774704 - part 4-4: Make `HTMLEditor::ChangeSelectedHardLinesToList` stop setting `TopLevelEditSubActionData::mNewBlockElement` r=m_kato
With taking an `AutoRangeArray` which is initialized with `Selection`, it can
restore selection and check if it's collapsed and if collapsed in the expected
list element.  Then, its caller can apply the returned range to `Selection`
because it's an edit sub-action handler.

Differential Revision: https://phabricator.services.mozilla.com/D152969
2022-08-04 02:28:11 +00:00
Masayuki Nakano cc6f01f78c Bug 1774704 - part 4-3: Make `HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction` stop computing editing host with current selection r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152968
2022-08-04 02:12:03 +00:00
Masayuki Nakano 87542555d4 Bug 1774704 - part 4-2: Make `HTMLEditor::ChangeListElementType` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152967
2022-08-04 02:02:46 +00:00
Masayuki Nakano 7b53a68cd6 Bug 1774704 - part 4-1: Move `HTMLEditor::GetParentListElementAtSelection` into `AutoRangeArray` r=m_kato
It oddly retrieve an ancestor list element which contains one range in the
selection ranges.  So, working it with `AutoRangeArray` which is initialized
with `Selection` makes `HTMLEditor` smaller...

Differential Revision: https://phabricator.services.mozilla.com/D152966
2022-08-04 01:50:28 +00:00
Masayuki Nakano 8b65b0bbf3 Bug 1774704 - part 3: Make `HTMLEditor::InsertParagraphSeparatorAsSubAction` stop setting `TopLevelEditSubActionData::mNewBlockElement` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152965
2022-08-04 01:00:25 +00:00
Masayuki Nakano 49774332d1 Bug 1774704 - part 2: Make `CreateOrChangeBlockContainerElement`, `FormatBlockContainerWithTransaction` and `WrapContentsInBlockquoteElementsWithTransaction` stop setting `TopLevelEditSubActionData::mNewBlockElement` r=m_kato
They set `TopLevelEditSubActionData::mNewBlockElement` and their root callers
in edit sub-action level are only `InsertParagraphSeparatorAsSubAction` and
`FormatBlockContainerAsSubAction`, and they are called each other.  Therefore,
this patch changes these 3 methods once.

Differential Revision: https://phabricator.services.mozilla.com/D152964
2022-08-04 00:39:13 +00:00
Masayuki Nakano 14dd35ea1d Bug 1774704 - part 1: Make `HTMLEditor::EnsureCaretInBlockElement` only computes new caret point in the given element r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152963
2022-08-04 00:21:53 +00:00
Masayuki Nakano 7f6f9cf71c Bug 1774704 - part 0: Add automated tests of preserving selection while handling some commands r=m_kato
The following patches touch the logic to restore selection after handling
commands.  However, it seems that they are not tested because I found some
regressions by manual testing, but didn't cause orange on tryserver.

`outdent-preserving-selection.tentative.html` causes a crash due to the
`MOZ_ASSERTION` in `HTMLEditor::HandleOutdentAtSelectionInternal`.  It means
that I misunderstand the logic and had put the assertion.  I should fix it
later with reading the complicated code again.  For now, I just change it
to `NS_WARNING_ASSERTION` instead.

And also `test_cmd_absPos.html` is the first test to check toggling `position`
between `static` and `absolute`.  Therefore, it detects wrong `MOZ_ASSERT`s
which test whether `EditActionData` or `TopLevelEditSubActionData` is created
or not **before** they create them by themselves.  So, this patch removes the
wrong assertions.

Differential Revision: https://phabricator.services.mozilla.com/D152962
2022-08-04 00:21:53 +00:00
Mark Banner 1c23a90c8e Bug 1782008 - Remove now unnecessary ESLint test definitions from other .eslintrc.js files. r=mossop,media-playback-reviewers,alwu
Differential Revision: https://phabricator.services.mozilla.com/D153216
2022-08-03 11:16:20 +00:00
Mark Banner 7428be4a86 Bug 1782008 - Remove now unnecessary .eslintrc.js files. r=webcompat-reviewers,extension-reviewers,media-playback-reviewers,pip-reviewers,denschub,rpl,alwu,mossop
Differential Revision: https://phabricator.services.mozilla.com/D152736
2022-08-03 11:16:20 +00:00
Nika Layzell c15823d075 Bug 1772006 - Part 5: Simplify and move the string searching APIs from ns[T]StringObsolete, r=xpcom-reviewers,necko-reviewers,eeejay,dragana,barret
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.

In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.

These patches do the following major changes to the searching APIs:

1. The ASCII case-insensitive search method was split out as
   LowerCaseFindASCII, rather than using a boolean. This should be less
   error-prone and more explicit, and allows the method to continue to use
   narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
   matching character types. I considered adding a FindASCII method which would
   use narrow string literals for both wide and narrow strings but it would've
   been the same amount of work as changing all of the literals to unicode
   literals.
   This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
   algorithm or stl algorithms to reduce code complexity, and avoid the need to
   carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
   called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
   to booleans normally implicitly coercing to `index_type`. This should
   probably be removed at some point, but may be useful during the transition.

Differential Revision: https://phabricator.services.mozilla.com/D148300
2022-07-30 00:12:48 +00:00
Masayuki Nakano bf2ccc8872 Bug 1780140 - Make `HTMLEditor::ClearStyleAt` clean up new empty inline elements which are not contain new text r=m_kato
Currently, `HTMLEditor` assumes that padding `<br>` element for empty last line
is outside of inline elements, but it may happen because of both:
* starting from bug 1778091, `HTMLEditor` move `<br>` element into new empty
inline elements at inserting new paragraph.
* web apps can put it into inline elements.

After splitting inline elements and which do not have meaningful content, users
cannot put caret into the empty inline elements so that the elements stay unless
delete around there.

For avoiding the leak due to meaningless elements, we should delete them at
splitting inline elements at inserting new text.

Note that Chrome does not pass the new tests of resetting ancestor bold style
because Chrome wraps the `<b>` with `<i>`, however, the `<i>` has odd
`style=""`.  Perhaps, the test framework should ignore it because it's not
important for the web-compatibility.

On the other hand, Chrome completely fails only the last testcase since it
unwraps the `<b>` from the last `<br>`, so the bold style which was applied by
the web app to the last `<br>` is lost.  This is not reasonable.

Differential Revision: https://phabricator.services.mozilla.com/D152616
2022-07-27 22:51:18 +00:00
Tooru Fujisawa a032f53a63 Bug 1780543 - Part 5: Add mozilla/chrome-script environment. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D152430
2022-07-26 02:46:30 +00:00
Masayuki Nakano a45b6d1e16 Bug 1773848 - Make the for-loop in the lambda in `HTMLEditor::InsertTableRowsWithTransaction` refer only `cellDataInLastRow` r=m_kato
It's renamed from `CellData`, but `cellData` still exists in the wider scope.
https://searchfox.org/mozilla-central/rev/f6a2ef2f028b8f1eb82fa5dc5cb1e39a3baa8feb/editor/libeditor/HTMLTableEditor.cpp#923-924

Therefore, these lines are wrong:
https://searchfox.org/mozilla-central/rev/f6a2ef2f028b8f1eb82fa5dc5cb1e39a3baa8feb/editor/libeditor/HTMLTableEditor.cpp#1049,1053

because `cellData` was in the for-loop:
https://searchfox.org/mozilla-central/rev/bc4493c72442ad55aecf6b575edb0df4ed18b113/editor/libeditor/HTMLTableEditor.cpp#1008-1009,1020,1022,1026

Differential Revision: https://phabricator.services.mozilla.com/D152144
2022-07-20 04:24:52 +00:00
Magnus Melin 2fec2a1929 Bug 1779343 - Don't crash rewrapping "> ". r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D151682
2022-07-14 13:12:29 +00:00
Neil Deakin ef2a63d6b6 Bug 1779042, fix test_paste_no_formatting.html to handle headless clipboard, r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D151548
2022-07-14 12:53:06 +00:00
Tooru Fujisawa 52c95734e7 Bug 1667455 - Part 9: Stop importing Services.jsm from chrome-priv HTML code, single-line cases. r=kmag,necko-reviewers,geckoview-reviewers,extension-reviewers,m_kato,dragana
Differential Revision: https://phabricator.services.mozilla.com/D150898
2022-07-11 12:41:52 +00:00
Neil Deakin 00acc7206b Bug 968104, paste unformatted shortcut (shift+ctrl/cmd+v) should work in plain text contexts, such as input and textarea, r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D150806
2022-07-11 08:58:35 +00:00
Masayuki Nakano 92c1ac04ef Bug 1778091 - Make `HTMLEditor` move invisible `<br>` element into the empty inline element after splitting a paragraph at end r=m_kato
In Yahoo! Mail, the paragraph has `<br>` after `<span>` element which has
`background-color`.  In this case, Gecko creates the following DOM tree after
splitting the paragraph:
```
<div><span>foo</span></div><div><span></span><br></div>
```
Then, the empty `<span>` in the right paragraph will be removed by the
post-processing.  However, in this case, the inline element is required for
preserving the style continued from the previous paragraph.

In this case, we should move the `<br>` element into the `<span>` to make
it non-empty and avoid it to be removed.  This is compatible with Chrome.

Differential Revision: https://phabricator.services.mozilla.com/D151345
2022-07-11 05:36:29 +00:00
Joel Maher 537a5a0dc8 Bug 1777549 - remove remaining e10s conditions in manifest files. r=gbrown,extension-reviewers,zombie
Differential Revision: https://phabricator.services.mozilla.com/D150820
2022-07-01 13:49:42 +00:00
Masayuki Nakano 80fbd3825b Bug 1774114 - Make `HTMLEditor` and its helper classes get split/join node direction dynamically r=m_kato
Currently I'm think that the split/join node direction should be managed per
`HTMLEditor` instance because per transaction makes undo/redo handling
complicated and may require additional space to save it in each transaction
instance.  However, the direction should be changeable with new Gecko specific
`execCommand` to support both direction until creating first split/join node
transaction or anytime with clearing the transactions.

Differential Revision: https://phabricator.services.mozilla.com/D149192
2022-07-01 02:02:03 +00:00
Kris Maglione 289588883e Bug 1776207: Part 1 - Remove obsolete _xpcom_factory definitions. r=mccr8
They only work with `generateNSGetFactory` definitions, which don't exist
anymore.

Differential Revision: https://phabricator.services.mozilla.com/D150191
2022-06-27 21:19:51 +00:00
Brad Werth 10e55143ef Bug 1761160: Disable spellechecking in the textarea for the blur-focus test. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D150281
2022-06-25 18:45:09 +00:00
Dan Minor 7ef01f1db8 Bug 1773802 - Specify charset in new test; r=smaug CLOSED TREE
Differential Revision: https://phabricator.services.mozilla.com/D150156
2022-06-23 16:59:16 +00:00
Dan Minor 32b9c84af0 Bug 1773802 - Ignore empty strings when spellchecking; r=smaug
This adds a check to see if the encoded word is not empty and does not start
with the null character. Hunspell accepts C-style strings and marks the empty
string as correctly spelled. This prevents other dictionaries from detecting
misspelled strings in languages that use a different charset, which has lead
to problems when using the en-US dictionary packaged with Firefox and Greek,
Hebrew and Russian dictionaries, where misspellings are not detected in the
non-English language.

Differential Revision: https://phabricator.services.mozilla.com/D149899
2022-06-23 15:34:20 +00:00
Masayuki Nakano b08b799b15 Bug 1770877 - part 38: Make `HTMLEditor::InsertParagraphSeparatorAsSubAction` stop updating `Selection` while handling its job r=m_kato
Finally, this patch makes it update `Selection` once after finishing its
preparation.

Differential Revision: https://phabricator.services.mozilla.com/D149109
2022-06-23 01:09:12 +00:00
Emilio Cobos Álvarez bd09497378 Bug 1372276 - Remove HTML menuitem. r=smaug,mconley,agi
This removes HTMLMenuItemElement and all the code and tests preffed off
by dom.menuitem.enabled.

The HTML parser changes are the result of applying the previous patch.

Differential Revision: https://phabricator.services.mozilla.com/D149979
2022-06-22 22:31:42 +00:00
Norisz Fay cfa3a53e0d Backed out changeset e9b6a7f08dc9 (bug 1770877) for causing wpt failures on editing-div-outside-body.html 2022-06-22 20:11:34 +03:00
Masayuki Nakano c2a64d2ada Bug 1770877 - part 38: Make `HTMLEditor::InsertParagraphSeparatorAsSubAction` stop updating `Selection` while handling its job r=m_kato
Finally, this patch makes it update `Selection` once after finishing its
preparation.

Differential Revision: https://phabricator.services.mozilla.com/D149109
2022-06-22 13:57:07 +00:00
Masayuki Nakano d292b994f8 Bug 1770877 - part 37: Make `HTMLEditor::HandleInsertLinefeed` stop touching `Selection` directly r=m_kato
Note that the odd path which always returns `NS_ERROR_FAILURE` is not covered by
the tests.  Therefore, this patch adds `MOZ_ASSERT` to make somebody hit it and
report a bug.

Differential Revision: https://phabricator.services.mozilla.com/D149108
2022-06-22 13:14:17 +00:00
Masayuki Nakano 4f7e0e9717 Bug 1770877 - part 36: Make `HTMLEditor::CreateStyleForInsertText` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149107
2022-06-22 13:07:05 +00:00
Masayuki Nakano d97c255cf8 Bug 1770877 - part 35: Make `HTMLEditor::SetInlinePropertyOnNode` and `HTMLEditor::SetInlinePropertyOnNodeImpl` stop touching `Selection` directly r=m_kato
Note that `CSSEditUtils` does not change `Selection` except
`RemoveCSSInlineStyleWithTransaction` which is used only by aligning in a block.
Therefore, this patch does not touch `CSSEditUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D149106
2022-06-22 12:57:51 +00:00
Masayuki Nakano d8cdcb51a1 Bug 1770877 - part 34: Make `HTMLEditor::RemoveStyleInside` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149105
2022-06-22 12:36:37 +00:00
Masayuki Nakano fd5663f3e8 Bug 1770877 - part 33: Make `HTMLEditor::RelativeFontChangeOnTextNode` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149104
2022-06-22 08:18:40 +00:00
Masayuki Nakano 616e905371 Bug 1770877 - part 32: Make `HTMLEditor::InsertContainerWithTransaction` stop touching `Selection` directly r=m_kato
This changes the behavior a little bit, unfortunately.

`InsertContainerWithTransaction` starts return code.  And the behavior changed
WPTs are hit here:
https://searchfox.org/mozilla-central/rev/a8bdd0feeb7ae596a202333ee324a68153f9f4c4/editor/libeditor/EditorBase.cpp#2179-2180

Then, the editor specific error will be converted to `NS_OK` at the
corresponding public method.  Therefore, the return code may be changed from
`NS_ERROR_FAILURE` to `NS_OK`, and that causes the return value change of
`Document.execCommand`.

Differential Revision: https://phabricator.services.mozilla.com/D149103
2022-06-22 08:04:26 +00:00
Masayuki Nakano 9c2145a90d Bug 1770877 - part 31-3: Replace `insertLineBreak` variable in `HTMLEditor::InsertParagraphSeparatorAsSubAction` with a lambda r=m_kato
This can encapsule the long if-elseif-else blocks into the lambda.

Differential Revision: https://phabricator.services.mozilla.com/D149102
2022-06-22 02:54:34 +00:00
Masayuki Nakano 5af4b5cb8d Bug 1770877 - part 31-2: Make `HTMLEditor::InsertParagraphSeparatorAsSubAction` call `HandleInsertParagraphInParagraph` without `Selection` r=m_kato
The preceding call of `InsertBRElement` may collapse selection at the inserted
padding `<br>` element.  Only when calling `HandleInsertParagraphInParagraph`,
`InsertParagraphSeparatorAsSubAction` uses `Selection`.  So, only in this case,
we need to recompute the point to split for keeping current (odd) behavior.

Note that in normal cases, using `atStartOfSelection` gets same result.
However, if there are some invisible nodes such as comment nodes, doing it
may change the behavior.  For now, we should keep the current behavior.  It
should be sorted out when we make it stop inserting `<br>` elements for the
preparation of split without checking whether it's actually necessary.

Differential Revision: https://phabricator.services.mozilla.com/D149101
2022-06-22 01:52:32 +00:00
Masayuki Nakano 47a4dbc560 Bug 1770877 - part 30: Make `HTMLEditor::HandleInsertParagraphInListItemElement` stop touching `Selection` directly r=m_kato
It touches `Selection` redundantly (i.e., immediately after that, it or its
caller collapse `Selection`).  So we can just stop it because we can ignore
the cases when the handling fails after the redundant `Selection` update and
it can be caused by tricky things with the mutation event listeners.

Note that without changing `SplitNodeResult` a lot, we cannot make it return
`SplitNodeResult`, and currently there is no motivation to do it because the
only caller does not need the detail of the split.  Therefore, I give up doing
it.

Differential Revision: https://phabricator.services.mozilla.com/D149099
2022-06-22 01:34:03 +00:00
Masayuki Nakano c76d7f7b67 Bug 1770877 - part 29: Make `HTMLEditor::HandleInsertParagraphInHeadingElement` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149098
2022-06-22 01:25:04 +00:00
Masayuki Nakano 9b86130934 Bug 1770877 - part 28-6: Make `HTMLEditor::HandleInsertParagraphInParagraph` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149097
2022-06-22 01:18:35 +00:00
Masayuki Nakano a8fbc40014 Bug 1770877 - part 28-5: Get rid of unnecessary duplication of `EditorDOMPoint` in `HTMLEditor::HandleInsertParagraphInParagraph` r=m_kato
I tried to make the latter half preparation to call
`HTMLEditor::SplitParagraphWithTransaction`, but I cannot make it cleaner
because it needs to return `HTMLBRElement*` and `EditorDOMPoint` with maybe
modifying the DOM tree.  So, I keep it as-is, but I make replace the unnecessary
duplicated `EditorDOMPoint` with the original one which is adjusted to avoid
to create new empty link in the right paragraph.

Differential Revision: https://phabricator.services.mozilla.com/D149096
2022-06-22 01:05:47 +00:00
Masayuki Nakano fc4610f7d0 Bug 1770877 - part 28-4: Make `HTMLEditor::HandlerInsertParagraphInParagraph` take a split point and editing host r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149095
2022-06-22 01:00:42 +00:00
Masayuki Nakano a1ce604b80 Bug 1770877 - part 28-3: Make `HTMLEditor::HandleInsertParagraphInParagraph` insert `<br>` element immediately after considering so r=m_kato
Using the wide scope `EditorDOMPoint pointToInsertBR` makes it harder to read.
Although this duplicates a call of `HTMLEditor::InsertBRElement` and a couple of
post processing, but I think that it's easier to read/understand.

Differential Revision: https://phabricator.services.mozilla.com/D149094
2022-06-22 00:40:20 +00:00
Masayuki Nakano c0a2068334 Bug 1770877 - part 28-2: Make `HTMLEditor::HandleInsertParagraphInParagraph` return earlier if should be default to insert `<br>` instead r=m_kato
If it needs to insert a `<br>` but the editor does not want to create new
paragraph, its caller should be default to insert a `<br>` element.  Rather
than checking this at inserting `<br>` element, it should do it at considering
the place to insert the new `<br>`.

Differential Revision: https://phabricator.services.mozilla.com/D149093
2022-06-21 23:50:42 +00:00
Masayuki Nakano b97aca0073 Bug 1770877 - part 28-1: Isolate the part of adjusting split point for avoiding to create new empty link in `HTMLEditor::HandleInsertParagraphInParagraph` r=m_kato
The method does several different things.  For making each part isolated,
this patch wraps the first part with a lambda.

Differential Revision: https://phabricator.services.mozilla.com/D149092
2022-06-21 23:38:06 +00:00
Masayuki Nakano c77d8d358f Bug 1770877 - part 27: Make `HTMLEditor::SplitParagraph` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149091
2022-06-21 08:49:51 +00:00
Masayuki Nakano 6f93e32018 Bug 1770877 - part 26: Make `HTMLEditor::InsertBRElementIfEmptyBlockElement` a lambda since it's used only by one method r=m_kato
And its selection update are not used except the legacy mutation event
listeners so that we can drop them.

Differential Revision: https://phabricator.services.mozilla.com/D149090
2022-06-21 08:19:37 +00:00
Masayuki Nakano f9d31a6638 Bug 1770877 - part 25: Make `HTMLEditor::FormatBlockContainerWithTransaction` stop touching `Selection` directly r=m_kato
This patch makes it take `AutoRangeArray` and it can save a snapshot of the
ranges and restore it like `AutoSelectionRestorer`.

For accessing `HTMLEditor::RangeUpdaterRef` for clearing the saved ranges,
`AutoRangeArray` needs to store `HTMLEditor`.  Therefore, its constructors
and the destructor cannot be inlined in the header due to the include-hell.

Differential Revision: https://phabricator.services.mozilla.com/D149089
2022-06-21 05:58:45 +00:00
Masayuki Nakano f89b9d6eb1 Bug 1770877 - part 24: Make `HTMLEditor::MaybeExtendSelectionToHardLineEdgesForBlockEditAction` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149088
2022-06-21 03:11:42 +00:00
Masayuki Nakano 5c2c671dec Bug 1770877 - part 23: Clean up callers of `AutoRangeArray::SplitTextNodesAtEndBoundariesAndParentInlineElementsAtBoundaries` r=m_kato
They at most twice updates the `Selection` right now.  We can make them update
`Selection` once.  And this patch makes the scope of `AutoRangeArray` clearer.

Differential Revision: https://phabricator.services.mozilla.com/D149087
2022-06-21 01:26:20 +00:00
Masayuki Nakano f1476f699b Bug 1770877 - part 22: Move `HTMLEditor::CollectEditTargetNodes` into `AutoRangeArray` r=m_kato
And also this moves `HTMLEditor::CollectChildren` to `HTMLEditUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D149086
2022-06-21 01:19:25 +00:00
Masayuki Nakano 84a30bf21e Bug 1770877 - part 21: Get rid of `HTMLEditor::SplitInlinesAndCollectEditTargetNodes` r=m_kato
It's callers become messy with this patch.  The following patches try to make
them smaller.

Differential Revision: https://phabricator.services.mozilla.com/D149085
2022-06-21 01:07:10 +00:00
Masayuki Nakano 57140816d5 Bug 1770877 - part 20: Move `HTMLEditor::SplitTextNodesAtRangeEnd` and `HTMLEditor::SplitParentInlineElementsAtRangeEdges` into `AutoRangeArray` r=m_kato
Although they update the DOM tree with transactions, but for making `HTMLEditor`
smaller, and the following patches makes the related code simpler, we need to
move them into `AutoRangeArray`.

Differential Revision: https://phabricator.services.mozilla.com/D149084
2022-06-20 23:45:02 +00:00
Masayuki Nakano a8774c53b2 Bug 1770877 - part 19: Make `HTMLEditor::SplitParentInlineElementsAtRangeEdges` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149083
2022-06-20 23:09:29 +00:00
Masayuki Nakano 1674784441 Bug 1770877 - part 18: Make `HTMLEditor::SplitTextNodesAtRangeEnd` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149082
2022-06-20 08:54:47 +00:00
Masayuki Nakano c5eaf27dcc Bug 1770877 - part 17: Make `HTMLEditor::SplitElementsAtEveryBRElement` and `HTMLEditor::MaybeSplitElementsAtEveryBRElement` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149081
2022-06-19 20:57:21 +00:00
Masayuki Nakano 0a922f7b19 Bug 1770877 - part 16: Make `AutoRangeArray` can be initialized with an `EditorDOMRangeBase` or `EditorDOMPointBase` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149080
2022-06-18 09:53:41 +00:00
Masayuki Nakano c3b56cac82 Bug 1770877 - part 15: Implement equivalent of `HTMLEditor::GetSelectionRangesExtendedToHardLineStartAndEnd` r=m_kato
It's always work with `Selection` ranges.  Then, it should be treated within
`AutoRangeArray` which can be initialized with `Selection` ranges automatically.
Then, we can making `HTMLEditor` simpler.

Note tha this tries to make it get editing host when the corresponding
public method is called (after dispatched `beforeinput` event if handling a
users' operation).  However, as commented in
`HTMLEditor::SetParagraphFormatAsAction`, it breaks a tricky crash test.
Therefore, only the format block path computes it after the preparation.

Differential Revision: https://phabricator.services.mozilla.com/D149079
2022-06-17 21:28:36 +00:00
Masayuki Nakano 85cb92758f Bug 1770877 - part 14: Make `AutoRangeArray::CreateRangeWrappingStartAndEndLinesContainingBoundaries` use a static method which sets existing `nsRange` instance r=m_kato
For making extending the range to wrap the lines containing start and end
boundaries of each range of `AutoRangeArray::mRanges`, we need a method which
updates existing `nsRange` instances rather than creating new one.

Differential Revision: https://phabricator.services.mozilla.com/D149078
2022-06-17 08:41:02 +00:00
Masayuki Nakano de381e88aa Bug 1770877 - part 13: Move `HTMLEditor::CreateRangeExtendedToHardLineStartAndEnd` into `AutoRangeArray` r=m_kato
This patch makes them take `const Element& aEditingHost` so that this patch
becomes bigger than what this patch does.

Differential Revision: https://phabricator.services.mozilla.com/D149077
2022-06-17 08:23:20 +00:00
Masayuki Nakano ee3a1ce8ef Bug 1770877 - part 12: Make `HTMLEditor` treat array of `nsRange` with `OwningNonNull` rather than `RefPtr` r=m_kato
`AutoRangeArran` uses `OwningNonNull`.  So making the following patch simpler
and smaller, all places should use array of `OwningNonNull<nsRange>` instead of
`RefPtr<nsRange>`.

Differential Revision: https://phabricator.services.mozilla.com/D149076
2022-06-17 07:40:37 +00:00
Masayuki Nakano af7273ab9c Bug 1770877 - part 11: Move `HTMLEditor::GetCurrentHardLineStartPoint` and `HTMLEditor::GetCurrentHardLineEndPoint` r=m_kato
Similar to the previous patch, you must feel odd to move the methods.  They
will be static methods in the `EditorUtils.cpp` file later.

Differential Revision: https://phabricator.services.mozilla.com/D149075
2022-06-17 07:33:56 +00:00
Masayuki Nakano 854d442d06 Bug 1770877 - part 10: Move `HTMLEditor::SelectBRElementIfCollapsedInEmptyBlock` to `AutoRangeArray` r=m_kato
This must make you feel odd. However, this is a separate patch for making easier
to review the following patches.  This will be a private member of
`AutoRangeArray`.

Differential Revision: https://phabricator.services.mozilla.com/D149074
2022-06-17 05:43:02 +00:00
Masayuki Nakano c814e8f99a Bug 1770877 - part 9: Get rid of `HTMLEditor::GetSelectionRangesExtendedToIncludeAdjuscentWhiteSpaces` because of unused r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149073
2022-06-17 04:41:30 +00:00
Masayuki Nakano ff48c12997 Bug 1770877 - part 8: Get rid of `HTMLEditor::CollectEditTargetNodesInExtendedSelectionRanges` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149072
2022-06-17 04:13:04 +00:00
Masayuki Nakano 8573929ec1 Bug 1770877 - part 7: Get rid of `HTMLEditor::SplitInlinesAndCollectEditTargetNodesInExtendedSelectionRanges` r=m_kato
Similar to the previous patch, but there are more callers than the previous one,
we should unwrap it temporarily for the following patches.

Differential Revision: https://phabricator.services.mozilla.com/D149071
2022-06-17 03:10:11 +00:00
Masayuki Nakano 387134833e Bug 1770877 - part 6: Get rid of `HTMLEditor::SplitInlinesAndCollectEditTargetNodesInOneHardLine` r=m_kato
It's used only by `HTMLEditor::MoveOneHardLineContentsWithTransaction` and
it just calls 2 methods with some simple additional error handlings.

I'd like to make `SplitInlinesAndCollectEditTargetNodes` work with
`AutoRangeArray`.  Therefore, I'd like to do this for avoiding to use
`AutoRangeArray` in `HTMLEditor.h`.

Differential Revision: https://phabricator.services.mozilla.com/D149070
2022-06-17 00:50:28 +00:00
Masayuki Nakano 8f49ba6026 Bug 1770877 - part 5: Make `HTMLEditor::MoveNodesIntoNewBlockquoteElement` stop touching `Selection` directly r=m_kato
Similar to the previous patches, nobody uses the result, but it should return
the suggestion.

Differential Revision: https://phabricator.services.mozilla.com/D149069
2022-06-16 08:16:43 +00:00
Masayuki Nakano 853b00c6ba Bug 1770877 - part 4: Make `HTMLEditor::RemoveBlockContainerElements` stop touching `Selection` directly r=m_kato
For aligning the style of similar methods, this makes it suggest caret position,
but nobody uses it.

Differential Revision: https://phabricator.services.mozilla.com/D149068
2022-06-16 03:34:19 +00:00
Masayuki Nakano 544f97954a Bug 1770877 - part 3: Make `HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer` stop touching `Selection` directly r=m_kato
And this renames it to `RemoveBlockContainerElementWithTransactionBetween` to
explain its job simpler.

Differential Revision: https://phabricator.services.mozilla.com/D149067
2022-06-16 01:57:57 +00:00
Masayuki Nakano ebb6012c31 Bug 1770877 - part 2: Make `HTMLEditor::SplitRangeOffFromBlock` stop touching `Selection` directly r=m_kato
The constructor of `SplitRangeOffFromNodeResult` is used only by the method.
Therefore, we can customize the constructor and make it store the caret
suggestion.

Differential Revision: https://phabricator.services.mozilla.com/D149066
2022-06-15 23:38:54 +00:00
Masayuki Nakano b16c4d741f Bug 1770877 - part 1: Make `HTMLEditor::CreateOrChangeBlockContainerElement` stop touching `Selection` directly r=m_kato
Although the its only caller does not need the caret position, it should return
a candidate caret position for aligning to the other methods.

Differential Revision: https://phabricator.services.mozilla.com/D149065
2022-06-15 22:31:38 +00:00
criss c6b2c5db61 Backed out 9 changesets (bug 1772006) causing build bustages on nsTString.cpp. CLOSED TREE
Backed out changeset f17c7565707b (bug 1772006)
Backed out changeset c725fe1f5882 (bug 1772006)
Backed out changeset d19663161261 (bug 1772006)
Backed out changeset b6611ab002d9 (bug 1772006)
Backed out changeset 790f42b64af9 (bug 1772006)
Backed out changeset 79a734b4e4d9 (bug 1772006)
Backed out changeset 42730aae16ea (bug 1772006)
Backed out changeset b2542aef3054 (bug 1772006)
Backed out changeset 962bfea4a309 (bug 1772006)
2022-06-11 01:13:42 +03:00
Nika Layzell b3c13bf114 Bug 1772006 - Part 6: Simplify and move the string searching APIs from ns[T]StringObsolete, r=xpcom-reviewers,necko-reviewers,eeejay,dragana,barret
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.

In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.

These patches do the following major changes to the searching APIs:

1. The ASCII case-insensitive search method was split out as
   LowerCaseFindASCII, rather than using a boolean. This should be less
   error-prone and more explicit, and allows the method to continue to use
   narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
   matching character types. I considered adding a FindASCII method which would
   use narrow string literals for both wide and narrow strings but it would've
   been the same amount of work as changing all of the literals to unicode
   literals.
   This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
   algorithm or stl algorithms to reduce code complexity, and avoid the need to
   carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
   called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
   to booleans normally implicitly coercing to `index_type`. This should
   probably be removed at some point, but may be useful during the transition.

Differential Revision: https://phabricator.services.mozilla.com/D148300
2022-06-10 21:12:08 +00:00
Emilio Cobos Álvarez 255763ef57 Bug 1773070 - Unify Gecko and Servo EventState/ElementState bits. r=smaug
Add a dom/base/rust crate called just "dom" where we can share these.

Most of the changes are automatic:

  s/mozilla::EventStates/mozilla::dom::ElementState/
  s/EventStates/ElementState/
  s/NS_EVENT_STATE_/ElementState::/
  s/NS_DOCUMENT_STATE_/DocumentState::/

And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.

Differential Revision: https://phabricator.services.mozilla.com/D148537
2022-06-07 23:09:52 +00:00
Mark Banner eadf832cfb Bug 1770727 - Fix failures of ESLint rule mozilla/use-includes-instead-of-indexOf in sjs files. r=Gijs
Depends on D147081

Differential Revision: https://phabricator.services.mozilla.com/D147082
2022-06-07 19:14:08 +00:00
Masayuki Nakano 6b77e7ceba Bug 1772022 - Make `EditorBase::DeleteNodeWithTransaction()` return `NS_ERROR_EDITOR_DESTROYED` if so r=m_kato
Its callers check `EditorBase::Destroyed()` with at least adding 4 lines, and
some callers do not check this important state.  So, we should make it check
`Destroyed()` at last and omit the additional error check in the caller sites.

Note that it's a virtual method, but `HTMLEditor` checks whether it's a
removable node or not.  So, we should can merge it into `EditorBase`.  This
patch does it too.

Differential Revision: https://phabricator.services.mozilla.com/D148084
2022-06-03 02:03:47 +00:00
Butkovits Atila a71d5a9604 Bug 1666056 - disable spellcheck-input-disabled.html on Mac for frequent failures. r=intermittent-reviewers,gbrown DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D147661
2022-06-01 22:16:59 +00:00
Masayuki Nakano 5ff09263c0 Bug 1771809 - Make `HTMLEditor::AutoDeleteRangesHandler::HandleDeleteNonCollapsedRanges` check if handling range is still editable r=m_kato
In the testcase, editing host is removed when first node removing, but
`HTMLEditor::Destroyed()` still returns `false`.  So, ideally, we should add
a check of editing host validity in `Destroyed()`, but for now, we should make
the method check whether the handling range is still editable after running
each transaction.

Depends on D147723

Differential Revision: https://phabricator.services.mozilla.com/D147724
2022-06-01 05:52:15 +00:00
Masayuki Nakano c89a938de5 Bug 1771780 - Make `TextEditor::ReinitializeSelection` skip things which are necessary to be handled only at getting `focus` event r=m_kato
Currently, `TextEditor::OnFocus` does the things which were in
`EditorEventListener::OnFocus`, and they are not necessary at re-initializing
`Selection` in the anonymous subtree.  Therefore, we should make it call
`EditorBase::OnFocus` directly.

Depends on D147623

Differential Revision: https://phabricator.services.mozilla.com/D147723
2022-06-01 00:01:50 +00:00
Masayuki Nakano 0785765372 Bug 1771570 - Make `HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::JoinBlockElementsInSameParent` check if the joining nodes are expected positions r=m_kato
The reported testcase causes an incompatible behavior with the other browsers,
that is, `selectAll` command without focus in document whose body ends with
editable nodes selects the nodes in the selection root for the focused node (end
of the range in the normal direction).  Therefore, `HTMLEditor` handles deletion
in odd state (without focus handling).  So the root cause is a bug in selection,
but this bug as of the editor module should avoid the try of joining nodes which
are moved by a DOM mutation event listener at the initial deletion.

Differential Revision: https://phabricator.services.mozilla.com/D147623
2022-05-31 23:20:33 +00:00
Masayuki Nakano 684a30f93f Bug 1771448 - part 4: Rename `HTMLEditor::GetActiveEditingHost` to `ComputeEditingHost` r=m_kato
It's currently computes the corresponding editing host from the focus node of
`Selection` with climbing up the DOM tree.  So, it does not just return a stored
element.  Therefore, some callers use it multiple times.  For avoiding it, we
should rename it to explain that it computes the editing host.

Note that I think that we should make it takes a node to compute editing host
without `Selection` for solving the case of no selection ranges.  Therefore,
I don't like to include more information into the name.

Differential Revision: https://phabricator.services.mozilla.com/D147504
2022-05-31 03:41:01 +00:00
Masayuki Nakano 3d7afa934d Bug 1771448 - part 3: Get rid of `EditorBase::GetEditorRoot` r=m_kato
It returns the anonymous `<div>` element if the instance is a `TextEditor`, and
compute editing host otherwise.  So it's unclear what it returns.  Additionally,
all users except `EditorBase::CreateTransactionForCollapsedRange` are the
methods of `HTMLEditor`.  Therefore, we should remove it and unwrap the code
which it's done.

Differential Revision: https://phabricator.services.mozilla.com/D147503
2022-05-31 03:41:01 +00:00
Masayuki Nakano bd948d52e9 Bug 1771448 - part 2: Get rid of `EditorBase::IsDescendantOfEditorRoot` r=m_kato
With this patch, there are some odd points.  We should investigate them later...

Differential Revision: https://phabricator.services.mozilla.com/D147502
2022-05-31 03:41:01 +00:00
Masayuki Nakano 2249e46d10 Bug 1771448 - part 1: Get rid of `EditorBase::IsEditorRoot` because of unused r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147501
2022-05-31 03:41:00 +00:00
Emilio Cobos Álvarez 9c190fff4b Bug 1771564 - Constify ComputedStyle usage in nsComputedDOMStyle. r=dholbert
None of the consumer need to mutate styles, and this saves some ugly
const_casting on the next patch.

Doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D147555
2022-05-28 01:04:24 +00:00
Masayuki Nakano dd554016e6 Bug 1770874 - part 8: Make `EditorBase::OnBlur` temporarily a virtual method r=m_kato
Similar to the previous patch, we should split the method into `TextEditor`
and `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D147144
2022-05-27 04:09:19 +00:00
Masayuki Nakano 353a53ded7 Bug 1770874 - part 7: Make `EditorBase::OnFocus` temporarily a virtual method r=m_kato
I'd like to split it for `TextEditor` and `HTMLEditor`.  `HTMLEditor` does not
require flushing the layout because it's required by `TextEditor` if and only if
a preceding `focus` event listener or the `Element.focus` caller reframes
`<input>` or `<textarea>` element (bug 1755104).  So this would fix bug 1760045.

Differential Revision: https://phabricator.services.mozilla.com/D147143
2022-05-27 04:09:19 +00:00
Masayuki Nakano 32ec4ed2f4 Bug 1770874 - part 6: Move most part of `EditorEventListener::Blur` into `EditorBase` r=m_kato
Note that `EditorBase::OnBlur` will be simpler at the last patch.

Differential Revision: https://phabricator.services.mozilla.com/D147142
2022-05-27 04:02:30 +00:00
Masayuki Nakano f6c2fb109c Bug 1770874 - part 5: Move `EditorBase::ReinitializeSelection` into `TextEditor` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147141
2022-05-27 04:02:30 +00:00
Masayuki Nakano b94daeeccf Bug 1770874 - part 4: Move most part of `EditorEventListener::Focus` into `EditorBase::OnFocus` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147140
2022-05-27 04:02:29 +00:00
Masayuki Nakano a7cd7ebe85 Bug 1770874 - part 3: Move `EditorEventListener::SpellCheckIfNeeded` to `EditorBase` r=m_kato
This method also can be protected in a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D147139
2022-05-27 03:47:34 +00:00
Masayuki Nakano cefc432a8b Bug 1770874 - part 2: Move the lambda in `EditorEventListener::Focus` to `EditorBase` r=m_kato
It's currently a public method, but it can be protected in a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D147138
2022-05-27 03:47:34 +00:00
Masayuki Nakano a0a7f2ac76 Bug 1770874 - part 1: Make some clean ups around `EditorBase::OnFocus` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147137
2022-05-27 03:47:33 +00:00
Masayuki Nakano f93d054430 Bug 1770133 - part 3: Make `EditorBase::GetFocusedContent()` return `Element*` instead of `nsIContent*` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147134
2022-05-26 07:03:20 +00:00
Masayuki Nakano 6817b54c9d Bug 1770133 - part 2: Make `IMEStateManager::sFocusedContent` store it as `Element` r=m_kato
`nsFocusManager` defines that focused content is at least `dom::Element`.
So `IMEStateManager` can handle focused content with `dom::Element` too.

Additionally, this patch makes `IMEStateManager` methods take references instead
of pointers as far as possible if they just return error for `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D147133
2022-05-26 07:03:19 +00:00
Tyson Smith 4874606430 Bug 1769128 - Enable '-ftrivial-auto-var-init=pattern' in editor. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D147369
2022-05-26 06:15:36 +00:00
Masayuki Nakano 971efcf6d8 Bug 1770684 - Mark `IMEStateManager::SetIMEState` and its callers in `IMEStateManager` as `MOZ_CAN_RUN_SCRIPT` r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147071
2022-05-26 04:37:21 +00:00
Masayuki Nakano cdfbc99cdf Bug 1680611 - part 6: Mark `nsFocusManager::MoveCaretToFocus()` and its callers in `nsFocusManager` as `MOZ_CAN_RUN_SCRIPT` r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147065
2022-05-26 04:37:19 +00:00
Molnar Sandor 05e3775a6c Backed out 4 changesets (bug 1770727) for causing mochitest failures in test_bug1180105/test_access_control. CLOSED TREE
Backed out changeset 6323b526b0ac (bug 1770727)
Backed out changeset fc7ea80aa2ff (bug 1770727)
Backed out changeset 2a358ba86652 (bug 1770727)
Backed out changeset 464d1af6523b (bug 1770727)
2022-05-24 17:24:40 +03:00
Mark Banner 18b014551e Bug 1770727 - Fix failures of ESLint rule mozilla/use-includes-instead-of-indexOf in sjs files. r=Gijs
Depends on D147081

Differential Revision: https://phabricator.services.mozilla.com/D147082
2022-05-24 12:59:09 +00:00
Masayuki Nakano 1ca919ee58 Bug 1766355 - part 9: Make `HTMLEditor::ReplaceContainerWithTransactionInternal` and its callers use `MoveNodeTransaction` and return `CreateElementResult` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146405
2022-05-20 10:44:04 +00:00
Masayuki Nakano b62e2b0629 Bug 1766355 - part 8: Make `HTMLEditor::RemoveBlockContainerWithTransaction` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146404
2022-05-20 09:57:38 +00:00
Masayuki Nakano f5d4ddc057 Bug 1766355 - part 7: Rewrite `HTMLEditor::RemoveContainerWithTransaction` with `MoveNodeTransaction` and make it stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146403
2022-05-20 09:01:40 +00:00
Masayuki Nakano e0d3f2aa96 Bug 1766355 - part 6: Make `HTMLEditor::MoveOneHardLineContents` return `MoveNodeResult` with caret point suggestion r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146402
2022-05-20 08:51:41 +00:00
Masayuki Nakano ec1386e3eb Bug 1766355 - part 5: Make `HTMLEditor::MoveChildrenWithTransaction` and `HTMLEditor::MoveNodeOrChildrenWithTransaction` stop touching `Selection` directly r=m_kato
Unfortunately, they call each other.  Therefore, this patch updates these 2
methods once.

Differential Revision: https://phabricator.services.mozilla.com/D146401
2022-05-20 08:40:59 +00:00
Masayuki Nakano 51a4bc4fb8 Bug 1766355 - part 4: Make `HTMLEditor::MoveNodeWithTransaction` and `HTMLEditor::MoveNodeToEndWithTransaction` return `MoveNodeResult` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146400
2022-05-20 08:28:09 +00:00
Masayuki Nakano ca554ccd03 Bug 1766355 - part 3: Make `MoveNodeResult` store caret point suggestion r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146399
2022-05-20 08:28:09 +00:00
Masayuki Nakano a0180a0f22 Bug 1766355 - part 2: Make `MoveNodeResult` method names alinging to `Result` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146398
2022-05-20 08:28:08 +00:00
Masayuki Nakano c5b2a589bd Bug 1766355 - part 1: Add `MoveNodeTransaction` to handle delete node and insert node in a transaction class instance r=m_kato
Creating both `DeleteNodeTransaction` and `InsertNodeTransaction` wastes
memory.  They should be done in an instance instead.

Fortunately, no edit action listener checks whether the deleted node is still
in the composed document or not, etc.  Therefore, we can simply notify them of
both deletion and insertion which were done in
`EditorBase::InsertNodeWithTransaction` and
`EditorBase::DeleteNodeWithTransaction`.  Note that previously, the range
updater needs to ignore the notifications from them while the node is being
moved.  However, it does not require anymore.  Therefore, this patch makes it
stop locking, and that would fix minor problem in the case of legacy mutation
event listeners run another edit action.

On the other hand, this changes some edge cases handling of
`MoveNodeWithTransaction` which are detected by the WPT.  According to the
previous result of applying this patch, `nsINode::InsertBefore` fails and that
leads some errors at updating the changed range.  I guess that the cause is
that there is some bugs at updating insertion point after deleting the node from
the DOM tree around here:
https://searchfox.org/mozilla-central/rev/0ffae75b690219858e5a45a39f8759a8aee7b9a2/editor/libeditor/HTMLEditor.cpp#5058-5071

However, it's safely fixed by the new code which does not remove the node from
the DOM tree explicitly.  So, I think that it's safe to accept this behavior
change for web apps in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D146397
2022-05-20 08:28:08 +00:00
Masayuki Nakano 5a6a9a0045 Bug 1730442 - part 7: Rewrite `HTMLEditor::InsertTableRowsWithTransaction()` to collect any cell information before touching the DOM tree r=m_kato
This patch also makes it inserts table rows immediately after the previous
row element of the found reference row element to make it insert new table
rows immediately after there when inserting position is "after".  Typically,
it's the parent `<tr>` element of `aCellElement`.  Therefore, this approach
can preserve text nodes immediately after it which was intentionally inserted
by the web apps.

Differential Revision: https://phabricator.services.mozilla.com/D146365
2022-05-20 07:39:53 +00:00
Masayuki Nakano bc4493c724 Bug 1730442 - part 6: Make `HTMLEditor::InsertTableColumnsWithTransaction()` collect all necessary data before touching the DOM tree r=m_kato
It needs to work with the latest layout information to consider which cell
element is the insertion point due to rowspan and colspan.  Therefore,
this patch makes it collects all cell data before touching the DOM except
the case that it needs to normalize the table to make it rectanble.

Note that the case requiring the normalizer should be fixed in a later patch.

This method is corresponding to an XPCOM method.  Therefore, this is tested
by `test_nsITableEditor_insertTableColumn.html`.

And also it's used by the inline table editor, but we don't have automated tests
for this because of no API to get the buttons.  Therefore, I tested it by my
hand.

Note that the old code fails to put caret to newly inserted cell at the reftest
situation.  This fixes the bug too.  Therefore, this changes the reftest's
reference.

Differential Revision: https://phabricator.services.mozilla.com/D146364
2022-05-20 07:39:53 +00:00
Masayuki Nakano 7b7e50e829 Bug 1730442 - part 5: Rewrite `HTMLEditor::GetNextTableRowElement()` as returning `Result<RefPtr<Element>, nsresult>` r=m_kato
There is no direct test because of no corresponding XPCOM method, but this is
called only by `HTMLEditor::InsertTableColumnsWithTransaction()` which is
tested by `test_nsITableEditor_insertTableColumn.html`.  Anyway, the chagne is
really simple.

Differential Revision: https://phabricator.services.mozilla.com/D146363
2022-05-20 07:39:52 +00:00
Masayuki Nakano f8da7ad612 Bug 1730442 - part 4: Rewrite `HTMLEditor::GetFirstTableRowElement()` as returing `Result<RefPtr<Element>, nsresult>` r=m_kato
This change is tested by `test_nsITableEditor_getFirstRow.html` and
`test_nsITableEditor_insertTableColumn.html`.

Differential Revision: https://phabricator.services.mozilla.com/D146362
2022-05-20 07:39:52 +00:00
Masayuki Nakano 88c3133a0b Bug 1730442 - part 3: Make `HTMLEditor::InsertTableCellsWithTransaction()` work without layout information r=m_kato
It refers the layout information for getting row/column index of selected cell
element or a cell element which contains selection.  However, it can stop
referring it if all callers can specify insertion point of new cells, and it's
possible.  Therefore, we can make it free from layout information.

Note that this blocks legacy mutation events during inserting table cell
elements, but perhaps this does not cause problems in the wild.
`DOMNodeInserted` will be fired after all cell elements are inserted, so
from point of view of the event listeners, editor content is different from
traditional behavior, but this works only when user uses inline table editor
which is disabled by default.  I.e., in the wild, this path is rarely run.

Additionally, this patch makes it return `CreateElementResult` for the latter
changes which want to put caret to first inserted cell element.

Note that the changes are tested by `test_nsITableEditor_insertTableColumn.html`
and `test_nsITableEditor_insertTableCell.html`.

Differential Revision: https://phabricator.services.mozilla.com/D146361
2022-05-20 07:39:52 +00:00