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

744 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 5255ec92fc Bug 1803044 - part 3: Make `EditorBase::RemoveAttributeWithTransaction` stop creating transaction if the element does not have the removing attribute r=m_kato
Depends on D163997

Differential Revision: https://phabricator.services.mozilla.com/D163998
2022-12-13 01:17:11 +00:00
Masayuki Nakano ab06299299 Bug 1768315 - Get rid of `nsIEditor.transactionManager` due to unused r=m_kato
`nsITransactionManager` provides too low level things and editor may want to
stop using it in the future if Undo Manager spec is implemented in another
browser.  Therefore, I'd like to stop exposing `nsITransactionManager` instance
for editor.

Note that `mozilla::TransactionManager` is still created and used by the
UI of mailer of SeaMonkey (i.e., under `mailnews`), once we move
`nsITransactionManager` instance moved into SeaMonkey, we can make
`mozilla::TransactionManager` stop inheriting `nsITransactionManager`.

Differential Revision: https://phabricator.services.mozilla.com/D160008
2022-10-27 22:50:07 +00:00
Jan-Niklas Jaeschke 67840fe563 Bug 1783641: Deleting a selected word deletes surrounding whitespace on MacOS. r=masayuki
Native behaviour on MacOS dictates one whitespace being removed after double-clicking a word and pressing delete.
This behaviour is achieved by saving the information that the selection is created by doubleclick to the `nsFrameSelection`
and using it in the `DeleteRangeTransaction`, where the range is extended by one whitespace character before or after the range.

Differential Revision: https://phabricator.services.mozilla.com/D159613
2022-10-25 07:00:26 +00:00
Andrew McCreight b1fa3e3b36 Bug 1794811, part 1 - Include nsISupports.h instead of nsISupportsBase.h. r=necko-reviewers,nika,valentin
nsISupports.h includes nsISupportsBase.h, so it should be equivalent.

In the next patch, I'm changing things so that nsISupports is defined in
nsISupports.h instead of nsISupportsBase.h, and deleting the latter, so
this change will be needed anyways. I'm guessing people were using IWYU
or something like that.

Differential Revision: https://phabricator.services.mozilla.com/D159169
2022-10-17 16:09:22 +00:00
Masayuki Nakano ff05850ef8 Bug 1793694 - part 7: Stop exposting `CSSEditUtils.h` and `ChangeStyleTransaction.h` r=m_kato
Depends on D158636

Differential Revision: https://phabricator.services.mozilla.com/D158637
2022-10-12 02:44:20 +00:00
Masayuki Nakano 020393179b Bug 1793694 - part 2: Move some protected inline method definitions of `HTMLEditor` to non-exposed header r=m_kato
Depends on D158631

Differential Revision: https://phabricator.services.mozilla.com/D158632
2022-10-12 02:44:18 +00:00
Masayuki Nakano f9fd02e705 Bug 1793381 - part 1: Make `HTMLEditor::InsertObject` and related methods use `enum class` instead of `bool` r=m_kato
They use `bool` arguments a lot.  Therefore, some call-sites are hard to read.
They should be replaced with `enum class`es.  Note that this patch does not
make the raw value of new `enum class`es to `bool` unless they are used in the
heap.

Differential Revision: https://phabricator.services.mozilla.com/D158481
2022-10-09 01:27:34 +00:00
Masayuki Nakano 221e6fe540 Bug 1792759 - part 3: Add `nsIEditor.undoAll` r=m_kato,Standard8
`nsIEditor.undo` and `nsIEditor.redo` are called with `1` except by the search
bar, and search bar wants to undo everything to reset the value.  Therefore,
search bar needs an API to undo all, and the others do not need the number of
undoing/redoing transactions.  Therefore, this patch adds `nsIEditor.undoAll`
for search bar, and remove the arguments from `nsIEditor.undo` and
`nsIEditor.redo`.

Differential Revision: https://phabricator.services.mozilla.com/D158338
2022-10-09 01:13:50 +00:00
Masayuki Nakano 85a314b8fd Bug 1792759 - part 2: Redesign `nsIEditor.canUndo` and `nsIEditor.canRedo` r=m_kato,NeilDeakin
They are methods to take 2 out params, and it's not convenient for light use.
I think that there should be 3 attributes, `undoRedoEnabled`, `canUndo` and
`canRedo`.  Then, the findbar does not need to check number of transactions
with `nsITransactionManager`.

Differential Revision: https://phabricator.services.mozilla.com/D158337
2022-10-09 01:13:49 +00:00
Masayuki Nakano 4ba9b4dd1c Bug 1792759 - part 1: Add `nsIEditor.clearUndoRedo()` to get rid of `nsIEditor.transactionManager` r=m_kato,NeilDeakin,Standard8
`nsIEditor.transactionManager` is used only for some simple purposes, however,
`nsIEditor` exposes the rich API.  That makes it harder to maintain internal
code around transactions.  Instead, `nsIEditor` exposes only simple and
necessary APIs.

This patch creates a new API to clear undo/redo history and make the users in
mozilla-central use it instead of using `nsITransactionManager.clear()`.

Differential Revision: https://phabricator.services.mozilla.com/D158336
2022-10-09 01:13:49 +00:00
Masayuki Nakano bd1059c951 Bug 1791501 - Use `EditActionResult` as ok type of `mozilla::Result` r=m_kato
Any callers do not refer "ignored", "handled" and "cancel" state without
checking whether the method returns error or not.  Therefore, error state
can be (and should be) managed by `mozilla::Result`'s error state.

Perhaps, it should store a caret position later because deletion handlers
of `HTMLEditor` use it, but update `Selection` immediately.

Differential Revision: https://phabricator.services.mozilla.com/D158080
2022-09-28 07:21:37 +00:00
Masayuki Nakano b6c97f3d73 Bug 1791224 - Use `CreateNodeResultBase` as the ok type of `mozilla::Result` r=m_kato
Similar to the previous patch, this changes a lot of lines.  However, I think
that it's not so hard to investigate regression point in this patch because
`CreateNodeResultBase` is not used so many times at handling on edit action.

Differential Revision: https://phabricator.services.mozilla.com/D157575
2022-09-28 04:00:19 +00:00
Butkovits Atila 79b03a7594 Backed out changeset 865c5d292958 (bug 1791224) for causing build bustages at Result.h. CLOSED TREE 2022-09-27 11:55:04 +03:00
Masayuki Nakano 6513faf43f Bug 1791224 - Use `CreateNodeResultBase` as the ok type of `mozilla::Result` r=m_kato
Similar to the previous patch, this changes a lot of lines.  However, I think
that it's not so hard to investigate regression point in this patch because
`CreateNodeResultBase` is not used so many times at handling on edit action.

Differential Revision: https://phabricator.services.mozilla.com/D157575
2022-09-27 05:12:05 +00:00
Masayuki Nakano 2f0ed118ae Bug 1789967 - part 2: Make `TextEditor` and `HTMLEditor` implement `EditorBase::CollapseSelectionToEndOfLastLeafNode` by themselves r=m_kato
It does different thing for `TextEditor` and `HTMLEditor`, and used almost
internally.  Therefore, it should be implemented in the sub classes and
we should name them better.

Differential Revision: https://phabricator.services.mozilla.com/D157407
2022-09-22 06:17:36 +00:00
Masayuki Nakano f1dd8bf3b5 Bug 1789967 - part 1: Make `TextEditor` and `HTMLEditor` implement `EditorBase::InitEditorContentAndSelection` by themselves r=m_kato
The method is enough simple, and uses bad cast from point of view of OOP.
Therefore, this patch make the sub classes implement the method only for each.

Differential Revision: https://phabricator.services.mozilla.com/D157406
2022-09-22 06:06:54 +00:00
Iulian Moraru 6af4d42518 Backed out changeset 555d2ca16477 (bug 1789967) as per dev request. CLOSED TREE 2022-09-21 06:48:30 +03:00
Masayuki Nakano f3ce7840c7 Bug 1789967 - part 1: Make `TextEditor` and `HTMLEditor` implement `EditorBase::InitEditorContentAndSelection` by themselves r=m_kato CLOSED TREE
The method is enough simple, and uses bad cast from point of view of OOP.
Therefore, this patch make the sub classes implement the method only for each.

Differential Revision: https://phabricator.services.mozilla.com/D157406
2022-09-21 00:20:26 +00:00
Iulian Moraru 52da19beca Backed out 2 changesets (bug 1789967) for causing wd failures on content_editable.py. CLOSED TREE
Backed out changeset f2f431ee78a3 (bug 1789967)
Backed out changeset edac234f1eba (bug 1789967)
2022-09-21 04:40:46 +03:00
Masayuki Nakano 7f5b2e7242 Bug 1789967 - part 2: Make `TextEditor` and `HTMLEditor` implement `EditorBase::CollapseSelectionToEndOfLastLeafNode` by themselves r=m_kato
It does different thing for `TextEditor` and `HTMLEditor`, and used almost
internally.  Therefore, it should be implemented in the sub classes and
we should name them better.

Differential Revision: https://phabricator.services.mozilla.com/D157407
2022-09-21 00:38:23 +00:00
Masayuki Nakano 7f5a748878 Bug 1789967 - part 1: Make `TextEditor` and `HTMLEditor` implement `EditorBase::InitEditorContentAndSelection` by themselves r=m_kato
The method is enough simple, and uses bad cast from point of view of OOP.
Therefore, this patch make the sub classes implement the method only for each.

Differential Revision: https://phabricator.services.mozilla.com/D157406
2022-09-21 00:20:26 +00:00
Masayuki Nakano 8bbdf5e967 Bug 1784192 - part 9: Rename `TypeInState` to `PendingStyles` r=m_kato
Additionally,
* `PropItem` -> `PendingStyle`
* `StyleCache` -> `PendingStyleCache`
* `AutoStyleCacheArray` -> `AutoPendingStyleCacheArray`

And finally, `PendingStyle` (formally `PropItem`) is changed to `class` and
its members are encapsuled.

Differential Revision: https://phabricator.services.mozilla.com/D155318
2022-08-26 03:31:26 +00:00
Masayuki Nakano 94b817dc98 Bug 1785311 - Make `EditorBase::InsertTextIntoTextNodeWithTransaction` update insertion point after executing the transaction r=m_kato
Before the fix of bug 1758420, `TextComposition`'s text node and offset in it
are updated at creating `CompositionTransaction`.  However, it's now put off
until getting the mutations.  Therefore, it always unsets `pointToInsert` at
first time of the composition and fails to notify the listeners.

This patch makes it retrieve the result after calling `DoTransactionInternal`
and handle the post processing with the new point.

Differential Revision: https://phabricator.services.mozilla.com/D155052
2022-08-22 23:56:36 +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 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 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
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
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
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
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
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
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
Masayuki Nakano 458bf2e95e Bug 1730442 - part 1: Make all `nsITableEditor` features flush pending layout at start to handle their jobs r=m_kato
Our table editor depends on layout information for getting raw/column position
of a cell, checking rawspan/colspan information and table size.  Therefore,
they require the latest information, but they don't flush pending layout by
themselves.  Therefore, this patch makes them do it by themselves and deleting
unnecessary hack from their tests.

Differential Revision: https://phabricator.services.mozilla.com/D146359
2022-05-20 07:39:51 +00:00
Molnar Sandor 416e516586 Backed out 7 changesets (bug 1730442) for causing reftest failures in editor/reftests/inline-table-editor-position-after-updating-table-size-from-input-event-listener.html. CLOSED TREE
Backed out changeset f6d7f162e57a (bug 1730442)
Backed out changeset e5d1671b3bbc (bug 1730442)
Backed out changeset e60a5cd69184 (bug 1730442)
Backed out changeset 943d4e4b0770 (bug 1730442)
Backed out changeset bd3324b635f4 (bug 1730442)
Backed out changeset ada0dda5bcde (bug 1730442)
Backed out changeset b67c4035c12f (bug 1730442)
2022-05-17 04:23:36 +03:00
Masayuki Nakano 216035e16f Bug 1730442 - part 1: Make all `nsITableEditor` features flush pending layout at start to handle their jobs r=m_kato
Our table editor depends on layout information for getting raw/column position
of a cell, checking rawspan/colspan information and table size.  Therefore,
they require the latest information, but they don't flush pending layout by
themselves.  Therefore, this patch makes them do it by themselves and deleting
unnecessary hack from their tests.

Differential Revision: https://phabricator.services.mozilla.com/D146359
2022-05-17 00:12:08 +00:00
Daisuke Akatsuka b5b6e4360f Bug 1457149: Make Ctrl+Backspace behavior on text editor in Windows during text selection the same as other OS. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D146392
2022-05-16 09:30:29 +00:00