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

10933 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 1cc969671c Bug 1758420 - part 2: Clean up update timing of `TextComposition` r=m_kato
Currently, it's done at creating `CompositionTransaction`, not after executing
it.  Let's clean it up now.

Differential Revision: https://phabricator.services.mozilla.com/D141194
2022-04-21 03:37:56 +00:00
Masayuki Nakano 5c4fed5f9d Bug 1758420 - part 1: Let `TextComposition` know where is changed in storing text node r=m_kato
`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
2022-04-21 03:37:56 +00:00
Masayuki Nakano 8b5390183f Bug 1765018 - part 7: Make some methods which return an instance (not reference) of `EditorDOMPointBase` be template methods r=m_kato
For avoiding to use `To<EditorDOMPoint>()` etc from temporary object, such
methods should be templated.

Differential Revision: https://phabricator.services.mozilla.com/D143884
2022-04-20 23:58:04 +00:00
Masayuki Nakano ef681f3a6c Bug 1765018 - part 6: Make `TypeInState::OnSelectionChange` stop using `EditorRawDOMPoint` r=m_kato
Using `EditorRawDOMPoint` in it just wastes conversion cost to `EditorDOMPoint`.

Differential Revision: https://phabricator.services.mozilla.com/D143883
2022-04-20 23:52:10 +00:00
Masayuki Nakano 9cd4ac5480 Bug 1765018 - part 5: Make `InsertText()` and `ReplaceText()` of `WhiteSpaceVisibilityKeeper` return `Result<EditorDOMPoint, nsresult>` r=m_kato
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
2022-04-20 23:52:09 +00:00
Masayuki Nakano 9968200d7c Bug 1765018 - part 4: Make `EditorBase::InsertTextWithTransaction` treat only `EditorDOMPoint` r=m_kato
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
2022-04-20 23:46:19 +00:00
Masayuki Nakano 19103784eb Bug 1765018 - part 3: Make `EditorBase::FindBetterInsertionPoint` be a template method r=m_kato
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
2022-04-20 23:41:28 +00:00
Masayuki Nakano d58e1b92f7 Bug 1765018 - part 2: Make `EditorBase::Get(Start|End)Point` return `EditorDOMPoint` or `EditorRawDOMPoint` r=m_kato
This avoids unnecessary conversion at the callers' side, although they should be
omitted by the complier.

Differential Revision: https://phabricator.services.mozilla.com/D143879
2022-04-20 23:35:18 +00:00
Masayuki Nakano 08b1fe0b20 Bug 1765018 - part 1: Get rid of implicit conversion between `EditorDOMPointBase` instances r=m_kato
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
2022-04-20 22:41:02 +00:00
Masayuki Nakano 1abcb1c46b Bug 1764866 - Add "mozilla/EditorForwards.h" r=m_kato
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
2022-04-20 14:46:16 +00:00
Masayuki Nakano 8dd67cabf0 Bug 1764684 - part 4: Make editor stop calling `SelectionRef().SetInterlinePosition` if followed by a call of `EditorBase::CollapseSelectionTo*` r=m_kato
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
2022-04-20 14:46:15 +00:00
Masayuki Nakano 73a2dbd211 Bug 1764684 - part 3: Fix and improve warnings of the result of `EditorBase::CollapseSelectionTo*` r=m_kato
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
2022-04-20 14:36:53 +00:00
Masayuki Nakano 17fc88e168 Bug 1764684 - part 2: Make editor use methods of `EditorBase` to collapse `Selection` r=m_kato
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
2022-04-20 14:36:52 +00:00
Masayuki Nakano fed61a245b Bug 1764684 - part 1: Make `EditorDOMPointBase` store `Selection::InterlinePosition` r=m_kato
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
2022-04-20 14:24:55 +00:00
Masayuki Nakano fc7b0ef770 Bug 1764679 - Make `GetInterlinePosition` and `SetInterlinePosition` work with new `enum class` r=smaug
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
2022-04-20 14:24:55 +00:00
Masayuki Nakano 36c2d519c8 Bug 1764238 - Backout the first and the second patch of bug 1758420 r=m_kato
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
2022-04-15 03:49:57 +00:00
Masayuki Nakano 53d56a6994 Bug 1763292 - Make `WhiteSpaceVisibilityKeeper::NormalizeVisibleWhiteSpacesAt` check the DOM tree after inserting a `<br>` element r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D143016
2022-04-15 02:24:55 +00:00
Masayuki Nakano 7ee35a6ae4 Bug 1761395 - part 5: Make `HTMLEditor::SplitNode(Deep)WithTransaction` callers refer `SplitNodeResult` for post-processing r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D142416
2022-04-05 07:02:46 +00:00
Masayuki Nakano b54dffa7c3 Bug 1761395 - part 4: Rewrite `HTMLEditor::SplitMailCiteElements` r=m_kato
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
2022-04-05 06:53:23 +00:00
Masayuki Nakano 9a5e601a7b Bug 1761395 - part 3: Make `HTMLEditor::SplitParagraph` refer result of `SplitNodeDeepWithTransaction` for its post-processing r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D142414
2022-04-05 06:32:02 +00:00
Masayuki Nakano 9cf21bf42a Bug 1761395 - part 2-2: Make `HTMLEditor::HandleInsertParagraphInHeadingElement` refer result of `SplitNodeDeepWithTransaction` for its post-processing r=m_kato
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
2022-04-05 06:17:43 +00:00
Masayuki Nakano 979284eab1 Bug 1761395 - part 2-1: Clean up `HTMLEditor::HandleInsertParagraphInHeadingElement()` r=m_kato
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
2022-04-05 06:05:05 +00:00
Masayuki Nakano d7bb598bdb Bug 1761395 - part 1-4: Make `HTMLEditor::CopyLastEditableChildStylesWithTransaction()` return `Result` r=m_kato
This is not directly related to this bug, but it's a helper class of
`HandleInsertParagraphInListItemElement()`.

Differential Revision: https://phabricator.services.mozilla.com/D142411
2022-04-05 05:25:50 +00:00
Masayuki Nakano 3da5ef2528 Bug 1761395 - part 1-3: Make `HTMLEditor::HandleInsertParagraphInListItemElement` refer `SplitNodeDeepWithTransaction` result at post-processing r=m_kato
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
2022-04-05 05:15:05 +00:00
Masayuki Nakano df5eac98a9 Bug 1761395 - part 1-2: Make the last part of `HTMLEditor::HandleInsertParagraphInListItemElement()` use early return style r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D142409
2022-04-05 03:52:16 +00:00
Masayuki Nakano de7feda8e7 Bug 1761395 - part 1-1: Rewrite `HTMLEditor::HandleInsertParagraphInListItemElement` to returning `Result` r=m_kato
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
2022-04-05 03:19:10 +00:00
Masayuki Nakano 6368a7e00a Bug 1761159 - Make constructors of `SplitNodeResult` take content nodes with logical meaning rather than physical meaning r=m_kato
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
2022-03-25 01:00:36 +00:00
Dan Minor 64d31d44db Bug 1761273 - Check for multiple dictionaries when saving site preferences; r=smaug
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
2022-03-24 22:29:42 +00:00
Dan Minor d55f7cc649 Bug 1402822 - Add mochitest for multiple dictionaries; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D140246
2022-03-23 13:53:39 +00:00
Dan Minor 337bc15035 Bug 1402822 - Update unit tests for multiple dictionaries; r=smaug
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
2022-03-23 13:53:39 +00:00
Dan Minor 0f00bde70a Bug 1402822 - Support multiple dictionaries in EditorSpellCheck; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D140243
2022-03-23 13:53:38 +00:00
Makoto Kato 41034a8ef5 Bug 1760725 - Remove unused members in FilteredContentIterator. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D141707
2022-03-22 04:15:39 +00:00
Masayuki Nakano bcfed4eede Bug 1759370 - The lambda in `HTMLEditor::InsertAsPlaintextQuotation` should not refer inserting new <span> element's parent r=m_kato
It's not been inserted into the DOM tree yet.  Therefore, it should refer the
insertion point instead.

Differential Revision: https://phabricator.services.mozilla.com/D141449
2022-03-18 08:34:44 +00:00
Masayuki Nakano fd40906504 Bug 1759885 - Default callback for initializing new element should be static r=m_kato
This decreases the binary size of xul.dll of debug build on Windows 3KB.

Depends on D141447

Differential Revision: https://phabricator.services.mozilla.com/D141448
2022-03-18 07:20:52 +00:00
Masayuki Nakano 5990ed6b84 Bug 1759885 - Make initializers of new element in `HTMLEditor` stop capturing everything r=m_kato
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
2022-03-18 07:20:52 +00:00
Masayuki Nakano 551381e3cd Bug 1759816 - Create `EditorDOMPointBase<PT, CT>::ParentPoint()` for avoiding warning spam caused by no necessary checks r=m_kato
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
2022-03-18 07:02:32 +00:00
Masayuki Nakano 728a229d8e Bug 1758420 - part 3: Rename `TextComposition::GetStartRef()` and `TextComposition::GetEndRef()` r=m_kato
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
2022-03-18 06:34:47 +00:00
Masayuki Nakano 6ff8aab6e3 Bug 1758420 - part 2: Clean up update timing of `TextComposition` r=m_kato
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
2022-03-18 06:34:47 +00:00
Masayuki Nakano ac604dec5a Bug 1725850 - part 35: Port editor/libeditor/crashtests/766305.html to WPT r=saschanaz
Depends on D141327

Differential Revision: https://phabricator.services.mozilla.com/D141328
2022-03-18 01:17:56 +00:00
Masayuki Nakano 9dc7efb70c Bug 1725850 - part 34: Port editor/libeditor/crashtests/762103.html to WPT r=saschanaz
Depends on D141326

Differential Revision: https://phabricator.services.mozilla.com/D141327
2022-03-18 01:17:56 +00:00
Masayuki Nakano 9fc3812c72 Bug 1725850 - part 33: Port editor/libeditor/crashtests/761861.html to WPT r=saschanaz
Depends on D141325

Differential Revision: https://phabricator.services.mozilla.com/D141326
2022-03-18 01:17:56 +00:00
Masayuki Nakano 96b7db4e1d Bug 1725850 - part 32: Port editor/libeditor/crashtests/759748.html to WPT r=saschanaz
Depends on D141324

Differential Revision: https://phabricator.services.mozilla.com/D141325
2022-03-18 01:17:55 +00:00
Masayuki Nakano deec94ef95 Bug 1725850 - part 31: Port editor/libeditor/crashtests/745494.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D141324
2022-03-18 01:17:55 +00:00
Emilio Cobos Álvarez 11a8108d96 Bug 1759602 - Make outline-style: auto the default focus outline. r=mstange
As per spec: https://html.spec.whatwg.org/#phrasing-content-3

This should generally be better as it is a better outline to begin with,
and allows us to customize it a bit in the future.

Differential Revision: https://phabricator.services.mozilla.com/D141051
2022-03-16 23:27:19 +00:00
Eitan Isaacson d4418e9378 Bug 1713050 - P1: Add granularity to selection change notification. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D139745
2022-03-16 05:56:25 +00:00
Masayuki Nakano c98a4265f6 Bug 1742933 - part 12: Make all `aInitializer` arguments optional r=m_kato
For making the callers simpler, they should be able to be omitted if they
want to do nothing.

Differential Revision: https://phabricator.services.mozilla.com/D140701
2022-03-11 09:21:36 +00:00
Masayuki Nakano 75a4321f48 Bug 1742933 - part 11: Create a pref to get back the traditional behavior r=m_kato
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
2022-03-11 09:21:36 +00:00
Masayuki Nakano 5de9964c0b Bug 1742933 - part 10: Make `HTMLEditor::InsertAsCitedQuotationInternal()` set attributes of `<blockquote>` before connecting it to the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140474
2022-03-11 09:21:36 +00:00
Masayuki Nakano 74b9376c5e Bug 1742933 - part 9: Make `HTMLEditor::InsertAsPlaintextQuotation()` set attributes of `<span>` before connecting to the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140473
2022-03-11 09:14:37 +00:00
Masayuki Nakano c0fa3848af Bug 1742933 - part 8: Make `HTMLEditor::PasteAsQuotationAsAction()` set "type" attribute of new blockquote element before connecting it to the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140472
2022-03-11 09:14:36 +00:00