It does not check whether it meets a non-editable parent or not. Therefore,
it may cross another editing host boundary when `aContent` is in a nested
editing host.
So, this patch fixes some edge cases when editing hosts are nested and
scanning from inner editing host.
Differential Revision: https://phabricator.services.mozilla.com/D122940
There are a lot of ancestor scanners in `HTMLEditUtils`. This is good thing
for the performance, but it makes us hard to maintain. Therefore, we should
merge them as far as possible.
Differential Revision: https://phabricator.services.mozilla.com/D122939
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
They clean up the tail of descendant block first. At this time, running script
may change one of or both of the left block element and the right block element.
In such situation, they should stop handling to join the blocks because of
unexpected case.
Depends on D122562
Differential Revision: https://phabricator.services.mozilla.com/D122565
It tries to delete a text node if it's invisible both selection start and
selection end. However, the selection range may be in a text node. If it's
an invisible, the node is deleted at first call of
`DeleteNodeIfInvisibleAndEditableTextNode()`, but it keep trying to remove
again with same method.
Differential Revision: https://phabricator.services.mozilla.com/D122561
The test causes different assertion count between platforms. As the comment in
crashtests.list, the difference is whether "removeList" command enabled check
is run at getting focus or not. Perhaps, the difference is caused by whether
HTML commands are initialized before or after executing "indent" command.
Differential Revision: https://phabricator.services.mozilla.com/D122546
`WSRunScanner::ScanNextVisibleNodeOrBlockBoundary()` is designed for scanning
editable content so that it's wrong to use it for scanning first editable leaf
node.
Differential Revision: https://phabricator.services.mozilla.com/D122479
It tries to replace a following NBSP with an ASCII white-space if there is.
However, it calls the scan method with start of the replacing range. Therefore,
the assertion in `GetInclusiveNextNBSPPointIfNeedToReplaceWithASCIIWhiteSpace()`
detects this bug.
Note that this occurs only when updating composition string because it's
called with non-collapsed range only for doing it. Otherwise, selected range
has already been deleted by `HTMLEditor::DeleteSelectionAsSubAction()`.
Unfortunately, I don't have how to make this bug appear. It seems that the
path does nothing in the wild because it tries to replace a first character
of composition string from an NBSP to a normal white-space, but it'll be
replaced with new composition string anyway. Therefore, this patch does not
have new tests.
Differential Revision: https://phabricator.services.mozilla.com/D122182
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
This will make implementing the new behavior behind a pref
really straight-forward, and is generally nicer.
Depends on D121858
Differential Revision: https://phabricator.services.mozilla.com/D121705
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
Web apps can modify normal selection even during IME composition and no
browsers stop composition by it. However, our editor tries to delete
non-collapsed selected range before updating composition. Therefore,
we need additional state at handling inserting text whether selection
should be deleted or ignored.
Depends on D121371
Differential Revision: https://phabricator.services.mozilla.com/D121372
Previously, `HTMLEditor::GetBetterInsertionPoint()` didn't check whether
given point is in an editing host or not. However, now
`HTMLEditUtils::GetBetterInsertionPoint()` does it with editing host which
is returned by `HTMLEditor::GetActiveEditingHost(LimitInBodyElement::No)`.
However, the old behavior is exactly same as
`HTMLEditor::GetActiveEditingHost(LimitInBodyElement::Yes)` if editing host
is outside the `<body>` element.
For taking back the original behavior, we should call the method with the
result of the latter.
Differential Revision: https://phabricator.services.mozilla.com/D121370
The function tests whether `input` event whose `inputType` is `insertFromPaste`
or not and it waits the event until timeout. This sometimes fails in my
environment, and `input` event should be fired synchronously in this case.
Therefore, it should just fail if the event isn't fired.
Depends on D120424
Differential Revision: https://phabricator.services.mozilla.com/D120425
Oddly, clipboard related test randomly (and frequently) fails in my environment.
And `test_pasting_table_rows.html` does not handle exception which is thrown
by `SimpleTest.promiseClipboardChange`. Therefore, I'm always waiting 5 mins
when I run all tests under `editor/libeditor/tests`.
Therefore, I'd like to make it abort remaning tests if it fails due to
an unexpected exception.
Additionally, this fixes a bug in `_copyToClipboard#validatorFn`. This method
modifies the variable of the parent function, `aExpectedPastedHTML`, with
itself. Therefore, when the function is called multiple times, the expected
string will be re-wrapped with `kTextHtmlPrefixClipboardDataWindows` and
`kTextHtmlSuffixClipboardDataWindows` again and again...
Differential Revision: https://phabricator.services.mozilla.com/D120424
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
It checks default `font-family` with editing commands, but it depends on the
system locale. ("serif" vs. "sans-serif"). So, its `<body>` should be styled
as `font-family: serif` for consistent behavior in any environment.
Differential Revision: https://phabricator.services.mozilla.com/D119871
`EventStateManager` gives up to track gesture to start a drag if mouse down
content which is stored in `mGestureDownFrameOwner` gets lost its primary frame.
When user tries to start to drag selected text in `<input>` or `<textarea>`
element, mouse down content is an anonymous node in `TextControlElement`. So,
if a reflow occurs after `mousedown` event, the anonymous `<div>` element
is replaced with new one and `EventStateManager` gives up to track it.
Therefore, this patch makes `EventStateManager` do similar things as
`nsBaseDragService`. When `nsTextControlFrame` notifies of remove/add
the anonymous nodes, `EventStateManager` tries to keep tracking gesture with
a new anonymous node.
Differential Revision: https://phabricator.services.mozilla.com/D119488
When `nsTextControlFrame` is reframed, `TextEditor`, anonymous `<div>`, its
`Text` and the independent `Selection`s are deleted temporarily and recreated
them.
If users are dragging text in `<input>` or `<textarea>`, the drag session's
source node is set to the anonymous text node in the element and the selection
is set to the independent selection. So, if the element is reframed during a
drag, the source node is disconnected from the document and `EndDragSession`
failed to dispatch `eDragEnd` event.
Therefore, this patch makes `nsTextControlFrame` replaces the source node and
selection when it's recreated and only when the drag session's original source
node was in the text control element. For checking which text control had the
anonymous text node, this patch makes `nsTextControlFrame` replaces source
node with the `<input>` or `<textarea>` element when the frame is destroyed.
Differential Revision: https://phabricator.services.mozilla.com/D119487
With IIEF, we can guarantee each test block isolated. So, without declaring
semi-global variables a lot for all tests, developers can comment out every
tests to debug only one thing.
Differential Revision: https://phabricator.services.mozilla.com/D119486
When the test is timed out, there is a JS error which is thrown by
`synthesizePlainDragAndDrop`. So, first, make the test handle exception
with `try-catch` and assert the error.
Differential Revision: https://phabricator.services.mozilla.com/D119485
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
`beforeinput` event was shipped and it won't be disabled for avoiding confusion
of web developers. So, we can drop the pref setting of
"dom.input_events.beforeinput.enabled" in our tests.
Depends on D119716
Differential Revision: https://phabricator.services.mozilla.com/D119729
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