There is 2 overloads. One is `TextServicesDocument`'s method, and the latter is
for `nsIEditActionListener`. The latter could occur if `TextServicesDocument`
is added to the editor when there is no inline spellchecker, `EditorSpellCheck`
or `mozSpellChecker`.
https://searchfox.org/mozilla-central/rev/d2f8488b6a704443a5c5bfc6d2878171b5f0d393/editor/libeditor/EditorBase.cpp#2388,2391,2393,2396,2398
I don't know whether this is possible case, but unfortunately,
`nsIEditActionListener::DidJoinNodes()` is not implemented by JS and implemented
only by `TextServicesDocument`. Therefore, we can make it "noscript" and use
non-scriptable classes as arguments.
This patch makes them get jointed point and removed content node and the joining
direction for fixing bug 1735608. Unfortunately, there is no test framework
to check the result in `TextServicesDocument` nor the new path. The latter
should be tested when we fix bug 1735608 later.
Differential Revision: https://phabricator.services.mozilla.com/D130458
I'd like to split utilities for all editors and only for `HTMLEditor`.
This moves some trivial classes into new `HTMLEditHelpers.h`. Perhaps, it's
better if we can move them into `HTMLEditUtils.h`, but it has too many inline
method definitions so that adding new classes into it makes it much bigger.
Depends on D130349
Differential Revision: https://phabricator.services.mozilla.com/D130425
There is also a mozilla::intl::Locale in intl/locale/MozLocale.h. This naming
collision was causing crashes in debug builds where the wrong destructor ended
up being called. This patch renames the intl/locale/MozLocale.h class to
MozLocale.
I've filed Bug 1736017 to move callers of the MozLocale version to the
unified intl/components/Locale version.
Differential Revision: https://phabricator.services.mozilla.com/D128593
Currently, `mozInlineSpellChecker` handles events in the default group. This
means that the listener may not run if web app stops the propagation. For
keeping the event listener order as far as possible, this patch changes to
listen to the event at capturing phase in the system group (editor handles
the events at bubbling phase in the system group).
Additionally, it listens to `keypress` events for handling caret/selection
changes. However, they should be handled at `keydown` because those keys
are not printable. Therefore, this patch changes to listen to `keydown`
events, but this could change the race between running the scheduled spellcheck
and following `keypress` event which is dispatched only for chrome code and
C++ event listeners. However, this may not change it actually because the
race is changed only when the following `keypress` event delays too much.
https://searchfox.org/mozilla-central/rev/2eebd6e256fa0355e08421265e57ee1307836d92/extensions/spellcheck/src/mozInlineSpellChecker.cpp#503-504
Differential Revision: https://phabricator.services.mozilla.com/D126635
* Rename arguments so that their names are consistent with Next().
* Make the function not assert on an empty string, i.e. aLen == 0, like
Next().
* Fix an undefined behavior when the user passes aTextLen == aOffset.
The methods used to access `aText[aOffset]` that is clearly out of range
because the string may not be null-terminated. After this patch, it
returns a sentinel WordRange when aLen == aPos.
* Add document and gtest TestFindWordWithEmptyString().
* Change the sentinel return value to {aLen,aLen} for FindWord(), and
adapt one caller.
Differential Revision: https://phabricator.services.mozilla.com/D125434
This is a regression of bug 1311934. The traditional
`TextServicesDocument::IsBlockNode()` was wrong name, the users of the method
intent to check whether a word is not split by the found sibling. Therefore,
the method returned `true` for `<br>` element. However, of course,
`HTMLEditUtils::IsBlockElement()` is not so because of an inline element.
For making the callers clearer, this patch adds `<br>` element check into
each place. Without this patch, the new test fails to replace a misspelled
word immediately after `<br>` element.
Depends on D123283
Differential Revision: https://phabricator.services.mozilla.com/D123284
For keeping current behavior, the options should be set to
`HTMLEditUtils::ClosestEditableBlockElement`, but it may cause returning
`nullptr` if the text node is in an inline editing host, and also cause
returning true from the method even when the text nodes are in different
inline editing hosts. Therefore, this patch uses
`HTMLEditUtils::ClosestEditableBlockElementOrInlineEditingHost` instead.
Differential Revision: https://phabricator.services.mozilla.com/D122947
If array size grows up, the array data may be reallocated. Therefore, after
getting a reference of an array item, we shouldn't modify array.
This makes them use raw pointer if they need to modify the array. Otherwise,
keep using the reference, but adds a stack class to detect the bug only in debug
build.
Differential Revision: https://phabricator.services.mozilla.com/D122920
This is just a simple mistake, but I'm not sure how this break the callers.
Therefore, I don't have a testcase for this.
Differential Revision: https://phabricator.services.mozilla.com/D122705
When getting suggestions from spellchecker's result, we use sync IPC
(`PRemoteSpellcheckEngine.CheckAndSuggest`). This is used by showing context
menu only on Gecko. So I think that we can remove this IPC if we add async API
to get spellchecker suggestions.
And in comm-central's code, `CheckCurrentWord` and `GetSuggestedWord` seems to
use on spellchecker dialog (content/dialogs/EdSpellCheck.js in mail and suite)
that runs on parent process. So c-c won't use this IPC method.
So I would like to add the promise version of getting spellchecker's
suggestion.
Differential Revision: https://phabricator.services.mozilla.com/D119936
It handles selection indexes really roughly since it does it only when
start index is same or greater then removing index. So, only end index
may be greater than the removing index, and if the start index is 0, it
sets `-1` to selection start.
I don't find any other issues around setting selection indexes. However,
for detecting wrong selection index management, this patch adds
`MOZ_DIAGNOSTIC_ASSERT` to every setter.
Differential Revision: https://phabricator.services.mozilla.com/D121592
For consistency, between `TextServicesDocument` and `HTMLEditor`,
`TextServicesDocument::IsBlockNode()` should be replaced with
`HTMLEditUtils::IsBlockElement()` for making same consideration for each
element type.
Differential Revision: https://phabricator.services.mozilla.com/D119870
There are some methods in `TextServicesDocument` which work only with
`TextServicesDocument::mOffsetTable`. Once we move such methods to custom
class of `nsTArray<UniquePtr<OffsetEntry>>`, we can make `TextServicesDocument`
simpler.
Depends on D119157
Differential Revision: https://phabricator.services.mozilla.com/D119158
Now, it stores `dom::Text` with `OwningNonNull`. So, once it's leaked, it
wastes a lot of memory spaces. Therefore, we should make `mOffsetTable`
store `UniquePtr<OffsetEntry>` instead of `OffsetEntry*`.
Depends on D119156
Differential Revision: https://phabricator.services.mozilla.com/D119157
Now, the meaning of `OffsetEntry` is clear. Therefore, this patch adds comment
explaining the class and its members.
Then, the meaning of `TextServicesDocument::mSelStartOffset` and
`TextServicesDocument::mSelEndOffset` becomes clearer since they are used to
create `OffsetEntry` instances. Therefore, this patch renames them.
Depends on D119155
Differential Revision: https://phabricator.services.mozilla.com/D119156
Now, `mNode` is always a text node, and it may store across "can run script"
boundaries. So, it should be `OwningNonNull<Text>`.
Depends on D119148
Differential Revision: https://phabricator.services.mozilla.com/D119149
It seems that it treats mainly a text node in various places, but it's not
guaranteed by any variable declarations. So, first of all, I'd like to make
it clearer.
`TextServicesDocument::IsTextNode()` isn't necessary because `nsINode::IsText()`
is enough useful. And `AsText()` should be zero cost at runtime. So, in blocks
which guarantee specific content node is a text node, this patch appends
`AsText()` for making the code clearer.
Differential Revision: https://phabricator.services.mozilla.com/D119148
It should be treated as `uint32_t` since DOM API does so. However, there are
some exceptions:
* Result of `nsINode::ComputeIndexOf()`
* Result of `nsAString` methods
They return `-1` as not found, and anyway, they cannot treat large integer
than `INT32_MAX`. Therefore, this patch does not touch around them.
Differential Revision: https://phabricator.services.mozilla.com/D118933
For consistency with the similar internal DOM API, `As*()` should just cast
the type without checking editor type. Instead, `GetAs*()` should do it.
Differential Revision: https://phabricator.services.mozilla.com/D117381