`IMEContentObserver` observes the text node change which contains the current
composition string. Therefore, it can let `TextComposition` know where is
updated by web apps and adjust offset and length in the text node.
Differential Revision: https://phabricator.services.mozilla.com/D141193
Aligning to `EditorBase::InsertTextWithTransaction`, these methods should return
`Result<EditorDOMPoint, nsresult>` rather than taking an out param.
Differential Revision: https://phabricator.services.mozilla.com/D143882
In theory, methods which touch the DOM tree should take `EditorDOMPoint` rather
than `EditorRawDOMPoint`. And now, we can return meaningful value if it
succeeded, with `Result`.
Therefore, this patch makes it return `Result<EditorDOMPoint, nsresult>` instead
of taking an out argument, and take only `EditorDOMPoint` rather than taking any
type of `EditorDOMPointBase` since it's always converted to `EditorDOMPoint`.
Differential Revision: https://phabricator.services.mozilla.com/D143881
To avoid the unnecessary conversion between `EditorDOMPoint` and
`EditorRawDOMPoint`, it should be a template method which can take/return either
`EditorDOMPoint` or `EditorRawDOMPoint`.
Differential Revision: https://phabricator.services.mozilla.com/D143880
The implicit copy constructors and `operator=` makes it harder to realize
that implicit conversion wastes the runtime cost. Therefore, this patch
replaces them with a template method to convert the `EditorDOMPointBase` type.
Differential Revision: https://phabricator.services.mozilla.com/D143878
Headers in editor module has a lot of forward declarations for avoiding the
include hell and has a lot of helper template classes.
Forward declarations of template classes is really messy and I'd want to
avoid the duplication because it blocks changing template class. Therefore,
centralizing forward declarations makes the headers cleaner and maintaining
template classes easier. Therefore, this patch adds a new header file which
has only forward declarations and some aliases.
It'd be better to define `enum class`es in it like `EventForwards.h` for
reducing the dependencies between headers, but currently this does not do it
for making the new file simpler as far as possible.
Removing `EditActionListener.h` is because it's unused.
Removing `AutoTopLevelEditSubActionNotifier` is because it's renamed to
`AutoEditSubActionNotifier`.
https://hg.mozilla.org/mozilla-central/rev/6de55c5b5f8d5f92389d0d244d2bced1f979ade9
Differential Revision: https://phabricator.services.mozilla.com/D143817
Now, `EditorBase::CollapseSelectionTo*()` set the interline position if it's
explicitly set to the `EditorDOMPointBase` parameter. Therefore, editor should
use the feature as far as possible instead of calling
`Selection::SetInterlinePosition` directly.
Differential Revision: https://phabricator.services.mozilla.com/D143816
Some of them were `HTMLEditor` so that we need to fix it to `EditorBase`, and
also this patch fixes `NS_ERROR_EDITOR_DESTROYED` handling around them.
Differential Revision: https://phabricator.services.mozilla.com/D143815
First, move methods of `HTMLEditor` which collapse `Selection` to `EditorBase`.
Then, make editor stop accessing `Selection::CollapseInLimiter` directly.
Differential Revision: https://phabricator.services.mozilla.com/D143814
When `HTMLEditor::CollapseSelectionTo` etc is called, interline position should
be set automatically. Then, we can get rid of duplicated code. Unfortunately,
this may increase the instance size, but I believe that the merit is valuable
because `EditorDOMPoint` should not be in the heap for a long time in so many
cases (perhaps, mainly in some transaction classes).
Differential Revision: https://phabricator.services.mozilla.com/D143813
It's hard to remember what the `bool` value of them means. Therefore, there
are a lot of comment around the API users to explain what they do. For making
it clearer and reducing the risk of specifying opposite value, they should work
with an `enum class`.
Differential Revision: https://phabricator.services.mozilla.com/D143812
Due to breaking `mobile.twitter.com/explore` for Hebrew IME users on Android,
this patch backs out the patches for bug 1753420 except the last patch which
just rename some methods and variables.
Differential Revision: https://phabricator.services.mozilla.com/D143684
This patch renames it to `HandleInsertParagraphInMailCiteElement` to explain
what it does clearer. And make it takes most-distant ancestor mail-cite
element to avoid the situation that it does nothing.
Then, this is rewritten to just return new caret position where is new
`<br>` element which is inserted at the split point.
Then, only the last block is changed to refer the split node result to
avoid deleting same node in the case of new split direction.
Differential Revision: https://phabricator.services.mozilla.com/D142415
It assumes that `aHeadingElement` is always the right node after split.
However, it'd be changed. Therefore, this patch makes it refer the result
of `SplitNodeDeepWithTransaction` instead.
Differential Revision: https://phabricator.services.mozilla.com/D142413
Similar to part 1-1, but this shouldn't change any behavior of the method except
the case that the editor is destroyed during a call of `CollapseSelectionTo`.
Differential Revision: https://phabricator.services.mozilla.com/D142412
It assumes that `aListItemElement` is always right element after splitting it.
However, it will be not so, and it scans its previous list item element from
`aListItemElement` after splitting it to get the left list item element and
it **may** be different list item element if mutation event listeners inserts
other things before `aListItemElement`.
Therefore, referring the result of `SplitNodeDeepWithTransaction` does make
sense for supporting both split node directions.
Differential Revision: https://phabricator.services.mozilla.com/D142410
Its body is too long, and it takes care of selection. For reducing its job,
let's make it return point to put caret.
Basically, this patch does not change the behavior. However, if mutation event
listeners change the DOM tree while this method runs, the behavior may be
different from current builds because of stricter error checks.
Differential Revision: https://phabricator.services.mozilla.com/D142408
Like `JoinNodesResult`, `SplitNodeResult` should take 2 content nodes as
"new one" and "original one" instead of "previous one" and "next one".
Then, the creators is easier to read.
Additionally, this patch creates some static methods and converter method
to create a result with explaining the result meaning.
Differential Revision: https://phabricator.services.mozilla.com/D141930
We only want to save the site preferences when the user's dictionary
preferences do not match the preferred language for the site. This is always
the case when there is more than one dictionary in use, but the current
code does not handle this case.
Differential Revision: https://phabricator.services.mozilla.com/D141981
For the most part these are simple updates to account for multiple
dictionaries and the fact that SetDictionaries is async whereas
SetDictionary was sync.
Fixing test_async_UpdateCurrentDictionary was more involved because
there were flaws in the existing test and it is more difficult to
harmonize the UpdateCurrentDictionary callback with the changes to make
SetDictionaries async.
Differential Revision: https://phabricator.services.mozilla.com/D140245
Capturing everything causes increasing the binary size especially of debug
build so that we should add more arguments to the callback and make some
lambda methods capture individual variables when they are necessary.
Note that nobody uses the 3rd argument, `aPointToInsert`, it'll be used to
fix bug 1759370 and makes the change smaller.
This decreases the size of xul.dll of debug build on Windows 123MB from 323MB.
I tried to delete all captures from the lambdas, but it does not affect to the
binary size and it makes the code harder to read, killing static analysis.
Therefore, we should not do it.
Depends on D141196
Differential Revision: https://phabricator.services.mozilla.com/D141447
When setting a point, the child must be `nsIContent`. However, climbing up
the tree from a point with `EditorDOMPointBase<PT, CT>`, it may reach top of
the DOM tree (fragment). Then, we'd get a warning which wouldn't hit in
usual cases. Therefore, we should add new API to get parent point of an
`EditorDOMPointBase<PT, CT>` instance and it should check properly before
creating new instance.
Differential Revision: https://phabricator.services.mozilla.com/D141196
They return IME selection range rather than composition string range. I.e.,
when the composition does not have IME selections anymore, e.g., at committing,
they return non-set `RawRangeBoundary`.
For making the result meaning clearer, they should be
`FirstIMESelectionStartRef` and `LastIMESelectionEndRef`.
Depends on D141194
Differential Revision: https://phabricator.services.mozilla.com/D141195
Currently, it's done at creating `CompositionTransaction`, not after executing
it. Let's clean it up now.
Depends on D141193
Differential Revision: https://phabricator.services.mozilla.com/D141194
For avoiding simple back-out of the patches when we get serious regression
reports, we should have a pref to disable the new pref.
Differential Revision: https://phabricator.services.mozilla.com/D140475